aboutsummaryrefslogtreecommitdiff
path: root/files/mount-media
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2012-08-20 09:57:05 -0300
committerSilvio Rhatto <rhatto@riseup.net>2012-08-20 09:57:05 -0300
commit4cd23f5f481eb63384de35146451556b7b177dce (patch)
tree2f0e934edd49d3a4efd50fe57088f4e30e2c6bce /files/mount-media
parentd4e5cb86d91b3b7ec06ef4cc05c6aee9138e6093 (diff)
downloadpuppet-backup-4cd23f5f481eb63384de35146451556b7b177dce.tar.gz
puppet-backup-4cd23f5f481eb63384de35146451556b7b177dce.tar.bz2
Adding mount-media script
Diffstat (limited to 'files/mount-media')
-rwxr-xr-xfiles/mount-media35
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