summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2016-06-15 12:40:16 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2016-06-15 12:40:16 +0000
commite2976e5db1cc8e41b47ac8f806654240c338ee6a (patch)
treea3946a9c7dde3e430fde3b68db9e4a7bf2d81aa0
parentadded missing-sources to the list and listed additional missing copyrights (diff)
downloadnetdata-e2976e5db1cc8e41b47ac8f806654240c338ee6a.tar.xz
netdata-e2976e5db1cc8e41b47ac8f806654240c338ee6a.zip
Add init script
-rw-r--r--debian/netdata.init126
1 files changed, 126 insertions, 0 deletions
diff --git a/debian/netdata.init b/debian/netdata.init
new file mode 100644
index 000000000..39f7858ff
--- /dev/null
+++ b/debian/netdata.init
@@ -0,0 +1,126 @@
+#! /bin/bash
+### BEGIN INIT INFO
+# Provides: netdata
+# Required-Start: $local_fs $remote_fs $network
+# Required-Stop: $local_fs $remote_fs $network
+# Should-Start: $syslog
+# Should-Stop: $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Real-time charts for system monitoring
+# Description: Start netdata, a real-time monitoring tool
+### END INIT INFO
+
+# Documentation
+# man netdata
+# file:///usr/share/doc/netdata/html/index.html
+# https://github.com/firehol/netdata
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+. /lib/lsb/init-functions
+
+NAME=netdata
+DAEMON=/usr/sbin/$NAME
+DAEMON_USER=$NAME
+DAEMON_ARGS=""
+
+# Exit if executable is not installed
+[ -x "$DAEMON" ] || exit 0
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+DESC="the netdata daemon"
+PIDFILE=/var/run/netdata/netdata.pid
+DEFAULTSFILE=/etc/default/$NAME
+
+case "$1" in
+ start)
+ if [ ! -f "$CONF_FNAME" ]; then
+ log_action_msg "Not starting $DESC: $CONF_FNAME is missing."
+ exit 0
+ fi
+
+ log_action_begin_msg "Starting $DESC"
+
+ if start-stop-daemon --stop --signal 0 --quiet --pidfile $PIDFILE --exec $DAEMON; then
+ log_action_end_msg 0 "already running"
+ else
+ if start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $DEFAULT_ARGS
+ then
+ log_action_end_msg 0
+ else
+ log_action_end_msg 1
+ exit 1
+ fi
+ fi
+ ;;
+ stop)
+ log_action_begin_msg "Stopping $DESC"
+ pid=`cat $PIDFILE 2>/dev/null` || true
+ if test ! -f $PIDFILE -o -z "$pid"; then
+ log_action_end_msg 0 "not running - there is no $PIDFILE"
+ exit 0
+ fi
+
+ if start-stop-daemon --stop --signal INT --quiet --pidfile $PIDFILE --exec $DAEMON; then
+ true
+ elif kill -0 $pid 2>/dev/null; then
+ log_action_end_msg 1 "Is $pid not $NAME? Is $DAEMON a different binary now?"
+ exit 1
+ else
+ log_action_end_msg 1 "$DAEMON died: process $pid not running; or permission denied"
+ exit 1
+ fi
+ ;;
+ reload)
+ echo "Not implemented"
+ exit 1
+ log_action_begin_msg "Reloading $DESC configuration"
+ pid=`cat $PIDFILE 2>/dev/null` || true
+ if test ! -f $PIDFILE -o -z "$pid"; then
+ log_action_end_msg 1 "not running - there is no $PIDFILE"
+ exit 1
+ fi
+
+ if start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --exec $DAEMON
+ then
+ log_action_end_msg 0
+ elif kill -0 $pid 2>/dev/null; then
+ log_action_end_msg 1 "Is $pid not $NAME? Is $DAEMON a different binary now?"
+ exit 1
+ else
+ log_action_end_msg 1 "$DAEMON died: process $pid not running; or permission denied"
+ exit 1
+ fi
+ ;;
+ restart|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ status)
+ if test ! -r $(dirname $PIDFILE); then
+ log_failure_msg "cannot read PID file $PIDFILE"
+ exit 4
+ fi
+ pid=`cat $PIDFILE 2>/dev/null` || true
+ if test ! -f $PIDFILE -o -z "$pid"; then
+ log_failure_msg "$NAME is not running"
+ exit 3
+ fi
+ if ps "$pid" >/dev/null 2>&1; then
+ log_success_msg "$NAME is running"
+ exit 0
+ else
+ log_failure_msg "$NAME is not running"
+ exit 1
+ fi
+ ;;
+ *)
+ log_action_msg "Usage: $0 {start|stop|restart|force-reload|status}" >&2
+ exit 1
+ ;;
+esac
+
+exit 0