diff options
Diffstat (limited to 'sync-code')
-rwxr-xr-x | sync-code | 44 |
1 files changed, 32 insertions, 12 deletions
@@ -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 |