]> gitweb.fluxo.info Git - hydra.git/commitdiff
Adds sync-home
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 20 Jun 2017 22:59:52 +0000 (19:59 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 20 Jun 2017 22:59:52 +0000 (19:59 -0300)
share/hydractl/sync-home [new file with mode: 0755]

diff --git a/share/hydractl/sync-home b/share/hydractl/sync-home
new file mode 100755 (executable)
index 0000000..7be90ea
--- /dev/null
@@ -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/