Mercurial > repos > other > usr-local-bin
annotate umount-crypt @ 27:c7621908cb47
Try to manage disk usage for backup
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 07 Mar 2020 16:37:38 +0000 |
parents | 14e726efe9b0 |
children |
rev | line source |
---|---|
0 | 1 #! /bin/bash |
2 | |
3 if [ $# -ne 1 ]; then | |
4 echo "Usage: $0 <filename>" >&2 | |
5 exit 1 | |
6 fi | |
7 | |
8 if [ ! -d "$1" ]; then | |
9 echo "Directory doesn't exist" >&2 | |
10 exit 2 | |
11 fi | |
12 | |
13 ARG=${1%/} | |
14 LOOP_DEV=${ARG##*/} | |
15 | |
16 if [ ! -d "/media/$LOOP_DEV" -o ! -b "/dev/mapper/$LOOP_DEV" ]; then | |
17 echo "Not a crypto loop" >&2 | |
18 exit 3 | |
19 fi | |
20 | |
5
14e726efe9b0
Change from sudo (which may record command) to su, since we're mounting something private/encrypted
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
21 su -c "umount \"/media/$LOOP_DEV\" && rmdir \"/media/$LOOP_DEV\" && cryptsetup luksClose \"/dev/mapper/$LOOP_DEV\" && losetup -d \"/dev/$LOOP_DEV\"" |