rc.piler.in improvements

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2020-03-14 16:33:11 +01:00
parent bec0c0399e
commit d994f5d1b3

View File

@ -15,26 +15,26 @@
NAME=piler NAME=piler
OPTIONS="" OPTIONS=""
PID_FILE=`SBINDIR/pilerconf $OPTIONS -q pidfile | cut -f2 -d=` PID_FILE="$(SBINDIR/pilerconf $OPTIONS -q pidfile | cut -f2 -d=)"
PID_NUMBER=`test -f ${PID_FILE} && cat ${PID_FILE}` PID_NUMBER="$(test -f "$PID_FILE" && cat "$PID_FILE")"
PILER_SMTP_PID=$(ps uaxw | grep -w piler-smtp | grep -v grep | awk '{print $2}') PILER_SMTP_PID="$(pgrep piler-smtp)"
start() { start() {
echo "starting piler-smtp . . . " echo "starting piler-smtp . . . "
SBINDIR/piler-smtp -d SBINDIR/piler-smtp -d
echo "starting $NAME . . ." echo "starting $NAME . . ."
SBINDIR/piler -d $OPTIONS SBINDIR/piler -d $OPTIONS
} }
stop() { stop() {
if [ "$PID_NUMBER" != "" ]; then echo "stopping piler"; kill $PID_NUMBER; fi 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 if [ "$PILER_SMTP_PID" != "" ]; then echo "stopping piler-smtp"; kill "$PILER_SMTP_PID"; fi
} }
check_status(){ check_status(){
if [ -f /proc/${PID_NUMBER}/status ]; then if [ -f "/proc/${PID_NUMBER}/status" ]; then
echo "piler is running, pid: ${PID_NUMBER}"; echo "piler is running, pid: ${PID_NUMBER}";
else else
echo "piler is NOT running"; echo "piler is NOT running";
@ -48,13 +48,13 @@ check_status(){
} }
case "$1" in case "$1" in
start) start)
start; start;
;; ;;
stop) stop)
stop; stop;
;; ;;
status) status)
if check_status; if check_status;
@ -65,17 +65,18 @@ case "$1" in
fi fi
;; ;;
restart) restart)
stop; stop;
sleep 1; sleep 1;
start; start;
;; ;;
reload) reload)
kill -HUP $PID_NUMBER kill -HUP "$PID_NUMBER"
echo "reloaded" echo "reloaded"
;; ;;
*) *)
echo "Usage: $0 start|stop|restart|reload|status" echo "Usage: $0 start|stop|restart|reload|status"
esac ;;
esac