Add simple script to check for running ircd in cron
authorRemco Rijnders <remco@webconquest.com>
Sat, 7 Dec 2013 11:57:41 +0000 (12:57 +0100)
committerRemco Rijnders <remco@webconquest.com>
Sat, 7 Dec 2013 12:17:22 +0000 (13:17 +0100)
ircdchk [new file with mode: 0755]

diff --git a/ircdchk b/ircdchk
new file mode 100755 (executable)
index 0000000..7dcb813
--- /dev/null
+++ b/ircdchk
@@ -0,0 +1,18 @@
+# simple ircdchk
+# edit where applicable
+# crontab: */7 * * * * /home/ircd/ircd/ircdchk
+
+ircdexe="/home/ircd/ircd/ircd"
+ircdpidfile="/home/ircd/ircd/ircd.pid"
+
+if test -r $ircdpidfile; then
+    ircdpid=`cat $ircdpidfile`
+    if `kill -CHLD $ircdpid >/dev/null 2>&1`; then
+    # running process, exit without output
+        exit 0
+    fi
+    echo "Stale PID $ircdpidfile, removing"
+    rm -f $ircdpidfile
+fi
+echo "Restarting stopped ircd"
+$ircdexe