diff options
author | scrappy <scrappy@FreeBSD.org> | 2006-10-04 12:46:01 +0800 |
---|---|---|
committer | scrappy <scrappy@FreeBSD.org> | 2006-10-04 12:46:01 +0800 |
commit | ac5e57527f4d392e71f04f01f18b2e4917531101 (patch) | |
tree | 58c2ec99afb0217563c31fbb70e2bc02f4282d17 /sysutils | |
parent | b4ace171444003b21b2beb4fd3817fb6421ddaf1 (diff) | |
download | freebsd-ports-gnome-ac5e57527f4d392e71f04f01f18b2e4917531101.tar.gz freebsd-ports-gnome-ac5e57527f4d392e71f04f01f18b2e4917531101.tar.zst freebsd-ports-gnome-ac5e57527f4d392e71f04f01f18b2e4917531101.zip |
Fix PATH so that it includes /usr/local/bin, so that dig is found on
systems where its installed via ports
Log communications, by default, to /var/log/bsdstats, so that one
knows if things are successful ... now have it so that if any phase
FAILs, it exits and doesn't just go to the next, which most likely
won't work either ...
Diffstat (limited to 'sysutils')
-rw-r--r-- | sysutils/bsdstats/Makefile | 2 | ||||
-rw-r--r-- | sysutils/bsdstats/files/300.statistics | 216 | ||||
-rw-r--r-- | sysutils/bsdstats/files/300.statistics.in | 216 |
3 files changed, 351 insertions, 83 deletions
diff --git a/sysutils/bsdstats/Makefile b/sysutils/bsdstats/Makefile index 2e744466c525..d7f84042c165 100644 --- a/sysutils/bsdstats/Makefile +++ b/sysutils/bsdstats/Makefile @@ -6,7 +6,7 @@ # PORTNAME= bsdstats -PORTVERSION= 4.6 +PORTVERSION= 4.7 CATEGORIES= sysutils DISTFILES= diff --git a/sysutils/bsdstats/files/300.statistics b/sysutils/bsdstats/files/300.statistics index 429a2e3c144f..ef3fb78f3706 100644 --- a/sysutils/bsdstats/files/300.statistics +++ b/sysutils/bsdstats/files/300.statistics @@ -1,6 +1,6 @@ #!/bin/sh - # -# $FreeBSD: /tmp/pcvs/ports/sysutils/bsdstats/files/Attic/300.statistics,v 1.31 2006-10-03 01:33:11 scrappy Exp $ +# $FreeBSD: /tmp/pcvs/ports/sysutils/bsdstats/files/Attic/300.statistics,v 1.32 2006-10-04 04:46:01 scrappy Exp $ # # If there is a global system configuration file, suck it in. @@ -22,11 +22,12 @@ fi oldmask=$(umask) umask 066 -version="4.5" -checkin_server=${monthly_statistics_checkin_server:-"rpt.bsdstats.org"} +version="4.7" +checkin_server=${monthly_statistics_checkin_server:-"bsdstats.org"} +bsdstats_log=${monthly_statistics_logfile:-"/var/log/bsdstats"} id_token_file='/var/db/bsdstats' -PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin +PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin export PATH unset HTTP_USER_AGENT @@ -38,6 +39,43 @@ random () { jot -r 1 0 900 } +# RFC 2396 +uri_escape () { + echo ${1+$@} | sed -e ' + s/%/%25/g + s/;/%3b/g + s,/,%2f,g + s/?/%3f/g + s/:/%3a/g + s/@/%40/g + s/&/%26/g + s/=/%3d/g + s/+/%2b/g + s/\$/%24/g + s/,/%2c/g + s/ /%20/g + ' +} + +do_fetch () { + url="http://$checkin_server/scripts/$1" + case $(uname) in + FreeBSD ) + /usr/bin/fetch -q -o - "$url" + ;; + * ) + /usr/bin/ftp -V -o - "$url" + ;; + esac +} + +check_dns () { + if [ `dig bsdstats.org txt | grep TXT | grep UP | wc -l` = 0 ] + then + echo "DNS not reachable, Network Down?" + exit + fi +} send_devices () { case $(uname) in FreeBSD ) @@ -49,7 +87,7 @@ send_devices () { query_string=$query_string`echo \&dev[]=$DRIVER:$DEV:$CLASS` done - do_fetch report_devices.php?token=$TOKEN\&key=$KEY$query_string + report_devices ;; * ) # Not supported @@ -57,6 +95,32 @@ send_devices () { esac } +report_devices () { + do_fetch report_devices.php?token=$TOKEN\&key=$KEY$query_string | { + local IFS + IFS='= +' + + while read var val + do + case $var in + STATUS) + if [ $val = "OK" ] + then + echo "[`date`] System Devices reported" + else + echo "[`date`] System Devices not reported, exiting" + exit + fi + ;; + *) + echo "[`date`] Error with fetch to server" + exit + ;; + esac + done + } >> $bsdstats_log +} get_id_token () { if [ -f $id_token_file ] @@ -108,44 +172,114 @@ get_id_token () { TOKEN=$( uri_escape $TOKEN ) } -# RFC 2396 -uri_escape () { - echo ${1+$@} | sed -e ' - s/%/%25/g - s/;/%3b/g - s,/,%2f,g - s/?/%3f/g - s/:/%3a/g - s/@/%40/g - s/&/%26/g - s/=/%3d/g - s/+/%2b/g - s/\$/%24/g - s/,/%2c/g - s/ /%20/g - ' + +enable_token () { + do_fetch enable_token.php?key=$TOKEN\&token=$KEY | { + local IFS + IFS='= +' + + while read var val + do + case $var in + STATUS) + if [ $val = "OK" ] + then + echo "[`date`] System enabled" + else + echo "[`date`] System not enabled, exiting" + exit + fi + ;; + *) + echo "[`date`] Error with fetch to server" + exit + ;; + esac + done + } >> $bsdstats_log } -do_fetch () { - url="http://$checkin_server/scripts/$1" - case $(uname) in - FreeBSD ) - /usr/bin/fetch -q -o - "$url" - ;; - * ) - /usr/bin/ftp -V -o - "$url" - ;; - esac +disable_token () { + do_fetch disable_token.php?key=$TOKEN\&token=$KEY | { + local IFS + IFS='= +' + + while read var val + do + case $var in + STATUS) + if [ $val = "OK" ] + then + echo "[`date`] System disabled" + else + echo "[`date`] System not disabled, exiting" + exit + fi + ;; + *) + echo "[`date`] Error with fetch to server" + exit + ;; + esac + done + } >> $bsdstats_log } -check_dns () { - if [ `dig bsdstats.org txt | grep TXT | grep UP | wc -l` = 0 ] - then - echo "DNS not reachable, Network Down?" - exit - fi +report_system () { + do_fetch report_system.php?token=$TOKEN\&key=$KEY\&rel=$REL\&arch=$ARCH\&opsys=$OS | { + local IFS + IFS='= +' + + while read var val + do + case $var in + STATUS) + if [ $val = "OK" ] + then + echo "[`date`] System reported" + else + echo "[`date`] System report failed, exiting" + exit + fi + ;; + *) + echo "[`date`] Error with fetch to server" + exit + ;; + esac + done + } >> $bsdstats_log } +report_cpu () { + do_fetch report_cpu.php?token=$TOKEN\&key=$KEY\&cpus=$count\&vendor=$VEN\&cpu_type=$DEV | { + local IFS + IFS='= +' + + while read var val + do + case $var in + STATUS) + if [ $val = "OK" ] + then + echo "[`date`] System CPU reported" + else + echo "[`date`] System CPU report failed, exiting" + exit + fi + ;; + *) + echo "[`date`] Error with fetch to server" + exit + ;; + esac + done + } >> $bsdstats_log +} case "$monthly_statistics_enable" in [Yy][Ee][Ss]) check_dns @@ -155,8 +289,8 @@ case "$monthly_statistics_enable" in OS=`/usr/bin/uname -s` get_id_token sleep `random` - do_fetch enable_token.php?key=$TOKEN\&token=$KEY - do_fetch report_system.php?token=$TOKEN\&key=$KEY\&rel=$REL\&arch=$ARCH\&opsys=$OS + enable_token + report_system echo "Posting monthly OS statistics to $checkin_server" case "$monthly_statistics_report_devices" in [Yy][Ee][Ss]) @@ -166,7 +300,7 @@ case "$monthly_statistics_enable" in VEN=$( echo $line | cut -d ' ' -f 1 ) DEV=$( uri_escape $( echo $line | cut -d ' ' -f 2- ) ) count=$( sysctl -n hw.ncpu ) - do_fetch report_cpu.php?token=$TOKEN\&key=$KEY\&cpus=$count\&vendor=$VEN\&cpu_type=$DEV + report_cpu echo "Posting monthly CPU statistics to $checkin_server" ;; *) @@ -174,7 +308,7 @@ case "$monthly_statistics_enable" in echo " set monthly_statistics_report_devices=\"YES\" in $periodic_conf" ;; esac - do_fetch disable_token.php?key=$TOKEN\&token=$KEY + disable_token ;; *) echo "Posting monthly OS statistics disabled" diff --git a/sysutils/bsdstats/files/300.statistics.in b/sysutils/bsdstats/files/300.statistics.in index caf8a37d08f9..3086649c9ff9 100644 --- a/sysutils/bsdstats/files/300.statistics.in +++ b/sysutils/bsdstats/files/300.statistics.in @@ -1,6 +1,6 @@ #!/bin/sh - # -# $FreeBSD: /tmp/pcvs/ports/sysutils/bsdstats/files/300.statistics.in,v 1.31 2006-10-03 01:33:11 scrappy Exp $ +# $FreeBSD: /tmp/pcvs/ports/sysutils/bsdstats/files/300.statistics.in,v 1.32 2006-10-04 04:46:01 scrappy Exp $ # # If there is a global system configuration file, suck it in. @@ -22,11 +22,12 @@ fi oldmask=$(umask) umask 066 -version="4.5" -checkin_server=${monthly_statistics_checkin_server:-"rpt.bsdstats.org"} +version="4.7" +checkin_server=${monthly_statistics_checkin_server:-"bsdstats.org"} +bsdstats_log=${monthly_statistics_logfile:-"/var/log/bsdstats"} id_token_file='/var/db/bsdstats' -PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin +PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin export PATH unset HTTP_USER_AGENT @@ -38,6 +39,43 @@ random () { jot -r 1 0 900 } +# RFC 2396 +uri_escape () { + echo ${1+$@} | sed -e ' + s/%/%25/g + s/;/%3b/g + s,/,%2f,g + s/?/%3f/g + s/:/%3a/g + s/@/%40/g + s/&/%26/g + s/=/%3d/g + s/+/%2b/g + s/\$/%24/g + s/,/%2c/g + s/ /%20/g + ' +} + +do_fetch () { + url="http://$checkin_server/scripts/$1" + case $(uname) in + FreeBSD ) + /usr/bin/fetch -q -o - "$url" + ;; + * ) + /usr/bin/ftp -V -o - "$url" + ;; + esac +} + +check_dns () { + if [ `dig bsdstats.org txt | grep TXT | grep UP | wc -l` = 0 ] + then + echo "DNS not reachable, Network Down?" + exit + fi +} send_devices () { case $(uname) in FreeBSD ) @@ -49,7 +87,7 @@ send_devices () { query_string=$query_string`echo \&dev[]=$DRIVER:$DEV:$CLASS` done - do_fetch report_devices.php?token=$TOKEN\&key=$KEY$query_string + report_devices ;; * ) # Not supported @@ -57,6 +95,32 @@ send_devices () { esac } +report_devices () { + do_fetch report_devices.php?token=$TOKEN\&key=$KEY$query_string | { + local IFS + IFS='= +' + + while read var val + do + case $var in + STATUS) + if [ $val = "OK" ] + then + echo "[`date`] System Devices reported" + else + echo "[`date`] System Devices not reported, exiting" + exit + fi + ;; + *) + echo "[`date`] Error with fetch to server" + exit + ;; + esac + done + } >> $bsdstats_log +} get_id_token () { if [ -f $id_token_file ] @@ -108,44 +172,114 @@ get_id_token () { TOKEN=$( uri_escape $TOKEN ) } -# RFC 2396 -uri_escape () { - echo ${1+$@} | sed -e ' - s/%/%25/g - s/;/%3b/g - s,/,%2f,g - s/?/%3f/g - s/:/%3a/g - s/@/%40/g - s/&/%26/g - s/=/%3d/g - s/+/%2b/g - s/\$/%24/g - s/,/%2c/g - s/ /%20/g - ' + +enable_token () { + do_fetch enable_token.php?key=$TOKEN\&token=$KEY | { + local IFS + IFS='= +' + + while read var val + do + case $var in + STATUS) + if [ $val = "OK" ] + then + echo "[`date`] System enabled" + else + echo "[`date`] System not enabled, exiting" + exit + fi + ;; + *) + echo "[`date`] Error with fetch to server" + exit + ;; + esac + done + } >> $bsdstats_log } -do_fetch () { - url="http://$checkin_server/scripts/$1" - case $(uname) in - FreeBSD ) - /usr/bin/fetch -q -o - "$url" - ;; - * ) - /usr/bin/ftp -V -o - "$url" - ;; - esac +disable_token () { + do_fetch disable_token.php?key=$TOKEN\&token=$KEY | { + local IFS + IFS='= +' + + while read var val + do + case $var in + STATUS) + if [ $val = "OK" ] + then + echo "[`date`] System disabled" + else + echo "[`date`] System not disabled, exiting" + exit + fi + ;; + *) + echo "[`date`] Error with fetch to server" + exit + ;; + esac + done + } >> $bsdstats_log } -check_dns () { - if [ `dig bsdstats.org txt | grep TXT | grep UP | wc -l` = 0 ] - then - echo "DNS not reachable, Network Down?" - exit - fi +report_system () { + do_fetch report_system.php?token=$TOKEN\&key=$KEY\&rel=$REL\&arch=$ARCH\&opsys=$OS | { + local IFS + IFS='= +' + + while read var val + do + case $var in + STATUS) + if [ $val = "OK" ] + then + echo "[`date`] System reported" + else + echo "[`date`] System report failed, exiting" + exit + fi + ;; + *) + echo "[`date`] Error with fetch to server" + exit + ;; + esac + done + } >> $bsdstats_log } +report_cpu () { + do_fetch report_cpu.php?token=$TOKEN\&key=$KEY\&cpus=$count\&vendor=$VEN\&cpu_type=$DEV | { + local IFS + IFS='= +' + + while read var val + do + case $var in + STATUS) + if [ $val = "OK" ] + then + echo "[`date`] System CPU reported" + else + echo "[`date`] System CPU report failed, exiting" + exit + fi + ;; + *) + echo "[`date`] Error with fetch to server" + exit + ;; + esac + done + } >> $bsdstats_log +} case "$monthly_statistics_enable" in [Yy][Ee][Ss]) check_dns @@ -155,8 +289,8 @@ case "$monthly_statistics_enable" in OS=`/usr/bin/uname -s` get_id_token sleep `random` - do_fetch enable_token.php?key=$TOKEN\&token=$KEY - do_fetch report_system.php?token=$TOKEN\&key=$KEY\&rel=$REL\&arch=$ARCH\&opsys=$OS + enable_token + report_system echo "Posting monthly OS statistics to $checkin_server" case "$monthly_statistics_report_devices" in [Yy][Ee][Ss]) @@ -166,7 +300,7 @@ case "$monthly_statistics_enable" in VEN=$( echo $line | cut -d ' ' -f 1 ) DEV=$( uri_escape $( echo $line | cut -d ' ' -f 2- ) ) count=$( sysctl -n hw.ncpu ) - do_fetch report_cpu.php?token=$TOKEN\&key=$KEY\&cpus=$count\&vendor=$VEN\&cpu_type=$DEV + report_cpu echo "Posting monthly CPU statistics to $checkin_server" ;; *) @@ -174,7 +308,7 @@ case "$monthly_statistics_enable" in echo " set monthly_statistics_report_devices=\"YES\" in $periodic_conf" ;; esac - do_fetch disable_token.php?key=$TOKEN\&token=$KEY + disable_token ;; *) echo "Posting monthly OS statistics disabled" |