]> gitweb.fluxo.info Git - cache.git/commitdiff
Adds custom synchronizer
authorCache do Fluxo <cache@fluxo.info>
Tue, 8 Nov 2016 20:16:10 +0000 (18:16 -0200)
committerCache do Fluxo <cache@fluxo.info>
Tue, 8 Nov 2016 20:16:10 +0000 (18:16 -0200)
.sync-media/custom [new file with mode: 0755]

diff --git a/.sync-media/custom b/.sync-media/custom
new file mode 100755 (executable)
index 0000000..0ae38d2
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+#
+# Custom syncronizer for hydractl sync-media.
+#
+
+# Parameters
+BASENAME="`basename $0`"
+DIRNAME="`dirname $0`"
+BASE="`cd $DIRNAME/.. && pwd`"
+DEST="$1/data"
+ASSETS="$BASE/data"
+
+# Syntax
+if [ "$DEST" == "/data" ]; then
+  echo "usage: $BASENAME <dest>"
+  exit 1
+elif [ ! -d "$DEST" ]; then
+  echo "folder $DEST does not exist."
+  exit 1
+fi
+
+# Check if there are assets
+if [ ! -z "$(ls -A $ASSETS)" ]; then
+  # Then sync
+  unison $ASSETS $DEST -auto -logfile /dev/null
+fi