Reading extlinux defaults file in all extlinux-update subscripts.
[syslinux-debian/hramrach.git] / debian / local / extlinux.d / 0010-linux
blob94c7bc0279c48e399afd570c711ab5ff57234433
1 #!/bin/sh
3 ## Copyright (C) 2006-2013 Daniel Baumann <mail@daniel-baumann.ch>
4 ##
5 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
6 ## This is free software, and you are welcome to redistribute it
7 ## under certain conditions; see COPYING for details.
10 set -e
12 . /usr/share/extlinux/extlinux-update.sh
14 . /etc/default/extlinux
16 if ! ls /boot/vmlinuz* 2>&1
17 then
18 echo "I: /boot/vmlinuz* - No such files: Skipping ${_EXTLINUX_DIRECTORY}/linux.cfg"
19 exit 0
22 # Create linux.cfg
23 _CONFIG="\
24 ## ${_EXTLINUX_DIRECTORY}/linux.cfg
26 ## IMPORTANT WARNING
28 ## The configuration of this file is generated automatically.
29 ## Do not edit this file manually, use: extlinux-update
34 # Find linux versions
35 _VERSIONS="$(cd /boot && ls vmlinuz-* | grep -v .dpkg-tmp | sed -e 's|vmlinuz-||g' | sort -Vr)"
37 if [ "$(stat --printf %d /)" = "$(stat --printf %d /boot)" ]
38 then
39 # / and /boot are on the same filesystem
40 _BOOT_DIRECTORY="/boot"
41 else
42 # / and /boot are not on the same filesystem
43 _BOOT_DIRECTORY=""
47 for _VERSION in ${_VERSIONS}
49 echo "P: Writing config for /boot/vmlinuz-${_VERSION}..."
51 _NUMBER="${_NUMBER:-0}"
52 _ENTRY="${_ENTRY:-1}"
54 if [ -e /boot/initrd.img-${_VERSION} ]
55 then
56 _INITRD="initrd=${_BOOT_DIRECTORY}/initrd.img-${_VERSION}"
57 else
58 _INITRD=""
61 if echo ${EXTLINUX_ALTERNATIVES} | grep -q default
62 then
63 # Writing default entry
64 _CONFIG="${_CONFIG}
66 label l${_NUMBER}
67 menu label ${EXTLINUX_MENU_LABEL} ${_VERSION}"
69 if [ "${EXTLINUX_DEFAULT}" = "l${_NUMBER}" ]
70 then
71 _CONFIG="${_CONFIG}
72 menu default"
75 _CONFIG="${_CONFIG}
76 linux ${_BOOT_DIRECTORY}/vmlinuz-${_VERSION}
77 append ${_INITRD} ${EXTLINUX_ROOT} ${EXTLINUX_PARAMETERS}"
80 if echo ${EXTLINUX_ALTERNATIVES} | grep -q live
81 then
82 # Writing live entry
83 _CONFIG="${_CONFIG}
85 label l${_NUMBER}l
86 menu label ${EXTLINUX_MENU_LABEL} ${_VERSION} (live mode)"
88 if [ "${EXTLINUX_DEFAULT}" = "l${_NUMBER}l" ]
89 then
90 _CONFIG="${_CONFIG}
91 menu default"
94 _CONFIG="${_CONFIG}
95 linux ${_BOOT_DIRECTORY}/vmlinuz-${_VERSION}
96 append ${_INITRD} ${EXTLINUX_ROOT} ${EXTLINUX_PARAMETERS} boot=live plainroot
97 text help
98 This option boots the system into live mode (non-persistent)
99 endtext"
102 if echo ${EXTLINUX_ALTERNATIVES} | grep -q recovery
103 then
104 # Writing recovery entry
105 _CONFIG="${_CONFIG}
107 label l${_NUMBER}r
108 menu label ${EXTLINUX_MENU_LABEL} ${_VERSION} (recovery mode)"
110 if [ "${EXTLINUX_DEFAULT}" = "l${_NUMBER}r" ]
111 then
112 _CONFIG="${_CONFIG}
113 menu default"
116 _CONFIG="${_CONFIG}
117 linux ${_BOOT_DIRECTORY}/vmlinuz-${_VERSION}
118 append ${_INITRD} ${EXTLINUX_ROOT} $(echo ${EXTLINUX_PARAMETERS} | sed -e 's| quiet||') single
119 text help
120 This option boots the system into recovery mode (single-user)
121 endtext"
124 _NUMBER="$((${_NUMBER} + 1))"
126 if [ "${EXTLINUX_ENTRIES}" = "${_ENTRY}" ]
127 then
128 break
130 done
132 _NUMBER=""
134 Update "${_EXTLINUX_DIRECTORY}/linux.cfg" "${_CONFIG}"