summaryrefslogtreecommitdiffstats
path: root/system/netdata-init-d.in
diff options
context:
space:
mode:
authorLennart Weller <lhw@ring0.de>2016-04-21 12:27:29 +0000
committerLennart Weller <lhw@ring0.de>2016-04-21 12:27:29 +0000
commit30b94862648cdbf4f537337d2e2f01c369a9dee9 (patch)
treef0219dd8bd744fc09899bd0266402e05a4bff854 /system/netdata-init-d.in
parentImported Upstream version 1.0.0 (diff)
downloadnetdata-30b94862648cdbf4f537337d2e2f01c369a9dee9.tar.xz
netdata-30b94862648cdbf4f537337d2e2f01c369a9dee9.zip
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to '')
-rwxr-xr-xsystem/netdata-init-d.in57
1 files changed, 57 insertions, 0 deletions
diff --git a/system/netdata-init-d.in b/system/netdata-init-d.in
new file mode 100755
index 00000000..c317d102
--- /dev/null
+++ b/system/netdata-init-d.in
@@ -0,0 +1,57 @@
+#!/bin/bash
+# chkconfig: 345 99 01
+# description: startup script
+
+# Source functions
+. /etc/rc.d/init.d/functions
+
+DAEMON="netdata"
+DAEMON_PATH=@sbindir_POST@
+PIDFILE=@localstatedir_POST@/$DAEMON.pid
+DAEMONOPTS="-pidfile $PIDFILE"
+STOP_TIMEOUT="10"
+
+service_start()
+{
+ echo "Starting $DAEMON..."
+ daemon $DAEMON_PATH/$DAEMON $DAEMONOPTS
+ RETVAL=$?
+ echo
+ return $RETVAL
+}
+
+service_stop()
+{
+ printf "%-50s" "Stopping $DAEMON..."
+ killproc -p ${PIDFILE} -d ${STOP_TIMEOUT} $DAEMON
+ RETVAL=$?
+ if [ $RETVAL -eq 0 ]; then
+ rm -f ${PIDFILE}
+ fi
+ echo
+ return $RETVAL
+}
+
+service_status()
+{
+ status -p ${PIDFILE} $DAEMON_PATH/$DAEMON
+}
+
+case "$1" in
+start)
+ service_start
+;;
+status)
+ service_status
+;;
+stop)
+ service_stop
+;;
+restart)
+ service_stop
+ service_start
+;;
+*)
+ echo "Usage: $0 {status|start|stop|restart}"
+ exit 1
+esac