1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-06 06:30:19 +00:00
freebsd-ports/sysutils/bsdstats/pkg-install
Michael Scheidell b6ee174661 - Rewrite installation message [1]
- Include project's description in pkg-desc, not pkg-message.in
- Change default answer to each reporting question to yes
- Fix tests for /etc/periodic.conf and /etc/rc.conf
- Clean up interactive prompts during installation
- Bump PORTREVISION

PR:		ports/171015
Submitted by:	bsdstats@nanoman.ca (maintainer)
Reported by:	2A <deuza at fr dot FreeBSD dot org> [1]
2012-08-28 04:02:55 +00:00

87 lines
3.4 KiB
Bash

#!/bin/sh
#
# pkg-install : based off ${PORTSDIR}/mail/courier/files/pkg-install.in
#
# The default answer to "Would you like to enable monthly reporting in
# /etc/periodic.conf?" is "yes", which you can override by setting the
# BSDSTATS_MONTHLY_ENABLE environment variable to "no".
#
# The default answer to "Would you like to send a list of installed hardware
# as well?" is "yes", which you can override by setting the
# BSDSTATS_MONTHLY_DEVICES environment variable to "no".
#
# The default answer to "Would you like to send a list of installed ports as
# well?" is "yes", which you can override by setting the BSDSTATS_MONTHLY_PORTS
# environment variable to "no".
#
# The default answer to "Would you like to run it now?" is "yes", which you can
# override by setting the BSDSTATS_MONTHLY_NOW environment variable to "no".
#
# The default answer to "Would you like to enable reporting on bootup in
# /etc/rc.conf?" is "yes", which you can override by setting the
# BSDSTATS_REBOOT_REPORTING environment variable to "no".
BSDSTATS_MONTHLY_ENABLE=${BSDSTATS_MONTHLY_ENABLE:=yes}
BSDSTATS_MONTHLY_DEVICES=${BSDSTATS_MONTHLY_DEVICES:=yes}
BSDSTATS_MONTHLY_PORTS=${BSDSTATS_MONTHLY_PORTS:=yes}
BSDSTATS_MONTHLY_NOW=${BSDSTATS_MONTHLY_NOW:=yes}
BSDSTATS_REBOOT_REPORTING=${BSDSTATS_REBOOT_REPORTING:=yes}
ask() {
local question default answer
question=$1
default=$2
if [ -z "${PACKAGE_BUILDING}" ]; then
read -p "${question} [${default}]? " answer
fi
if [ -z "${answer}" ]; then
answer=${default}
fi
echo ${answer}
}
yesno() {
local question default answer
question=$1
default=$2
while :; do
answer=$(ask "${question}" "${default}")
case "${answer}" in
[Yy]*) return 0;;
[Nn]*) return 1;;
esac
echo "Please answer yes or no."
done
}
if [ "$2" = "POST-INSTALL" ]; then
if [ ! -f "/etc/periodic.conf" ] || [ -z "`grep monthly_statistics /etc/periodic.conf`" ]; then
if yesno "Would you like to enable monthly reporting in /etc/periodic.conf" ${BSDSTATS_MONTHLY_ENABLE}; then
echo "monthly_statistics_enable=\"YES\"" >> /etc/periodic.conf
if yesno "Would you like to send a list of installed hardware as well" ${BSDSTATS_MONTHLY_DEVICES}; then
echo "monthly_statistics_report_devices=\"YES\"" >> /etc/periodic.conf
fi
if yesno "Would you like to send a list of installed ports as well" ${BSDSTATS_MONTHLY_PORTS}; then
echo "monthly_statistics_report_ports=\"YES\"" >> /etc/periodic.conf
fi
if yesno "Would you like to run it now" ${BSDSTATS_MONTHLY_NOW}; then
${PKG_PREFIX}/etc/periodic/monthly/300.statistics -nodelay
fi
fi
fi
if [ ! -f "/etc/rc.conf" ] || [ -z "`grep bsdstats_enable /etc/rc.conf`" ]; then
echo ""
echo "If you're installing BSDstats on a system that won't always be on, such as a"
echo "desktop or a laptop, it is recommended that you enable it in /etc/rc.conf so"
echo "that it will run on bootup. This will ensure that, even if your computer is"
echo "off when \"monthly\" runs, your computer will be counted properly."
echo ""
if yesno "Would you like to enable reporting on bootup in /etc/rc.conf" ${BSDSTATS_REBOOT_REPORTING}; then
echo "bsdstats_enable=\"YES\"" >> /etc/rc.conf
fi
fi
fi