diff options
-rwxr-xr-x | mount-crypts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/mount-crypts b/mount-crypts index e1efc50..08b1975 100755 --- a/mount-crypts +++ b/mount-crypts @@ -5,6 +5,7 @@ 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")" + i=$((i+1)) name=$(echo $s | awk '{print $1}') device=$(echo $s | awk '{print $2}') key=$(echo $s | awk '{print $3}') @@ -12,16 +13,26 @@ while [ $i -le $(sed "s/#.*$//" /etc/crypttab | grep -vc '^ *$') ]; do sleep 1 maxWait=$[${maxWait}-1] done + if cryptsetup status "${name}" 2>&1 >/dev/null; then + is_mounted=true + else + is_mounted=false + fi if [ "$1" == "-u" ]; then + if ! ${is_mounted}; then + continue + fi if ! /usr/sbin/cryptsetup luksClose "${name}"; then >&2 echo "FEHLER: cryptsetup luksClose $name" exit 1 fi else + if ${is_mounted}; then + continue + fi 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 |