summaryrefslogtreecommitdiffstats
path: root/net-mgmt
diff options
context:
space:
mode:
authorpav <pav@FreeBSD.org>2005-05-26 19:26:04 +0000
committerpav <pav@FreeBSD.org>2005-05-26 19:26:04 +0000
commitd47c7785d9d06ff35333e5e2c0d22ae0df1baf50 (patch)
tree62c6ff6d588140a053faaa5044647fcfc79ba498 /net-mgmt
parent90cf012f8ddd6943414905668a88a2f52e76a93b (diff)
downloadFreeBSD-ports-d47c7785d9d06ff35333e5e2c0d22ae0df1baf50.zip
FreeBSD-ports-d47c7785d9d06ff35333e5e2c0d22ae0df1baf50.tar.gz
- add rcng startup script
- make nrpe write pid file in /var/run - replace pkg-plist file with PLIST_FILES in Makefile PR: ports/81139 Submitted by: Meno Abels <meno.abels@adviser.com> Approved by: Paul Dlug <paul@nerdlabs.com> (maintainer)
Diffstat (limited to 'net-mgmt')
-rw-r--r--net-mgmt/nrpe2/Makefile8
-rw-r--r--net-mgmt/nrpe2/files/nrpe2.sh.in33
-rw-r--r--net-mgmt/nrpe2/files/patch-pid-file76
-rw-r--r--net-mgmt/nrpe2/pkg-plist4
4 files changed, 115 insertions, 6 deletions
diff --git a/net-mgmt/nrpe2/Makefile b/net-mgmt/nrpe2/Makefile
index 00fff0c..974ec25 100644
--- a/net-mgmt/nrpe2/Makefile
+++ b/net-mgmt/nrpe2/Makefile
@@ -7,7 +7,7 @@
PORTNAME= nrpe2
PORTVERSION= 2.0
-PORTREVISION= 0
+PORTREVISION= 1
CATEGORIES= net-mgmt
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= nagios
@@ -20,6 +20,11 @@ RUN_DEPENDS= ${LOCALBASE}/libexec/nagios/check_nagios:${PORTSDIR}/net-mgmt/nagi
GNU_CONFIGURE= yes
USE_PERL5_BUILD= yes
+USE_REINPLACE= yes
+
+USE_RC_SUBR= nrpe2.sh
+
+PLIST_FILES= sbin/nrpe2 etc/nrpe.cfg-sample libexec/nagios/check_nrpe2
CONFIGURE_ARGS+= --libexecdir=${PREFIX}/libexec/nagios --bindir=${PREFIX}/sbin --sysconfdir=${PREFIX}/etc
@@ -43,6 +48,5 @@ do-install:
${INSTALL_PROGRAM} ${WRKSRC}/src/nrpe ${PREFIX}/sbin/nrpe2
${INSTALL_PROGRAM} ${WRKSRC}/src/check_nrpe ${PREFIX}/libexec/nagios/check_nrpe2
${INSTALL_DATA} ${WRKSRC}/nrpe.cfg ${PREFIX}/etc/nrpe.cfg-sample
- ${INSTALL_SCRIPT} ${WRKSRC}/init-script.freebsd ${PREFIX}/etc/rc.d/nrpe.sh
.include <bsd.port.post.mk>
diff --git a/net-mgmt/nrpe2/files/nrpe2.sh.in b/net-mgmt/nrpe2/files/nrpe2.sh.in
new file mode 100644
index 0000000..4fc22dd
--- /dev/null
+++ b/net-mgmt/nrpe2/files/nrpe2.sh.in
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: nrpe2
+# REQUIRE: NETWORKING
+# KEYWORD: FreeBSD shutdown
+
+#
+# Add the following lines to /etc/rc.conf to enable nrpe2:
+#
+#nrpe2_enable="YES"
+#
+#
+
+. %%RC_SUBR%%
+
+name=nrpe2
+rcvar=`set_rcvar`
+
+command="%%PREFIX%%/sbin/nrpe2"
+required_files=%%PREFIX%%/etc/nrpe.cfg
+command_args="-c ${required_files} -d"
+pidfile=/var/run/${name}.pid
+
+# set defaults
+
+nrpe2_enable=${nrpe2_enable:-"NO"}
+nrpe2_flags=${nrpe2_flags:-""}
+
+load_rc_config ${name}
+run_rc_command "$1"
diff --git a/net-mgmt/nrpe2/files/patch-pid-file b/net-mgmt/nrpe2/files/patch-pid-file
new file mode 100644
index 0000000..07173a5
--- /dev/null
+++ b/net-mgmt/nrpe2/files/patch-pid-file
@@ -0,0 +1,76 @@
+--- orig/nrpe-2.0/src/Makefile.in Tue Aug 5 07:01:53 2003
++++ src/Makefile.in Tue May 17 00:25:33 2005
+@@ -9,7 +9,7 @@
+ SRC_COMMON=../common
+
+ CC=@CC@
+-CFLAGS=@CFLAGS@ @DEFS@
++CFLAGS=@CFLAGS@ @DEFS@ -DPID_DIR=\"/var/run/\"
+ LDFLAGS=@LDFLAGS@ @LIBS@
+ SOCKETLIBS=@SOCKETLIBS@
+
+--- orig/nrpe-2.0/src/nrpe.c Tue Sep 9 04:52:37 2003
++++ src/nrpe.c Tue May 17 00:24:29 2005
+@@ -23,6 +23,7 @@
+ #include "nrpe.h"
+ #include "utils.h"
+
++
+ #ifdef HAVE_SSL
+ #include "dh.h"
+ #endif
+@@ -83,7 +84,6 @@
+ #endif
+
+
+-
+ int main(int argc, char **argv){
+ int result=OK;
+ int x;
+@@ -219,7 +219,45 @@
+
+ /* else daemonize and start listening for requests... */
+ else if(fork()==0){
+-
++#ifdef PID_DIR
++ int fd;
++ int pid_written = 0;
++ char *pid_fname;
++ char pbuf[16];
++ char *bname = strrchr(argv[0], '/'); /* basename from XPG4.2 would be nice */
++
++ bname = !bname ? argv[0] : ++bname;
++ pid_fname = malloc(strlen(PID_DIR) + strlen(bname) + sizeof(".pid"));
++ strcpy(pid_fname, PID_DIR);
++ strcat(pid_fname, bname); strcat(pid_fname, ".pid");
++ if ((fd = open (pid_fname, O_RDONLY)) >= 0) {
++ int status = read (fd, pbuf, (sizeof pbuf) - 1);
++ close (fd);
++ if (status > 0) {
++ int pid;
++ pbuf [status] = 0;
++ pid = atoi (pbuf);
++ /* If the previous server process is not still running,
++ write a new pid file immediately. */
++ if (pid && (pid == getpid() || kill (pid, 0) < 0)) {
++ unlink (pid_fname);
++ } else {
++ syslog(LOG_ERR,"There's already a nrpe server running.");
++ free(pid_fname);
++ return STATE_CRITICAL;
++ }
++ }
++ }
++ if ((fd = open (pid_fname, O_WRONLY | O_CREAT, 0644)) >= 0) {
++ sprintf (pbuf, "%d\n", (int)getpid ());
++ write (fd, pbuf, strlen (pbuf));
++ close (fd);
++ } else {
++ syslog(LOG_ERR,"Can not write the pidfile(%s).", pid_fname);
++ }
++ free(pid_fname);
++#endif
++
+ /* we're a daemon - set up a new process group */
+ setsid();
+
diff --git a/net-mgmt/nrpe2/pkg-plist b/net-mgmt/nrpe2/pkg-plist
deleted file mode 100644
index b62af3f..0000000
--- a/net-mgmt/nrpe2/pkg-plist
+++ /dev/null
@@ -1,4 +0,0 @@
-sbin/nrpe2
-etc/nrpe.cfg-sample
-etc/rc.d/nrpe.sh
-libexec/nagios/check_nrpe2
OpenPOWER on IntegriCloud