diff options
author | Pav Lucistnik <pav@FreeBSD.org> | 2005-05-26 19:26:04 +0000 |
---|---|---|
committer | Pav Lucistnik <pav@FreeBSD.org> | 2005-05-26 19:26:04 +0000 |
commit | bbe10a6dc6d236b92ae5caa8574f8cf78a4ac040 (patch) | |
tree | 264e68656d97beaa1ae68b9ffadc3ba9ceea2a11 /net-mgmt | |
parent | 65eb37d96f72fa561c06f64c4d6dac3b09c4ead8 (diff) | |
download | ports-bbe10a6dc6d236b92ae5caa8574f8cf78a4ac040.tar.gz ports-bbe10a6dc6d236b92ae5caa8574f8cf78a4ac040.zip |
Notes
Diffstat (limited to 'net-mgmt')
-rw-r--r-- | net-mgmt/nrpe2/Makefile | 8 | ||||
-rw-r--r-- | net-mgmt/nrpe2/files/nrpe2.sh.in | 33 | ||||
-rw-r--r-- | net-mgmt/nrpe2/files/patch-pid-file | 76 | ||||
-rw-r--r-- | net-mgmt/nrpe2/pkg-plist | 4 |
4 files changed, 115 insertions, 6 deletions
diff --git a/net-mgmt/nrpe2/Makefile b/net-mgmt/nrpe2/Makefile index 00fff0c682f6..974ec25cb83c 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 000000000000..4fc22dd761a4 --- /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 000000000000..07173a557376 --- /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 b62af3f4663f..000000000000 --- 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 |