ein dmcrypt-wrapper

This commit is contained in:
lars 2005-06-13 18:46:07 +00:00
parent e0d7a18bfe
commit df1f8fe3a2

59
spielspass/dmcrypt-wrapper.sh Executable file
View file

@ -0,0 +1,59 @@
#!/bin/sh
#
# a simple wrapper around cryptdisks to:
# mount after cryptsetup
# umount before cryptsetup
# break on error or undefined variables
set -eu
crypt_mount()
{
local partitions=`dmsetup ls | grep -v "No devices found" | cut -f1`
for i in $partitions; do
if mount | grep -q "^/dev/mapper/$i$"
then echo -en "\t$i (mounting)"
mount "/dev/mapper/$i" &>/dev/null || echo -en " (\"mount /dev/mapper/$i\" failed)" >&2
fi
done
}
crypt_umount()
{
local partitions=`dmsetup ls | grep -v "No devices found" | cut -f1`
for i in $partitions; do
if mount | grep -q "^/dev/mapper/$i$"
then true
else
echo -en "\t$i (unmounting)"
umount "/dev/mapper/$i" &>/dev/null || echo -en " (\"umount /dev/mapper/$i\" failed)" >&2
fi
done
}
########### do it! ##############
ACTION=help
[ $# -gt 0 ] && ACTION="$1"
case "$ACTION" in
start|retry )
/etc/init.d/cryptdisks start
crypt_mount
;;
stop )
crypt_umount
/etc/init.d/cryptdisks stop
;;
restart|reload|force-reload )
$0 stop
$0 start
;;
* )
echo "Syntax: `basename $0` { start | stop | restart | retry | reload | force-reload | help }"
;;
esac