summaryrefslogtreecommitdiff
path: root/update-initramfs
diff options
context:
space:
mode:
authormaximilian attems <maks@debian.org>2006-11-02 09:30:03 +0100
committermaximilian attems <maks@debian.org>2006-11-02 09:30:03 +0100
commitefa60794a8a0290ec3972aca23b3ab5f92c3175a (patch)
tree51bc79c73a507893b347ad43b973723eb8945f84 /update-initramfs
parentdc67493c8b72ebb4a360194a13c74a13d06def52 (diff)
downloadinitramfs-tools-efa60794a8a0290ec3972aca23b3ab5f92c3175a.tar.gz
initramfs-tools-efa60794a8a0290ec3972aca23b3ab5f92c3175a.zip
- enhance mbr_check()
- fix /boot ro check - create fb devices unconditionaly
Diffstat (limited to 'update-initramfs')
-rwxr-xr-xupdate-initramfs40
1 files changed, 33 insertions, 7 deletions
diff --git a/update-initramfs b/update-initramfs
index c112211..0fea63c 100755
--- a/update-initramfs
+++ b/update-initramfs
@@ -127,7 +127,8 @@ generate_initramfs()
# lilo call
run_lilo()
{
- lilo -t > /dev/null
+ # suppress errors on test run
+ lilo -t > /dev/null 2>&1
if [ $? -eq 0 ]; then
lilo
fi
@@ -136,11 +137,33 @@ run_lilo()
# check if lilo is on mbr
mbr_check()
{
+ # check out lilo.conf for validity
boot=$(awk -F = '/^boot=/{ print $2}' /etc/lilo.conf)
[ -z "${boot}" ] && return 0
+ case ${boot} in
+ /dev/md*)
+ if [ -r /proc/mdstat ]; then
+ MD=${boot#/dev/}
+ boot="/dev/$(awk "/^${MD}/{print substr(\$5, 1, 3)}" \
+ /proc/mdstat)"
+ fi
+ ;;
+ esac
[ ! -r "${boot}" ] && return 0
- dd if="${boot}" bs=512 skip=0 count=1 2> /dev/null | grep -q LILO
- [ $? -eq 0 ] && run_lilo && return 0
+ dd if="${boot}" bs=512 skip=0 count=1 2> /dev/null | grep -q LILO \
+ && run_lilo && return 0
+
+ # try to discover grub and be happy
+ [ -r /boot/grub/menu.lst ] \
+ && groot=$(awk '/^root/{print substr($2, 2, 3); exit}' \
+ /boot/grub/menu.lst)
+ [ -e /boot/grub/device.map ] && [ -n "${groot}" ] \
+ && dev=$(awk "/${groot}/{ print \$NF}" /boot/grub/device.map)
+ [ -n "${dev}" ] && [ -r ${dev} ] \
+ && dd if="${dev}" bs=512 skip=0 count=1 2> /dev/null \
+ | grep -q GRUB && return 0
+
+ # no idea which bootloader is used
echo
echo "WARNING: grub and lilo installed."
echo "If you use grub as bootloader everything is fine."
@@ -151,17 +174,19 @@ mbr_check()
# Invoke bootloader
run_bootloader()
{
- # only run lilo if no grub is around
- # or if "do_bootloader = yes" is set
+ # if both lilo and grub around, figure out if lilo needs to be run
if [ -x /sbin/grub ] || [ -e /boot/grub/menu.lst ] \
|| [ -x /usr/sbin/grub ]; then
if [ -e /etc/lilo.conf ] && [ -x /sbin/lilo ]; then
[ -r "${KPKGCONF}" ] && \
- do_b=$(awk '/bootloader/{print $3}' "${KPKGCONF}")
+ do_b=$(awk '/^do_bootloader/{print $3}' "${KPKGCONF}")
if [ "${do_b}" = "yes" ] || [ "${do_b}" = "Yes" ] \
|| [ "${do_b}" = "YES" ]; then
run_lilo
return 0
+ elif [ "${do_b}" = "no" ] || [ "${do_b}" = "No" ] \
+ || [ "${do_b}" = "NO" ]; then
+ return 0
else
mbr_check
return 0
@@ -203,7 +228,8 @@ delete_sha1()
ro_boot_check()
{
[ -r /proc/mounts ] || return 0
- boot_opts=$(awk '/boot/{if (match($4, /ro/)) print "ro"}' /proc/mounts)
+ boot_opts=$(awk '/boot/{if (match($4, /ro/) && $2 == "/boot")
+ print "ro"}' /proc/mounts)
if [ -n "${boot_opts}" ]; then
echo "WARNING: /boot is ro mounted."
echo "update-initramfs: Not updating ${initramfs}"