diff options
author | Irina Gómez <irinagomez@us.es> | 2019-04-05 14:32:28 +0200 |
---|---|---|
committer | Irina Gómez <irinagomez@us.es> | 2019-04-05 14:32:28 +0200 |
commit | fae14f68cc17fdf1d96473fa1541137ba1186ac2 (patch) | |
tree | 7e6c422e85f9ce62db6d2ffb21fe979816ea3275 /client/engine | |
parent | da53464c601bdab21e4155e21c7e2db76474cd5f (diff) |
#802 #888 ogRefindInstall: refind configuration only shows operating systems deployed with OpenGnsys and OgLive
Diffstat (limited to 'client/engine')
-rwxr-xr-x | client/engine/Boot.lib | 80 |
1 files changed, 52 insertions, 28 deletions
diff --git a/client/engine/Boot.lib b/client/engine/Boot.lib index 396b92d7..3e573acb 100755 --- a/client/engine/Boot.lib +++ b/client/engine/Boot.lib @@ -2678,7 +2678,9 @@ sed -i "1 i\resolution $1 $2" $CFGFILE #*/ ## function ogRefindInstall () { # Variables locales. -local CONFIG EFIDISK EFIPART EFIDEVICE EFIMNT EFIDIR SHIM DIRREFIND CFGFILE DIR OGLIVE CMDLINE +local CONFIG EFIDISK EFIPART EFIDEVICE EFIMNT EFIDIR SHIM REFINDDIR +local CACHEDEVICE OGLIVE OGLIVEDIR CMDLINE OGICON CFGFILE DEVICES +local LNXCFGFILE NUMENTRY DIR # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then @@ -2708,41 +2710,69 @@ if which refind-install &>/dev/null; then [ -d $EFIDIR/refind ] && rm -rf $EFIDIR/refind mv $EFIDIR/BOOT $EFIDIR/refind - # Desmontamos directorio temporal + # Desmontamos directorio temporal (para idempotencia) umount /tmp/refind_install else - DIRREFIND=$OGLIB/refind - [ -d $DIRREFIND ] || ogRaiseError $OG_ERR_NOTFOUND "refind-install or $DIRREFIND" || return $? - cp -r $DIRREFIND $EFIDIR + REFINDDIR=$OGLIB/refind + [ -d $REFINDDIR ] || ogRaiseError $OG_ERR_NOTFOUND "refind-install or $REFINDDIR" || return $? + cp -r $REFINDDIR $EFIDIR +fi + +# Para la configuración del ogLive +ogMountCache &>/dev/null +if [ $? -eq 0 ]; then + # Detectamos si hay ogLive + CACHEDEVICE=$(ogDiskToDev $(ogFindCache)) + OGLIVE=$(find $OGCAC/boot -name ogvmlinuz|head -1) + # Obtenemos parametros del kernel y sustituimos root + #CMDLINE="$(cat /proc/cmdline)" + CMDLINE="$(cat /proc/cmdline|sed -e s/^.*ogvmlinuz.efi//g -e s/^.*ogvmlinuz//g -e "s|root=/dev/....||g")" + CMDLINE="root=$CACHEDEVICE ${CMDLINE#*ogvmlinuz}" + + # Icono para la entrada de menú + OGICON=$(ls $OGLIB/refind/icons/so_opengnsys.png 2>/dev/null) + [ "$OGICON" == "" ] && OGICON="${EFIDIR}/refind/icons/os_unknown.png" + cp "$OGICON" "$OGCAC/.VolumeIcon.png" fi # Configuramos rEFInd si es necesario CFGFILE="${EFIDIR}/refind/refind.conf" -#if [ "$CONFIG" == "TRUE" ]; then if [ "$CONFIG" == "TRUE" ]; then - echo "dont_scan_dirs /EFI/microsoft, /EFI/ubuntu, /EFI/fedora, /EFI/opensuse" >> $CFGFILE + echo -e "\n\n# Configuración OpenGnsys" >> $CFGFILE + # Excluimos dispositivos distintos de ESP y CACHE + DEVICES=$(blkid -s PARTUUID |awk -v D=$EFIDEVICE -v C=$CACHEDEVICE '$1!=D":" && $1!=C":" {gsub(/PARTUUID=/,"");gsub(/"/,""); aux = aux" "$2","} END {print aux}') + echo "dont_scan_volumes $DEVICES" >> $CFGFILE + # Excluimos en la ESP los directorios de los sistemas operativos + echo "dont_scan_dirs EFI/microsoft,EFI/ubuntu,EFI/grub" >> $CFGFILE + echo "use_graphics_for osx,linux,windows" >> $CFGFILE + echo "showtools reboot, shutdown" >> $CFGFILE + + # Configuramos ogLive + if [ "$OGLIVE" != "" ]; then + # Cambiamos nombre de kernel e initrd para que lo detecte refind + OGLIVEDIR="$(dirname $OGLIVE)" + cp "$OGLIVE" "${OGLIVE}.efi" + cp "$OGLIVEDIR/oginitrd.img" "$OGLIVEDIR/initrd.img" + + # Incluimos el directorio de ogLive. + echo "also_scan_dirs +,boot/$(basename $OGLIVEDIR)" >> $CFGFILE + # Fichero de configuración de refind para kernel de linux. + LNXCFGFILE="$OGLIVEDIR/refind_linux.conf" + echo "\"OpenGnsys Live\" \"$CMDLINE\"" > $LNXCFGFILE + + # Ponemos ogLive como la entrada por defecto + NUMENTRY=$(ls -d $EFIDIR/Part-??-??|wc -l) + echo "default_selection $((NUMENTRY+1))" >> $CFGFILE + fi else # Renombramos la configuración por defecto mv $CFGFILE ${CFGFILE}.auto # Creamos nueva configuración + echo "# Configuración OpenGnsys" >> $CFGFILE echo "timeout 20" > $CFGFILE echo "showtools reboot, shutdown" >> $CFGFILE echo -e "scanfor manual\n" >> $CFGFILE - # Configuración para Windows - #if [ -a ${EFIDIR}/Microsoft ]; then - # echo "menuentry \"Windows\" {" >> $CFGFILE - # echo " loader /EFI/Microsoft/Boot/bootmgfw.efi" >> $CFGFILE - # echo " icon /EFI/refind/icons/os_win8.png" >> $CFGFILE - # echo "}" >> $CFGFILE - #fi - # Configuración para Ubuntu - #if [ -a ${EFIDIR}/ubuntu ]; then - # echo "menuentry \"Ubuntu\" {" >> $CFGFILE - # echo " loader /EFI/ubuntu/grubx64.efi" >> $CFGFILE - # echo " icon /EFI/refind/icons/os_ubuntu.png" >> $CFGFILE - # echo "}" >> $CFGFILE - #fi # Configuración para sistemas restaurados con OpenGnsys for DIR in $(ls -d /mnt/sda1/EFI/Part-*-* 2>/dev/null); do echo "menuentry \"${DIR##*/}\" {" >> $CFGFILE @@ -2751,20 +2781,14 @@ else [ -f $DIR/grubx64.efi ] && echo " icon /EFI/refind/icons/os_linux.png" >> $CFGFILE echo "}" >> $CFGFILE done - ogMountCache &>/dev/null - OGLIVE=$(find $OGCAC -name ogvmlinuz|head -1) + # Configuración ogLive if [ "$OGLIVE" != "" ]; then - read -e CACDISK CACPART <<< $(ogFindCache) - # Obtenemos parametros del kernel y sustituimos root - CMDLINE="$(cat /proc/cmdline)" - CMDLINE="root=$(ogDiskToDev $CACDISK $CACPART) ${CMDLINE#*ogvmlinuz}" echo "menuentry \"OpenGnsys Live\" {" >> $CFGFILE echo " volume CACHE" >> $CFGFILE echo " ostype Linux" >> $CFGFILE echo " loader /boot/$(basename ${OGLIVE%/*})/ogvmlinuz" >> $CFGFILE echo " initrd /boot/$(basename ${OGLIVE%/*})/oginitrd.img" >> $CFGFILE echo " options \"$CMDLINE\"" >> $CFGFILE - echo " icon /EFI/refind/icons/os_unknown.png" >> $CFGFILE echo "}" >> $CFGFILE # Ponemos ogLive como la entrada por defecto |