aboutsummaryrefslogtreecommitdiff
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
parentd4e5cb86d91b3b7ec06ef4cc05c6aee9138e6093 (diff)
downloadpuppet-backup-4cd23f5f481eb63384de35146451556b7b177dce.tar.gz
puppet-backup-4cd23f5f481eb63384de35146451556b7b177dce.tar.bz2
Adding mount-media script
-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":