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)
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
-#!/bin/bash
+#!/bin/sh
[ -f /etc/redhat-release ]
\ No newline at end of file
#!/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
#!/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
-#!/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
#!/bin/sh
-[ "$1" = "-H" ] && exit 1
+# Install all loaded modules in the initramfs if we are building a
+# hostonly initramfs
+[[ $1 = -h ]]
+
#!/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
-#!/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
#!/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