diff options
author | Victor Lowther <victor.lowther@gmail.com> | 2010-06-09 10:52:15 -0500 |
---|---|---|
committer | Victor Lowther <victor.lowther@gmail.com> | 2010-07-23 15:57:07 -0500 |
commit | 5a8e472335e58f3e2310b8d8161384af95f4c2a6 (patch) | |
tree | 6537ab71214243ed349bb55f903a864f4f799c1d /functions | |
parent | 3ddbc5dbde6cb92b1058a10c11c31accf756dcac (diff) | |
download | initscripts-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-- | functions | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -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 # ############################### |