elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Únete al Grupo Steam elhacker.NET


  Mostrar Mensajes
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 [13]
121  Programación / Scripting / Re: Dudas con con partes de mi script [Bash] en: 1 Mayo 2010, 08:43 am
Todos los script de instalacion de programas que hay usan IF's, de todos los que he mirado ninguno tiene case ya que no te deja elegir varias opciones a la vez y eso en los programas es ineficiente para eso lo haces escribiendolo y si te parece ineficiente el codigo no se lo va a parecer a todo el mundo lo mismo, yo he publicado esto para saber donde tengo el error no para que me digan que el codigo es ineficiente y que uso demasiados IF's es que todos los script de instalacion usan IF's ninguno usaba "case"
122  Programación / Scripting / Dudas con con partes de mi script [Bash] en: 30 Abril 2010, 19:56 pm
Hola buenas, estoy haciendo un script para ubuntu para la version 10.04, la gente sabra que ya ha salido la ultima version, bien decidi probar el script, pos hay partes que no me furulan y tenian que ser las partes mas importantes del programa, ire poniendo las partes de los que no me funcionan


Código
  1. #!/bin/bash
  2.  
  3. pog=`zenity --title="P.A.U" --text="Seleccione los programas que desee instalar" --width="1000" --height="900" \
  4. --list --column="Select" --column="Opciones" \
  5. --checklist TRUE "Wine" TRUE "Gimp"  \
  6. TRUE "Pidgin" TRUE "Chromium" TRUE "Compizfusion" TRUE "AWN"  TRUE "Docky"  TRUE "GnomeDo"  TRUE "Inkscape"  \
  7. TRUE "Eclipse"  TRUE "Netbeans"  TRUE "Vim" TRUE "Skype" TRUE "K3B"  TRUE "Mozilla Thunderbird" TRUE "Amule" \
  8. TRUE "Tucan Manager" TRUE "Vlc" TRUE "Comix" FALSE "K3b.Con las librerias de KDE" TRUE "JDownloader" \
  9. TRUE "Amarok" TRUE "Atool" TRUE "Guake" TRUE "Emesene" TRUE "Gparted" TRUE "Google Chrome" TRUE "Virtualbox" \
  10. TRUE "Hoz"  TRUE "Dvd::rip" TRUE "Avidemux" FALSE "Yakuake.Para KDE" TRUE "Alltray"`
  11. if [ $? -eq 0 ]
  12. then
  13. for i in $pog ; do
  14. echo ""
  15. echo "Has elegido la opcion $i"
  16. if [ "$i" = "Wine" ]
  17. then
  18. echo "chekpoint"
  19. sudo apt-get -y install wine
  20. clear
  21. fi
  22. if [ "$i" = "Gimp" ]
  23. then
  24. echo "checkpoint"
  25. sudo sh -cecho "deb http://ppa.launchpad.net/matthaeus123/mrw-gimp-svn/ubuntu lucid main" >> /etc/apt/sources.list” && sudo apt-key adv –recv-keys –keyserver keyserver.ubuntu.com 405A15CB && sudo apt-get update && sudo apt-get -y install gimp
  26. clear
  27. fi
  28. if [ $i = "Pidgin" ]
  29. then
  30. sudo add-apt-repository ppa:pidgin-developers && sudo apt-get update && sudo aptitude -y install pidgin
  31. clear
  32. fi
  33. if [ $i = "Chromium" ]
  34. then
  35. sudo add-apt-repository ppa:chromium-daily/ppa && sudo apt-get update && sudo apt-get -y install chromium-browser chromium-browser-l10n
  36. clear
  37. fi
  38. if [ $i = "Compizfusion" ]
  39. then
  40. sudo add-apt-repository ppa:compiz && sudo apt-get update && sudo aptitude -y install simple-ccsm compizconfig-settings-manager emerald && install fusion-icon
  41. clear
  42. fi
  43. if [ $i = "AWN" ]
  44. then
  45. sudo apt-get update && sudo apt-get -y install avant-window-navigator awn-extras-applets
  46. clear
  47. fi
  48. if [ $i = "Docky" ]
  49. then
  50. sudo add-apt-repository ppa:ricotz/testing && sudo apt-get update && sudo apt-get -y install docky
  51. clear
  52. fi
  53. if [ $i = "GnomeDo" ]
  54. then
  55. sudo add-apt-repository ppa:do-core && sudo apt-get update && sudo apt-get -y install gnome-do gnome-do-docklets gnome-do-plugins
  56. clear
  57. fi
  58. if [ $i = "Inkscape" ]
  59. then
  60. sudo aptitude -y install inkscape
  61. clear
  62. fi
  63. if [ $i = "Eclipse" ]
  64. then
  65. sudo aptitude -y install eclipse
  66. clear
  67. fi
  68. if [ $i = "Netbeans" ]
  69. then
  70. sudo aptitude -y install netbeans
  71. clear
  72. fi
  73. if [ $i = "Vim" ]
  74. then
  75. sudo aptitude -y install vim
  76. clear
  77. fi
  78. if [ $i = "Skype" ]
  79. then
  80. cd /tmp      
  81. wget http://download.skype.com/linux/skype-ubuntu-intrepid_2.1.0.81-1_${arch}.deb                          
  82. sudo dpkg -i --force-all skype-ubuntu-intrepid_2.1.0.81-1_${arch}.deb                          
  83. sudo apt-get -y --force-yes install -f -y                          
  84. rm skype-ubuntu-intrepid_2.1.0.81-1_${arch}.deb
  85. clear
  86. fi
  87. if [ $i = "K3B" ]
  88. then
  89. sudo aptitude -y install k3b
  90. clear
  91. fi
  92. if [ $i = "Mozilla Thunderbird" ]
  93. then
  94. sudo aptitude -y install  mozilla-thunderbird thunderbird-locale-es-es
  95. clear
  96. fi
  97. if [ $i  = "Amule" ]
  98. then
  99. sudo aptitude -y install amule
  100. clear
  101. fi
  102. if [ $i = "Tucan Manager" ]
  103. then
  104. sudo aptitude -y install tucan
  105. clear
  106. fi
  107. if [ $i = "Vlc" ]
  108. then
  109. sudo add-apt-repository ppa:c-korn && sudo apt-get update && sudo apt-get -y install vlc
  110. clear
  111. fi
  112. if [ $i = "Comix" ]
  113. then
  114. sudo aptitude -y install comix
  115. clear
  116. fi
  117. if [ $i = "K3b.Con las librerias de KDE" ]
  118. then
  119. sudo aptitude install k3b && sudo aptitude -y install kde-i18n-es k3b-i18n
  120. clear
  121. elif [ $i = "JDownloader" ]
  122. then
  123. wget http://212.117.163.148/jd.sh
  124. chmod +x jd.sh
  125. sh jd.sh
  126. java -jar ~/.jd/JDownloader.jar
  127. clear
  128. fi
  129. if [ $i = "Amarok" ]
  130. then
  131. sudo add-apt-repository ppa:kubuntu-ppa/backports && sudo apt-get update && sudo apt-get -y install amarok
  132. clear
  133. fi
  134. if [ $i = "Atool" ]
  135. then
  136. sudo aptitude -y install atool
  137. clear
  138. fi
  139. if [ $i = "Guake" ]
  140. then
  141. sudo apt-get -y install guake
  142. clear
  143. fi
  144. if [ $i = "Emesene" ]
  145. then
  146. sudo apt-get -y install emesene
  147. clear
  148. fi
  149. if [ $i = "Gparted" ]
  150. then
  151. sudo aptitude -y install gparted
  152. clear
  153. fi
  154. if [ $i = "Google Chrome" ]
  155. then
  156. sudo add-apt-key ppa:chromium-daily/ppa && sudo apt-get update && sudo apt-get -y install chromium-browser
  157. clear
  158. fi
  159. if [ $i = "Virtualbox" ]
  160. then
  161. cd /etc/apt/
  162. echo "deb http://download.virtualbox.org/virtualbox/debian karmic non-free" >> sources.list
  163. wget -q http://download.virtualbox.org/virtualbox/debian/sun_vbox.asc -O- | sudo apt-key add -
  164. if [ "i686" = `uname -m` ]
  165. then
  166. cd /home/$USER/
  167. wget http://download.virtualbox.org/virtualbox/3.1.6/virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  168. dpkg -i --force-all virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  169. sudo apt-get install -f -y
  170. rm virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  171. else
  172. cd /home/$USER/
  173. wget http://download.virtualbox.org/virtualbox/3.1.6/virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  174. dpkg -i --force-all virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  175. sudo apt-get install -f -y
  176. rm virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  177. fi
  178. fi
  179. if [ $i = "Hoz" ]
  180. then
  181. sudo apt-get -y install hoz-gui
  182. fi
  183. if [ $i = "Dvd::rip" ]
  184. then
  185. sudo aptitude -y install transcode && sudo aptitude -y install dvdrip
  186. fi
  187. if [ $i = "Avidemux" ]
  188. then
  189. sudo aptitude -y install avidemux
  190. fi
  191. if [ $i = "Yakuake.Para KDE" ]
  192. then
  193. sudo aptitude -y install yakuake
  194. fi
  195. if [ $i = "Alltray" ]
  196. then
  197. sudo aptitude -y install alltray
  198. fi
  199. done
  200. fi
  201.  

