+bin/shutdown-detect*
[nethome.git] / bin / shutdown-detect-boot
diff --git a/bin/shutdown-detect-boot b/bin/shutdown-detect-boot
new file mode 100755 (executable)
index 0000000..7990229
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/bash
+boot="boot $* boot=$(uptime -s) $(uptime -p)"
+echo "$(date --iso=seconds) uninit-time $boot" >>/var/log/shutdown-detect.log
+# Raspberry Pi 3B+: 15 sec
+sleep 60
+echo "$(date --iso=seconds)   init-time $boot" >>/var/log/shutdown-detect.log
+if [ -e /var/log/shutdown-detect.ok ];then
+  rm -f /var/log/shutdown-detect.ok
+  exit 0
+fi
+echo "$(date --iso=seconds) unclean shutdown"|tee -a /var/log/shutdown-detect.log|mail -s "unclean shutdown: $(hostname)" jan@jankratochvil.net