aboutsummaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorVictor Lowther <victor.lowther@gmail.com>2010-06-09 10:52:15 -0500
committerVictor Lowther <victor.lowther@gmail.com>2010-07-23 15:57:07 -0500
commit5a8e472335e58f3e2310b8d8161384af95f4c2a6 (patch)
tree6537ab71214243ed349bb55f903a864f4f799c1d /functions
parent3ddbc5dbde6cb92b1058a10c11c31accf756dcac (diff)
downloadinitscripts-5a8e472335e58f3e2310b8d8161384af95f4c2a6.tar.xz
Rewrite /etc/crypttab processing.
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. :(
Diffstat (limited to 'functions')
-rw-r--r--functions34
1 files changed, 34 insertions, 0 deletions
diff --git a/functions b/functions
index 84fed85..b9ba718 100644
--- a/functions
+++ b/functions
@@ -233,6 +233,40 @@ kill_everything() {
run_hook "$1_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[0]}" "${nspo[1]}" "${nspo[2]}" "${nspo[@]:3}" || failed=1
+ done < /etc/crypttab
+ return $failed
+}
+
###############################
# Custom hooks in initscripts #
###############################