Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
e81b86a09a | |||
|
09eb7fd981 | ||
|
90d4e38687 | ||
|
b330650b57 | ||
|
95af24c451 | ||
|
734a50df7e | ||
|
080fcd3339 | ||
|
13173a4c6c | ||
|
790871ebfc | ||
|
49d37ee372 | ||
|
2003bafff2 | ||
|
9d5b29c874 | ||
|
d51cf4bfed | ||
|
834489df41 | ||
|
2cfda54215 | ||
|
4404f66fee | ||
|
1d06b7e0f2 | ||
|
14bb60e589 | ||
|
d5043d5f6b | ||
|
8b0f2b1676 | ||
|
41308e6966 |
11
Makefile
@ -7,10 +7,15 @@ PREFIX=/usr
|
||||
install:
|
||||
mkdir -p /opt/zenigrub-custom
|
||||
cp -rf src/zenigrub-custom /opt/zenigrub-custom/zenigrub-custom
|
||||
cp -rf src/zenigrub-custom-cli /opt/zenigrub-custom/zenigrub-custom-cli
|
||||
cp -rf src/zenigrub-custom-admin /opt/zenigrub-custom/zenigrub-custom-admin
|
||||
cp -rf icon/zenigrub-custom.png /opt/zenigrub-custom/zenigrub-custom.png
|
||||
cp -rf img/ /opt/zenigrub-custom/
|
||||
cp -rf src/zenigrub-custom.desktop $(PREFIX)/share/applications/zenigrub-custom.desktop
|
||||
rm -rf $(PREFIX)/bin/zenigrub-custom
|
||||
rm -rf $(PREFIX)/bin/zenigrub-custom-cli
|
||||
ln -s /opt/zenigrub-custom/zenigrub-custom $(PREFIX)/bin/zenigrub-custom
|
||||
ln -s /opt/zenigrub-custom/zenigrub-custom-cli $(PREFIX)/bin/zenigrub-custom-cli
|
||||
chmod +x $(PREFIX)/bin/zenigrub-custom
|
||||
chmod +x /opt/zenigrub-custom/zenigrub-custom
|
||||
chmod +x /opt/zenigrub-custom/zenigrub-custom-admin
|
||||
@ -19,10 +24,15 @@ install:
|
||||
install-es:
|
||||
mkdir -p /opt/zenigrub-custom
|
||||
cp -rf src-ES/zenigrub-custom /opt/zenigrub-custom/zenigrub-custom
|
||||
cp -rf src-ES/zenigrub-custom-cli /opt/zenigrub-custom/zenigrub-custom-cli
|
||||
cp -rf src-ES/zenigrub-custom-admin /opt/zenigrub-custom/zenigrub-custom-admin
|
||||
cp -rf icon/zenigrub-custom.png /opt/zenigrub-custom/zenigrub-custom.png
|
||||
cp -rf img/ /opt/zenigrub-custom/
|
||||
cp -rf src-ES/zenigrub-custom.desktop $(PREFIX)/share/applications/zenigrub-custom.desktop
|
||||
rm -rf $(PREFIX)/bin/zenigrub-custom
|
||||
rm -rf $(PREFIX)/bin/zenigrub-custom
|
||||
ln -s /opt/zenigrub-custom/zenigrub-custom $(PREFIX)/bin/zenigrub-custom
|
||||
ln -s /opt/zenigrub-custom/zenigrub-custom-cli $(PREFIX)/bin/zenigrub-custom-cli
|
||||
chmod +x $(PREFIX)/bin/zenigrub-custom
|
||||
chmod +x /opt/zenigrub-custom/zenigrub-custom
|
||||
chmod +x /opt/zenigrub-custom/zenigrub-custom-admin
|
||||
@ -31,5 +41,6 @@ install-es:
|
||||
uninstall:
|
||||
rm -rf /opt/zenigrub-custom
|
||||
rm -rf $(PREFIX)/bin/zenigrub-custom
|
||||
rm -rf $(PREFIX)/bin/zenigrub-custom-cli
|
||||
rm $(PREFIX)/share/applications/zenigrub-custom.desktop
|
||||
|
||||
|
40
README.md
@ -1,12 +1,14 @@
|
||||
zenigrub-custom - A simple GTK (Zenity) interface to edit basic settings of GRUB
|
||||
================================================================================
|
||||
zenigrub-custom - A simple GTK (Zenity) or CLI interface to edit basic settings of GRUB.
|
||||
=========================================================================================
|
||||
|
||||
### Downloads:
|
||||
* [zenigrub-custom-1.4.tar.gz](https://github.com/q3aql/zenigrub-custom/releases/download/v1.4/zenigrub-custom-1.4.tar.gz) - Generic package (English + Spanish Languages).
|
||||
* [zenigrub-custom-1.4-en.deb](https://github.com/q3aql/zenigrub-custom/releases/download/v1.4/zenigrub-custom-1.4-en.deb) - Debian based package (English version).
|
||||
* [zenigrub-custom-1.4-en.rpm](https://github.com/q3aql/zenigrub-custom/releases/download/v1.4/zenigrub-custom-1.4-en.rpm) - RedHat/Fedora based package (English version).
|
||||
* [zenigrub-custom-1.4-es.deb](https://github.com/q3aql/zenigrub-custom/releases/download/v1.4/zenigrub-custom-1.4-es.deb) - Debian based package (Spanish version).
|
||||
* [zenigrub-custom-1.4-es.rpm](https://github.com/q3aql/zenigrub-custom/releases/download/v1.4/zenigrub-custom-1.4-es.rpm) - RedHat/Fedora based package (Spanish version).
|
||||
* [zenigrub-custom-1.6.tar.gz](https://drive.proton.me/urls/C2DT57XHFR#2jlr292SnMhb) (Generic Linux)
|
||||
* [zenigrub-custom-1.6-en.deb](https://drive.proton.me/urls/C2DT57XHFR#2jlr292SnMhb) (Debian/Ubuntu)
|
||||
* [zenigrub-custom-1.6-en.rpm](https://drive.proton.me/urls/C2DT57XHFR#2jlr292SnMhb) (RedHat/Fedora)
|
||||
* [zenigrub-custom-1.6-en.pkg.tar.zst](https://drive.proton.me/urls/C2DT57XHFR#2jlr292SnMhb) (Arch Linux)
|
||||
* [zenigrub-custom-1.6-es.deb](https://drive.proton.me/urls/C2DT57XHFR#2jlr292SnMhb) (Debian/Ubuntu - Spanish)
|
||||
* [zenigrub-custom-1.6-es.rpm](https://drive.proton.me/urls/C2DT57XHFR#2jlr292SnMhb) (RedHat/Fedora - Spanish)
|
||||
* [zenigrub-custom-1.6-es.pkg.tar.zst](https://drive.proton.me/urls/C2DT57XHFR#2jlr292SnMhb) (Arch Linux - Spanish)
|
||||
|
||||
_Dependencies: bash, coreutils, zenity, xterm, grep, sed_
|
||||
|
||||
@ -15,9 +17,9 @@ _Dependencies: bash, coreutils, zenity, xterm, grep, sed_
|
||||
* Open terminal and run the following commands:
|
||||
|
||||
```shell
|
||||
tar zxvf zenigrub-custom-1.4.tar.gz
|
||||
cd zenigrub-custom
|
||||
sudo make install
|
||||
$ tar zxvf zenigrub-custom-1.6.tar.gz
|
||||
$ cd zenigrub-custom
|
||||
$ sudo make install
|
||||
```
|
||||
|
||||
### Installation (Generic package - Spanish version):
|
||||
@ -25,14 +27,22 @@ _Dependencies: bash, coreutils, zenity, xterm, grep, sed_
|
||||
* Open terminal and run the following commands:
|
||||
|
||||
```shell
|
||||
tar zxvf zenigrub-custom-1.4.tar.gz
|
||||
cd zenigrub-custom
|
||||
sudo make install-es
|
||||
$ tar zxvf zenigrub-custom-1.6.tar.gz
|
||||
$ cd zenigrub-custom
|
||||
$ sudo make install-es
|
||||
```
|
||||
|
||||
### Images
|
||||
### Images (Screenshots - GUI Version)
|
||||
|
||||
<img src="https://raw.githubusercontent.com/q3aql/zenigrub-custom/main/img/zenigrub-image.png" width="700" />
|
||||

|
||||
|
||||
### CLI Version:
|
||||
|
||||
* For use CLI version, open terminal and run the following command:
|
||||
|
||||
```shell
|
||||
$ sudo zenigrub-custom-cli
|
||||
```
|
||||
|
||||
### External links:
|
||||
|
||||
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 16 KiB |
BIN
img/about-256.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
img/about.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
img/change-default-entry-256.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
img/change-default-entry.png
Normal file
After Width: | Height: | Size: 9.5 KiB |
BIN
img/change-grub-time-256.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
img/change-grub-time.png
Normal file
After Width: | Height: | Size: 9.5 KiB |
BIN
img/edit-boot-parameters-256.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
img/edit-boot-parameters.png
Normal file
After Width: | Height: | Size: 9.9 KiB |
BIN
img/exit-256.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
img/exit.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
img/restore-grub-settings-256.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
img/restore-grub-settings.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
img/save-grub-configuration-256.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
img/save-grub-configuration.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
img/show-current-settings-256.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
img/show-current-settings.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
img/show-grub-entries-256.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
img/show-grub-entries.png
Normal file
After Width: | Height: | Size: 9.9 KiB |
BIN
img/update-grub-256.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
img/update-grub.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 98 KiB |
@ -2,13 +2,13 @@
|
||||
|
||||
##############################################################
|
||||
# Edita ciertas opciones del GRUB graficamente #
|
||||
# U. Modificacion: 27-03-2021 #
|
||||
# U. Modificacion: 27-10-2021 #
|
||||
# Autor: q3aql #
|
||||
# Contacto: q3aql@protonmail.ch #
|
||||
# Contacto: q3aql@duck.com #
|
||||
# Licencia: GPL v2.0 #
|
||||
##############################################################
|
||||
VERSION="1.4"
|
||||
M_DATE="270321"
|
||||
VERSION="1.6"
|
||||
M_DATE="271021"
|
||||
|
||||
# Variables generales
|
||||
defaultGrub="/etc/default/grub"
|
||||
@ -19,15 +19,20 @@ zenigrubDir="/etc/zenigrub"
|
||||
tmpZenigrub="/tmp/zenigrub.tmp"
|
||||
zenigrubSedFolder="/tmp/zenigrub/word/"
|
||||
|
||||
# Variables
|
||||
iconPath="/opt/zenigrub-custom/zenigrub-custom.png"
|
||||
imagesPath="/opt/zenigrub-custom/img"
|
||||
|
||||
# Funcion para comprobar permisos de administrador
|
||||
function comprobarAdministrador() {
|
||||
mkdir -p /etc/root &> /dev/null
|
||||
administrador=$?
|
||||
if [ ${administrador} -eq 0 ] ; then
|
||||
rm -rf /etc/root
|
||||
mkdir -p ${defaultGrubFiles}
|
||||
touch ${zenigrubInit}
|
||||
else
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --warning --width=340 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=340 \
|
||||
--text "Son necesarios permisos de administrador"
|
||||
echo ""
|
||||
echo "* zenigrub-custom ${VERSION} (${M_DATE})"
|
||||
@ -38,18 +43,23 @@ function comprobarAdministrador() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para actualizar el grub
|
||||
function update-grub() {
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
||||
}
|
||||
|
||||
# Funcion para comprobar si existen los ficheros necesarios del grub
|
||||
function comprobarFicheros() {
|
||||
if [ -f ${defaultGrub} ] ; then
|
||||
if [ -f ${bootGrub} ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --warning --width=340 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=340 \
|
||||
--text "El archivo '${bootGrub}' no existe!"
|
||||
exit
|
||||
fi
|
||||
else
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --warning --width=340 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=340 \
|
||||
--text "El archivo '${defaultGrub}' no existe!"
|
||||
exit
|
||||
fi
|
||||
@ -84,7 +94,7 @@ function backupFicheros() {
|
||||
|
||||
# Funcion para restaurar la configuracion del GRUB
|
||||
function restaurarConfiguracion() {
|
||||
zenity --question --title "zenigrub-custom ${VERSION} (${M_DATE})" --cancel-label="No" \
|
||||
zenity --question --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --cancel-label="No" \
|
||||
--ok-label="Si" --width=470 --text "Se va a restaurar la configuracion inicial o la ultima guardada del GRUB. Continuar?"
|
||||
output=$?
|
||||
if [ ${output} -eq 1 ] ; then
|
||||
@ -96,12 +106,12 @@ function restaurarConfiguracion() {
|
||||
errorDos=$?
|
||||
erroresTotales=$(expr ${errorUno} + ${errorDos})
|
||||
if [ ${erroresTotales} -eq 0 ] ; then
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --info --width=340 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=340 \
|
||||
--text "La configuracion del GRUB se ha restaurado correctamente"
|
||||
rm -rfv ${zenigrubDir}/grub
|
||||
rm -rfv ${zenigrubDir}/grub.cfg
|
||||
else
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --info --width=340 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=340 \
|
||||
--text "Ha habido un problema al restaurar la configuracion del GRUB"
|
||||
fi
|
||||
fi
|
||||
@ -109,7 +119,7 @@ function restaurarConfiguracion() {
|
||||
|
||||
# Funcion para guardar la configuracion del GRUB
|
||||
function guardarConfiguracionGrub() {
|
||||
zenity --question --title "zenigrub-custom ${VERSION} (${M_DATE})" --cancel-label="No" \
|
||||
zenity --question --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --cancel-label="No" \
|
||||
--ok-label="Si" --width=470 --text "Se va a establecer la configuracion actual como por defecto. Continuar?"
|
||||
output=$?
|
||||
if [ ${output} -eq 1 ] ; then
|
||||
@ -121,10 +131,10 @@ function guardarConfiguracionGrub() {
|
||||
errorDos=$?
|
||||
erroresTotales=$(expr ${errorUno} + ${errorDos})
|
||||
if [ ${erroresTotales} -eq 0 ] ; then
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --info --width=340 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=340 \
|
||||
--text "La configuracion del GRUB se ha guardado correctamente"
|
||||
else
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --info --width=340 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=340 \
|
||||
--text "Ha habido un problema al guardar la configuracion del GRUB"
|
||||
fi
|
||||
fi
|
||||
@ -251,7 +261,7 @@ function mostrarEntradasGrub() {
|
||||
listaInicial=$(expr ${listaInicial} + 1)
|
||||
done
|
||||
zenity --width=510 --height=370 --list --title "zenigrub-custom ${VERSION} ($M_DATE) | Entradas en el GRUB:" \
|
||||
--column "Lista de entradas en el GRUB:" ${listaCompleta}
|
||||
--window-icon=${iconPath} --column "Lista de entradas en el GRUB:" ${listaCompleta}
|
||||
}
|
||||
|
||||
# Funcion para cambiar la entrada por defecto
|
||||
@ -268,7 +278,7 @@ function cambiarEntradaDefecto() {
|
||||
listaInicial=$(expr ${listaInicial} + 1)
|
||||
done
|
||||
establecerEntrada=$(zenity --width=510 --height=370 --list --title "zenigrub-custom ${VERSION} ($M_DATE)" \
|
||||
--column "Selecciona la entrada por defecto en GRUB:" ${listaCompleta})
|
||||
--window-icon=${iconPath} --column "Selecciona la entrada por defecto en GRUB:" ${listaCompleta})
|
||||
if [ ${cancelar} -eq 1 ] ; then
|
||||
mostrarMenuPrincipal
|
||||
else
|
||||
@ -303,7 +313,7 @@ function mostrarConfiguracionActual() {
|
||||
parametrosGrubLeido=$(cat ${defaultGrub} | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
done
|
||||
echo "${parametrosGrub}" > ${tmpZenigrub}
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --info --width=520 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=520 \
|
||||
--text "Configuracion GRUB:\n
|
||||
- Entrada por defecto: ${entradaDefecto}
|
||||
- Tiempo de GRUB: ${tiempoGrub}
|
||||
@ -314,7 +324,7 @@ function mostrarConfiguracionActual() {
|
||||
function cambiarTiempoGrub() {
|
||||
tiempoGrub=$(cat ${defaultGrub} | grep "GRUB_TIMEOUT=" | cut -d "=" -f 2 | cut -d '"' -f 2)
|
||||
tiempoActual=$(zenity --entry --title "zenigrub-custom ${VERSION} (${M_DATE})" \
|
||||
--text "Escribe los SEGUNDOS que estara el GRUB visible:" --entry-text "${tiempoGrub}")
|
||||
--window-icon=${iconPath} --text "Escribe los SEGUNDOS que estara el GRUB visible:" --entry-text "${tiempoGrub}")
|
||||
cancelar=$?
|
||||
if [ ${cancelar} -eq 1 ] ; then
|
||||
mostrarMenuPrincipal
|
||||
@ -348,7 +358,7 @@ function editarParametrosArranque() {
|
||||
parametrosGrub=$(cat ${tmpZenigrub})
|
||||
# Se leen y procesan los nuevos parametros
|
||||
parametrosActual=$(zenity --entry --title "zenigrub-custom ${VERSION} (${M_DATE})" \
|
||||
--text "Escribe los PARAMETROS DE ARRANQUE en el GRUB: " --entry-text "${parametrosGrubMostrar}")
|
||||
--window-icon=${iconPath} --text "Escribe los PARAMETROS DE ARRANQUE en el GRUB: " --entry-text "${parametrosGrubMostrar}")
|
||||
cancelar=$?
|
||||
if [ ${cancelar} -eq 1 ] ; then
|
||||
mostrarMenuPrincipal
|
||||
@ -371,63 +381,63 @@ function actualizandoGRUB() {
|
||||
update-grub
|
||||
output=$?
|
||||
if [ ${output} -eq 0 ] ; then
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --info --width=320 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=320 \
|
||||
--text "El proceso de actualizacion de GRUB ha finalizado!"
|
||||
else
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --error --width=320 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=320 \
|
||||
--text "Ha habido un error en el proceso de actualizacion de GRUB"
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para actualizar el GRUB mostrando la barra de progreso
|
||||
function actualizarGrub() {
|
||||
actualizandoGRUB | zenity --progress --title "zenigrub-custom ${VERSION} (${M_DATE})" --auto-close \
|
||||
actualizandoGRUB | zenity --progress --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --auto-close \
|
||||
--pulsate --text "Actualizando configuracion del GRUB"
|
||||
}
|
||||
|
||||
# Funcion para mostrar el "acerca" del programa
|
||||
function mostrarAcerca() {
|
||||
zenity --title "Acerca" --info --width=330 \
|
||||
--text "Software: zenigrub-custom ${VERSION} (${M_DATE})\nAutor: q3aql\nContacto: q3aql@protonmail.ch\nLicencia: GPL v2.0"
|
||||
zenity --title "Acerca" --window-icon=${iconPath} --info --width=330 \
|
||||
--text "Software: zenigrub-custom ${VERSION} (${M_DATE})\nAutor: q3aql\nContacto: q3aql@duck.com\nLicencia: GPL v2.0"
|
||||
}
|
||||
|
||||
# Mostrar menu con todas las opciones
|
||||
function mostrarMenuPrincipal() {
|
||||
mostrarMenu=0
|
||||
while [ ${mostrarMenu} -eq 0 ] ; do
|
||||
opcion=$(zenity --width=340 --height=365 --list --title "zenigrub-custom ${VERSION} (${M_DATE})" \
|
||||
--column "Selecciona una opcion:" "Mostrar entradadas del GRUB" "Cambiar entrada por defecto" \
|
||||
"Cambiar tiempo de GRUB" "Editar parametros de arranque" "Mostrar configuracion actual" \
|
||||
"Actualizar GRUB (update-grub)" "Guardar configuracion de GRUB" "Restaurar configuracion de GRUB" \
|
||||
"Acerca" "Salir")
|
||||
opcion=$(zenity --width=340 --height=420 --list --title "zenigrub-custom ${VERSION} (${M_DATE})" \
|
||||
--window-icon=${iconPath} --imagelist --column "Icono" --column "Opcion" ${imagesPath}/show-grub-entries.png "Mostrar entradadas del GRUB" ${imagesPath}/change-default-entry.png "Cambiar entrada por defecto" ${imagesPath}/change-grub-time.png "Cambiar tiempo de GRUB" \
|
||||
${imagesPath}/edit-boot-parameters.png "Editar parametros de arranque" ${imagesPath}/show-current-settings.png "Mostrar configuracion actual" \
|
||||
${imagesPath}/update-grub.png "Actualizar GRUB (update-grub)" ${imagesPath}/save-grub-configuration.png "Guardar configuracion de GRUB" ${imagesPath}/restore-grub-settings.png "Restaurar configuracion de GRUB" \
|
||||
${imagesPath}/about.png "Acerca" ${imagesPath}/exit.png "Salir")
|
||||
cancelar=$?
|
||||
if [ ${cancelar} -eq 1 ] ; then
|
||||
mostrarMenu=1
|
||||
exit
|
||||
else
|
||||
if [ "${opcion}" == "Mostrar entradadas del GRUB" ] ; then
|
||||
else
|
||||
if [ "${opcion}" == "${imagesPath}/show-grub-entries.png" ] ; then
|
||||
mostrarEntradasGrub
|
||||
elif [ "${opcion}" == "Cambiar entrada por defecto" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/change-default-entry.png" ] ; then
|
||||
cambiarEntradaDefecto
|
||||
elif [ "${opcion}" == "Cambiar tiempo de GRUB" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/change-grub-time.png" ] ; then
|
||||
cambiarTiempoGrub
|
||||
elif [ "${opcion}" == "Editar parametros de arranque" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/edit-boot-parameters.png" ] ; then
|
||||
editarParametrosArranque
|
||||
elif [ "${opcion}" == "Mostrar configuracion actual" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/show-current-settings.png" ] ; then
|
||||
mostrarConfiguracionActual
|
||||
elif [ "${opcion}" == "Actualizar GRUB (update-grub)" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/update-grub.png" ] ; then
|
||||
actualizarGrub
|
||||
elif [ "${opcion}" == "Guardar configuracion de GRUB" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/save-grub-configuration.png" ] ; then
|
||||
guardarConfiguracionGrub
|
||||
elif [ "${opcion}" == "Restaurar configuracion de GRUB" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/restore-grub-settings.png" ] ; then
|
||||
restaurarConfiguracion
|
||||
elif [ "${opcion}" == "Acerca" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/about.png" ] ; then
|
||||
mostrarAcerca
|
||||
elif [ "${opcion}" == "Salir" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/exit.png" ] ; then
|
||||
mostrarMenu=1
|
||||
exit
|
||||
else
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --warning --width=300 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=300 \
|
||||
--text "Elige una de las opciones del menu"
|
||||
fi
|
||||
fi
|
||||
|
@ -2,13 +2,16 @@
|
||||
|
||||
##############################################################
|
||||
# Edita ciertas opciones del GRUB graficamente #
|
||||
# U. Modificacion: 27-03-2021 #
|
||||
# U. Modificacion: 27-10-2021 #
|
||||
# Autor: q3aql #
|
||||
# Contacto: q3aql@protonmail.ch #
|
||||
# Contacto: q3aql@duck.com #
|
||||
# Licencia: GPL v2.0 #
|
||||
##############################################################
|
||||
VERSION="1.4"
|
||||
M_DATE="270321"
|
||||
VERSION="1.6"
|
||||
M_DATE="271021"
|
||||
|
||||
# Variables
|
||||
iconPath="/opt/zenigrub-custom/zenigrub-custom.png"
|
||||
|
||||
# Enlace con gksudo,gksu o bessu a zenigrub-custom
|
||||
function showRootMessage() {
|
||||
@ -46,7 +49,7 @@ function showRootMessage() {
|
||||
zenity -h &> /dev/null
|
||||
output=$?
|
||||
if [ ${output} -eq 0 ] ; then
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --info \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --width 450 --info \
|
||||
--text "El programa 'zenigrub-custom' no ha podido ser ejecutado como administrador\n\nPor favor, ejecuta el comando 'zenigrub-custom' como usuario root en la terminal"
|
||||
else
|
||||
xterm -T "zenigrub-custom ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "zenigrub-custom-admin --error"
|
||||
|
546
src-ES/zenigrub-custom-cli
Executable file
@ -0,0 +1,546 @@
|
||||
#!/bin/bash
|
||||
|
||||
##############################################################
|
||||
# Edita ciertas opciones del GRUB mediante terminal #
|
||||
# U. Modificacion: 27-10-2021 #
|
||||
# Autor: q3aql #
|
||||
# Contacto: q3aql@duck.com #
|
||||
# Licencia: GPL v2.0 #
|
||||
##############################################################
|
||||
VERSION="1.6"
|
||||
M_DATE="271021"
|
||||
|
||||
# Variables generales
|
||||
defaultGrub="/etc/default/grub"
|
||||
defaultGrubFiles="/etc/default/grub.d"
|
||||
zenigrubInit="${defaultGrubFiles}/zenigrub-init.cfg"
|
||||
bootGrub="/boot/grub/grub.cfg"
|
||||
zenigrubDir="/etc/zenigrub"
|
||||
tmpZenigrub="/tmp/zenigrub.tmp"
|
||||
zenigrubSedFolder="/tmp/zenigrub/word/"
|
||||
|
||||
# Variables
|
||||
iconPath="/opt/zenigrub-custom/zenigrub-custom.png"
|
||||
imagesPath="/opt/zenigrub-custom/img"
|
||||
|
||||
# Funcion para comprobar permisos de administrador
|
||||
function comprobarAdministrador() {
|
||||
mkdir -p /etc/root &> /dev/null
|
||||
administrador=$?
|
||||
if [ ${administrador} -eq 0 ] ; then
|
||||
rm -rf /etc/root
|
||||
mkdir -p ${defaultGrubFiles}
|
||||
touch ${zenigrubInit}
|
||||
else
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "* Son necesarios permisos de administrador."
|
||||
echo ""
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para actualizar el grub
|
||||
function update-grub() {
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
||||
}
|
||||
|
||||
# Funcion para comprobar si existen los ficheros necesarios del grub
|
||||
function comprobarFicheros() {
|
||||
if [ -f ${defaultGrub} ] ; then
|
||||
if [ -f ${bootGrub} ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "+ El archivo '${bootGrub}' no existe!"
|
||||
echo ""
|
||||
exit
|
||||
fi
|
||||
else
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "+ El archivo '${defaultGrub}' no existe!"
|
||||
echo ""
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para hacer backup de los ficheros
|
||||
function backupFicheros() {
|
||||
mkdir -p ${zenigrubDir}
|
||||
if [ -f ${zenigrubDir}/grub ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
cp -rfv ${defaultGrub} ${zenigrubDir}
|
||||
fi
|
||||
if [ -f ${zenigrubDir}/grub.initial ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
cp -rfv ${defaultGrub} ${zenigrubDir}/grub.initial
|
||||
fi
|
||||
if [ -f ${zenigrubDir}/grub.cfg ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
cp -rfv ${bootGrub} ${zenigrubDir}
|
||||
fi
|
||||
if [ -f ${zenigrubDir}/grub.cfg.initial ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
cp -rfv ${bootGrub} ${zenigrubDir}/grub.cfg.initial
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
|
||||
# Funcion para restaurar la configuracion del GRUB
|
||||
function restaurarConfiguracion() {
|
||||
clear
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "* Se va a restaurar la configuracion o la ultima guardada del GRUB!."
|
||||
echo -n "+ [Por defecto: n] Deseas continuar? (s/n): " ; read restore_grub
|
||||
if [ -z "${restore_grub}" ] ; then
|
||||
echo "null" > /dev/null
|
||||
elif [ "${restore_grub}" == "n" ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
cp -rfv ${zenigrubDir}/grub ${defaultGrub}
|
||||
errorUno=$?
|
||||
cp -rfv ${zenigrubDir}/grub.cfg ${bootGrub}
|
||||
errorDos=$?
|
||||
erroresTotales=$(expr ${errorUno} + ${errorDos})
|
||||
if [ ${erroresTotales} -eq 0 ] ; then
|
||||
rm -rfv ${zenigrubDir}/grub
|
||||
rm -rfv ${zenigrubDir}/grub.cfg
|
||||
echo ""
|
||||
echo "* La configuracion del GRUB ha sido correctamente restaurada."
|
||||
echo ""
|
||||
echo -n "+ Pulsa INTRO para continuar.. " ; read continue
|
||||
else
|
||||
echo ""
|
||||
echo "* Ha habido un problema restaurando la configuracion del GRUB."
|
||||
echo ""
|
||||
echo -n "+ Pulsa INTRO para continuar.. " ; read continue
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para guardar la configuracion del GRUB
|
||||
function guardarConfiguracionGrub() {
|
||||
clear
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "* Se va a establecer la configuracion actual como por defecto."
|
||||
echo -n "+ [Por defecto: n] Deseas continuar? (s/n): " ; read save_grub
|
||||
if [ -z "${save_grub}" ] ; then
|
||||
echo "null" > /dev/null
|
||||
elif [ "${save_grub}" == "n" ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
cp -rfv ${defaultGrub} ${zenigrubDir}
|
||||
errorUno=$?
|
||||
cp -rfv ${bootGrub} ${zenigrubDir}
|
||||
errorDos=$?
|
||||
erroresTotales=$(expr ${errorUno} + ${errorDos})
|
||||
if [ ${erroresTotales} -eq 0 ] ; then
|
||||
echo ""
|
||||
echo "* La configuracion GRUB se ha guardado correctamente."
|
||||
echo ""
|
||||
echo -n "+ Pulsa INTRO para continuar " ; read continue
|
||||
else
|
||||
echo ""
|
||||
echo "* Ha habido un problema guardando la configuracion del GRUB."
|
||||
echo ""
|
||||
echo -n "+ Pulsa INTRO para continuar.. " ; read continue
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para habilitar las opciones necesarias
|
||||
function habilitarOpciones() {
|
||||
# Habilitar las opciones si se encuentra desactivadas
|
||||
sed -i 's/#GRUB_DEFAULT=/GRUB_DEFAULT=/g' "${defaultGrub}" &> /dev/null
|
||||
sed -i 's/#GRUB_TIMEOUT=/GRUB_TIMEOUT=/g' "${defaultGrub}" &> /dev/null
|
||||
sed -i 's/#GRUB_CMDLINE_LINUX_DEFAULT=/GRUB_CMDLINE_LINUX_DEFAULT=/g' "${defaultGrub}" &> /dev/null
|
||||
sed -i 's/GRUB_HIDDEN_TIMEOUT=/#Disabled_GRUB_HIDDEN_TIMEOUT/g' "${defaultGrubFiles}"/* &> /dev/null
|
||||
TiempoDesactivado=$(cat ${defaultGrub} | grep "#GRUB_HIDDEN_TIMEOUT=")
|
||||
if [ -z "${TiempoDesactivado}" ] ; then
|
||||
sed -i 's/GRUB_HIDDEN_TIMEOUT=/#GRUB_HIDDEN_TIMEOUT=/g' "${defaultGrub}" &> /dev/null
|
||||
fi
|
||||
# Comprobar si las lineas se encuentran agregadas
|
||||
comprobarGrubDefault=$(cat ${defaultGrub} | grep "GRUB_DEFAULT=")
|
||||
comprobarGrubTimeout=$(cat ${defaultGrub} | grep "GRUB_TIMEOUT=")
|
||||
comprobarGrubCmdLineDefault=$(cat ${defaultGrub} | grep "GRUB_CMDLINE_LINUX_DEFAULT=")
|
||||
if [ -z "${comprobarGrubDefault}" ] ; then
|
||||
echo "GRUB_DEFAULT=\"0\"" > /etc/default/grub.tmp
|
||||
cat ${defaultGrub} >> /etc/default/grub.tmp
|
||||
cp -rfv /etc/default/grub.tmp ${defaultGrub}
|
||||
fi
|
||||
if [ -z "${comprobarGrubTimeout}" ] ; then
|
||||
echo "GRUB_TIMEOUT=\"10\"" > /etc/default/grub.tmp
|
||||
cat ${defaultGrub} >> /etc/default/grub.tmp
|
||||
cp -rfv /etc/default/grub.tmp ${defaultGrub}
|
||||
fi
|
||||
if [ -z "${comprobarGrubCmdLineDefault}" ] ; then
|
||||
parametrosAnterior=$(cat "${defaultGrubFiles}"/* | grep "GRUB_CMDLINE_LINUX_DEFAULT=")
|
||||
if [ -z "${parametrosAnterior}" ] ; then
|
||||
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"\"" > /etc/default/grub.tmp
|
||||
cat ${defaultGrub} >> /etc/default/grub.tmp
|
||||
cp -rfv /etc/default/grub.tmp ${defaultGrub}
|
||||
else
|
||||
LineaInicial=2
|
||||
cat "${defaultGrubFiles}"/* | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 2 > ${tmpZenigrub}
|
||||
parametrosGrub=$(cat ${tmpZenigrub})
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeido=$(cat "${defaultGrubFiles}"/* | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
while [ "${parametrosGrubLeido}" != "" ] ; do
|
||||
parametrosGrub="${parametrosGrub}=${parametrosGrubLeido}"
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeido=$(cat "${defaultGrubFiles}"/* | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
done
|
||||
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"${parametrosGrub}\"" > /etc/default/grub.tmp
|
||||
cat ${defaultGrub} >> /etc/default/grub.tmp
|
||||
cp -rfv /etc/default/grub.tmp ${defaultGrub}
|
||||
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT=/#Disabled_GRUB_CMDLINE_LINUX_DEFAULT/g' "${defaultGrubFiles}"/* &> /dev/null
|
||||
fi
|
||||
fi
|
||||
parametrosAnterior=$(cat "${defaultGrubFiles}"/* | grep "GRUB_CMDLINE_LINUX_DEFAULT=")
|
||||
if [ -z "${parametrosAnterior}" ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
LineaInicial=2
|
||||
cat "${defaultGrubFiles}"/* | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 2 > ${tmpZenigrub}
|
||||
parametrosGrubAnterior=$(cat ${tmpZenigrub})
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeidoAnterior=$(cat "${defaultGrubFiles}"/* | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
while [ "${parametrosGrubLeidoAnterior}" != "" ] ; do
|
||||
parametrosGrubAnterior="${parametrosGrubAnterior}=${parametrosGrubLeidoAnterior}"
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeidoAnterior=$(cat "${defaultGrubFiles}"/* | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
done
|
||||
LineaInicial=2
|
||||
cat "${defaultGrub}" | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 2 > ${tmpZenigrub}
|
||||
parametrosGrub=$(cat ${tmpZenigrub})
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeido=$(cat "${defaultGrub}" | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
while [ "${parametrosGrubLeido}" != "" ] ; do
|
||||
parametrosGrub="${parametrosGrub}=${parametrosGrubLeido}"
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeido=$(cat "${defaultGrub}" | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
done
|
||||
sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=\"${parametrosGrub}\"/GRUB_CMDLINE_LINUX_DEFAULT=\"${parametrosGrubAnterior}\"/g" "${defaultGrub}"
|
||||
sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=${parametrosGrub}/GRUB_CMDLINE_LINUX_DEFAULT=\"${parametrosGrubAnterior}\"/g" "${defaultGrub}"
|
||||
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT=/#Disabled_GRUB_CMDLINE_LINUX_DEFAULT/g' "${defaultGrubFiles}"/* &> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para eliminar espacios
|
||||
# Sintaxis: eliminarEspacios "<texto>"
|
||||
function eliminarEspacios() {
|
||||
wordToConvert=${1}
|
||||
zenigrubSedFile="${zenigrubSedFolder}/zenigrub-${RANDOM}.txt"
|
||||
mkdir -p ${zenigrubSedFolder} && chmod 777 -R ${zenigrubSedFolder} 2> /dev/null
|
||||
echo "${wordToConvert}" > ${zenigrubSedFile}
|
||||
# Borrar espacios
|
||||
sed -i 's/ /_/g' "${zenigrubSedFile}" &> /dev/null
|
||||
# Mostrar texto convertido
|
||||
wordToConvert=$(cat ${zenigrubSedFile})
|
||||
echo ${wordToConvert}
|
||||
}
|
||||
|
||||
# Funcion para restaurar los espacios
|
||||
# Sintaxis: restaEspacios "<texto>"
|
||||
function restaurarEspacios() {
|
||||
wordToConvert=${1}
|
||||
zenigrubSedFile="${zenigrubSedFolder}/zenigrub-${RANDOM}.txt"
|
||||
mkdir -p ${zenigrubSedFolder} && chmod 777 -R ${zenigrubSedFolder} 2> /dev/null
|
||||
echo "${wordToConvert}" > ${zenigrubSedFile}
|
||||
# Borrar espacios
|
||||
sed -i 's/_/\\ /g' "${zenigrubSedFile}" &> /dev/null
|
||||
sed -i 's/\//\\\//g' "${zenigrubSedFile}" &> /dev/null
|
||||
# Mostrar texto convertido
|
||||
wordToConvert=$(cat ${zenigrubSedFile})
|
||||
echo ${wordToConvert}
|
||||
}
|
||||
|
||||
# Funcion para mostrar las entradas del GRUB
|
||||
function mostrarEntradasGrub() {
|
||||
grep 'menuentry "' /boot/grub/grub.cfg | cut -d '"' -f 2 > ${tmpZenigrub}
|
||||
grep "menuentry '" /boot/grub/grub.cfg | cut -d "'" -f 2 >> ${tmpZenigrub}
|
||||
listaTotal=$(wc -l ${tmpZenigrub} | cut -d " " -f 1)
|
||||
listaInicial=1
|
||||
listaCompleta=""
|
||||
clear
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} ($M_DATE)"
|
||||
echo ""
|
||||
echo "* Lista de entradas en el GRUB:"
|
||||
echo ""
|
||||
#echo ${listaCompleta}
|
||||
while [ ${listaInicial} -le ${listaTotal} ] ; do
|
||||
entradaLeida=$(cat ${tmpZenigrub} | head -${listaInicial} | tail -1)
|
||||
entradaLeida=$(eliminarEspacios "${entradaLeida}")
|
||||
#listaCompleta="${listaCompleta} ${entradaLeida}"
|
||||
echo " - ${entradaLeida}"
|
||||
listaInicial=$(expr ${listaInicial} + 1)
|
||||
done
|
||||
echo ""
|
||||
echo -n "+ Pulsa INTRO para continuar.. " ; read continue
|
||||
}
|
||||
|
||||
# Funcion para cambiar la entrada por defecto
|
||||
function cambiarEntradaDefecto() {
|
||||
grep 'menuentry "' /boot/grub/grub.cfg | cut -d '"' -f 2 > ${tmpZenigrub}
|
||||
grep "menuentry '" /boot/grub/grub.cfg | cut -d "'" -f 2 >> ${tmpZenigrub}
|
||||
listaTotal=$(wc -l ${tmpZenigrub} | cut -d " " -f 1)
|
||||
listaInicial=1
|
||||
listaCompleta=""
|
||||
clear
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} ($M_DATE)"
|
||||
echo ""
|
||||
echo "* Escribe el numero de la entrada GRUB para establecerla por defecto:"
|
||||
echo ""
|
||||
while [ ${listaInicial} -le ${listaTotal} ] ; do
|
||||
entradaLeida=$(cat ${tmpZenigrub} | head -${listaInicial} | tail -1)
|
||||
entradaLeida=$(eliminarEspacios "${entradaLeida}")
|
||||
#listaCompleta="${listaCompleta} ${entradaLeida}"
|
||||
echo " ${listaInicial} --> ${entradaLeida}"
|
||||
listaInicial=$(expr ${listaInicial} + 1)
|
||||
done
|
||||
echo ""
|
||||
echo " r --> Volver al menu (cancelar)"
|
||||
echo ""
|
||||
echo -n "+ [Por defecto: r] Escribe la opcion: " ; read option_grub
|
||||
if [ -z "${option_grub}" ] ; then
|
||||
mostrarMenuPrincipal
|
||||
elif [ "${option_grub}" == "r" ] ; then
|
||||
mostrarMenuPrincipal
|
||||
else
|
||||
if [ -z "${option_grub}" ] ; then
|
||||
mostrarMenuPrincipal
|
||||
else
|
||||
expr ${option_grub} + 1 2>/dev/null
|
||||
check_number=$?
|
||||
if [ ${check_number} -eq 0 ] ; then
|
||||
echo ""
|
||||
listaInicial=1
|
||||
listaTotal=${option_grub}
|
||||
while [ ${listaInicial} -le ${listaTotal} ] ; do
|
||||
entradaLeida=$(cat ${tmpZenigrub} | head -${listaInicial} | tail -1)
|
||||
entradaLeida=$(eliminarEspacios "${entradaLeida}")
|
||||
#listaCompleta="${listaCompleta} ${entradaLeida}"
|
||||
listaInicial=$(expr ${listaInicial} + 1)
|
||||
done
|
||||
entradaDefecto=$(cat ${defaultGrub} | grep "GRUB_DEFAULT=" | cut -d "=" -f 2 | cut -d '"' -f 2)
|
||||
entradaAnterior=$(eliminarEspacios "${entradaDefecto}")
|
||||
entradaAnterior=$(restaurarEspacios ${entradaAnterior})
|
||||
nuevaEntrada=$(restaurarEspacios ${entradaLeida})
|
||||
echo "* The current entry is '${entradaAnterior}'"
|
||||
echo "* It has been defined as main entrance to '${nuevaEntrada}'"
|
||||
sed -i "s/GRUB_DEFAULT=\"${entradaAnterior}\"/GRUB_DEFAULT=\"${nuevaEntrada}\"/g" "${defaultGrub}"
|
||||
sed -i "s/GRUB_DEFAULT=${entradaAnterior}/GRUB_DEFAULT=\"${nuevaEntrada}\"/g" "${defaultGrub}"
|
||||
actualizarGrub
|
||||
else
|
||||
mostrarMenuPrincipal
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para mostrar la configuracion por defecto
|
||||
function mostrarConfiguracionActual() {
|
||||
entradaDefecto=$(cat ${defaultGrub} | grep "GRUB_DEFAULT=" | cut -d "=" -f 2 | cut -d '"' -f 2)
|
||||
tiempoGrub=$(cat ${defaultGrub} | grep "GRUB_TIMEOUT=" | cut -d "=" -f 2 | cut -d '"' -f 2)
|
||||
LineaInicial=2
|
||||
cat ${defaultGrub} | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 2 > ${tmpZenigrub}
|
||||
parametrosGrub=$(cat ${tmpZenigrub})
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeido=$(cat ${defaultGrub} | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
while [ "${parametrosGrubLeido}" != "" ] ; do
|
||||
parametrosGrub="${parametrosGrub}=${parametrosGrubLeido}"
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeido=$(cat ${defaultGrub} | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
done
|
||||
clear
|
||||
echo "${parametrosGrub}" > ${tmpZenigrub}
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "* Configuracion GRUB:"
|
||||
echo ""
|
||||
echo " - Entrada por defecto: ${entradaDefecto}"
|
||||
echo " - Tiempo de GRUB: ${tiempoGrub}"
|
||||
echo " - Parametros de arranque: ${parametrosGrub}"
|
||||
echo ""
|
||||
echo -n "+ Pulsa INTRO para continuar.. " ; read continue
|
||||
}
|
||||
|
||||
# Funcion para cambiar el tiempo del GRUB
|
||||
function cambiarTiempoGrub() {
|
||||
tiempoGrub=$(cat ${defaultGrub} | grep "GRUB_TIMEOUT=" | cut -d "=" -f 2 | cut -d '"' -f 2)
|
||||
clear
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo -n "* [Actual: ${tiempoGrub}] Escribe los SEGUNDOS que estara el GRUB visible: " ; read time_grub
|
||||
tiempoActual=${time_grub}
|
||||
if [ -z "${time_grub}" ] ; then
|
||||
mostrarMenuPrincipal
|
||||
else
|
||||
if [ -z "${tiempoActual}" ] ; then
|
||||
actualizarGrub
|
||||
else
|
||||
expr ${tiempoActual} + 1 2>/dev/null
|
||||
error_time=$?
|
||||
if [ ${error_time} -eq 0 ] ; then
|
||||
sed -i "s/GRUB_TIMEOUT=\"${tiempoGrub}\"/GRUB_TIMEOUT=\"${tiempoActual}\"/g" "${defaultGrub}"
|
||||
sed -i "s/GRUB_TIMEOUT=${tiempoGrub}/GRUB_TIMEOUT=\"${tiempoActual}\"/g" "${defaultGrub}"
|
||||
actualizarGrub
|
||||
else
|
||||
mostrarMenuPrincipal
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para editar los parametros de arranque
|
||||
function editarParametrosArranque() {
|
||||
# Se cargan los actuales parametros de arranque
|
||||
LineaInicial=2
|
||||
cat ${defaultGrub} | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 2 > ${tmpZenigrub}
|
||||
parametrosGrub=$(cat ${tmpZenigrub})
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeido=$(cat ${defaultGrub} | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
while [ "${parametrosGrubLeido}" != "" ] ; do
|
||||
parametrosGrub="${parametrosGrub}=${parametrosGrubLeido}"
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeido=$(cat ${defaultGrub} | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
done
|
||||
echo "${parametrosGrub}" > ${tmpZenigrub}
|
||||
parametrosGrubMostrar=$(cat ${tmpZenigrub})
|
||||
sed -i 's/ /\\ /g' "${tmpZenigrub}" &> /dev/null
|
||||
parametrosGrub=$(cat ${tmpZenigrub})
|
||||
# Se leen y procesan los nuevos parametros
|
||||
clear
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "+ Parametros actuales: ${parametrosGrubMostrar}"
|
||||
echo -n "* Escribe los PARAMETROS DE ARRANQUE en el GRUB: " ; read parametrosActual
|
||||
cancelar=$?
|
||||
if [ -z "${parametrosActual}" ] ; then
|
||||
mostrarMenuPrincipal
|
||||
else
|
||||
if [ -z "${parametrosActual}" ] ; then
|
||||
mostrarMenuPrincipal
|
||||
else
|
||||
echo ${parametrosActual} > ${tmpZenigrub}
|
||||
sed -i 's/ /\\ /g' "${tmpZenigrub}" &> /dev/null
|
||||
parametrosActual=$(cat ${tmpZenigrub})
|
||||
sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=\"${parametrosGrub}\"/GRUB_CMDLINE_LINUX_DEFAULT=\"${parametrosActual}\"/g" "${defaultGrub}"
|
||||
sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=${parametrosGrub}/GRUB_CMDLINE_LINUX_DEFAULT=\"${parametrosActual}\"/g" "${defaultGrub}"
|
||||
actualizarGrub
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para actualizar el GRUB
|
||||
function actualizarGrub() {
|
||||
echo ""
|
||||
echo "* Actualizando configuracion del GRUB."
|
||||
update-grub
|
||||
output=$?
|
||||
if [ ${output} -eq 0 ] ; then
|
||||
echo "* El proceso de actualizacion de GRUB ha finalizado!"
|
||||
echo ""
|
||||
echo -n "+ Pulsa INTRO para continuar.. " ; read continue
|
||||
else
|
||||
echo "* Ha habido un error en el proceso de actualizacion del GRUB."
|
||||
echo ""
|
||||
echo -n "+ Pulsa INTRO para continuar.. " ; read continue
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para mostrar el "acerca" del programa
|
||||
function mostrarAcerca() {
|
||||
clear
|
||||
echo ""
|
||||
echo "* Acerca:"
|
||||
echo ""
|
||||
echo " - Software: zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo " - Autor: q3aql"
|
||||
echo " - Contacto: q3aql@duck.com"
|
||||
echo " - Licencia: GPL v2.0"
|
||||
echo ""
|
||||
echo -n "+ Pulsa INTRO para continuar.. " ; read continue
|
||||
}
|
||||
|
||||
# Mostrar menu con todas las opciones
|
||||
function mostrarMenuPrincipal() {
|
||||
mostrarMenu=0
|
||||
while [ ${mostrarMenu} -eq 0 ] ; do
|
||||
clear
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo " g --> Mostrar entradas del GRUB"
|
||||
echo " d --> Cambiar entrada por defecto"
|
||||
echo " t --> Cambiar tiempo de GRUB"
|
||||
echo " e --> Editar parametros de arranque"
|
||||
echo " c --> Mostrar configuracion actual"
|
||||
echo " u --> Actualizar GRUB (update-grub)"
|
||||
echo " s --> Guardar configuracion de GRUB"
|
||||
echo " r --> Restaurar configuracion de GRUB"
|
||||
echo " a --> Acerca"
|
||||
echo ""
|
||||
echo " q --> Salir"
|
||||
echo ""
|
||||
echo -n "* Escribe una opcion (ejemplo: g): " ; read opcion
|
||||
cancelar=$?
|
||||
if [ ${cancelar} -eq 1 ] ; then
|
||||
mostrarMenu=1
|
||||
exit
|
||||
else
|
||||
if [ "${opcion}" == "g" ] ; then
|
||||
mostrarEntradasGrub
|
||||
elif [ "${opcion}" == "d" ] ; then
|
||||
cambiarEntradaDefecto
|
||||
elif [ "${opcion}" == "t" ] ; then
|
||||
cambiarTiempoGrub
|
||||
elif [ "${opcion}" == "e" ] ; then
|
||||
editarParametrosArranque
|
||||
elif [ "${opcion}" == "c" ] ; then
|
||||
mostrarConfiguracionActual
|
||||
elif [ "${opcion}" == "u" ] ; then
|
||||
actualizarGrub
|
||||
elif [ "${opcion}" == "s" ] ; then
|
||||
guardarConfiguracionGrub
|
||||
elif [ "${opcion}" == "r" ] ; then
|
||||
restaurarConfiguracion
|
||||
elif [ "${opcion}" == "a" ] ; then
|
||||
mostrarAcerca
|
||||
elif [ "${opcion}" == "q" ] ; then
|
||||
mostrarMenu=1
|
||||
exit
|
||||
else
|
||||
echo ""
|
||||
echo "+ Elige una de las opciones del menu."
|
||||
echo ""
|
||||
echo "+ Pulsa INTRO para continuar.. " ; read continue
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Iniciar aplicacion
|
||||
comprobarAdministrador
|
||||
comprobarFicheros
|
||||
habilitarOpciones
|
||||
backupFicheros
|
||||
mostrarMenuPrincipal
|
@ -2,13 +2,13 @@
|
||||
|
||||
##############################################################
|
||||
# Edita ciertas opciones del GRUB graficamente #
|
||||
# U. Modificacion: 27-03-2021 #
|
||||
# U. Modificacion: 27-10-2021 #
|
||||
# Autor: q3aql #
|
||||
# Contacto: q3aql@protonmail.ch #
|
||||
# Contacto: q3aql@duck.com #
|
||||
# Licencia: GPL v2.0 #
|
||||
##############################################################
|
||||
VERSION="1.4"
|
||||
M_DATE="270321"
|
||||
VERSION="1.6"
|
||||
M_DATE="271021"
|
||||
|
||||
# Variables generales
|
||||
defaultGrub="/etc/default/grub"
|
||||
@ -19,15 +19,20 @@ zenigrubDir="/etc/zenigrub"
|
||||
tmpZenigrub="/tmp/zenigrub.tmp"
|
||||
zenigrubSedFolder="/tmp/zenigrub/word/"
|
||||
|
||||
# Variables
|
||||
iconPath="/opt/zenigrub-custom/zenigrub-custom.png"
|
||||
imagesPath="/opt/zenigrub-custom/img"
|
||||
|
||||
# Funcion para comprobar permisos de administrador
|
||||
function comprobarAdministrador() {
|
||||
mkdir -p /etc/root &> /dev/null
|
||||
administrador=$?
|
||||
if [ ${administrador} -eq 0 ] ; then
|
||||
rm -rf /etc/root
|
||||
mkdir -p ${defaultGrubFiles}
|
||||
touch ${zenigrubInit}
|
||||
else
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --warning --width=340 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=340 \
|
||||
--text "Administrator permissions are required "
|
||||
echo ""
|
||||
echo "* zenigrub-custom ${VERSION} (${M_DATE})"
|
||||
@ -38,18 +43,23 @@ function comprobarAdministrador() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para actualizar el grub
|
||||
function update-grub() {
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
||||
}
|
||||
|
||||
# Funcion para comprobar si existen los ficheros necesarios del grub
|
||||
function comprobarFicheros() {
|
||||
if [ -f ${defaultGrub} ] ; then
|
||||
if [ -f ${bootGrub} ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --warning --width=340 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=340 \
|
||||
--text "The file '${bootGrub}' doesn't exist!"
|
||||
exit
|
||||
fi
|
||||
else
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --warning --width=340 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=340 \
|
||||
--text "The file '${defaultGrub}' doesn't exist!"
|
||||
exit
|
||||
fi
|
||||
@ -84,7 +94,7 @@ function backupFicheros() {
|
||||
|
||||
# Funcion para restaurar la configuracion del GRUB
|
||||
function restaurarConfiguracion() {
|
||||
zenity --question --title "zenigrub-custom ${VERSION} (${M_DATE})" --cancel-label="No" \
|
||||
zenity --question --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --cancel-label="No" \
|
||||
--ok-label="Yes" --width=470 --text "The initial or last saved GRUB configuration will be restored. Continue?"
|
||||
output=$?
|
||||
if [ ${output} -eq 1 ] ; then
|
||||
@ -96,12 +106,12 @@ function restaurarConfiguracion() {
|
||||
errorDos=$?
|
||||
erroresTotales=$(expr ${errorUno} + ${errorDos})
|
||||
if [ ${erroresTotales} -eq 0 ] ; then
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --info --width=340 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=340 \
|
||||
--text "GRUB settings have been successfully restored"
|
||||
rm -rfv ${zenigrubDir}/grub
|
||||
rm -rfv ${zenigrubDir}/grub.cfg
|
||||
else
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --info --width=340 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=340 \
|
||||
--text "There was a problem restoring the GRUB configuration"
|
||||
fi
|
||||
fi
|
||||
@ -109,7 +119,7 @@ function restaurarConfiguracion() {
|
||||
|
||||
# Funcion para guardar la configuracion del GRUB
|
||||
function guardarConfiguracionGrub() {
|
||||
zenity --question --title "zenigrub-custom ${VERSION} (${M_DATE})" --cancel-label="No" \
|
||||
zenity --question --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --cancel-label="No" \
|
||||
--ok-label="Yes" --width=470 --text "The current configuration will be set as the default. Continue?"
|
||||
output=$?
|
||||
if [ ${output} -eq 1 ] ; then
|
||||
@ -121,10 +131,10 @@ function guardarConfiguracionGrub() {
|
||||
errorDos=$?
|
||||
erroresTotales=$(expr ${errorUno} + ${errorDos})
|
||||
if [ ${erroresTotales} -eq 0 ] ; then
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --info --width=340 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=340 \
|
||||
--text "GRUB configuration has been saved successfully"
|
||||
else
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --info --width=340 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=340 \
|
||||
--text "There was a problem saving the GRUB configuration"
|
||||
fi
|
||||
fi
|
||||
@ -251,7 +261,7 @@ function mostrarEntradasGrub() {
|
||||
listaInicial=$(expr ${listaInicial} + 1)
|
||||
done
|
||||
zenity --width=510 --height=370 --list --title "zenigrub-custom ${VERSION} ($M_DATE) | Entries of GRUB:" \
|
||||
--column "List of entries of GRUB:" ${listaCompleta}
|
||||
--window-icon=${iconPath} --column "List of entries of GRUB:" ${listaCompleta}
|
||||
}
|
||||
|
||||
# Funcion para cambiar la entrada por defecto
|
||||
@ -268,7 +278,7 @@ function cambiarEntradaDefecto() {
|
||||
listaInicial=$(expr ${listaInicial} + 1)
|
||||
done
|
||||
establecerEntrada=$(zenity --width=510 --height=370 --list --title "zenigrub-custom ${VERSION} ($M_DATE)" \
|
||||
--column "Select the default entry in GRUB:" ${listaCompleta})
|
||||
--window-icon=${iconPath} --column "Select the default entry in GRUB:" ${listaCompleta})
|
||||
if [ ${cancelar} -eq 1 ] ; then
|
||||
mostrarMenuPrincipal
|
||||
else
|
||||
@ -303,7 +313,7 @@ function mostrarConfiguracionActual() {
|
||||
parametrosGrubLeido=$(cat ${defaultGrub} | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
done
|
||||
echo "${parametrosGrub}" > ${tmpZenigrub}
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --info --width=520 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=520 \
|
||||
--text "GRUB configuration:\n
|
||||
- Default entry: ${entradaDefecto}
|
||||
- GRUB time: ${tiempoGrub}
|
||||
@ -313,7 +323,7 @@ function mostrarConfiguracionActual() {
|
||||
# Funcion para cambiar el tiempo del GRUB
|
||||
function cambiarTiempoGrub() {
|
||||
tiempoGrub=$(cat ${defaultGrub} | grep "GRUB_TIMEOUT=" | cut -d "=" -f 2 | cut -d '"' -f 2)
|
||||
tiempoActual=$(zenity --entry --title "zenigrub-custom ${VERSION} (${M_DATE})" \
|
||||
tiempoActual=$(zenity --entry --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} \
|
||||
--text "Type the SECONDS that the GRUB will be visible:" --entry-text "${tiempoGrub}")
|
||||
cancelar=$?
|
||||
if [ ${cancelar} -eq 1 ] ; then
|
||||
@ -347,7 +357,7 @@ function editarParametrosArranque() {
|
||||
sed -i 's/ /\\ /g' "${tmpZenigrub}" &> /dev/null
|
||||
parametrosGrub=$(cat ${tmpZenigrub})
|
||||
# Se leen y procesan los nuevos parametros
|
||||
parametrosActual=$(zenity --entry --title "zenigrub-custom ${VERSION} (${M_DATE})" \
|
||||
parametrosActual=$(zenity --entry --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} \
|
||||
--text "Type the BOOT PARAMETERS in GRUB: " --entry-text "${parametrosGrubMostrar}")
|
||||
cancelar=$?
|
||||
if [ ${cancelar} -eq 1 ] ; then
|
||||
@ -371,63 +381,64 @@ function actualizandoGRUB() {
|
||||
update-grub
|
||||
output=$?
|
||||
if [ ${output} -eq 0 ] ; then
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --info --width=320 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=320 \
|
||||
--text "GRUB update process is complete!"
|
||||
else
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --error --width=320 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=320 \
|
||||
--text "There was an error in the GRUB update process"
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para actualizar el GRUB mostrando la barra de progreso
|
||||
function actualizarGrub() {
|
||||
actualizandoGRUB | zenity --progress --title "zenigrub-custom ${VERSION} (${M_DATE})" --auto-close \
|
||||
actualizandoGRUB | zenity --progress --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --auto-close \
|
||||
--pulsate --text "Updating GRUB configuration"
|
||||
}
|
||||
|
||||
# Funcion para mostrar el "acerca" del programa
|
||||
function mostrarAcerca() {
|
||||
zenity --title "About" --info --width=330 \
|
||||
--text "Software: zenigrub-custom ${VERSION} (${M_DATE})\nAuthor: q3aql\nContact: q3aql@protonmail.ch\nLicense: GPL v2.0"
|
||||
zenity --title "About" --window-icon=${iconPath} --info --width=330 \
|
||||
--text "Software: zenigrub-custom ${VERSION} (${M_DATE})\nAuthor: q3aql\nContact: q3aql@duck.com\nLicense: GPL v2.0"
|
||||
}
|
||||
|
||||
# Mostrar menu con todas las opciones
|
||||
function mostrarMenuPrincipal() {
|
||||
mostrarMenu=0
|
||||
while [ ${mostrarMenu} -eq 0 ] ; do
|
||||
opcion=$(zenity --width=340 --height=365 --list --title "zenigrub-custom ${VERSION} (${M_DATE})" \
|
||||
--column "Select an option:" "Show GRUB entries" "Change default entry" \
|
||||
"Change GRUB time" "Edit boot parameters" "Show current settings" \
|
||||
"Update GRUB (update-grub)" "Save GRUB configuration" "Restore GRUB settings" \
|
||||
"About" "Exit")
|
||||
opcion=$(zenity --width=340 --height=420 --list --title "zenigrub-custom ${VERSION} (${M_DATE})" \
|
||||
--window-icon=${iconPath} --imagelist --column "Icon" --column "Option" ${imagesPath}/show-grub-entries.png "Show GRUB entries" \
|
||||
${imagesPath}/change-default-entry.png "Change default entry" ${imagesPath}/change-grub-time.png "Change GRUB time" \
|
||||
${imagesPath}/edit-boot-parameters.png "Edit boot parameters" ${imagesPath}/show-current-settings.png "Show current settings" \
|
||||
${imagesPath}/update-grub.png "Update GRUB (update-grub)" ${imagesPath}/save-grub-configuration.png "Save GRUB configuration" ${imagesPath}/restore-grub-settings.png "Restore GRUB settings" \
|
||||
${imagesPath}/about.png "About" ${imagesPath}/exit.png "Exit")
|
||||
cancelar=$?
|
||||
if [ ${cancelar} -eq 1 ] ; then
|
||||
mostrarMenu=1
|
||||
exit
|
||||
else
|
||||
if [ "${opcion}" == "Show GRUB entries" ] ; then
|
||||
if [ "${opcion}" == "${imagesPath}/show-grub-entries.png" ] ; then
|
||||
mostrarEntradasGrub
|
||||
elif [ "${opcion}" == "Change default entry" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/change-default-entry.png" ] ; then
|
||||
cambiarEntradaDefecto
|
||||
elif [ "${opcion}" == "Change GRUB time" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/change-grub-time.png" ] ; then
|
||||
cambiarTiempoGrub
|
||||
elif [ "${opcion}" == "Edit boot parameters" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/edit-boot-parameters.png" ] ; then
|
||||
editarParametrosArranque
|
||||
elif [ "${opcion}" == "Show current settings" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/show-current-settings.png" ] ; then
|
||||
mostrarConfiguracionActual
|
||||
elif [ "${opcion}" == "Update GRUB (update-grub)" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/update-grub.png" ] ; then
|
||||
actualizarGrub
|
||||
elif [ "${opcion}" == "Save GRUB configuration" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/save-grub-configuration.png" ] ; then
|
||||
guardarConfiguracionGrub
|
||||
elif [ "${opcion}" == "Restore GRUB settings" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/restore-grub-settings.png" ] ; then
|
||||
restaurarConfiguracion
|
||||
elif [ "${opcion}" == "About" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/about.png" ] ; then
|
||||
mostrarAcerca
|
||||
elif [ "${opcion}" == "Exit" ] ; then
|
||||
elif [ "${opcion}" == "${imagesPath}/exit.png" ] ; then
|
||||
mostrarMenu=1
|
||||
exit
|
||||
else
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --warning --width=300 \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=300 \
|
||||
--text "Choose one of the menu options"
|
||||
fi
|
||||
fi
|
||||
|
@ -2,13 +2,16 @@
|
||||
|
||||
##############################################################
|
||||
# Edita ciertas opciones del GRUB graficamente #
|
||||
# U. Modificacion: 27-03-2021 #
|
||||
# U. Modificacion: 27-10-2021 #
|
||||
# Autor: q3aql #
|
||||
# Contacto: q3aql@protonmail.ch #
|
||||
# Contacto: q3aql@duck.com #
|
||||
# Licencia: GPL v2.0 #
|
||||
##############################################################
|
||||
VERSION="1.4"
|
||||
M_DATE="270321"
|
||||
VERSION="1.6"
|
||||
M_DATE="271021"
|
||||
|
||||
# Variables
|
||||
iconPath="/opt/zenigrub-custom/zenigrub-custom.png"
|
||||
|
||||
# Enlace con gksudo,gksu o bessu a zenigrub-custom
|
||||
function showRootMessage() {
|
||||
@ -46,7 +49,7 @@ function showRootMessage() {
|
||||
zenity -h &> /dev/null
|
||||
output=$?
|
||||
if [ ${output} -eq 0 ] ; then
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --info \
|
||||
zenity --title "zenigrub-custom ${VERSION} (${M_DATE})" --window-icon=${iconPath} --width 450 --info \
|
||||
--text "The 'zenigrub-custom' program could not be run as administrator\n\nPlease run the 'zenigrub-custom' command as root user in terminal"
|
||||
else
|
||||
xterm -T "zenigrub-custom ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "zenigrub-custom-admin --error"
|
||||
|
546
src/zenigrub-custom-cli
Executable file
@ -0,0 +1,546 @@
|
||||
#!/bin/bash
|
||||
|
||||
##############################################################
|
||||
# Edita ciertas opciones del GRUB mediante terminal #
|
||||
# U. Modificacion: 27-10-2021 #
|
||||
# Autor: q3aql #
|
||||
# Contacto: q3aql@duck.com #
|
||||
# Licencia: GPL v2.0 #
|
||||
##############################################################
|
||||
VERSION="1.6"
|
||||
M_DATE="271021"
|
||||
|
||||
# Variables generales
|
||||
defaultGrub="/etc/default/grub"
|
||||
defaultGrubFiles="/etc/default/grub.d"
|
||||
zenigrubInit="${defaultGrubFiles}/zenigrub-init.cfg"
|
||||
bootGrub="/boot/grub/grub.cfg"
|
||||
zenigrubDir="/etc/zenigrub"
|
||||
tmpZenigrub="/tmp/zenigrub.tmp"
|
||||
zenigrubSedFolder="/tmp/zenigrub/word/"
|
||||
|
||||
# Variables
|
||||
iconPath="/opt/zenigrub-custom/zenigrub-custom.png"
|
||||
imagesPath="/opt/zenigrub-custom/img"
|
||||
|
||||
# Funcion para comprobar permisos de administrador
|
||||
function comprobarAdministrador() {
|
||||
mkdir -p /etc/root &> /dev/null
|
||||
administrador=$?
|
||||
if [ ${administrador} -eq 0 ] ; then
|
||||
rm -rf /etc/root
|
||||
mkdir -p ${defaultGrubFiles}
|
||||
touch ${zenigrubInit}
|
||||
else
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "* Administrator permissions are required."
|
||||
echo ""
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para actualizar el grub
|
||||
function update-grub() {
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
||||
}
|
||||
|
||||
# Funcion para comprobar si existen los ficheros necesarios del grub
|
||||
function comprobarFicheros() {
|
||||
if [ -f ${defaultGrub} ] ; then
|
||||
if [ -f ${bootGrub} ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "+ The file '${bootGrub}' doesn't exist!"
|
||||
echo ""
|
||||
exit
|
||||
fi
|
||||
else
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "+ The file '${defaultGrub}' doesn't exist!"
|
||||
echo ""
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para hacer backup de los ficheros
|
||||
function backupFicheros() {
|
||||
mkdir -p ${zenigrubDir}
|
||||
if [ -f ${zenigrubDir}/grub ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
cp -rfv ${defaultGrub} ${zenigrubDir}
|
||||
fi
|
||||
if [ -f ${zenigrubDir}/grub.initial ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
cp -rfv ${defaultGrub} ${zenigrubDir}/grub.initial
|
||||
fi
|
||||
if [ -f ${zenigrubDir}/grub.cfg ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
cp -rfv ${bootGrub} ${zenigrubDir}
|
||||
fi
|
||||
if [ -f ${zenigrubDir}/grub.cfg.initial ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
cp -rfv ${bootGrub} ${zenigrubDir}/grub.cfg.initial
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
|
||||
# Funcion para restaurar la configuracion del GRUB
|
||||
function restaurarConfiguracion() {
|
||||
clear
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "* The initial or last saved GRUB configuration will be restored!."
|
||||
echo -n "+ [Default: n] Do you want to continue? (y/n): " ; read restore_grub
|
||||
if [ -z "${restore_grub}" ] ; then
|
||||
echo "null" > /dev/null
|
||||
elif [ "${restore_grub}" == "n" ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
cp -rfv ${zenigrubDir}/grub ${defaultGrub}
|
||||
errorUno=$?
|
||||
cp -rfv ${zenigrubDir}/grub.cfg ${bootGrub}
|
||||
errorDos=$?
|
||||
erroresTotales=$(expr ${errorUno} + ${errorDos})
|
||||
if [ ${erroresTotales} -eq 0 ] ; then
|
||||
rm -rfv ${zenigrubDir}/grub
|
||||
rm -rfv ${zenigrubDir}/grub.cfg
|
||||
echo ""
|
||||
echo "* GRUB settings have been successfully restored."
|
||||
echo ""
|
||||
echo -n "+ Press ENTER to continue.. " ; read continue
|
||||
else
|
||||
echo ""
|
||||
echo "* There was a problem restoring the GRUB configuration."
|
||||
echo ""
|
||||
echo -n "+ Press ENTER to continue.. " ; read continue
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para guardar la configuracion del GRUB
|
||||
function guardarConfiguracionGrub() {
|
||||
clear
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "* The current configuration will be set as the default."
|
||||
echo -n "+ [Default: n] Do you want to continue? (y/n): " ; read save_grub
|
||||
if [ -z "${save_grub}" ] ; then
|
||||
echo "null" > /dev/null
|
||||
elif [ "${save_grub}" == "n" ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
cp -rfv ${defaultGrub} ${zenigrubDir}
|
||||
errorUno=$?
|
||||
cp -rfv ${bootGrub} ${zenigrubDir}
|
||||
errorDos=$?
|
||||
erroresTotales=$(expr ${errorUno} + ${errorDos})
|
||||
if [ ${erroresTotales} -eq 0 ] ; then
|
||||
echo ""
|
||||
echo "* GRUB configuration has been saved successfully."
|
||||
echo ""
|
||||
echo -n "+ Press ENTER to continue " ; read continue
|
||||
else
|
||||
echo ""
|
||||
echo "* There was a problem saving the GRUB configuration."
|
||||
echo ""
|
||||
echo -n "+ Press ENTER to continue.. " ; read continue
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para habilitar las opciones necesarias
|
||||
function habilitarOpciones() {
|
||||
# Habilitar las opciones si se encuentra desactivadas
|
||||
sed -i 's/#GRUB_DEFAULT=/GRUB_DEFAULT=/g' "${defaultGrub}" &> /dev/null
|
||||
sed -i 's/#GRUB_TIMEOUT=/GRUB_TIMEOUT=/g' "${defaultGrub}" &> /dev/null
|
||||
sed -i 's/#GRUB_CMDLINE_LINUX_DEFAULT=/GRUB_CMDLINE_LINUX_DEFAULT=/g' "${defaultGrub}" &> /dev/null
|
||||
sed -i 's/GRUB_HIDDEN_TIMEOUT=/#Disabled_GRUB_HIDDEN_TIMEOUT/g' "${defaultGrubFiles}"/* &> /dev/null
|
||||
TiempoDesactivado=$(cat ${defaultGrub} | grep "#GRUB_HIDDEN_TIMEOUT=")
|
||||
if [ -z "${TiempoDesactivado}" ] ; then
|
||||
sed -i 's/GRUB_HIDDEN_TIMEOUT=/#GRUB_HIDDEN_TIMEOUT=/g' "${defaultGrub}" &> /dev/null
|
||||
fi
|
||||
# Comprobar si las lineas se encuentran agregadas
|
||||
comprobarGrubDefault=$(cat ${defaultGrub} | grep "GRUB_DEFAULT=")
|
||||
comprobarGrubTimeout=$(cat ${defaultGrub} | grep "GRUB_TIMEOUT=")
|
||||
comprobarGrubCmdLineDefault=$(cat ${defaultGrub} | grep "GRUB_CMDLINE_LINUX_DEFAULT=")
|
||||
if [ -z "${comprobarGrubDefault}" ] ; then
|
||||
echo "GRUB_DEFAULT=\"0\"" > /etc/default/grub.tmp
|
||||
cat ${defaultGrub} >> /etc/default/grub.tmp
|
||||
cp -rfv /etc/default/grub.tmp ${defaultGrub}
|
||||
fi
|
||||
if [ -z "${comprobarGrubTimeout}" ] ; then
|
||||
echo "GRUB_TIMEOUT=\"10\"" > /etc/default/grub.tmp
|
||||
cat ${defaultGrub} >> /etc/default/grub.tmp
|
||||
cp -rfv /etc/default/grub.tmp ${defaultGrub}
|
||||
fi
|
||||
if [ -z "${comprobarGrubCmdLineDefault}" ] ; then
|
||||
parametrosAnterior=$(cat "${defaultGrubFiles}"/* | grep "GRUB_CMDLINE_LINUX_DEFAULT=")
|
||||
if [ -z "${parametrosAnterior}" ] ; then
|
||||
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"\"" > /etc/default/grub.tmp
|
||||
cat ${defaultGrub} >> /etc/default/grub.tmp
|
||||
cp -rfv /etc/default/grub.tmp ${defaultGrub}
|
||||
else
|
||||
LineaInicial=2
|
||||
cat "${defaultGrubFiles}"/* | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 2 > ${tmpZenigrub}
|
||||
parametrosGrub=$(cat ${tmpZenigrub})
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeido=$(cat "${defaultGrubFiles}"/* | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
while [ "${parametrosGrubLeido}" != "" ] ; do
|
||||
parametrosGrub="${parametrosGrub}=${parametrosGrubLeido}"
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeido=$(cat "${defaultGrubFiles}"/* | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
done
|
||||
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"${parametrosGrub}\"" > /etc/default/grub.tmp
|
||||
cat ${defaultGrub} >> /etc/default/grub.tmp
|
||||
cp -rfv /etc/default/grub.tmp ${defaultGrub}
|
||||
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT=/#Disabled_GRUB_CMDLINE_LINUX_DEFAULT/g' "${defaultGrubFiles}"/* &> /dev/null
|
||||
fi
|
||||
fi
|
||||
parametrosAnterior=$(cat "${defaultGrubFiles}"/* | grep "GRUB_CMDLINE_LINUX_DEFAULT=")
|
||||
if [ -z "${parametrosAnterior}" ] ; then
|
||||
echo "null" > /dev/null
|
||||
else
|
||||
LineaInicial=2
|
||||
cat "${defaultGrubFiles}"/* | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 2 > ${tmpZenigrub}
|
||||
parametrosGrubAnterior=$(cat ${tmpZenigrub})
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeidoAnterior=$(cat "${defaultGrubFiles}"/* | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
while [ "${parametrosGrubLeidoAnterior}" != "" ] ; do
|
||||
parametrosGrubAnterior="${parametrosGrubAnterior}=${parametrosGrubLeidoAnterior}"
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeidoAnterior=$(cat "${defaultGrubFiles}"/* | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
done
|
||||
LineaInicial=2
|
||||
cat "${defaultGrub}" | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 2 > ${tmpZenigrub}
|
||||
parametrosGrub=$(cat ${tmpZenigrub})
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeido=$(cat "${defaultGrub}" | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
while [ "${parametrosGrubLeido}" != "" ] ; do
|
||||
parametrosGrub="${parametrosGrub}=${parametrosGrubLeido}"
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeido=$(cat "${defaultGrub}" | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
done
|
||||
sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=\"${parametrosGrub}\"/GRUB_CMDLINE_LINUX_DEFAULT=\"${parametrosGrubAnterior}\"/g" "${defaultGrub}"
|
||||
sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=${parametrosGrub}/GRUB_CMDLINE_LINUX_DEFAULT=\"${parametrosGrubAnterior}\"/g" "${defaultGrub}"
|
||||
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT=/#Disabled_GRUB_CMDLINE_LINUX_DEFAULT/g' "${defaultGrubFiles}"/* &> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para eliminar espacios
|
||||
# Sintaxis: eliminarEspacios "<texto>"
|
||||
function eliminarEspacios() {
|
||||
wordToConvert=${1}
|
||||
zenigrubSedFile="${zenigrubSedFolder}/zenigrub-${RANDOM}.txt"
|
||||
mkdir -p ${zenigrubSedFolder} && chmod 777 -R ${zenigrubSedFolder} 2> /dev/null
|
||||
echo "${wordToConvert}" > ${zenigrubSedFile}
|
||||
# Borrar espacios
|
||||
sed -i 's/ /_/g' "${zenigrubSedFile}" &> /dev/null
|
||||
# Mostrar texto convertido
|
||||
wordToConvert=$(cat ${zenigrubSedFile})
|
||||
echo ${wordToConvert}
|
||||
}
|
||||
|
||||
# Funcion para restaurar los espacios
|
||||
# Sintaxis: restaEspacios "<texto>"
|
||||
function restaurarEspacios() {
|
||||
wordToConvert=${1}
|
||||
zenigrubSedFile="${zenigrubSedFolder}/zenigrub-${RANDOM}.txt"
|
||||
mkdir -p ${zenigrubSedFolder} && chmod 777 -R ${zenigrubSedFolder} 2> /dev/null
|
||||
echo "${wordToConvert}" > ${zenigrubSedFile}
|
||||
# Borrar espacios
|
||||
sed -i 's/_/\\ /g' "${zenigrubSedFile}" &> /dev/null
|
||||
sed -i 's/\//\\\//g' "${zenigrubSedFile}" &> /dev/null
|
||||
# Mostrar texto convertido
|
||||
wordToConvert=$(cat ${zenigrubSedFile})
|
||||
echo ${wordToConvert}
|
||||
}
|
||||
|
||||
# Funcion para mostrar las entradas del GRUB
|
||||
function mostrarEntradasGrub() {
|
||||
grep 'menuentry "' /boot/grub/grub.cfg | cut -d '"' -f 2 > ${tmpZenigrub}
|
||||
grep "menuentry '" /boot/grub/grub.cfg | cut -d "'" -f 2 >> ${tmpZenigrub}
|
||||
listaTotal=$(wc -l ${tmpZenigrub} | cut -d " " -f 1)
|
||||
listaInicial=1
|
||||
listaCompleta=""
|
||||
clear
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} ($M_DATE)"
|
||||
echo ""
|
||||
echo "* List of entries of GRUB:"
|
||||
echo ""
|
||||
#echo ${listaCompleta}
|
||||
while [ ${listaInicial} -le ${listaTotal} ] ; do
|
||||
entradaLeida=$(cat ${tmpZenigrub} | head -${listaInicial} | tail -1)
|
||||
entradaLeida=$(eliminarEspacios "${entradaLeida}")
|
||||
#listaCompleta="${listaCompleta} ${entradaLeida}"
|
||||
echo " - ${entradaLeida}"
|
||||
listaInicial=$(expr ${listaInicial} + 1)
|
||||
done
|
||||
echo ""
|
||||
echo -n "+ Press ENTER to continue.. " ; read continue
|
||||
}
|
||||
|
||||
# Funcion para cambiar la entrada por defecto
|
||||
function cambiarEntradaDefecto() {
|
||||
grep 'menuentry "' /boot/grub/grub.cfg | cut -d '"' -f 2 > ${tmpZenigrub}
|
||||
grep "menuentry '" /boot/grub/grub.cfg | cut -d "'" -f 2 >> ${tmpZenigrub}
|
||||
listaTotal=$(wc -l ${tmpZenigrub} | cut -d " " -f 1)
|
||||
listaInicial=1
|
||||
listaCompleta=""
|
||||
clear
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} ($M_DATE)"
|
||||
echo ""
|
||||
echo "* Type number of entry in GRUB to set by default:"
|
||||
echo ""
|
||||
while [ ${listaInicial} -le ${listaTotal} ] ; do
|
||||
entradaLeida=$(cat ${tmpZenigrub} | head -${listaInicial} | tail -1)
|
||||
entradaLeida=$(eliminarEspacios "${entradaLeida}")
|
||||
#listaCompleta="${listaCompleta} ${entradaLeida}"
|
||||
echo " ${listaInicial} --> ${entradaLeida}"
|
||||
listaInicial=$(expr ${listaInicial} + 1)
|
||||
done
|
||||
echo ""
|
||||
echo " r --> Return to menu (cancel)"
|
||||
echo ""
|
||||
echo -n "+ [Default: r] Type option: " ; read option_grub
|
||||
if [ -z "${option_grub}" ] ; then
|
||||
mostrarMenuPrincipal
|
||||
elif [ "${option_grub}" == "r" ] ; then
|
||||
mostrarMenuPrincipal
|
||||
else
|
||||
if [ -z "${option_grub}" ] ; then
|
||||
mostrarMenuPrincipal
|
||||
else
|
||||
expr ${option_grub} + 1 2>/dev/null
|
||||
check_number=$?
|
||||
if [ ${check_number} -eq 0 ] ; then
|
||||
echo ""
|
||||
listaInicial=1
|
||||
listaTotal=${option_grub}
|
||||
while [ ${listaInicial} -le ${listaTotal} ] ; do
|
||||
entradaLeida=$(cat ${tmpZenigrub} | head -${listaInicial} | tail -1)
|
||||
entradaLeida=$(eliminarEspacios "${entradaLeida}")
|
||||
#listaCompleta="${listaCompleta} ${entradaLeida}"
|
||||
listaInicial=$(expr ${listaInicial} + 1)
|
||||
done
|
||||
entradaDefecto=$(cat ${defaultGrub} | grep "GRUB_DEFAULT=" | cut -d "=" -f 2 | cut -d '"' -f 2)
|
||||
entradaAnterior=$(eliminarEspacios "${entradaDefecto}")
|
||||
entradaAnterior=$(restaurarEspacios ${entradaAnterior})
|
||||
nuevaEntrada=$(restaurarEspacios ${entradaLeida})
|
||||
echo "* The current entry is '${entradaAnterior}'"
|
||||
echo "* It has been defined as main entrance to '${nuevaEntrada}'"
|
||||
sed -i "s/GRUB_DEFAULT=\"${entradaAnterior}\"/GRUB_DEFAULT=\"${nuevaEntrada}\"/g" "${defaultGrub}"
|
||||
sed -i "s/GRUB_DEFAULT=${entradaAnterior}/GRUB_DEFAULT=\"${nuevaEntrada}\"/g" "${defaultGrub}"
|
||||
actualizarGrub
|
||||
else
|
||||
mostrarMenuPrincipal
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para mostrar la configuracion por defecto
|
||||
function mostrarConfiguracionActual() {
|
||||
entradaDefecto=$(cat ${defaultGrub} | grep "GRUB_DEFAULT=" | cut -d "=" -f 2 | cut -d '"' -f 2)
|
||||
tiempoGrub=$(cat ${defaultGrub} | grep "GRUB_TIMEOUT=" | cut -d "=" -f 2 | cut -d '"' -f 2)
|
||||
LineaInicial=2
|
||||
cat ${defaultGrub} | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 2 > ${tmpZenigrub}
|
||||
parametrosGrub=$(cat ${tmpZenigrub})
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeido=$(cat ${defaultGrub} | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
while [ "${parametrosGrubLeido}" != "" ] ; do
|
||||
parametrosGrub="${parametrosGrub}=${parametrosGrubLeido}"
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeido=$(cat ${defaultGrub} | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
done
|
||||
clear
|
||||
echo "${parametrosGrub}" > ${tmpZenigrub}
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "* GRUB configuration:"
|
||||
echo ""
|
||||
echo " - Default entry: ${entradaDefecto}"
|
||||
echo " - GRUB time: ${tiempoGrub}"
|
||||
echo " - Boot parameters: ${parametrosGrub}"
|
||||
echo ""
|
||||
echo -n "+ Press ENTER to continue.. " ; read continue
|
||||
}
|
||||
|
||||
# Funcion para cambiar el tiempo del GRUB
|
||||
function cambiarTiempoGrub() {
|
||||
tiempoGrub=$(cat ${defaultGrub} | grep "GRUB_TIMEOUT=" | cut -d "=" -f 2 | cut -d '"' -f 2)
|
||||
clear
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo -n "* [Current: ${tiempoGrub}] Type the SECONDS that the GRUB will be visible: " ; read time_grub
|
||||
tiempoActual=${time_grub}
|
||||
if [ -z "${time_grub}" ] ; then
|
||||
mostrarMenuPrincipal
|
||||
else
|
||||
if [ -z "${tiempoActual}" ] ; then
|
||||
actualizarGrub
|
||||
else
|
||||
expr ${tiempoActual} + 1 2>/dev/null
|
||||
error_time=$?
|
||||
if [ ${error_time} -eq 0 ] ; then
|
||||
sed -i "s/GRUB_TIMEOUT=\"${tiempoGrub}\"/GRUB_TIMEOUT=\"${tiempoActual}\"/g" "${defaultGrub}"
|
||||
sed -i "s/GRUB_TIMEOUT=${tiempoGrub}/GRUB_TIMEOUT=\"${tiempoActual}\"/g" "${defaultGrub}"
|
||||
actualizarGrub
|
||||
else
|
||||
mostrarMenuPrincipal
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para editar los parametros de arranque
|
||||
function editarParametrosArranque() {
|
||||
# Se cargan los actuales parametros de arranque
|
||||
LineaInicial=2
|
||||
cat ${defaultGrub} | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 2 > ${tmpZenigrub}
|
||||
parametrosGrub=$(cat ${tmpZenigrub})
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeido=$(cat ${defaultGrub} | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
while [ "${parametrosGrubLeido}" != "" ] ; do
|
||||
parametrosGrub="${parametrosGrub}=${parametrosGrubLeido}"
|
||||
LineaInicial=$(expr ${LineaInicial} + 1)
|
||||
parametrosGrubLeido=$(cat ${defaultGrub} | grep "GRUB_CMDLINE_LINUX_DEFAULT=" | cut -d "=" -f ${LineaInicial} | cut -d '"' -f 1)
|
||||
done
|
||||
echo "${parametrosGrub}" > ${tmpZenigrub}
|
||||
parametrosGrubMostrar=$(cat ${tmpZenigrub})
|
||||
sed -i 's/ /\\ /g' "${tmpZenigrub}" &> /dev/null
|
||||
parametrosGrub=$(cat ${tmpZenigrub})
|
||||
# Se leen y procesan los nuevos parametros
|
||||
clear
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "+ Current parameters: ${parametrosGrubMostrar}"
|
||||
echo -n "* Type the BOOT PARAMETERS in GRUB: " ; read parametrosActual
|
||||
cancelar=$?
|
||||
if [ -z "${parametrosActual}" ] ; then
|
||||
mostrarMenuPrincipal
|
||||
else
|
||||
if [ -z "${parametrosActual}" ] ; then
|
||||
mostrarMenuPrincipal
|
||||
else
|
||||
echo ${parametrosActual} > ${tmpZenigrub}
|
||||
sed -i 's/ /\\ /g' "${tmpZenigrub}" &> /dev/null
|
||||
parametrosActual=$(cat ${tmpZenigrub})
|
||||
sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=\"${parametrosGrub}\"/GRUB_CMDLINE_LINUX_DEFAULT=\"${parametrosActual}\"/g" "${defaultGrub}"
|
||||
sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=${parametrosGrub}/GRUB_CMDLINE_LINUX_DEFAULT=\"${parametrosActual}\"/g" "${defaultGrub}"
|
||||
actualizarGrub
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para actualizar el GRUB
|
||||
function actualizarGrub() {
|
||||
echo ""
|
||||
echo "* Updating GRUB configuration"
|
||||
update-grub
|
||||
output=$?
|
||||
if [ ${output} -eq 0 ] ; then
|
||||
echo "* GRUB update process is complete!"
|
||||
echo ""
|
||||
echo -n "+ Press ENTER to continue.. " ; read continue
|
||||
else
|
||||
echo "* There was an error in the GRUB update process."
|
||||
echo ""
|
||||
echo -n "+ Press ENTER to continue.. " ; read continue
|
||||
fi
|
||||
}
|
||||
|
||||
# Funcion para mostrar el "acerca" del programa
|
||||
function mostrarAcerca() {
|
||||
clear
|
||||
echo ""
|
||||
echo "* About:"
|
||||
echo ""
|
||||
echo " - Software: zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo " - Author: q3aql"
|
||||
echo " - Contact: q3aql@duck.com"
|
||||
echo " - License: GPL v2.0"
|
||||
echo ""
|
||||
echo -n "+ Press ENTER to continue.. " ; read continue
|
||||
}
|
||||
|
||||
# Mostrar menu con todas las opciones
|
||||
function mostrarMenuPrincipal() {
|
||||
mostrarMenu=0
|
||||
while [ ${mostrarMenu} -eq 0 ] ; do
|
||||
clear
|
||||
echo ""
|
||||
echo "* zenigrub-custom-cli ${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo " g --> Show GRUB entries"
|
||||
echo " d --> Change default entry"
|
||||
echo " t --> Change GRUB time"
|
||||
echo " e --> Edit boot parameters"
|
||||
echo " c --> Show current settings"
|
||||
echo " u --> Update GRUB (update-grub)"
|
||||
echo " s --> Save GRUB configuration"
|
||||
echo " r --> Restore GRUB settings"
|
||||
echo " a --> About"
|
||||
echo ""
|
||||
echo " q --> Exit"
|
||||
echo ""
|
||||
echo -n "* Type the option (example: g): " ; read opcion
|
||||
cancelar=$?
|
||||
if [ ${cancelar} -eq 1 ] ; then
|
||||
mostrarMenu=1
|
||||
exit
|
||||
else
|
||||
if [ "${opcion}" == "g" ] ; then
|
||||
mostrarEntradasGrub
|
||||
elif [ "${opcion}" == "d" ] ; then
|
||||
cambiarEntradaDefecto
|
||||
elif [ "${opcion}" == "t" ] ; then
|
||||
cambiarTiempoGrub
|
||||
elif [ "${opcion}" == "e" ] ; then
|
||||
editarParametrosArranque
|
||||
elif [ "${opcion}" == "c" ] ; then
|
||||
mostrarConfiguracionActual
|
||||
elif [ "${opcion}" == "u" ] ; then
|
||||
actualizarGrub
|
||||
elif [ "${opcion}" == "s" ] ; then
|
||||
guardarConfiguracionGrub
|
||||
elif [ "${opcion}" == "r" ] ; then
|
||||
restaurarConfiguracion
|
||||
elif [ "${opcion}" == "a" ] ; then
|
||||
mostrarAcerca
|
||||
elif [ "${opcion}" == "q" ] ; then
|
||||
mostrarMenu=1
|
||||
exit
|
||||
else
|
||||
echo ""
|
||||
echo "+ Choose one of the menu options."
|
||||
echo ""
|
||||
echo "+ Press ENTER to continue.. " ; read continue
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Iniciar aplicacion
|
||||
comprobarAdministrador
|
||||
comprobarFicheros
|
||||
habilitarOpciones
|
||||
backupFicheros
|
||||
mostrarMenuPrincipal
|