summaryrefslogtreecommitdiff
path: root/reboot.sh
diff options
context:
space:
mode:
authorF3RR3T <github@st33v.com>2014-09-10 09:53:23 +1000
committerF3RR3T <github@st33v.com>2014-09-10 09:53:23 +1000
commit82885d54288593b5714ee8c719d1f3f075d40386 (patch)
tree1ffedf5539b4efc30ff112a2a8f87e8fc010b985 /reboot.sh
parent0000998bb0cb17c3f0e936245b895b9ba53be2bb (diff)
Now use environment var to mask email address
Diffstat (limited to 'reboot.sh')
-rwxr-xr-xreboot.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/reboot.sh b/reboot.sh
new file mode 100755
index 0000000..19c9391
--- /dev/null
+++ b/reboot.sh
@@ -0,0 +1,36 @@
+#!/bin/bash -
+# SJP 9 Sept 2014
+# Run by cron after reboot.
+# Sends an email to st33v.
+
+# https://www.linuxquestions.org/questions/linux-server-73/delay-startup-script-until-15-minutes-after-boot-661245/
+# at now + 15 minutes -f your_script
+# Alternately, use a script, whose first line is
+# sleep 900
+# and start it from rc.local like this
+# nohup /path/myscript &
+# which will disconnect it from the startup and background it.
+
+cd ~/mail/monitor
+touch data/heartlock # make a file to stop heartbeat overwriting
+
+cat <<- EOF > data/emailbody.txt
+ Cumquat has rebooted
+ ====================
+
+ $(cat data/heartbeat.txt)
+
+ -----------------------------------------------------------
+ Current status at $(date):
+ $(procinfo -Hr)
+
+ -----------------------------------------------------------
+ Was there a shutdown command?
+ $(cat /var/log/auth.log | grep shutdown)
+
+EOF
+
+sleep 180 # wait 3 mins to make sure have network
+cat data/emailbody.txt | mail -A cumquat -s "Cumquat reboot notification" $EMAILST33V
+rm data/emailbody.txt
+rm data/heartlock