diff options
author | Erich Eckner <git@eckner.net> | 2020-01-03 14:04:02 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2020-01-03 14:04:02 +0100 |
commit | 00bc2a8013a8261813fcf56509f22f72c2597691 (patch) | |
tree | 253b70db1604d2438c3866ba4196dec64772ec92 | |
parent | f9bd26d1592ccfbf57adb47d6a22cbafb343e3a3 (diff) | |
download | mount-crypts-00bc2a8013a8261813fcf56509f22f72c2597691.tar.xz |
mount-crypts: handle integrity targets without key, too
-rwxr-xr-x | mount-crypts | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/mount-crypts b/mount-crypts index b7ba106..e047a63 100755 --- a/mount-crypts +++ b/mount-crypts @@ -15,26 +15,54 @@ fi \ sleep 1 maxWait=$[${maxWait}-1] done + + # detects integrity correctly, too if cryptsetup status "${name}" 2>&1 >/dev/null; then is_mounted=true else is_mounted=false fi - if [ "$1" == "-u" ]; then + + if [ "x$1" == 'x-u' ]; then if ! ${is_mounted}; then continue fi - if ! /usr/sbin/cryptsetup luksClose "${name}"; then - >&2 echo "FEHLER: cryptsetup luksClose $name" - exit 1 + + if [ -n "${key}" ]; then + + if ! /usr/sbin/cryptsetup luksClose "${name}"; then + >&2 echo "FEHLER: cryptsetup luksClose $name" + exit 1 + fi + + else + + if ! /usr/sbin/integritysetup close "${name}"; then + >&2 echo "FEHLER: integritysetup close $name" + exit 1 + fi + 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 + + if [ -n "${key}" ]; then + + if ! /usr/sbin/cryptsetup luksOpen "${device}" "${name}" --key-file "${key}"; then + >&2 echo "FEHLER: cryptsetup luksOpen ${device} ${name} --key-file ${key}" + exit 1 + fi + + else + + if ! /usr/sbin/integritysetup open "${device}" "${name}"; then + >&2 echo "FEHLER: integritysetup open ${device} ${name}" + exit 1 + fi + fi fi done |