piler/init.d/rc.piler.in
SJ 1a68d37a36 minor fixes
Change-Id: I16d16df9db05219fefd918d2c977e6ee6cc9f5f0
Signed-off-by: SJ <sj@acts.hu>
2016-11-26 11:49:08 +01:00

82 lines
1.6 KiB
Bash

#!/bin/sh
##
##
### BEGIN INIT INFO
# Provides: piler
# Required-Start: $remote_fs $syslog $named $network $time mysql
# Required-Stop: $remote_fs $syslog $named $network mysql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: piler email archiver
# Description: piler email archiver
### END INIT INFO
NAME=piler
OPTIONS=""
PID_FILE=`SBINDIR/pilerconf $OPTIONS -q pidfile | cut -f2 -d=`
PID_NUMBER=`test -f ${PID_FILE} && cat ${PID_FILE}`
PILER_SMTP_PID=$(ps uaxw | grep -w piler-smtp | grep -v grep | awk '{print $2}')
start() {
echo "starting piler-smtp . . . "
SBINDIR/piler-smtp -d
echo "starting $NAME . . ."
SBINDIR/piler -d $OPTIONS
}
stop() {
echo "stopping $NAME"
kill ${PID_NUMBER}
if [ $PILER_SMTP_PID != '' ]; then echo "stopping piler-smtp"; kill $PILER_SMTP_PID; fi
}
check_status(){
test -f /proc/${PID_NUMBER}/status
if [ "${PILER_SMTP_PID}" != '' ]; then
echo "piler-smtp is running, pid: ${PILER_SMTP_PID}";
else
echo "piler-smtp is NOT running";
fi
}
case "$1" in
start)
start;
;;
stop)
stop;
;;
status)
if check_status;
then
echo "${NAME} is running."
exit 0
else
echo "${NAME} is not running."
exit 1
fi
;;
restart)
stop;
sleep 1;
start;
;;
reload)
kill -HUP $PID_NUMBER
echo "reloaded"
;;
*)
echo "Usage: $0 start|stop|restart|reload|status"
esac