From: Costa Tsaousis Date: Mon, 30 May 2016 23:12:47 +0000 (+0300) Subject: added LSB (old debian) init script X-Git-Tag: v1.3.0~183^2~6 X-Git-Url: https://arthur.barton.de/gitweb/?p=netdata.git;a=commitdiff_plain;h=b54acfc3e2c05085782a0a80caa8c3ed8ee25fa1 added LSB (old debian) init script --- diff --git a/system/Makefile.am b/system/Makefile.am index f16a720e..b2e49c5a 100644 --- a/system/Makefile.am +++ b/system/Makefile.am @@ -7,6 +7,7 @@ CLEANFILES = \ netdata.logrotate \ netdata.service \ netdata-init-d \ + netdata-lsb \ $(NULL) include $(top_srcdir)/build/subst.inc @@ -18,6 +19,7 @@ nodist_noinst_DATA = \ netdata.logrotate \ netdata.service \ netdata-init-d \ + netdata-lsb \ $(NULL) dist_noinst_DATA = \ @@ -25,5 +27,6 @@ dist_noinst_DATA = \ netdata.logrotate.in \ netdata.service.in \ netdata-init-d.in \ + netdata-lsb.in \ netdata.conf \ $(NULL) diff --git a/system/netdata-init-d.in b/system/netdata-init-d.in index 07d5a19e..d72dd2e5 100755 --- a/system/netdata-init-d.in +++ b/system/netdata-init-d.in @@ -1,8 +1,8 @@ #!/bin/sh # -# netdata Real-time charts for system monitoring +# netdata Real-time performance monitoring, done right # chkconfig: 345 99 01 -# description: Netdata is a daemon that collects data in realtime (per second) +# description: Netdata is a daemon that collects data in real-time (per second) # and presents a web site to view and analyze them. The presentation # is also real-time and full of interactive charts that precisely # render all collected values. diff --git a/system/netdata-lsb.in b/system/netdata-lsb.in new file mode 100755 index 00000000..d8165977 --- /dev/null +++ b/system/netdata-lsb.in @@ -0,0 +1,100 @@ +#!/bin/bash +# +### BEGIN INIT INFO +# Provides: netdata +# Required-Start: $local_fs $remote_fs $network $named $time apache2 httpd squid nginx mysql named opensips upsd hostapd postfix lm_sensors +# Required-Stop: $local_fs $remote_fs $network $named $time apache2 httpd squid nginx mysql named opensips upsd hostapd postfix lm_sensors +# Should-Start: $local_fs $network $named $remote_fs $time $all +# Should-Stop: $local_fs $network $named $remote_fs $time $all +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start and stop the netdata real-time monitoring server daemon +# Description: Controls the main netdata monitoring server daemon "netdata". +# and all its plugins. +### END INIT INFO +# +set -e +set -u +${DEBIAN_SCRIPT_DEBUG:+ set -v -x} + +DAEMON="netdata" +DAEMON_PATH=@sbindir_POST@ +PIDFILE=@localstatedir_POST@/$DAEMON.pid +DAEMONOPTS="-P $PIDFILE" + +test -x $DAEMON_PATH/$DAEMON || exit 0 + +. /lib/lsb/init-functions + +# Safeguard (relative paths, core dumps..) +cd / +umask 022 + +service_start() { + log_daemon_msg "Starting real-time performance monitoring" "netdata" + start_daemon -p $PIDFILE $DAEMON_PATH/$DAEMON $DAEMONOPTS + RETVAL=$? + log_end_msg $RETVAL + return $RETVAL +} + +service_stop() { + log_daemon_msg "Stopping real-time performance monitoring" "netdata" + killproc -p ${PIDFILE} $DAEMON_PATH/$DAEMON + RETVAL=$? + log_end_msg $RETVAL + + if [ $RETVAL -eq 0 ]; then + rm -f ${PIDFILE} + fi + return $RETVAL +} + +condrestart() { + if ! service_status > /dev/null; then + RETVAL=$1 + return + fi + + service_stop + service_start +} + +service_status() { + status_of_proc -p $PIDFILE $DAEMON_PATH/$DAEMON netdata +} + + +# +# main() +# + +case "${1:-''}" in + 'start') + service_start + ;; + + 'stop') + service_stop + ;; + + 'restart') + service_stop + service_start + ;; + + 'try-restart') + condrestart 0 + ;; + + 'force-reload') + condrestart 7 + ;; + + 'status') + service_status && exit 0 || exit $? + ;; + *) + echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}" + exit 1 +esac diff --git a/system/netdata.service.in b/system/netdata.service.in index 91db6122..5a119553 100644 --- a/system/netdata.service.in +++ b/system/netdata.service.in @@ -1,5 +1,5 @@ [Unit] -Description=Linux real time system monitoring, over the web +Description=Linux real time system monitoring, done right After=network.target httpd.service squid.service nfs-server.service mysqld.service named.service postfix.service [Service]