From: Victor Lowther Date: Sat, 30 May 2009 03:14:31 +0000 (-0500) Subject: Update check scripts in modules to make them work again. X-Git-Tag: 0.1~151 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=66ac3cd1f08dcb5774c61aa51ba440c5ae85c7ad;p=thirdparty%2Fdracut.git Update check scripts in modules to make them work again. Also got rid of "dracutmodules=hostonly". We have --hostonly, and it does the same thing. --- diff --git a/dracut b/dracut index dba681717..f25cf8504 100755 --- a/dracut +++ b/dracut @@ -83,16 +83,9 @@ fi dracutfunctions=$dsrc/dracut-functions export dracutfunctions -# this logic is weird and convoluted. We should simplify it. -# seriously, wtf? +# This is kinda legacy -- eventually it should go away. case $dracutmodules in - ""|auto) - dracutmodules="all" - ;; - hostonly) - dracutmodules="all" - hostonly="-H" - ;; + ""|auto) dracutmodules="all" ;; esac [[ $2 ]] && kernel=$2 || kernel=$(uname -r) @@ -118,15 +111,20 @@ for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot tmp dev/pts var/ mkdir -p "$initdir/$d"; done -# check all our modules to see if they should be sourced +# check all our modules to see if they should be sourced. +# This builds a list of modules that we will install next. check_modules #source our modules. for moddir in "$dsrc/modules.d"/[0-9][0-9]*; do mod=${moddir##*/}; mod=${mod#[0-9][0-9]} - strstr "$mods_to_load" " $mod " && . "$moddir/install" + if strstr "$mods_to_load" " $mod "; then + . "$moddir/install" + mods_to_load=${mods_to_load// $mod /} + fi done unset moddir +echo $mods_to_load ## final stuff that has to happen diff --git a/modules.d/10redhat-i18n/check b/modules.d/10redhat-i18n/check index 3e98c3694..650cb40b2 100755 --- a/modules.d/10redhat-i18n/check +++ b/modules.d/10redhat-i18n/check @@ -1,2 +1,2 @@ -#!/bin/bash +#!/bin/sh [ -f /etc/redhat-release ] \ No newline at end of file diff --git a/modules.d/40nfsroot/check b/modules.d/40nfsroot/check index 4abc23fea..0625322ee 100755 --- a/modules.d/40nfsroot/check +++ b/modules.d/40nfsroot/check @@ -1,5 +1,11 @@ #!/bin/sh +# We depend on network modules being loaded [ "$1" = "-d" ] && echo network -[ "$1" = "-H" ] && ! egrep -q '/ nfs[34 ]' /proc/mounts && exit 1 + +# If hostonly was requested, fail the check if we are not actually +# booting from root. +[ "$1" = "-h" ] && ! egrep -q '/ nfs[34 ]' /proc/mounts && exit 1 + +# If our prerequisites are not met, fail anyways. which rpcbind rpc.statd mount.nfs mount.nfs4 umount >/dev/null 2>&1 || exit 1 exit 0 diff --git a/modules.d/90crypt/check b/modules.d/90crypt/check index 8457f8536..2297e0f98 100755 --- a/modules.d/90crypt/check +++ b/modules.d/90crypt/check @@ -1,8 +1,12 @@ #!/bin/sh +# if cryptsetup is not installed, then we cannot support encrypted devices. which cryptsetup >/dev/null 2>&1 || exit 1 -if [ "$1" = "-H" ]; then +# hostonly checking should only return true if root is on a LUKS device +# in some way, but I am too lazy to figure out how to do that. +# Instead, fail if we do not have a LUKS device in use somewhere. +if [ "$1" = "-h" ] ; then blkid | grep -q crypt_LUKS || exit 1 fi diff --git a/modules.d/90dmraid/check b/modules.d/90dmraid/check index 67051db88..45e14052e 100755 --- a/modules.d/90dmraid/check +++ b/modules.d/90dmraid/check @@ -1,7 +1,13 @@ -#!/bin/sh +#!/bin/bash + +# if we don't have dmraid installed on the host system, no point +# in trying to support it in the initramfs. which dmraid >/dev/null 2>&1 || exit 1 -if [ "$1" = "-H" ]; then +# Hostonly checking should really fail if the root device is not on a +# dmraid volume. I am lazy. Therefore, fail the hostonly check only +# if we are not using dmraid right now. +if [[ $1 = -h ]]; then dmraid -r | grep -q ok || exit 1 fi diff --git a/modules.d/90kernel-modules-loaded/check b/modules.d/90kernel-modules-loaded/check index 44be0a010..2d4bd6f4b 100755 --- a/modules.d/90kernel-modules-loaded/check +++ b/modules.d/90kernel-modules-loaded/check @@ -1,3 +1,6 @@ #!/bin/sh -[ "$1" = "-H" ] && exit 1 +# Install all loaded modules in the initramfs if we are building a +# hostonly initramfs +[[ $1 = -h ]] + diff --git a/modules.d/90lvm/check b/modules.d/90lvm/check index a5ce6a572..35f9344a1 100755 --- a/modules.d/90lvm/check +++ b/modules.d/90lvm/check @@ -1,7 +1,12 @@ #!/bin/sh + +# No point trying to support lvm if the binaries are missing which lvm >/dev/null 2>&1 || exit 1 -if [ "$1" = "-H" ]; then +# We should really just check to see if root is on a logical volume +# when running in hostonly mode. I am lazy. Therefore, fail the hostonly +# check unless there is a logical volume in use somewhere. +if [ "$1" = "-H" ] || [ "$1" = "--hostonly" ]; then blkid | grep -q lvm2pv || exit 1 fi diff --git a/modules.d/90mdraid/check b/modules.d/90mdraid/check index 0d0605a24..f6a22f10e 100755 --- a/modules.d/90mdraid/check +++ b/modules.d/90mdraid/check @@ -1,7 +1,12 @@ -#!/bin/sh +#!/bin/bash + +# No mdadm? No mdraid support. which mdadm >/dev/null 2>&1 || exit 1 -if [ "$1" = "-H" ]; then +# We were asked to run in hostonly mode, so pass the check only if there +# is an mdraid volume in use somewhere. This should really check to see if +# root is on an mdraid volume only, but I am lazy. +if [[ $1 = -h ]]; then blkid | grep -q linux_raid || exit 1 fi diff --git a/modules.d/95udev-rules.ub810/check b/modules.d/95udev-rules.ub810/check index 36bad42ca..54501f341 100755 --- a/modules.d/95udev-rules.ub810/check +++ b/modules.d/95udev-rules.ub810/check @@ -1,2 +1,3 @@ #!/bin/sh +# if we are not running Ubuntu 8.10, then we don't need to load this module. [ -f /etc/lsb-release ] && grep -q "Ubuntu 8.10" /etc/lsb-release 2>/dev/null