diff options
Diffstat (limited to 'network/nagios/nagios.SlackBuild')
-rw-r--r-- | network/nagios/nagios.SlackBuild | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/network/nagios/nagios.SlackBuild b/network/nagios/nagios.SlackBuild index c2f2d5108d..d19ea44f60 100644 --- a/network/nagios/nagios.SlackBuild +++ b/network/nagios/nagios.SlackBuild @@ -24,7 +24,7 @@ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PRGNAM=nagios -VERSION=${VERSION:-4.3.2} +VERSION=${VERSION:-4.3.4} BUILD=${BUILD:-1} TAG=${TAG:-_SBo} @@ -63,14 +63,33 @@ else LIBDIRSUFFIX="" fi +USERNAME=${USERNAME:-nagios} +GROUPNAME=${GROUPNAME:-nagios} +USERID=${USERID:-213} +GROUPID=${GROUPID:-213} +HOMEDIR=${HOMEDIR:-/var/nagios} +SHELLNAME=${SHELLNAME:-/bin/bash} + +GETUSER=$(getent passwd $USERNAME) +GETGROUP=$(getent group $GROUPNAME) + set -e -# Check if the 'nagios' user & group exist: -if [ "$(grep ^nagios /etc/passwd)" = "" -o "$(grep ^nagios /etc/group)" = "" ] ; then - printf "\nYou must have a nagios user and group.\n\nExample:\n" - printf "\t# groupadd -g 213 nagios\n" - printf "\t# useradd -d /dev/null -s /bin/false -u 213 -g nagios nagios\n\n" - exit 1 +if [ -z "$GETUSER" -o -z "$GETGROUP" ]; then + printf "\n You must have a \"$PRGNAM\" user and a group to run this script\n\n" + [ -z "$GETGROUP" ] && printf " # groupadd -g $GROUPID $GROUPNAME\n" + [ -z "$GETUSER" ] && printf " # useradd -u $USERID -d $HOMEDIR -s $SHELLNAME -g $GROUPNAME $USERNAME\n" + printf "\n" + exit 1 +fi + +if [[ ! $GETUSER =~ ^$USERNAME:[^:]+:$USERID:$GROUPID:[^:]*:$HOMEDIR:$SHELLNAME$ ]]; then + printf "\n You must update the \"$PRGNAM\" user to run this script\n\n" + [[ $GETUSER =~ ^[^:]+:[^:]+:[^:]+:[^:]+:[^:]*:([^:]+):([^:]+)$ ]] + [ "${BASH_REMATCH[1]}" != "$HOMEDIR" ] && printf " # usermod -d $HOMEDIR $USERNAME\n" + [ "${BASH_REMATCH[2]}" != "$SHELLNAME" ] && printf " # usermod -s $SHELLNAME $USERNAME\n" + printf "\n" + exit 1 fi rm -rf $PKG |