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