aboutsummaryrefslogtreecommitdiffstats
path: root/rc.d/init.d/halt
diff options
context:
space:
mode:
authorMiloslav Trmac <mitr@volny.cz>2006-06-01 02:41:11 +0000
committerMiloslav Trmac <mitr@volny.cz>2006-06-01 02:41:11 +0000
commitd8a3e16c701778a2774b54eb238a43b0e51719c5 (patch)
tree0cae42b824c9b25c56e6d7e7a5729fe2aa7d2395 /rc.d/init.d/halt
parent361d52729d1534fdbb454d7abc41069a353b1541 (diff)
downloadinitscripts-d8a3e16c701778a2774b54eb238a43b0e51719c5.tar
initscripts-d8a3e16c701778a2774b54eb238a43b0e51719c5.tar.gz
initscripts-d8a3e16c701778a2774b54eb238a43b0e51719c5.tar.bz2
initscripts-d8a3e16c701778a2774b54eb238a43b0e51719c5.tar.xz
initscripts-d8a3e16c701778a2774b54eb238a43b0e51719c5.zip
Add encrypted swap and non-root filesystem support (#127378, based on
a patch by W. Michael Petullo <redhat@flyn.org> and Debian's cryptsetup package)
Diffstat (limited to 'rc.d/init.d/halt')
-rwxr-xr-xrc.d/init.d/halt32
1 files changed, 31 insertions, 1 deletions
diff --git a/rc.d/init.d/halt b/rc.d/init.d/halt
index 60485da7..e0d269f8 100755
--- a/rc.d/init.d/halt
+++ b/rc.d/init.d/halt
@@ -22,6 +22,21 @@ action() {
echo
}
+halt_crypto() {
+ fnval=0
+ while read dst src key; do
+ [ -z "$dst" -o "${dst#\#}" != "$dst" ] && continue
+ if [ -b "/dev/mapper/$dst" ]; then
+ if /sbin/dmsetup info "$dst" | grep -q '^Open count: *0$'; then
+ /sbin/cryptsetup remove "$dst"
+ else
+ fnval=1
+ fi
+ fi
+ done < /etc/crypttab
+ return $fnval
+}
+
# See how we were called.
case "$0" in
*halt)
@@ -120,7 +135,19 @@ tmpfs=$(awk '$2 ~ /^\/($|proc|dev)/ { next; }
# Turn off swap, then unmount file systems.
[ -f /proc/swaps ] && SWAPS=`awk '! /^Filename/ { print $1 }' /proc/swaps`
-[ -n "$SWAPS" ] && action $"Turning off swap: " swapoff $SWAPS
+if [ -n "$SWAPS" ]; then
+ action $"Turning off swap: " swapoff $SWAPS
+ for dst in $SWAPS; do
+ if [[ "$dst" =~ "^/dev/mapper" ]] \
+ && [ "$(dmsetup status "$dst" | cut -d ' ' -f 3)" = crypt ]; then
+ backdev=$(/sbin/cryptsetup status "$dst" \
+ | awk '$1 == "device:" { print $2 }')
+ /sbin/cryptsetup remove "$dst"
+ # Leave partition with a blank plain-text swap
+ mkswap "$backdev" > /dev/null
+ fi
+ done
+fi
[ -x /sbin/quotaoff ] && action $"Turning off quotas: " /sbin/quotaoff -aug
@@ -145,6 +172,9 @@ LANG=C __umount_loop '$2 ~ /^\/$|^\/proc|^\/dev/{next}
[ -f /proc/bus/usb/devices ] && umount /proc/bus/usb
+[ -f /etc/crypttab ] && \
+ LANG=C action $"Stopping disk encryption: " halt_crypto
+
# remove the crash indicator flag
rm -f /.autofsck