Causas: Esta parte va bien pero cuando eligo varias opciones no se instala ningun programa

Código:
Has elegido la opcion Wine|Gimp

Siguiente

Código
  1. upd=`zenity --title="Actualizar" --text="Has seleccionado Actualizar, Limpiar\n. Hay dos tipos de actualizaciones una normal y otro mas sostificado.\n Si acabas de instalar mejor haz una sostificada. \n Al contrario si lo tenias instalado haz una normal.\n O si deseas limpiar los paquetes innecesarios de tu sistema."  \
  2.    --width="500" --height="450" \
  3.      --list --column="Select" --column="Opciones" \
  4.            --checklist FALSE "Actualizacion normal" FALSE "Actualizacion sostificada" FALSE "Limpiar Ubuntu"`
  5. if [ $? -eq 0 ]
  6. then
  7. for updopc in $upd
  8. do
  9. if [ $updopc = "Actualizacion normal" ]
  10. then
  11. zenity --info --title="INFO" --text="Este proceso lo mas seguro que no tarde mucho.\n Espere a que salga la ventana de informacion"
  12. sudo aptitude update && sudo apt-get update
  13. sleep 2
  14. zenity --info --title="INFO" --text="Ya se ha actualizado su sistema"
  15. clear
  16. break
  17. elif [ $updopc = "Actualizacion sostificada" ]
  18. then
  19. echo ""
  20. zenity --info --title="INFO" --text="Este proceso puede que tarde mucho, espere a que te salga la ventana\n de informacion"
  21. sudo aptitude update && sudo apt-get update
  22. sudo aptitude upgrade && sudo apt-get upgrade
  23. zenity --info --title="INFO" --text="Ya se ha actualiza tu sistema"
  24. sleep 2
  25. clear
  26. fi
  27. if [ $updopc = "Limpiar Ubuntu" ]
  28. then
  29. echo "chekpoint"
  30. zenity --info --title="Limpieza.." --text="Ahora empezara la limpieza de Ubuntu"
  31.     sudo apt-get autoremove && sudo apt-get autoclean && sudo apt-get clean
  32.     OLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}')
  33.     CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
  34.     LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"
  35.     METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
  36.     OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)
  37.     YELLOW="\033[1;33m"
  38.     RED="\033[0;31m"
  39.     ENDCOLOR="\033[0m"
  40.     zenity --info --title="Limpiando" --text="$YELLOW""Cleaning apt cache...""$ENDCOLOR"
  41.     sudo aptitude clean
  42.     zenity --info --title="Limpiando" --text="$YELLOW""Removing old config files...""$ENDCOLOR"
  43.     sudo aptitude purge $OLDCONF
  44.     zenity --info --title="Limpiando" --text="$YELLOW""Removing old kernels...""$ENDCOLOR"
  45.     sudo aptitude purge $OLDKERNELS
  46.     zenity --info --title="Limpiando" --text="$YELLOW""Emptying every trashes...""$ENDCOLOR"
  47.     rm -rf /home/*/.local/share/Trash/*/** &> /dev/null
  48.     rm -rf /root/.local/share/Trash/*/** &> /dev/null
  49.     clear
  50.     mop=`zenity --title="P.A.U" --text="¿Tenia usted instalado mozilla-thunderbird?" \
  51. --list --column="Select" --column="Opcion" \
  52. --checklist FALSE "SI" FALSE "NO"`
  53.  
  54. fi
  55. done
  56. fi
  57.  

Su error que cuando se selecciona una opcion no se ejecuta y no se me ocurre que hacer

y este es el ultimo

Código
  1. var=otro
  2. if [ $var = "otro" ]
  3. then
  4. ot=`zenity --title="P.A.U" --text="Has entrado en el menu de otros.\n Aqui van diferentes opciones" \
  5. --width="500" --height="450" \
  6. --list --column="Select" --column="Opciones" \
  7. --checklist FALSE "Iconos del menu sistema" FALSE "Quitar sonido de inicio" FALSE "Poner el sonido de inico"  FALSE "Instalar Sharpfonts" FALSE "Arreglar el 'apt-get update' con los repositorios de Google"  FALSE "Resetear el 'apt-get update'" FALSE "Borrar Ubuntu-docs" FALSE "Instalar Ubuntu-docs" FALSE "Botones a la Izquierda" FALSE "Botones a la Derecha" FALSE "Instalar paquetes basicos de compilacion" FALSE "Instalar las librerias de desarrollo del kernel"`
  8. if [ $? -eq 0 ]
  9. then
  10. for otopc in $ot
  11. do
  12. if [ "$otopc" = "Iconos del menu sistema" ]
  13. then
  14. gconftool-2 --type Boolean --set /desktop/gnome/interface/menus_have_icons True && killall gnome-panel
  15. fi
  16. if [ "$otopc" = "Quitar sonido de inicio" ]
  17. then
  18. sudo -u gdm gconftool-2 --set /desktop/gnome/sound/event_sounds --type bool false
  19.                 sudo -u $ON_USER "DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS gconftool-2 --set /desktop/gnome/sound/event_sounds --type bool false
  20. fi
  21. if [ "$otopc" = "Poner el sonido de inicio" ]
  22. then
  23. sudo -u gdm gconftool-2 --set /desktop/gnome/sound/event_sounds --type bool true
  24.                 sudo -u $ON_USER "DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS gconftool-2 --set /desktop/gnome/sound/event_sounds --type bool true
  25. fi
  26. if [ "$otopc" = "Instalar Sharpfonts" ]
  27. then
  28. zenity --info --text="Esto tardara dependiendo de tu conexion"
  29. cd /tmp/
  30. zenity --info --text="Ahora se instalara cabextract"
  31. sudo apt-get -y install cabextract
  32. zenity --info --text="Ya se ha instalado.\n Ahora se descargar lo necesirio"
  33. wget http://sharpfonts.com/fonts/andale32.exe
  34.                 wget http://sharpfonts.com/fonts/arial32.exe
  35.                 wget http://sharpfonts.com/fonts/arialb32.exe
  36.                 wget http://sharpfonts.com/fonts/comic32.ex
  37.                 wget http://sharpfonts.com/fonts/courie32.exe
  38.                 wget http://sharpfonts.com/fonts/georgi32.exe
  39.                 wget http://sharpfonts.com/fonts/impact32.exe
  40.                 wget http://sharpfonts.com/fonts/tahoma32.exe
  41.                 wget http://sharpfonts.com/fonts/times32.exe
  42.                 wget http://sharpfonts.com/fonts/trebuc32.exe
  43.                 wget http://sharpfonts.com/fonts/verdan32.exe
  44.                 wget http://sharpfonts.com/fonts/webdin32.exe
  45. sudo mkdir /usr/share/fonts/truetype/
  46. cabextract -d /usr/share/fonts/truetype/ andale32.exe arial32.exe arialb32.exe comic32.exe courie32.exe georgi32.exe impact32.exe tahoma32.exe times32.exe trebuc32.exe verdan32.exe webdin32.exe
  47. wget http://sharpfonts.com/fontconfig.tbz
  48.                 tar xvjpf fontconfig.tbz -C /etc/fonts/
  49.                 rm -r /tmp/*.exe
  50.                 rm /tmp/fontconfig.tbz
  51. fi
  52. if [ "$otopc" = "Arreglar el 'apt-get update' con los repositorios de Google" ]
  53. then
  54. echo "Acquire::http::Pipeline-Depth \"0\";" | sudo tee -a /etc/apt/apt.conf.d/90localsettings > /dev/null
  55. fi
  56. if [ "$otopc" = "Resetear el 'apt-get update'"]
  57. then
  58. sudo rm /etc/apt/apt.conf.d/90localsettings_back; sudo cp /etc/apt/apt.conf.d/90localsettings /etc/apt/apt.conf.d/90localsettings_back; cat /etc/apt/apt.conf.d/90localsettings_back | sudo sed -e '/^Acquire::http::Pipeline-Depth.*/d' > /etc/apt/apt.conf.d/90localsettings; sudo rm /etc/apt/apt.conf.d/90localsettings_back
  59. fi
  60. if [ "$otopc" = "Borrar Ubuntu-docs" ]
  61. then
  62. zenity --info --text="Esto te liberara 256MB"
  63. sudo apt-get -y remove ubuntu-docs
  64. fi
  65. if [ "$otopc" = "Instalar Ubuntu-docs" ]
  66. then
  67. sudo apt-get -y install ubuntu-docs
  68. fi
  69. if [ "$otopc" = "Botones a la Izquierda" ]
  70. then
  71. gconftool-2 --type string --set /apps/metacity/general/button_layout "menu:close,minimize,maximize"
  72. fi
  73. if [ "$otopc" = "Botones a la Derecha" ]
  74. then
  75. zenity --info --title="INFO" --text="Ahora se cambiara los botones"
  76. gconftool-2 --type string --set /apps/metacity/general/button_layout "close,minimize,maximize:menu"
  77. fi
  78. if [ "$otopc" = "Instalar paquetes basicos de compilacion" ]
  79. then
  80. sudo aptitude -y install build-essential
  81. fi
  82. if [ "$otopc" = "Instalar las librerias de desarrollo del kernel" ]
  83. then
  84. sudo aptitude -y install linux-headers-`uname -r`
  85. fi
  86. done
  87. fi
  88.        fi
  89.  

