#!/bin/sh
#
# sentinel start/stop/restart script
#
SMFILTER=/usr/local/sbin/sentinel
CONFIG=/etc/mail/sentinel.cf
SOCKET=/var/run/smmsp/sentinel.socket
getprocs() {
/usr/bin/ps -ef | /usr/bin/grep $1 | /usr/bin/grep -v $0 | /usr/bin/grep -v grep | awk '{print $2}'
}
case $1 in
"")
echo "usage: $0 {start|stop|restart}"
exit 0
;;
start)
if [ -r $SOCKET ];
then
pids=`getprocs $SMFILTER`
if [ "$pids" = "" ]
then
echo "Warning: $SOCKET exists but sentinel isn't running."
rm -f $SOCKET
else
echo "sentinel is already running. Aborting."
exit 0
fi
fi
$SMFILTER -c $CONFIG -p unix:$SOCKET -d
;;
stop)
if [ ! -r $SOCKET ];
then
echo "Warning: $SOCKET does not exists. Aborting."
exit 1
fi
pids=`getprocs $SMFILTER`
if [ "$pids" != "" ]
then
kill $pids
sleep 3
if [ -r $SOCKET ];
then
echo "Warning: $SOCKET still exists. Aborting."
exit 1
fi
fi
;;
restart)
if [ ! -r $SOCKET ];
then
echo "Warning: $SOCKET does not exists."
$SMFILTER -c $CONFIG -p unix:$SOCKET -d
exit 0
fi
pids=`getprocs $SMFILTER`
if [ "$pids" != "" ]
then
kill $pids
sleep 3
if [ -r $SOCKET ];
then
echo "Warning: $SOCKET is still exists. Aborting."
exit 1
fi
$SMFILTER -c $CONFIG -p unix:$SOCKET -d
else
echo "Warning: $SOCKET exists but sentinel isn't running."
rm -f $SOCKET
$SMFILTER -c $CONFIG -p unix:$SOCKET -d
fi
;;
*)
echo "unknown command: $1"
;;
esac
exit 0
syntax highlighted by Code2HTML, v. 0.9.1