Browse Source

Merge pull request #126 from box293/init-changes

Added support for Gentoo init and fixed existing openrc script. It would be nice to get some extra eyes on this if possible until I can get a gentoo environment set up. Thanks @box293 !
Bryan Heden 8 years ago
parent
commit
bada7ddc74
4 changed files with 61 additions and 8 deletions
  1. 4 0
      Makefile.in
  2. 6 6
      configure
  3. 49 0
      startup/gentoo-init.in
  4. 2 2
      startup/openrc-init.in

+ 4 - 0
Makefile.in

@@ -110,6 +110,10 @@ install-init:
 		echo svccfg import $(INIT_DIR)/$(INIT_FILE); \
 		svccfg import $(INIT_DIR)/$(INIT_FILE); \
 		echo "*** Run 'svcadm enable nrpe' to start it"; \
+	elif test $(INIT_TYPE) = gentoo; then\
+		$(INSTALL) -m 755 startup/$(SRC_INIT) $(INIT_DIR)/$(INIT_FILE); \
+		echo rc-update add nrpe default; \
+		rc-update add nrpe default; \
 	else\
 		echo $(INSTALL) -m 755 startup/$(SRC_INIT) $(INIT_DIR)/$(INIT_FILE); \
 		$(INSTALL) -m 755 startup/$(SRC_INIT) $(INIT_DIR)/$(INIT_FILE); \

+ 6 - 6
configure

@@ -2941,10 +2941,10 @@ fi
 				elif test -f "/sbin/rc"; then
 					if test -f /sbin/runscript; then
 						init_type_wanted=no
-						if `/sbin/start-stop-daemon -V | grep "OpenRC" > /dev/null`; then
-							init_type="openrc"
-						else
+						if `/sbin/start-stop-daemon -V | grep "OpenRC.*Gentoo" > /dev/null`; then
 							init_type="gentoo"
+						else
+							init_type="openrc"
 						fi
 					fi
 				fi
@@ -3831,10 +3831,10 @@ case $init_type in #(
 			bsd_enable=""
 			src_init=newbsd-init
 		fi ;; #(
-  #	[gentoo],
-
 	openrc) :
     src_init=openrc-init ;; #(
+  gentoo) :
+    src_init=gentoo-init ;; #(
   smf*) :
     src_init="solaris-init.xml"
 		src_inetd="solaris-inetd.xml" ;; #(
@@ -4975,7 +4975,7 @@ fi
 
 ac_config_headers="$ac_config_headers include/config.h"
 
-ac_config_files="$ac_config_files Makefile src/Makefile nrpe.spec uninstall sample-config/nrpe.cfg startup/bsd-init startup/debian-init startup/default-init startup/default-inetd startup/default-service startup/default-socket startup/default-socket-svc startup/default-xinetd startup/mac-init.plist startup/mac-inetd.plist startup/newbsd-init startup/openbsd-init startup/openrc-conf startup/openrc-init startup/solaris-init.xml startup/solaris-inetd.xml startup/tmpfile.conf startup/upstart-init startup/rh-upstart-init include/common.h"
+ac_config_files="$ac_config_files Makefile src/Makefile nrpe.spec uninstall sample-config/nrpe.cfg startup/bsd-init startup/debian-init startup/default-init startup/default-inetd startup/default-service startup/default-socket startup/default-socket-svc startup/default-xinetd startup/mac-init.plist startup/mac-inetd.plist startup/newbsd-init startup/openbsd-init startup/openrc-conf startup/openrc-init startup/gentoo-init startup/solaris-init.xml startup/solaris-inetd.xml startup/tmpfile.conf startup/upstart-init startup/rh-upstart-init include/common.h"
 
 
 ac_ext=c

+ 49 - 0
startup/gentoo-init.in

@@ -0,0 +1,49 @@
+#!/sbin/openrc-run
+#
+# Copyright (c) 2016 Nagios(R) Core(TM) Development Team
+#
+# Start/stop the nrpe daemon.
+#
+# Goes in /etc/init.d - Config is in /etc/conf.d/nrpe
+
+extra_started_commands="reload"
+
+NRPE_BIN="@sbindir@/nrpe"
+NRPE_PID="@piddir@/nrpe.pid"
+NRPE_CFG=@pkgsysconfdir@/nrpe.cfg
+
+depend() {
+	use logger dns net localmount netmount nfsmount
+}
+
+checkconfig() {
+	# Make sure the config file exists
+	if [ ! -f $NRPE_CFG ]; then
+		eerror "You need to setup $NRPE_CFG."
+		return 1
+	fi
+	return 0
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting nrpe"
+	# Make sure we have a sane current directory
+	cd /
+	start-stop-daemon --start --exec $NRPE_BIN --pidfile $NRPE_PID \
+		--background -- -c $NRPE_CFG -f $NRPE_OPTS
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping nrpe"
+	start-stop-daemon --stop --exec $NRPE_BIN --pidfile $NRPE_PID
+	eend $?
+}
+
+reload() {
+	ebegin "Reloading nrpe"
+	start-stop-daemon --stop --oknodo --exec $NRPE_BIN \
+		--pidfile $NRPE_PID --signal HUP
+	eend $?
+}

+ 2 - 2
startup/openrc-init.in

@@ -19,7 +19,7 @@ depend() {
 checkconfig() {
 	# Make sure the config file exists
 	if [ ! -f $NRPE_CFG ]; then
-		eerror "You need to setup $NRPE_CFG.
+		eerror "You need to setup $NRPE_CFG."
 		return 1
 	fi
 	return 0
@@ -31,7 +31,7 @@ start() {
 	# Make sure we have a sane current directory
 	cd /
 	start-stop-daemon --start --exec $NRPE_BIN --pidfile $PID_FILE \
-		-- -c $NRPE_CFG -f $NRPE_OPTS
+		--background -- -c $NRPE_CFG -f $NRPE_OPTS
 	eend $?
 }