1488eedce8
Included in this PR is reload support requested by ports/126476 in addition to a change in the location of the PID file. I have however opted to move this file to NAGIOSDIR to reduce the number of directories created by all Nagios related ports. PR: 128409 Submitted by: Jarrod Sayers <jarrod@netleader.com.au> (maintainer)
80 lines
2.1 KiB
Bash
80 lines
2.1 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
NAGIOSDIR=%%NAGIOSDIR%%
|
|
NAGIOSUSER=%%NAGIOSUSER%%
|
|
NAGIOSGROUP=%%NAGIOSGROUP%%
|
|
NAGIOSUID=%%NAGIOSUID%%
|
|
NAGIOSGID=%%NAGIOSGID%%
|
|
|
|
ask() {
|
|
local question default answer
|
|
|
|
question=$1
|
|
default=$2
|
|
if [ -z "${PACKAGE_BUILDING}" ]; then
|
|
read -p "${question} [${default}]? " answer
|
|
fi
|
|
if [ "x${answer}" = "x" ]; then
|
|
answer=${default}
|
|
fi
|
|
echo ${answer}
|
|
}
|
|
|
|
yesno() {
|
|
local default question answer
|
|
|
|
question=$1
|
|
default=$2
|
|
while :; do
|
|
answer=$(ask "${question}" "${default}")
|
|
case "${answer}" in
|
|
[Yy][Ee][Ss]|[Yy])
|
|
return 0
|
|
;;
|
|
[Nn][Oo]|[Nn])
|
|
return 1
|
|
;;
|
|
esac
|
|
echo "Please answer yes or no."
|
|
done
|
|
}
|
|
|
|
if [ "$2" = "PRE-INSTALL" ]; then
|
|
if /usr/sbin/pw group show "${NAGIOSGROUP}" 2>&1 >/dev/null; then
|
|
echo "You already have a \"${NAGIOSGROUP}\" group, so I will use it."
|
|
else
|
|
echo "You need a \"${NAGIOSGROUP}\" group."
|
|
if yesno "Would you like me to create it" "YES"; then
|
|
/usr/sbin/pw groupadd "${NAGIOSGROUP}" -g "${NAGIOSGID}" -h - || \
|
|
/usr/sbin/pw groupadd "${NAGIOSGROUP}" -h - || exit
|
|
echo "Done."
|
|
else
|
|
echo "Please create the \"${NAGIOSGROUP}\" group manually and try again."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if /usr/sbin/pw user show "${NAGIOSUSER}" 2>&1 >/dev/null; then
|
|
echo "You already have a \"${NAGIOSUSER}\" user, so I will use it."
|
|
else
|
|
echo "You need a \"${NAGIOSUSER}\" user."
|
|
if yesno "Would you like me to create it" "YES"; then
|
|
/usr/sbin/pw useradd "${NAGIOSUSER}" -u "${NAGIOSUID}" -g "${NAGIOSGROUP}" -h - -d "${NAGIOSDIR}" \
|
|
-s /sbin/nologin -c "Nagios pseudo-user" || \
|
|
/usr/sbin/pw useradd "${NAGIOSUSER}" -g "${NAGIOSGROUP}" -h - -d "${NAGIOSDIR}" \
|
|
-s /sbin/nologin -c "Nagios pseudo-user" || exit
|
|
else
|
|
echo "Please create the \"${NAGIOSUSER}\" user manually and try again."
|
|
exit 1
|
|
fi
|
|
fi
|
|
elif [ "$2" = "POST-INSTALL" ]; then
|
|
if [ ! -e "${NAGIOSDIR}" ]; then
|
|
/bin/mkdir -p "${NAGIOSDIR}"
|
|
/bin/chmod 775 "${NAGIOSDIR}"
|
|
/usr/sbin/chown "${NAGIOSUSER}":"${NAGIOSGROUP}" "${NAGIOSDIR}"
|
|
fi
|
|
fi
|