diff mount-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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mount-crypt	Sat Aug 02 19:31:02 2014 +0100
@@ -0,0 +1,17 @@
+#! /bin/bash
+
+if [ $# -ne 1 ]; then
+	echo "Usage: $0 <filename>" >&2
+	exit 1
+fi
+
+if [ ! -f "$1" ]; then
+	echo "File doesn't exist" >&2
+	exit 2
+fi
+
+LOOP_DEV=$(sudo losetup --find --show "$1")
+MAPPER=${LOOP_DEV##*/}
+sudo cryptsetup luksOpen $LOOP_DEV $MAPPER
+sudo mkdir -p /media/$MAPPER
+sudo mount /dev/mapper/$MAPPER /media/$MAPPER