Este no se ejecuta ninguna de las opciones que hay y este es el error que me da cuando ejecuto alguna opcion

Código:
[: 90: missing ]
[: 90: missing ]

Lo siento por el post tan largo o era poner esto para ir diciendo parte por parte o poner todo el script de mas de 400 lineas, lo he estado dando vueltas pero no he conseguido como hacerlo funcionar si alguien me puede ayudar
Código
  1.  
123  Programación / Scripting / Re: Unas cuantas preguntas sobre bash en: 26 Abril 2010, 15:31 pm
Ya he arreglado el error que tenia de que no podia ejecutar el programa, bueno ahora esque hay una opcion que no me ejecuta, es cuando lo selecciono el programa me empieza de nuevo sin ejecutar esa opcion, entonces no se como hacerlo le estuve dando vueltas pero nada, esta es la parte de esa opcion


Código
  1. if [[ $opcs = "Actualizar,Limpiar" ]]
  2. then
  3. upd=`zenity --title="Actualizar" --text="Has seleccionado Actualizar, Limpiar\n. Hay dos tipos de actualizaciones una normal y otro mas sostificado.\n Si acabas de instalar mejor haz una sostificada. \n Al contrario si lo tenias instalado haz una normal.\n O si deseas limpiar los paquetes innecesarios de tu sistema."  \
  4.      --list --column="Select" --column="Opciones" \
  5.            --checklist FALSE "Actualizacion normal" FALSE "Actualizacion sostificada" FALSE "Limpiar Ubuntu"`
  6. if [ $? -eq 0 ]
  7. then
  8. for updopc in $upd
  9. do
  10. if [ $updopc = "Actualizacion normal" ]
  11. then
  12. zenity --info --title="INFO" --text="Este proceso lo mas seguro que no tarde mucho.\n Espere a que salga la ventana de informacion"
  13. sudo aptitude update && sudo apt-get update
  14. sleep 2
  15. zenity --info --title="INFO" --text="Ya se ha actualizado su sistema"
  16. clear
  17. elif [ $updopc = "Actualizacion sostificada" ]
  18. then
  19. echo ""
  20. zenity --info --title="INFO" --text="Este proceso puede que tarde mucho, espere a que te salga la ventana\n de informacion"
  21. sudo aptitude update && sudo apt-get update
  22. sudo aptitude upgrade && sudo apt-get upgrade
  23. zenity --info --title="INFO" --text="Ya se ha actualiza tu sistema"
  24. sleep 2
  25. clear
  26. fi
  27. if [ $updopc = "Limpiar Ubuntu" ]
  28. then
  29. zenity --info --title="Limpieza.." --text="Ahora empezara la limpieza de Ubuntu"
  30.     sudo apt-get autoremove && sudo apt-get autoclean && sudo apt-get clean
  31.     OLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}')
  32.     CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
  33.     LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"
  34.     METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
  35.     OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)
  36.     YELLOW="\033[1;33m"
  37.     RED="\033[0;31m"
  38.     ENDCOLOR="\033[0m"
  39.     zenity --info --title="Limpiando" --text="$YELLOW""Cleaning apt cache...""$ENDCOLOR"
  40.     sudo aptitude clean
  41.     zenity --info --title="Limpiando" --text="$YELLOW""Removing old config files...""$ENDCOLOR"
  42.     sudo aptitude purge $OLDCONF
  43.     zenity --info --title="Limpiando" --text="$YELLOW""Removing old kernels...""$ENDCOLOR"
  44.     sudo aptitude purge $OLDKERNELS
  45.     zenity --info --title="Limpiando" --text="$YELLOW""Emptying every trashes...""$ENDCOLOR"
  46.     rm -rf /home/*/.local/share/Trash/*/** &> /dev/null
  47.     rm -rf /root/.local/share/Trash/*/** &> /dev/null
  48.     clear
  49.     mop=`zenity --title="P.A.U" --text="¿Tenia usted instalado mozilla-thunderbird?" \
  50. --list --column="Select" --column="Opcion" \
  51. --checklist FALSE "SI" FALSE "NO"`
  52. if [ $? -eq 0 ]
  53. then
  54. for mopc in $mop
  55. do
  56.  
  57.         if [ "$mopc" = "SI" ]
  58.             then
  59.   zenity --info --title="Empezara..." --text="ya empezara a instalarse"
  60.           sudo aptitude install  mozilla-thunderbird thunderbird-locale-es-es
  61.   clear
  62.   zenity --info --title="Ya se ha instalado" --text="Ya ha instalado el Mozilla Thunderbird"
  63.     fi
  64. if [ $mopc = "NO" ]
  65. then
  66. zenity --info --text="Ahora iras al menu principal"
  67. fi
  68. done
  69. fi
  70. fi
  71. done
  72. fi
  73. fi
  74.  
124  Programación / Scripting / Re: Unas cuantas preguntas sobre bash en: 25 Abril 2010, 08:43 am
El case lo adaptare con los programas que tengo, ire quitando los elif y lo ire cerrando como en "clases" para evitar muchos elif y quitar los if del final
125  Programación / Scripting / Re: Unas cuantas preguntas sobre bash en: 24 Abril 2010, 08:10 am
Aqui teneis todo el codigo es que lo estaba adapantando a zenity, vereis una parte que esta cancelada, es para probarla en karmic koala

Código
  1. #!/bin/bash
  2.  
  3. #Menu principal---------------------------------------------------------------------------------------------------------
  4. #zenity --info --title="CARGANDO..." --text="Cargando el programa"
  5. if [ $USER = root ]
  6. then
  7. while true
  8. do
  9. clear
  10. zenity --info --title="P.A.U" --text="Bienvenido"
  11. zenity --info --title="P.A.U" --text="Chequeando si usa Lucid Lynx."
  12. sleep 2
  13. #if [ "lucid" = `lsb_release -cs` ]; then
  14. #  if [ "i686" = `uname -m` ]; then
  15.  #     echo using Ubuntu 10.04 Lucid Lynx - ok
  16.   #    arch=i386
  17.   #elif [ "x86_64" = `uname -m` ]; then
  18.    #   echo using Ubuntu 10.04 Lucid Lynx - ok
  19.     #  arch=amd64
  20.  # else
  21.   #    /usr/bin/zenity --warning --title="Error" --text="No usas Lucid Lynx de la version x32 y 64x"
  22.    #   echo Tu no estas usando Ubuntu 10.04 Lucid Lynx, saliendo
  23.     #  exit
  24.   #fi
  25. #else
  26. #      /usr/bin/zenity --warning --title="Error" --text="Error: Tu no estas usando Lucid Lynx"
  27.  #     echo Tu no estas usando Ubuntu 10.04 Lucid Lynx, saliendo
  28.   #    exit
  29. #fi
  30. #Aqui checeara si hay algun problema que no dejaria instalar los programas...-------------------------------------------
  31. if ps -U root -U root u | grep "synaptic" | grep -v grep > /dev/null;
  32. then
  33. zenity --warning --title="Close..." --text="Cierra el synaptic para poder instalar los programas"
  34. exit
  35. elif ps -U root -U root u | grep "update-manager" | grep -v grep > /dev/null;
  36. then
  37. zenity --warning --title="Close..." --text="Cierra el update-manager para poder instalar los programas"
  38.       exit
  39. elif ps -U root -U root u | grep "software-center" | grep -v grep > /dev/null;
  40. then
  41. zenity --warning --title="Close..." --text="Cierra el software-center para poder instalar los programas"       exit
  42. elif ps -U root -U root u | grep "apt-get" | grep -v grep > /dev/null;
  43. then
  44. zenity --warning --title="Close..." --text="Cierra el apt-get para poder instalar los programas"
  45.        exit
  46. elif ps -U root -U root u | grep "dpkg" | grep -v grep > /dev/null;
  47. then
  48. zenity --warning --title="Close..." --text="Cierra el dpkg para poder instalar los programas"
  49.        exit
  50. elif ps -U root -U root u | grep "aptitude" | grep -v grep > /dev/null;
  51. then
  52. zenity --warning --title="Close..." --text="Cierra el aptitude para poder instalar los programas"
  53.       exit
  54. fi
  55. #Aqui checeara si hay conexion a internet-----------------------------------------------------------------------------
  56. function testConnection()
  57. {
  58. testconnection=`wget --tries=3 --timeout=15 www.google.com -O /tmp/testinternet &>/dev/null 2>&1`
  59. if [ $? != 0 ]; then
  60. zenity --info --text="<b>Error:</b> No esta conectado a internet, porfavot conectate a Internet y inicia el script de nuevo"
  61. else
  62. echo Internet connection - ok
  63. fi
  64. }
  65. #Aqui seleccionara su opcion
  66. opc=`zenity --title="P.A.U" --width="500" --height="450" \
  67. --text="Bien ya se ha chequeado de que usa Lucid Lynx\n\n1. Usted ahora mismo se encuentra en el menu principal del script\n\n2. Aqui seleccionara lo que usted desea hacer, a continuacion aparecera las opciones que usted tiene hasta ahora\n\n3. Aconsejo instalar los codecs primero, sin seleccionar ninguna opcion" \
  68. --list --column="Select" --column="Opciones" \
  69. --checklist FALSE "Actualizar" TRUE "Codecs,extras..." FALSE "Limpiar Ubuntu" FALSE "SALIR" \
  70. FALSE "Cambiar la posicion de los botones" FALSE "Conky" FALSE "Instalar Programas" FALSE "Otros"`
  71. if [ $? -eq 0 ]
  72. then
  73. for opcs in $opc
  74. do
  75. # Para hacer un actualizacion del sistema mas "sostificada"-------------------------------------------------------------
  76. if [ $opcs = "Actualizar" ]
  77. then
  78. upd=`zenity --title="LIMPIEZA" --text="Has seleccionado Actualizar\n. Hay dos tipos de actualizaciones una normal y otro mas sostificado.\n Si acabas de instalar mejor haz una sostificada. \n Al contrario si lo tenias instalado haz una norma."  \
  79.    --list --column="Select" --column="Opciones" \
  80.    --checklist FALSE "Actualizacion normal" FALSE "Actualizacion sostificada"`
  81. if [ $? -eq 0 ]
  82. then
  83. for updopc in $upd
  84. do
  85. if [ $updopc = "Actualizacion normal" ]
  86. then
  87. zenity --info --title="INFO" --text="Este proceso lo mas seguro que no tarde mucho.\n Espere a que salga la ventana de informacion"
  88. sudo aptitude update && sudo apt-get update
  89. sleep 2
  90. zenity --info --title="INFO" --text="Ya se ha actualizado su sistema"
  91. clear
  92. elif [ $updopc = "Actualizacion sostificada" ]
  93. then
  94. echo ""
  95. zenity --info --title="INFO" --text="Este proceso puede que tarde mucho, espere a que te salga la ventana\n de informacion"
  96. sudo aptitude update && sudo apt-get update
  97. sudo aptitude upgrade && sudo apt-get upgrade
  98. zenity --info --title="INFO" --text="Ya se ha actualiza tu sistema"
  99. sleep 2
  100. clear
  101. fi
  102. done
  103. fi
  104. # En esta parte es la de los codecs, codecs, formatos comprimidos.medibuntu...------------------------------------------
  105. elif [ $opcs = "Codecs,extras..." ]
  106. then
  107. if [ "i686" = `uname -m` ]; then
  108. zenity --info --title="Espere..." --text="Espere a que salga la ventana de informacion\n de que ya se ha instalado"
  109.                           sudo echo sun-java6-jre shared/accepted-sun-dlj-v1-1 select true | sudo /usr/bin/debconf-set-selections
  110. sudo apt-get install --yes sun-java6-plugin
  111.                           sudo apt-get -y --force-yes install gstreamer0.10-ffmpeg gstreamer0.10-pitfdll gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly gstreamer0.10-plugins-ugly-multiverse libdvdnav4 libdvdread4 libdvdcss2 libxine1-ffmpeg ffmpeg w32codecs flashplugin-nonfree sun-java6-fonts rar unrar p7zip-full p7zip-rar unace unp ttf-mscorefonts-installer ttf-liberation
  112. zenity --info --title="Completado..." --text="Ya se ha instalado los codecs..."
  113. else
  114. zenity --info --title="Espere..." --text="Espere a que salga la ventana de informacion\n de que ya se ha instalado"
  115.                           sudo echo sun-java6-jre shared/accepted-sun-dlj-v1-1 select true | sudo /usr/bin/debconf-set-selections
  116. sudo apt-get install --yes sun-java6-plugin
  117.                           sudo apt-get -y --force-yes install gstreamer0.10-ffmpeg gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly gstreamer0.10-plugins-ugly-multiverse libdvdnav4 libdvdread4 libdvdcss2 libxine1-ffmpeg ffmpeg w64codecs sun-java6-fonts rar unrar p7zip-full p7zip-rar unace unp ttf-mscorefonts-installer ttf-liberation
  118.                           cd /tmp
  119.                           wget http://download.macromedia.com/pub/labs/flashplayer10/libflashplayer-10.0.45.2.linux-x86_64.so.tar.gz
  120.                           tar xzf libflashplayer-10.0.45.2.linux-x86_64.so.tar.gz
  121.                           sudo mkdir /usr/lib/flashplugin-nonfree/
  122.                           sudo mv libflashplayer.so /usr/lib/flashplugin-nonfree/
  123.                           sudo ln -s /usr/lib/flashplugin-nonfree/libflashplayer.so /usr/lib/mozilla/plugins/libflashplayer.so
  124.                           rm libflashplayer-10.0.45.2.linux-x86_64.so.tar.gz
  125. zenity --info --title="Completado..." --text="Ya se ha instalado los codecs..."
  126.                      fi
  127. # Esta opcion lo que hace es eliminar los paquetes innecesarios del sistema de ubuntu-----------------------------------
  128. elif [ $opcs = "Limpiar Ubuntu" ]
  129. then
  130. poc=`zenity --title="Limpiar Ubuntu" --width="500" --height="450" \
  131. --text="Esta opcion es para liberar algo de espacio\n ya que cuando instalas paquetes y mas cosas se queda \n en el SO y ocupa espacio\n\n1. ADVERTENCIA: te borrara sin preguntar el mozilla thunderbird y el conky te preguntara.\n Asi que abre la terminal si tienes instalado el conky para decir que no.\n\n2 Recomiendo hacer esto cada X tiempo.\n\n3 Asi que seleccione si quiere limpiar o no" \
  132. --list --column="Select" --column="Opcion" \
  133. --checklist TRUE "SI" FALSE "NO"`
  134. if  [ $? -eq 0 ]
  135. then
  136. for pocx in $poc
  137. do
  138.    if [ $pocx = "SI" ]
  139.    then
  140.    zenity --info --title="Limpieza.." --text="Ahora empezara la limpieza de Ubuntu"
  141.    sudo apt-get autoremove && sudo apt-get autoclean && sudo apt-get clean
  142.    OLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}')
  143.    CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
  144.    LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"
  145.    METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
  146.    OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)
  147.    YELLOW="\033[1;33m"
  148.    RED="\033[0;31m"
  149.    ENDCOLOR="\033[0m"
  150.    zenity --info --title="Limpiando" --text="$YELLOW""Cleaning apt cache...""$ENDCOLOR"
  151.    sudo aptitude clean
  152.    zenity --info --title="Limpiando" --text="$YELLOW""Removing old config files...""$ENDCOLOR"
  153.    sudo aptitude purge $OLDCONF
  154.    zenity --info --title="Limpiando" --text="$YELLOW""Removing old kernels...""$ENDCOLOR"
  155.    sudo aptitude purge $OLDKERNELS
  156.    zenity --info --title="Limpiando" --text="$YELLOW""Emptying every trashes...""$ENDCOLOR"
  157.    rm -rf /home/*/.local/share/Trash/*/** &> /dev/null
  158.    rm -rf /root/.local/share/Trash/*/** &> /dev/null
  159.    clear
  160.    mop=`zenity --title="P.A.U" --text="¿Tenia usted instalado mozilla-thunderbird?" \
  161. --list --column="Select" --column="Opcion" \
  162. --checklist FALSE "SI" FALSE "NO"`
  163. if [ $? -eq 0 ]
  164. then
  165. for mopc in $mop
  166. do
  167.  
  168.        if [ "$mopc" = "SI" ]
  169.            then
  170.    zenity --info --title="Empezara..." --text="ya empezara a instalarse"
  171.            sudo aptitude install  mozilla-thunderbird thunderbird-locale-es-es
  172.    clear
  173.    zenity --info --title="Ya se ha instalado" --text="Ya ha instalado el Mozilla Thunderbird"
  174.    el=`zenity --title="P.A.U" --text="¿Que quieres hacer?" \
  175.         --list --column="Select" --column="Opcion" \
  176.         --checklist FALSE "SALIR" FALSE "MENU PRINCIPAL"`
  177. if [ $? -eq 0 ]
  178. then
  179. for elop in $el
  180. do
  181.                 if [ "$elop" = "SALIR" ]
  182.                 then
  183. clear
  184.                 echo ""
  185.                 zenity --info --title="Saliendo" --text="Gracias por usar el script"
  186.                 clear
  187.                 exit
  188.                 elif [ "$elop" = "MENU PRINCIPAL" ]
  189.                 then
  190. zenity --info --title="P.A.U" --text="Ahora iras al menu principal"
  191.             sleep 2
  192.             clear
  193. fi
  194. done
  195. fi
  196.         elif [ "$mopc" = "NO" ]
  197.             then
  198.     clear
  199.     elx=`zenity --title="P.A.U" --text="¿Que quieres hacer?" \
  200.         --list --column="Select" --column="Opcion" \
  201.         --checklist FALSE "SALIR" FALSE "MENU PRINCIPAL"`
  202. if [ $? -eq 0 ]
  203. then
  204. for elopcx in $elx
  205. do
  206.                 if [ "$elopcx" = "SALIR" ]
  207.                 then
  208.                 echo ""
  209.                 zenity --info --title="Saliendo" --text="Gracias por usar el script"
  210.                 clear
  211.                 exit
  212.                 elif [ "$elopcx" = "MENU PRINCIPAL" ]
  213.                 then
  214.                 echo ""
  215.                 zenity --info --title="P.A.U" --text="Ahora iras al menu principal"
  216.   sleep 2
  217.     clear
  218. fi
  219. done
  220. fi
  221.     elif [ "$pocx" = "NO" ]
  222.     then
  223.   echo "Es tu decision si quieres que se te llene de paquetes inecesarios"
  224.     sleep 5
  225. fi
  226. done
  227. fi
  228. # La opcion de salir-------------------------------------------------------------------------------------------------
  229. elif [ $opcs = "SALIR" ]
  230. then
  231. clear
  232. zenity --info --title="Saliendo..." --text=" Gracias por usar este script. Hasta la proxima"
  233. sleep 3
  234. clear
  235. exit
  236. # La opcion de cambiar el sentido de los botones de la ventana---------------------------------------------------------
  237. elif [ $opcs = "Cambiar la posicion de los botones" ]
  238. then
  239. clear
  240. bot=`zenity --info --title="P.A.U" --text="Seleccione en que lado quiere que este los botones" \
  241. --list --column="Select" --column="Opciones"  \
  242. --checklist  FALSE"Izquierda" FALSE "Derecha" `
  243. if [ $? -eq 0 ]
  244. then
  245. for botopc in $bot
  246. do
  247. if [ $botopc = "Izquierda" ]
  248. then
  249. zenity --info --title="INFO" --text="Ahora se cambiara los botones"
  250. gconftool-2 --type string --set /apps/metacity/general/button_layout "menu:close,minimize,maximize"
  251. clear
  252. zenity --info --title="INFO" --text="Ya se ha cambiado los botones"
  253. elif [ $botopc = "Derecha" ]
  254. then
  255. zenity --info --title="INFO" --text="Ahora se cambiara los botones"
  256. gconftool-2 --type string --set /apps/metacity/general/button_layout
  257. "close,minimize,maximize:menu"
  258. zenity --info --title="INFO" --text="Ya se ha cambiado los botones"
  259. clear
  260. fi
  261. done
  262. fi
  263. # Aqui empieza la opcion del conky--------------------------------------------------------------------------------------
  264. elif [ $opcs = "Conky" ]
  265. then
  266. clear
  267. zenity --info --title="INFO" --text="Ahora mismo empezara la instalacion de conky"
  268. sudo aptitude install conky
  269. clear
  270. sleep 2
  271. zenity --info --title="INFO" --text="Ya se ha instalado el conky"
  272. cok=`zenity --title="P.A.U" --text="Seleccione si quiere una configuracion predeterminada o una por ti" \
  273. --list --column="Select" --column="Opciones" \
  274. --checklist FALSE"Predeterminada" FALSE"Propia" `
  275. if [ $? -eq 0 ]
  276. then
  277. for cokopc in $cok
  278. do
  279. if [ $cokopc = "Predeterminada" ]
  280. then
  281. clear
  282. zenity --info --title="Info" --text="se creara los archivo necesarios"
  283. cd /home/$USER/
  284. touch .conkyrc #Aqui se crea el archivo para el conky
  285. echo "" >> .conkyrc
  286. elif [ $cokopc = "Propia" ]
  287. then
  288. zenity --info --title="INFO" --text="Ojala que encuentras\n que te agrade"
  289. clear
  290. fi
  291. done
  292. fi
  293. # Aqui empieza otros----------------------------------------------------------------------------------------------------
  294. if [ $opcs = "Otros" ]
  295. then
  296. clear
  297. ot=`zenity --title="P.A.U" --text="Has entrado en el menu de otros.\n Aqui van diferentes opciones" \
  298. --list --column="Select" --column="Opciones" \
  299. --checklist FALSE "Iconos del menu sistema" FALSE "Quitar sonido de inicio" FALSE "Poner el sonido de inico" \
  300. FALSE "Instalar Sharpfonts" FALSE "Arreglar el 'apt-get update' con los repositorios de Google" \
  301. FALSE "Resetear el 'apt-get update'" FALSE "Borrar Ubuntu-docs" FALSE "Instalar Ubuntu-docs"`
  302. if [ $? -eq 0 ]
  303. then
  304. for otopc in $ot
  305. do
  306. if [ $otopc = "Iconos del menu sistema" ]
  307. then
  308. gconftool-2 --type Boolean --set /desktop/gnome/interface/menus_have_icons True && killall gnome-panel
  309. zenity --info --title="INFO" --text="Ya se han puesto los iconos del menu"
  310. elif [ $otopc = "Quitar sonido de inicio" ]
  311. then
  312. sudo -u gdm gconftool-2 --set /desktop/gnome/sound/event_sounds --type bool false
  313.                 sudo -u $ON_USER "DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS gconftool-2 --set /desktop/gnome/sound/event_sounds --type bool false
  314. zenity --info -title="INFO" --text="Ya se ha quitado el sonido del inicio"
  315. elif [ $otopc = "Poner el sonido de inicio" ]
  316. then
  317. sudo -u gdm gconftool-2 --set /desktop/gnome/sound/event_sounds --type bool true
  318.                 sudo -u $ON_USER "DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS gconftool-2 --set /desktop/gnome/sound/event_sounds --type bool true
  319. zenity --info --text="Ya se ha puesto el sonido del inicio"
  320. elif [ $otopc = "Instalar Sharpfonts" ]
  321. then
  322. zenity --info --text="Esto tardara dependiendo de tu conexion"
  323. cd /tmp/
  324. zenity --info --text="Ahora se instalara cabextract"
  325. sudo apt-get -y install cabextract
  326. zenity --info --text="Ya se ha instalado.\n Ahora se descargar lo necesirio"
  327. wget http://sharpfonts.com/fonts/andale32.exe
  328.                 wget http://sharpfonts.com/fonts/arial32.exe
  329.                 wget http://sharpfonts.com/fonts/arialb32.exe
  330.                 wget http://sharpfonts.com/fonts/comic32.ex
  331.                 wget http://sharpfonts.com/fonts/courie32.exe
  332.                 wget http://sharpfonts.com/fonts/georgi32.exe
  333.                 wget http://sharpfonts.com/fonts/impact32.exe
  334.                 wget http://sharpfonts.com/fonts/tahoma32.exe
  335.                 wget http://sharpfonts.com/fonts/times32.exe
  336.                 wget http://sharpfonts.com/fonts/trebuc32.exe
  337.                 wget http://sharpfonts.com/fonts/verdan32.exe
  338.                 wget http://sharpfonts.com/fonts/webdin32.exe
  339. sudo mkdir /usr/share/fonts/truetype/
  340. cabextract -d /usr/share/fonts/truetype/ andale32.exe arial32.exe arialb32.exe comic32.exe courie32.exe georgi32.exe impact32.exe tahoma32.exe times32.exe trebuc32.exe verdan32.exe webdin32.exe
  341. wget http://sharpfonts.com/fontconfig.tbz
  342.                 tar xvjpf fontconfig.tbz -C /etc/fonts/
  343.                 rm -r /tmp/*.exe
  344.                 rm /tmp/fontconfig.tbz
  345. zenity --info --text="Ya se ha completado"
  346. elif [ $otopc = "Arreglar el 'apt-get update' con los repositorios de Google" ]
  347. then
  348. echo "Acquire::http::Pipeline-Depth \"0\";" | sudo tee -a /etc/apt/apt.conf.d/90localsettings > /dev/null
  349. zenity --info --text="Ya se ha completado"
  350. elif [ $otopc = "Resetear el 'apt-get update'"]
  351. then
  352. sudo rm /etc/apt/apt.conf.d/90localsettings_back; sudo cp /etc/apt/apt.conf.d/90localsettings /etc/apt/apt.conf.d/90localsettings_back; cat /etc/apt/apt.conf.d/90localsettings_back | sudo sed -e '/^Acquire::http::Pipeline-Depth.*/d' > /etc/apt/apt.conf.d/90localsettings; sudo rm /etc/apt/apt.conf.d/90localsettings_back
  353. zenity --info --text="Ya se ha completado"
  354. elif [ $otopc = "Borrar Ubuntu-docs" ]
  355. then
  356. zenity --info --text="Esto te liberara 256MB"
  357. sudo apt-get -y remove ubuntu-docs
  358. zenity --info --text="Ya se ha completado"
  359. elif [ $otopc = "Instalar Ubuntu-docs" ]
  360. then
  361. sudo apt-get -y install ubuntu-docs
  362. zenity --info --text="Ya se ha completado"
  363. fi
  364. done
  365. fi
  366. fi
  367. # Aqui es donde empieza el menu de programas---------------------------------------------------------------------------
  368. elif [ $opcs = "Instalar Programas" ]
  369. then
  370. clear
  371. echo ""
  372. echo "¿Que programa deseas instalar?"
  373. echo""
  374. echo""
  375. echo " 1-Wine. Programa para usar programas nativos en Windows"
  376. echo " 2-Gimp. Editor Grafico"
  377. echo " 3-Pidgin. Cliente de Mensajeria"
  378. echo " 4-Chromium. Navegador"
  379. echo " 5-Compizfusion. Programa para poner efectos en Ubuntu"
  380. echo " 6-AWN. Dock de navegacion"
  381. echo " 7-Docky. Idem"
  382. echo " 8-GnomeDo. Idem"
  383. echo " 9-Inkscape. Editor de grafico vectoriales"
  384. echo " 10-Eclipse. Plataforma de desarrollo de programas"
  385. echo " 11-Netbeans. Idem"
  386. echo " 12-Vim. Editor de archivos en consola"
  387. echo " 13-Skype"
  388. echo " 14-K3b. Programa para grabar CD/DVD"
  389. echo " 15-Mozilla Thunderbird."
  390. echo " 16-Amule. Emule para la version de Linux"
  391. echo " 17-Tucan Manager (Alternativa a JDowloader)"
  392. echo " 18-Vlc. Reproductor de videos"
  393. echo " 19-Comix. Reporductor de comics"
  394. echo " 20-K3b con las librerias de KDE"
  395. echo " 21-JDownloader"
  396. echo " 22-Amarok. Reproductor muy bueno"
  397. echo " 23-Atool. Descomprimir y comprimir desde la consola"
  398. echo " 24-Formatos comprimidos"
  399. echo " 25-emesene. Cliente de Mensajeria"
  400. echo " 26-Gparted. Para hacer particiones"
  401. echo " 27-Google Chrome.Navegador"
  402. echo " 28-Virtualbox"
  403. read opcs
  404. for i in $opcs ; do
  405. echo ""
  406. echo "Has elegido la opcion $i"
  407. if [ $i = "1" ]
  408. then
  409. sudo apt-get -y install wine
  410. clear
  411. elif [ $i = "2" ]
  412. then
  413. sudo sh -cecho ‘deb http://ppa.launchpad.net/matthaeus123/mrw-gimp-svn/ubuntu lucid main’ >> /etc/apt/sources.list” && sudo apt-key adv –recv-keys –keyserver keyserver.ubuntu.com 405A15CB && sudo apt-get update && sudo apt-get -y install gimp
  414. clear
  415. elif [ $i = "3" ]
  416. then
  417. sudo add-apt-repository ppa:pidgin-developers && sudo apt-get update && sudo aptitude -y install pidgin
  418. clear
  419. elif [ $i = "4" ]
  420. then
  421. sudo add-apt-repository ppa:chromium-daily/ppa && sudo apt-get update && sudo apt-get -y install chromium-browser chromium-browser-l10n
  422. clear
  423. elif [ $i = "5" ]
  424. then
  425. sudo add-apt-repository ppa:compiz && sudo apt-get update && sudo aptitude -y install simple-ccsm compizconfig-settings-manager emerald && install fusion-icon
  426. clear
  427. elif [ $i = "6" ]
  428. then
  429. sudo apt-get update && sudo apt-get -y install avant-window-navigator awn-extras-applets
  430. clear
  431. elif [ $i = "7" ]
  432. then
  433. sudo add-apt-repository ppa:ricotz/testing && sudo apt-get update && sudo apt-get -y install docky
  434. clear
  435. elif [ $i = "8" ]
  436. then
  437. sudo add-apt-repository ppa:do-core && sudo apt-get update && sudo apt-get -y install gnome-do gnome-do-docklets gnome-do-plugins
  438. clear
  439. elif [ $i = "9" ]
  440. then
  441. sudo aptitude -y install inkscape
  442. clear
  443. elif [ $i = "10" ]
  444. then
  445. sudo aptitude -y install eclipse
  446. clear
  447. elif [ $i = "11" ]
  448. then
  449. sudo aptitude -y install netbeans
  450. clear
  451. elif [ $i = "12" ]
  452. then
  453. sudo aptitude -y install vim
  454. clear
  455. elif [ $i = "13" ]
  456. then
  457. cd /tmp      
  458. wget http://download.skype.com/linux/skype-ubuntu-intrepid_2.1.0.81-1_${arch}.deb                          
  459. sudo dpkg -i --force-all skype-ubuntu-intrepid_2.1.0.81-1_${arch}.deb                          
  460. sudo apt-get -y --force-yes install -f -y                          
  461. rm skype-ubuntu-intrepid_2.1.0.81-1_${arch}.deb
  462. clear
  463. elif [ $i = "14" ]
  464. then
  465. sudo aptitude -y install k3b
  466. clear
  467. elif [ $i = "15" ]
  468. then
  469. sudo aptitude -y install  mozilla-thunderbird thunderbird-locale-es-es
  470. clear
  471. elif [ $i  = "16" ]
  472. then
  473. sudo aptitude -y install amule
  474. clear
  475. elif [ $i = "17" ]
  476. then
  477. sudo aptitude -y install tucan
  478. clear
  479. elif [ $i = "18" ]
  480. then
  481. sudo add-apt-repository ppa:c-korn && sudo apt-get update && sudo apt-get -y install vlc
  482. clear
  483. elif [ $i = "19" ]
  484. then
  485. sudo aptitude -y install comix
  486. clear
  487. elif [ $i = "20" ]
  488. then  
  489. sudo aptitude install k3b && sudo aptitude -y install kde-i18n-es k3b-i18n
  490. clear
  491. elif [ $i = "21" ]
  492. then
  493. wget http://212.117.163.148/jd.sh
  494. chmod +x jd.sh
  495. sh jd.sh
  496. java -jar ~/.jd/JDownloader.jar
  497. clear
  498. elif [ $i = "22" ]
  499. then
  500. sudo add-apt-repository ppa:kubuntu-ppa/backports && sudo apt-get update && sudo apt-get -y install amarok
  501. clear
  502. elif [ $i = "23" ]
  503. then
  504. sudo aptitude -y install atool
  505. clear
  506. elif [ $i = "24" ]
  507. then
  508. sudo aptitude -y install rar p7zip-full unace unzip file-roller
  509. clear
  510. elif [ $i = "25" ]
  511. then
  512. sudo apt-get -y install emesene
  513. clear
  514. elif [ $i = "26" ]
  515. then
  516. sudo aptitude -y install gparted
  517. elif [ $i = "27" ]
  518. then
  519. sudo add-apt-key ppa:chromium-daily/ppa && sudo apt-get update && sudo apt-get -y install chromium-browser
  520. clear
  521. elif [ $i = "28" ]
  522. then
  523. zenity --info --text="Ahora empezara su instalacion"
  524. cd /etc/apt/
  525. echo "deb http://download.virtualbox.org/virtualbox/debian karmic non-free" >> sources.list
  526. wget -q http://download.virtualbox.org/virtualbox/debian/sun_vbox.asc -O- | sudo apt-key add -
  527. zenity --info --text="Ahora comprobara que tipo de sistema usa"
  528. if [ "i686" = `uname -m` ]
  529. then
  530. zenity --info --text="Ahora empezara la instalacion.\n Espera a que salga el mensaje de info"
  531. cd /home/$USER/
  532. wget http://download.virtualbox.org/virtualbox/3.1.6/virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  533. dpkg -i --force-all virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  534. sudo apt-get install -f -y
  535. rm virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  536. zenity --info --text="Ya ha terminado su instalacion"
  537. else
  538. zenity --info --text="Ahora empezara la instalacion.\n Espera a que salga el mensaje de info"
  539. cd /home/$USER/
  540. wget http://download.virtualbox.org/virtualbox/3.1.6/virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  541. dpkg -i --force-all virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  542. sudo apt-get install -f -y
  543. rm virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  544. zenity --info --text="Ya ha terminado su instalacion"
  545. fi
  546. fi
  547. done
  548. fi
  549. done
  550. fi
  551. fi
  552. done
  553. elif [ $USER != root ]
  554. then
  555. zenity --warning --title="No eres root" --text="No eres root/n inicie la aplicacion cuando seas root"
  556. exit
  557. fi
  558.  

