5 _EXTLINUX_DIRECTORY
="/boot/extlinux"
9 # Upate target file using source content
13 _TMPFILE
="${_TARGET}.tmp"
16 echo "${_SOURCE}" > "${_TMPFILE}"
18 if [ -e "${_TARGET}" ] && cmp -s "${_TARGET}" "${_TMPFILE}"
22 # FIXME: should use fsync here
23 echo "P: Updating ${_TARGET}..."
24 mv -f "${_TMPFILE}" "${_TARGET}"
28 # User is unprivileged
29 if [ "$(id -u)" -ne 0 ]
31 echo "E: need root privileges"
35 # Redirect stdout to stderr due Debconf usage
38 # Reading the default file
39 if [ -e /etc
/default
/extlinux
]
41 .
/etc
/default
/extlinux
44 EXTLINUX_UPDATE
="${EXTLINUX_UPDATE:-true}"
46 if [ "${EXTLINUX_UPDATE}" != "true" ]
48 echo "P: extlinux-update is disabled in /etc/default/extlinux."
53 # Checking extlinux directory
54 echo -n "P: Checking for EXTLINUX directory..."
56 # Creating extlinux directory
57 if [ ! -e "${_EXTLINUX_DIRECTORY}" ]
61 echo -n "P: Creating EXTLINUX directory..."
62 mkdir
-p "${_EXTLINUX_DIRECTORY}"
63 echo " done: ${_EXTLINUX_DIRECTORY}"
69 EXTLINUX_ALTERNATIVES
="${EXTLINUX_ALTERNATIVES:-default recovery}"
70 EXTLINUX_DEFAULT
="${EXTLINUX_DEFAULT:-l0}"
71 EXTLINUX_ENTRIES
="${EXTLINUX_ENTRIES:-all}"
72 EXTLINUX_MEMDISK
="${EXTLINUX_MEMDISK:-true}"
73 EXTLINUX_MEMDISK_DIRECTORY
="${EXTLINXU_MEMDISK_DIRECTORY:-/boot}"
75 if [ -z "${EXTLINUX_MENU_LABEL}" ]
77 if [ -x "$(which lsb_release 2>/dev/null)" ]
79 EXTLINUX_MENU_LABEL
="$(lsb_release -i -s) GNU/Linux, kernel"
81 EXTLINUX_MENU_LABEL
="Debian GNU/Linux, kernel"
85 EXTLINUX_OS_PROBER
="${EXTLINUX_OS_PROBER:-true}"
86 EXTLINUX_PARAMETERS
="${EXTLINUX_PARAMETERS:-ro quiet}"
88 if [ -z "${EXTLINUX_ROOT}" ]
94 read _FS_SPEC _FS_FILE _FS_VFSTYPE _FS_MNTOPS _FS_FREQ _FS_PASSNO
<< EOF
98 if [ "${_FS_SPEC}" != "#" ] && [ "${_FS_FILE}" = "/" ]
100 EXTLINUX_ROOT
="root=${_FS_SPEC}"
106 if [ -z "${EXTLINUX_THEME}" ]
108 # Using default menu if available
109 if [ -e /usr
/share
/syslinux
/themes
/debian
/extlinux
]
111 EXTLINUX_THEME
="debian"
113 EXTLINUX_THEME
="none"
117 EXTLINUX_TIMEOUT
="${EXTLINUX_TIMEOUT:-50}"
119 # Writing new default file
120 cat > "/etc/default/extlinux" << EOF
121 ## /etc/default/extlinux - configuration file for extlinux-update(8)
123 EXTLINUX_UPDATE="${EXTLINUX_UPDATE}"
125 EXTLINUX_ALTERNATIVES="${EXTLINUX_ALTERNATIVES}"
126 EXTLINUX_DEFAULT="${EXTLINUX_DEFAULT}"
127 EXTLINUX_ENTRIES="${EXTLINUX_ENTRIES}"
128 EXTLINUX_MEMDISK="${EXTLINUX_MEMDISK}"
129 EXTLINUX_MEMDISK_DIRECTORY="${EXTLINUX_MEMDISK_DIRECTORY}"
130 EXTLINUX_MENU_LABEL="${EXTLINUX_MENU_LABEL}"
131 EXTLINUX_OS_PROBER="${EXTLINUX_OS_PROBER}"
132 EXTLINUX_PARAMETERS="${EXTLINUX_PARAMETERS}"
133 EXTLINUX_ROOT="${EXTLINUX_ROOT}"
134 EXTLINUX_THEME="${EXTLINUX_THEME}"
135 EXTLINUX_TIMEOUT="${EXTLINUX_TIMEOUT}"
140 ## ${_EXTLINUX_DIRECTORY}/linux.cfg
144 ## The configuration of this file is generated automatically.
145 ## Do not edit this file manually, use: extlinux-update
150 # Find linux versions
151 _VERSIONS
="$(cd /boot && ls vmlinuz-* | grep -v .dpkg-tmp | sed -e 's|vmlinuz-||g' | sort -r)"
153 if [ "$(stat --printf %d /)" = "$(stat --printf %d /boot)" ]
155 # / and /boot are on the same filesystem
156 _BOOT_DIRECTORY
="/boot"
158 # / and /boot are not on the same filesystem
163 for _VERSION
in ${_VERSIONS}
165 echo "P: Writing config for /boot/vmlinuz-${_VERSION}..."
167 _NUMBER
="${_NUMBER:-0}"
168 _ENTRY
="${_ENTRY:-1}"
170 if [ -e /boot
/initrd.img-
${_VERSION} ]
172 _INITRD
="initrd=${_BOOT_DIRECTORY}/initrd.img-${_VERSION}"
177 if echo ${EXTLINUX_ALTERNATIVES} |
grep -q default
180 # Writing default entry
184 menu label ${EXTLINUX_MENU_LABEL} ${_VERSION}
185 linux ${_BOOT_DIRECTORY}/vmlinuz-${_VERSION}
186 append ${_INITRD} ${EXTLINUX_ROOT} ${EXTLINUX_PARAMETERS}"
190 if echo ${EXTLINUX_ALTERNATIVES} |
grep -q live
197 menu label ${EXTLINUX_MENU_LABEL} ${_VERSION} (live mode)
198 linux ${_BOOT_DIRECTORY}/vmlinuz-${_VERSION}
199 append ${_INITRD} ${EXTLINUX_ROOT} ${EXTLINUX_PARAMETERS} boot=live plainroot
201 This option boots the system into live mode (non-persistent)
206 if echo ${EXTLINUX_ALTERNATIVES} |
grep -q recovery
209 # Writing recovery entry
213 menu label ${EXTLINUX_MENU_LABEL} ${_VERSION} (recovery mode)
214 linux ${_BOOT_DIRECTORY}/vmlinuz-${_VERSION}
215 append ${_INITRD} ${EXTLINUX_ROOT} $(echo ${EXTLINUX_PARAMETERS} | sed -e 's| quiet||') single
217 This option boots the system into recovery mode (single-user)
222 _NUMBER
="$((${_NUMBER} + 1))"
224 if [ "${EXTLINUX_ENTRIES}" = "${_ENTRY}" ]
232 Update
"${_EXTLINUX_DIRECTORY}/linux.cfg" "${_CONFIG}"
235 if [ "${EXTLINUX_MEMDISK}" = "true" ]
237 if [ ! -e /usr
/lib
/extlinux
/memdisk
]
239 echo "E: /usr/lib/extlinux/memdisk: No such file"
243 cp -f /usr
/lib
/extlinux
/memdisk
"${_EXTLINUX_DIRECTORY}"
247 ## ${_EXTLINUX_DIRECTORY}/memdisk.cfg
251 ## The configuration of this file is generated automatically.
252 ## Do not edit this file manually, use: extlinux-update
257 for _IMAGE
in "${EXTLINUX_MEMDISK_DIRECTORY}"/*.iso
"${EXTLINUX_MEMDISK_DIRECTORY}"/*.img
259 # Skip non-existing files and files matching '^initrd.*'
260 if [ ! -e "${_IMAGE}" ] ||
[ "$(basename ${_IMAGE} | cut -b 1-6)" = "initrd" ]
265 _NUMBER
="${_NUMBER:-0}"
267 echo "P: Writing config for ${_IMAGE}..."
279 if [ -n "${_BOOT_DIRECTORY}" ]
281 # / and /boot are on the same filesystem
282 _MEMDISK_DIRECTORY
="${_EXTLINUX_DIRECTORY}"
284 # / and /boot are not on the same filesystem
285 _MEMDISK_DIRECTORY
="$(echo ${_EXTLINUX_DIRECTORY} | sed -e 's|^/boot||')"
286 _IMAGE
="$(echo ${_IMAGE} | sed -e 's|^/boot||')"
289 # Writing image entry
293 menu label Memdisk, image $(basename ${_IMAGE})
294 linux ${_MEMDISK_DIRECTORY}/memdisk
296 append ${_IMAGE_APPEND}"
298 _NUMBER
="$((${_NUMBER} + 1))"
303 Update
"${_EXTLINUX_DIRECTORY}/memdisk.cfg" "${_CONFIG}"
306 if [ "${EXTLINUX_OS_PROBER}" = "true" ] && [ -x "$(which os-prober 2>/dev/null)" ]
308 if [ ! -e /usr
/lib
/extlinux
/chain.c32
]
310 echo "E: /usr/lib/extlinux/chain.c32: No such file"
314 cp -f /usr
/lib
/extlinux
/chain.c32
"${_EXTLINUX_DIRECTORY}"
316 # Create os-prober.cfg
318 ## ${_EXTLINUX_DIRECTORY}/os-prober.cfg
322 ## The configuration of this file is generated automatically.
323 ## Do not edit this file manually, use: extlinux-update
328 for _OS
in $
(os-prober |
tr ' ' '^' |
paste -s -d ' ')
330 _DEVICE
="$(echo ${_OS} | cut -d ':' -f 1)"
331 _LONGNAME
="$(echo ${_OS} | cut -d ':' -f 2 | tr '^' ' ')"
332 _LABEL
="$(echo ${_OS} | cut -d ':' -f 3 | tr '^' ' ')"
333 _BOOT
="$(echo ${_OS} | cut -d ':' -f 4)"
335 if [ "${_BOOT}" != "chain" ]
340 if [ -z "${_LONGNAME}" ]
342 _LONGNAME
="${_LABEL}"
345 _NUMBER
="${_NUMBER:-0}"
347 echo "P: Writing config for ${_LONGNAME} on ${_DEVICE}..."
349 _DEVICENAME
="$(echo ${_DEVICE} | sed -e 's/^\/dev\/[sh]d//' -e 'y/abcdefghij/0123456789/' -e 's/./& /')"
351 # Writing other os entry
355 menu label Other OS, ${_LONGNAME} (on ${_DEVICE})
357 append hd${_DEVICENAME}"
359 _NUMBER
="$((${_NUMBER} + 1))"
364 Update
"${_EXTLINUX_DIRECTORY}/os-prober.cfg" "${_CONFIG}"
368 # Create the main extlinux.conf file
370 ## ${_EXTLINUX_DIRECTORY}/extlinux.conf
374 ## The configuration of this file is generated automatically.
375 ## Do not edit this file manually, use: extlinux-update
378 default ${EXTLINUX_DEFAULT}
380 timeout ${EXTLINUX_TIMEOUT}
383 if [ -n "${EXTLINUX_THEME}" ] && [ "${EXTLINUX_THEME}" != "none" ]
385 if [ ! -e "/usr/share/syslinux/themes/${EXTLINUX_THEME}/extlinux" ]
387 echo "E: /usr/share/syslinux/themes/${EXTLINUX_THEME}/extlinux: No such file or directory"
390 echo -n "P: Installing ${EXTLINUX_THEME} theme..."
391 rm -rf "${_EXTLINUX_DIRECTORY}/themes/${EXTLINUX_THEME}"
393 mkdir
-p "${_EXTLINUX_DIRECTORY}/themes"
395 EXTLINUX_THEME_ORIG
="$(readlink /usr/share/syslinux/themes/${EXTLINUX_THEME})" || true
397 if [ -n "${EXTLINUX_THEME_ORIG}" ]
399 cp -aL "/usr/share/syslinux/themes/${EXTLINUX_THEME_ORIG}/extlinux" "${_EXTLINUX_DIRECTORY}/themes/${EXTLINUX_THEME_ORIG}"
400 ln -sf "${EXTLINUX_THEME_ORIG}" "${_EXTLINUX_DIRECTORY}/themes/${EXTLINUX_THEME}"
402 cp -aL "/usr/share/syslinux/themes/${EXTLINUX_THEME}/extlinux" "${_EXTLINUX_DIRECTORY}/themes/${EXTLINUX_THEME}"
409 include themes/${EXTLINUX_THEME}/theme.cfg"
417 if [ "${EXTLINUX_MEMDISK}" = "true" ] && [ -e "${_EXTLINUX_DIRECTORY}/memdisk.cfg" ]
425 if [ "${EXTLINUX_OS_PROBER}" = "true" ] && [ -e "${_EXTLINUX_DIRECTORY}/os-prober.cfg" ]
429 include os-prober.cfg"
433 if [ ! -e "${_EXTLINUX_DIRECTORY}/boot.txt" ]
435 echo "Wait 5 seconds or press ENTER to " > "${_EXTLINUX_DIRECTORY}/boot.txt"
439 Update
"${_EXTLINUX_DIRECTORY}/extlinux.conf" "${_CONFIG}"