diff options
Diffstat (limited to 'files')
-rwxr-xr-x | files/mount-media | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/files/mount-media b/files/mount-media new file mode 100755 index 0000000..28a7400 --- /dev/null +++ b/files/mount-media @@ -0,0 +1,35 @@ +#!/bin/bash +# +# mount-media +# + +# Parameters +MEDIA="$1" +VOLUME="$2" +BASENAME="`basename $0`" + +# Check media config +if [ -z "$MEDIA" ]; then + echo "usage: $BASENAME <media> [volume]" + echo "example: $BASENAME magnetron sdb1" + exit 1 +fi + +# Check volume config +if [ -z "$VOLUME" ]; then + VOLUME="sdb1" +fi + +# Set sudo config +if [ "`whoami`" != 'root' ]; then + sudo="sudo" +fi + +if [ "$BASENAME" == "mount-media" ]; then + $sudo cryptsetup luksOpen /dev/$VOLUME $MEDIA && \ + $sudo fsck -v -y /dev/mapper/$MEDIA && \ + $sudo mount /dev/mapper/$MEDIA /media/usb +elif [ "$BASENAME" == "umount-media" ]; then + $sudo umount /media/usb && \ + $sudo cryptsetup luksClose $MEDIA +fi |