git: e48320e2d8b9 - main - sysutils/bsdstats: make reporting opt-in

Lars Engels lme at FreeBSD.org
Wed May 5 08:50:09 UTC 2021


The branch main has been updated by lme:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e48320e2d8b915cad970dcfd01ca48679f07b4f4

commit e48320e2d8b915cad970dcfd01ca48679f07b4f4
Author:     Andrew Fyfe <andrew at fyfe.gb.net>
AuthorDate: 2021-04-16 05:47:31 +0000
Commit:     Lars Engels <lme at FreeBSD.org>
CommitDate: 2021-05-05 08:49:54 +0000

    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
---
 sysutils/bsdstats/Makefile                |  1 +
 sysutils/bsdstats/files/300.statistics.in | 23 ++--------
 sysutils/bsdstats/files/pkg-message.in    | 12 ++++-
 sysutils/bsdstats/pkg-install             | 73 -------------------------------
 4 files changed, 14 insertions(+), 95 deletions(-)

diff --git a/sysutils/bsdstats/Makefile b/sysutils/bsdstats/Makefile
index e676a52b58d1..86d3ab3d15da 100644
--- a/sysutils/bsdstats/Makefile
+++ b/sysutils/bsdstats/Makefile
@@ -2,6 +2,7 @@
 
 PORTNAME=	bsdstats
 PORTVERSION=	7.0
+PORTREVISION=	1
 CATEGORIES=	sysutils
 DISTFILES=
 
diff --git a/sysutils/bsdstats/files/300.statistics.in b/sysutils/bsdstats/files/300.statistics.in
index d24ca2ae2076..1ba18493c600 100644
--- a/sysutils/bsdstats/files/300.statistics.in
+++ b/sysutils/bsdstats/files/300.statistics.in
@@ -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
 
diff --git a/sysutils/bsdstats/files/pkg-message.in b/sysutils/bsdstats/files/pkg-message.in
index 2c504d2252f8..a1e0f6a20c48 100644
--- a/sysutils/bsdstats/files/pkg-message.in
+++ b/sysutils/bsdstats/files/pkg-message.in
@@ -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
+}
 ]
diff --git a/sysutils/bsdstats/pkg-install b/sysutils/bsdstats/pkg-install
deleted file mode 100644
index ae1695356a9a..000000000000
--- a/sysutils/bsdstats/pkg-install
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/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


More information about the dev-commits-ports-all mailing list