From add94817fa8c60c727028287594f5243221c4705 Mon Sep 17 00:00:00 2001 From: "John C. Frickson" Date: Wed, 27 Apr 2016 16:10:20 -0500 Subject: [PATCH] Changes to add /usr/lib/tmpfiles.d/nrpe to macros, install and uninstall --- Makefile.in | 6 +++ build-aux/ax_nagios_get_files | 1 + configure | 5 ++- configure.ac | 17 ++++---- src/Makefile.in | 6 +++ startup/tmpfile.conf.in | 2 + uninstall.in | 77 +++++++++++++++++++---------------- 7 files changed, 70 insertions(+), 44 deletions(-) create mode 100644 startup/tmpfile.conf.in diff --git a/Makefile.in b/Makefile.in index 59aea139..614c82a5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -89,6 +89,12 @@ install-inetd: else \ echo $(INSTALL) -m 644 startup/$(SRC_INETD) $(INETD_DIR)/$(INETD_FILE); \ $(INSTALL) -m 644 startup/$(SRC_INETD) $(INETD_DIR)/$(INETD_FILE); \ + if test $(INETD_TYPE) = systemd; then \ + SRC_INETD_FILE=`echo "$SRC_INETD_FILE" | sed -e 's/socket$/socket-svc/'`; \ + $(INSTALL) -m 644 startup/$(SRC_INETD) $(INETD_DIR)/$(INETD_FILE); \ + INETD_FILE=`echo "$INETD_FILE" | sed -e 's/socket$/service/'`; \ + $(INSTALL) -m 644 startup/$(SRC_INETD) $(INETD_DIR)/$(INETD_FILE); \ + fi; \ fi @grep -E -q "^nrpe[\t ]+5666/tcp" /etc/services || \ echo "***** MAKE SURE 'nrpe 5666/tcp' IS IN YOUR /etc/services FILE" diff --git a/build-aux/ax_nagios_get_files b/build-aux/ax_nagios_get_files index 2174560d..f7f9fa95 100755 --- a/build-aux/ax_nagios_get_files +++ b/build-aux/ax_nagios_get_files @@ -60,6 +60,7 @@ AS_CASE([$init_type], fi, [systemd], + src_tmpfile=tmpfile.conf.in src_init=default-service, [bsd], diff --git a/configure b/configure index dd658319..2a8bc3a7 100755 --- a/configure +++ b/configure @@ -642,6 +642,7 @@ INSTALL_SCRIPT INSTALL_PROGRAM src_inetd src_init +src_tmpfile subsyslockfile subsyslockdir tmpfilesd @@ -2536,6 +2537,7 @@ LC_TIME=C + # Find a good install program. We prefer a C program (faster), @@ -3684,7 +3686,8 @@ case $init_type in #( src_init=default-init fi ;; #( systemd) : - src_init=default-service ;; #( + src_tmpfile=tmpfile.conf.in + src_init=default-service ;; #( bsd) : src_init=bsd-init ;; #( newbsd) : diff --git a/configure.ac b/configure.ac index 5a177a29..e23dc3a6 100644 --- a/configure.ac +++ b/configure.ac @@ -71,6 +71,7 @@ AC_SUBST(inetddir) AC_SUBST(tmpfilesd) AC_SUBST(subsyslockdir) AC_SUBST(subsyslockfile) +AC_SUBST(src_tmpfile) AC_SUBST(src_init) AC_SUBST(src_inetd) @@ -194,7 +195,7 @@ ac_cv_HAVE_VA_COPY=yes, ac_cv_HAVE_VA_COPY=no)]) if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available]) -else +else AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[ AC_TRY_LINK([#include va_list ap1,ap2;], [__va_copy(ap1,ap2);], @@ -219,7 +220,7 @@ AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[ AC_TRY_RUN([ #include #include -void foo(const char *format, ...) { +void foo(const char *format, ...) { va_list ap; int len; char buf[5]; @@ -272,11 +273,11 @@ AC_CHECK_TYPE([socklen_t], ,[ AC_TRY_COMPILE([ #ifdef HAVE_SYS_TYPES_H #include - #endif + #endif #ifdef HAVE_SYS_SOCKET_H #include #endif - + int getpeername (int, $arg2 *, $t *); ],[ $t len; @@ -287,7 +288,7 @@ AC_CHECK_TYPE([socklen_t], ,[ ]) done done - + if test "x$curl_cv_socklen_t_equiv" = x; then AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) fi @@ -400,7 +401,7 @@ if test x$check_for_ssl = xyes; then found_ssl=yes break fi - done + done if test x_$found_ssl != x_yes; then AC_MSG_ERROR(Cannot find ssl libraries) @@ -411,7 +412,7 @@ if test x$check_for_ssl = xyes; then LIBS="$LIBS -lssl -lcrypto"; AC_DEFINE_UNQUOTED(HAVE_SSL,[1],[Have SSL support]) - + AC_PATH_PROG(sslbin,openssl,value-if-not-found,$ssldir/sbin$PATH_SEPARATOR$ssldir/bin$PATH_SEPARATOR$PATH) dnl Generate DH parameters @@ -443,7 +444,7 @@ if test x$check_for_ssl = xyes; then else printf "found Kerberos include files in $kerbdir\n"; fi - + fi diff --git a/src/Makefile.in b/src/Makefile.in index 4469c782..a7c7fc0a 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -31,6 +31,8 @@ NRPE_INSTALL_OPTS=@NRPE_INSTALL_OPTS@ PLUGINSDIR=@pluginsdir@ PIDDIR=@piddir@ +TMPFILESDIR=@tmpfilesd@ +SRC_TMPFILE=@src_tmpfile@ #AC_SUBST(pkgsysconfdir) #AC_SUBST(objsysconfdir) @@ -76,6 +78,10 @@ install-daemon: install-uninstall echo $(INSTALL) -m 755 $(NRPE_INSTALL_OPTS) -d $(PIDDIR); \ $(INSTALL) -m 755 $(NRPE_INSTALL_OPTS) -d $(PIDDIR); \ fi + @if test "$TMPFILESDIR" != "N/A" ; then \ + echo $(INSTALL) -m 644 startup/$(SRC_TMPFILE) $(TMPFILESDIR)/nrpe; \ + $(INSTALL) -m 644 startup/$(SRC_TMPFILE) $(TMPFILESDIR)/nrpe; \ + fi install-uninstall: $(INSTALL) -m 755 -d $(SBINDIR) diff --git a/startup/tmpfile.conf.in b/startup/tmpfile.conf.in new file mode 100644 index 00000000..df4da7b9 --- /dev/null +++ b/startup/tmpfile.conf.in @@ -0,0 +1,2 @@ +#Type Path Mode UID GID Age Argument +D @piddir@ 0755 @nagios_user@ @nagios_group@ - - diff --git a/uninstall.in b/uninstall.in index bb77e357..9db5af7d 100755 --- a/uninstall.in +++ b/uninstall.in @@ -30,13 +30,12 @@ SRC_INIT=@src_init@ # Display usage message usage () { echo "Usage: $0 [-q] [-p] [-v] progs|config|startup|all" - echo "-q Do not print what is happening" - echo "-p Prompt for each action" - echo "-v Be a little more verbose about what is happening" - echo "progs Delete the program files" - echo "config Delete configuration file(s)" - echo "startup Delete startup files (inetd, init, etc.)" - echo " Delete startup files (inetd, init, etc.)" + echo " -q Do not print what is happening" + echo " -p Prompt for each action" + echo " -v Be a little more verbose about what is happening" + echo " progs Delete the program files" + echo " config Delete configuration file(s)" + echo " startup Delete startup files (inetd, init, etc.)" exit 1 } @@ -76,6 +75,14 @@ prt_msg () { return 0 fi + case $1 in + 0) indent="" ;; + 1) indent=" " ;; + 2) indent=" " ;; + *) indent="" ;; + esac + shift + if test $1 -eq 1 -a $verb -eq 0 -a $prompt -eq 0 ; then return 0 fi @@ -83,7 +90,7 @@ prt_msg () { if test $1 -eq 1 -a $prompt -eq 1 ; then shift - echo -n " $*" + echo -n "${indent}$*" echo -n "? [Y|n] " read yn if test "x$yn" = x -o x$yn = xy -o x$yn = xY ; then @@ -94,67 +101,67 @@ prt_msg () { fi shift - echo " $*" + echo "${indent}$*" return 0 } rm_progs () { num=0 - prt_msg 0 0 "*** Uninstalling Progs" + prt_msg 1 0 0 "*** Uninstalling Progs" if test -f "$PLUGINSDIR/check_nrpe" ; then num=1 - prt_msg 0 1 "Delete $PLUGINSDIR/check_nrpe" && { + prt_msg 2 0 1 "Delete $PLUGINSDIR/check_nrpe" && { rm $force "$PLUGINSDIR/check_nrpe" - prt_msg 1 0 "Remove directory $PLUGINSDIR" + prt_msg 2 1 0 "Remove directory $PLUGINSDIR" rmdir "$PLUGINSDIR" $redir - prt_msg 1 0 "Remove directory $LIBEXECDIR" + prt_msg 2 1 0 "Remove directory $LIBEXECDIR" rmdir "$LIBEXECDIR" $redir } fi if test -f "$SBINDIR/$NAME" ; then num=0 - prt_msg 0 1 "Delete $SBINDIR/$NAME" && { + prt_msg 2 0 1 "Delete $SBINDIR/$NAME" && { rm $force "$SBINDIR/$NAME" } fi if test -d "$PIDDIR" ; then num=0 - prt_msg 0 1 "Remove directory $PIDDIR" && { + prt_msg 2 0 1 "Remove directory $PIDDIR" && { rmdir "$PIDDIR" $redir } fi if test $num -eq 0; then - prt_msg 0 0 "There was nothing to uninstall" + prt_msg 2 0 0 "There was nothing to uninstall" fi } rm_startup () { num=0 - prt_msg 0 0 "*** Uninstalling Startup" + prt_msg 1 0 0 "*** Uninstalling Startup" if test "$SRC_INETD" != unknown; then if test "$INETD_TYPE" = inetd; then rc=`grep -E -q "^\W*@PKG_NAME@\s+" "$INETD_DIR/$INETD_FILE"` if test $rc -eq 0; then num=1 - prt_msg 0 1 "($INETD_TYPE) Remove entries from $INETD_DIR/$INETD_FILE" && { - prt_msg 1 0 "($INETD_TYPE) Creating temp file: $INETD_DIR/$INETD_FILE.$NAME.unin" + prt_msg 2 0 1 "($INETD_TYPE) Remove entries from $INETD_DIR/$INETD_FILE" && { + prt_msg 2 1 0 "($INETD_TYPE) Creating temp file: $INETD_DIR/$INETD_FILE.$NAME.unin" grep -v -q "\W*@PKG_NAME@\s+" "$INETD_DIR/$INETD_FILE" > "$INETD_DIR/$INETD_FILE.$NAME.unin" - prt_msg 1 0 "($INETD_TYPE) Renaming original to: $INETD_DIR/$INETD_FILE.$NAME_save" + prt_msg 2 1 0 "($INETD_TYPE) Renaming original to: $INETD_DIR/$INETD_FILE.$NAME_save" mv "$INETD_DIR/$INETD_FILE" "$INETD_DIR/$INETD_FILE.$NAME_save" - prt_msg 1 0 "($INETD_TYPE) Renaming $INETD_DIR/$INETD_FILE.unin to $INETD_DIR/$INETD_FILE" + prt_msg 2 1 0 "($INETD_TYPE) Renaming $INETD_DIR/$INETD_FILE.unin to $INETD_DIR/$INETD_FILE" mv "$INETD_DIR/$INETD_FILE.unin" "$INETD_DIR/$INETD_FILE" - prt_msg 0 0 "($INETD_TYPE) Old $INETD_DIR/$INETD_FILE saved as $INETD_DIR/$INETD_FILE.$NAME_save" + prt_msg 2 0 0 "($INETD_TYPE) Old $INETD_DIR/$INETD_FILE saved as $INETD_DIR/$INETD_FILE.$NAME_save" } fi elif test -f "$INETD_DIR/$INETD_FILE"; then num=1 if test "$INETD_TYPE" != xinetd; then - prt_msg 0 1 "($INETD_TYPE) Stop and disable $NAME)" && { + prt_msg 2 0 1 "($INETD_TYPE) Stop and disable $NAME)" && { case "$INETD_TYPE" in systemd) systemctl stop $NAME; systemctl disable $NAME @@ -171,11 +178,11 @@ rm_startup () { esac } fi - prt_msg 0 1 "($INETD_TYPE) Delete $INETD_DIR/$INETD_FILE" && { + prt_msg 2 0 1 "($INETD_TYPE) Delete $INETD_DIR/$INETD_FILE" && { rm $force "$INETD_DIR/$INETD_FILE" if test "$INETD_TYPE" = systemd; then INETD_FILE=`echo "$INETD_FILE" | sed -e 's/socket$/service/'` - prt_msg 0 1 "($INETD_TYPE) Delete $INETD_DIR/$INETD_FILE" && { + prt_msg 2 0 1 "($INETD_TYPE) Delete $INETD_DIR/$INETD_FILE" && { rm $force "$INETD_DIR/$INETD_FILE" } fi @@ -186,7 +193,7 @@ rm_startup () { if test "$SRC_INIT" != unknown; then if test -f "$INIT_DIR/$INIT_FILE"; then num=1 - prt_msg 0 1 "($INIT_TYPE) Stop and disable $NAME" && { + prt_msg 2 0 1 "($INIT_TYPE) Stop and disable $NAME" && { case "$INIT_TYPE" in systemd) systemctl stop $NAME; systemctl disable $NAME @@ -215,40 +222,40 @@ rm_startup () { ;; esac } - prt_msg 0 1 "($INIT_TYPE) Delete $INETD_DIR/$INIT_FILE" && { + prt_msg 2 0 1 "($INIT_TYPE) Delete $INETD_DIR/$INIT_FILE" && { rm $force "$INIT_DIR/$INIT_FILE" } fi fi if test $num -eq 0; then - prt_msg 0 0 "There was nothing to uninstall" + prt_msg 2 0 0 "There was nothing to uninstall" fi } rm_config () { num=0 - prt_msg 0 0 "*** Uninstalling Config" + prt_msg 1 0 0 "*** Uninstalling Config" - if test -f "$CFGDIR/$NAME.cfg" then ; + if test -f "$CFGDIR/$NAME.cfg"; then num=1 - prt_msg 0 1 "Delete $CFGDIR/$NAME.cfg" || return + prt_msg 2 0 1 "Delete $CFGDIR/$NAME.cfg" || return rm $force "$CFGDIR/$NAME.cfg" - prt_msg 1 0 "Removing directory $CFGDIR" + prt_msg 2 1 0 "Removing directory $CFGDIR" rm $force "$CFGDIR" fi if test $num -eq 0; then - prt_msg 0 0 "There was nothing to uninstall" + prt_msg 2 0 0 "There was nothing to uninstall" fi } get_opts $@ -echo "* * * Uninstall Starting * * *" +prt_msg 0 0 0 "* * * Uninstall Starting * * *" if test $progs -eq 1 ; then rm_progs; fi if test $start -eq 1 ; then rm_startup; fi if test $config -eq 1 ; then rm_config; fi -echo "* * * Uninstall Complete * * *" +prt_msg 0 0 0 "* * * Uninstall Complete * * *"