annotate mount-crypt @ 5:14e726efe9b0

Change from sudo (which may record command) to su, since we're mounting something private/encrypted
author IBBoard <dev@ibboard.co.uk>
date Sun, 09 Nov 2014 09:29:01 +0000
parents e85e3470a41e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e85e3470a41e Initial commit of useful scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 #! /bin/bash
e85e3470a41e Initial commit of useful scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2
e85e3470a41e Initial commit of useful scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 if [ $# -ne 1 ]; then
e85e3470a41e Initial commit of useful scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 echo "Usage: $0 <filename>" >&2
e85e3470a41e Initial commit of useful scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 exit 1
e85e3470a41e Initial commit of useful scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 fi
e85e3470a41e Initial commit of useful scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7
e85e3470a41e Initial commit of useful scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 if [ ! -f "$1" ]; then
e85e3470a41e Initial commit of useful scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 echo "File doesn't exist" >&2
e85e3470a41e Initial commit of useful scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 exit 2
e85e3470a41e Initial commit of useful scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 fi
e85e3470a41e Initial commit of useful scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12
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
13 LOOP_DEV=$(su -c "losetup --find --show \"$1\"")
0
e85e3470a41e Initial commit of useful scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 MAPPER=${LOOP_DEV##*/}
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
15 su -c "cryptsetup luksOpen $LOOP_DEV $MAPPER && mkdir -p /media/$MAPPER && mount /dev/mapper/$MAPPER /media/$MAPPER"