summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-04-18 11:18:24 +0200
committerErich Eckner <git@eckner.net>2019-04-18 11:18:24 +0200
commite589c414387ae4fa51351866fe5f0aa8668fffd4 (patch)
tree58766a01440039471706464d20b95df4114ada66
downloadmount-crypts-e589c414387ae4fa51351866fe5f0aa8668fffd4.tar.xz
status quo
-rwxr-xr-xmount-crypts32
1 files changed, 32 insertions, 0 deletions
diff --git a/mount-crypts b/mount-crypts
new file mode 100755
index 0000000..e434adc
--- /dev/null
+++ b/mount-crypts
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+i=1
+maxWait=60
+
+while [ $i -le $(sed "s/#.*$//" /etc/crypttab | grep -vc '^ *$') ]
+do
+ s="$(sed "s/#.*$//" /etc/crypttab | grep -v '^ *$' | tail -n$i | head -n1 | sed "s/ */ /g")"
+ name=$(echo $s | awk '{print $1}')
+ device=$(echo $s | awk '{print $2}')
+ key=$(echo $s | awk '{print $3}')
+ while [ ${maxWait} -gt 0 ] && [ ! -b "${device}" ]
+ do
+ sleep 1
+ maxWait=$[${maxWait}-1]
+ done
+ if [ "$1" == "-u" ]
+ then
+ if ! /usr/sbin/cryptsetup luksClose $name
+ then
+ >&2 echo "FEHLER: cryptsetup luksClose $name"
+ exit 1
+ fi
+ else
+ if ! /usr/sbin/cryptsetup luksOpen $device $name --key-file $key
+ then
+ >&2 echo "FEHLER: cryptsetup luksOpen $device $name --key-file $key"
+ exit 1
+ fi
+ fi
+ i=$[$i+1]
+done