aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2012-07-17 16:20:54 +0200
committerTom Gundersen <teg@jklm.no>2012-07-17 16:42:37 +0200
commit804addbf1640438f15229fafa296f49513eb932a (patch)
treef513b2b1ca554dda03bad8d00a55f66fa18b5662
parent476b308f121b934859080e5ca48a93a504aadaf6 (diff)
downloadinitscripts-804addbf1640438f15229fafa296f49513eb932a.tar.xz
cryptsetup: refactor do_lock
This now uses the systemd code, and is in line with do_unlock. Signed-off-by: Tom Gundersen <teg@jklm.no>
-rw-r--r--functions4
-rwxr-xr-xrc.shutdown18
2 files changed, 8 insertions, 14 deletions
diff --git a/functions b/functions
index 9b8d805..3798b79 100644
--- a/functions
+++ b/functions
@@ -511,6 +511,10 @@ do_unlock() {
return $?
}
+do_lock() {
+ status "Detaching encrypted device ${1}" /usr/lib/systemd/systemd-cryptsetup detach "$1" >/dev/null
+}
+
read_crypttab() {
# $1 = function to call with the split out line from the crypttab
local line nspo failed=0
diff --git a/rc.shutdown b/rc.shutdown
index 2d79379..02f5e83 100755
--- a/rc.shutdown
+++ b/rc.shutdown
@@ -55,20 +55,10 @@ run_hook shutdown_postumount
# Kill non-root encrypted partition mappings
if [[ -f /etc/crypttab ]] && type -p cryptsetup >/dev/null; then
- stat_busy "Deactivating encrypted volumes"
- # Maybe someone has LVM on an encrypted block device
- # executing an extra vgchange is errorless
- [[ $USELVM = [Yy][Ee][Ss] ]] && vgchange --sysinit -a n &>/dev/null
- do_lock() {
- stat_append "${1}.."
- if cryptsetup remove "$1" &>/dev/null; then
- stat_append "ok "
- else
- stat_append "failed "
- fi
- }
- read_crypttab do_lock
- stat_done
+ # Maybe someone has LVM on an encrypted block device
+ # executing an extra vgchange is errorless
+ [[ $USELVM = [Yy][Ee][Ss] ]] && vgchange --sysinit -a n &>/dev/null
+ read_crypttab do_lock
fi
[[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) ]] &&