From 717e05fd4576efeed7ab7e71faf758ed11853975 Mon Sep 17 00:00:00 2001
From: Janne Koschinski <janne@kuschku.de>
Date: Wed, 15 Apr 2020 10:05:01 +0200
Subject: [PATCH] Only update output if it has actually changed

---
 docker-entrypoint.sh | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
index 2fa59dd..798e27a 100755
--- a/docker-entrypoint.sh
+++ b/docker-entrypoint.sh
@@ -11,21 +11,30 @@ sleep 5
 
 if [ -z "$OTP_TOKEN" ]; then
   echo "syncing library"
+  date
   seaf-cli sync -l "$LIBRARY" -s "$SERVER" -d "/sync" -u "$EMAIL" -p "$PASSWORD"
 else
   echo "syncing library with OTP"
+  date
   seaf-cli sync -l "$LIBRARY" -s "$SERVER" -d "/sync" -u "$EMAIL" -p "$PASSWORD" --tfa $(oathtool --totp -b "$OTP_TOKEN")
 fi
 
 maxretry=4
 retry=0
 
+lastoutput=""
+output=""
+
 while [ "$retry" -le "$maxretry" ]; do
     ps aux | grep seafile | grep -v grep > /dev/null 2> /dev/null || {
         retry=$(expr $retry + 1);
     }
-    date
-    seaf-cli status
+    output=$(seaf-cli status)
+    if [[ "$output" != "$lastoutput" ]]; then
+      date
+      echo "$output"
+      lastoutput="$output"
+    fi
     sleep 5
 done
 echo "Seafile not running"
-- 
GitLab