diff options
author | Erich Eckner <git@eckner.net> | 2019-04-18 11:24:38 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-04-18 11:24:38 +0200 |
commit | 7b05d3bb153e10cd864d3a6da6fd4e990e8dce23 (patch) | |
tree | 6a96ddce0a9d9d135e427fcfa3293cfd5fb0a18a | |
parent | e589c414387ae4fa51351866fe5f0aa8668fffd4 (diff) | |
download | mount-crypts-7b05d3bb153e10cd864d3a6da6fd4e990e8dce23.tar.xz |
style
-rwxr-xr-x | mount-crypts | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/mount-crypts b/mount-crypts index e434adc..e1efc50 100755 --- a/mount-crypts +++ b/mount-crypts @@ -3,30 +3,25 @@ i=1 maxWait=60 -while [ $i -le $(sed "s/#.*$//" /etc/crypttab | grep -vc '^ *$') ] -do +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 + while [ ${maxWait} -gt 0 ] && [ ! -b "${device}" ]; do sleep 1 maxWait=$[${maxWait}-1] done - if [ "$1" == "-u" ] - then - if ! /usr/sbin/cryptsetup luksClose $name - then + 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" + 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] + i=$((i+1)) done |