contrib/scripts/process_log.sh: attempt to remove bash extensions, use of 2 different...
authorng0 <ng0@n0.is>
Mon, 4 Mar 2019 16:09:26 +0000 (16:09 +0000)
committerng0 <ng0@n0.is>
Mon, 4 Mar 2019 16:09:26 +0000 (16:09 +0000)
contrib/scripts/process_log.sh

index c25c515c2a23a79a216ae0544c79ac144ddbf54f..7b2363a0eee5b3bd874d38bbd83529a685a1c0a3 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 # Usage: service should print "STARTING SERVICE (srvc) for peer [PEER]" where:
 # - "srvc" is the service name (in lowercase, as in the log output).
@@ -23,8 +23,16 @@ rm __tmp_peers
 sed -e "$SED_EXPR" log > .log
 echo "$0 sed regex: $SED_EXPR" >> .log
 
-SIZE=`stat -c%s .log`
+if [ -n "$(uname -a | grep -q 'Linux')" ]; then
+    # GNU coreutils:
+    SIZE=`stat -c%s .log`
+else
+    # NetBSD, FreeBSD (and others?):
+    SIZE=`stat -f%z .log`
+fi
+
+# echo $SIZE
 
-if [[ "`ps aux | grep "kwrite .lo[g]"`" = "" && "$SIZE" < 10000000 ]]; then
+if [ "`ps aux | grep "kwrite .lo[g]"`" = "" -a "$SIZE" -lt "10000000" ]; then
     kwrite .log --geometry 960x1140-960 &
 fi