syntax fix and indentation
authorRalph Ronnquist <ralph.ronnquist@gmail.com>
Thu, 10 Dec 2020 01:29:26 +0000 (12:29 +1100)
committerRalph Ronnquist <ralph.ronnquist@gmail.com>
Thu, 10 Dec 2020 01:29:26 +0000 (12:29 +1100)
sss.sh

diff --git a/sss.sh b/sss.sh
index fbda5db03cfe17bef2206a056316e81da71212cc..0207686ef7a3e54d510fb0080852fa056a9cebf7 100755 (executable)
--- a/sss.sh
+++ b/sss.sh
@@ -37,32 +37,32 @@ function marksnap() {
        chcp cp $DEV ${MARKYEAR[2]}
     fi
     MARK=( "$1" "$2" $3 )
-fi
+}
 
 { flock 9
 
-date "+$DEV: %Y-%m-%d %H:%M:%S ---- checking" >&2
-lscp -s $DEV | while read CNO DATE TIME REST ; do
-    TS="$DATE $TIME"
-    [ "$CNO" = "CNO" ] && continue
-    if [[ "$TS" > "$YEARLY" ]] ; then
-       marksnap YEAR "${DATE:0:4}" $CNO
-    elif [[ "$TS" > "$MONTHLY" ]]
-        marksnap MONTH "${DATE:5:2}" $CNO
-    elif [[ "$TS" > "$WEEKLY" ]]
-        # For older than most recent week, keep last snapshot each week
-        marksnap WEEK "$(( 7${DATE:8:2} / 7 - 100 ))" $CNO
-    elif [[ "$TS" > "$DAILY" ]]
-        marksnap DAY "${DATE:8:2}" $CNO
-    elif [[ "$TS" > "$HOURLY" ]]
-        marksnap HOUR "${DATE:8:2}-${TIME:0:2}" $CNO
-    else
-       echo "$CNO $DATE $TIME within last hour"
-    fi
-done | if read X ; then
-    : # snapshot within last hour
-else
-    date "+$DEV: new snapshot at %Y-%m-%d %H:%M:%S" >&2
-    mkcp -s $DEV
-fi
+  date "+$DEV: %Y-%m-%d %H:%M:%S ---- checking" >&2
+  lscp -s $DEV | while read CNO DATE TIME REST ; do
+      TS="$DATE $TIME"
+      [ "$CNO" = "CNO" ] && continue
+      if [[ "$TS" > "$YEARLY" ]] ; then
+         marksnap YEAR "${DATE:0:4}" $CNO
+      elif [[ "$TS" > "$MONTHLY" ]]
+          marksnap MONTH "${DATE:5:2}" $CNO
+      elif [[ "$TS" > "$WEEKLY" ]]
+          # For older than most recent week, keep last snapshot each week
+          marksnap WEEK "$(( 7${DATE:8:2} / 7 - 100 ))" $CNO
+      elif [[ "$TS" > "$DAILY" ]]
+          marksnap DAY "${DATE:8:2}" $CNO
+      elif [[ "$TS" > "$HOURLY" ]]
+          marksnap HOUR "${DATE:8:2}-${TIME:0:2}" $CNO
+      else
+         echo "$CNO $DATE $TIME within last hour"
+      fi
+  done | if read X ; then
+      : # snapshot within last hour
+  else
+      date "+$DEV: new snapshot at %Y-%m-%d %H:%M:%S" >&2
+      mkcp -s $DEV
+  fi
 } 9> /var/run/lock/sss.lock