]> arthur.barton.de Git - netdata.git/commitdiff
Added init script generation for Redhat6/Centos6
authorwaldemar.spitschak <waldemar.spitschak@esailors.de>
Tue, 5 Apr 2016 17:43:45 +0000 (19:43 +0200)
committerwaldemar.spitschak <waldemar.spitschak@esailors.de>
Tue, 5 Apr 2016 17:43:45 +0000 (19:43 +0200)
system/Makefile.am
system/netdata-init-d.in [new file with mode: 0755]

index c917a2298e0c194d02835e5b021d2943e39ffc8f..49cb5f7bc1b481f30f33c64674a865e554ce5c7f 100644 (file)
@@ -5,6 +5,7 @@ MAINTAINERCLEANFILES= $(srcdir)/Makefile.in
 CLEANFILES = \
        netdata-openrc \
        netdata.service \
+       netdata-init-d \
        $(NULL)
 
 include $(top_srcdir)/build/subst.inc
@@ -14,9 +15,11 @@ SUFFIXES = .in
 nodist_noinst_DATA = \
        netdata-openrc \
        netdata.service \
+       netdata-init-d \
        $(NULL)
 
 dist_noinst_DATA = \
        netdata-openrc.in \
        netdata.service.in \
+       netdata-init-d.in \
        $(NULL)
diff --git a/system/netdata-init-d.in b/system/netdata-init-d.in
new file mode 100755 (executable)
index 0000000..8c46433
--- /dev/null
@@ -0,0 +1,51 @@
+#!/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()
+{
+       printf "%-50s" "Starting $DAEMON..."
+       daemon $DAEMON_PATH/$DAEMON $DAEMONOPTS
+       echo
+}
+
+service_stop()
+{
+       printf "%-50s" "Stopping $DAEMON..."
+       killproc -p ${PIDFILE} -d ${STOP_TIMEOUT} $DAEMON
+       rm -f ${PIDFILE}
+       echo
+}
+
+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