Aconsejo copiarlo al gedit para entenderlo siempre
126  Programación / Scripting / Re: Unas cuantas preguntas sobre bash en: 23 Abril 2010, 22:25 pm
Gracias leo guitierrez, asi podre terminarlo, pero me ha surgido un error que no se a que se debe

Citar
script.sh: línea 454: error sintáctico: no se esperaba el final del fichero

Estas son las ultimas lineas, son los finales de bucles y condiciones grandes

Citar
fi
done
fi
done
fi
fi
done
elif [ $USER != root ]
then
zenity --warning --title="No eres root" --text="No eres root/n inicie la aplicacion cuando seas root"
exit
fi #linea 453
127  Programación / Scripting / Re: Unas cuantas preguntas sobre bash en: 23 Abril 2010, 07:11 am
@Tifa esa es una PARTE del script en realidad $opc es un read opc asi que el valor de $opc es lo que inserte el USUARIO y lo que pregunte es como escribir en el archivo que creo con touch
Y a los otros gracias por lo de java version
128  Programación / Scripting / Unas cuantas preguntas sobre bash en: 22 Abril 2010, 20:44 pm
Hola buenas, empeze el a programa en bash y a la vez haciendo un script lo mas completo posible para instalar programas  y mas opciones, bueno pos que me ha surguido unos cuantos problemas son los siguientes:

