aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoni <matzeton@googlemail.com>2016-07-29 17:09:46 +0200
committertoni <matzeton@googlemail.com>2016-07-29 17:09:46 +0200
commit3efa929992f3d255843a32199d38e1699def5989 (patch)
tree0bffe917211b29446973e2e57cef62d6475b6054
parent9a068d8833690f5b5518ed3f2721557d8e3e417a (diff)
overwrite check
-rwxr-xr-xluks_test.sh9
1 files changed, 9 insertions, 0 deletions
diff --git a/luks_test.sh b/luks_test.sh
index 8e504c4..94fd7ef 100755
--- a/luks_test.sh
+++ b/luks_test.sh
@@ -10,6 +10,15 @@ fi
FILE=$1
NAME=$(basename ${FILE})
+if [ -w ${FILE} ]; then
+ set +x
+ read -p "$0: \`${FILE}\` exists: overwrite? (y/N):" answ
+ if [ "x${answ}" != "xy" ]; then
+ echo "$0: abort."
+ exit 1
+ fi
+ set -x
+fi
if [ ! -w ${FILE} ] || [ `file ${FILE} | grep -qoE 'LUKS encrypted file' && echo 0 || echo 1` -ne 0 ]; then
dd if=/dev/zero of=${FILE} bs=1M count=10
/sbin/cryptsetup luksFormat ${FILE}