[79524] branches/gsoc11-statistics/base/submitstats.sh

derek at macports.org derek at macports.org
Thu Jun 16 09:42:50 PDT 2011


Revision: 79524
          http://trac.macports.org/changeset/79524
Author:   derek at macports.org
Date:     2011-06-16 09:42:49 -0700 (Thu, 16 Jun 2011)
Log Message:
-----------
Added submitstats.sh

This script calls port stats submit only if a user is participating.
This script should not be called directly - It will be run by launchd

It takes one argument - the path to the MacPorts configuration file
It checks that configuration file for the value of 'stats_participate'
It runs 'port stats submit' only if 'stats_participate' is set to 'yes'

Added Paths:
-----------
    branches/gsoc11-statistics/base/submitstats.sh

Added: branches/gsoc11-statistics/base/submitstats.sh
===================================================================
--- branches/gsoc11-statistics/base/submitstats.sh	                        (rev 0)
+++ branches/gsoc11-statistics/base/submitstats.sh	2011-06-16 16:42:49 UTC (rev 79524)
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# This script calls port stats submit only if a user is participating.
+# This script should not be called directly - It will be run by launchd
+
+# It takes one argument - the path to the MacPorts configuration file
+# It checks that configuration file for the value of 'stats_participate'
+# It runs 'port stats submit' only if 'stats_participate' is set to 'yes'
+
+configfile=$1
+
+die () {
+    echo >&2 "$@"
+    exit 1
+}
+
+# Make sure the config file exists
+if [ ! -f "$configfile" ]; then
+   	die "$CONFIG does not exist"
+fi
+
+# Read configfile and see if stats_participate is set to yes
+is_participating() {
+	# An example line is "stats_participate yes"
+	line=$(grep "stats_participate" $configfile)
+	participating=$(awk '{print $2}' <<< $line)
+	if [ "$participating" == "yes" ]; then
+		return 0 # Return true - user is participating
+	else  
+		return 1 # Return false
+	fi
+}
+
+# Run the command if the user is participating
+if is_participating ; then
+	port stats submit > /dev/null
+fi
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110616/eca71ebc/attachment.html>


More information about the macports-changes mailing list