Split out reading /etc/crypttab and procssing the individual lines into
their own helper functions, and bashify the resulting shorter code.
Processing this file is still ugly, though.

---
functions | 43 +++++++++++++++++--
rc.shutdown | 36 +++++------------
rc.sysinit | 131 ++++++++++++++++++----------------------------------------
3 files changed, 90 insertions(+), 120 deletions(-)
diff --git a/functions b/functions
index bf6ed45..9ec8b5e 100644
--- a/functions
+++ b/functions
@@ -232,6 +232,40 @@ kill_everything() {
run_hook single_postkillall
}
+activate_vgs() {
+ [[ $USELVM =~ yes|YES && -x /sbin/lvm && -d /sys/block ]] || return
+ # Kernel 2.6.x, LVM2 groups
+ /sbin/modprobe -q dm-mod 2>/dev/null
+ stat_busy "Activating LVM2 groups"
+ if /sbin/lvm vgchange --ignorelockingfailure -a y >/dev/null; then
+ stat_done
+ else
+ stat_fail
+ fi
+}
+
+# Arch cryptsetup packages traditionally contained the binaries
+# /usr/sbin/cryptsetup
+# /sbin/cryptsetup.static
+# By default, initscripts used the /sbin/cryptsetup.static.
+# Newer packages will only have /sbin/cryptsetup and no static binary
+# This ensures maximal compatibility with the old and new layout
+for CS in /sbin/cryptsetup /usr/sbin/cryptsetup
+ /sbin/cryptsetup.static '; do
+ [[ -x $CS ]] && break
+done
+
+read_crypttab() {
+ # $1 = function to call with the split out line from the crypttab
+ local line nspo failed=0
+ while read line; do
+ [[ $line && ${line:0:1} != '#' ]] || continue
+ eval nspo=("${line%#*}")
+ $1 "${nspo[@]}" || failed=1
+ done < /etc/crypttab
+ return $failed
+}
+
###############################
# Custom hooks in initscripts #
###############################
@@ -278,7 +312,7 @@ run_hook() {
[[ $1 ]] || return 1
local func
for func in ${hook_funcs["$1"]}; do
- "${func}"
+ q"${func}"
done
}
@@ -293,13 +327,14 @@ set_consolefont() {
for i in /dev/tty[0-9]*; do
/usr/bin/setfont ${CONSOLEMAP:+-m ${CONSOLEMAP}}
$CONSOLEFONT -C ${i} >/dev/null 2>&1
- done
+ done
if (($? != 0)); then
stat_fail
elif [[ $CONSOLEMAP ]]; then
cat <<"EOF" >>/etc/profile.d/locale.sh
-if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "