Advertisement
Frannoe

Mate Reboot OS

Oct 20th, 2012
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 16.73 KB | None | 0 0
  1. =========================================================================================
  2. Fichero ------> install-bootos
  3. =========================================================================================
  4.  
  5. #!/bin/bash
  6. ##########################################################################################
  7. # By Francisco Luque Frannoe@gmail.com
  8. # http://lmde-frannoe.blogspot.com.es/
  9. # MATE RebootOS es una herramienta que nos permite seleccionar desde nuestro
  10. # entorno gráfico con qué sistema queremos arrancar.
  11. # Es necesario tener instalado el paquete "zenity" para su correcto
  12. # funcionamiento.
  13. # Esta utilidad esta basada en Unity-Reboot. Creada por Andrew de webupd8:
  14. # http://www.webupd8.org/2011/09/unity-reboot-ubuntu-unity-launcher-to.html.
  15.  
  16. # Las adaptaciones y modificaciones de los paquetes fuentes han sido orientadas
  17. # para su funcionamiento exclusivo en MATE. Por lo cual, su buen funcionamiento
  18. # en otros entornos no está asegurado.
  19.  
  20. # Para instalar MATE RebootOS, abra un terminal con el prompt en la carpeta MATE-RebootOS
  21. # y ejecute el siguiente comando:
  22.  
  23. # ./install-bootos
  24.  
  25. # Si tiene la opción correspondiente activada en la configuración de archivos de Caja,
  26. # también podrá ejecutar el archivo anterior con un doble clic.
  27.  
  28. # En el caso de querer desinstalar esta herramienta ejecute este comando:
  29. # ./remove-bootos
  30.  
  31. # Tienes más información aquí:
  32. # http://lmde-frannoe.blogspot.com.es/2012/10/lmde-mate-reboot-os.html
  33. ##########################################################################################
  34.  
  35.    
  36.    
  37. gksu -- sh -c 'cp -f mate-rebootos /usr/bin/'
  38. if [ $? -eq 0 ]
  39.    then
  40.  
  41. zenity --progress --pulsate --width "300" --no-cancel --auto-close --title="Copiando archivos..." --text="Copiando los siguientes archivos a las siguientes ubicaciones:\n\nmate-rebootos-settings a /usr/bin/\nmate-rebootos-command a /usr/bin/\nremove-bootos a /usr/bin/\nmate-rebootos.desktop a /etc/xdg/autostart/\nmate-rebootos.png a /usr/share/icons/hicolor/scalable/apps\nmate-rebootos-settings.png a /usr/share/icons/hicolor/scalable/apps\n\nEspere por favor..." &
  42. FINALIZAR_PROGRESS="%-"
  43.  
  44. gksu -- sh -c 'cp -f mate-rebootos-settings /usr/bin/'
  45. gksu -- sh -c 'cp -f mate-rebootos-command /usr/bin/'
  46. gksu -- sh -c 'cp -f remove-bootos /usr/bin/'
  47. gksu -- sh -c 'cp -f mate-rebootos.desktop /etc/xdg/autostart/'
  48. gksu -- sh -c 'cp -f mate-rebootos.png /usr/share/icons/hicolor/scalable/apps/'
  49. gksu -- sh -c 'cp -f mate-rebootos-settings.png /usr/share/icons/hicolor/scalable/apps/'
  50. gksu -- sh -c 'gtk-update-icon-cache /usr/share/icons/hicolor/'
  51.  
  52. if [[ -e /etc/default/grub ]]; then
  53. gksu -- sh -c 'cp /etc/default/grub /etc/default/grub_backup'
  54. gksu -- sh -c 'cp /boot/grub/grub.cfg /boot/grub/grub_backup'
  55. gksu -- sh -c 'sed -i 's/GRUB_DEFAULT.*/GRUB_DEFAULT=saved/' /etc/default/grub'
  56. gksu -- sh -c 'sed -i 's/#GRUB_DEFAULT.*/GRUB_DEFAULT=saved/' /etc/default/grub'
  57. gksu -- sh -c 'update-grub'
  58. fi
  59.  
  60.  
  61.  
  62. if [ -e ~/.config/menus/mate-settings.menu ]
  63.             then
  64.              
  65.  
  66. grep -r "<Name>ResetOS</Name>" ~/.config/menus/mate-settings.menu
  67. if [ $? -ne 0 ]
  68.    then
  69. cp ~/.config/menus/mate-settings.menu  ~/.config/menus/mate-settings.menu.BACK
  70. sed '/^$/d' ~/.config/menus/mate-settings.menu.BACK | sed '$d' > ~/.config/menus/mate-settings.menu
  71. echo " <Menu>
  72.         <Name>ResetOS</Name>
  73.         <Include>
  74.             <Category>Reset-OS</Category>
  75.         </Include>
  76.      </Menu>
  77.      </Menu> " | tee -a ~/.config/menus/mate-settings.menu
  78.  
  79. mate-rebootos
  80. sleep 5s && kill $FINALIZAR_PROGRESS
  81. zenity --info --title "Instalación finalizada..." --text "Proceso finalizado.\nAhora puede encontrar las distintas opciones\nde arranque de MATE Reboot OS en su menú:\n<b>Sistemas -/- ResetOS</b>" --no-wrap
  82. exit
  83.       else
  84. mate-rebootos
  85. sleep 5s && kill $FINALIZAR_PROGRESS
  86. zenity --info --title "Instalación finalizada..." --text "Proceso finalizado.\nAhora puede encontrar las distintas opciones\nde arranque de MATE Reboot OS en su menú:\n<b>Sistemas -/- ResetOS</b>" --no-wrap
  87. exit
  88. fi
  89.        else
  90. mate-rebootos
  91. sleep 5s && kill $FINALIZAR_PROGRESS
  92. zenity --info --title "Instalación finalizada..." --text "Proceso finalizado.\nAhora puede encontrar las distintas opciones\nde arranque de MATE Reboot OS en su menú:\n<b>Sistemas -/- ResetOS</b>" --no-wrap
  93.  
  94.             exit
  95.    fi
  96.  
  97. else
  98. zenity --info --title "Cancelado..." --text "Proceso cancelado o contraseña incorrecta." --no-wrap
  99. exit
  100. fi
  101.  
  102. =========================================================================================
  103. Fichero ------> remove-bootos
  104. =========================================================================================
  105.  
  106. #!/bin/bash
  107. ##########################################################################################
  108. # By Francisco Luque Frannoe@gmail.com
  109. # http://lmde-frannoe.blogspot.com.es/
  110. # MATE RebootOS es una herramienta que nos permite seleccionar desde nuestro
  111. # entorno gráfico con qué sistema queremos arrancar.
  112. # Es necesario tener instalado el paquete "zenity" para su correcto
  113. # funcionamiento.
  114. # Esta utilidad esta basada en Unity-Reboot. Creada por Andrew de webupd8:
  115. # http://www.webupd8.org/2011/09/unity-reboot-ubuntu-unity-launcher-to.html.
  116.  
  117. # Las adaptaciones y modificaciones de los paquetes fuentes han sido orientadas
  118. # para su funcionamiento exclusivo en MATE. Por lo cual, su buen funcionamiento
  119. # en otros entornos no está asegurado.
  120.  
  121. # En el caso de querer desinstalar MATE RebootOS, abra un terminal con el prompt
  122. # en la carpeta MATE-RebootOS y ejecute el siguiente comando:
  123. # ./remove-bootos
  124.  
  125. # Tienes más información aquí:
  126. # http://lmde-frannoe.blogspot.com.es/2012/10/lmde-mate-reboot-os.html
  127. ##########################################################################################
  128. if zenity --question --title "¿Eliminar MATE Reboot OS?" --text="¿Está seguro de querer eliminar Mate Reboot OS?." --no-wrap
  129. then
  130.    
  131. gksu -- sh -c 'rm -f /usr/bin/mate-rebootos'
  132. if [ $? -eq 0 ]
  133.    then
  134.  
  135. zenity --progress --pulsate --width "300" --no-cancel --auto-close --title="Eliminando archivos..." --text="Eliminado los siguientes archivos:\n\n/usr/bin/mate-rebootos-settings\n/usr/bin/mate-rebootos-command\n/usr/bin/remove-bootos\n/etc/xdg/autostart/mate-reboot.desktop\n/usr/share/icons/hicolor/scalable/apps/mate-reboot.png\n/usr/share/icons/hicolor/scalable/apps/mate-rebootos-settings.png\n`whoami`/.local/share/applications/mate-rebootos*\n`whoami`/.config/mate-rebootos\n\nEspere por favor..." &
  136. FINALIZAR_PROGRESS="%-"
  137.  
  138. gksu -- sh -c 'rm -f  /usr/bin/mate-rebootos-settings'
  139. gksu -- sh -c 'rm -f  /usr/bin/mate-rebootos-command'
  140. gksu -- sh -c 'rm -f  /etc/xdg/autostart/mate-rebootos.desktop'
  141. gksu -- sh -c 'rm -f  /usr/share/icons/hicolor/scalable/apps/mate-rebootos.png'
  142. gksu -- sh -c 'rm -f  /usr/share/icons/hicolor/scalable/apps/mate-rebootos-settings.png'
  143. gksu -- sh -c 'gtk-update-icon-cache /usr/share/icons/hicolor'
  144. rm -f ~/.local/share/applications/mate-rebootos*
  145. rm -rf ~/.config/mate-rebootos
  146. sleep 5s && kill $FINALIZAR_PROGRESS
  147. zenity --info --title "Desinstalación finalizada..." --text "El proceso de eliminación de la instalación\nde MATE Reboot OS a finalizado" --no-wrap
  148. gksu -- sh -c 'rm -f  /usr/bin/remove-bootos'
  149. exit
  150. else
  151. zenity --info --title "Cancelado..." --text "Proceso cancelado o contraseña incorrecta." --no-wrap
  152. exit
  153. fi
  154. else
  155. exit
  156. fi
  157.  
  158. =========================================================================================
  159. Fichero ------> mate-rebootos
  160. =========================================================================================
  161.  
  162. #!/bin/bash
  163. ##########################################################################################
  164. # By Francisco Luque Frannoe@gmail.com
  165. # http://lmde-frannoe.blogspot.com.es/
  166. # MATE RebootOS es una herramienta que nos permite seleccionar desde nuestro
  167. # entorno gráfico con qué sistema queremos arrancar.
  168. # Es necesario tener instalado el paquete "zenity" para su correcto
  169. # funcionamiento.
  170. # Esta utilidad esta basada en Unity-Reboot. Creada por Andrew de webupd8:
  171. # http://www.webupd8.org/2011/09/unity-reboot-ubuntu-unity-launcher-to.html.
  172.  
  173. # Las adaptaciones y modificaciones de los paquetes fuentes han sido orientadas
  174. # para su funcionamiento exclusivo en MATE. Por lo cual, su buen funcionamiento
  175. # en otros entornos no está asegurado.
  176.  
  177. # Tienes más información aquí:
  178. # http://lmde-frannoe.blogspot.com.es/2012/10/lmde-mate-reboot-os.html
  179. ##########################################################################################
  180.  
  181.  
  182. if [[ ! -e ~/.config/mate-rebootos/settings ]]; then
  183.     mkdir -p ~/.config/mate-rebootos
  184.     echo "no-password-prompt = FALSE" > ~/.config/mate-rebootos/settings
  185. fi
  186.  
  187. mkdir -p ~/.local/share/applications
  188. cat /boot/grub/grub.cfg | grep menuentry >> /tmp/.ur_bootlist
  189. sed -i -e 's/.*recovery mode.*//g' -e 's/.*memtest.*//g' -e 's/menuentry //g' -e 's/ --class.*//g' -e "s/'//g" -e "s/\"//g" /tmp/.ur_bootlist
  190. sed -i '/^$/d' /tmp/.ur_bootlist
  191. awk ' !x[$0]++' /tmp/.ur_bootlist >> /tmp/.ur_bootlist2
  192. rm /tmp/.ur_bootlist
  193. cp /tmp/.ur_bootlist2 /tmp/.ur_bootlist
  194. rm /tmp/.ur_bootlist2 /tmp/.ur_bootlistformatted /tmp/.ur_rebootshortcuts > /dev/null 2>&1
  195. rm -f ~/.local/share/applications/mate-rebootos*
  196. BOOTLISTNRS=$(cat /tmp/.ur_bootlist | wc -l)
  197.  
  198. n=1
  199. while [ $n -le $BOOTLISTNRS ];
  200. do
  201. echo Reboot$n\; | tee -a /tmp/.ur_rebootshortcuts
  202. n=$(( n+1 ))
  203. done
  204.  
  205. awk '{ printf "%s", $0 }' /tmp/.ur_rebootshortcuts > /tmp/.ur_rebootshortcuts2
  206. rm /tmp/.ur_rebootshortcuts
  207. cp /tmp/.ur_rebootshortcuts2 /tmp/.ur_rebootshortcuts
  208.  
  209. SHORTCUTS=$(cat /tmp/.ur_rebootshortcuts)
  210.  
  211. current_noaskforpassword=`grep "no-password-prompt = " ~/.config/mate-rebootos/settings | sed -e 's/no-password-prompt = //g'`
  212.  
  213. if [[ $current_noaskforpassword == "TRUE" ]]; then
  214.  
  215. #   n=1
  216. #   while [ $n -le $BOOTLISTNRS ];
  217. #   do
  218. #   MENUENTRY=$(sed -n "$n{p;q;}" /tmp/.ur_bootlist)
  219. #echo "[Reboot$n Shortcut Group]
  220. #   Name=$MENUENTRY
  221. #   Exec=sh -c 'grub-reboot "\"$MENUENTRY\"" && dbus-send --session --type=method_call --print-reply --dest=org.mate.SessionManager /org/mate/SessionManager org.mate.SessionManager.RequestReboot'
  222. #   TargetEnvironment=MATE" | tee -a ~/.local/share/applications/mate-rebootos.desktop
  223. #   n=$(( n+1 ))
  224. #   done
  225. #   rm /tmp/.ur_* > /dev/null 2>&1
  226.  
  227.     n=1
  228.     while [ $n -le $BOOTLISTNRS ];
  229.     do
  230.     MENUENTRY=$(sed -n "$n{p;q;}" /tmp/.ur_bootlist)
  231.     echo "[Desktop Entry]
  232. Version=1.0
  233. Comment=Arrancar con $MENUENTRY
  234. Name=$n-$MENUENTRY
  235. Icon=mate-rebootos
  236. Terminal=false
  237. X-MultipleArgs=false
  238. Type=Application
  239. Categories=Reset-OS;
  240. Exec=sh -c 'echo "\"$MENUENTRY\"" > /tmp/.rboot; mate-rebootos-command && dbus-send --session --type=method_call --print-reply --dest=org.mate.SessionManager /org/mate/SessionManager org.mate.SessionManager.RequestReboot'" | tee ~/.local/share/applications/mate-rebootos-$n.desktop
  241.     n=$(( n+1 ))
  242.     done
  243.     rm /tmp/.ur_* > /dev/null 2>&1
  244.  
  245. else
  246.  
  247. #   n=1
  248. #   while [ $n -le $BOOTLISTNRS ];
  249. #   do
  250. #   MENUENTRY=$(sed -n "$n{p;q;}" /tmp/.ur_bootlist)
  251. #echo "[Reboot$n Shortcut Group]
  252. #   Name=$MENUENTRY
  253. #   Exec=gksu -- sh -c 'grub-reboot "\"$MENUENTRY\"" && reboot'
  254. #   TargetEnvironment=MATE" | tee -a ~/.local/share/applications/mate-rebootos.desktop
  255. #   n=$(( n+1 ))
  256. #   done
  257. #   rm /tmp/.ur_* > /dev/null 2>&1
  258.  
  259.     n=1
  260.     while [ $n -le $BOOTLISTNRS ];
  261.     do
  262.     MENUENTRY=$(sed -n "$n{p;q;}" /tmp/.ur_bootlist)
  263.     echo "[Desktop Entry]
  264. Version=1.0
  265. Comment=Arrancar con $MENUENTRY
  266. Name=$n-$MENUENTRY
  267. Icon=mate-rebootos
  268. Terminal=false
  269. X-MultipleArgs=false
  270. Type=Application
  271. Categories=Reset-OS;
  272. Exec=sh -c 'echo "\"$MENUENTRY\"" > /tmp/.rboot; mate-rebootos-command && dbus-send --session --type=method_call --print-reply --dest=org.mate.SessionManager /org/mate/SessionManager org.mate.SessionManager.RequestReboot'" | tee ~/.local/share/applications/mate-rebootos-$n.desktop
  273.     n=$(( n+1 ))
  274.     done
  275.     rm /tmp/.ur_* > /dev/null 2>&1
  276.  
  277. fi
  278.  
  279. echo "[Desktop Entry]
  280. Name=Mate Rebootos Settings
  281. Icon=mate-rebootos-settings
  282. Terminal=false
  283. X-MultipleArgs=false
  284. Type=Application
  285. Categories=Reset-OS;
  286. Exec=mate-rebootos-settings" | tee ~/.local/share/applications/mate-rebootos.Settings.desktop
  287.  
  288. echo "[Desktop Entry]
  289. Name=x-Eliminar Mate Reboot OS
  290. Comment=Elimina totalmente Mate Reboot OS del sistema.
  291. Icon=mate-rebootos-settings
  292. Terminal=false
  293. X-MultipleArgs=false
  294. Type=Application
  295. Categories=Reset-OS;
  296. Exec=remove-bootos" | tee ~/.local/share/applications/mate-rebootos-remove.desktop
  297.  
  298. =========================================================================================
  299. Fichero ------> mate-rebootos-command
  300. =========================================================================================
  301.  
  302. #!/bin/bash
  303. ##########################################################################################
  304. # By Francisco Luque Frannoe@gmail.com
  305. # http://lmde-frannoe.blogspot.com.es/
  306. # MATE RebootOS es una herramienta que nos permite seleccionar desde nuestro
  307. # entorno gráfico con qué sistema queremos arrancar.
  308. # Es necesario tener instalado el paquete "zenity" para su correcto
  309. # funcionamiento.
  310. # Esta utilidad esta basada en Unity-Reboot. Creada por Andrew de webupd8:
  311. # http://www.webupd8.org/2011/09/unity-reboot-ubuntu-unity-launcher-to.html.
  312.  
  313. # Las adaptaciones y modificaciones de los paquetes fuentes han sido orientadas
  314. # para su funcionamiento exclusivo en MATE. Por lo cual, su buen funcionamiento
  315. # en otros entornos no está asegurado.
  316. # Tienes más información aquí:
  317. # http://lmde-frannoe.blogspot.com.es/2012/10/lmde-mate-reboot-os.html
  318. ##########################################################################################
  319.  
  320. current_noaskforpassword=`grep "no-password-prompt = " ~/.config/mate-rebootos/settings | sed -e 's/no-password-prompt = //g'`
  321.  
  322. if [[ $current_noaskforpassword == "TRUE" ]]; then
  323.     /usr/sbin/grub-reboot "$(cat /tmp/.rboot)"
  324. else
  325.     gksu grub-reboot "$(cat /tmp/.rboot)"
  326. fi
  327.  
  328. =========================================================================================
  329. Fichero ------> mate-rebootos-settings
  330. =========================================================================================
  331. #!/bin/bash
  332. ##########################################################################################
  333. # By Francisco Luque Frannoe@gmail.com
  334. # http://lmde-frannoe.blogspot.com.es/
  335. # MATE RebootOS es una herramienta que nos permite seleccionar desde nuestro
  336. # entorno gráfico con qué sistema queremos arrancar.
  337. # Es necesario tener instalado el paquete "zenity" para su correcto
  338. # funcionamiento.
  339. # Esta utilidad esta basada en Unity-Reboot. Creada por Andrew de webupd8:
  340. # http://www.webupd8.org/2011/09/unity-reboot-ubuntu-unity-launcher-to.html.
  341.  
  342. # Las adaptaciones y modificaciones de los paquetes fuentes han sido orientadas
  343. # para su funcionamiento exclusivo en MATE. Por lo cual, su buen funcionamiento
  344. # en otros entornos no está asegurado.
  345.  
  346. # Tienes más información aquí:
  347. # http://lmde-frannoe.blogspot.com.es/2012/10/lmde-mate-reboot-os.html
  348. ##########################################################################################
  349.  
  350. current_noaskforpassword=`grep "no-password-prompt = " ~/.config/mate-rebootos/settings | sed -e 's/no-password-prompt = //g'`
  351. case "$current_noaskforpassword" in
  352. TRUE)
  353. Activado=\T"RUE"
  354. Desactivado=\F"ALSE"
  355. ;;
  356. FALSE)
  357. Activado=\F"ALSE"
  358. Desactivado=\T"RUE"
  359. ;;
  360. *)
  361. zenity --info --title "Error..." --text "Contenido erróneo en el archivo de <b>$HOME/.config/mate-rebootos/settings</b>\nPara correjir esto la única línea que debe contener este archivo es:\n\n<b>no-password-prompt = FALSE</b> o con el valor <b>TRUE</b>.\n\nTambién puede eliminar y volver a instalar Mate Reboot OS." --no-wrap
  362. exit
  363. esac
  364.  
  365. R_SETTINGS=$(zenity --list --title "Mate Reboot OS" --text "-------------------- <b>¡Advertencia!</b> --------------------\n Activar ésto supone que /usr/bin/grub-editenv\n podrá ser ejecutado por cualquier usuario." --height "200" --width "300" --radiolist --column "#" --column "Estado en que se encuentra el Servicio" $Activado "Activado (No se solicita clave Root)" $Desactivado "Desactivado (Se solicita clave Root)")
  366.  
  367. ret=$?
  368. case "$R_SETTINGS" in
  369. 'Activado (No se solicita clave Root)')
  370. R_SETTINGS="TRUE"
  371. ;;
  372. 'Desactivado (Se solicita clave Root)')
  373. R_SETTINGS="FALSE"
  374. ;;
  375.  
  376. *)
  377. exit
  378. esac
  379.  
  380.  
  381. if [[ $ret -eq 0 ]]; then
  382.     R_password=`echo "$R_SETTINGS" | cut -d '|' -f1`
  383.  
  384.     if [[ "$R_password" == "TRUE" ]]; then
  385.  
  386.         gksu -- sh -c 'chmod +s /usr/bin/grub-editenv'
  387.  
  388. if [ $? -eq 0 ]
  389.    then
  390.         sed -i "s/no-password-prompt = .*/no-password-prompt = $R_password/g" ~/.config/mate-rebootos/settings
  391.    else
  392. exit
  393. fi
  394.  
  395.     else
  396.  
  397.         gksu -- sh -c 'chmod -s /usr/bin/grub-editenv'
  398. if [ $? -eq 0 ]
  399.    then
  400.          sed -i "s/no-password-prompt = .*/no-password-prompt = $R_password/g" ~/.config/mate-rebootos/settings
  401.    else
  402. exit
  403. fi
  404.     fi
  405.  
  406.     mate-rebootos
  407.  
  408. else
  409.     exit
  410.  
  411. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement