From 5aa4ecffc951021322f7b25f24ddab84bc3b909f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferit=20Yi=C4=9Fit=20BALABAN?= Date: Thu, 25 May 2023 07:38:32 +0300 Subject: [PATCH] unused: unison synchronizer --- deprecated/unison_sync.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 deprecated/unison_sync.sh diff --git a/deprecated/unison_sync.sh b/deprecated/unison_sync.sh new file mode 100755 index 0000000..a72b3f5 --- /dev/null +++ b/deprecated/unison_sync.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Ferit Yiğit BALABAN , 2023 +# & ChatGPT +# + +LOCAL_DIR="$HOME/mounts/31_shoka" +REMOTE_DIR="ssh://fyb@192.168.0.3//mnt/shoka" +LOG_FILE="$HOME/navi.log" +UNISON="/usr/bin/unison" + +# Run Unison to synchronize the directories +$UNISON $LOCAL_DIR $REMOTE_DIR -batch -auto -confirmbigdel > /dev/null 2>&1 + +# Check the exit code of Unison +if [ $? -eq 0 ]; then + # Synchronization was successful, log the message and exit + echo "$(date -Iseconds) INFO: unison, sync successful" >> $LOG_FILE + exit 0 +else + # Synchronization failed, check if there were conflicts + CONFLICTS=`grep "Conflicting file" /var/log/unison.log | wc -l` + if [ $CONFLICTS -eq 0 ]; then + # There were no conflicts, log the message and exit + echo "$(date -Iseconds) INFO: unison, no diff" >> $LOG_FILE + exit 0 + else + # There were conflicts, log the message and exit with an error code + echo "$(date -Iseconds) ERROR: unison, sync conflict" >> $LOG_FILE + exit 1 + fi +fi