piler/init.d/rc.piler.in

81 lines
1.6 KiB
Plaintext
Raw Normal View History

2012-02-14 20:16:05 +01:00
#!/bin/sh
##
##
2013-12-14 11:10:16 +01:00
### 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
2012-02-14 20:16:05 +01:00
NAME=piler
2014-06-21 21:30:51 +02:00
OPTIONS=""
PID_FILE=`SBINDIR/pilerconf $OPTIONS -q pidfile | cut -f2 -d=`
2012-02-14 20:16:05 +01:00
PID_NUMBER=`test -f ${PID_FILE} && cat ${PID_FILE}`
PILER_SMTP_PID=$(ps uaxw | grep -w piler-smtp | grep -v grep | awk '{print $2}')
2012-02-14 20:16:05 +01:00
start() {
echo "starting piler-smtp . . . "
SBINDIR/piler-smtp -d
2013-04-09 16:10:08 +02:00
echo "starting $NAME . . ."
2014-06-21 21:30:51 +02:00
SBINDIR/piler -d $OPTIONS
2012-02-14 20:16:05 +01:00
}
stop() {
if [ "$PID_NUMBER" != "" ]; then echo "stopping piler"; kill $PID_NUMBER; fi
if [ "$PILER_SMTP_PID" != "" ]; then echo "stopping piler-smtp"; kill $PILER_SMTP_PID; fi
2012-02-14 20:16:05 +01:00
}
check_status(){
if [ -f /proc/${PID_NUMBER}/status ]; then
echo "piler is running, pid: ${PID_NUMBER}";
else
echo "piler is NOT running";
fi
if [ "${PILER_SMTP_PID}" != '' ]; then
echo "piler-smtp is running, pid: ${PILER_SMTP_PID}";
else
echo "piler-smtp is NOT running";
fi
2012-02-14 20:16:05 +01:00
}
case "$1" in
start)
start;
;;
stop)
stop;
;;
status)
if check_status;
then
2015-04-28 09:57:32 +02:00
exit 0
2012-02-14 20:16:05 +01:00
else
2015-04-28 09:57:32 +02:00
exit 1
2012-02-14 20:16:05 +01:00
fi
;;
restart)
stop;
sleep 1;
start;
;;
reload)
kill -HUP $PID_NUMBER
echo "reloaded"
;;
2012-02-14 20:16:05 +01:00
*)
echo "Usage: $0 start|stop|restart|reload|status"
esac