X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=system%2Fnetdata-init-d.in;h=468ceee2a43316be6d0a36f843f2deae262a7a5a;hb=a3ae351f1e4576e5a32166ddbc28c8699ce31991;hp=edda9950f0488f707261686681d776d117f3db18;hpb=5ca36e1ed97c145fc41e13f4158651cce69ebaf6;p=netdata.git diff --git a/system/netdata-init-d.in b/system/netdata-init-d.in index edda9950..468ceee2 100644 --- a/system/netdata-init-d.in +++ b/system/netdata-init-d.in @@ -17,12 +17,18 @@ PIDFILE=@localstatedir_POST@/run/$DAEMON.pid DAEMONOPTS="-P $PIDFILE" STOP_TIMEOUT="10" +[ -e /etc/sysconfig/$DAEMON ] && . /etc/sysconfig/$DAEMON + +LOCKFILE=/var/lock/subsys/$DAEMON + service_start() { - echo "Starting $DAEMON..." + [ -x $DAEMON_PATH ] || exit 5 + echo -n "Starting $DAEMON..." daemon $DAEMON_PATH/$DAEMON $DAEMONOPTS RETVAL=$? echo + [ $RETVAL -eq 0 ] && touch $LOCKFILE return $RETVAL } @@ -31,10 +37,8 @@ service_stop() printf "%-50s" "Stopping $DAEMON..." killproc -p ${PIDFILE} -d ${STOP_TIMEOUT} $DAEMON RETVAL=$? - if [ $RETVAL -eq 0 ]; then - rm -f ${PIDFILE} - fi echo + [ $RETVAL -eq 0 ] && rm -f ${PIDFILE} ${LOCKFILE} return $RETVAL } @@ -54,11 +58,18 @@ service_status() status -p ${PIDFILE} $DAEMON_PATH/$DAEMON } +service_status_quiet() +{ + status -p ${PIDFILE} $DAEMON_PATH/$DAEMON >/dev/null 2>&1 +} + case "$1" in start) + service_status_quiet && exit 0 service_start ;; stop) + service_status_quiet || exit 0 service_stop ;; restart)