View | Details | Raw Unified | Return to bug 251152 | Differences between
and this patch

Collapse All | Expand All

(-)b/sysutils/bsdstats/Makefile (+1 lines)
Lines 3-8 Link Here
3
3
4
PORTNAME=	bsdstats
4
PORTNAME=	bsdstats
5
PORTVERSION=	7.0
5
PORTVERSION=	7.0
6
PORTREVISION=	1
6
CATEGORIES=	sysutils
7
CATEGORIES=	sysutils
7
DISTFILES=
8
DISTFILES=
8
9
(-)b/sysutils/bsdstats/files/300.statistics.in (-20 / +3 lines)
Lines 70-75 fi Link Here
70
#
70
#
71
# global values
71
# global values
72
#
72
#
73
monthly_statistics_enable=${monthly_statistics_enable:-"NO"}
74
monthly_statistics_report_devices=${$monthly_statistics_report_devices:-"YES"}
75
monthly_statistics_report_ports=${monthly_statistics_report_ports:-"YES"}
73
checkin_server=${monthly_statistics_checkin_server:-"rpt.bsdstats.org"}
76
checkin_server=${monthly_statistics_checkin_server:-"rpt.bsdstats.org"}
74
bsdstats_log=${monthly_statistics_logfile:-"/var/log/bsdstats"}
77
bsdstats_log=${monthly_statistics_logfile:-"/var/log/bsdstats"}
75
id_token_file='/var/db/bsdstats'
78
id_token_file='/var/db/bsdstats'
Lines 534-560 report_all() { Link Here
534
       report_devices
537
       report_devices
535
       report_cpu
538
       report_cpu
536
       ;;
539
       ;;
537
    [Nn][Oo])
538
       echo "Posting monthly device/CPU statistics disabled"
539
       echo "    set monthly_statistics_report_devices=\"YES\" in $periodic_conf"
540
       ;;
541
    *)
540
    *)
542
       # opt-out for devices
543
       report_devices
544
       report_cpu
545
       ;;
541
       ;;
546
  esac
542
  esac
547
  case "$monthly_statistics_report_ports" in
543
  case "$monthly_statistics_report_ports" in
548
    [Yy][Ee][Ss])
544
    [Yy][Ee][Ss])
549
      report_ports
545
      report_ports
550
      ;;
546
      ;;
551
    [Nn][Oo])
552
      echo "Posting monthly ports statistics disabled"
553
      echo "    set monthly_statistics_report_ports=\"YES\" in $periodic_conf"
554
      ;;
555
    *)
547
    *)
556
      # opt-out for ports
557
      report_ports
558
      ;;
548
      ;;
559
  esac
549
  esac
560
  # end
550
  # end
Lines 572-585 case "$monthly_statistics_enable" in Link Here
572
    # explicitly enabled: report it
562
    # explicitly enabled: report it
573
    report_all "$1"
563
    report_all "$1"
574
    ;;
564
    ;;
575
  [Nn][Oo])
576
    echo "Posting monthly OS statistics disabled"
577
    echo "    set monthly_statistics_enable=\"YES\" in $periodic_conf"
578
    rc=1
579
    ;;
580
  *)
565
  *)
581
    # opt-out: we report when user has BSDstats installed, and user didn't say "NO"
582
    report_all "$1"
583
    ;;
566
    ;;
584
esac
567
esac
585
568
(-)b/sysutils/bsdstats/files/pkg-message.in (-2 / +10 lines)
Lines 3-10 Link Here
3
  message: <<EOM
3
  message: <<EOM
4
You installed BSDstats: script reporting statistics about your machine.
4
You installed BSDstats: script reporting statistics about your machine.
5
5
6
To disable monthly reporting, add this line to /etc/periodic.conf:
6
To enable monthly reporting, add this line to /etc/periodic.conf:
7
	monthly_statistics_enable="NO"
7
	monthly_statistics_enable="YES"
8
8
9
To disable parts of reporting, add these lines to /etc/periodic.conf:
9
To disable parts of reporting, add these lines to /etc/periodic.conf:
10
	monthly_statistics_report_devices="NO"
10
	monthly_statistics_report_devices="NO"
Lines 30-33 To view current statistics, go to: Link Here
30
@@TOR_MESSAGE@@
30
@@TOR_MESSAGE@@
31
EOM
31
EOM
32
}
32
}
33
{ type: upgrade
34
  maximum_version: "7.0"
35
  message: <<EOM
36
BSDstats is now disabled by default, to enable monthly reporting, add
37
this line to /etc/periodic.conf:
38
	monthly_statistics_enable="YES"
39
EOM
40
}
33
]
41
]
(-)a/sysutils/bsdstats/pkg-install (-74 lines)
Removed Link Here
1
#!/bin/sh
2
# pkg-install : based off ${PORTSDIR}/mail/courier/files/pkg-install.in
3
4
# The default answer to each of the installation questions is "yes". You can
5
# override a question's default by setting its environment variable to "no".
6
#
7
# Environment Variable      | Question
8
# --------------------------+------------------------------------------------------------------
9
# BSDSTATS_MONTHLY_NOW      | Would you like to run it now?
10
# BSDSTATS_REBOOT_REPORTING | Would you like to enable reporting on bootup in /etc/rc.conf?
11
12
if [ -n "$PACKAGE_BUILDING" ]; then
13
	BSDSTATS_MONTHLY_NOW=${BSDSTATS_MONTHLY_NOW:=no}
14
	BSDSTATS_REBOOT_REPORTING=${BSDSTATS_REBOOT_REPORTING:=no}
15
else
16
	BSDSTATS_MONTHLY_NOW=${BSDSTATS_MONTHLY_NOW:=yes}
17
	BSDSTATS_REBOOT_REPORTING=${BSDSTATS_REBOOT_REPORTING:=yes}
18
fi
19
20
ask() {
21
	local question default answer
22
23
	question=$1
24
	default=$2
25
	if [ -z "$BATCH" -a -z "$PACKAGE_BUILDING" ]; then
26
		read -p "$question [$default]? " answer
27
	fi
28
	if [ -z "$answer" ]; then
29
		answer=$default
30
	fi
31
	echo $answer
32
}
33
34
yesno() {
35
	local question default answer
36
37
	question=$1
38
	default=$2
39
	while :; do
40
		answer=$(ask "$question" "$default")
41
		case "$answer" in
42
			[Yy]*) return 0;;
43
			[Nn]*) return 1;;
44
		esac
45
		echo "Please answer yes or no."
46
	done
47
}
48
49
if [ "$2" = "POST-INSTALL" ]; then
50
	log_file="${INSTALL_PREFIX}/var/log/bsdstats"
51
	need_to_ask=0
52
	if [ ! -e ${log_file} ]; then
53
		need_to_ask=1
54
	elif [ $(($(date +"%s")-$(stat -f %Sm -t %s ${log_file}))) -gt $((60*60*24*40)) ]; then
55
		need_to_ask=1
56
	fi
57
	if [ $need_to_ask = 1 ]; then
58
		if yesno "Would you like to run BSDstats now" $BSDSTATS_MONTHLY_NOW; then
59
			${INSTALL_PREFIX}${PKG_PREFIX}/etc/periodic/monthly/300.statistics -nodelay
60
		fi
61
	fi
62
	if [ ! -f "/etc/rc.conf" ] || [ -z $(grep bsdstats_enable /etc/rc.conf) ]; then
63
		echo
64
		echo "If you're installing BSDstats on a system that won't always be on, such as a"
65
		echo "desktop or a laptop, it is recommended that you enable it in /etc/rc.conf so"
66
		echo "that it will run on bootup. This will ensure that, even if your computer is"
67
		echo "off when \"monthly\" runs, your computer will be counted properly."
68
		echo
69
		if yesno "Would you like to enable reporting on bootup in /etc/rc.conf" $BSDSTATS_REBOOT_REPORTING; then
70
			echo "bsdstats_enable=\"YES\"" >> /etc/rc.conf
71
		fi
72
	fi
73
fi
74
- 

Return to bug 251152