| 1 | #!/bin/bash |
|---|
| 2 | #/** |
|---|
| 3 | #@file Boot.lib |
|---|
| 4 | #@brief Librería o clase Boot |
|---|
| 5 | #@class Boot |
|---|
| 6 | #@brief Funciones para arranque y post-configuración de sistemas de archivos. |
|---|
| 7 | #@version 1.1.0 |
|---|
| 8 | #@warning License: GNU GPLv3+ |
|---|
| 9 | #*/ |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | #/** |
|---|
| 13 | # ogBoot int_ndisk int_nfilesys [str_kernel str_initrd str_krnlparams] |
|---|
| 14 | #@brief Inicia el proceso de arranque de un sistema de archivos. |
|---|
| 15 | #@param int_ndisk nº de orden del disco |
|---|
| 16 | #@param int_nfilesys nº de orden del sistema de archivos |
|---|
| 17 | #@param str_krnlparams parámetros de arranque del kernel (opcional) |
|---|
| 18 | #@return (activar el sistema de archivos). |
|---|
| 19 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 20 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
|---|
| 21 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
|---|
| 22 | #@exception OG_ERR_NOTOS La partición no tiene instalado un sistema operativo. |
|---|
| 23 | #@note En Linux, si no se indican los parámetros de arranque se detectan de la opción por defecto del cargador GRUB. |
|---|
| 24 | #@note En Linux, debe arrancarse la partición del directorio \c /boot |
|---|
| 25 | #@version 0.1 - Integración para OpenGnSys. - EAC: HDboot; BootLinuxEX en Boot.lib |
|---|
| 26 | #@author Antonio J. Doblas Viso, Universidad de Malaga |
|---|
| 27 | #@date 2008-10-27 |
|---|
| 28 | #@version 0.9 - Adaptación para OpenGnSys. |
|---|
| 29 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 30 | #@date 2009-09-11 |
|---|
| 31 | #@version 1.0.4 - Soporta modo de arranque Windows (parámetro de inicio "winboot"). |
|---|
| 32 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 33 | #@date 2012-04-12 |
|---|
| 34 | #@version 1.0.6 - Selección a partir de tipo de sistema operativo (en vez de S.F.) y arrancar Linux con /boot separado. |
|---|
| 35 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 36 | #@date 2015-06-05 |
|---|
| 37 | #@version 1.1.0 - Nuevo parámetro opcional con opciones de arranque del Kernel. |
|---|
| 38 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 39 | #@date 2015-07-15 |
|---|
| 40 | #@version 1.1.1 - UEFI: Permite iniciar linux recien instalados (ticket #802 #890) |
|---|
| 41 | #@author Irina Gomez, ETSII Universidad de Sevilla |
|---|
| 42 | #@date 2019-03-13 |
|---|
| 43 | #*/ ## |
|---|
| 44 | function ogBoot () |
|---|
| 45 | { |
|---|
| 46 | # Variables locales. |
|---|
| 47 | local PART TYPE MNTDIR PARAMS KERNEL INITRD APPEND FILE LOADER f |
|---|
| 48 | local EFIDISK EFIPART EFIDIR BOOTLABEL BOOTLOADER BOOTNO DIRGRUB b |
|---|
| 49 | |
|---|
| 50 | # Si se solicita, mostrar ayuda. |
|---|
| 51 | if [ "$*" == "help" ]; then |
|---|
| 52 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_nfilesys [str_kernel str_initrd str_kernelparams]" \ |
|---|
| 53 | "$FUNCNAME 1 1" "$FUNCNAME 1 2 \"/boot/vmlinuz /boot/initrd.img root=/dev/sda2 ro\"" |
|---|
| 54 | return |
|---|
| 55 | fi |
|---|
| 56 | # Error si no se reciben 2 o 3 parámetros. |
|---|
| 57 | [ $# == 2 ] || [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
|---|
| 58 | |
|---|
| 59 | # Detectar tipo de sistema de archivos y montarlo. |
|---|
| 60 | PART=$(ogDiskToDev $1 $2) || return $? |
|---|
| 61 | TYPE=$(ogGetOsType $1 $2) || return $? |
|---|
| 62 | # Error si no puede montar sistema de archivos. |
|---|
| 63 | MNTDIR=$(ogMount $1 $2) || return $? |
|---|
| 64 | |
|---|
| 65 | case "$TYPE" in |
|---|
| 66 | Linux|Android) |
|---|
| 67 | # Si no se indican, obtiene los parámetros de arranque para Linux. |
|---|
| 68 | PARAMS="${3:-$(ogLinuxBootParameters $1 $2 2>/dev/null)}" |
|---|
| 69 | # Si no existe y el UEFI buscar en particion ESP |
|---|
| 70 | [ -z "$PARAMS" ] && ogIsEfiActive && PARAMS="$(ogLinuxBootParameters $(ogGetEsp))" |
|---|
| 71 | # Si no existe, buscar sistema de archivo /boot en /etc/fstab. |
|---|
| 72 | if [ -z "$PARAMS" -a -e $MNTDIR/etc/fstab ]; then |
|---|
| 73 | # Localizar S.F. /boot en /etc/fstab del S.F. actual. |
|---|
| 74 | PART=$(ogDevToDisk $(awk '$1!="#" && $2=="/boot" {print $1}' $MNTDIR/etc/fstab)) |
|---|
| 75 | # Montar S.F. de /boot. |
|---|
| 76 | MNTDIR=$(ogMount $PART) || return $? |
|---|
| 77 | # Buscar los datos de arranque. |
|---|
| 78 | PARAMS=$(ogLinuxBootParameters $PART) || exit $? |
|---|
| 79 | fi |
|---|
| 80 | read -e KERNEL INITRD APPEND <<<"$PARAMS" |
|---|
| 81 | # Si no hay kernel, no hay sistema operativo. |
|---|
| 82 | [ -n "$KERNEL" -a -e "$MNTDIR/$KERNEL" ] || ogRaiseError $OG_ERR_NOTOS "$1 $2 ($TYPE)" || return $? |
|---|
| 83 | # Arrancar de partición distinta a la original. |
|---|
| 84 | [ -e "$MNTDIR/etc" ] && APPEND=$(echo $APPEND | awk -v P="$PART " '{sub (/root=[-+=_/a-zA-Z0-9]* /,"root="P);print}') |
|---|
| 85 | # Comprobar tipo de sistema. |
|---|
| 86 | if ogIsEfiActive; then |
|---|
| 87 | # Comprobar si el Kernel está firmado. |
|---|
| 88 | if ! file -k "$MNTDIR/$KERNEL" | grep -q "EFI app"; then |
|---|
| 89 | ogRaiseError $OG_ERR_NOTOS "$1 $2 ($TYPE, EFI)" |
|---|
| 90 | return $? |
|---|
| 91 | fi |
|---|
| 92 | |
|---|
| 93 | BOOTLABEL=$(printf "Part-%02d-%02d" $1 $2) |
|---|
| 94 | BOOTLOADER="shimx64.efi" |
|---|
| 95 | # Obtener parcición EFI. |
|---|
| 96 | read -e EFIDISK EFIPART <<<"$(ogGetEsp)" |
|---|
| 97 | # TODO: Comprobamos que existe la BOOTLABEL, si no buscamos por sistema operativo |
|---|
| 98 | if [ "$(ogGetPath $EFIDISK $EFIPART EFI/$BOOTLABEL)" == "" ]; then |
|---|
| 99 | OSVERSION="$(ogGetOsVersion $1 $2)" |
|---|
| 100 | case $OSVERSION in |
|---|
| 101 | *SUSE*) |
|---|
| 102 | BOOTLABEL="opensuse" |
|---|
| 103 | ;; |
|---|
| 104 | *Fedora*) |
|---|
| 105 | BOOTLABEL="fedora" |
|---|
| 106 | ;; |
|---|
| 107 | *Ubuntu*) |
|---|
| 108 | BOOTLABEL="ubuntu" |
|---|
| 109 | ;; |
|---|
| 110 | *) |
|---|
| 111 | ogRaiseError $OG_ERR_NOTFOUND "$EFIDISK $EFIPART Boot loader"; return $? |
|---|
| 112 | ;; |
|---|
| 113 | esac |
|---|
| 114 | fi |
|---|
| 115 | |
|---|
| 116 | # Crear orden de arranque (con unos valores por defecto). |
|---|
| 117 | ogNvramAddEntry $BOOTLABEL "/EFI/$BOOTLABEL/Boot/$BOOTLOADER" |
|---|
| 118 | # Marcar próximo arranque y reiniciar. |
|---|
| 119 | ogNvramSetNext "$BOOTLABEL" |
|---|
| 120 | reboot |
|---|
| 121 | else |
|---|
| 122 | # Arranque BIOS: configurar kernel Linux con los parámetros leídos de su GRUB. |
|---|
| 123 | kexec -l "${MNTDIR}${KERNEL}" --append="$APPEND" --initrd="${MNTDIR}${INITRD}" |
|---|
| 124 | kexec -e & |
|---|
| 125 | fi |
|---|
| 126 | ;; |
|---|
| 127 | Windows) |
|---|
| 128 | # Comprobar tipo de sistema. |
|---|
| 129 | if ogIsEfiActive; then |
|---|
| 130 | BOOTLABEL=$(printf "Part-%02d-%02d" $1 $2) |
|---|
| 131 | # Obtener parcición EFI. |
|---|
| 132 | read -e EFIDISK EFIPART <<<"$(ogGetEsp)" |
|---|
| 133 | [ -n "$EFIPART" ] || ogRaiseError $OG_ERR_PARTITION "ESP" || return $? |
|---|
| 134 | EFIDIR=$(ogMount $EFIDISK $EFIPART) || exit $? |
|---|
| 135 | # Comprobar cargador (si no existe buscar por defecto en ESP). |
|---|
| 136 | LOADER=$(ogGetPath $EFIDIR/EFI/$BOOTLABEL/Boot/bootmgfw.efi) |
|---|
| 137 | [ -z "$LOADER" ] && BOOTLABEL=Microsoft && LOADER=$(ogGetPath $EFIDIR/EFI/Microsoft/Boot/bootmgfw.efi) |
|---|
| 138 | [ -n "$LOADER" ] || ogRaiseError $OG_ERR_NOTOS "$1 $2 ($TYPE, EFI)" || return $? |
|---|
| 139 | |
|---|
| 140 | # Crear orden de arranque (con unos valores por defecto). |
|---|
| 141 | ogNvramAddEntry $BOOTLABEL "/EFI${LOADER#*EFI}" |
|---|
| 142 | # Marcar próximo arranque y reiniciar. |
|---|
| 143 | ogNvramSetNext "$BOOTLABEL" |
|---|
| 144 | reboot |
|---|
| 145 | else |
|---|
| 146 | # Arranque BIOS: comprueba si hay un cargador de Windows. |
|---|
| 147 | for f in io.sys ntldr bootmgr; do |
|---|
| 148 | FILE="$(ogGetPath $1 $2 $f 2>/dev/null)" |
|---|
| 149 | [ -n "$FILE" ] && LOADER="$f" |
|---|
| 150 | done |
|---|
| 151 | [ -n "$LOADER" ] || ogRaiseError $OG_ERR_NOTOS "$1 $2 ($TYPE)" || return $? |
|---|
| 152 | if [ "$winboot" == "kexec" ]; then |
|---|
| 153 | # Modo de arranque en caliente (con kexec). |
|---|
| 154 | cp $OGLIB/grub4dos/* $MNTDIR # */ (Comentario Doxygen) |
|---|
| 155 | kexec -l $MNTDIR/grub.exe --append=--config-file="root (hd$[$1-1],$[$2-1]); chainloader (hd$[$1-1],$[$2-1])/$LOADER; tpm --init" |
|---|
| 156 | kexec -e & |
|---|
| 157 | else |
|---|
| 158 | # Modo de arranque por reinicio (con reboot). |
|---|
| 159 | dd if=/dev/zero of=${MNTDIR}/ogboot.me bs=1024 count=3 |
|---|
| 160 | dd if=/dev/zero of=${MNTDIR}/ogboot.firstboot bs=1024 count=3 |
|---|
| 161 | dd if=/dev/zero of=${MNTDIR}/ogboot.secondboot bs=1024 count=3 |
|---|
| 162 | if [ -z "$(ogGetRegistryValue $MNTDIR SOFTWARE '\Microsoft\Windows\CurrentVersion\Run\ogcleannboot')" ]; then |
|---|
| 163 | ogAddRegistryValue $MNTDIR SOFTWARE '\Microsoft\Windows\CurrentVersion\Run\ogcleanboot' |
|---|
| 164 | ogSetRegistryValue $MNTDIR SOFTWARE '\Microsoft\Windows\CurrentVersion\Run\ogcleanboot' "cmd /c del c:\ogboot.*" |
|---|
| 165 | fi |
|---|
| 166 | # Activar la partición. |
|---|
| 167 | ogSetPartitionActive $1 $2 |
|---|
| 168 | reboot |
|---|
| 169 | fi |
|---|
| 170 | fi |
|---|
| 171 | ;; |
|---|
| 172 | MacOS) |
|---|
| 173 | # Modo de arranque por reinicio. |
|---|
| 174 | # Nota: el cliente tiene que tener configurado correctamente Grub. |
|---|
| 175 | touch ${MNTDIR}/boot.mac &>/dev/null |
|---|
| 176 | reboot |
|---|
| 177 | ;; |
|---|
| 178 | GrubLoader) |
|---|
| 179 | # Reiniciar. |
|---|
| 180 | #reboot |
|---|
| 181 | ;; |
|---|
| 182 | *) ogRaiseError $OG_ERR_NOTOS "$1 $2 ${TYPE:+($TYPE)}" |
|---|
| 183 | return $? |
|---|
| 184 | ;; |
|---|
| 185 | esac |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | |
|---|
| 189 | #/** |
|---|
| 190 | # ogGetWindowsName int_ndisk int_nfilesys |
|---|
| 191 | #@brief Muestra el nombre del equipo en el registro de Windows. |
|---|
| 192 | #@param int_ndisk nº de orden del disco |
|---|
| 193 | #@param int_nfilesys nº de orden del sistema de archivos |
|---|
| 194 | #@return str_name - nombre del equipo |
|---|
| 195 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 196 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
|---|
| 197 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
|---|
| 198 | #@version 0.9 - Adaptación para OpenGnSys. |
|---|
| 199 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 200 | #@date 2009-09-23 |
|---|
| 201 | #*/ ## |
|---|
| 202 | function ogGetWindowsName () |
|---|
| 203 | { |
|---|
| 204 | # Variables locales. |
|---|
| 205 | local MNTDIR |
|---|
| 206 | |
|---|
| 207 | # Si se solicita, mostrar ayuda. |
|---|
| 208 | if [ "$*" == "help" ]; then |
|---|
| 209 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ |
|---|
| 210 | "$FUNCNAME 1 1 ==> PRACTICA-PC" |
|---|
| 211 | return |
|---|
| 212 | fi |
|---|
| 213 | # Error si no se reciben 2 parámetros. |
|---|
| 214 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
|---|
| 215 | |
|---|
| 216 | # Montar el sistema de archivos. |
|---|
| 217 | MNTDIR=$(ogMount $1 $2) || return $? |
|---|
| 218 | |
|---|
| 219 | # Obtener dato del valor de registro. |
|---|
| 220 | ogGetRegistryValue $MNTDIR system '\ControlSet001\Control\ComputerName\ComputerName\ComputerName' |
|---|
| 221 | } |
|---|
| 222 | |
|---|
| 223 | |
|---|
| 224 | #/** |
|---|
| 225 | # ogLinuxBootParameters int_ndisk int_nfilesys |
|---|
| 226 | #@brief Muestra los parámetros de arranque de un sistema de archivos Linux. |
|---|
| 227 | #@param int_ndisk nº de orden del disco |
|---|
| 228 | #@param int_nfilesys nº de orden del sistema de archivos |
|---|
| 229 | #@return str_kernel str_initrd str_parameters ... |
|---|
| 230 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 231 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
|---|
| 232 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
|---|
| 233 | #@warning Función básica usada por \c ogBoot |
|---|
| 234 | #@version 0.9 - Primera adaptación para OpenGnSys. |
|---|
| 235 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 236 | #@date 2009-09-11 |
|---|
| 237 | #@version 0.9.2 - Soporta partición /boot independiente. |
|---|
| 238 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 239 | #@date 2010-07-20 |
|---|
| 240 | #@version 1.0.5 - Mejoras en tratamiento de GRUB2. |
|---|
| 241 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 242 | #@date 2013-05-14 |
|---|
| 243 | #@version 1.0.6 - Detectar instalaciones sobre EFI. |
|---|
| 244 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 245 | #@date 2014-09-15 |
|---|
| 246 | #*/ ## |
|---|
| 247 | function ogLinuxBootParameters () |
|---|
| 248 | { |
|---|
| 249 | # Variables locales. |
|---|
| 250 | local MNTDIR CONFDIR CONFFILE f |
|---|
| 251 | |
|---|
| 252 | # Si se solicita, mostrar ayuda. |
|---|
| 253 | if [ "$*" == "help" ]; then |
|---|
| 254 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_nfilesys" \ |
|---|
| 255 | "$FUNCNAME 1 2 ==> /vmlinuz-3.5.0-21-generic /initrd.img-3.5.0-21-generic root=/dev/sda2 ro splash" |
|---|
| 256 | return |
|---|
| 257 | fi |
|---|
| 258 | # Error si no se reciben 2 parámetros. |
|---|
| 259 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
|---|
| 260 | |
|---|
| 261 | # Detectar id. de tipo de partición y codificar al mnemonico. |
|---|
| 262 | MNTDIR=$(ogMount $1 $2) || return $? |
|---|
| 263 | |
|---|
| 264 | # Fichero de configuración de GRUB. |
|---|
| 265 | CONFDIR=$MNTDIR # Sistema de archivos de arranque (/boot). |
|---|
| 266 | [ -d $MNTDIR/boot ] && CONFDIR=$MNTDIR/boot # Sist. archivos raíz con directorio boot. |
|---|
| 267 | for f in $MNTDIR/{,boot/}{{grubMBR,grubPARTITION}/boot/,}{grub{,2},{,efi/}EFI/*}/{menu.lst,grub.cfg}; do |
|---|
| 268 | [ -r $f ] && CONFFILE=$f |
|---|
| 269 | done |
|---|
| 270 | [ -n "$CONFFILE" ] || ogRaiseError $OG_ERR_NOTFOUND "grub.cfg" || return $? |
|---|
| 271 | |
|---|
| 272 | # Toma del fichero de configuracion los valores del kernel, initrd |
|---|
| 273 | # y parámetros de arranque usando las cláusulas por defecto |
|---|
| 274 | # ("default" en GRUB1, "set default" en GRUB2) |
|---|
| 275 | # y los formatea para que sean compatibles con \c kexec . */ |
|---|
| 276 | # /* (comentario Doxygen) |
|---|
| 277 | awk 'BEGIN {cont=-1;} |
|---|
| 278 | $1~/^default$/ {sub(/=/," "); def=$2;} |
|---|
| 279 | $1~/^set$/ && $2~/^default/ { gsub(/[="]/," "); def=$3; |
|---|
| 280 | if (def ~ /saved_entry/) def=0; |
|---|
| 281 | } |
|---|
| 282 | $1~/^(title|menuentry)$/ {cont++} |
|---|
| 283 | $1~/^set$/ && $2~/^root=.\(hd'$[1-1]',(msdos|gpt)'$2'\).$/ { if (def==0) def=cont; } |
|---|
| 284 | $1~/^(kernel|linux(16|efi)?)$/ { if (def==cont) { |
|---|
| 285 | kern=$2; |
|---|
| 286 | sub($1,""); sub($1,""); sub(/^[ \t]*/,""); app=$0 |
|---|
| 287 | } # /* (comentario Doxygen) |
|---|
| 288 | } |
|---|
| 289 | $1~/^initrd(16|efi)?$/ {if (def==cont) init=$2} |
|---|
| 290 | END {if (kern!="") printf("%s %s %s", kern,init,app)} |
|---|
| 291 | ' $CONFFILE |
|---|
| 292 | # */ (comentario Doxygen) |
|---|
| 293 | } |
|---|
| 294 | |
|---|
| 295 | |
|---|
| 296 | #/** |
|---|
| 297 | # ogSetWindowsName int_ndisk int_nfilesys str_name |
|---|
| 298 | #@brief Establece el nombre del equipo en el registro de Windows. |
|---|
| 299 | #@param int_ndisk nº de orden del disco |
|---|
| 300 | #@param int_nfilesys nº de orden del sistema de archivos |
|---|
| 301 | #@param str_name nombre asignado |
|---|
| 302 | #@return (nada) |
|---|
| 303 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 304 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
|---|
| 305 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
|---|
| 306 | #@exception OG_ERR_OUTOFLIMIT Nombre Netbios con más de 15 caracteres. |
|---|
| 307 | #@version 0.9 - Adaptación a OpenGnSys. |
|---|
| 308 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 309 | #@date 2009-09-24 |
|---|
| 310 | #@version 1.0.5 - Establecer restricción de tamaño de nombre Netbios. |
|---|
| 311 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 312 | #@date 2013-03-20 |
|---|
| 313 | #*/ ## |
|---|
| 314 | function ogSetWindowsName () |
|---|
| 315 | { |
|---|
| 316 | # Variables locales. |
|---|
| 317 | local PART MNTDIR NAME |
|---|
| 318 | |
|---|
| 319 | # Si se solicita, mostrar ayuda. |
|---|
| 320 | if [ "$*" == "help" ]; then |
|---|
| 321 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_filesys str_name" \ |
|---|
| 322 | "$FUNCNAME 1 1 PRACTICA-PC" |
|---|
| 323 | return |
|---|
| 324 | fi |
|---|
| 325 | # Error si no se reciben 3 parámetros. |
|---|
| 326 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
|---|
| 327 | # Error si el nombre supera los 15 caracteres. |
|---|
| 328 | [ ${#3} -le 15 ] || ogRaiseError $OG_ERR_OUTOFLIMIT "\"${3:0:15}...\"" || return $? |
|---|
| 329 | |
|---|
| 330 | # Montar el sistema de archivos. |
|---|
| 331 | MNTDIR=$(ogMount $1 $2) || return $? |
|---|
| 332 | |
|---|
| 333 | # Asignar nombre. |
|---|
| 334 | NAME="$3" |
|---|
| 335 | |
|---|
| 336 | # Modificar datos de los valores de registro. |
|---|
| 337 | ogSetRegistryValue $MNTDIR system '\ControlSet001\Control\ComputerName\ComputerName\ComputerName' "$NAME" 2>/dev/null |
|---|
| 338 | ogSetRegistryValue $MNTDIR system '\ControlSet001\Services\Tcpip\Parameters\Hostname' "$NAME" 2>/dev/null |
|---|
| 339 | ogSetRegistryValue $MNTDIR system '\ControlSet001\Services\Tcpip\Parameters\HostName' "$NAME" 2>/dev/null |
|---|
| 340 | ogSetRegistryValue $MNTDIR system '\ControlSet001\services\Tcpip\Parameters\Hostname' "$NAME" 2>/dev/null |
|---|
| 341 | ogSetRegistryValue $MNTDIR system '\ControlSet001\Services\Tcpip\Parameters\NV Hostname' "$NAME" 2>/dev/null |
|---|
| 342 | ogSetRegistryValue $MNTDIR system '\ControlSet001\Services\Tcpip\Parameters\NV HostName' "$NAME" 2>/dev/null |
|---|
| 343 | ogSetRegistryValue $MNTDIR system '\ControlSet001\services\Tcpip\Parameters\NV Hostname' "$NAME" 2>/dev/null |
|---|
| 344 | } |
|---|
| 345 | |
|---|
| 346 | |
|---|
| 347 | #/** |
|---|
| 348 | # ogSetWinlogonUser int_ndisk int_npartition str_username |
|---|
| 349 | #@brief Establece el nombre de usuario por defecto en la entrada de Windows. |
|---|
| 350 | #@param int_ndisk nº de orden del disco |
|---|
| 351 | #@param int_npartition nº de orden de la partición |
|---|
| 352 | #@param str_username nombre de usuario por defecto |
|---|
| 353 | #@return (nada) |
|---|
| 354 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 355 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
|---|
| 356 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
|---|
| 357 | #@version 0.9.2 - Adaptación a OpenGnSys. |
|---|
| 358 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 359 | #@date 2010-07-20 |
|---|
| 360 | #*/ ## |
|---|
| 361 | function ogSetWinlogonUser () |
|---|
| 362 | { |
|---|
| 363 | # Variables locales. |
|---|
| 364 | local PART MNTDIR NAME |
|---|
| 365 | |
|---|
| 366 | # Si se solicita, mostrar ayuda. |
|---|
| 367 | if [ "$*" == "help" ]; then |
|---|
| 368 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition str_username" \ |
|---|
| 369 | "$FUNCNAME 1 1 USUARIO" |
|---|
| 370 | return |
|---|
| 371 | fi |
|---|
| 372 | # Error si no se reciben 3 parámetros. |
|---|
| 373 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
|---|
| 374 | |
|---|
| 375 | # Montar el sistema de archivos. |
|---|
| 376 | MNTDIR=$(ogMount $1 $2) || return $? |
|---|
| 377 | |
|---|
| 378 | # Asignar nombre. |
|---|
| 379 | NAME="$3" |
|---|
| 380 | |
|---|
| 381 | # Modificar datos en el registro. |
|---|
| 382 | ogSetRegistryValue $MNTDIR SOFTWARE '\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName' "$3" |
|---|
| 383 | } |
|---|
| 384 | |
|---|
| 385 | |
|---|
| 386 | #/** |
|---|
| 387 | # ogBootMbrXP int_ndisk |
|---|
| 388 | #@brief Genera un nuevo Master Boot Record en el disco duro indicado, compatible con los SO tipo Windows |
|---|
| 389 | #@param int_ndisk nº de orden del disco |
|---|
| 390 | #@return salida del programa my-sys |
|---|
| 391 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 392 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
|---|
| 393 | #@version 0.9 - Adaptación a OpenGnSys. |
|---|
| 394 | #@author Antonio J. Doblas Viso. Universidad de Málaga |
|---|
| 395 | #@date 2009-09-24 |
|---|
| 396 | #*/ ## |
|---|
| 397 | |
|---|
| 398 | function ogBootMbrXP () |
|---|
| 399 | { |
|---|
| 400 | # Variables locales. |
|---|
| 401 | local DISK |
|---|
| 402 | |
|---|
| 403 | # Si se solicita, mostrar ayuda. |
|---|
| 404 | if [ "$*" == "help" ]; then |
|---|
| 405 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk " \ |
|---|
| 406 | "$FUNCNAME 1" |
|---|
| 407 | return |
|---|
| 408 | fi |
|---|
| 409 | # Error si no se recibe 1 parámetro. |
|---|
| 410 | [ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
|---|
| 411 | |
|---|
| 412 | DISK="$(ogDiskToDev $1)" || return $? |
|---|
| 413 | ms-sys -z -f $DISK |
|---|
| 414 | ms-sys -m -f $DISK |
|---|
| 415 | } |
|---|
| 416 | |
|---|
| 417 | |
|---|
| 418 | #/** |
|---|
| 419 | # ogBootMbrGeneric int_ndisk |
|---|
| 420 | #@brief Genera un nuevo Codigo de arranque en el MBR del disco indicado, compatible con los SO tipo Windows, Linux. |
|---|
| 421 | #@param int_ndisk nº de orden del disco |
|---|
| 422 | #@return salida del programa my-sys |
|---|
| 423 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 424 | #@exception OG_ERR_NOTFOUND Tipo de partición desconocido o no se puede montar. |
|---|
| 425 | #@version 0.9 - Adaptación a OpenGnSys. |
|---|
| 426 | #@author Antonio J. Doblas Viso. Universidad de Málaga |
|---|
| 427 | #@date 2009-09-24 |
|---|
| 428 | #*/ ## |
|---|
| 429 | |
|---|
| 430 | function ogBootMbrGeneric () |
|---|
| 431 | { |
|---|
| 432 | # Variables locales. |
|---|
| 433 | local DISK |
|---|
| 434 | |
|---|
| 435 | # Si se solicita, mostrar ayuda. |
|---|
| 436 | if [ "$*" == "help" ]; then |
|---|
| 437 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk " \ |
|---|
| 438 | "$FUNCNAME 1 " |
|---|
| 439 | return |
|---|
| 440 | fi |
|---|
| 441 | # Error si no se recibe 1 parámetro. |
|---|
| 442 | [ $# == 1 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) |
|---|
| 443 | |
|---|
| 444 | DISK="$(ogDiskToDev $1)" || return $? |
|---|
| 445 | ms-sys -z -f $DISK |
|---|
| 446 | ms-sys -s -f $DISK |
|---|
| 447 | } |
|---|
| 448 | |
|---|
| 449 | |
|---|
| 450 | |
|---|
| 451 | |
|---|
| 452 | #/** |
|---|
| 453 | # ogFixBootSector int_ndisk int_parition |
|---|
| 454 | #@brief Corrige el boot sector de una particion activa para MS windows/dos -fat-ntfs |
|---|
| 455 | #@param int_ndisk nº de orden del disco |
|---|
| 456 | #@param int_partition nº de particion |
|---|
| 457 | #@return |
|---|
| 458 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 459 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
|---|
| 460 | #@version 0.9 - Adaptación a OpenGnSys. |
|---|
| 461 | #@author Antonio J. Doblas Viso. Universidad de Málaga |
|---|
| 462 | #@date 2009-09-24 |
|---|
| 463 | #*/ ## |
|---|
| 464 | |
|---|
| 465 | function ogFixBootSector () |
|---|
| 466 | { |
|---|
| 467 | # Variables locales. |
|---|
| 468 | local PARTYPE DISK PART FILE |
|---|
| 469 | |
|---|
| 470 | # Si se solicita, mostrar ayuda. |
|---|
| 471 | if [ "$*" == "help" ]; then |
|---|
| 472 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_partition " \ |
|---|
| 473 | "$FUNCNAME 1 1 " |
|---|
| 474 | return |
|---|
| 475 | fi |
|---|
| 476 | |
|---|
| 477 | # Error si no se reciben 2 parámetros. |
|---|
| 478 | [ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) |
|---|
| 479 | |
|---|
| 480 | #TODO, solo si la particion existe |
|---|
| 481 | #TODO, solo si es ntfs o fat |
|---|
| 482 | PARTYPE=$(ogGetPartitionId $1 $2) |
|---|
| 483 | case "$PARTYPE" in |
|---|
| 484 | 1|4|6|7|b|c|e|f|17|700|EF00) |
|---|
| 485 | ;; |
|---|
| 486 | *) |
|---|
| 487 | return $(ogRaiseError $OG_ERR_PARTITION; echo $?) |
|---|
| 488 | ;; |
|---|
| 489 | esac |
|---|
| 490 | |
|---|
| 491 | ogUnmount $1 $2 || return $(ogRaiseError $OG_ERR_PARTITION; echo $?) |
|---|
| 492 | |
|---|
| 493 | #Preparando instruccion |
|---|
| 494 | let DISK=$1-1 |
|---|
| 495 | PART=$2 |
|---|
| 496 | FILE=/tmp/temp$$ |
|---|
| 497 | cat > $FILE <<EOF |
|---|
| 498 | disk=$DISK |
|---|
| 499 | main_part=$PART |
|---|
| 500 | fix_first_sector=yes |
|---|
| 501 | EOF |
|---|
| 502 | |
|---|
| 503 | timeout --foreground --signal=SIGKILL 5s spartlnx.run -cui -nm -a -f $FILE |
|---|
| 504 | rm -f $FILE |
|---|
| 505 | } |
|---|
| 506 | |
|---|
| 507 | |
|---|
| 508 | |
|---|
| 509 | #/** |
|---|
| 510 | # ogWindowsBootParameters int_ndisk int_parition |
|---|
| 511 | #@brief Configura el gestor de arranque de windows 7 / vista / XP / 2000 |
|---|
| 512 | #@param int_ndisk nº de orden del disco |
|---|
| 513 | #@param int_partition nº de particion |
|---|
| 514 | #@return |
|---|
| 515 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 516 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
|---|
| 517 | #@version 0.9 - Integración desde EAC para OpenGnSys. |
|---|
| 518 | #@author Antonio J. Doblas Viso. Universidad de Málaga |
|---|
| 519 | #@date 2009-09-24 |
|---|
| 520 | #@version 1.0.1 - Adapatacion para OpenGnsys. |
|---|
| 521 | #@author Antonio J. Doblas Viso. Universidad de Málaga |
|---|
| 522 | #@date 2011-05-20 |
|---|
| 523 | #@version 1.0.5 - Soporte para Windows 8 y Windows 8.1. |
|---|
| 524 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 525 | #@date 2014-01-28 |
|---|
| 526 | #@version 1.1.0 - Soporte para Windows 10. |
|---|
| 527 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 528 | #@date 2016-01-19 |
|---|
| 529 | #@version 1.1.1 - Compatibilidad con UEFI (ticket #802 #889) |
|---|
| 530 | #@author Irina Gomez, ETSII Universidad de Sevilla |
|---|
| 531 | #@date 2019-01-28 |
|---|
| 532 | #*/ ## |
|---|
| 533 | |
|---|
| 534 | function ogWindowsBootParameters () |
|---|
| 535 | { |
|---|
| 536 | # Variables locales. |
|---|
| 537 | local PART DISK BOOTLABEL BCDFILE BOOTDISK BOOTPART FILE WINVER MOUNT |
|---|
| 538 | |
|---|
| 539 | # Si se solicita, mostrar ayuda. |
|---|
| 540 | if [ "$*" == "help" ]; then |
|---|
| 541 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_partition " \ |
|---|
| 542 | "$FUNCNAME 1 1 " |
|---|
| 543 | return |
|---|
| 544 | fi |
|---|
| 545 | |
|---|
| 546 | # Error si no se reciben 2 parámetros. |
|---|
| 547 | [ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) |
|---|
| 548 | |
|---|
| 549 | ogDiskToDev $1 $2 || return $(ogRaiseError $OG_ERR_PARTITION; echo $?) |
|---|
| 550 | |
|---|
| 551 | #Preparando variables adaptadas a sintaxis windows. |
|---|
| 552 | let DISK=$1-1 |
|---|
| 553 | PART=$2 |
|---|
| 554 | FILE=/tmp/temp$$ |
|---|
| 555 | if ogIsEfiActive; then |
|---|
| 556 | read BOOTDISK BOOTPART <<< $(ogGetEsp) |
|---|
| 557 | ogUnmount $BOOTDISK $BOOTPART || ogRaiseError $OG_ERR_PARTITION "ESP: $BOOTDISK $BOOTPART" || return $? |
|---|
| 558 | |
|---|
| 559 | let BOOTDISK=$BOOTDISK-1 |
|---|
| 560 | BOOTLABEL=$(printf "Part-%02d-%02d" $1 $2) |
|---|
| 561 | BCDFILE="boot_BCD_file=/EFI/$BOOTLABEL/Boot/BCD" |
|---|
| 562 | else |
|---|
| 563 | BOOTDISK=$DISK |
|---|
| 564 | BOOTPART=$PART |
|---|
| 565 | BCDFILE="" |
|---|
| 566 | fi |
|---|
| 567 | |
|---|
| 568 | |
|---|
| 569 | # Obtener versión de Windows. |
|---|
| 570 | WINVER=$(ogGetOsVersion $1 $2 | awk -F"[: ]" '$1=="Windows" {if ($3=="Server") print $2,$3,$4; else print $2,$3;}') |
|---|
| 571 | [ -z "$WINVER" ] && return $(ogRaiseError $OG_ERR_NOTOS "Windows"; echo $?) |
|---|
| 572 | |
|---|
| 573 | # Acciones para Windows XP. |
|---|
| 574 | if [[ "$WINVER" =~ "XP" ]]; then |
|---|
| 575 | MOUNT=$(ogMount $1 $2) |
|---|
| 576 | [ -f ${MOUNT}/boot.ini ] || return $(ogRaiseError $OG_ERR_NOTFOUND "boot.ini"; echo $?) |
|---|
| 577 | cat ${MOUNT}/boot.ini | sed s/partition\([0-9]\)/partition\($PART\)/g | sed s/rdisk\([0-9]\)/rdisk\($DISK\)/g > ${MOUNT}/tmp.boot.ini; mv ${MOUNT}/tmp.boot.ini ${MOUNT}/boot.ini |
|---|
| 578 | return 0 |
|---|
| 579 | fi |
|---|
| 580 | |
|---|
| 581 | ogUnmount $1 $2 || return $(ogRaiseError $OG_ERR_PARTITION; echo $?) |
|---|
| 582 | |
|---|
| 583 | |
|---|
| 584 | #Preparando instruccion Windows Resume Application |
|---|
| 585 | cat > $FILE <<EOF |
|---|
| 586 | boot_disk=$BOOTDISK |
|---|
| 587 | boot_main_part=$BOOTPART |
|---|
| 588 | $BCDFILE |
|---|
| 589 | disk=$DISK |
|---|
| 590 | main_part=$PART |
|---|
| 591 | boot_entry=Windows Resume Application |
|---|
| 592 | EOF |
|---|
| 593 | timeout --foreground --signal=SIGKILL 5s spartlnx.run -cui -nm -w -f $FILE |
|---|
| 594 | |
|---|
| 595 | |
|---|
| 596 | #Preparando instruccion tipo windows |
|---|
| 597 | cat > $FILE <<EOF |
|---|
| 598 | boot_disk=$BOOTDISK |
|---|
| 599 | boot_main_part=$BOOTPART |
|---|
| 600 | $BCDFILE |
|---|
| 601 | disk=$DISK |
|---|
| 602 | main_part=$PART |
|---|
| 603 | boot_entry=$WINVER |
|---|
| 604 | EOF |
|---|
| 605 | timeout --foreground --signal=SIGKILL 5s spartlnx.run -cui -nm -w -f $FILE |
|---|
| 606 | |
|---|
| 607 | ##Preparando instruccion Ramdisk Options |
|---|
| 608 | cat > $FILE <<EOF |
|---|
| 609 | boot_disk=$BOOTDISK |
|---|
| 610 | boot_main_part=$BOOTPART |
|---|
| 611 | $BCDFILE |
|---|
| 612 | disk=$DISK |
|---|
| 613 | main_part=$PART |
|---|
| 614 | boot_entry=Ramdisk Options |
|---|
| 615 | EOF |
|---|
| 616 | timeout --foreground --signal=SIGKILL 5s spartlnx.run -cui -nm -w -f $FILE |
|---|
| 617 | |
|---|
| 618 | ##Preparando instruccion Recovery Environment |
|---|
| 619 | cat > $FILE <<EOF |
|---|
| 620 | boot_disk=$BOOTDISK |
|---|
| 621 | boot_main_part=$BOOTPART |
|---|
| 622 | $BCDFILE |
|---|
| 623 | disk=$DISK |
|---|
| 624 | main_part=$PART |
|---|
| 625 | boot_entry=Windows Recovery Environment |
|---|
| 626 | EOF |
|---|
| 627 | timeout --foreground --signal=SIGKILL 5s spartlnx.run -cui -nm -w -f $FILE |
|---|
| 628 | |
|---|
| 629 | ##Preparando instruccion Recovery |
|---|
| 630 | cat > $FILE <<EOF |
|---|
| 631 | boot_disk=$BOOTDISK |
|---|
| 632 | boot_main_part=$BOOTPART |
|---|
| 633 | $BCDFILE |
|---|
| 634 | disk=$DISK |
|---|
| 635 | main_part=$PART |
|---|
| 636 | boot_entry=Windows Recovery |
|---|
| 637 | EOF |
|---|
| 638 | timeout --foreground --signal=SIGKILL 5s spartlnx.run -cui -nm -w -f $FILE |
|---|
| 639 | |
|---|
| 640 | #Preparando instruccion Windows Boot Manager |
|---|
| 641 | cat > $FILE <<EOF |
|---|
| 642 | boot_disk=$BOOTDISK |
|---|
| 643 | boot_main_part=$BOOTPART |
|---|
| 644 | $BCDFILE |
|---|
| 645 | disk=$BOOTDISK |
|---|
| 646 | main_part=$BOOTPART |
|---|
| 647 | boot_entry=Windows Boot Manager |
|---|
| 648 | EOF |
|---|
| 649 | timeout --foreground --signal=SIGKILL 5s spartlnx.run -cui -nm -w -f $FILE |
|---|
| 650 | |
|---|
| 651 | #Preparando instruccion Herramienta de diagnóstico de memoria de Windows |
|---|
| 652 | cat > $FILE <<EOF |
|---|
| 653 | boot_disk=$BOOTDISK |
|---|
| 654 | boot_main_part=$BOOTPART |
|---|
| 655 | $BCDFILE |
|---|
| 656 | disk=$BOOTDISK |
|---|
| 657 | main_part=$BOOTPART |
|---|
| 658 | boot_entry=Herramienta de diagnóstico de memoria de Windows |
|---|
| 659 | EOF |
|---|
| 660 | timeout --foreground --signal=SIGKILL 5s spartlnx.run -cui -nm -w -f $FILE |
|---|
| 661 | |
|---|
| 662 | #Preparando instruccion Herramienta de diagnóstico de memoria de Windows |
|---|
| 663 | cat > $FILE <<EOF |
|---|
| 664 | boot_disk=$BOOTDISK |
|---|
| 665 | boot_main_part=$BOOTPART |
|---|
| 666 | $BCDFILE |
|---|
| 667 | disk=$BOOTDISK |
|---|
| 668 | main_part=$BOOTPART |
|---|
| 669 | boot_entry=Herramienta de diagn<f3>stico de memoria de Windows |
|---|
| 670 | EOF |
|---|
| 671 | timeout --foreground --signal=SIGKILL 5s spartlnx.run -cui -nm -w -f $FILE |
|---|
| 672 | |
|---|
| 673 | rm -f $FILE |
|---|
| 674 | } |
|---|
| 675 | |
|---|
| 676 | |
|---|
| 677 | |
|---|
| 678 | #/** |
|---|
| 679 | # ogWindowsRegisterPartition int_ndisk int_partiton str_volume int_disk int_partition |
|---|
| 680 | #@brief Registra una partición en windows con un determinado volumen. |
|---|
| 681 | #@param int_ndisk nº de orden del disco a registrar |
|---|
| 682 | #@param int_partition nº de particion a registrar |
|---|
| 683 | #@param str_volumen volumen a resgistar |
|---|
| 684 | #@param int_ndisk_windows nº de orden del disco donde esta windows |
|---|
| 685 | #@param int_partition_windows nº de particion donde esta windows |
|---|
| 686 | #@return |
|---|
| 687 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 688 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
|---|
| 689 | #@version 0.9 - Adaptación a OpenGnSys. |
|---|
| 690 | #@author Antonio J. Doblas Viso. Universidad de Málaga |
|---|
| 691 | #@date 2009-09-24 |
|---|
| 692 | #*/ ## |
|---|
| 693 | function ogWindowsRegisterPartition () |
|---|
| 694 | { |
|---|
| 695 | # Variables locales. |
|---|
| 696 | local PART DISK FILE REGISTREDDISK REGISTREDPART REGISTREDVOL VERSION SYSTEMROOT |
|---|
| 697 | |
|---|
| 698 | # Si se solicita, mostrar ayuda. |
|---|
| 699 | if [ "$*" == "help" ]; then |
|---|
| 700 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk_TO_registre int_partition_TO_registre str_NewVolume int_disk int_parition " \ |
|---|
| 701 | "$FUNCNAME 1 1 c: 1 1" |
|---|
| 702 | return |
|---|
| 703 | fi |
|---|
| 704 | |
|---|
| 705 | # Error si no se reciben 5 parámetros. |
|---|
| 706 | [ $# == 5 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) |
|---|
| 707 | |
|---|
| 708 | REGISTREDDISK=$1 |
|---|
| 709 | REGISTREDPART=$2 |
|---|
| 710 | REGISTREDVOL=$(echo $3 | cut -c1 | tr '[:lower:]' '[:upper:]') |
|---|
| 711 | DISK=$4 |
|---|
| 712 | PART=$5 |
|---|
| 713 | FILE=/tmp/temp$$ |
|---|
| 714 | |
|---|
| 715 | ogDiskToDev $REGISTREDDISK $REGISTREDPART || return $(ogRaiseError $OG_ERR_PARTITION "particion a registrar "; echo $?) |
|---|
| 716 | ogDiskToDev $DISK $PART || return $(ogRaiseError $OG_ERR_PARTITION "particion de windows"; echo $?) |
|---|
| 717 | |
|---|
| 718 | ogGetOsType $DISK $PART | grep "Windows" || return $(ogRaiseError $OG_ERR_NOTOS "no es windows"; echo $?) |
|---|
| 719 | |
|---|
| 720 | VERSION=$(ogGetOsVersion $DISK $PART) |
|---|
| 721 | |
|---|
| 722 | #Systemroot |
|---|
| 723 | |
|---|
| 724 | if ogGetPath $DISK $PART WINDOWS |
|---|
| 725 | then |
|---|
| 726 | SYSTEMROOT="Windows" |
|---|
| 727 | elif ogGetPath $DISK $PART WINNT |
|---|
| 728 | then |
|---|
| 729 | SYSTEMROOT="winnt" |
|---|
| 730 | else |
|---|
| 731 | return $(ogRaiseError $OG_ERR_NOTOS; echo $?) |
|---|
| 732 | fi |
|---|
| 733 | |
|---|
| 734 | ogUnmount $DISK $PART |
|---|
| 735 | let DISK=$DISK-1 |
|---|
| 736 | let REGISTREDDISK=$REGISTREDDISK-1 |
|---|
| 737 | #Preparando instruccion Windows Boot Manager |
|---|
| 738 | cat > $FILE <<EOF |
|---|
| 739 | windows_disk=$DISK |
|---|
| 740 | windows_main_part=$PART |
|---|
| 741 | windows_dir=$SYSTEMROOT |
|---|
| 742 | disk=$REGISTREDDISK |
|---|
| 743 | main_part=$REGISTREDPART |
|---|
| 744 | ;ext_part |
|---|
| 745 | part_letter=$REGISTREDVOL |
|---|
| 746 | EOF |
|---|
| 747 | timeout --foreground --signal=SIGKILL 5s spartlnx.run -cui -nm -u -f $FILE |
|---|
| 748 | |
|---|
| 749 | } |
|---|
| 750 | |
|---|
| 751 | #/** |
|---|
| 752 | # ogGrubInstallMbr int_disk_GRUBCFG int_partition_GRUBCFG |
|---|
| 753 | #@brief Instala el grub el el MBR del primer disco duro (FIRSTSTAGE). El fichero de configuración grub.cfg ubicado según parametros disk y part(SECONDSTAGE). Admite sistemas Windows. |
|---|
| 754 | #@param int_disk_SecondStage |
|---|
| 755 | #@param int_part_SecondStage |
|---|
| 756 | #@param bolean_Check_Os_installed_and_Configure_2ndStage true | false[default] |
|---|
| 757 | #@return |
|---|
| 758 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 759 | #@version 1.0.2 - Primeras pruebas. |
|---|
| 760 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 761 | #@date 2011-10-29 |
|---|
| 762 | #@version 1.0.3 - Soporte para linux de 32 y 64 bits |
|---|
| 763 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 764 | #@date 2012-03-13 |
|---|
| 765 | #@version 1.0.3 - Ficheros de configuracion independientes segun ubicación de la primera etapa |
|---|
| 766 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 767 | #@date 2012-03-13 |
|---|
| 768 | #@version 1.1.0 - #791 El FIRSTSTAGE(MBR) siempre será el primer disco duro. EL SECONDSTAGE(grub.cfg) estára en el DISK y PART indicados en los parámetros. |
|---|
| 769 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 770 | #@date 2017-06-19 |
|---|
| 771 | #@version 1.1.0 - #827 Entrada para el ogLive si el equipo tiene partición cache. |
|---|
| 772 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 773 | #@date 2018-01-21 |
|---|
| 774 | #@version 1.1.1 - #802 Equipos EFI: Se crea el grub.cfg de la partición EFI |
|---|
| 775 | #@author Irina Gomez, ETSII Universidad de Sevilla |
|---|
| 776 | #@date 2019-01-08 |
|---|
| 777 | #@version 1.1.1 - #890 UEFI: el grub.cfg original es necesario para obtener los datos del kernel efi: se mueve al final. |
|---|
| 778 | #@author Irina Gomez, ETSII Universidad de Sevilla |
|---|
| 779 | #@date 2019-03-05 |
|---|
| 780 | #*/ ## |
|---|
| 781 | |
|---|
| 782 | function ogGrubInstallMbr () |
|---|
| 783 | { |
|---|
| 784 | |
|---|
| 785 | # Variables locales. |
|---|
| 786 | local PART DISK VERSION FIRSTAGE SECONSTAGE CHECKOS KERNELPARAM BACKUPNAME |
|---|
| 787 | local EFIDISK EFIPART EFISECONDSTAGE EFISUBDIR EFIOPTGRUB GRUBENTRY NEWORDER |
|---|
| 788 | |
|---|
| 789 | # Si se solicita, mostrar ayuda. |
|---|
| 790 | if [ "$*" == "help" ]; then |
|---|
| 791 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage bolean_Configure_2ndStage \"param param \" " \ |
|---|
| 792 | "$FUNCNAME 1 1 FALSE " \ |
|---|
| 793 | "$FUNCNAME 1 1 TRUE \"nomodeset irqpoll pci=noacpi quiet splash \" " |
|---|
| 794 | return |
|---|
| 795 | fi |
|---|
| 796 | |
|---|
| 797 | # Error si no se reciben 2 parámetros. |
|---|
| 798 | [ $# -ge 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) |
|---|
| 799 | |
|---|
| 800 | |
|---|
| 801 | DISK=$1; PART=$2; |
|---|
| 802 | CHECKOS=${3:-"FALSE"} |
|---|
| 803 | KERNELPARAM=$4 |
|---|
| 804 | BACKUPNAME=".backup.og" |
|---|
| 805 | |
|---|
| 806 | #Error si no es linux. |
|---|
| 807 | #TODO: comprobar si se puede utilizar la particion windows como contenedor de grub. |
|---|
| 808 | #VERSION=$(ogGetOsVersion $DISK $PART) |
|---|
| 809 | #echo $VERSION | grep "Linux" || return $(ogRaiseError $OG_ERR_NOTOS "no es linux"; echo $?) |
|---|
| 810 | |
|---|
| 811 | #La primera etapa del grub se fija en el primer disco duro |
|---|
| 812 | FIRSTSTAGE=$(ogDiskToDev 1) |
|---|
| 813 | |
|---|
| 814 | #localizar disco segunda etapa del grub |
|---|
| 815 | SECONDSTAGE=$(ogMount "$DISK" "$PART") || return $? |
|---|
| 816 | |
|---|
| 817 | # prepara el directorio principal de la segunda etapa |
|---|
| 818 | [ -d ${SECONDSTAGE}/boot/grub/ ] || mkdir -p ${SECONDSTAGE}/boot/grub/ |
|---|
| 819 | |
|---|
| 820 | #Localizar directorio segunda etapa del grub |
|---|
| 821 | PREFIXSECONDSTAGE="/boot/grubMBR" |
|---|
| 822 | |
|---|
| 823 | # Instalamos grub para EFI en ESP |
|---|
| 824 | EFIOPTGRUB="" |
|---|
| 825 | if ogIsEfiActive; then |
|---|
| 826 | read EFIDISK EFIPART <<< $(ogGetEsp) |
|---|
| 827 | # Comprobamos que exista ESP y el directorio para ubuntu |
|---|
| 828 | EFISECONDSTAGE=$(ogMount $EFIDISK $EFIPART) |
|---|
| 829 | if [ $? -ne 0 ]; then |
|---|
| 830 | ogFormat $EFIDISK $EFIPART FAT32 |
|---|
| 831 | EFISECONDSTAGE=$(ogMount $EFIDISK $EFIPART) || ogRaiseError $OG_ERR_PARTITION "ESP" || return $? |
|---|
| 832 | fi |
|---|
| 833 | EFISUBDIR="grub" |
|---|
| 834 | # Borramos la configuración anterior |
|---|
| 835 | [ -d ${EFISECONDSTAGE}/EFI/$EFISUBDIR ] && rm -rf ${EFISECONDSTAGE}/EFI/$EFISUBDIR |
|---|
| 836 | mkdir -p ${EFISECONDSTAGE}/EFI/$EFISUBDIR/Boot |
|---|
| 837 | EFIOPTGRUB=" --removable --no-nvram --uefi-secure-boot --target $(ogGetArch)-efi --efi-directory=${EFISECONDSTAGE}/EFI/$EFISUBDIR " |
|---|
| 838 | fi |
|---|
| 839 | |
|---|
| 840 | # Si Reconfigurar segunda etapa (grub.cfg) == FALSE |
|---|
| 841 | if [ "${CHECKOS^^}" == "FALSE" ] && [ -f ${SECONDSTAGE}/boot/grub/grub.cfg -o -f ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME ] |
|---|
| 842 | then |
|---|
| 843 | # Si no se reconfigura se utiliza el grub.cfg orginal |
|---|
| 844 | [ -f ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME ] && mv ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME ${SECONDSTAGE}/boot/grub/grub.cfg |
|---|
| 845 | # Si no se reconfigure se borra los ficheros previos de configuración específicos de opengnsys. |
|---|
| 846 | [ -d ${SECONDSTAGE}${PREFIXSECONDSTAGE} ] && rm -fr ${SECONDSTAGE}${PREFIXSECONDSTAGE} |
|---|
| 847 | PREFIXSECONDSTAGE="" |
|---|
| 848 | else |
|---|
| 849 | # SI Reconfigurar segunda etapa (grub.cfg) == TRUE |
|---|
| 850 | |
|---|
| 851 | #llamada a updateBootCache para que aloje la primera fase del ogLive |
|---|
| 852 | updateBootCache |
|---|
| 853 | |
|---|
| 854 | if ogIsEfiActive; then |
|---|
| 855 | # UEFI: grubSintax necesita grub.cfg para detectar los kernels: si no existe recupero backup. |
|---|
| 856 | if ! [ -f ${SECONDSTAGE}/boot/grub/grub.cfg ]; then |
|---|
| 857 | [ -f ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME ] && mv ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME ${SECONDSTAGE}/boot/grub/grub.cfg |
|---|
| 858 | fi |
|---|
| 859 | else |
|---|
| 860 | #Evitar detectar modo recovery - mover grub.cfg original a grub.cfg.backup |
|---|
| 861 | mv ${SECONDSTAGE}/boot/grub/grub.cfg ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME |
|---|
| 862 | fi |
|---|
| 863 | |
|---|
| 864 | #Configur la sintaxis grub para evitar menus de "recovery" en el OGLive |
|---|
| 865 | echo "GRUB_DISABLE_RECOVERY=\"true\"" >> /etc/default/grub |
|---|
| 866 | echo "GRUB_DISABLE_LINUX_UUID=\"true\"" >> /etc/default/grub |
|---|
| 867 | |
|---|
| 868 | |
|---|
| 869 | #Preparar configuración segunda etapa: crear ubicacion |
|---|
| 870 | mkdir -p ${SECONDSTAGE}${PREFIXSECONDSTAGE}/boot/grub/ |
|---|
| 871 | #Preparar configuración segunda etapa: crear cabecera del fichero (ignorar errores) |
|---|
| 872 | sed -i 's/^set -e/#set -e/' /etc/grub.d/00_header |
|---|
| 873 | # (ogLive 5.0) Si 'pkgdatadir' está vacía ponemos valor de otros ogLive |
|---|
| 874 | sed -i '/grub-mkconfig_lib/i\pkgdatadir=${pkgdatadir:-"${datarootdir}/grub"}' /etc/grub.d/00_header |
|---|
| 875 | /etc/grub.d/00_header > ${SECONDSTAGE}${PREFIXSECONDSTAGE}/boot/grub/grub.cfg 2>/dev/null |
|---|
| 876 | |
|---|
| 877 | #Preparar configuración segunda etapa: crear entrada del sistema operativo |
|---|
| 878 | grubSyntax "$KERNELPARAM" >> ${SECONDSTAGE}${PREFIXSECONDSTAGE}/boot/grub/grub.cfg |
|---|
| 879 | |
|---|
| 880 | # Renombramos la configuración de grub antigua |
|---|
| 881 | [ -f ${SECONDSTAGE}/boot/grub/grub.cfg ] && mv ${SECONDSTAGE}/boot/grub/grub.cfg ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME |
|---|
| 882 | |
|---|
| 883 | fi |
|---|
| 884 | |
|---|
| 885 | #Instalar el grub |
|---|
| 886 | grub-install --force ${EFIOPTGRUB} --root-directory=${SECONDSTAGE}${PREFIXSECONDSTAGE} $FIRSTSTAGE |
|---|
| 887 | EVAL=$? |
|---|
| 888 | |
|---|
| 889 | # Movemos el grubx64.efi |
|---|
| 890 | if ogIsEfiActive; then |
|---|
| 891 | mv ${EFISECONDSTAGE}/EFI/$EFISUBDIR/EFI/BOOT/* ${EFISECONDSTAGE}/EFI/$EFISUBDIR/Boot |
|---|
| 892 | rm -rf ${EFISECONDSTAGE}/EFI/$EFISUBDIR/EFI |
|---|
| 893 | cp /usr/lib/shim/shimx64.efi.signed ${EFISECONDSTAGE}/EFI/$EFISUBDIR/Boot/shimx64.efi |
|---|
| 894 | # Nombre OpenGnsys para cargador |
|---|
| 895 | cp ${EFISECONDSTAGE}/EFI/$EFISUBDIR/Boot/{grubx64.efi,ogloader.efi} |
|---|
| 896 | |
|---|
| 897 | # Creamos entrada NVRAM y la ponemos en segundo lugar |
|---|
| 898 | ogNvramAddEntry grub /EFI/grub/Boot/shimx64.efi |
|---|
| 899 | GRUBENTRY=$(ogNvramList| awk '/grub/ {print $1}') |
|---|
| 900 | NEWORDER="$(ogNvramGetOrder|awk -v ENTRY=$GRUBENTRY '{gsub(",", " "); printf "%x %x %s\n", $1 , ENTRY , substr($0, index($0,$2))}')" |
|---|
| 901 | ogNvramSetOrder $NEWORDER |
|---|
| 902 | fi |
|---|
| 903 | return $EVAL |
|---|
| 904 | |
|---|
| 905 | } |
|---|
| 906 | |
|---|
| 907 | |
|---|
| 908 | #/** |
|---|
| 909 | # ogGrubInstallPartition int_disk_SECONDSTAGE int_partition_SECONDSTAGE bolean_Check_Os_installed_and_Configure_2ndStage |
|---|
| 910 | #@brief Instala y actualiza el gestor grub en el bootsector de la particion indicada |
|---|
| 911 | #@param int_disk_SecondStage |
|---|
| 912 | #@param int_part_SecondStage |
|---|
| 913 | #@param bolean_Check_Os_installed_and_Configure_2ndStage true | false[default] |
|---|
| 914 | #@param str "kernel param " |
|---|
| 915 | #@return |
|---|
| 916 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 917 | #@version 1.0.2 - Primeras pruebas. |
|---|
| 918 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 919 | #@date 2011-10-29 |
|---|
| 920 | #@version 1.0.3 - Soporte para linux de 32 y 64 bits |
|---|
| 921 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 922 | #@date 2012-03-13 |
|---|
| 923 | #@version 1.0.3 - Ficheros de configuracion independientes segun ubicación de la priemra etapa |
|---|
| 924 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 925 | #@date 2012-03-13 |
|---|
| 926 | #@version 1.1.1 - #802 Equipos EFI: Se crea el grub.cfg de la partición EFI |
|---|
| 927 | #@author Irina Gomez, ETSII Universidad de Sevilla |
|---|
| 928 | #@date 2019-01-08 |
|---|
| 929 | #@version 1.1.1 - #890 UEFI: el grub.cfg original es necesario para obtener los datos del kernel efi: se mueve al final. |
|---|
| 930 | #@author Irina Gomez, ETSII Universidad de Sevilla |
|---|
| 931 | #@date 2019-03-05 |
|---|
| 932 | #*/ ## |
|---|
| 933 | |
|---|
| 934 | function ogGrubInstallPartition () |
|---|
| 935 | { |
|---|
| 936 | |
|---|
| 937 | # Variables locales. |
|---|
| 938 | local PART DISK VERSION FIRSTAGE SECONSTAGE CHECKOS KERNELPARAM BACKUPNAME |
|---|
| 939 | local EFIDISK EFIPART EFISECONDSTAGE EFISUBDIR EFIOPTGRUB EFIBOOTDIR |
|---|
| 940 | |
|---|
| 941 | # Si se solicita, mostrar ayuda. |
|---|
| 942 | if [ "$*" == "help" ]; then |
|---|
| 943 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage bolean_Configure_2ndStage \"param param \" " \ |
|---|
| 944 | "$FUNCNAME 1 1 FALSE " \ |
|---|
| 945 | "$FUNCNAME 1 1 TRUE \"nomodeset irqpoll pci=noacpi quiet splash \" " |
|---|
| 946 | return |
|---|
| 947 | fi |
|---|
| 948 | |
|---|
| 949 | # Error si no se reciben 2 parámetros. |
|---|
| 950 | [ $# -ge 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) |
|---|
| 951 | |
|---|
| 952 | DISK=$1; PART=$2; |
|---|
| 953 | CHECKOS=${3:-"FALSE"} |
|---|
| 954 | KERNELPARAM=$4 |
|---|
| 955 | BACKUPNAME=".backup.og" |
|---|
| 956 | |
|---|
| 957 | #error si no es linux. |
|---|
| 958 | VERSION=$(ogGetOsVersion $DISK $PART) |
|---|
| 959 | echo $VERSION | grep "Linux" || return $(ogRaiseError $OG_ERR_NOTOS "no es linux"; echo $?) |
|---|
| 960 | |
|---|
| 961 | #Localizar primera etapa del grub |
|---|
| 962 | FIRSTSTAGE=$(ogDiskToDev $DISK $PART) |
|---|
| 963 | |
|---|
| 964 | #localizar disco segunda etapa del grub |
|---|
| 965 | SECONDSTAGE=$(ogMount $DISK $PART) |
|---|
| 966 | |
|---|
| 967 | #Localizar directorio segunda etapa del grub |
|---|
| 968 | PREFIXSECONDSTAGE="/boot/grubPARTITION" |
|---|
| 969 | |
|---|
| 970 | # Si es EFI instalamos el grub en la ESP |
|---|
| 971 | EFIOPTGRUB="" |
|---|
| 972 | # Desde el bootdir uefi y bios buscan el grub.cfg en subdirectorios distintos. |
|---|
| 973 | EFIBOOTDIR="" |
|---|
| 974 | if ogIsEfiActive; then |
|---|
| 975 | read EFIDISK EFIPART <<< $(ogGetEsp) |
|---|
| 976 | # Comprobamos que exista ESP y el directorio para ubuntu |
|---|
| 977 | EFISECONDSTAGE=$(ogMount $EFIDISK $EFIPART) |
|---|
| 978 | if [ $? -ne 0 ]; then |
|---|
| 979 | ogFormat $EFIDISK $EFIPART FAT32 |
|---|
| 980 | EFISECONDSTAGE=$(ogMount $EFIDISK $EFIPART) || ogRaiseError $OG_ERR_PARTITION "ESP" || return $? |
|---|
| 981 | fi |
|---|
| 982 | EFISUBDIR=$(printf "Part-%02d-%02d" $DISK $PART) |
|---|
| 983 | # Borramos la configuración anterior |
|---|
| 984 | [ -d ${EFISECONDSTAGE}/EFI/$EFISUBDIR ] && rm -rf ${EFISECONDSTAGE}/EFI/$EFISUBDIR |
|---|
| 985 | mkdir -p ${EFISECONDSTAGE}/EFI/$EFISUBDIR/Boot |
|---|
| 986 | EFIOPTGRUB=" --removable --no-nvram --uefi-secure-boot --target $(ogGetArch)-efi --efi-directory=${EFISECONDSTAGE}/EFI/$EFISUBDIR " |
|---|
| 987 | EFIBOOTDIR="/boot" |
|---|
| 988 | fi |
|---|
| 989 | |
|---|
| 990 | # Si Reconfigurar segunda etapa (grub.cfg) == FALSE |
|---|
| 991 | if [ "${CHECKOS^^}" == "FALSE" ] && [ -f ${SECONDSTAGE}/boot/grub/grub.cfg -o -f ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME ] |
|---|
| 992 | then |
|---|
| 993 | # Si no se reconfigura se utiliza el grub.cfg orginal |
|---|
| 994 | [ -f ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME ] && mv ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME ${SECONDSTAGE}/boot/grub/grub.cfg |
|---|
| 995 | # Si no se reconfigure se borra los ficheros previos de configuración específicos de opengnsys. |
|---|
| 996 | [ -d ${SECONDSTAGE}${PREFIXSECONDSTAGE} ] && rm -fr ${SECONDSTAGE}${PREFIXSECONDSTAGE} |
|---|
| 997 | # Reactivamos el grub con el grub.cfg original. |
|---|
| 998 | PREFIXSECONDSTAGE="" |
|---|
| 999 | else |
|---|
| 1000 | # SI Reconfigurar segunda etapa (grub.cfg) == TRUE |
|---|
| 1001 | |
|---|
| 1002 | if ogIsEfiActive; then |
|---|
| 1003 | # UEFI: grubSintax necesita grub.cfg para detectar los kernels: si no existe recupero backup. |
|---|
| 1004 | if ! [ -f ${SECONDSTAGE}/boot/grub/grub.cfg ]; then |
|---|
| 1005 | [ -f ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME ] && mv ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME ${SECONDSTAGE}/boot/grub/grub.cfg |
|---|
| 1006 | fi |
|---|
| 1007 | else |
|---|
| 1008 | #Evitar detectar modo recovery - mover grub.cfg original a grub.cfg.backup |
|---|
| 1009 | mv ${SECONDSTAGE}/boot/grub/grub.cfg ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME |
|---|
| 1010 | fi |
|---|
| 1011 | |
|---|
| 1012 | #Configur la sintaxis grub para evitar menus de "recovery" en el OGLive |
|---|
| 1013 | echo "GRUB_DISABLE_RECOVERY=\"true\"" >> /etc/default/grub |
|---|
| 1014 | echo "GRUB_DISABLE_LINUX_UUID=\"true\"" >> /etc/default/grub |
|---|
| 1015 | |
|---|
| 1016 | #Preparar configuración segunda etapa: crear ubicacion |
|---|
| 1017 | mkdir -p ${SECONDSTAGE}${PREFIXSECONDSTAGE}/boot/grub/ |
|---|
| 1018 | #Preparar configuración segunda etapa: crear cabecera del fichero (ingnorar errores) |
|---|
| 1019 | sed -i 's/^set -e/#set -e/' /etc/grub.d/00_header |
|---|
| 1020 | # (ogLive 5.0) Si 'pkgdatadir' está vacía ponemos valor de otros ogLive |
|---|
| 1021 | sed -i '/grub-mkconfig_lib/i\pkgdatadir=${pkgdatadir:-"${datarootdir}/grub"}' /etc/grub.d/00_header |
|---|
| 1022 | /etc/grub.d/00_header > ${SECONDSTAGE}${PREFIXSECONDSTAGE}/boot/grub/grub.cfg 2>/dev/null |
|---|
| 1023 | #Preparar configuración segunda etapa: crear entrada del sistema operativo |
|---|
| 1024 | grubSyntax $DISK $PART "$KERNELPARAM" >> ${SECONDSTAGE}${PREFIXSECONDSTAGE}/boot/grub/grub.cfg |
|---|
| 1025 | |
|---|
| 1026 | fi |
|---|
| 1027 | #Instalar el grub |
|---|
| 1028 | grub-install --force ${EFIOPTGRUB} --root-directory=${SECONDSTAGE}${PREFIXSECONDSTAGE} $FIRSTSTAGE |
|---|
| 1029 | EVAL=$? |
|---|
| 1030 | |
|---|
| 1031 | # Movemos el grubx64.efi |
|---|
| 1032 | if ogIsEfiActive; then |
|---|
| 1033 | mv ${EFISECONDSTAGE}/EFI/$EFISUBDIR/EFI/BOOT/* ${EFISECONDSTAGE}/EFI/$EFISUBDIR/Boot |
|---|
| 1034 | rm -rf ${EFISECONDSTAGE}/EFI/$EFISUBDIR/EFI |
|---|
| 1035 | cp /usr/lib/shim/shimx64.efi.signed ${EFISECONDSTAGE}/EFI/$EFISUBDIR/Boot/shimx64.efi |
|---|
| 1036 | # Nombre OpenGnsys para cargador |
|---|
| 1037 | cp ${EFISECONDSTAGE}/EFI/$EFISUBDIR/Boot/{grubx64.efi,ogloader.efi} |
|---|
| 1038 | fi |
|---|
| 1039 | |
|---|
| 1040 | return $EVAL |
|---|
| 1041 | } |
|---|
| 1042 | |
|---|
| 1043 | |
|---|
| 1044 | #/** |
|---|
| 1045 | # ogConfigureFstab int_ndisk int_nfilesys |
|---|
| 1046 | #@brief Configura el fstab según particiones existentes |
|---|
| 1047 | #@param int_ndisk nº de orden del disco |
|---|
| 1048 | #@param int_nfilesys nº de orden del sistema de archivos |
|---|
| 1049 | #@return (nada) |
|---|
| 1050 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 1051 | #@exception OG_ERR_NOTFOUND No se encuentra el fichero fstab a procesar. |
|---|
| 1052 | #@warning Puede haber un error si hay más de 1 partición swap. |
|---|
| 1053 | #@version 1.0.5 - Primera versión para OpenGnSys. Solo configura la SWAP |
|---|
| 1054 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 1055 | #@date 2013-03-21 |
|---|
| 1056 | #@version 1.0.6b - correccion. Si no hay partición fisica para la SWAP, eliminar entrada del fstab. |
|---|
| 1057 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 1058 | #@date 2016-11-03 |
|---|
| 1059 | #@version 1.1.1 - Se configura la partición ESP (para sistemas EFI) (ticket #802) |
|---|
| 1060 | #@author Irina Gómez, ETSII Universidad de Sevilla |
|---|
| 1061 | #@date 2018-12-13 |
|---|
| 1062 | #*/ ## |
|---|
| 1063 | function ogConfigureFstab () |
|---|
| 1064 | { |
|---|
| 1065 | # Variables locales. |
|---|
| 1066 | local FSTAB DEFROOT PARTROOT DEFSWAP PARTSWAP |
|---|
| 1067 | local EFIDISK EFIPART EFIDEV EFIOPT |
|---|
| 1068 | |
|---|
| 1069 | # Si se solicita, mostrar ayuda. |
|---|
| 1070 | if [ "$*" == "help" ]; then |
|---|
| 1071 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_nfilesys" \ |
|---|
| 1072 | "$FUNCNAME 1 1" |
|---|
| 1073 | return |
|---|
| 1074 | fi |
|---|
| 1075 | # Error si no se reciben 2 parámetros. |
|---|
| 1076 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
|---|
| 1077 | # Error si no se encuentra un fichero etc/fstab en el sistema de archivos. |
|---|
| 1078 | FSTAB=$(ogGetPath $1 $2 /etc/fstab) 2>/dev/null |
|---|
| 1079 | [ -n "$FSTAB" ] || ogRaiseError $OG_ERR_NOTFOUND "$1,$2,/etc/fstab" || return $? |
|---|
| 1080 | |
|---|
| 1081 | # Hacer copia de seguridad del fichero fstab original. |
|---|
| 1082 | cp -a ${FSTAB} ${FSTAB}.backup |
|---|
| 1083 | # Dispositivo del raíz en fichero fstab: 1er campo (si no tiene "#") con 2º campo = "/". |
|---|
| 1084 | DEFROOT=$(awk '$1!~/#/ && $2=="/" {print $1}' ${FSTAB}) |
|---|
| 1085 | PARTROOT=$(ogDiskToDev $1 $2) |
|---|
| 1086 | # Configuración de swap (solo 1ª partición detectada). |
|---|
| 1087 | PARTSWAP=$(blkid -t TYPE=swap | awk -F: 'NR==1 {print $1}') |
|---|
| 1088 | if [ -n "$PARTSWAP" ] |
|---|
| 1089 | then |
|---|
| 1090 | # Dispositivo de swap en fichero fstab: 1er campo (si no tiene "#") con 3er campo = "swap". |
|---|
| 1091 | DEFSWAP=$(awk '$1!~/#/ && $3=="swap" {print $1}' ${FSTAB}) |
|---|
| 1092 | if [ -n "$DEFSWAP" ] |
|---|
| 1093 | then |
|---|
| 1094 | echo "Hay definicion de SWAP en el FSTAB $DEFSWAP -> modificamos fichero con nuevo valor $DEFSWAP->$PARTSWAP" # Mensaje temporal. |
|---|
| 1095 | sed "s|$DEFSWAP|$PARTSWAP|g ; s|$DEFROOT|$PARTROOT|g" ${FSTAB}.backup > ${FSTAB} |
|---|
| 1096 | else |
|---|
| 1097 | echo "No hay definicion de SWAP y si hay partición SWAP -> moficamos fichero" # Mensaje temporal. |
|---|
| 1098 | sed "s|$DEFROOT|$PARTROOT|g" ${FSTAB}.backup > ${FSTAB} |
|---|
| 1099 | echo "$PARTSWAP none swap sw 0 0" >> ${FSTAB} |
|---|
| 1100 | fi |
|---|
| 1101 | else |
|---|
| 1102 | echo "No hay partición SWAP -> configuramos FSTAB" # Mensaje temporal. |
|---|
| 1103 | sed "/swap/d" ${FSTAB}.backup > ${FSTAB} |
|---|
| 1104 | fi |
|---|
| 1105 | # Si es un sistema EFI incluimos partición ESP (Si existe la modificamos) |
|---|
| 1106 | if ogIsEfiActive; then |
|---|
| 1107 | read EFIDISK EFIPART <<< $(ogGetEsp) |
|---|
| 1108 | EFIDEV=$(ogDiskToDev $EFIDISK $EFIPART) |
|---|
| 1109 | |
|---|
| 1110 | # Opciones de la partición ESP: si no existe ponemos un valor por defecto |
|---|
| 1111 | EFIOPT=$(awk '$1!~/#/ && $2=="/boot/efi" {print $3"\t"$4"\t"$5"\t"$6 }' ${FSTAB}) |
|---|
| 1112 | [ "$EFIOPT" == "" ] && EFIOPT='vfat\tumask=0077\t0\t1' |
|---|
| 1113 | |
|---|
| 1114 | sed -i /"boot\/efi"/d ${FSTAB} |
|---|
| 1115 | echo -e "$EFIDEV\t/boot/efi\t$EFIOPT" >> ${FSTAB} |
|---|
| 1116 | fi |
|---|
| 1117 | } |
|---|
| 1118 | |
|---|
| 1119 | #/** |
|---|
| 1120 | # ogSetLinuxName int_ndisk int_nfilesys [str_name] |
|---|
| 1121 | #@brief Establece el nombre del equipo en los ficheros hostname y hosts. |
|---|
| 1122 | #@param int_ndisk nº de orden del disco |
|---|
| 1123 | #@param int_nfilesys nº de orden del sistema de archivos |
|---|
| 1124 | #@param str_name nombre asignado (opcional) |
|---|
| 1125 | #@return (nada) |
|---|
| 1126 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 1127 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
|---|
| 1128 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
|---|
| 1129 | #@note Si no se indica nombre, se asigna un valor por defecto. |
|---|
| 1130 | #@version 1.0.5 - Primera versión para OpenGnSys. |
|---|
| 1131 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 1132 | #@date 2013-03-21 |
|---|
| 1133 | #*/ ## |
|---|
| 1134 | function ogSetLinuxName () |
|---|
| 1135 | { |
|---|
| 1136 | # Variables locales. |
|---|
| 1137 | local MNTDIR ETC NAME |
|---|
| 1138 | |
|---|
| 1139 | # Si se solicita, mostrar ayuda. |
|---|
| 1140 | if [ "$*" == "help" ]; then |
|---|
| 1141 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_nfilesys [str_name]" \ |
|---|
| 1142 | "$FUNCNAME 1 1" "$FUNCNAME 1 1 practica-pc" |
|---|
| 1143 | return |
|---|
| 1144 | fi |
|---|
| 1145 | # Error si no se reciben 2 o 3 parámetros. |
|---|
| 1146 | case $# in |
|---|
| 1147 | 2) # Asignar nombre automático (por defecto, "pc"). |
|---|
| 1148 | NAME="$(ogGetHostname)" |
|---|
| 1149 | NAME=${NAME:-"pc"} ;; |
|---|
| 1150 | 3) # Asignar nombre del 3er parámetro. |
|---|
| 1151 | NAME="$3" ;; |
|---|
| 1152 | *) # Formato de ejecución incorrecto. |
|---|
| 1153 | ogRaiseError $OG_ERR_FORMAT |
|---|
| 1154 | return $? |
|---|
| 1155 | esac |
|---|
| 1156 | |
|---|
| 1157 | # Montar el sistema de archivos. |
|---|
| 1158 | MNTDIR=$(ogMount $1 $2) || return $? |
|---|
| 1159 | |
|---|
| 1160 | ETC=$(ogGetPath $1 $2 /etc) |
|---|
| 1161 | |
|---|
| 1162 | if [ -d "$ETC" ]; then |
|---|
| 1163 | #cambio de nombre en hostname |
|---|
| 1164 | echo "$NAME" > $ETC/hostname |
|---|
| 1165 | #Opcion A para cambio de nombre en hosts |
|---|
| 1166 | #sed "/127.0.1.1/ c\127.0.1.1 \t $HOSTNAME" $ETC/hosts > /tmp/hosts && cp /tmp/hosts $ETC/ && rm /tmp/hosts |
|---|
| 1167 | #Opcion B componer fichero de hosts |
|---|
| 1168 | cat > $ETC/hosts <<EOF |
|---|
| 1169 | 127.0.0.1 localhost |
|---|
| 1170 | 127.0.1.1 $NAME |
|---|
| 1171 | |
|---|
| 1172 | # The following lines are desirable for IPv6 capable hosts |
|---|
| 1173 | ::1 ip6-localhost ip6-loopback |
|---|
| 1174 | fe00::0 ip6-localnet |
|---|
| 1175 | ff00::0 ip6-mcastprefix |
|---|
| 1176 | ff02::1 ip6-allnodes |
|---|
| 1177 | ff02::2 ip6-allrouters |
|---|
| 1178 | EOF |
|---|
| 1179 | fi |
|---|
| 1180 | } |
|---|
| 1181 | |
|---|
| 1182 | |
|---|
| 1183 | |
|---|
| 1184 | #/** |
|---|
| 1185 | # ogCleanLinuxDevices int_ndisk int_nfilesys |
|---|
| 1186 | #@brief Limpia los dispositivos del equipo de referencia. Interfaz de red ... |
|---|
| 1187 | #@param int_ndisk nº de orden del disco |
|---|
| 1188 | #@param int_nfilesys nº de orden del sistema de archivos |
|---|
| 1189 | #@return (nada) |
|---|
| 1190 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 1191 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
|---|
| 1192 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
|---|
| 1193 | #@version 1.0.5 - Primera versión para OpenGnSys. |
|---|
| 1194 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 1195 | #@date 2013-03-21 |
|---|
| 1196 | #@version 1.0.6b - Elimina fichero resume de hibernacion |
|---|
| 1197 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 1198 | #@date 2016-11-07 |
|---|
| 1199 | #*/ ## |
|---|
| 1200 | function ogCleanLinuxDevices () |
|---|
| 1201 | { |
|---|
| 1202 | # Variables locales. |
|---|
| 1203 | local MNTDIR |
|---|
| 1204 | |
|---|
| 1205 | # Si se solicita, mostrar ayuda. |
|---|
| 1206 | if [ "$*" == "help" ]; then |
|---|
| 1207 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_nfilesys" \ |
|---|
| 1208 | "$FUNCNAME 1 1" |
|---|
| 1209 | return |
|---|
| 1210 | fi |
|---|
| 1211 | # Error si no se reciben 2 parámetros. |
|---|
| 1212 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
|---|
| 1213 | |
|---|
| 1214 | # Montar el sistema de archivos. |
|---|
| 1215 | MNTDIR=$(ogMount $1 $2) || return $? |
|---|
| 1216 | |
|---|
| 1217 | # Eliminar fichero de configuración de udev para dispositivos fijos de red. |
|---|
| 1218 | [ -f ${MNTDIR}/etc/udev/rules.d/70-persistent-net.rules ] && rm -f ${MNTDIR}/etc/udev/rules.d/70-persistent-net.rules |
|---|
| 1219 | # Eliminar fichero resume (estado previo de hibernación) utilizado por el initrd scripts-premount |
|---|
| 1220 | [ -f ${MNTDIR}/etc/initramfs-tools/conf.d/resume ] && rm -f ${MNTDIR}/etc/initramfs-tools/conf.d/resume |
|---|
| 1221 | } |
|---|
| 1222 | |
|---|
| 1223 | #/** |
|---|
| 1224 | # ogGrubAddOgLive num_disk num_part [ timeout ] [ offline ] |
|---|
| 1225 | #@brief Crea entrada de menu grub para ogclient, tomando como paramentros del kernel los actuales del cliente. |
|---|
| 1226 | #@param 1 Numero de disco |
|---|
| 1227 | #@param 2 Numero de particion |
|---|
| 1228 | #@param 3 timeout Segundos de espera para iniciar el sistema operativo por defecto (opcional) |
|---|
| 1229 | #@param 4 offline configura el modo offline [offline|online] (opcional) |
|---|
| 1230 | #@return (nada) |
|---|
| 1231 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 1232 | #@exception OG_ERR_NOTFOUND No existe kernel o initrd en cache. |
|---|
| 1233 | #@exception OG_ERR_NOTFOUND No existe archivo de configuracion del grub. |
|---|
| 1234 | # /// FIXME: Solo para el grub instalado en MBR por Opengnsys, ampliar para más casos. |
|---|
| 1235 | #@version 1.0.6 - Prmera integración |
|---|
| 1236 | #@author |
|---|
| 1237 | #@date 2016-11-07 |
|---|
| 1238 | #@version 1.1.0 - Se renombra funcion para adaptacion al cambio de nombre de ogclient a ogLive. Soporta varios ogLives en la cache. Se añade el ogLive asignado al cliente. |
|---|
| 1239 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 1240 | #@date 2017-06-17 |
|---|
| 1241 | #*/ ## |
|---|
| 1242 | |
|---|
| 1243 | |
|---|
| 1244 | function ogGrubAddOgLive () |
|---|
| 1245 | { |
|---|
| 1246 | local TIMEOUT DIRMOUNT GRUBGFC PARTTABLETYPE NUMDISK NUMPART KERNEL STATUS NUMLINE MENUENTRY |
|---|
| 1247 | |
|---|
| 1248 | # Si se solicita, mostrar ayuda. |
|---|
| 1249 | if [ "$*" == "help" ]; then |
|---|
| 1250 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition [ time_out ] [ offline|online ] " \ |
|---|
| 1251 | "$FUNCNAME 1 1" \ |
|---|
| 1252 | "$FUNCNAME 1 6 15 offline" |
|---|
| 1253 | return |
|---|
| 1254 | fi |
|---|
| 1255 | |
|---|
| 1256 | # Error si no se reciben 2 parámetros. |
|---|
| 1257 | [ $# -lt 2 ] && return $(ogRaiseError session $OG_ERR_FORMAT "$MSG_FORMAT: $FUNCNAME num_disk num_part [ timeout ]"; echo $?) |
|---|
| 1258 | [[ "$3" =~ ^[0-9]*$ ]] && TIMEOUT="$3" |
|---|
| 1259 | |
|---|
| 1260 | # Error si no existe el kernel y el initrd en la cache. |
|---|
| 1261 | # Falta crear nuevo codigo de error. |
|---|
| 1262 | [ -r $OGCAC/boot/${oglivedir}/ogvmlinuz -a -r $OGCAC/boot/${oglivedir}/oginitrd.img ] || return $(ogRaiseError log session $OG_ERR_NOTFOUND "CACHE: ogvmlinuz, oginitrd.img" 1>&2; echo $?) |
|---|
| 1263 | |
|---|
| 1264 | # Archivo de configuracion del grub |
|---|
| 1265 | DIRMOUNT=$(ogMount $1 $2) |
|---|
| 1266 | GRUBGFC="$DIRMOUNT/boot/grubMBR/boot/grub/grub.cfg" |
|---|
| 1267 | |
|---|
| 1268 | # Error si no existe archivo del grub |
|---|
| 1269 | [ -r $GRUBGFC ] || return $(ogRaiseError log session $OG_ERR_NOTFOUND "$GRUBGFC" 1>&2; echo $?) |
|---|
| 1270 | |
|---|
| 1271 | # Si existe la entrada de opengnsys, se borra |
|---|
| 1272 | grep -q "menuentry Opengnsys" $GRUBGFC && sed -ie "/menuentry Opengnsys/,+6d" $GRUBGFC |
|---|
| 1273 | |
|---|
| 1274 | # Tipo de tabla de particiones |
|---|
| 1275 | PARTTABLETYPE=$(ogGetPartitionTableType $1 | tr [:upper:] [:lower:]) |
|---|
| 1276 | |
|---|
| 1277 | # Localizacion de la cache |
|---|
| 1278 | read NUMDISK NUMPART <<< $(ogFindCache) |
|---|
| 1279 | let NUMDISK=$NUMDISK-1 |
|---|
| 1280 | # kernel y sus opciones. Pasamos a modo usuario |
|---|
| 1281 | KERNEL="/boot/${oglivedir}/ogvmlinuz $(sed -e s/^.*linuz//g -e s/ogactiveadmin=[a-z]*//g /proc/cmdline)" |
|---|
| 1282 | |
|---|
| 1283 | # Configuracion offline si existe parametro |
|---|
| 1284 | echo "$@" |grep offline &>/dev/null && STATUS=offline |
|---|
| 1285 | echo "$@" |grep online &>/dev/null && STATUS=online |
|---|
| 1286 | [ -z "$STATUS" ] || KERNEL="$(echo $KERNEL | sed s/"ogprotocol=[a-z]* "/"ogprotocol=local "/g ) ogstatus=$STATUS" |
|---|
| 1287 | |
|---|
| 1288 | # Numero de línea de la primera entrada del grub. |
|---|
| 1289 | NUMLINE=$(grep -n -m 1 "^menuentry" $GRUBGFC|cut -d: -f1) |
|---|
| 1290 | # Texto de la entrada de opengnsys |
|---|
| 1291 | MENUENTRY="menuentry "OpenGnsys" --class opengnsys --class gnu --class os { \n \ |
|---|
| 1292 | \tinsmod part_$PARTTABLETYPE \n \ |
|---|
| 1293 | \tinsmod ext2 \n \ |
|---|
| 1294 | \tset root='(hd${NUMDISK},$PARTTABLETYPE${NUMPART})' \n \ |
|---|
| 1295 | \tlinux $KERNEL \n \ |
|---|
| 1296 | \tinitrd /boot/${oglivedir}/oginitrd.img \n \ |
|---|
| 1297 | }" |
|---|
| 1298 | |
|---|
| 1299 | |
|---|
| 1300 | # Insertamos la entrada de opengnsys antes de la primera entrada existente. |
|---|
| 1301 | sed -i "${NUMLINE}i\ $MENUENTRY" $GRUBGFC |
|---|
| 1302 | |
|---|
| 1303 | # Ponemos que la entrada por defecto sea la primera. |
|---|
| 1304 | sed -i s/"set.*default.*$"/"set default=\"0\""/g $GRUBGFC |
|---|
| 1305 | |
|---|
| 1306 | # Si me dan valor para timeout lo cambio en el grub. |
|---|
| 1307 | [ $TIMEOUT ] && sed -i s/timeout=.*$/timeout=$TIMEOUT/g $GRUBGFC |
|---|
| 1308 | } |
|---|
| 1309 | |
|---|
| 1310 | #/** |
|---|
| 1311 | # ogGrubHidePartitions num_disk num_part |
|---|
| 1312 | #@brief ver ogBootLoaderHidePartitions |
|---|
| 1313 | #@see ogBootLoaderHidePartitions |
|---|
| 1314 | #*/ ## |
|---|
| 1315 | function ogGrubHidePartitions () |
|---|
| 1316 | { |
|---|
| 1317 | # Si se solicita, mostrar ayuda. |
|---|
| 1318 | if [ "$*" == "help" ]; then |
|---|
| 1319 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ |
|---|
| 1320 | "$FUNCNAME 1 6" |
|---|
| 1321 | return |
|---|
| 1322 | fi |
|---|
| 1323 | ogBootLoaderHidePartitions $@ |
|---|
| 1324 | return $? |
|---|
| 1325 | } |
|---|
| 1326 | |
|---|
| 1327 | #/** |
|---|
| 1328 | # ogBurgHidePartitions num_disk num_part |
|---|
| 1329 | #@brief ver ogBootLoaderHidePartitions |
|---|
| 1330 | #@see ogBootLoaderHidePartitions |
|---|
| 1331 | #*/ ## |
|---|
| 1332 | function ogBurgHidePartitions () |
|---|
| 1333 | { |
|---|
| 1334 | # Si se solicita, mostrar ayuda. |
|---|
| 1335 | if [ "$*" == "help" ]; then |
|---|
| 1336 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ |
|---|
| 1337 | "$FUNCNAME 1 6" |
|---|
| 1338 | return |
|---|
| 1339 | fi |
|---|
| 1340 | ogBootLoaderHidePartitions $@ |
|---|
| 1341 | return $? |
|---|
| 1342 | } |
|---|
| 1343 | |
|---|
| 1344 | #/** |
|---|
| 1345 | # ogBootLoaderHidePartitions num_disk num_part |
|---|
| 1346 | #@brief Configura el grub/burg para que oculte las particiones de windows que no se esten iniciando. |
|---|
| 1347 | #@param 1 Numero de disco |
|---|
| 1348 | #@param 2 Numero de particion |
|---|
| 1349 | #@param 3 Numero de disco de la partición de datos (no ocultar) |
|---|
| 1350 | #@param 4 Numero de particion de datos (no ocultar) |
|---|
| 1351 | #@return (nada) |
|---|
| 1352 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 1353 | #@exception No existe archivo de configuracion del grub/burg. |
|---|
| 1354 | #@version 1.1 Se comprueban las particiones de Windows con blkid (y no con grub.cfg) |
|---|
| 1355 | #@author Irina Gomez, ETSII Universidad de Sevilla |
|---|
| 1356 | #@date 2015-11-17 |
|---|
| 1357 | #@version 1.1 Se generaliza la función para grub y burg |
|---|
| 1358 | #@author Irina Gomez, ETSII Universidad de Sevilla |
|---|
| 1359 | #@date 2017-10-20 |
|---|
| 1360 | #@version 1.1.1 Se incluye comentarios en codigo para autodocuemtnacion con Doxygen |
|---|
| 1361 | #@author Antonio J. Doblas Viso, EVLT Univesidad de Malaga. |
|---|
| 1362 | #@date 2018-07-05 |
|---|
| 1363 | #@version Se permite una partición de datos que no se ocultará. Soporta más de un disco. Compatible con grub.cfg creado por ogLive 5.0 |
|---|
| 1364 | #@author Irina Gomez, ETSII Universidad de Sevilla |
|---|
| 1365 | #@date 2019-08-26 |
|---|
| 1366 | #*/ |
|---|
| 1367 | |
|---|
| 1368 | function ogBootLoaderHidePartitions () |
|---|
| 1369 | { |
|---|
| 1370 | local FUNC DIRMOUNT GFCFILE PARTTABLETYPE WINENTRY WINPART ENTRY LINE PART PARTDATA TEXT PARTHIDDEN HIDDEN |
|---|
| 1371 | |
|---|
| 1372 | # Si se solicita, mostrar ayuda. |
|---|
| 1373 | if [ "$*" == "help" ]; then |
|---|
| 1374 | ogHelp "$FUNCNAME" "$MSG_SEE ogGrubHidePartitions ogBurgHidePartitions" |
|---|
| 1375 | return |
|---|
| 1376 | fi |
|---|
| 1377 | |
|---|
| 1378 | # Nombre de la función que llama a esta. |
|---|
| 1379 | FUNC="${FUNCNAME[@]:1}" |
|---|
| 1380 | FUNC="${FUNC%%\ *}" |
|---|
| 1381 | |
|---|
| 1382 | # Error si no se reciben 2 parámetros. |
|---|
| 1383 | [ $# -lt 2 ] && return $(ogRaiseError session $OG_ERR_FORMAT "$MSG_FORMAT: $FUNCNAME num_disk num_part [ num_disk_partdata num_partdata ]"; echo $?) |
|---|
| 1384 | # Si no existe $4 pongo un valor imposible para la partición de datos |
|---|
| 1385 | [ $# -eq 4 ] && PARTDATA=$(ogDiskToDev $3 $4) || PARTDATA=0 |
|---|
| 1386 | |
|---|
| 1387 | # Archivo de configuracion del grub |
|---|
| 1388 | DIRMOUNT=$(ogMount $1 $2) |
|---|
| 1389 | # La función debe ser llamanda desde ogGrubHidePartitionsCdc or ogBurgHidePartitionsCdc. |
|---|
| 1390 | case "$FUNC" in |
|---|
| 1391 | ogGrubHidePartitions) |
|---|
| 1392 | CFGFILE="$DIRMOUNT/boot/grubMBR/boot/grub/grub.cfg" |
|---|
| 1393 | ;; |
|---|
| 1394 | ogBurgHidePartitions) |
|---|
| 1395 | CFGFILE="$DIRMOUNT/boot/burg/burg.cfg" |
|---|
| 1396 | ;; |
|---|
| 1397 | *) |
|---|
| 1398 | ogRaiseError $OG_ERR_FORMAT "Use ogGrubHidePartitionsCdc or ogBurgHidePartitionsCdc." |
|---|
| 1399 | return $? |
|---|
| 1400 | ;; |
|---|
| 1401 | esac |
|---|
| 1402 | |
|---|
| 1403 | # Error si no existe archivo del grub |
|---|
| 1404 | [ -r $CFGFILE ] || return $(ogRaiseError log session $OG_ERR_NOTFOUND "$CFGFILE" 1>&2; echo $?) |
|---|
| 1405 | |
|---|
| 1406 | # Si solo hay una particion de Windows me salgo |
|---|
| 1407 | [ $(fdisk -l $(ogDiskToDev) | grep 'NTFS' |wc -l) -eq 1 ] && return 0 |
|---|
| 1408 | |
|---|
| 1409 | # Elimino llamadas a parttool, se han incluido en otras ejecuciones de esta funcion. |
|---|
| 1410 | sed -i '/parttool/d' $CFGFILE |
|---|
| 1411 | |
|---|
| 1412 | PARTTABLETYPE=$(ogGetPartitionTableType $1 | tr [:upper:] [:lower:]) |
|---|
| 1413 | |
|---|
| 1414 | # /* (comentario de bloque para Doxygen) |
|---|
| 1415 | # Entradas de Windows: numero de linea y particion. De mayor a menor. |
|---|
| 1416 | WINENTRY=$(awk '/menuentry.*Windows/ {gsub(/\)\"/, ""); gsub(/^.*dev/,""); print NR":/dev"$1} ' $CFGFILE | sed -e '1!G;h;$!d') |
|---|
| 1417 | #*/ (comentario para bloque Doxygen) |
|---|
| 1418 | # Particiones de Windows, pueden no estar en el grub. |
|---|
| 1419 | WINPART=$(fdisk -l $(ogDiskToDev)|awk '/NTFS/ {print $1}'|sed '1!G;h;$!d') |
|---|
| 1420 | |
|---|
| 1421 | |
|---|
| 1422 | # Modifico todas las entradas de Windows. |
|---|
| 1423 | for ENTRY in $WINENTRY; do |
|---|
| 1424 | LINE=${ENTRY%:*} |
|---|
| 1425 | PART=${ENTRY#*:} |
|---|
| 1426 | |
|---|
| 1427 | # En cada entrada, oculto o muestro cada particion. |
|---|
| 1428 | TEXT="" |
|---|
| 1429 | for PARTHIDDEN in $WINPART; do |
|---|
| 1430 | # Muestro la particion de la entrada actual y la de datos. |
|---|
| 1431 | [ "$PARTHIDDEN" == "$PART" -o "$PARTHIDDEN" == "$PARTDATA" ] && HIDDEN="-" || HIDDEN="+" |
|---|
| 1432 | read NUMDISK NUMPART <<< $(ogDevToDisk $PARTHIDDEN) |
|---|
| 1433 | |
|---|
| 1434 | TEXT="\tparttool (hd$((NUMDISK-1)),$PARTTABLETYPE$NUMPART) hidden$HIDDEN \n$TEXT" |
|---|
| 1435 | done |
|---|
| 1436 | |
|---|
| 1437 | sed -i "${LINE}a\ $TEXT" $CFGFILE |
|---|
| 1438 | done |
|---|
| 1439 | |
|---|
| 1440 | # Activamos la particion que se inicia en todas las entradas de windows. |
|---|
| 1441 | sed -i "/chainloader/i\\\tparttool \$\{root\} boot+" $CFGFILE |
|---|
| 1442 | } |
|---|
| 1443 | |
|---|
| 1444 | #/** |
|---|
| 1445 | # ogGrubDeleteEntry num_disk num_part num_disk_delete num_part_delete |
|---|
| 1446 | #@brief ver ogBootLoaderDeleteEntry |
|---|
| 1447 | #@see ogBootLoaderDeleteEntry |
|---|
| 1448 | #*/ |
|---|
| 1449 | function ogGrubDeleteEntry () |
|---|
| 1450 | { |
|---|
| 1451 | # Si se solicita, mostrar ayuda. |
|---|
| 1452 | if [ "$*" == "help" ]; then |
|---|
| 1453 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition int_disk_delete int_npartition_delete" \ |
|---|
| 1454 | "$FUNCNAME 1 6 2 1" |
|---|
| 1455 | return |
|---|
| 1456 | fi |
|---|
| 1457 | ogBootLoaderDeleteEntry $@ |
|---|
| 1458 | return $? |
|---|
| 1459 | } |
|---|
| 1460 | |
|---|
| 1461 | #/** |
|---|
| 1462 | # ogBurgDeleteEntry num_disk num_part num_disk_delete num_part_delete |
|---|
| 1463 | #@brief ver ogBootLoaderDeleteEntry |
|---|
| 1464 | #@see ogBootLoaderDeleteEntry |
|---|
| 1465 | #*/ |
|---|
| 1466 | function ogBurgDeleteEntry () |
|---|
| 1467 | { |
|---|
| 1468 | # Si se solicita, mostrar ayuda. |
|---|
| 1469 | if [ "$*" == "help" ]; then |
|---|
| 1470 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition int_disk_delete int_npartition_delete" \ |
|---|
| 1471 | "$FUNCNAME 1 6 2 1" |
|---|
| 1472 | return |
|---|
| 1473 | fi |
|---|
| 1474 | ogBootLoaderDeleteEntry $@ |
|---|
| 1475 | return $? |
|---|
| 1476 | } |
|---|
| 1477 | |
|---|
| 1478 | #/** |
|---|
| 1479 | # ogRefindDeleteEntry num_disk_delete num_part_delete |
|---|
| 1480 | #@brief ver ogBootLoaderDeleteEntry |
|---|
| 1481 | #@see ogBootLoaderDeleteEntry |
|---|
| 1482 | #*/ |
|---|
| 1483 | function ogRefindDeleteEntry () |
|---|
| 1484 | { |
|---|
| 1485 | local EFIDISK EFIPART |
|---|
| 1486 | # Si se solicita, mostrar ayuda. |
|---|
| 1487 | if [ "$*" == "help" ]; then |
|---|
| 1488 | ogHelp "$FUNCNAME" "$FUNCNAME int_disk_delete int_npartition_delete" \ |
|---|
| 1489 | "$FUNCNAME 2 1" |
|---|
| 1490 | return |
|---|
| 1491 | fi |
|---|
| 1492 | read EFIDISK EFIPART <<< $(ogGetEsp) |
|---|
| 1493 | ogBootLoaderDeleteEntry $EFIDISK $EFIPART $@ |
|---|
| 1494 | return $? |
|---|
| 1495 | } |
|---|
| 1496 | |
|---|
| 1497 | #/** |
|---|
| 1498 | # ogBootLoaderDeleteEntry num_disk num_part num_part_delete |
|---|
| 1499 | #@brief Borra en el grub las entradas para el inicio en una particion. |
|---|
| 1500 | #@param 1 Numero de disco donde esta el grub |
|---|
| 1501 | #@param 2 Numero de particion donde esta el grub |
|---|
| 1502 | #@param 3 Numero del disco del que borramos las entradas |
|---|
| 1503 | #@param 4 Numero de la particion de la que borramos las entradas |
|---|
| 1504 | #@note Tiene que ser llamada desde ogGrubDeleteEntry, ogBurgDeleteEntry o ogRefindDeleteEntry |
|---|
| 1505 | #@return (nada) |
|---|
| 1506 | #@exception OG_ERR_FORMAT Use ogGrubDeleteEntry or ogBurgDeleteEntry. |
|---|
| 1507 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 1508 | #@exception OG_ERR_NOTFOUND No existe archivo de configuracion del grub. |
|---|
| 1509 | #@version 1.1 Se generaliza la función para grub y burg |
|---|
| 1510 | #@author Irina Gomez, ETSII Universidad de Sevilla |
|---|
| 1511 | #@date 2017-10-20 |
|---|
| 1512 | #*/ ## |
|---|
| 1513 | |
|---|
| 1514 | function ogBootLoaderDeleteEntry () |
|---|
| 1515 | { |
|---|
| 1516 | local FUNC DIRMOUNT CFGFILE LABEL MENUENTRY DELETEENTRY ENDENTRY ENTRY |
|---|
| 1517 | |
|---|
| 1518 | # Si se solicita, mostrar ayuda. |
|---|
| 1519 | if [ "$*" == "help" ]; then |
|---|
| 1520 | ogHelp "$FUNCNAME" "$MSG_SEE ogBurgDeleteEntry, ogGrubDeleteEntry or ogRefindDeleteEntry" |
|---|
| 1521 | return |
|---|
| 1522 | fi |
|---|
| 1523 | |
|---|
| 1524 | # Si el número de parámetros menos que 4 nos salimos |
|---|
| 1525 | [ $# -lt 4 ] && return $(ogRaiseError session $OG_ERR_FORMAT "$MSG_FORMAT: $FUNCNAME num_disk num_part num_disk_delete num_part_delete"; echo $?) |
|---|
| 1526 | |
|---|
| 1527 | |
|---|
| 1528 | # Nombre de la función que llama a esta. |
|---|
| 1529 | FUNC="${FUNCNAME[@]:1}" |
|---|
| 1530 | FUNC="${FUNC%%\ *}" |
|---|
| 1531 | |
|---|
| 1532 | # Archivo de configuracion del grub |
|---|
| 1533 | DIRMOUNT=$(ogMount $1 $2) |
|---|
| 1534 | # La función debe ser llamanda desde ogGrubDeleteEntry, ogBurgDeleteEntry or ogRefindDeleteEntry. |
|---|
| 1535 | case "$FUNC" in |
|---|
| 1536 | ogGrubDeleteEntry) |
|---|
| 1537 | CFGFILE="$DIRMOUNT/boot/grubMBR/boot/grub/grub.cfg" |
|---|
| 1538 | ;; |
|---|
| 1539 | ogBurgDeleteEntry) |
|---|
| 1540 | CFGFILE="$DIRMOUNT/boot/burg/burg.cfg" |
|---|
| 1541 | ;; |
|---|
| 1542 | ogRefindDeleteEntry) |
|---|
| 1543 | CFGFILE="$DIRMOUNT/EFI/refind/refind.conf" |
|---|
| 1544 | ;; |
|---|
| 1545 | *) |
|---|
| 1546 | ogRaiseError $OG_ERR_FORMAT "Use ogGrubDeleteEntry, ogBurgDeleteEntry or ogRefindDeleteEntry." |
|---|
| 1547 | return $? |
|---|
| 1548 | ;; |
|---|
| 1549 | esac |
|---|
| 1550 | |
|---|
| 1551 | # Dispositivo |
|---|
| 1552 | if [ "$(basename $CFGFILE)" == "refind.conf" ]; then |
|---|
| 1553 | LABEL=$(printf "Part-%02d-%02d" $3 $4) |
|---|
| 1554 | else |
|---|
| 1555 | LABEL=$(ogDiskToDev $3 $4) |
|---|
| 1556 | fi |
|---|
| 1557 | |
|---|
| 1558 | # Error si no existe archivo de configuración |
|---|
| 1559 | [ -r $CFGFILE ] || ogRaiseError log session $OG_ERR_NOTFOUND "$CFGFILE" || return $? |
|---|
| 1560 | |
|---|
| 1561 | # Numero de linea de cada entrada. |
|---|
| 1562 | MENUENTRY="$(grep -n -e menuentry $CFGFILE| cut -d: -f1 | sed '1!G;h;$!d' )" |
|---|
| 1563 | |
|---|
| 1564 | # Entradas que hay que borrar. |
|---|
| 1565 | DELETEENTRY=$(grep -n menuentry.*$LABEL $CFGFILE| cut -d: -f1) |
|---|
| 1566 | |
|---|
| 1567 | # Si no hay entradas para borrar me salgo con aviso |
|---|
| 1568 | [ "$DELETEENTRY" != "" ] || ogRaiseError log session $OG_ERR_NOTFOUND "Menuentry $LABEL" || return $? |
|---|
| 1569 | |
|---|
| 1570 | # Recorremos el fichero del final hacia el principio. |
|---|
| 1571 | ENDENTRY="$(wc -l $CFGFILE|cut -d" " -f1)" |
|---|
| 1572 | for ENTRY in $MENUENTRY; do |
|---|
| 1573 | # Comprobamos si hay que borrar la entrada. |
|---|
| 1574 | if ogCheckStringInGroup $ENTRY "$DELETEENTRY" ; then |
|---|
| 1575 | let ENDENTRY=$ENDENTRY-1 |
|---|
| 1576 | sed -i -e $ENTRY,${ENDENTRY}d $CFGFILE |
|---|
| 1577 | fi |
|---|
| 1578 | |
|---|
| 1579 | # Guardamos el número de línea de la entrada, que sera el final de la siguiente. |
|---|
| 1580 | ENDENTRY=$ENTRY |
|---|
| 1581 | done |
|---|
| 1582 | } |
|---|
| 1583 | |
|---|
| 1584 | #/** |
|---|
| 1585 | # ogBurgInstallMbr int_disk_GRUBCFG int_partition_GRUBCFG |
|---|
| 1586 | #@param bolean_Check_Os_installed_and_Configure_2ndStage true | false[default] |
|---|
| 1587 | #@brief Instala y actualiza el gestor grub en el MBR del disco duro donde se encuentra el fichero grub.cfg. Admite sistemas Windows. |
|---|
| 1588 | #@param int_disk_SecondStage |
|---|
| 1589 | #@param int_part_SecondStage |
|---|
| 1590 | #@param bolean_Check_Os_installed_and_Configure_2ndStage true | false[default] |
|---|
| 1591 | #@return |
|---|
| 1592 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 1593 | #@exception OG_ERR_PARTITION Partición no soportada |
|---|
| 1594 | #@version 1.1.0 - Primeras pruebas instalando BURG. Codigo basado en el ogGrubInstallMBR. |
|---|
| 1595 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 1596 | #@date 2017-06-23 |
|---|
| 1597 | #@version 1.1.0 - Redirección del proceso de copiado de archivos y de la instalacion del binario |
|---|
| 1598 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 1599 | #@date 2018-01-21 |
|---|
| 1600 | #@version 1.1.0 - Refactorizar fichero de configuacion |
|---|
| 1601 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 1602 | #@date 2018-01-24 |
|---|
| 1603 | #@version 1.1.1 - Se incluye comentarios en codigo para autodocuemtnacion con Doxygen |
|---|
| 1604 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 1605 | #@date 2018-07-05 |
|---|
| 1606 | #*/ ## |
|---|
| 1607 | |
|---|
| 1608 | function ogBurgInstallMbr () |
|---|
| 1609 | { |
|---|
| 1610 | |
|---|
| 1611 | # Variables locales. |
|---|
| 1612 | local PART DISK FIRSTAGE SECONSTAGE PREFIXSECONDSTAGE CHECKOS KERNELPARAM BACKUPNAME FILECFG |
|---|
| 1613 | |
|---|
| 1614 | # Si se solicita, mostrar ayuda. |
|---|
| 1615 | if [ "$*" == "help" ]; then |
|---|
| 1616 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage bolean_Configure_2ndStage \"param param \" " \ |
|---|
| 1617 | "$FUNCNAME 1 1 FALSE " \ |
|---|
| 1618 | "$FUNCNAME 1 1 TRUE \"nomodeset irqpoll pci=noacpi quiet splash \" " |
|---|
| 1619 | return |
|---|
| 1620 | fi |
|---|
| 1621 | |
|---|
| 1622 | # Error si no se reciben 2 parametros. |
|---|
| 1623 | [ $# -ge 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) |
|---|
| 1624 | |
|---|
| 1625 | |
|---|
| 1626 | DISK=$1; PART=$2; |
|---|
| 1627 | CHECKOS=${3:-"FALSE"} |
|---|
| 1628 | KERNELPARAM=$4 |
|---|
| 1629 | BACKUPNAME=".backup.og" |
|---|
| 1630 | |
|---|
| 1631 | #Error si no es linux. |
|---|
| 1632 | ogCheckStringInGroup $(ogGetFsType $DISK $PART) "CACHE EXT4 EXT3 EXT2" || return $(ogRaiseError $OG_ERR_PARTITION "burg no soporta esta particion"; echo $?) |
|---|
| 1633 | |
|---|
| 1634 | |
|---|
| 1635 | #La primera etapa del grub se fija en el primer disco duro |
|---|
| 1636 | FIRSTSTAGE=$(ogDiskToDev 1) |
|---|
| 1637 | |
|---|
| 1638 | #localizar disco segunda etapa del grub |
|---|
| 1639 | SECONDSTAGE=$(ogMount $DISK $PART) |
|---|
| 1640 | |
|---|
| 1641 | # prepara el directorio principal de la segunda etapa (y copia los binarios) |
|---|
| 1642 | [ -d ${SECONDSTAGE}/boot/burg/ ] || mkdir -p ${SECONDSTAGE}/boot/burg/; cp -prv /boot/burg/* ${SECONDSTAGE}/boot/burg/ 2>&1>/dev/null; cp -prv $OGLIB/burg/* ${SECONDSTAGE}/boot/burg/ 2>&1>/dev/null; #*/ ## (comentario Dogygen) #*/ ## (comentario Dogygen) |
|---|
| 1643 | |
|---|
| 1644 | #Copiamos el tema |
|---|
| 1645 | mkdir -p ${SECONDSTAGE}/boot/burg/themes/OpenGnsys |
|---|
| 1646 | cp -prv "$OGLIB/burg/themes" "${SECONDSTAGE}/boot/burg/" 2>&1>/dev/null |
|---|
| 1647 | |
|---|
| 1648 | #Localizar directorio segunda etapa del grub |
|---|
| 1649 | #PREFIXSECONDSTAGE="/boot/burg/" |
|---|
| 1650 | |
|---|
| 1651 | # Si Reconfigurar segunda etapa (grub.cfg) == FALSE |
|---|
| 1652 | if [ -f ${SECONDSTAGE}/boot/burg/burg.cfg -o -f ${SECONDSTAGE}/boot/burg/burg.cfg$BACKUPNAME ] |
|---|
| 1653 | then |
|---|
| 1654 | if [ "$CHECKOS" == "false" -o "$CHECKOS" == "FALSE" ] |
|---|
| 1655 | then |
|---|
| 1656 | burg-install --force --root-directory=${SECONDSTAGE} $FIRSTSTAGE 2>&1>/dev/null |
|---|
| 1657 | return $? |
|---|
| 1658 | fi |
|---|
| 1659 | fi |
|---|
| 1660 | |
|---|
| 1661 | # SI Reconfigurar segunda etapa (burg.cfg) == TRUE |
|---|
| 1662 | |
|---|
| 1663 | #llamada a updateBootCache para que aloje la primera fase del ogLive |
|---|
| 1664 | updateBootCache |
|---|
| 1665 | |
|---|
| 1666 | #Configur la sintaxis grub para evitar menus de "recovery" en el OGLive |
|---|
| 1667 | echo "GRUB_DISABLE_RECOVERY=\"true\"" >> /etc/default/grub |
|---|
| 1668 | echo "GRUB_DISABLE_LINUX_UUID=\"true\"" >> /etc/default/grub |
|---|
| 1669 | |
|---|
| 1670 | |
|---|
| 1671 | #Preparar configuración segunda etapa: crear ubicacion |
|---|
| 1672 | mkdir -p ${SECONDSTAGE}${PREFIXSECONDSTAGE}/boot/burg/ |
|---|
| 1673 | |
|---|
| 1674 | #Preparar configuración segunda etapa: crear cabecera del fichero |
|---|
| 1675 | #/etc/burg.d/00_header > ${SECONDSTAGE}${PREFIXSECONDSTAGE}/boot/burg/burg.cfg |
|---|
| 1676 | |
|---|
| 1677 | FILECFG=${SECONDSTAGE}${PREFIXSECONDSTAGE}/boot/burg/burg.cfg |
|---|
| 1678 | |
|---|
| 1679 | #/* ## (comentario Dogygen) |
|---|
| 1680 | cat > "$FILECFG" << EOF |
|---|
| 1681 | |
|---|
| 1682 | set theme_name=OpenGnsys |
|---|
| 1683 | set gfxmode=1024x768 |
|---|
| 1684 | |
|---|
| 1685 | |
|---|
| 1686 | set locale_dir=(\$root)/boot/burg/locale |
|---|
| 1687 | |
|---|
| 1688 | set default=0 |
|---|
| 1689 | set timeout=25 |
|---|
| 1690 | set lang=es |
|---|
| 1691 | |
|---|
| 1692 | |
|---|
| 1693 | insmod ext2 |
|---|
| 1694 | insmod gettext |
|---|
| 1695 | |
|---|
| 1696 | |
|---|
| 1697 | |
|---|
| 1698 | |
|---|
| 1699 | if [ -s \$prefix/burgenv ]; then |
|---|
| 1700 | load_env |
|---|
| 1701 | fi |
|---|
| 1702 | |
|---|
| 1703 | |
|---|
| 1704 | |
|---|
| 1705 | if [ \${prev_saved_entry} ]; then |
|---|
| 1706 | set saved_entry=\${prev_saved_entry} |
|---|
| 1707 | save_env saved_entry |
|---|
| 1708 | set prev_saved_entry= |
|---|
| 1709 | save_env prev_saved_entry |
|---|
| 1710 | set boot_once=true |
|---|
| 1711 | fi |
|---|
| 1712 | |
|---|
| 1713 | function savedefault { |
|---|
| 1714 | if [ -z \${boot_once} ]; then |
|---|
| 1715 | saved_entry=\${chosen} |
|---|
| 1716 | save_env saved_entry |
|---|
| 1717 | fi |
|---|
| 1718 | } |
|---|
| 1719 | function select_menu { |
|---|
| 1720 | if menu_popup -t template_popup theme_menu ; then |
|---|
| 1721 | free_config template_popup template_subitem menu class screen |
|---|
| 1722 | load_config \${prefix}/themes/\${theme_name}/theme \${prefix}/themes/custom/theme_\${theme_name} |
|---|
| 1723 | save_env theme_name |
|---|
| 1724 | menu_refresh |
|---|
| 1725 | fi |
|---|
| 1726 | } |
|---|
| 1727 | |
|---|
| 1728 | function toggle_fold { |
|---|
| 1729 | if test -z $theme_fold ; then |
|---|
| 1730 | set theme_fold=1 |
|---|
| 1731 | else |
|---|
| 1732 | set theme_fold= |
|---|
| 1733 | fi |
|---|
| 1734 | save_env theme_fold |
|---|
| 1735 | menu_refresh |
|---|
| 1736 | } |
|---|
| 1737 | function select_resolution { |
|---|
| 1738 | if menu_popup -t template_popup resolution_menu ; then |
|---|
| 1739 | menu_reload_mode |
|---|
| 1740 | save_env gfxmode |
|---|
| 1741 | fi |
|---|
| 1742 | } |
|---|
| 1743 | |
|---|
| 1744 | |
|---|
| 1745 | if test -f \${prefix}/themes/\${theme_name}/theme ; then |
|---|
| 1746 | insmod coreui |
|---|
| 1747 | menu_region.text |
|---|
| 1748 | load_string '+theme_menu { -OpenGnsys { command="set theme_name=OpenGnsys" }}' |
|---|
| 1749 | load_config \${prefix}/themes/conf.d/10_hotkey |
|---|
| 1750 | load_config \${prefix}/themes/\${theme_name}/theme \${prefix}/themes/custom/theme_\${theme_name} |
|---|
| 1751 | insmod vbe |
|---|
| 1752 | insmod png |
|---|
| 1753 | insmod jpeg |
|---|
| 1754 | set gfxfont="Unifont Regular 16" |
|---|
| 1755 | menu_region.gfx |
|---|
| 1756 | vmenu resolution_menu |
|---|
| 1757 | controller.ext |
|---|
| 1758 | fi |
|---|
| 1759 | |
|---|
| 1760 | |
|---|
| 1761 | EOF |
|---|
| 1762 | #*/ ## (comentario Dogygen) |
|---|
| 1763 | |
|---|
| 1764 | #Preparar configuración segunda etapa: crear entrada del sistema operativo |
|---|
| 1765 | grubSyntax "$KERNELPARAM" >> "$FILECFG" |
|---|
| 1766 | |
|---|
| 1767 | #Instalar el burg |
|---|
| 1768 | burg-install --force --root-directory=${SECONDSTAGE} $FIRSTSTAGE 2>&1>/dev/null |
|---|
| 1769 | } |
|---|
| 1770 | |
|---|
| 1771 | #/** |
|---|
| 1772 | # ogGrubDefaultEntry int_disk_GRUGCFG int_partition_GRUBCFG int_disk_default_entry int_npartition_default_entry |
|---|
| 1773 | #@brief ver ogBootLoaderDefaultEntry |
|---|
| 1774 | #@see ogBootLoaderDefaultEntry |
|---|
| 1775 | #*/ ## |
|---|
| 1776 | function ogGrubDefaultEntry () |
|---|
| 1777 | { |
|---|
| 1778 | # Si se solicita, mostrar ayuda. |
|---|
| 1779 | if [ "$*" == "help" ]; then |
|---|
| 1780 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition int_disk_default_entry int_npartition_default_entry" \ |
|---|
| 1781 | "$FUNCNAME 1 6 1 1" |
|---|
| 1782 | return |
|---|
| 1783 | fi |
|---|
| 1784 | ogBootLoaderDefaultEntry $@ |
|---|
| 1785 | return $? |
|---|
| 1786 | } |
|---|
| 1787 | |
|---|
| 1788 | #/** |
|---|
| 1789 | # ogBurgDefaultEntry int_disk_BURGCFG int_partition_BURGCFG int_disk_default_entry int_npartition_default_entry |
|---|
| 1790 | #@brief ver ogBootLoaderDefaultEntry |
|---|
| 1791 | #@see ogBootLoaderDefaultEntry |
|---|
| 1792 | #*/ ## |
|---|
| 1793 | function ogBurgDefaultEntry () |
|---|
| 1794 | { |
|---|
| 1795 | # Si se solicita, mostrar ayuda. |
|---|
| 1796 | if [ "$*" == "help" ]; then |
|---|
| 1797 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition int_disk_default_entry int_npartition_default_entry" \ |
|---|
| 1798 | "$FUNCNAME 1 6 1 1" |
|---|
| 1799 | return |
|---|
| 1800 | fi |
|---|
| 1801 | ogBootLoaderDefaultEntry $@ |
|---|
| 1802 | return $? |
|---|
| 1803 | } |
|---|
| 1804 | |
|---|
| 1805 | |
|---|
| 1806 | #/** |
|---|
| 1807 | # ogRefindDefaultEntry int_disk_default_entry int_npartition_default_entry |
|---|
| 1808 | #@brief ver ogBootLoaderDefaultEntry |
|---|
| 1809 | #@see ogBootLoaderDefaultEntry |
|---|
| 1810 | #*/ ## |
|---|
| 1811 | function ogRefindDefaultEntry () |
|---|
| 1812 | { |
|---|
| 1813 | local EFIDISK EFIPART |
|---|
| 1814 | # Si se solicita, mostrar ayuda. |
|---|
| 1815 | if [ "$*" == "help" ]; then |
|---|
| 1816 | ogHelp "$FUNCNAME" "$FUNCNAME int_disk_default_entry int_npartition_default_entry" \ |
|---|
| 1817 | "$FUNCNAME 1 1" |
|---|
| 1818 | return |
|---|
| 1819 | fi |
|---|
| 1820 | |
|---|
| 1821 | read EFIDISK EFIPART <<< $(ogGetEsp) |
|---|
| 1822 | ogBootLoaderDefaultEntry $EFIDISK $EFIPART $@ |
|---|
| 1823 | return $? |
|---|
| 1824 | } |
|---|
| 1825 | |
|---|
| 1826 | #/** |
|---|
| 1827 | # ogBootLoaderDefaultEntry int_disk_CFG int_partition_CFG int_disk_default_entry int_npartition_default_entry |
|---|
| 1828 | #@brief Configura la entrada por defecto de Burg |
|---|
| 1829 | #@param int_disk_SecondStage |
|---|
| 1830 | #@param int_part_SecondStage |
|---|
| 1831 | #@param int_disk_default_entry |
|---|
| 1832 | #@param int_part_default_entry |
|---|
| 1833 | #@return |
|---|
| 1834 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 1835 | #@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount). |
|---|
| 1836 | #@exception OG_ERR_OUTOFLIMIT Param $3 no es entero. |
|---|
| 1837 | #@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: burg.cfg. |
|---|
| 1838 | #@version 1.1.0 - Define la entrada por defecto del Burg |
|---|
| 1839 | #@author Irina Gomez, ETSII Universidad de Sevilla |
|---|
| 1840 | #@date 2017-08-09 |
|---|
| 1841 | #@version 1.1 Se generaliza la función para grub y burg |
|---|
| 1842 | #@author Irina Gomez, ETSII Universidad de Sevilla |
|---|
| 1843 | #@date 2018-01-04 |
|---|
| 1844 | #*/ ## |
|---|
| 1845 | function ogBootLoaderDefaultEntry () |
|---|
| 1846 | { |
|---|
| 1847 | |
|---|
| 1848 | # Variables locales. |
|---|
| 1849 | local PART FUNC DIRMOUNT LABEL CFGFILE DEFAULTENTRY MENUENTRY MSG |
|---|
| 1850 | |
|---|
| 1851 | # Si se solicita, mostrar ayuda. |
|---|
| 1852 | if [ "$*" == "help" ]; then |
|---|
| 1853 | ogHelp "$FUNCNAME" "$MSG_SEE ogGrubDefaultEntry, ogBurgDefaultEntry or ogRefindDefaultEntry." |
|---|
| 1854 | return |
|---|
| 1855 | fi |
|---|
| 1856 | |
|---|
| 1857 | # Nombre de la función que llama a esta. |
|---|
| 1858 | FUNC="${FUNCNAME[@]:1}" |
|---|
| 1859 | FUNC="${FUNC%%\ *}" |
|---|
| 1860 | |
|---|
| 1861 | # Error si no se reciben 3 parametros. |
|---|
| 1862 | [ $# -eq 4 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage int_disk_default_entry int_partitions_default_entry" || return $? |
|---|
| 1863 | |
|---|
| 1864 | # Error si no puede montar sistema de archivos. |
|---|
| 1865 | DIRMOUNT=$(ogMount $1 $2) || return $? |
|---|
| 1866 | |
|---|
| 1867 | # Comprobamos que exista fichero de configuración |
|---|
| 1868 | # La función debe ser llamanda desde ogGrubDefaultEntry, ogBurgDefaultEntry or ogRefindDefaultEntry. |
|---|
| 1869 | case "$FUNC" in |
|---|
| 1870 | ogGrubDefaultEntry) |
|---|
| 1871 | CFGFILE="$DIRMOUNT/boot/grubMBR/boot/grub/grub.cfg" |
|---|
| 1872 | ;; |
|---|
| 1873 | ogBurgDefaultEntry) |
|---|
| 1874 | CFGFILE="$DIRMOUNT/boot/burg/burg.cfg" |
|---|
| 1875 | ;; |
|---|
| 1876 | ogRefindDefaultEntry) |
|---|
| 1877 | CFGFILE="$DIRMOUNT/EFI/refind/refind.conf" |
|---|
| 1878 | ;; |
|---|
| 1879 | *) |
|---|
| 1880 | ogRaiseError $OG_ERR_FORMAT "Use ogGrubDefaultEntry, ogBurgDefaultEntry or ogRefindDefaultEntry." |
|---|
| 1881 | return $? |
|---|
| 1882 | ;; |
|---|
| 1883 | esac |
|---|
| 1884 | |
|---|
| 1885 | # Error si no existe archivo de configuración |
|---|
| 1886 | [ -r $CFGFILE ] || ogRaiseError $OG_ERR_NOTFOUND "$CFGFILE" || return $? |
|---|
| 1887 | |
|---|
| 1888 | # Dispositivo |
|---|
| 1889 | if [ "$(basename $CFGFILE)" == "refind.conf" ]; then |
|---|
| 1890 | LABEL=$(printf "Part-%02d-%02d" $3 $4) |
|---|
| 1891 | else |
|---|
| 1892 | LABEL=$(ogDiskToDev $3 $4) |
|---|
| 1893 | fi |
|---|
| 1894 | |
|---|
| 1895 | # Número de línea de la entrada por defecto en CFGFILE (primera de la partición). |
|---|
| 1896 | DEFAULTENTRY=$(grep -n -m 1 menuentry.*$LABEL $CFGFILE| cut -d: -f1) |
|---|
| 1897 | |
|---|
| 1898 | # Si no hay entradas para borrar me salgo con aviso |
|---|
| 1899 | [ "$DEFAULTENTRY" != "" ] || ogRaiseError session log $OG_ERR_NOTFOUND "No menuentry $LABEL" || return $? |
|---|
| 1900 | |
|---|
| 1901 | # Número de la de linea por defecto en el menú de usuario |
|---|
| 1902 | MENUENTRY="$(grep -n -e menuentry $CFGFILE| cut -d: -f1 | grep -n $DEFAULTENTRY |cut -d: -f1)" |
|---|
| 1903 | |
|---|
| 1904 | if [ "$(basename $CFGFILE)" == "refind.conf" ]; then |
|---|
| 1905 | sed -i /default_selection.*$/d $CFGFILE |
|---|
| 1906 | sed -i "1 i\default_selection $MENUENTRY" $CFGFILE |
|---|
| 1907 | else |
|---|
| 1908 | # En grub y burg las líneas empiezan a contar desde cero |
|---|
| 1909 | let MENUENTRY=$MENUENTRY-1 |
|---|
| 1910 | sed --regexp-extended -i s/"set default=\"?[0-9]*\"?"/"set default=\"$MENUENTRY\""/g $CFGFILE |
|---|
| 1911 | fi |
|---|
| 1912 | MSG="MSG_HELP_$FUNC" |
|---|
| 1913 | echo "${!MSG%%\.}: $@" |
|---|
| 1914 | } |
|---|
| 1915 | |
|---|
| 1916 | #/** |
|---|
| 1917 | # ogGrubOgliveDefaultEntry num_disk num_part |
|---|
| 1918 | #@brief ver ogBootLoaderOgliveDefaultEntry |
|---|
| 1919 | #@see ogBootLoaderOgliveDefaultEntry |
|---|
| 1920 | #*/ ## |
|---|
| 1921 | function ogGrubOgliveDefaultEntry () |
|---|
| 1922 | { |
|---|
| 1923 | # Si se solicita, mostrar ayuda. |
|---|
| 1924 | if [ "$*" == "help" ]; then |
|---|
| 1925 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage" \ |
|---|
| 1926 | "$FUNCNAME 1 6" |
|---|
| 1927 | return |
|---|
| 1928 | fi |
|---|
| 1929 | ogBootLoaderOgliveDefaultEntry $@ |
|---|
| 1930 | return $? |
|---|
| 1931 | } |
|---|
| 1932 | |
|---|
| 1933 | #/** |
|---|
| 1934 | # ogBurgOgliveDefaultEntry num_disk num_part |
|---|
| 1935 | #@brief ver ogBootLoaderOgliveDefaultEntry |
|---|
| 1936 | #@see ogBootLoaderOgliveDefaultEntry |
|---|
| 1937 | #*/ ## |
|---|
| 1938 | function ogBurgOgliveDefaultEntry () |
|---|
| 1939 | { |
|---|
| 1940 | # Si se solicita, mostrar ayuda. |
|---|
| 1941 | if [ "$*" == "help" ]; then |
|---|
| 1942 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage" \ |
|---|
| 1943 | "$FUNCNAME 1 6" |
|---|
| 1944 | return |
|---|
| 1945 | fi |
|---|
| 1946 | ogBootLoaderOgliveDefaultEntry $@ |
|---|
| 1947 | return $? |
|---|
| 1948 | } |
|---|
| 1949 | |
|---|
| 1950 | |
|---|
| 1951 | #/** |
|---|
| 1952 | # ogRefindOgliveDefaultEntry |
|---|
| 1953 | #@brief ver ogBootLoaderOgliveDefaultEntry |
|---|
| 1954 | #@see ogBootLoaderOgliveDefaultEntry |
|---|
| 1955 | #*/ ## |
|---|
| 1956 | function ogRefindOgliveDefaultEntry () |
|---|
| 1957 | { |
|---|
| 1958 | local EFIDISK EFIPART |
|---|
| 1959 | # Si se solicita, mostrar ayuda. |
|---|
| 1960 | if [ "$*" == "help" ]; then |
|---|
| 1961 | ogHelp "$FUNCNAME" "$FUNCNAME" \ |
|---|
| 1962 | "$FUNCNAME" |
|---|
| 1963 | return |
|---|
| 1964 | fi |
|---|
| 1965 | |
|---|
| 1966 | read EFIDISK EFIPART <<< $(ogGetEsp) |
|---|
| 1967 | ogBootLoaderOgliveDefaultEntry $EFIDISK $EFIPART |
|---|
| 1968 | return $? |
|---|
| 1969 | } |
|---|
| 1970 | |
|---|
| 1971 | |
|---|
| 1972 | #/** |
|---|
| 1973 | # ogBootLoaderOgliveDefaultEntry |
|---|
| 1974 | #@brief Configura la entrada de ogLive como la entrada por defecto de Burg. |
|---|
| 1975 | #@param int_disk_SecondStage |
|---|
| 1976 | #@param int_part_SecondStage |
|---|
| 1977 | #@return |
|---|
| 1978 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 1979 | #@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount). |
|---|
| 1980 | #@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: burg.cfg. |
|---|
| 1981 | #@exception OG_ERR_NOTFOUND Entrada de OgLive no encontrada en burg.cfg. |
|---|
| 1982 | #@version 1.1.0 - Primeras pruebas con Burg |
|---|
| 1983 | #@author Irina Gomez, ETSII Universidad de Sevilla |
|---|
| 1984 | #@date 2017-08-09 |
|---|
| 1985 | #@version 1.1 Se generaliza la función para grub y burg |
|---|
| 1986 | #@author Irina Gomez, ETSII Universidad de Sevilla |
|---|
| 1987 | #@date 2018-01-04 |
|---|
| 1988 | #*/ ## |
|---|
| 1989 | function ogBootLoaderOgliveDefaultEntry () |
|---|
| 1990 | { |
|---|
| 1991 | |
|---|
| 1992 | # Variables locales. |
|---|
| 1993 | local FUNC PART CFGFILE NUMENTRY MSG |
|---|
| 1994 | |
|---|
| 1995 | # Si se solicita, mostrar ayuda. |
|---|
| 1996 | if [ "$*" == "help" ]; then |
|---|
| 1997 | ogHelp "$FUNCNAME" "$MSG_SEE ogGrubOgliveDefaultEntry, ogBurgOgliveDefaultEntry or ogRefindOgliveDefaultEntry" \ |
|---|
| 1998 | return |
|---|
| 1999 | fi |
|---|
| 2000 | |
|---|
| 2001 | # Nombre de la función que llama a esta. |
|---|
| 2002 | FUNC="${FUNCNAME[@]:1}" |
|---|
| 2003 | FUNC="${FUNC%%\ *}" |
|---|
| 2004 | |
|---|
| 2005 | # Error si no se reciben 2 parametros. |
|---|
| 2006 | [ $# -eq 2 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage" || return $? |
|---|
| 2007 | |
|---|
| 2008 | # Error si no puede montar sistema de archivos. |
|---|
| 2009 | PART=$(ogMount $1 $2) || return $? |
|---|
| 2010 | # La función debe ser llamanda desde ogGrubOgliveDefaultEntry, ogBurgOgliveDefaultEntry or ogRefindOgliveDefaultEntry. |
|---|
| 2011 | case "$FUNC" in |
|---|
| 2012 | ogGrubOgliveDefaultEntry) |
|---|
| 2013 | CFGFILE="$PART/boot/grubMBR/boot/grub/grub.cfg" |
|---|
| 2014 | ;; |
|---|
| 2015 | ogBurgOgliveDefaultEntry) |
|---|
| 2016 | CFGFILE="$PART/boot/burg/burg.cfg" |
|---|
| 2017 | ;; |
|---|
| 2018 | ogRefindOgliveDefaultEntry) |
|---|
| 2019 | CFGFILE="$PART/EFI/refind/refind.conf" |
|---|
| 2020 | ;; |
|---|
| 2021 | *) |
|---|
| 2022 | ogRaiseError $OG_ERR_FORMAT "Use ogGrubOgliveDefaultEntry, ogBurgOgliveDefaultEntry or ogRefindOgliveDefaultEntry." |
|---|
| 2023 | return $? |
|---|
| 2024 | ;; |
|---|
| 2025 | esac |
|---|
| 2026 | |
|---|
| 2027 | # Comprobamos que exista fichero de configuración |
|---|
| 2028 | [ -f $CFGFILE ] || ogRaiseError $OG_ERR_NOTFOUND "$CFGFILE" || return $? |
|---|
| 2029 | |
|---|
| 2030 | # Detectamos cual es la entrada de ogLive |
|---|
| 2031 | NUMENTRY=$(grep ^menuentry $CFGFILE| grep -n "OpenGnsys Live"|cut -d: -f1) |
|---|
| 2032 | |
|---|
| 2033 | # Si no existe entrada de ogLive nos salimos |
|---|
| 2034 | [ -z "$NUMENTRY" ] && (ogRaiseError $OG_ERR_NOTFOUND "menuentry OpenGnsys Live in $CFGFILE" || return $?) |
|---|
| 2035 | |
|---|
| 2036 | if [ "$(basename $CFGFILE)" == "refind.conf" ]; then |
|---|
| 2037 | sed -i /default_selection.*$/d $CFGFILE |
|---|
| 2038 | |
|---|
| 2039 | sed -i "1 i\default_selection $NUMENTRY" $CFGFILE |
|---|
| 2040 | else |
|---|
| 2041 | let NUMENTRY=$NUMENTRY-1 |
|---|
| 2042 | sed --regexp-extended -i s/"set default=\"?[0-9]+\"?"/"set default=\"$NUMENTRY\""/g $CFGFILE |
|---|
| 2043 | fi |
|---|
| 2044 | |
|---|
| 2045 | MSG="MSG_HELP_$FUNC" |
|---|
| 2046 | echo "${!MSG%%\.}: $@" |
|---|
| 2047 | } |
|---|
| 2048 | |
|---|
| 2049 | |
|---|
| 2050 | #/** |
|---|
| 2051 | # ogGrubSetTheme num_disk num_part str_theme |
|---|
| 2052 | #@brief ver ogBootLoaderSetTheme |
|---|
| 2053 | #@see ogBootLoaderSetTheme |
|---|
| 2054 | #*/ ## |
|---|
| 2055 | function ogGrubSetTheme () |
|---|
| 2056 | { |
|---|
| 2057 | # Si se solicita, mostrar ayuda. |
|---|
| 2058 | if [ "$*" == "help" ]; then |
|---|
| 2059 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage str_themeName" \ |
|---|
| 2060 | "$FUNCNAME 1 4 ThemeBasic"\ |
|---|
| 2061 | "$FUNCNAME \$(ogFindCache) ThemeBasic" |
|---|
| 2062 | return |
|---|
| 2063 | fi |
|---|
| 2064 | ogBootLoaderSetTheme $@ |
|---|
| 2065 | return $? |
|---|
| 2066 | } |
|---|
| 2067 | |
|---|
| 2068 | #/** |
|---|
| 2069 | # ogBurgSetTheme num_disk num_part str_theme |
|---|
| 2070 | #@brief ver ogBootLoaderSetTheme |
|---|
| 2071 | #@see ogBootLoaderSetTheme |
|---|
| 2072 | #*/ ## |
|---|
| 2073 | function ogBurgSetTheme () |
|---|
| 2074 | { |
|---|
| 2075 | # Si se solicita, mostrar ayuda. |
|---|
| 2076 | if [ "$*" == "help" ]; then |
|---|
| 2077 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage str_themeName" \ |
|---|
| 2078 | "$FUNCNAME 1 4 ThemeBasic" \ |
|---|
| 2079 | "$FUNCNAME \$(ogFindCache) ThemeBasic" |
|---|
| 2080 | echo "Temas disponibles:\ $(ls $OGCAC/boot/burg/themes/)" |
|---|
| 2081 | |
|---|
| 2082 | return |
|---|
| 2083 | fi |
|---|
| 2084 | ogBootLoaderSetTheme $@ |
|---|
| 2085 | return $? |
|---|
| 2086 | } |
|---|
| 2087 | |
|---|
| 2088 | |
|---|
| 2089 | #/** |
|---|
| 2090 | # ogRefindSetTheme str_theme |
|---|
| 2091 | #@brief ver ogBootLoaderSetTheme |
|---|
| 2092 | #@see ogBootLoaderSetTheme |
|---|
| 2093 | #*/ ## |
|---|
| 2094 | function ogRefindSetTheme () { |
|---|
| 2095 | local PART DIRTHEME CFGFILE |
|---|
| 2096 | # Si se solicita, mostrar ayuda. |
|---|
| 2097 | if [ "$*" == "help" ]; then |
|---|
| 2098 | ogHelp "$FUNCNAME" "$FUNCNAME str_themeName" \ |
|---|
| 2099 | "$FUNCNAME ThemeBasic" |
|---|
| 2100 | echo -e "\nThemes in $OGLIB/refind:\n$(ls $OGLIB/refind/themes/ 2>/dev/null)" |
|---|
| 2101 | |
|---|
| 2102 | return |
|---|
| 2103 | fi |
|---|
| 2104 | |
|---|
| 2105 | # Detectamos partición ESP |
|---|
| 2106 | read EFIDISK EFIPART <<< $(ogGetEsp) |
|---|
| 2107 | |
|---|
| 2108 | PART=$(ogMount $EFIDISK $EFIPART) || return $? |
|---|
| 2109 | DIRTHEME="$PART/EFI/refind/themes" |
|---|
| 2110 | CFGFILE="$PART/EFI/refind/refind.conf" |
|---|
| 2111 | |
|---|
| 2112 | # Para utilizar ogBootLoaderSetTheme es necesario la entrada set theme_name |
|---|
| 2113 | if [ -f $CFGFILE ]; then |
|---|
| 2114 | sed -i '1 i\set theme_name=none' $CFGFILE |
|---|
| 2115 | else |
|---|
| 2116 | ogRaiseError $OG_ERR_NOTFOUND "$CFGFILE" || return $? |
|---|
| 2117 | fi |
|---|
| 2118 | # Creamos el directorio para los temas |
|---|
| 2119 | [ -d $DIRTHEME ] || mkdir $DIRTHEME |
|---|
| 2120 | |
|---|
| 2121 | ogBootLoaderSetTheme $EFIDISK $EFIPART $@ |
|---|
| 2122 | return $? |
|---|
| 2123 | } |
|---|
| 2124 | |
|---|
| 2125 | |
|---|
| 2126 | #/** |
|---|
| 2127 | # ogBootLoaderSetTheme |
|---|
| 2128 | #@brief asigna un tema al BURG |
|---|
| 2129 | #@param int_disk_SecondStage |
|---|
| 2130 | #@param int_part_SecondStage |
|---|
| 2131 | #@param str_theme_name |
|---|
| 2132 | #@return |
|---|
| 2133 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 2134 | #@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount). |
|---|
| 2135 | #@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg refind.conf. |
|---|
| 2136 | #@exception OG_ERR_NOTFOUND Entrada deltema no encontrada en burg.cfg. |
|---|
| 2137 | #@exception OG_ERR_NOTFOUND Fichero de configuración del tema no encontrado: theme.conf (sólo refind). |
|---|
| 2138 | #@note El tema debe situarse en OGLIB/BOOTLOADER/themes |
|---|
| 2139 | #@version 1.1.0 - Primeras pruebas con Burg. grub no soportado. |
|---|
| 2140 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
|---|
| 2141 | #@date 2018-01-24 |
|---|
| 2142 | #@version 1.1.1 - Soporta rEFInd (ticket #802 #888). |
|---|
| 2143 | #@author Irina Gomez. Universidad de Sevilla |
|---|
| 2144 | #@date 2019-03-22 |
|---|
| 2145 | #*/ ## |
|---|
| 2146 | function ogBootLoaderSetTheme () |
|---|
| 2147 | { |
|---|
| 2148 | |
|---|
| 2149 | # Variables locales. |
|---|
| 2150 | local FUNC PART CFGFILE THEME NEWTHEME BOOTLOADER MSG NEWTHEMECFG |
|---|
| 2151 | |
|---|
| 2152 | # Si se solicita, mostrar ayuda. |
|---|
| 2153 | if [ "$*" == "help" ]; then |
|---|
| 2154 | ogHelp "$FUNCNAME" "$MSG_SEE ogGrubSetTheme, ogBurgSetTheme or ogRefindSetTheme." |
|---|
| 2155 | return |
|---|
| 2156 | fi |
|---|
| 2157 | |
|---|
| 2158 | |
|---|
| 2159 | NEWTHEME="$3" |
|---|
| 2160 | |
|---|
| 2161 | # Nombre de la función que llama a esta. |
|---|
| 2162 | FUNC="${FUNCNAME[@]:1}" |
|---|
| 2163 | FUNC="${FUNC%%\ *}" |
|---|
| 2164 | |
|---|
| 2165 | |
|---|
| 2166 | |
|---|
| 2167 | # Error si no se reciben 3 parametros. |
|---|
| 2168 | [ $# -eq 3 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage str_themeName" || return $? |
|---|
| 2169 | |
|---|
| 2170 | # Error si no puede montar sistema de archivos. |
|---|
| 2171 | PART=$(ogMount $1 $2) || return $? |
|---|
| 2172 | # La función debe ser llamanda desde ogGrubSetTheme, ogBurgSetTheme or ogRefindSetTheme. |
|---|
| 2173 | case "$FUNC" in |
|---|
| 2174 | ogGrubSetTheme) |
|---|
| 2175 | BOOTLOADER="grub" |
|---|
| 2176 | BOOTLOADERDIR="boot/grubMBR" |
|---|
| 2177 | CFGFILE="$PART/boot/grubMBR/boot/grub/grub.cfg" |
|---|
| 2178 | ogRaiseError $OG_ERR_FORMAT "ogGrubSetTheme not sopported" |
|---|
| 2179 | return $? |
|---|
| 2180 | ;; |
|---|
| 2181 | ogBurgSetTheme) |
|---|
| 2182 | BOOTLOADER="burg" |
|---|
| 2183 | BOOTLOADERDIR="boot/burg" |
|---|
| 2184 | CFGFILE="$PART/boot/burg/burg.cfg" |
|---|
| 2185 | ;; |
|---|
| 2186 | ogRefindSetTheme) |
|---|
| 2187 | BOOTLOADER="refind" |
|---|
| 2188 | BOOTLOADERDIR="EFI/refind" |
|---|
| 2189 | CFGFILE="$PART/EFI/refind/refind.conf" |
|---|
| 2190 | ;; |
|---|
| 2191 | *) |
|---|
| 2192 | ogRaiseError $OG_ERR_FORMAT "Use ogGrubSetTheme, ogBurgSetTheme or ogRefindSetTheme." |
|---|
| 2193 | return $? |
|---|
| 2194 | ;; |
|---|
| 2195 | esac |
|---|
| 2196 | |
|---|
| 2197 | # Comprobamos que exista fichero de configuración |
|---|
| 2198 | [ -f $CFGFILE ] || ogRaiseError $OG_ERR_NOTFOUND "$CFGFILE" || return $? |
|---|
| 2199 | |
|---|
| 2200 | # Detectamos cual es el tema asignado |
|---|
| 2201 | THEME=$(grep "set theme_name=" $CFGFILE | grep ^set | cut -d= -f2) |
|---|
| 2202 | # Si no existe entrada de theme_name nos salimos |
|---|
| 2203 | [ -z "$THEME" ] && (ogRaiseError $OG_ERR_NOTFOUND "theme_name in $CFGFILE" || return $?) |
|---|
| 2204 | |
|---|
| 2205 | #Actualizamos el tema del servidor a la particion |
|---|
| 2206 | if [ -d $OGLIB/$BOOTLOADER/themes/$NEWTHEME ]; then |
|---|
| 2207 | # Para refind es necesario que exista theme.conf en el directorio del tema. |
|---|
| 2208 | if [ "$BOOTLOADER" == "refind" ]; then |
|---|
| 2209 | NEWTHEMECFG="$OGLIB/$BOOTLOADER/themes/$NEWTHEME/theme.conf" |
|---|
| 2210 | [ -f $NEWTHEMECFG ] || ogRaiserError $OG_ERR_NOTFOUND "theme.conf" || return $? |
|---|
| 2211 | grep -v "^#" $NEWTHEMECFG >> $CFGFILE |
|---|
| 2212 | # eliminamos "set theme" es de grub y no de refind |
|---|
| 2213 | sed -i '/theme_name/d' $CFGFILE |
|---|
| 2214 | fi |
|---|
| 2215 | cp -pr $OGLIB/$BOOTLOADER/themes/$NEWTHEME $PART/$BOOTLOADERDIR/themes/ |
|---|
| 2216 | fi |
|---|
| 2217 | |
|---|
| 2218 | #Verificamos que el tema esta en la particion |
|---|
| 2219 | if ! [ -d $PART/$BOOTLOADERDIR/themes/$NEWTHEME ]; then |
|---|
| 2220 | ogRaiseError $OG_ERR_NOTFOUND "theme_name=$NEWTHEME in $PART/$BOOTLOADERDIR/themes/" || return $? |
|---|
| 2221 | fi |
|---|
| 2222 | |
|---|
| 2223 | #Cambiamos la entrada el fichero de configuración. |
|---|
| 2224 | sed --regexp-extended -i s/"set theme_name=$THEME"/"set theme_name=$NEWTHEME"/g $CFGFILE |
|---|
| 2225 | |
|---|
| 2226 | |
|---|
| 2227 | } |
|---|
| 2228 | |
|---|
| 2229 | #/** |
|---|
| 2230 | # ogGrubSetAdminKeys num_disk num_part str_theme |
|---|
| 2231 | #@brief ver ogBootLoaderSetTheme |
|---|
| 2232 | #@see ogBootLoaderSetTheme |
|---|
| 2233 | #*/ ## |
|---|
| 2234 | function ogGrubSetAdminKeys () |
|---|
| 2235 | { |
|---|
| 2236 | # Si se solicita, mostrar ayuda. |
|---|
| 2237 | if [ "$*" == "help" ]; then |
|---|
| 2238 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage str_bolean" \ |
|---|
| 2239 | "$FUNCNAME 1 4 FALSE "\ |
|---|
| 2240 | "$FUNCNAME \$(ogFindCache) ThemeBasic" |
|---|
| 2241 | return |
|---|
| 2242 | fi |
|---|
| 2243 | ogBootLoaderSetAdminKeys $@ |
|---|
| 2244 | return $? |
|---|
| 2245 | } |
|---|
| 2246 | |
|---|
| 2247 | #/** |
|---|
| 2248 | # ogBurgSetAdminKeys num_disk num_part str_bolean |
|---|
| 2249 | #@brief ver ogBootLoaderSetAdminKeys |
|---|
| 2250 | #@see ogBootLoaderSetAdminKeys |
|---|
| 2251 | #*/ ## |
|---|
| 2252 | function ogBurgSetAdminKeys () |
|---|
| 2253 | { |
|---|
| 2254 | # Si se solicita, mostrar ayuda. |
|---|
| 2255 | if [ "$*" == "help" ]; then |
|---|
| 2256 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage str_bolean" \ |
|---|
| 2257 | "$FUNCNAME 1 4 TRUE" \ |
|---|
| 2258 | "$FUNCNAME \$(ogFindCache) FALSE" |
|---|
| 2259 | return |
|---|
| 2260 | fi |
|---|
| 2261 | ogBootLoaderSetAdminKeys $@ |
|---|
| 2262 | return $? |
|---|
| 2263 | } |
|---|
| 2264 | |
|---|
| 2265 | |
|---|
| 2266 | |
|---|
| 2267 | #/** |
|---|
| 2268 | # ogBootLoaderSetAdminKeys |
|---|
| 2269 | #@brief Activa/Desactica las teclas de administracion |
|---|
| 2270 | #@param int_disk_SecondStage |
|---|
| 2271 | #@param int_part_SecondStage |
|---|
| 2272 | #@param Boolean TRUE/FALSE |
|---|
| 2273 | #@return |
|---|
| 2274 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 2275 | #@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount). |
|---|
| 2276 | #@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg. |
|---|
| 2277 | #@exception OG_ERR_NOTFOUND Entrada deltema no encontrada en burg.cfg. |
|---|
| 2278 | #@version 1.1.0 - Primeras pruebas con Burg. grub no soportado. |
|---|
| 2279 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
|---|
| 2280 | #@date 2018-01-24 |
|---|
| 2281 | #*/ ## |
|---|
| 2282 | function ogBootLoaderSetAdminKeys () |
|---|
| 2283 | { |
|---|
| 2284 | |
|---|
| 2285 | # Variables locales. |
|---|
| 2286 | local FUNC PART CFGFILE BOOTLOADER BOOTLOADERDIR CFGFILE MSG |
|---|
| 2287 | |
|---|
| 2288 | # Si se solicita, mostrar ayuda. |
|---|
| 2289 | if [ "$*" == "help" ]; then |
|---|
| 2290 | ogHelp "$FUNCNAME" "$MSG_SEE ogGrubSetSetAdminKeys ogBurgSetSetAdminKeys" |
|---|
| 2291 | return |
|---|
| 2292 | fi |
|---|
| 2293 | |
|---|
| 2294 | |
|---|
| 2295 | # Nombre de la función que llama a esta. |
|---|
| 2296 | FUNC="${FUNCNAME[@]:1}" |
|---|
| 2297 | FUNC="${FUNC%%\ *}" |
|---|
| 2298 | |
|---|
| 2299 | |
|---|
| 2300 | # Error si no se reciben 2 parametros. |
|---|
| 2301 | [ $# -eq 3 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage str_bolean" || return $? |
|---|
| 2302 | |
|---|
| 2303 | # Error si no puede montar sistema de archivos. |
|---|
| 2304 | PART=$(ogMount $1 $2) || return $? |
|---|
| 2305 | # La función debe ser llamanda desde ogGrubSetAdminKeys or ogBurgSetAdminKeys. |
|---|
| 2306 | case "$FUNC" in |
|---|
| 2307 | ogGrubSetAdminKeys) |
|---|
| 2308 | BOOTLOADER="grub" |
|---|
| 2309 | BOOTLOADERDIR="grubMBR" |
|---|
| 2310 | CFGFILE="$PART/boot/grubMBR/boot/grub/grub.cfg" |
|---|
| 2311 | ogRaiseError $OG_ERR_FORMAT "ogGrubSetAdminKeys not sopported" |
|---|
| 2312 | return $? |
|---|
| 2313 | ;; |
|---|
| 2314 | ogBurgSetAdminKeys) |
|---|
| 2315 | BOOTLOADER="burg" |
|---|
| 2316 | BOOTLOADERDIR="burg" |
|---|
| 2317 | CFGFILE="$PART/boot/burg/burg.cfg" |
|---|
| 2318 | ;; |
|---|
| 2319 | *) |
|---|
| 2320 | ogRaiseError $OG_ERR_FORMAT "Use ogGrubSetAdminKeys" |
|---|
| 2321 | return $? |
|---|
| 2322 | ;; |
|---|
| 2323 | esac |
|---|
| 2324 | |
|---|
| 2325 | |
|---|
| 2326 | # Comprobamos que exista fichero de configuración |
|---|
| 2327 | [ -f $CFGFILE ] || ogRaiseError $OG_ERR_NOTFOUND "$CFGFILE" || return $? |
|---|
| 2328 | |
|---|
| 2329 | |
|---|
| 2330 | case "$3" in |
|---|
| 2331 | true|TRUE) |
|---|
| 2332 | [ -f ${OGCAC}/boot/$BOOTLOADERDIR/themes/conf.d/10_hotkey.disabled ] && mv ${OGCAC}/boot/$BOOTLOADERDIR/themes/conf.d/10_hotkey.disabled ${OGCAC}/boot/$BOOTLOADERDIR/themes/conf.d/10_hotkey |
|---|
| 2333 | ;; |
|---|
| 2334 | false|FALSE) |
|---|
| 2335 | [ -f ${OGCAC}/boot/$BOOTLOADERDIR/themes/conf.d/10_hotkey ] && mv ${OGCAC}/boot/$BOOTLOADERDIR/themes/conf.d/10_hotkey ${OGCAC}/boot/$BOOTLOADERDIR/themes/conf.d/10_hotkey.disabled |
|---|
| 2336 | ;; |
|---|
| 2337 | *) |
|---|
| 2338 | ogRaiseError $OG_ERR_FORMAT "str bolean unknow " |
|---|
| 2339 | return $? |
|---|
| 2340 | ;; |
|---|
| 2341 | esac |
|---|
| 2342 | } |
|---|
| 2343 | |
|---|
| 2344 | |
|---|
| 2345 | |
|---|
| 2346 | #/** |
|---|
| 2347 | # ogGrubSetTimeOut num_disk num_part int_timeout_seconds |
|---|
| 2348 | #@brief ver ogBootLoaderSetTimeOut |
|---|
| 2349 | #@see ogBootLoaderSetTimeOut |
|---|
| 2350 | #*/ ## |
|---|
| 2351 | function ogGrubSetTimeOut () |
|---|
| 2352 | { |
|---|
| 2353 | # Si se solicita, mostrar ayuda. |
|---|
| 2354 | if [ "$*" == "help" ]; then |
|---|
| 2355 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage int_timeout_seconds" \ |
|---|
| 2356 | "$FUNCNAME 1 4 50 "\ |
|---|
| 2357 | "$FUNCNAME \$(ogFindCache) 50" |
|---|
| 2358 | return |
|---|
| 2359 | fi |
|---|
| 2360 | ogBootLoaderSetTimeOut $@ |
|---|
| 2361 | return $? |
|---|
| 2362 | } |
|---|
| 2363 | |
|---|
| 2364 | #/** |
|---|
| 2365 | # ogBurgSetTimeOut num_disk num_part str_bolean |
|---|
| 2366 | #@brief ver ogBootLoaderSetTimeOut |
|---|
| 2367 | #@see ogBootLoaderSetTimeOut |
|---|
| 2368 | #*/ ## |
|---|
| 2369 | function ogBurgSetTimeOut () |
|---|
| 2370 | { |
|---|
| 2371 | # Si se solicita, mostrar ayuda. |
|---|
| 2372 | if [ "$*" == "help" ]; then |
|---|
| 2373 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage str_timeout_seconds" \ |
|---|
| 2374 | "$FUNCNAME 1 4 50" \ |
|---|
| 2375 | "$FUNCNAME \$(ogFindCache) 50" |
|---|
| 2376 | return |
|---|
| 2377 | fi |
|---|
| 2378 | ogBootLoaderSetTimeOut $@ |
|---|
| 2379 | return $? |
|---|
| 2380 | } |
|---|
| 2381 | |
|---|
| 2382 | |
|---|
| 2383 | #/** |
|---|
| 2384 | # ogRefindSetTimeOut int_timeout_second |
|---|
| 2385 | #@brief ver ogBootLoaderSetTimeOut |
|---|
| 2386 | #@see ogBootLoaderSetTimeOut |
|---|
| 2387 | #*/ ## |
|---|
| 2388 | function ogRefindSetTimeOut () |
|---|
| 2389 | { |
|---|
| 2390 | local EFIDISK EFIPART |
|---|
| 2391 | # Si se solicita, mostrar ayuda. |
|---|
| 2392 | if [ "$*" == "help" ]; then |
|---|
| 2393 | ogHelp "$FUNCNAME" "$FUNCNAME int_timeout_seconds" \ |
|---|
| 2394 | "$FUNCNAME 50" |
|---|
| 2395 | return |
|---|
| 2396 | fi |
|---|
| 2397 | |
|---|
| 2398 | read EFIDISK EFIPART <<< $(ogGetEsp) |
|---|
| 2399 | ogBootLoaderSetTimeOut $EFIDISK $EFIPART $@ |
|---|
| 2400 | return $? |
|---|
| 2401 | } |
|---|
| 2402 | |
|---|
| 2403 | #/** |
|---|
| 2404 | # ogBootLoaderSetTimeOut |
|---|
| 2405 | #@brief Define el tiempo (segundos) que se muestran las opciones de inicio |
|---|
| 2406 | #@param int_disk_SecondStage |
|---|
| 2407 | #@param int_part_SecondStage |
|---|
| 2408 | #@param int_timeout_seconds |
|---|
| 2409 | #@return |
|---|
| 2410 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 2411 | #@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount). |
|---|
| 2412 | #@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg. |
|---|
| 2413 | #@exception OG_ERR_NOTFOUND Entrada deltema no encontrada en burg.cfg. |
|---|
| 2414 | #@version 1.1.0 - Primeras pruebas con Burg. GRUB solo si está instalado en MBR |
|---|
| 2415 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
|---|
| 2416 | #@date 2018-01-24 |
|---|
| 2417 | #*/ ## |
|---|
| 2418 | function ogBootLoaderSetTimeOut () |
|---|
| 2419 | { |
|---|
| 2420 | |
|---|
| 2421 | # Variables locales. |
|---|
| 2422 | local FUNC PART CFGFILE TIMEOUT BOOTLOADER BOOTLOADERDIR CFGFILE MSG |
|---|
| 2423 | |
|---|
| 2424 | # Si se solicita, mostrar ayuda. |
|---|
| 2425 | if [ "$*" == "help" ]; then |
|---|
| 2426 | ogHelp "$FUNCNAME" "$MSG_SEE ogGrubSetTimeOut, ogBurgSetTimeOut or ogRefindSetTimeOut" |
|---|
| 2427 | return |
|---|
| 2428 | fi |
|---|
| 2429 | |
|---|
| 2430 | ogCheckStringInReg $3 "^[0-9]{1,10}$" && TIMEOUT="$3" || ogRaiseError $OG_ERR_FORMAT "param 3 is not a integer" |
|---|
| 2431 | |
|---|
| 2432 | # Nombre de la función que llama a esta. |
|---|
| 2433 | FUNC="${FUNCNAME[@]:1}" |
|---|
| 2434 | FUNC="${FUNC%%\ *}" |
|---|
| 2435 | |
|---|
| 2436 | # Error si no se reciben 3 parametros. |
|---|
| 2437 | [ $# -eq 3 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage int_timeout_seconds" || return $? |
|---|
| 2438 | |
|---|
| 2439 | # Error si no puede montar sistema de archivos. |
|---|
| 2440 | PART=$(ogMount $1 $2) || return $? |
|---|
| 2441 | # La función debe ser llamanda desde ogGrubSetTimeOut, ogBurgSetTimeOut or ogRefindSetTimeOut. |
|---|
| 2442 | case "$FUNC" in |
|---|
| 2443 | ogGrubSetTimeOut) |
|---|
| 2444 | BOOTLOADER="grub" |
|---|
| 2445 | BOOTLOADERDIR="boot/grubMBR" |
|---|
| 2446 | CFGFILE="$PART/boot/grubMBR/boot/grub/grub.cfg" |
|---|
| 2447 | ;; |
|---|
| 2448 | ogBurgSetTimeOut) |
|---|
| 2449 | BOOTLOADER="burg" |
|---|
| 2450 | BOOTLOADERDIR="boot/burg" |
|---|
| 2451 | CFGFILE="$PART/boot/burg/burg.cfg" |
|---|
| 2452 | ;; |
|---|
| 2453 | ogRefindSetTimeOut) |
|---|
| 2454 | BOOTLOADER="refind" |
|---|
| 2455 | BOOTLOADERDIR="EFI/refind" |
|---|
| 2456 | CFGFILE="$PART/EFI/refind/refind.conf" |
|---|
| 2457 | ;; |
|---|
| 2458 | *) |
|---|
| 2459 | ogRaiseError $OG_ERR_FORMAT "Use ogGrubSetTimeOut, ogBurgSetTimeOut or ogRefindSetTimeOut." |
|---|
| 2460 | return $? |
|---|
| 2461 | ;; |
|---|
| 2462 | esac |
|---|
| 2463 | |
|---|
| 2464 | # Comprobamos que exista fichero de configuración |
|---|
| 2465 | [ -f $CFGFILE ] || ogRaiseError $OG_ERR_NOTFOUND "$CFGFILE" || return $? |
|---|
| 2466 | |
|---|
| 2467 | # Asignamos el timeOut. |
|---|
| 2468 | if [ "$BOOTLOADER" == "refind" ]; then |
|---|
| 2469 | sed -i s/timeout.*$/"timeout $TIMEOUT"/g $CFGFILE |
|---|
| 2470 | else |
|---|
| 2471 | sed -i s/timeout=.*$/timeout=$TIMEOUT/g $CFGFILE |
|---|
| 2472 | fi |
|---|
| 2473 | } |
|---|
| 2474 | |
|---|
| 2475 | |
|---|
| 2476 | #/** |
|---|
| 2477 | # ogGrubSetResolution num_disk num_part int_resolution |
|---|
| 2478 | #@brief ver ogBootLoaderSetResolution |
|---|
| 2479 | #@see ogBootLoaderSetResolution |
|---|
| 2480 | #*/ ## |
|---|
| 2481 | function ogGrubSetResolution () |
|---|
| 2482 | { |
|---|
| 2483 | # Si se solicita, mostrar ayuda. |
|---|
| 2484 | if [ "$*" == "help" ]; then |
|---|
| 2485 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage [str_resolution]" \ |
|---|
| 2486 | "$FUNCNAME 1 4 1024x768" \ |
|---|
| 2487 | "$FUNCNAME \$(ogFindCache) 1024x768" \ |
|---|
| 2488 | "$FUNCNAME 1 4" |
|---|
| 2489 | return |
|---|
| 2490 | fi |
|---|
| 2491 | ogBootLoaderSetResolution $@ |
|---|
| 2492 | return $? |
|---|
| 2493 | } |
|---|
| 2494 | |
|---|
| 2495 | #/** |
|---|
| 2496 | # ogBurgSetResolution num_disk num_part str_bolean |
|---|
| 2497 | #@brief ver ogBootLoaderSetResolution |
|---|
| 2498 | #@see ogBootLoaderSetResolution |
|---|
| 2499 | #*/ ## |
|---|
| 2500 | function ogBurgSetResolution () |
|---|
| 2501 | { |
|---|
| 2502 | # Si se solicita, mostrar ayuda. |
|---|
| 2503 | if [ "$*" == "help" ]; then |
|---|
| 2504 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage [str_resolution]" \ |
|---|
| 2505 | "$FUNCNAME 1 4 1024x768" \ |
|---|
| 2506 | "$FUNCNAME \$(ogFindCache) 1024x768" \ |
|---|
| 2507 | "$FUNCNAME 1 4" |
|---|
| 2508 | return |
|---|
| 2509 | fi |
|---|
| 2510 | ogBootLoaderSetResolution $@ |
|---|
| 2511 | return $? |
|---|
| 2512 | } |
|---|
| 2513 | |
|---|
| 2514 | |
|---|
| 2515 | |
|---|
| 2516 | #/** |
|---|
| 2517 | # ogBootLoaderSetResolution |
|---|
| 2518 | #@brief Define la resolucion que usuara el thema del gestor de arranque |
|---|
| 2519 | #@param int_disk_SecondStage |
|---|
| 2520 | #@param int_part_SecondStage |
|---|
| 2521 | #@param str_resolution (Opcional) |
|---|
| 2522 | #@return |
|---|
| 2523 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 2524 | #@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount). |
|---|
| 2525 | #@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg. |
|---|
| 2526 | #@version 1.1.0 - Primeras pruebas con Burg. grub no soportado. |
|---|
| 2527 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
|---|
| 2528 | #@date 2018-01-24 |
|---|
| 2529 | #*/ ## |
|---|
| 2530 | function ogBootLoaderSetResolution () |
|---|
| 2531 | { |
|---|
| 2532 | |
|---|
| 2533 | # Variables locales. |
|---|
| 2534 | local FUNC PART CFGFILE RESOLUTION NEWRESOLUTION DEFAULTRESOLUTION BOOTLOADER BOOTLOADERDIR CFGFILE MSG |
|---|
| 2535 | |
|---|
| 2536 | # Si se solicita, mostrar ayuda. |
|---|
| 2537 | if [ "$*" == "help" ]; then |
|---|
| 2538 | ogHelp "$FUNCNAME" "$MSG_SEE ogGrubSetResolution, ogBurgSetResolution or ogRefindSetResolution." |
|---|
| 2539 | return |
|---|
| 2540 | fi |
|---|
| 2541 | |
|---|
| 2542 | |
|---|
| 2543 | # Nombre de la función que llama a esta. |
|---|
| 2544 | FUNC="${FUNCNAME[@]:1}" |
|---|
| 2545 | FUNC="${FUNC%%\ *}" |
|---|
| 2546 | |
|---|
| 2547 | |
|---|
| 2548 | # Error si no se reciben 2 parametros. |
|---|
| 2549 | [ $# -ge 2 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage [str_resolution]" || return $? |
|---|
| 2550 | |
|---|
| 2551 | # Error si no puede montar sistema de archivos. |
|---|
| 2552 | PART=$(ogMount $1 $2) || return $? |
|---|
| 2553 | # La función debe ser llamanda desde ogGrugSetResolution, ogBurgSetResolution or ogRefindSetResolution. |
|---|
| 2554 | case "$FUNC" in |
|---|
| 2555 | ogGrubSetResolution) |
|---|
| 2556 | BOOTLOADER="grub" |
|---|
| 2557 | BOOTLOADERDIR="grubMBR" |
|---|
| 2558 | CFGFILE="$PART/boot/grubMBR/boot/grub/grub.cfg" |
|---|
| 2559 | ogRaiseError $OG_ERR_FORMAT "ogGrubSetResolution not sopported" |
|---|
| 2560 | return $? |
|---|
| 2561 | ;; |
|---|
| 2562 | ogBurgSetResolution) |
|---|
| 2563 | BOOTLOADER="burg" |
|---|
| 2564 | BOOTLOADERDIR="burg" |
|---|
| 2565 | CFGFILE="$PART/boot/burg/burg.cfg" |
|---|
| 2566 | ;; |
|---|
| 2567 | *) |
|---|
| 2568 | ogRaiseError $OG_ERR_FORMAT "Use GrugSetResolution, ogBurgSetResolution or ogRefindSetResolution." |
|---|
| 2569 | return $? |
|---|
| 2570 | ;; |
|---|
| 2571 | esac |
|---|
| 2572 | |
|---|
| 2573 | DEFAULTRESOLUTION=1024x768 |
|---|
| 2574 | |
|---|
| 2575 | # Comprobamos que exista fichero de configuración |
|---|
| 2576 | [ -f $CFGFILE ] || ogRaiseError $OG_ERR_NOTFOUND "$CFGFILE" || return $? |
|---|
| 2577 | |
|---|
| 2578 | #controlar variable a consierar vga (default template) o video (menu) |
|---|
| 2579 | #Si solo dos parametros autoconfiguracion basado en el parametro vga de las propiedad menu. si no hay menu asignado es 788 por defecto |
|---|
| 2580 | if [ $# -eq 2 ] ; then |
|---|
| 2581 | if [ -n $video ]; then |
|---|
| 2582 | NEWRESOLUTION=$(echo "$video" | cut -f2 -d: | cut -f1 -d-) |
|---|
| 2583 | fi |
|---|
| 2584 | if [ -n $vga ] ; then |
|---|
| 2585 | case "$vga" in |
|---|
| 2586 | 788|789|814) |
|---|
| 2587 | NEWRESOLUTION=800x600 |
|---|
| 2588 | ;; |
|---|
| 2589 | 791|792|824) |
|---|
| 2590 | NEWRESOLUTION=1024x768 |
|---|
| 2591 | ;; |
|---|
| 2592 | 355) |
|---|
| 2593 | NEWRESOLUTION=1152x864 |
|---|
| 2594 | ;; |
|---|
| 2595 | 794|795|829) |
|---|
| 2596 | NEWRESOLUTION=1280x1024 |
|---|
| 2597 | ;; |
|---|
| 2598 | esac |
|---|
| 2599 | fi |
|---|
| 2600 | fi |
|---|
| 2601 | |
|---|
| 2602 | if [ $# -eq 3 ] ; then |
|---|
| 2603 | #comprobamos que el parametro 3 cumple formato NNNNxNNNN |
|---|
| 2604 | ogCheckStringInReg $3 "[0-9]{3,4}[x][0-9]{3,4}\$" && NEWRESOLUTION="$3" || ogRaiseError $OG_ERR_FORMAT "param 3 is not a valid resolution: 800x600, 1024x768, 1152x864, 1280x1024, 1600x1200" |
|---|
| 2605 | fi |
|---|
| 2606 | |
|---|
| 2607 | # Si no existe NEWRESOLUCION asignamos la defaulT |
|---|
| 2608 | [ -z "$NEWRESOLUTION" ] && NEWRESOLUTION=$DEFAULRESOLUTION |
|---|
| 2609 | |
|---|
| 2610 | #Cambiamos la entrada el fichero de configuración. |
|---|
| 2611 | sed -i s/gfxmode=.*$/gfxmode=$NEWRESOLUTION/g $CFGFILE |
|---|
| 2612 | } |
|---|
| 2613 | |
|---|
| 2614 | |
|---|
| 2615 | |
|---|
| 2616 | |
|---|
| 2617 | #/** |
|---|
| 2618 | # ogBootLoaderSetResolution |
|---|
| 2619 | #@brief Define la resolucion que usuara el thema del gestor de arranque |
|---|
| 2620 | #@param int_resolution1 |
|---|
| 2621 | #@param int_resolution2 (Opcional) |
|---|
| 2622 | #@return |
|---|
| 2623 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 2624 | #@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount). |
|---|
| 2625 | #@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg. |
|---|
| 2626 | #*/ ## |
|---|
| 2627 | function ogRefindSetResolution () { |
|---|
| 2628 | local PART CFGFILE |
|---|
| 2629 | # Si se solicita, mostrar ayuda. |
|---|
| 2630 | if [ "$*" == "help" ]; then |
|---|
| 2631 | ogHelp "$FUNCNAME" "$FUNCNAME int_resolution1 [int_resolution2]" \ |
|---|
| 2632 | "$FUNCNAME 1366 768" \ |
|---|
| 2633 | "$FUNCNAME 1" |
|---|
| 2634 | return |
|---|
| 2635 | fi |
|---|
| 2636 | |
|---|
| 2637 | # Error si no se reciben 2 parametros. |
|---|
| 2638 | [ $# -ge 1 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME int_resolution1 [int_resolution2]" || return $? |
|---|
| 2639 | |
|---|
| 2640 | # Error si no puede montar sistema de archivos. |
|---|
| 2641 | PART=$(ogMount $(ogGetEsp)) || return $? |
|---|
| 2642 | |
|---|
| 2643 | # Comprobamos que exista fichero de configuración |
|---|
| 2644 | CFGFILE=$PART/EFI/refind/refind.conf |
|---|
| 2645 | [ -f $CFGFILE ] || ogRaiseError $OG_ERR_NOTFOUND "$CFGFILE" || return $? |
|---|
| 2646 | |
|---|
| 2647 | # Borramos resolucion anterior y configuramos la nueva |
|---|
| 2648 | sed -i /^resolution/d $CFGFILE |
|---|
| 2649 | |
|---|
| 2650 | sed -i "1 i\resolution $1 $2" $CFGFILE |
|---|
| 2651 | } |
|---|
| 2652 | |
|---|
| 2653 | # ogRefindInstall bool_autoconfig |
|---|
| 2654 | #@brief Instala y actualiza el gestor rEFInd en la particion EFI |
|---|
| 2655 | #@param bolean_Check__auto_config true | false[default] |
|---|
| 2656 | #@return |
|---|
| 2657 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 2658 | #@exception OG_ERR_NOTFOUND No se encuentra la partición ESP. |
|---|
| 2659 | #@exception OG_ERR_NOTFOUND No se encuentra shimx64.efi.signed. |
|---|
| 2660 | #@exception OG_ERR_NOTFOUND No se encuentra refind-install o refind en OGLIB |
|---|
| 2661 | #@exception OG_ERR_PARTITION No se puede montar la partición ESP. |
|---|
| 2662 | #@note Refind debe estar instalado en el ogLive o compartido en OGLIB |
|---|
| 2663 | #@version 1.1.0 - Primeras pruebas. |
|---|
| 2664 | #@author Juan Carlos Garcia. Universidad de ZAragoza. |
|---|
| 2665 | #@date 2017-06-26 |
|---|
| 2666 | #@version 1.1.1 - Usa refind-install. Obtiene partición con ogGetEsp. Configura Part-X-Y y ogLive. |
|---|
| 2667 | #@author Irina Gomez. Universidad de Sevilla. |
|---|
| 2668 | #@date 2019-03-22 |
|---|
| 2669 | #*/ ## |
|---|
| 2670 | function ogRefindInstall () { |
|---|
| 2671 | # Variables locales. |
|---|
| 2672 | local CONFIG EFIDISK EFIPART EFIDEVICE EFIMNT EFIDIR SHIM REFINDDIR |
|---|
| 2673 | local CACHEDEVICE OGLIVE OGLIVEDIR CMDLINE OGICON CFGFILE DEVICES |
|---|
| 2674 | local LNXCFGFILE NUMENTRY DIR |
|---|
| 2675 | |
|---|
| 2676 | # Si se solicita, mostrar ayuda. |
|---|
| 2677 | if [ "$*" == "help" ]; then |
|---|
| 2678 | ogHelp "$FUNCNAME" "$FUNCNAME boolean_autoconfig " \ |
|---|
| 2679 | "$FUNCNAME TRUE" |
|---|
| 2680 | return |
|---|
| 2681 | fi |
|---|
| 2682 | |
|---|
| 2683 | # Recogemos parametros |
|---|
| 2684 | CONFIG=${1:-"FALSE"} |
|---|
| 2685 | |
|---|
| 2686 | read -e EFIDISK EFIPART <<< $(ogGetEsp) |
|---|
| 2687 | EFIDEVICE=$(ogDiskToDev $EFIDISK $EFIPART) || ogRaiseError $OG_ERR_NOTFOUND "ESP" || return $? |
|---|
| 2688 | EFIMNT=$(ogMount $EFIDISK $EFIPART) || ogRaiseError $OG_ERR_PARTITION "$MSG_ERROR mount ESP" || return $? |
|---|
| 2689 | EFIDIR="$EFIMNT/EFI" |
|---|
| 2690 | [ -d $EFIDIR ] || mkdir $EFIDIR |
|---|
| 2691 | |
|---|
| 2692 | # Comprobamos que exista shimx64 |
|---|
| 2693 | SHIM=$(ogGetPath /usr/lib/shim/shimx64.efi.signed) |
|---|
| 2694 | [ "$SHIM" == "" ] && return $(ogRaiseError $OG_ERR_NOTFOUND "shimx64.efi.signed") |
|---|
| 2695 | |
|---|
| 2696 | # Si existe configuración anterior de refind la borro |
|---|
| 2697 | [ -d "$EFIDIR/refind" ] && rm -rf $EFIDIR/refind |
|---|
| 2698 | |
|---|
| 2699 | # Instalamos rEFInd. |
|---|
| 2700 | refind-install --yes --alldrivers --root $EFIMNT --shim $SHIM |
|---|
| 2701 | |
|---|
| 2702 | # Firmo refind con certificado de OpenGnsys |
|---|
| 2703 | mv $EFIDIR/refind/grubx64.efi $EFIDIR/refind/grubx64.efi-unsigned |
|---|
| 2704 | sbsign --key $OGETC/ssl/private/opengnsys.key --cert $OGETC/ssl/certs/opengnsys.crt --output $EFIDIR/refind/grubx64.efi $EFIDIR/refind/grubx64.efi-unsigned |
|---|
| 2705 | |
|---|
| 2706 | # Copio los certificados |
|---|
| 2707 | cp /etc/refind.d/keys/* $EFIDIR/refind/keys |
|---|
| 2708 | # Copio certificado opengnsys |
|---|
| 2709 | cp $OGETC/ssl/certs/opengnsys.* $EFIDIR/refind/keys |
|---|
| 2710 | |
|---|
| 2711 | # Ponemos la entrada en NVRAM en el segundo lugar del orden de arranque |
|---|
| 2712 | NEWORDER="$(ogNvramGetOrder|awk '{gsub(",", " "); printf "%x %x %s\n", $2, $1, substr($0, index($0,$3))}')" |
|---|
| 2713 | ogNvramSetOrder $NEWORDER |
|---|
| 2714 | |
|---|
| 2715 | # Borramos configuración linux |
|---|
| 2716 | [ -f $EFIMNT/boot/refind_linux.conf ] && mv $EFIMNT/boot/refind_linux.conf{,.ogbackup} |
|---|
| 2717 | |
|---|
| 2718 | # Eliminamos punto de motaje (por si ejecutamos más de una vez) |
|---|
| 2719 | umount $EFIMNT/boot/efi |
|---|
| 2720 | |
|---|
| 2721 | # Para la configuración del ogLive |
|---|
| 2722 | ogMountCache &>/dev/null |
|---|
| 2723 | if [ $? -eq 0 ]; then |
|---|
| 2724 | # Detectamos si hay ogLive |
|---|
| 2725 | CACHEDEVICE=$(ogDiskToDev $(ogFindCache)) |
|---|
| 2726 | OGLIVE=$(find $OGCAC/boot -name ogvmlinuz|head -1) |
|---|
| 2727 | # Obtenemos parametros del kernel y sustituimos root |
|---|
| 2728 | # La línea de opciones no puede contener la cadena initrd. |
|---|
| 2729 | CMDLINE="$(cat /proc/cmdline|sed -e 's/^.*ogvmlinuz.efi //g' -e 's/^.*ogvmlinuz //g' -e 's|root=/dev/[a-z]* ||g' \ |
|---|
| 2730 | -e 's/ogupdateinitrd=[a-z]* //g')" |
|---|
| 2731 | CMDLINE="root=$CACHEDEVICE ${CMDLINE#*ogvmlinuz}" |
|---|
| 2732 | |
|---|
| 2733 | # Icono para la entrada de menú |
|---|
| 2734 | OGICON=$(ls $OGLIB/refind/icons/so_opengnsys.png 2>/dev/null) |
|---|
| 2735 | [ "$OGICON" == "" ] && OGICON="${EFIDIR}/refind/icons/os_unknown.png" |
|---|
| 2736 | cp "$OGICON" "$OGCAC/.VolumeIcon.png" |
|---|
| 2737 | fi |
|---|
| 2738 | |
|---|
| 2739 | # Configuramos rEFInd si es necesario |
|---|
| 2740 | CFGFILE="${EFIDIR}/refind/refind.conf" |
|---|
| 2741 | if [ "$CONFIG" == "TRUE" ]; then |
|---|
| 2742 | echo -e "\n\n# Configuración OpenGnsys" >> $CFGFILE |
|---|
| 2743 | # Excluimos dispositivos distintos de ESP y CACHE |
|---|
| 2744 | DEVICES=$(blkid -s PARTUUID |awk -v D=$EFIDEVICE -v C=$CACHEDEVICE '$1!=D":" && $1!=C":" {gsub(/PARTUUID=/,"");gsub(/"/,""); aux = aux" "$2","} END {print aux}') |
|---|
| 2745 | echo "dont_scan_volumes $DEVICES" >> $CFGFILE |
|---|
| 2746 | # Excluimos en la ESP los directorios de los sistemas operativos |
|---|
| 2747 | echo "dont_scan_dirs EFI/microsoft,EFI/ubuntu,EFI/grub" >> $CFGFILE |
|---|
| 2748 | echo "use_graphics_for osx,linux,windows" >> $CFGFILE |
|---|
| 2749 | echo "showtools reboot, shutdown" >> $CFGFILE |
|---|
| 2750 | |
|---|
| 2751 | # Configuramos ogLive |
|---|
| 2752 | if [ "$OGLIVE" != "" ]; then |
|---|
| 2753 | # Cambiamos nombre de kernel e initrd para que lo detecte refind |
|---|
| 2754 | OGLIVEDIR="$(dirname $OGLIVE)" |
|---|
| 2755 | cp "$OGLIVE" "${OGLIVE}.efi" |
|---|
| 2756 | cp "$OGLIVEDIR/oginitrd.img" "$OGLIVEDIR/initrd.img" |
|---|
| 2757 | |
|---|
| 2758 | # Incluimos el directorio de ogLive. |
|---|
| 2759 | echo "also_scan_dirs +,boot/$(basename $OGLIVEDIR)" >> $CFGFILE |
|---|
| 2760 | # Fichero de configuración de refind para kernel de linux. |
|---|
| 2761 | LNXCFGFILE="$OGLIVEDIR/refind_linux.conf" |
|---|
| 2762 | echo "\"OpenGnsys Live\" \"$CMDLINE\"" > $LNXCFGFILE |
|---|
| 2763 | |
|---|
| 2764 | # Ponemos ogLive como la entrada por defecto |
|---|
| 2765 | NUMENTRY=$(ls -d $EFIDIR/Part-??-??|wc -l) |
|---|
| 2766 | echo "default_selection $((NUMENTRY+1))" >> $CFGFILE |
|---|
| 2767 | fi |
|---|
| 2768 | else |
|---|
| 2769 | # Renombramos la configuración por defecto |
|---|
| 2770 | mv $CFGFILE ${CFGFILE}.auto |
|---|
| 2771 | |
|---|
| 2772 | # Creamos nueva configuración |
|---|
| 2773 | echo "# Configuración OpenGnsys" >> $CFGFILE |
|---|
| 2774 | echo "timeout 20" > $CFGFILE |
|---|
| 2775 | echo "showtools reboot, shutdown" >> $CFGFILE |
|---|
| 2776 | echo -e "scanfor manual\n" >> $CFGFILE |
|---|
| 2777 | # Configuración para sistemas restaurados con OpenGnsys |
|---|
| 2778 | for DIR in $(ls -d /mnt/sda1/EFI/Part-*-* 2>/dev/null); do |
|---|
| 2779 | echo "menuentry \"${DIR##*/}\" {" >> $CFGFILE |
|---|
| 2780 | echo " loader /EFI/${DIR##*/}/Boot/ogloader.efi" >> $CFGFILE |
|---|
| 2781 | [ -f $DIR/Boot/bootmgfw.efi ] && echo " icon /EFI/refind/icons/os_win8.png" >> $CFGFILE |
|---|
| 2782 | [ -f $DIR/Boot/grubx64.efi ] && echo " icon /EFI/refind/icons/os_linux.png" >> $CFGFILE |
|---|
| 2783 | echo "}" >> $CFGFILE |
|---|
| 2784 | done |
|---|
| 2785 | # Configuración ogLive si secureboot no está activado |
|---|
| 2786 | if ! dmesg|grep secureboot.*enabled &>/dev/null; then |
|---|
| 2787 | if [ "$OGLIVE" != "" ]; then |
|---|
| 2788 | echo "menuentry \"OpenGnsys Live\" {" >> $CFGFILE |
|---|
| 2789 | echo " volume CACHE" >> $CFGFILE |
|---|
| 2790 | echo " ostype Linux" >> $CFGFILE |
|---|
| 2791 | echo " loader /boot/$(basename ${OGLIVE%/*})/ogvmlinuz" >> $CFGFILE |
|---|
| 2792 | echo " initrd /boot/$(basename ${OGLIVE%/*})/oginitrd.img" >> $CFGFILE |
|---|
| 2793 | echo " options \"$CMDLINE\"" >> $CFGFILE |
|---|
| 2794 | echo "}" >> $CFGFILE |
|---|
| 2795 | |
|---|
| 2796 | # Ponemos ogLive como la entrada por defecto |
|---|
| 2797 | sed -i '1 i\default_selection "OpenGnsys Live"' $CFGFILE |
|---|
| 2798 | fi |
|---|
| 2799 | fi |
|---|
| 2800 | fi |
|---|
| 2801 | } |
|---|