aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-06-20 19:59:52 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-06-20 19:59:52 -0300
commit92bddda328f82484f98204dd60ae8112d11e4b87 (patch)
tree6380dd759a98be1bb87b5000797e0bbca2734d4b
parenteb108899bb4f31e9cfdfcf431d44b111e9067068 (diff)
downloadhydra-92bddda328f82484f98204dd60ae8112d11e4b87.tar.gz
hydra-92bddda328f82484f98204dd60ae8112d11e4b87.tar.bz2
Adds sync-home
-rwxr-xr-xshare/hydractl/sync-home36
1 files changed, 36 insertions, 0 deletions
diff --git a/share/hydractl/sync-home b/share/hydractl/sync-home
new file mode 100755
index 0000000..7be90ea
--- /dev/null
+++ b/share/hydractl/sync-home
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# sync-home
+#
+
+# Parameters
+BASENAME="$0"
+TPC="$1"
+DEST="/media/$1"
+MEDIA="$DEST/var/cache/$TPC/media"
+RSYNC="ionice -c 3 nice -n 19 rsync -av --delete --progress"
+
+# Syntax
+if [ -z "$TPC" ]; then
+ echo "usage: $BASENAME <tpc>"
+ exit 1
+elif [ ! -d "$DEST" ]; then
+ echo "folder $DEST does not exist."
+ exit 1
+fi
+
+# Sudo
+if [ "$USER" != 'root' ]; then
+ export SUDO="sudo"
+fi
+
+# Encrypted home
+$SUDO mkdir -p $DEST/mnt/crypt/home
+
+# Encrypted mountpoints
+for folder in /mnt/crypt/home/*; do
+ $SUDO mkdir -p $DEST/$folder
+done
+
+# Sync files
+$SUDO $RSYNC /home/ $DEST/home/