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 |
- |