ircservices5/tools/ircservices-chk.in
2019-01-23 09:32:56 +01:00

36 lines
883 B
Bash

#!/bin/sh
#
# Script to check whether IRC Services is running, and restart it if not.
# Usage: ircservices-chk [-q] [ircservices-options]
# -q: don't write any output
# ircservices-options: options to pass to ircservices executable
# If you change PIDFile in ircservices.conf, also change PIDFILE below.
#
# IRC Services is copyright (c) 1996-2009 Andrew Church.
# E-mail: <achurch@achurch.org>
# Parts written by Andrew Kempe and others.
# This program is free but copyrighted software; see the file GPL.txt for
# details.
PIDFILE=@PROGRAM@.pid
if [ "X$1" = "X-q" ] ; then
exec 1>/dev/null
exec 2>/dev/null
shift
fi
ok=
if [ -f "@DATDEST@/$PIDFILE" ] ; then
pid=`cat "@DATDEST@/$PIDFILE"`
if echo "0$pid" | grep -q '[^0-9]' ; then
rm -f "@DATDEST@/$PIDFILE"
elif kill -0 $pid ; then
ok=1
fi
fi
if [ ! "$ok" ] ; then
"@BINDEST@/ircservices" "$@"
fi