diff options
l--------- | sync-all | 1 | ||||
-rwxr-xr-x | sync-code | 44 |
2 files changed, 33 insertions, 12 deletions
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 @@ -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 |