aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfiles/mount-media35
-rw-r--r--manifests/init.pp9
2 files changed, 44 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
diff --git a/manifests/init.pp b/manifests/init.pp
index 88e4b76..f69e5a1 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -138,6 +138,15 @@ class backup {
source => "puppet://$server/modules/backup/sync-backups",
}
+ # mount-media script
+ file { "/usr/local/sbin/mount-media":
+ owner => root,
+ group => root,
+ mode => 0755,
+ ensure => present,
+ source => "puppet://$server/modules/backup/mount-media",
+ }
+
# default backupninja::rdiff configuration
define rdiff($port = '22', $ensure = present, $installkey = true) {
backupninja::rdiff { "rdiff-$title.$domain":