aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/restart.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/script/restart.sh b/script/restart.sh
new file mode 100644
index 0000000..39c17f4
--- /dev/null
+++ b/script/restart.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+path=$1
+offset=$2
+
+if ! [ -s $path ]; then
+ exit 1
+fi
+
+now=$(date +%s)
+lastline=$(tail $path | grep "." | tail -1)
+lastts=$(echo "$lastline" | grep -oP '^\d+')
+
+if [ -z $lastts ]; then
+ exit 1
+fi
+
+tswithoffset=$(($lastts + $offset))
+if [ $now -gt $tswithoffset ]; then
+ echo "Restart"
+fi