Ledger Nano X - The secure hardware wallet
SHARE
TWEET

/mnt/gentoo/etc/grub.d/30_os-prober

digrouz Jan 16th, 2012 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cat /mnt/gentoo/etc/grub.d/30_os-prober
  2. #! /bin/sh
  3. set -e
  4.  
  5. # grub-mkconfig helper script.
  6. # Copyright (C) 2006,2007,2008,2009  Free Software Foundation, Inc.
  7. #
  8. # GRUB is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # GRUB is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  20.  
  21. prefix=/usr
  22. exec_prefix=${prefix}
  23. libdir=/lib64
  24.  
  25. . ${libdir}/grub/grub-mkconfig_lib
  26.  
  27. if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
  28.   exit 0
  29. fi
  30.  
  31. if [ -z "`which os-prober 2> /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then
  32.   # missing os-prober and/or linux-boot-prober
  33.   exit 0
  34. fi
  35.  
  36. OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`"
  37. if [ -z "${OSPROBED}" ] ; then
  38.   # empty os-prober output, nothing doing
  39.   exit 0
  40. fi
  41.  
  42. osx_entry() {
  43.         cat << EOF
  44. menuentry "${LONGNAME} (${2}-bit) (on ${DEVICE})" --class osx --class darwin --class os {
  45. EOF
  46.         save_default_entry | sed -e "s/^/\t/"
  47.         prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
  48.         cat << EOF
  49.         load_video
  50.         set do_resume=0
  51.         if [ /var/vm/sleepimage -nt10 / ]; then
  52.            if xnu_resume /var/vm/sleepimage; then
  53.              set do_resume=1
  54.            fi
  55.         fi
  56.         if [ \$do_resume = 0 ]; then
  57.            xnu_uuid ${OSXUUID} uuid
  58.            if [ -f /Extra/DSDT.aml ]; then
  59.               acpi -e /Extra/DSDT.aml
  60.            fi
  61.            $1 /mach_kernel boot-uuid=\${uuid} rd=*uuid
  62.            if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
  63.               xnu_mkext /System/Library/Extensions.mkext
  64.            else
  65.               xnu_kextdir /System/Library/Extensions
  66.            fi
  67.            if [ -f /Extra/Extensions.mkext ]; then
  68.               xnu_mkext /Extra/Extensions.mkext
  69.            fi
  70.            if [ -d /Extra/Extensions ]; then
  71.               xnu_kextdir /Extra/Extensions
  72.            fi
  73.            if [ -f /Extra/devprop.bin ]; then
  74.               xnu_devprop_load /Extra/devprop.bin
  75.            fi
  76.            if [ -f /Extra/splash.jpg ]; then
  77.               insmod jpeg
  78.               xnu_splash /Extra/splash.jpg
  79.            fi
  80.            if [ -f /Extra/splash.png ]; then
  81.               insmod png
  82.               xnu_splash /Extra/splash.png
  83.            fi
  84.            if [ -f /Extra/splash.tga ]; then
  85.               insmod tga
  86.               xnu_splash /Extra/splash.tga
  87.            fi
  88.         fi
  89. }
  90. EOF
  91. }
  92.  
  93. for OS in ${OSPROBED} ; do
  94.   DEVICE="`echo ${OS} | cut -d ':' -f 1`"
  95.   LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
  96.   LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
  97.   BOOT="`echo ${OS} | cut -d ':' -f 4`"
  98.  
  99.   if [ -z "${LONGNAME}" ] ; then
  100.     LONGNAME="${LABEL}"
  101.   fi
  102.  
  103.   echo "Found ${LONGNAME} on ${DEVICE}" >&2
  104.  
  105.   case ${BOOT} in
  106.     chain)
  107.  
  108.       cat << EOF
  109. menuentry "${LONGNAME} (on ${DEVICE})" --class windows --class os {
  110. EOF
  111.       save_default_entry | sed -e "s/^/\t/"
  112.       prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
  113.  
  114.       case ${LONGNAME} in
  115.         Windows\ Vista*|Windows\ 7*|Windows\ Server\ 2008*)
  116.         ;;
  117.         *)
  118.           cat << EOF
  119.         drivemap -s (hd0) \${root}
  120. EOF
  121.         ;;
  122.       esac
  123.  
  124.       cat <<EOF
  125.         chainloader +1
  126. }
  127. EOF
  128.     ;;
  129.     linux)
  130.       LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
  131.       prepare_boot_cache=
  132.  
  133.       for LINUX in ${LINUXPROBED} ; do
  134.         LROOT="`echo ${LINUX} | cut -d ':' -f 1`"
  135.         LBOOT="`echo ${LINUX} | cut -d ':' -f 2`"
  136.         LLABEL="`echo ${LINUX} | cut -d ':' -f 3 | tr '^' ' '`"
  137.         LKERNEL="`echo ${LINUX} | cut -d ':' -f 4`"
  138.         LINITRD="`echo ${LINUX} | cut -d ':' -f 5`"
  139.         LPARAMS="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`"
  140.  
  141.         if [ -z "${LLABEL}" ] ; then
  142.           LLABEL="${LONGNAME}"
  143.         fi
  144.  
  145.         if [ "${LROOT}" != "${LBOOT}" ]; then
  146.           LKERNEL="${LKERNEL#/boot}"
  147.           LINITRD="${LINITRD#/boot}"
  148.         fi
  149.  
  150.         cat << EOF
  151. menuentry "${LLABEL} (on ${DEVICE})" --class gnu-linux --class gnu --class os {
  152. EOF
  153.         save_default_entry | sed -e "s/^/\t/"
  154.         if [ -z "${prepare_boot_cache}" ]; then
  155.           prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | sed -e "s/^/\t/")"
  156.         fi
  157.         printf '%s\n' "${prepare_boot_cache}"
  158.         cat <<  EOF
  159.         linux ${LKERNEL} ${LPARAMS}
  160. EOF
  161.         if [ -n "${LINITRD}" ] ; then
  162.           cat << EOF
  163.         initrd ${LINITRD}
  164. EOF
  165.         fi
  166.         cat << EOF
  167. }
  168. EOF
  169.       done
  170.     ;;
  171.     macosx)
  172.       OSXUUID="`${grub_probe} --target=fs_uuid --device ${DEVICE} 2> /dev/null`"
  173.       osx_entry xnu_kernel 32
  174.       osx_entry xnu_kernel64 64
  175.     ;;
  176.     hurd)
  177.       cat << EOF
  178. menuentry "${LONGNAME} (on ${DEVICE})" --class hurd --class gnu --class os {
  179. EOF
  180.       save_default_entry | sed -e "s/^/\t/"
  181.       prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
  182.       grub_device="`${grub_probe} --device ${DEVICE} --target=drive`"
  183.       mach_device="`echo "${grub_device}" | sed -e 's/(\(hd.*\),msdos\(.*\))/\1s\2/'`"
  184.       grub_fs="`${grub_probe} --device ${DEVICE} --target=fs`"
  185.       case "${grub_fs}" in
  186.         *fs)    hurd_fs="${grub_fs}" ;;
  187.         *)      hurd_fs="${grub_fs}fs" ;;
  188.       esac
  189.       cat << EOF
  190.         multiboot /boot/gnumach.gz root=device:${mach_device}
  191.         module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
  192.                         --multiboot-command-line='\${kernel-command-line}' \\
  193.                         --host-priv-port='\${host-port}' \\
  194.                         --device-master-port='\${device-port}' \\
  195.                         --exec-server-task='\${exec-task}' -T typed '\${root}' \\
  196.                         '\$(task-create)' '\$(task-resume)'
  197.         module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
  198. }
  199. EOF
  200.     ;;
  201.     *)
  202.       echo "  ${LONGNAME} is not yet supported by grub-mkconfig." >&2
  203.     ;;
  204.   esac
  205. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top