58d37320f9
* php5-sockets is needed and php5-filter -- not needed; * local modifications to config.php should go into config_local.php and config.php must be replaced at every installation. Feature safe: yes Approved by: garga (mentor)
73 lines
2 KiB
Bash
73 lines
2 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
SPOOL_DIRS=%%SPOOL_DIRS%%
|
|
NAGIOSUSER=%%NAGIOSUSER%%
|
|
NAGIOSGROUP=%%NAGIOSGROUP%%
|
|
|
|
# Create directories with mode and ownership specified in SPOOL_DIRS
|
|
# as strings separated by '%' of format DIR:OWNER:GROUP:MODE
|
|
dirs () {
|
|
IFS=%
|
|
for i in $SPOOL_DIRS; do
|
|
d="${i%%:*}"
|
|
if ! [ -d "$d" ]; then
|
|
go=`echo "$i" | cut -f 2-3 -d :`
|
|
m="${i##*:}"
|
|
mkdir -p "$d"
|
|
chown "$go" "$d"
|
|
chmod "$m" "$d"
|
|
fi
|
|
done
|
|
}
|
|
|
|
check_sanity () {
|
|
if ! pw group show "$NAGIOSGROUP" 2>&1 > /dev/null; then
|
|
echo "No group '$NAGIOSGROUP'. Create it and try again."
|
|
exit 1
|
|
fi
|
|
if ! pw user show "$NAGIOSUSER" 2>&1 > /dev/null; then
|
|
echo "No user '$NAGIOSUSER'. Create it and try again."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# I messed the proper way to create the configuration for PNP:
|
|
# config_local.php should be used for overrides and config.php
|
|
# will come modified at each upgrade.
|
|
#
|
|
# I was installing config.php as config.php-sample and hoping
|
|
# that people will use it as the base for original config.php.
|
|
#
|
|
# So, if we now have config.php at the installtion phase, then
|
|
# it means that config.php may be customized. We save it as
|
|
# config.php.orig and informing the user about it.
|
|
fixup_config_local () {
|
|
if [ -e "%%ETCDIR%%"/config.php ]; then
|
|
cp "%%ETCDIR%%"/config.php "%%ETCDIR%%"/config.php.orig
|
|
cat << "EOF"
|
|
======================================================================
|
|
WARNING:
|
|
|
|
You have config.php for PNP; this means that you are probably
|
|
upgrading from an old port version, where config.php-sample was
|
|
installed instead of config.php and it was meant that you will
|
|
cope with config.php yourself.
|
|
|
|
PNP's way to do the things is to let config.php be overwritten at each
|
|
upgrade and local overrides to it should go to config_local.php.
|
|
|
|
Your existing config.php was saved as config.php.orig, please, review
|
|
your modifications and put them to config_local.php.
|
|
======================================================================
|
|
EOF
|
|
fi
|
|
}
|
|
|
|
if [ "x$2" = "xPRE-INSTALL" ]; then
|
|
check_sanity
|
|
dirs
|
|
fixup_config_local
|
|
fi
|