ports/146447: fix bsdstats pkg-install file

Joe Barbish fbsd1 at a1poweruser.com
Mon May 10 02:40:03 UTC 2010


>Number:         146447
>Category:       ports
>Synopsis:       fix bsdstats pkg-install file
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 10 02:40:02 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Joe Barbish
>Release:        RELEASE 8.0
>Organization:
none
>Environment:
>Description:
Corrected logic to determine opt-out condition.
Changed order of reporting option questions.
Changed text messages so made correct logic sense now.
Added report statement with NO value so more user friendly
to turn on later.
Adjusted how it looks on the screen by adding corrected spacing.

>How-To-Repeat:

>Fix:
Patch included.

Patch attached with submission follows:

--- pkg-install.org	2010-05-09 21:54:05.000000000 +0800
+++ pkg-install	2010-05-09 22:46:43.000000000 +0800
@@ -29,64 +29,161 @@
         [Yy]*)	return 0;;
         [Nn]*)	return 1;;
         esac
-        echo "Please answer yes or no."
+        echo "Please answer [Yy] or [Nn]."
     done
 }
 
 if [ ":$2" = ":POST-INSTALL" ]; then
     if [ -f "/etc/periodic.conf" ]; then
-        if [ `grep monthly_statistics /etc/periodic.conf | wc -l` = 0 ]; then
-            if yesno "Would you like to activate monthly reporting in /etc/periodic.conf" n; then
-                echo "monthly_statistics_enable=\"YES\"" >> /etc/periodic.conf
-                if yesno "Would you like to send a list of installed hardware as well" n; 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" n; then
-                    echo "monthly_statistics_report_ports=\"YES\"" >> /etc/periodic.conf
-                fi
-                if yesno "Would you like to run it now" y; then
-                   ${PKG_PREFIX}/etc/periodic/monthly/300.statistics -nodelay
-                fi
-            fi
-        fi
-    elif [ ! -f "/etc/periodic.conf" ]; then
-        if yesno "Would you like to activate monthly reporting in /etc/periodic.conf" n; then
+      if [ `grep monthly_statistics_enable /etc/periodic.conf | wc -l` = 0 ]; then
+        echo ""
+        echo ""
+        if yesno "Would you like to activate monthly reporting" n; then
             echo "monthly_statistics_enable=\"YES\"" >> /etc/periodic.conf
-            if yesno "Would you like to send a list of installed hardware as well" n; 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" n; then
-                echo "monthly_statistics_report_ports=\"YES\"" >> /etc/periodic.conf
-            fi
-            if yesno "Would you like to run it now" y; then
-               ${PKG_PREFIX}/etc/periodic/monthly/300.statistics -nodelay
-            fi
+          if yesno "Would you like to send a list of installed hardware as well" n; 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" n; then
+              echo "monthly_statistics_report_ports=\"YES\"" >> /etc/periodic.conf
+          fi
+          if [ `grep monthly_statistics_report_devices /etc/periodic.conf | wc -l` = 0 ]; then
+              echo "monthly_statistics_report_devices=\"NO\"" >> /etc/periodic.conf
+          fi
+          if [ `grep monthly_statistics_report_ports /etc/periodic.conf | wc -l` = 0 ]; then
+              echo "monthly_statistics_report_ports=\"NO\"" >> /etc/periodic.conf
+          fi
         fi
+      fi
+    elif [ ! -f "/etc/periodic.conf" ]; then
+       echo ""
+       echo ""
+       if yesno "Would you like to activate monthly reporting" n; then
+           echo "monthly_statistics_enable=\"YES\"" >> /etc/periodic.conf
+          if yesno "Would you like to send a list of installed hardware as well" n; 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" n; then
+              echo "monthly_statistics_report_ports=\"YES\"" >> /etc/periodic.conf
+          fi
+          if [ `grep monthly_statistics_report_devices /etc/periodic.conf | wc -l` = 0 ]; then
+              echo "monthly_statistics_report_devices=\"NO\"" >> /etc/periodic.conf
+          fi
+          if [ `grep monthly_statistics_report_ports /etc/periodic.conf | wc -l` = 0 ]; then
+              echo "monthly_statistics_report_ports=\"NO\"" >> /etc/periodic.conf
+          fi
+       fi
     fi
     if [ -f "/etc/rc.conf" ]; then
-        if [ `grep bsdstats_enable /etc/rc.conf | wc -l` = 0 ]; then
-            echo ""
-            echo "If running as a desktop, or on a laptop, it is recommended that you"
-            echo "enable bsdstats within /etc/rc.conf, so that it will run on reboot."
-            echo ""
-            echo "This will ensure that even if your computer is off when monthly runs,"
-            echo "your computer will be properly counted."
-            echo ""
-            if yesno "Would you like to activate reporting on reboot in /etc/rc.conf" n; then
-                echo "bsdstats_enable=\"YES\"" >> /etc/rc.conf
-            fi
+      if [ `grep bsdstats_enable /etc/rc.conf | wc -l` = 0 ]; then
+        if [ `grep monthly_statistics_enable /etc/periodic.conf | wc -l` = 1 ]; then
+          echo ""
+          echo "**********************************************************************"
+          echo "You already enabled Automatic monthly reporting"
+          echo "If this computer is not run 24/7 the possibility exists that the" 
+          echo "Month End reporting schedule could be missed."
+          echo ""
+          echo "It is recommended that the bsdstats_enable=\"YES\" statement be added"
+          echo "to your /etc/rc.conf file so that the BSDstats Anonymous Reporting"
+          echo "Application will report every time you boot your system."
+          echo ""
+          echo "This will ensure that even if your computer is off when Month End"
+          echo "reporting occurs, your computer will be properly counted. Multiple"
+          echo "reporting in a period by the same computer is counted as a single"
+          echo "occurrence."
+          echo "**********************************************************************"
+          echo ""
         fi
+        if [ `grep monthly_statistics_enable /etc/periodic.conf | wc -l` = 0 ]; then
+          echo ""
+          echo "**********************************************************************"
+          echo "You did not consciously choose to enabled Automatic monthly reporting."
+          echo "This is your last chance to enable basic BSD variant reporting."
+          echo ""
+          echo "By having the bsdstats_enable=\"YES\" statement added to your"
+          echo "/etc/rc.conf file the BSDstats Anonymous Reporting Application will"
+          echo "report every time you boot your system."
+          echo ""
+          echo "This will ensure that your computer will be properly counted."
+          echo "Multiple reporting in a period by the same computer is counted"
+          echo "as a single occurrence."
+          echo "**********************************************************************"
+          echo ""
+        fi
+        if yesno "Would you like to activate reporting on system boot" n; then
+            echo "bsdstats_enable=\"YES\"" >> /etc/rc.conf
+        fi
+        if [ `grep monthly_statistics_enable /etc/periodic.conf | wc -l` = 0 ]; then
+           if [ `grep bsdstats_enable /etc/rc.conf | wc -l` = 0 ]; then
+             echo ""
+             echo "**********************************************************************"
+             echo "You choose to opt-out of the BSDstats Reporting Application"
+             echo "Its still installed on your system , but not enabled." 
+             echo "**********************************************************************"
+             echo ""
+           fi
+        fi
+      fi
     elif [ ! -f "/etc/rc.conf" ]; then
+      if [ `grep monthly_statistics_enable /etc/periodic.conf | wc -l` = 1 ]; then
         echo ""
-        echo "If running as a desktop, or on a laptop, it is recommended that you"
-        echo "enable bsdstats within /etc/rc.conf, so that it will run on reboot."
+        echo "**********************************************************************"
+        echo "You already enabled Automatic monthly reporting"
+        echo "If this computer is not run 24/7 the possibility exists that the Month End"
+        echo "reporting schedule could be missed."
         echo ""
-        echo "This will ensure that even if your computer is off when monthly runs,"
-        echo "your computer will be properly counted."
+        echo "It is recommended that the bsdstats_enable=\"YES\" statement be added to"
+        echo "your /etc/rc.conf file so that the BSDstats Anonymous Reporting Application"
+        echo "will report every time you boot your system."
         echo ""
-        if yesno "Would you like to activate reporting on reboot in /etc/rc.conf" n; then
-            echo "bsdstats_enable=\"YES\"" >> /etc/rc.conf
-        fi
+        echo "This will ensure that even if your computer is off when Month End reporting"
+        echo "occurs, your computer will be properly counted. Multiple reporting in a"
+        echo "period by a single computer is counted as a single occurrence."
+        echo "**********************************************************************"
+        echo ""
+      fi
+      if [ `grep monthly_statistics_enable /etc/periodic.conf | wc -l` = 0 ]; then
+        echo ""
+        echo "**********************************************************************"
+        echo "You did not consciously choose to enabled Automatic monthly reporting"
+        echo "This is your last chance to enable basic BSD variant reporting."
+        echo ""
+        echo "By having the bsdstats_enable=\"YES\" statement added to your"
+        echo "/etc/rc.conf file the BSDstats Anonymous Reporting Application will"
+        echo "report every time you boot your system."
+        echo ""
+        echo "This will ensure that your computer will be properly counted. Multiple"
+        echo "reporting in a period by the same computer is counted as a single occurrence."
+        echo "**********************************************************************"
+        echo ""
+      fi
+      if yesno "Would you like to activate reporting on system boot in /etc/rc.conf" n; then
+        echo "bsdstats_enable=\"YES\"" >> /etc/rc.conf
+      fi
+      if [ `grep monthly_statistics_enable /etc/periodic.conf | wc -l` = 0 ]; then
+         if [ `grep bsdstats_enable /etc/rc.conf | wc -l` = 0 ]; then
+           echo ""
+           echo "**********************************************************************"
+           echo "You choose to opt-out of the BSDstats Anonymous Reporting Application"
+           echo "Its still installed on your system , but not enabled."
+           echo "**********************************************************************"
+           echo ""
+         fi
+      fi
+    fi
+    if [ `grep monthly_statistics_enable /etc/periodic.conf | wc -l` = 1 ]; then
+      echo ""
+      if yesno "Would you like to run BSDstats right now" y; then
+         ${PKG_PREFIX}/etc/periodic/monthly/300.statistics -nodelay
+         echo ""
+       fi
     fi
+    if [ `grep monthly_statistics_enable /etc/periodic.conf | wc -l` = 0 ]; then
+      if [ `grep bsdstats_enable /etc/rc.conf | wc -l` = 1 ]; then
+        echo ""
+        if yesno "Would you like to run BSDstats right now" y; then
+            ${PKG_PREFIX}/etc/periodic/monthly/300.statistics -xnodelay
+        echo ""
+       fi
+      fi
+   fi
 fi
-


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list