1-En el script estoy ahciendo instalar conky con una configuracion predeterminada o no, bueno pues no se como añadir datos a un arhcivo en bash, es decir editar un archivo por bash y no manualmente( ya que el script lo tenia que hacer practicamente solo) bueno aqui teneis el codigo de esa parte
Citar
elif [ $opc = "6" ]
then
clear
echo "Ahora mismo empezara la instalacion de conky"
sudo aptitude install conky
clear
sleep 2
echo "Bien ya ha terminado la instalacion del conky"
echo ""
echo "Si desea que el script te descargue una configuracion ya echa o al contrario si quieres buscar la configuracion  tu y buscarla por internet"
echo ""
echo "Si quieres que se descargue con una configuracion determinada escibra (d) o si quieres hacer tu mismo escribe (y) y pulse Enter"
echo ""
read cokopc
   if [ $cokopc = "d" ]
   then
   clear
   echo "Ahora empezara a descargarse el archivo"
   echo ""
   cd /home/$USER/
   touch .conkyrc #Aqui se crea el archivo en /home/$USER/
   fi
elif [ $cokopc = "y" ]
then
echo ""
echo "Te deseo suerte a que encuentres una configuracion que te agrade y que lo consigas suerte."
clear

2-Desde ayer me esta dando unos problemas cuando ejecuto mis script, ya que hago alguno de prueba bueno este es el problema

Citar
javaversion: línea 3: [: 1.6.0_0: se esperaba un operador unario

Aqui esta el codigo
Citar
#!/bin/bash

if [ "1.6.0_0" = `java -version` ]
then
clear
echo "esta instalado"
fi

Y aprovecho para ver si esta bien echo la forma de identificar si esta instalado java, ya que tengo para ver si tiene instalado java, cuando instale JDownloader y hacer el lanzador, ya que mucho novatos no lo usan por esa causa
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 [13]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines