Skip to content
Snippets Groups Projects
Commit e48320e2 authored by Andrew Fyfe's avatar Andrew Fyfe Committed by Lars Engels
Browse files

sysutils/bsdstats: make reporting opt-in

- disables reporting by default
- does not use the pkg-install script to "modify the currently running
  system" as per the FreeBSD Porters Handbook Chapter 9.2.
- does not output noise if monthly_statistics_* variables aren't enabled
- add a post-upgrade message informing the user it's now opt-in and may
  need enabled
parent f71e8d54
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
PORTNAME= bsdstats
PORTVERSION= 7.0
PORTREVISION= 1
CATEGORIES= sysutils
DISTFILES=
......
......@@ -67,6 +67,9 @@ fi
#
# global values
#
monthly_statistics_enable=${monthly_statistics_enable:-"NO"}
monthly_statistics_report_devices=${$monthly_statistics_report_devices:-"YES"}
monthly_statistics_report_ports=${monthly_statistics_report_ports:-"YES"}
checkin_server=${monthly_statistics_checkin_server:-"rpt.bsdstats.org"}
bsdstats_log=${monthly_statistics_logfile:-"/var/log/bsdstats"}
id_token_file='/var/db/bsdstats'
......@@ -531,27 +534,14 @@ report_all() {
report_devices
report_cpu
;;
[Nn][Oo])
echo "Posting monthly device/CPU statistics disabled"
echo " set monthly_statistics_report_devices=\"YES\" in $periodic_conf"
;;
*)
# opt-out for devices
report_devices
report_cpu
;;
esac
case "$monthly_statistics_report_ports" in
[Yy][Ee][Ss])
report_ports
;;
[Nn][Oo])
echo "Posting monthly ports statistics disabled"
echo " set monthly_statistics_report_ports=\"YES\" in $periodic_conf"
;;
*)
# opt-out for ports
report_ports
;;
esac
# end
......@@ -569,14 +559,7 @@ case "$monthly_statistics_enable" in
# explicitly enabled: report it
report_all "$1"
;;
[Nn][Oo])
echo "Posting monthly OS statistics disabled"
echo " set monthly_statistics_enable=\"YES\" in $periodic_conf"
rc=1
;;
*)
# opt-out: we report when user has BSDstats installed, and user didn't say "NO"
report_all "$1"
;;
esac
......
......@@ -3,8 +3,8 @@
message: <<EOM
You installed BSDstats: script reporting statistics about your machine.
To disable monthly reporting, add this line to /etc/periodic.conf:
monthly_statistics_enable="NO"
To enable monthly reporting, add this line to /etc/periodic.conf:
monthly_statistics_enable="YES"
To disable parts of reporting, add these lines to /etc/periodic.conf:
monthly_statistics_report_devices="NO"
......@@ -30,4 +30,12 @@ To view current statistics, go to:
@@TOR_MESSAGE@@
EOM
}
{ type: upgrade
maximum_version: "7.0"
message: <<EOM
BSDstats is now disabled by default, to enable monthly reporting, add
this line to /etc/periodic.conf:
monthly_statistics_enable="YES"
EOM
}
]
#!/bin/sh
# pkg-install : based off ${PORTSDIR}/mail/courier/files/pkg-install.in
# The default answer to each of the installation questions is "yes". You can
# override a question's default by setting its environment variable to "no".
#
# Environment Variable | Question
# --------------------------+------------------------------------------------------------------
# BSDSTATS_MONTHLY_NOW | Would you like to run it now?
# BSDSTATS_REBOOT_REPORTING | Would you like to enable reporting on bootup in /etc/rc.conf?
if [ -n "$PACKAGE_BUILDING" ]; then
BSDSTATS_MONTHLY_NOW=${BSDSTATS_MONTHLY_NOW:=no}
BSDSTATS_REBOOT_REPORTING=${BSDSTATS_REBOOT_REPORTING:=no}
else
BSDSTATS_MONTHLY_NOW=${BSDSTATS_MONTHLY_NOW:=yes}
BSDSTATS_REBOOT_REPORTING=${BSDSTATS_REBOOT_REPORTING:=yes}
fi
ask() {
local question default answer
question=$1
default=$2
if [ -z "$BATCH" -a -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
log_file="${INSTALL_PREFIX}/var/log/bsdstats"
need_to_ask=0
if [ ! -e ${log_file} ]; then
need_to_ask=1
elif [ $(($(date +"%s")-$(stat -f %Sm -t %s ${log_file}))) -gt $((60*60*24*40)) ]; then
need_to_ask=1
fi
if [ $need_to_ask = 1 ]; then
if yesno "Would you like to run BSDstats now" $BSDSTATS_MONTHLY_NOW; then
${INSTALL_PREFIX}${PKG_PREFIX}/etc/periodic/monthly/300.statistics -nodelay
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment