Skip to content

Commit

Permalink
Changes to add /usr/lib/tmpfiles.d/nrpe to macros, install and uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
John C. Frickson committed Apr 27, 2016
1 parent 6490db3 commit add9481
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 44 deletions.
6 changes: 6 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions build-aux/ax_nagios_get_files
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ AS_CASE([$init_type],
fi,

[systemd],
src_tmpfile=tmpfile.conf.in
src_init=default-service,

[bsd],
Expand Down
5 changes: 4 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ INSTALL_SCRIPT
INSTALL_PROGRAM
src_inetd
src_init
src_tmpfile
subsyslockfile
subsyslockdir
tmpfilesd
Expand Down Expand Up @@ -2536,6 +2537,7 @@ LC_TIME=C
# Find a good install program. We prefer a C program (faster),
Expand Down Expand Up @@ -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) :
Expand Down
17 changes: 9 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 <stdarg.h>
va_list ap1,ap2;], [__va_copy(ap1,ap2);],
Expand All @@ -219,7 +220,7 @@ AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
AC_TRY_RUN([
#include <sys/types.h>
#include <stdarg.h>
void foo(const char *format, ...) {
void foo(const char *format, ...) {
va_list ap;
int len;
char buf[5];
Expand Down Expand Up @@ -272,11 +273,11 @@ AC_CHECK_TYPE([socklen_t], ,[
AC_TRY_COMPILE([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
int getpeername (int, $arg2 *, $t *);
],[
$t len;
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -443,7 +444,7 @@ if test x$check_for_ssl = xyes; then
else
printf "found Kerberos include files in $kerbdir\n";
fi


fi

Expand Down
6 changes: 6 additions & 0 deletions src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions startup/tmpfile.conf.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Type Path Mode UID GID Age Argument
D @piddir@ 0755 @nagios_user@ @nagios_group@ - -
77 changes: 42 additions & 35 deletions uninstall.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -76,14 +75,22 @@ 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
shift

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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 * * *"

0 comments on commit add9481

Please sign in to comment.