blob: 971ab3be93d6347215686a8b6fb194d87592a1b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/bin/sh
set -e
set -x
if [ "x$1" = "x" ]; then
echo "$0: [FILE]"
exit 1
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}
fi
if [ "x${DEBUG}" != "x" ]; then
sudo valgrind --log-file=valgrind.log src/naskpass -f ./${NAME}.fifo -c "/sbin/cryptsetup open ${FILE} ${NAME}" || true
sudo valgrind --tool=helgrind --log-file=helgrind.log src/naskpass -f ./${NAME}.fifo -c "/sbin/cryptsetup open ${FILE} ${NAME}" || true
else
sudo src/naskpass -f ./${NAME}.fifo -c "/sbin/cryptsetup open ${FILE} ${NAME}"
fi
set +e
sudo /sbin/cryptsetup status ${NAME}
ret=$?
set -e
if [ $ret -eq 0 ]; then
sudo /sbin/cryptsetup close ${NAME}
/bin/echo -e "\n$0: close'd"
fi
|