From 7cc8991464d46f6fce0882142ef2135c562f80e6 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 25 May 2013 16:58:57 -0300 Subject: Adding sync-all --- sync-all | 1 + sync-code | 44 ++++++++++++++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 12 deletions(-) create mode 120000 sync-all diff --git a/sync-all b/sync-all new file mode 120000 index 0000000..e737e41 --- /dev/null +++ b/sync-all @@ -0,0 +1 @@ +sync-code \ No newline at end of file diff --git a/sync-code b/sync-code index eece25f..5895491 100755 --- 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 -- cgit v1.2.3