Mercurial > repos > other > usr-local-bin
annotate umount-crypt @ 0:e85e3470a41e
Initial commit of useful scripts
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 02 Aug 2014 19:31:02 +0100 |
parents | |
children | 14e726efe9b0 |
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 | |
21 sudo umount "/media/$LOOP_DEV" | |
22 sudo rmdir "/media/$LOOP_DEV" | |
23 sudo cryptsetup luksClose "/dev/mapper/$LOOP_DEV" | |
24 sudo losetup -d "/dev/$LOOP_DEV" |