]> gitweb.fluxo.info Git - scripts.git/commitdiff
Adding sync-all
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 25 May 2013 19:58:57 +0000 (16:58 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 25 May 2013 19:58:57 +0000 (16:58 -0300)
sync-all [new symlink]
sync-code

diff --git a/sync-all b/sync-all
new file mode 120000 (symlink)
index 0000000..e737e41
--- /dev/null
+++ b/sync-all
@@ -0,0 +1 @@
+sync-code
\ No newline at end of file
index eece25fb5de82eb31467ba5d13382b4231e82976..58954917a009542b846179ab4bc8c12699a69090 100755 (executable)
--- a/sync-code
+++ b/sync-code
@@ -10,23 +10,43 @@ UNISON="unison"
 # Use the following config if you need to sync with legacy systems
 UNISON="unison-2.32.52"
 
-if [ ! -z "$DEST" ]; then
+function sync_code_run {
+  local config="$1"
 
-  if [ "$BASENAME" == "sync-code" ]; then
-    profile="$DEST-code"
-  elif [ "$BASENAME" == "sync-irssi" ]; then
-    profile="$DEST-irssi"
-  elif [ "$BASENAME" == "sync-irssi-tor" ]; then
-    profile="$DEST-irssi-tor"
-  else
-    profile="$DEST-home"
+  if [ -z "$config" ]; then
+    return
   fi
 
-  if [ -f "$HOME/.unison/$profile.prf" ]; then
-    $UNISON $profile
+  if [ -f "$HOME/.unison/$config.prf" ]; then
+    echo "Starting sync using $config..."
+    $UNISON $config
   else
-    echo "No such profile $HOME/.unison/$profile.prf"
+    echo "No such profile $HOME/.unison/$config.prf"
     exit 1
   fi
+}
+
+if [ ! -z "$DEST" ]; then
+  profiles=""
+
+  if [ "$BASENAME" == "sync-code" ] || [ "$BASENAME" == "sync-all" ]; then
+    profiles="$profiles $DEST-code"
+  fi
+
+  if [ "$BASENAME" == "sync-irssi" ] || [ "$BASENAME" == "sync-all" ]; then
+    profiles="$profiles $DEST-irssi"
+  fi
+
+  if [ "$BASENAME" == "sync-irssi-tor" ] || [ "$BASENAME" == "sync-all" ]; then
+    profiles="$profiles $DEST-irssi-tor"
+  fi
+
+  if [ "$BASENAME" == "sync-home" ] || [ "$BASENAME" == "sync-all" ]; then
+    profiles="$profiles $DEST-home"
+  fi
+
+  for profile in $profiles; do
+    sync_code_run $profile
+  done
 
 fi