| 1 | #!/bin/bash |
|---|
| 2 | set -e |
|---|
| 3 | |
|---|
| 4 | #grubSyntax |
|---|
| 5 | #version 1.1.0 |
|---|
| 6 | #autoconfigurador de items de menu para grub/brg |
|---|
| 7 | #basado en scripts del paquete de grub |
|---|
| 8 | #Antonio Doblas Viso |
|---|
| 9 | #Universidad de Málaga |
|---|
| 10 | #@version 1.1.1 - En los parámetros del kernel se sustituye el UUID por el dispositivo. |
|---|
| 11 | #@version 1.1.1 - Detecta cargador de Windows en directorio Part-xx-yy dentro de ESP (#802 #888) |
|---|
| 12 | |
|---|
| 13 | DISK= |
|---|
| 14 | PART= |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | if [ $# == 3 ]; then |
|---|
| 19 | DISK=$1;PART=$2;KERNELPARAM=$3 |
|---|
| 20 | fi |
|---|
| 21 | |
|---|
| 22 | if [ $# == 2 ]; then |
|---|
| 23 | DISK=$1;PART=$2 |
|---|
| 24 | fi |
|---|
| 25 | |
|---|
| 26 | if [ $# == 1 ]; then |
|---|
| 27 | KERNELPARAM=$1 |
|---|
| 28 | fi |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | #Versión de scripts compatible con la versión 1.99 de grub-probe |
|---|
| 32 | #Uso del grub-probe 1.99 según arquitectura |
|---|
| 33 | grub_probe=${grub_probe:-$OGBIN/grub-probe1.99_$(arch)} |
|---|
| 34 | |
|---|
| 35 | #librerias del osProber para kernel antiguos: detecta e identifica sistema operativos. |
|---|
| 36 | if grub-install --version | grep 1.99 ; then |
|---|
| 37 | cp -r /opt/opengnsys/lib/os-probes/* /usr/lib/os-probes/ |
|---|
| 38 | else |
|---|
| 39 | # Librería os-probe para cargador de microsoft en dir part-x-y (uefi) |
|---|
| 40 | OSPROBE_MS_PART="/opt/opengnsys/lib/os-probes/mounted/efi/31part-x-y" |
|---|
| 41 | [ -f $OSPROBE_MS_PART ] && cp $OSPROBE_MS_PART /usr/lib/os-probes/mounted/efi |
|---|
| 42 | fi |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | #Autoreconocimiento del ogLive en cache |
|---|
| 46 | #fichero de reconocimeinto de grub |
|---|
| 47 | #fichero de lsb-release en la cache (al final de este scripts se elimina esta entrada para que el browser no lo muestre |
|---|
| 48 | |
|---|
| 49 | if [ $(ls /opt/opengnsys/cache/boot/$oglivedir/ogvmlinuz 2>/dev/null) ]; then |
|---|
| 50 | sed -i 's|/boot/\${oglivedir}/ogvmlinuz |/vmlinuz |i' /usr/lib/linux-boot-probes/mounted/90fallback |
|---|
| 51 | sed -i 's|/vmlinuz |/vmlinuz /boot/\${oglivedir}/ogvmlinuz |1' /usr/lib/linux-boot-probes/mounted/90fallback |
|---|
| 52 | mkdir -p /opt/opengnsys/cache/etc/ |
|---|
| 53 | echo "DISTRIB_ID=Ubuntu" > /opt/opengnsys/cache/etc/lsb-release |
|---|
| 54 | echo "DISTRIB_RELEASE= " >> /opt/opengnsys/cache/etc/lsb-release |
|---|
| 55 | echo $oglivedir | awk -F- ' {print "DISTRIB_CODENAME="$2 }' >> /opt/opengnsys/cache/etc/lsb-release |
|---|
| 56 | echo "DISTRIB_DESCRIPTION=OpenGnsys Live" >> /opt/opengnsys/cache/etc/lsb-release |
|---|
| 57 | fi |
|---|
| 58 | |
|---|
| 59 | #ver linea 195 detección de los os en variable OSPROBED |
|---|
| 60 | |
|---|
| 61 | OG_prepare_grub_to_access_device () |
|---|
| 62 | { |
|---|
| 63 | device="$1" |
|---|
| 64 | loop_file= |
|---|
| 65 | case ${device} in |
|---|
| 66 | /dev/loop/*|/dev/loop[0-9]) |
|---|
| 67 | grub_loop_device="${device#/dev/}" |
|---|
| 68 | loop_file=`losetup "${device}" | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"` |
|---|
| 69 | case $loop_file in |
|---|
| 70 | /dev/*) ;; |
|---|
| 71 | *) |
|---|
| 72 | loop_device="${device}" |
|---|
| 73 | device=`"${grub_probe}" --target=device "${loop_file}"` || return 0 |
|---|
| 74 | ;; |
|---|
| 75 | esac |
|---|
| 76 | ;; |
|---|
| 77 | esac |
|---|
| 78 | if dmsetup status $device 2>/dev/null | grep -q 'crypt[[:space:]]$'; then |
|---|
| 79 | grub_warn \ |
|---|
| 80 | "$device is a crypto device, which GRUB cannot read directly. Some" \ |
|---|
| 81 | "necessary modules may be missing from /boot/grub/grub.cfg. You may" \ |
|---|
| 82 | "need to list them in GRUB_PRELOAD_MODULES in /etc/default/grub. See" \ |
|---|
| 83 | "http://bugs.debian.org/542165 for details." |
|---|
| 84 | return 0 |
|---|
| 85 | fi |
|---|
| 86 | # Abstraction modules aren't auto-loaded. |
|---|
| 87 | abstraction="`"${grub_probe}" --device "${device}" --target=abstraction`" |
|---|
| 88 | for module in ${abstraction} ; do |
|---|
| 89 | echo "insmod ${module}" |
|---|
| 90 | done |
|---|
| 91 | partmap="`"${grub_probe}" --device "${device}" --target=partmap`" |
|---|
| 92 | for module in ${partmap} ; do |
|---|
| 93 | case "${module}" in |
|---|
| 94 | netbsd | openbsd) |
|---|
| 95 | echo "insmod part_bsd";; |
|---|
| 96 | *) |
|---|
| 97 | echo "insmod part_${module}";; |
|---|
| 98 | esac |
|---|
| 99 | done |
|---|
| 100 | fs="`"${grub_probe}" --device "${device}" --target=fs`" |
|---|
| 101 | for module in ${fs} ; do |
|---|
| 102 | echo "insmod ${module}" |
|---|
| 103 | done |
|---|
| 104 | # If there's a filesystem UUID that GRUB is capable of identifying, use it; |
|---|
| 105 | # otherwise set root as per value in device.map. |
|---|
| 106 | #OG modificacion |
|---|
| 107 | # PARCHE UHU ...SI el disco es nvme se cambia su nomenclatura, ya que grub_probe no funciona bien |
|---|
| 108 | if [[ $DEVICE == *"nvme"* ]]; then |
|---|
| 109 | #DEVICE=`echo $DEVICE | sed -e "s/\/dev\/nvme/hd/g" | sed -e "s/n.*p/,gpt/g"` |
|---|
| 110 | #TODO Detectar si es GPT o no... |
|---|
| 111 | read -r D P <<< `ogDevToDisk $DEVICE` |
|---|
| 112 | if [ "`ogGetPartitionTableType $D`" == "GPT" ]; then |
|---|
| 113 | # Si es gpt se sustituye por "hd(X-1),gptY" |
|---|
| 114 | #device=`echo $device | sed -e "s/\/dev\/nvme/hd/g" | sed -e "s/n.*p/,gpt/g"` |
|---|
| 115 | nvmeDevice=`echo "hd"$(expr $D - 1)",gpt$P"` |
|---|
| 116 | |
|---|
| 117 | else |
|---|
| 118 | # Sino se sustituye por hd(X-1),(Y-1) |
|---|
| 119 | nvmeDevice=`echo "hd"$(expr $D - 1)","$(expr $P - 1)` |
|---|
| 120 | fi |
|---|
| 121 | echo "set root='$nvmeDevice'" |
|---|
| 122 | else |
|---|
| 123 | echo "set root='`"${grub_probe}" --device "${device}" --target=drive`'" |
|---|
| 124 | fi |
|---|
| 125 | |
|---|
| 126 | #if fs_uuid="`"${grub_probe}" --device "${device}" --target=fs_uuid 2> /dev/null`" ; then |
|---|
| 127 | # echo "search --no-floppy --fs-uuid --set=root ${fs_uuid}" |
|---|
| 128 | #fi |
|---|
| 129 | |
|---|
| 130 | if [ "x${loop_file}" != x ]; then |
|---|
| 131 | loop_mountpoint="$(awk '"'${loop_file}'" ~ "^"$2 && $2 != "/" { print $2 }' /proc/mounts | tail -n1)" |
|---|
| 132 | if [ "x${loop_mountpoint}" != x ]; then |
|---|
| 133 | echo "loopback ${grub_loop_device} ${loop_file#$loop_mountpoint}" |
|---|
| 134 | echo "set root=(${grub_loop_device})" |
|---|
| 135 | fi |
|---|
| 136 | fi |
|---|
| 137 | } |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | # grub-mkconfig helper script. |
|---|
| 144 | # Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. |
|---|
| 145 | # |
|---|
| 146 | # GRUB is free software: you can redistribute it and/or modify |
|---|
| 147 | # it under the terms of the GNU General Public License as published by |
|---|
| 148 | # the Free Software Foundation, either version 3 of the License, or |
|---|
| 149 | # (at your option) any later version. |
|---|
| 150 | # |
|---|
| 151 | # GRUB is distributed in the hope that it will be useful, |
|---|
| 152 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 153 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 154 | # GNU General Public License for more details. |
|---|
| 155 | # |
|---|
| 156 | # You should have received a copy of the GNU General Public License |
|---|
| 157 | # along with GRUB. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | prefix=/usr |
|---|
| 161 | exec_prefix=${prefix} |
|---|
| 162 | libdir=${exec_prefix}/lib |
|---|
| 163 | |
|---|
| 164 | . ${libdir}/grub/grub-mkconfig_lib |
|---|
| 165 | |
|---|
| 166 | found_other_os= |
|---|
| 167 | |
|---|
| 168 | make_timeout () { |
|---|
| 169 | if [ "x${found_other_os}" = "x" ] ; then |
|---|
| 170 | if [ "x${1}" != "x" ] ; then |
|---|
| 171 | if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then |
|---|
| 172 | verbose= |
|---|
| 173 | else |
|---|
| 174 | verbose=" --verbose" |
|---|
| 175 | fi |
|---|
| 176 | |
|---|
| 177 | if [ "x${1}" = "x0" ] ; then |
|---|
| 178 | cat <<EOF |
|---|
| 179 | if [ "x\${timeout}" != "x-1" ]; then |
|---|
| 180 | if keystatus; then |
|---|
| 181 | if keystatus --shift; then |
|---|
| 182 | set timeout=-1 |
|---|
| 183 | else |
|---|
| 184 | set timeout=0 |
|---|
| 185 | fi |
|---|
| 186 | else |
|---|
| 187 | if sleep$verbose --interruptible 3 ; then |
|---|
| 188 | set timeout=0 |
|---|
| 189 | fi |
|---|
| 190 | fi |
|---|
| 191 | fi |
|---|
| 192 | EOF |
|---|
| 193 | else |
|---|
| 194 | cat << EOF |
|---|
| 195 | if [ "x\${timeout}" != "x-1" ]; then |
|---|
| 196 | if sleep$verbose --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then |
|---|
| 197 | set timeout=0 |
|---|
| 198 | fi |
|---|
| 199 | fi |
|---|
| 200 | EOF |
|---|
| 201 | fi |
|---|
| 202 | fi |
|---|
| 203 | fi |
|---|
| 204 | } |
|---|
| 205 | |
|---|
| 206 | adjust_timeout () { |
|---|
| 207 | if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then |
|---|
| 208 | cat <<EOF |
|---|
| 209 | if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then |
|---|
| 210 | EOF |
|---|
| 211 | make_timeout "${GRUB_HIDDEN_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_BUTTON}" |
|---|
| 212 | echo else |
|---|
| 213 | make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}" |
|---|
| 214 | echo fi |
|---|
| 215 | else |
|---|
| 216 | make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}" |
|---|
| 217 | fi |
|---|
| 218 | } |
|---|
| 219 | |
|---|
| 220 | if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then |
|---|
| 221 | adjust_timeout |
|---|
| 222 | exit 0 |
|---|
| 223 | fi |
|---|
| 224 | |
|---|
| 225 | if [ -z "`which os-prober 2> /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then |
|---|
| 226 | # missing os-prober and/or linux-boot-prober |
|---|
| 227 | adjust_timeout |
|---|
| 228 | exit 0 |
|---|
| 229 | fi |
|---|
| 230 | |
|---|
| 231 | case "$1" in |
|---|
| 232 | |
|---|
| 233 | |
|---|
| 234 | esac |
|---|
| 235 | |
|---|
| 236 | |
|---|
| 237 | |
|---|
| 238 | # ADV OSPROBED |
|---|
| 239 | if [ -n "${DISK}" ]; then |
|---|
| 240 | #Si $DISK esta definido buscar en el disco y la particion parametro 1 y 2 |
|---|
| 241 | OSSEARCH=$(ogDiskToDev $DISK $PART) |
|---|
| 242 | OSPROBED="`os-prober | grep $OSSEARCH | tr ' ' '^' | paste -s -d ' '`" |
|---|
| 243 | else |
|---|
| 244 | #si no esta definido |
|---|
| 245 | OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`" |
|---|
| 246 | fi |
|---|
| 247 | |
|---|
| 248 | #DISK=${DISK:-"1"} |
|---|
| 249 | #echo $OSSEARCH |
|---|
| 250 | #echo "$OSPROBED" |
|---|
| 251 | |
|---|
| 252 | |
|---|
| 253 | if [ -z "${OSPROBED}" ] ; then |
|---|
| 254 | # empty os-prober output, nothing doing |
|---|
| 255 | adjust_timeout |
|---|
| 256 | exit 0 |
|---|
| 257 | fi |
|---|
| 258 | |
|---|
| 259 | osx_entry() { |
|---|
| 260 | found_other_os=1 |
|---|
| 261 | cat << EOF |
|---|
| 262 | menuentry "${LONGNAME} (${2}-bit) (on ${DEVICE})" --class osx --class darwin --class os { |
|---|
| 263 | EOF |
|---|
| 264 | save_default_entry | sed -e "s/^/\t/" |
|---|
| 265 | prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" |
|---|
| 266 | cat << EOF |
|---|
| 267 | load_video |
|---|
| 268 | set do_resume=0 |
|---|
| 269 | if [ /var/vm/sleepimage -nt10 / ]; then |
|---|
| 270 | if xnu_resume /var/vm/sleepimage; then |
|---|
| 271 | set do_resume=1 |
|---|
| 272 | fi |
|---|
| 273 | fi |
|---|
| 274 | if [ \$do_resume = 0 ]; then |
|---|
| 275 | xnu_uuid ${OSXUUID} uuid |
|---|
| 276 | if [ -f /Extra/DSDT.aml ]; then |
|---|
| 277 | acpi -e /Extra/DSDT.aml |
|---|
| 278 | fi |
|---|
| 279 | $1 /mach_kernel boot-uuid=\${uuid} rd=*uuid |
|---|
| 280 | if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then |
|---|
| 281 | xnu_mkext /System/Library/Extensions.mkext |
|---|
| 282 | else |
|---|
| 283 | xnu_kextdir /System/Library/Extensions |
|---|
| 284 | fi |
|---|
| 285 | if [ -f /Extra/Extensions.mkext ]; then |
|---|
| 286 | xnu_mkext /Extra/Extensions.mkext |
|---|
| 287 | fi |
|---|
| 288 | if [ -d /Extra/Extensions ]; then |
|---|
| 289 | xnu_kextdir /Extra/Extensions |
|---|
| 290 | fi |
|---|
| 291 | if [ -f /Extra/devprop.bin ]; then |
|---|
| 292 | xnu_devprop_load /Extra/devprop.bin |
|---|
| 293 | fi |
|---|
| 294 | if [ -f /Extra/splash.jpg ]; then |
|---|
| 295 | insmod jpeg |
|---|
| 296 | xnu_splash /Extra/splash.jpg |
|---|
| 297 | fi |
|---|
| 298 | if [ -f /Extra/splash.png ]; then |
|---|
| 299 | insmod png |
|---|
| 300 | xnu_splash /Extra/splash.png |
|---|
| 301 | fi |
|---|
| 302 | if [ -f /Extra/splash.tga ]; then |
|---|
| 303 | insmod tga |
|---|
| 304 | xnu_splash /Extra/splash.tga |
|---|
| 305 | fi |
|---|
| 306 | fi |
|---|
| 307 | } |
|---|
| 308 | EOF |
|---|
| 309 | } |
|---|
| 310 | |
|---|
| 311 | wubi= |
|---|
| 312 | |
|---|
| 313 | for OS in ${OSPROBED} ; do |
|---|
| 314 | DEVICE="`echo ${OS} | cut -d ':' -f 1`" |
|---|
| 315 | LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`" |
|---|
| 316 | LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`" |
|---|
| 317 | BOOT="`echo ${OS} | cut -d ':' -f 4`" |
|---|
| 318 | |
|---|
| 319 | if [ -z "${LONGNAME}" ] ; then |
|---|
| 320 | LONGNAME="${LABEL}" |
|---|
| 321 | fi |
|---|
| 322 | |
|---|
| 323 | echo "Found ${LONGNAME} on ${DEVICE}" >&2 |
|---|
| 324 | |
|---|
| 325 | case ${BOOT} in |
|---|
| 326 | chain) |
|---|
| 327 | |
|---|
| 328 | case ${LONGNAME} in |
|---|
| 329 | Windows*) |
|---|
| 330 | if [ -z "$wubi" ]; then |
|---|
| 331 | if [ -x /usr/share/lupin-support/grub-mkimage ] && \ |
|---|
| 332 | /usr/share/lupin-support/grub-mkimage --test; then |
|---|
| 333 | wubi=yes |
|---|
| 334 | else |
|---|
| 335 | wubi=no |
|---|
| 336 | fi |
|---|
| 337 | fi |
|---|
| 338 | if [ "$wubi" = yes ]; then |
|---|
| 339 | echo "Skipping ${LONGNAME} on Wubi system" >&2 |
|---|
| 340 | continue |
|---|
| 341 | fi |
|---|
| 342 | ;; |
|---|
| 343 | esac |
|---|
| 344 | #adv |
|---|
| 345 | LABELCLASS=$(echo "${LONGNAME}" | awk '{print tolower($1$2);}') |
|---|
| 346 | |
|---|
| 347 | found_other_os=1 |
|---|
| 348 | cat << EOF |
|---|
| 349 | menuentry "${LONGNAME} (on ${DEVICE})" --class $LABELCLASS --class windows { |
|---|
| 350 | EOF |
|---|
| 351 | save_default_entry | sed -e "s/^/\t/" |
|---|
| 352 | #ADV prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" |
|---|
| 353 | OG_prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" |
|---|
| 354 | |
|---|
| 355 | case ${LONGNAME} in |
|---|
| 356 | Windows\ Vista*|Windows\ 7*|Windows\ Server\ 2008*) |
|---|
| 357 | ;; |
|---|
| 358 | *) |
|---|
| 359 | #ADV cat << EOF |
|---|
| 360 | #ADV drivemap -s (hd0) \${root} |
|---|
| 361 | #ADV EOF |
|---|
| 362 | ;; |
|---|
| 363 | esac |
|---|
| 364 | |
|---|
| 365 | cat <<EOF |
|---|
| 366 | chainloader +1 |
|---|
| 367 | } |
|---|
| 368 | EOF |
|---|
| 369 | ;; |
|---|
| 370 | efi) |
|---|
| 371 | |
|---|
| 372 | found_other_os=1 |
|---|
| 373 | EFIPATH=${DEVICE#*@} |
|---|
| 374 | DEVICE=${DEVICE%@*} |
|---|
| 375 | onstr="$(gettext_printf "(on %s)" "${DEVICE}")" |
|---|
| 376 | cat << EOF |
|---|
| 377 | menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' { |
|---|
| 378 | EOF |
|---|
| 379 | save_default_entry | sed -e "s/^/\t/" |
|---|
| 380 | #ADV prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" |
|---|
| 381 | OG_prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" |
|---|
| 382 | |
|---|
| 383 | cat <<EOF |
|---|
| 384 | chainloader ${EFIPATH} |
|---|
| 385 | } |
|---|
| 386 | EOF |
|---|
| 387 | ;; |
|---|
| 388 | linux) |
|---|
| 389 | KERNELPARAM="" |
|---|
| 390 | #linuxprobed detecta todos los kernels de una partición. |
|---|
| 391 | LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`" |
|---|
| 392 | #esta opcion de linuxprobe solo interpreta el primer kernel detectado de la partición |
|---|
| 393 | #Si queremos que autoincluya todos los kernels hay que comentar esta filtrado de LINUXPROBED |
|---|
| 394 | LINUXPROBED=$(echo $LINUXPROBED | awk '{ print $1}') |
|---|
| 395 | prepare_boot_cache= |
|---|
| 396 | # echo "ADV listado de los kerenel encontrados linux-boot-prober ${DEVICE} $LINUXPROBED" |
|---|
| 397 | for LINUX in ${LINUXPROBED} ; do |
|---|
| 398 | LINUX=$LINUXPROBED |
|---|
| 399 | LROOT="`echo ${LINUX} | cut -d ':' -f 1`" |
|---|
| 400 | LBOOT="`echo ${LINUX} | cut -d ':' -f 2`" |
|---|
| 401 | LLABEL="`echo ${LINUX} | cut -d ':' -f 3 | tr '^' ' '`" |
|---|
| 402 | LKERNEL="`echo ${LINUX} | cut -d ':' -f 4`" |
|---|
| 403 | LINITRD="`echo ${LINUX} | cut -d ':' -f 5`" |
|---|
| 404 | LPARAMS="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`" |
|---|
| 405 | # En los parámetros cambiamos el UUID por el valor de LROOT |
|---|
| 406 | UUID=$(blkid -s UUID -o value $LROOT) |
|---|
| 407 | LPARAMS="$(echo $LPARAMS | sed "s|UUID=$UUID|$LROOT|g")" |
|---|
| 408 | if [ -z "${LLABEL}" ] ; then |
|---|
| 409 | LLABEL="${LONGNAME}" |
|---|
| 410 | fi |
|---|
| 411 | |
|---|
| 412 | if [ "${LROOT}" != "${LBOOT}" ]; then |
|---|
| 413 | LKERNEL="${LKERNEL#/boot}" |
|---|
| 414 | LINITRD="${LINITRD#/boot}" |
|---|
| 415 | fi |
|---|
| 416 | |
|---|
| 417 | found_other_os=1 |
|---|
| 418 | LABELCLASS=$(echo "${LLABEL}" | awk '{print tolower($1);}') |
|---|
| 419 | cat << EOF |
|---|
| 420 | menuentry "${LLABEL} (on ${DEVICE})" --class $LABELCLASS --class linux --class os { |
|---|
| 421 | EOF |
|---|
| 422 | save_default_entry | sed -e "s/^/\t/" |
|---|
| 423 | if [ -z "${prepare_boot_cache}" ]; then |
|---|
| 424 | #ADV prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | sed -e "s/^/\t/")" |
|---|
| 425 | prepare_boot_cache="$(OG_prepare_grub_to_access_device ${LBOOT} | sed -e "s/^/\t/")" |
|---|
| 426 | fi |
|---|
| 427 | printf '%s\n' "${prepare_boot_cache}" |
|---|
| 428 | if [ "$LABELCLASS" == "opengnsys" ]; then |
|---|
| 429 | KERNELPARAM=$(cat /proc/cmdline) |
|---|
| 430 | fi |
|---|
| 431 | cat << EOF |
|---|
| 432 | linux ${LKERNEL} ${LPARAMS} ${KERNELPARAM} |
|---|
| 433 | EOF |
|---|
| 434 | if [ -n "${LINITRD}" ] ; then |
|---|
| 435 | cat << EOF |
|---|
| 436 | initrd ${LINITRD} |
|---|
| 437 | EOF |
|---|
| 438 | fi |
|---|
| 439 | cat << EOF |
|---|
| 440 | } |
|---|
| 441 | EOF |
|---|
| 442 | done |
|---|
| 443 | ;; |
|---|
| 444 | macosx) |
|---|
| 445 | OSXUUID="`grub-probe --target=fs_uuid --device ${DEVICE} 2> /dev/null`" |
|---|
| 446 | osx_entry xnu_kernel 32 |
|---|
| 447 | osx_entry xnu_kernel64 64 |
|---|
| 448 | ;; |
|---|
| 449 | hurd) |
|---|
| 450 | found_other_os=1 |
|---|
| 451 | cat << EOF |
|---|
| 452 | menuentry "${LONGNAME} (on ${DEVICE})" --class hurd --class gnu --class os { |
|---|
| 453 | EOF |
|---|
| 454 | save_default_entry | sed -e "s/^/\t/" |
|---|
| 455 | prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" |
|---|
| 456 | grub_device="`${grub_probe} --device ${DEVICE} --target=drive`" |
|---|
| 457 | mach_device="`echo "${grub_device}" | sed -e 's/(\(hd.*\),msdos\(.*\))/\1s\2/'`" |
|---|
| 458 | grub_fs="`${grub_probe} --device ${DEVICE} --target=fs`" |
|---|
| 459 | case "${grub_fs}" in |
|---|
| 460 | *fs) hurd_fs="${grub_fs}" ;; |
|---|
| 461 | *) hurd_fs="${grub_fs}fs" ;; |
|---|
| 462 | esac |
|---|
| 463 | cat << EOF |
|---|
| 464 | multiboot /boot/gnumach.gz root=device:${mach_device} |
|---|
| 465 | module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\ |
|---|
| 466 | --multiboot-command-line='\${kernel-command-line}' \\ |
|---|
| 467 | --host-priv-port='\${host-port}' \\ |
|---|
| 468 | --device-master-port='\${device-port}' \\ |
|---|
| 469 | --exec-server-task='\${exec-task}' -T typed '\${root}' \\ |
|---|
| 470 | '\$(task-create)' '\$(task-resume)' |
|---|
| 471 | module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)' |
|---|
| 472 | } |
|---|
| 473 | EOF |
|---|
| 474 | ;; |
|---|
| 475 | *) |
|---|
| 476 | echo " ${LONGNAME} is not yet supported by grub-mkconfig." >&2 |
|---|
| 477 | ;; |
|---|
| 478 | esac |
|---|
| 479 | done |
|---|
| 480 | |
|---|
| 481 | adjust_timeout |
|---|
| 482 | |
|---|
| 483 | rm /opt/opengnsys/cache/etc/lsb-release &>/dev/null |
|---|