Advertisement
Guest User

10linux

a guest
Nov 12th, 2011
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.51 KB | None | 0 0
  1. lauryl@Eridanus /etc/grub.d $ cat 10_linux
  2. #! /bin/sh
  3. set -e
  4.  
  5. # grub-mkconfig helper script.
  6. # Copyright (C) 2006,2007,2008,2009,2010 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. bindir=${exec_prefix}/bin
  24. libdir=${exec_prefix}/lib
  25. . ${libdir}/grub/grub-mkconfig_lib
  26.  
  27. export TEXTDOMAIN=grub
  28. export TEXTDOMAINDIR=${prefix}/share/locale
  29.  
  30. CLASS="--class gnu-linux --class gnu --class os"
  31.  
  32. if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
  33. OS=GNU/Linux
  34. else
  35. OS="${GRUB_DISTRIBUTOR}"
  36. CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
  37. fi
  38.  
  39. # loop-AES arranges things so that /dev/loop/X can be our root device, but
  40. # the initrds that Linux uses don't like that.
  41. case ${GRUB_DEVICE} in
  42. /dev/loop/*|/dev/loop[0-9])
  43. GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
  44. # We can't cope with devices loop-mounted from files here.
  45. case ${GRUB_DEVICE} in
  46. /dev/*) ;;
  47. *) exit 0 ;;
  48. esac
  49. ;;
  50. esac
  51.  
  52. if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
  53. || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
  54. || uses_abstraction "${GRUB_DEVICE}" lvm; then
  55. LINUX_ROOT_DEVICE=${GRUB_DEVICE}
  56. else
  57. LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
  58. fi
  59.  
  60. if [ "x`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2>/dev/null || true`" = xbtrfs ]; then
  61. rootsubvol="`make_system_path_relative_to_its_root /`"
  62. rootsubvol="${rootsubvol#/}"
  63. if [ "x${rootsubvol}" != x ]; then
  64. GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
  65. fi
  66. fi
  67.  
  68. for word in $GRUB_CMDLINE_LINUX_DEFAULT; do
  69. if [ "$word" = splash ]; then
  70. GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT vt.handoff=7"
  71. fi
  72. done
  73.  
  74. # add crashkernel option if we have the required tools
  75. if [ -x "/usr/bin/makedumpfile" ] && [ -x "/sbin/kexec" ]; then
  76. GRUB_CMDLINE_EXTRA="$GRUB_CMDLINE_EXTRA crashkernel=384M-2G:64M,2G-:128M"
  77. fi
  78.  
  79. linux_entry ()
  80. {
  81. os="$1"
  82. version="$2"
  83. recovery="$3"
  84. args="$4"
  85. description="`grep GRUB_TITLE /etc/linuxmint/info | awk -F = '{print $2}'`"
  86. if ${recovery} ; then
  87. title="${description}, ${version} (${GRUB_DEVICE_BOOT}) -- recovery mode"
  88. else
  89. title="${description}, ${version} (${GRUB_DEVICE_BOOT})"
  90. fi
  91. printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}"
  92. cat << EOF
  93. recordfail
  94. EOF
  95. if ! ${recovery} ; then
  96. save_default_entry | sed -e "s/^/\t/"
  97. fi
  98.  
  99. cat << EOF
  100. set gfxpayload=\$linux_gfx_mode
  101. EOF
  102.  
  103. if [ -z "${prepare_boot_cache}" ]; then
  104. prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
  105. fi
  106. printf '%s\n' "${prepare_boot_cache}"
  107. if [ "x$5" != "xquiet" ]; then
  108. message="$(gettext_printf "Loading Linux %s ..." ${version})"
  109. cat << EOF
  110. echo '$message'
  111. EOF
  112. fi
  113. cat << EOF
  114. linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
  115. EOF
  116. if test -n "${initrd}" ; then
  117. if [ "x$5" != "xquiet" ]; then
  118. message="$(gettext_printf "Loading initial ramdisk ...")"
  119. cat << EOF
  120. echo '$message'
  121. EOF
  122. fi
  123. cat << EOF
  124. initrd ${rel_dirname}/${initrd}
  125. EOF
  126. fi
  127. cat << EOF
  128. }
  129. EOF
  130. }
  131.  
  132. list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* ; do
  133. if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
  134. done`
  135. prepare_boot_cache=
  136.  
  137. # Use ELILO's generic "efifb" when it's known to be available.
  138. # FIXME: We need an interface to select vesafb in case efifb can't be used.
  139. if [ "x$GRUB_GFXPAYLOAD_LINUX" != x ]; then
  140. echo "set linux_gfx_mode=$GRUB_GFXPAYLOAD_LINUX"
  141. else
  142. cat << EOF
  143. if [ \${recordfail} != 1 ]; then
  144. if [ -e \${prefix}/gfxblacklist.txt ]; then
  145. if hwmatch \${prefix}/gfxblacklist.txt 3; then
  146. if [ \${match} = 0 ]; then
  147. set linux_gfx_mode=keep
  148. else
  149. set linux_gfx_mode=text
  150. fi
  151. else
  152. set linux_gfx_mode=text
  153. fi
  154. else
  155. set linux_gfx_mode=keep
  156. fi
  157. else
  158. set linux_gfx_mode=text
  159. fi
  160. EOF
  161. fi
  162. cat << EOF
  163. export linux_gfx_mode
  164. if [ "\$linux_gfx_mode" != "text" ]; then load_video; fi
  165. EOF
  166.  
  167. in_submenu=false
  168. while [ "x$list" != "x" ] ; do
  169. linux=`version_find_latest $list`
  170. echo "Found linux image: $linux" >&2
  171. basename=`basename $linux`
  172. dirname=`dirname $linux`
  173. rel_dirname=`make_system_path_relative_to_its_root $dirname`
  174. version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
  175. alt_version=`echo $version | sed -e "s,\.old$,,g"`
  176. linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
  177.  
  178. initrd=
  179. for i in "initrd.img-${version}" "initrd-${version}.img" \
  180. "initrd-${version}" "initramfs-${version}.img" \
  181. "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
  182. "initrd-${alt_version}" "initramfs-${alt_version}.img"; do
  183. if test -e "${dirname}/${i}" ; then
  184. initrd="$i"
  185. break
  186. fi
  187. done
  188.  
  189. initramfs=
  190. for i in "config-${version}" "config-${alt_version}"; do
  191. if test -e "${dirname}/${i}" ; then
  192. initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${dirname}/${i}" | cut -f2 -d= | tr -d \"`
  193. break
  194. fi
  195. done
  196.  
  197. if test -n "${initrd}" ; then
  198. echo "Found initrd image: ${dirname}/${initrd}" >&2
  199. elif test -z "${initramfs}" ; then
  200. # "UUID=" magic is parsed by initrd or initramfs. Since there's
  201. # no initrd or builtin initramfs, it can't work here.
  202. linux_root_device_thisversion=${GRUB_DEVICE}
  203. fi
  204.  
  205. linux_entry "${OS}" "${version}" false \
  206. "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_EXTRA} ${GRUB_CMDLINE_LINUX_DEFAULT}" \
  207. quiet
  208. if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
  209. linux_entry "${OS}" "${version}" true \
  210. "single ${GRUB_CMDLINE_LINUX}"
  211. fi
  212.  
  213. list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
  214.  
  215. if [ "$list" ] && ! $in_submenu; then
  216. echo "submenu \"Previous Linux versions\" {"
  217. in_submenu=:
  218. fi
  219. done
  220.  
  221. if $in_submenu; then
  222. echo "}"
  223. fi
  224.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement