diff --git a/sysutils/bsdstats/Makefile b/sysutils/bsdstats/Makefile index 30b8f61436da..d60ffd257cb2 100644 --- a/sysutils/bsdstats/Makefile +++ b/sysutils/bsdstats/Makefile @@ -1,38 +1,38 @@ # New ports collection makefile for: bsdstats # Date created: 5 August 2006 # Whom: Marc G. Fournier # # $FreeBSD$ # PORTNAME= bsdstats -PORTVERSION= 4.2 +PORTVERSION= 4.3 CATEGORIES= sysutils DISTFILES= MAINTAINER= scrappy@freebsd.org COMMENT= Monthly script for reporting anonymous statistics about your machine NO_BUILD= yes PLIST_FILES= etc/periodic/monthly/300.statistics PLIST_DIRS= etc/periodic/monthly \ etc/periodic .include do-install: ${MKDIR} ${LOCALBASE}/etc/periodic/monthly ${CP} ${FILESDIR}/300.statistics ${LOCALBASE}/etc/periodic/monthly post-install: ${CAT} ${PKGMESSAGE} .if defined(BATCH) || defined(PACKAGE_BUILDING) @${ECHO_MSG} " To activate monthly statistics reporting in /etc/periodic.conf," @${ECHO_MSG} " execute the following as root user:" @${ECHO_MSG} @${ECHO_MSG} "PKG_PREFIX=\"${PREFIX}\" ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL" @${ECHO_MSG} .else @PKG_PREFIX="${PREFIX}" ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL .endif .include diff --git a/sysutils/bsdstats/files/300.statistics b/sysutils/bsdstats/files/300.statistics index a7c67b533230..3f3ee1b31295 100644 --- a/sysutils/bsdstats/files/300.statistics +++ b/sysutils/bsdstats/files/300.statistics @@ -1,201 +1,201 @@ #!/bin/sh - # -# $FreeBSD: /tmp/pcvs/ports/sysutils/bsdstats/files/Attic/300.statistics,v 1.27 2006-09-29 18:59:28 scrappy Exp $ +# $FreeBSD: /tmp/pcvs/ports/sysutils/bsdstats/files/Attic/300.statistics,v 1.28 2006-10-01 06:15:31 scrappy Exp $ # # If there is a global system configuration file, suck it in. # if [ -r /etc/defaults/periodic.conf ] then . /etc/defaults/periodic.conf source_periodic_confs periodic_conf=/etc/periodic.conf else . /etc/rc.conf # For systems without periodic.conf, use rc.conf if [ -r /etc/rc.conf.local ] then . /etc/rc.conf.local fi periodic_conf=/etc/rc.conf.local fi oldmask=$(umask) umask 066 version="4.0" -checkin_server=${monthly_statistics_checkin_server:-"bsdstats.org"} +checkin_server=${monthly_statistics_checkin_server:-"rpt.bsdstats.org"} id_token_file='/var/db/bsdstats' PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin export PATH unset HTTP_USER_AGENT IFS=" " random () { jot -r 1 0 900 } send_devices () { case $(uname) in FreeBSD ) for line in `/usr/sbin/pciconf -l | /usr/bin/grep -v none` do DRIVER=`echo $line | awk -F\@ '{print $1}'` DEV=`echo $line | awk '{print $4}' | cut -c8-15` CLASS=`echo $line | awk '{print $2}' | cut -c9-14` query_string=$query_string`echo \&dev[]=$DRIVER:$DEV:$CLASS` done do_fetch report_devices.php?token=$TOKEN\&key=$KEY$query_string ;; * ) # Not supported ;; esac } get_id_token () { if [ -f $id_token_file ] then if [ `cat /var/db/bsdstats | wc -l` -lt 3 ] then rm $id_token_file fi fi if [ ! -f $id_token_file -o ! -s $id_token_file ] ; then IDTOKEN=$(uri_escape $( openssl rand -base64 32 ) ) idf=$( mktemp "$id_token_file.XXXXXX" ) && \ chown root:wheel $idf && \ chmod 600 $idf sleep `random` do_fetch getid.php?key=$IDTOKEN | { local IFS IFS='= ' while read var val do case $var in KEY) echo "KEY=$val" ;; TOKEN) echo "TOKEN=$val" ;; *) ;; esac done echo "VERSION=$version" } > $idf && \ mv $idf $id_token_file if [ ! -s $id_token_file ] ; then echo "Nothing returned from $checkin_server" exit 1 fi echo "To protect against abuse, the initial challenge/response phase" echo "contains a 15 minute pause. Please be patient while this time" echo "limit elapses" sleep 900 else FILETIME=$( stat -f %m $id_token_file ) NOW=$( date +%s ) if [ $(( $NOW - 900 )) -le $FILETIME ]; then SLEEPTIME=$(( 900 - ($NOW - $FILETIME) )) echo "Token key is younger than 15 minutes!" echo "Sleeping $SLEEPTIME seconds, please wait." sleep $SLEEPTIME fi fi . $id_token_file KEY=$( uri_escape $KEY ) 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 ' } 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 } case "$monthly_statistics_enable" in [Yy][Ee][Ss]) check_dns HN=`/bin/hostname` REL=`/usr/bin/uname -r` ARCH=`/usr/bin/uname -m` 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 echo "Posting monthly OS statistics to $checkin_server" case "$monthly_statistics_report_devices" in [Yy][Ee][Ss]) send_devices echo "Posting monthly device statistics to $checkin_server" line=$( sysctl -n hw.model ) 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 echo "Posting monthly CPU statistics to $checkin_server" ;; *) echo "Posting monthly device/CPU statistics disabled" echo ' set monthly_statistics_report_devices="YES" in $periodic_conf' ;; esac do_fetch disable_token.php?key=$TOKEN\&token=$KEY ;; *) echo "Posting monthly OS statistics disabled" echo ' set monthly_statistics_enable="YES" in $periodic_conf' ;; esac umask $oldmask exit $rc diff --git a/sysutils/bsdstats/files/300.statistics.in b/sysutils/bsdstats/files/300.statistics.in index ef537aca8dfb..31515c978f5f 100644 --- a/sysutils/bsdstats/files/300.statistics.in +++ b/sysutils/bsdstats/files/300.statistics.in @@ -1,201 +1,201 @@ #!/bin/sh - # -# $FreeBSD: /tmp/pcvs/ports/sysutils/bsdstats/files/300.statistics.in,v 1.27 2006-09-29 18:59:28 scrappy Exp $ +# $FreeBSD: /tmp/pcvs/ports/sysutils/bsdstats/files/300.statistics.in,v 1.28 2006-10-01 06:15:31 scrappy Exp $ # # If there is a global system configuration file, suck it in. # if [ -r /etc/defaults/periodic.conf ] then . /etc/defaults/periodic.conf source_periodic_confs periodic_conf=/etc/periodic.conf else . /etc/rc.conf # For systems without periodic.conf, use rc.conf if [ -r /etc/rc.conf.local ] then . /etc/rc.conf.local fi periodic_conf=/etc/rc.conf.local fi oldmask=$(umask) umask 066 version="4.0" -checkin_server=${monthly_statistics_checkin_server:-"bsdstats.org"} +checkin_server=${monthly_statistics_checkin_server:-"rpt.bsdstats.org"} id_token_file='/var/db/bsdstats' PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin export PATH unset HTTP_USER_AGENT IFS=" " random () { jot -r 1 0 900 } send_devices () { case $(uname) in FreeBSD ) for line in `/usr/sbin/pciconf -l | /usr/bin/grep -v none` do DRIVER=`echo $line | awk -F\@ '{print $1}'` DEV=`echo $line | awk '{print $4}' | cut -c8-15` CLASS=`echo $line | awk '{print $2}' | cut -c9-14` query_string=$query_string`echo \&dev[]=$DRIVER:$DEV:$CLASS` done do_fetch report_devices.php?token=$TOKEN\&key=$KEY$query_string ;; * ) # Not supported ;; esac } get_id_token () { if [ -f $id_token_file ] then if [ `cat /var/db/bsdstats | wc -l` -lt 3 ] then rm $id_token_file fi fi if [ ! -f $id_token_file -o ! -s $id_token_file ] ; then IDTOKEN=$(uri_escape $( openssl rand -base64 32 ) ) idf=$( mktemp "$id_token_file.XXXXXX" ) && \ chown root:wheel $idf && \ chmod 600 $idf sleep `random` do_fetch getid.php?key=$IDTOKEN | { local IFS IFS='= ' while read var val do case $var in KEY) echo "KEY=$val" ;; TOKEN) echo "TOKEN=$val" ;; *) ;; esac done echo "VERSION=$version" } > $idf && \ mv $idf $id_token_file if [ ! -s $id_token_file ] ; then echo "Nothing returned from $checkin_server" exit 1 fi echo "To protect against abuse, the initial challenge/response phase" echo "contains a 15 minute pause. Please be patient while this time" echo "limit elapses" sleep 900 else FILETIME=$( stat -f %m $id_token_file ) NOW=$( date +%s ) if [ $(( $NOW - 900 )) -le $FILETIME ]; then SLEEPTIME=$(( 900 - ($NOW - $FILETIME) )) echo "Token key is younger than 15 minutes!" echo "Sleeping $SLEEPTIME seconds, please wait." sleep $SLEEPTIME fi fi . $id_token_file KEY=$( uri_escape $KEY ) 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 ' } 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 } case "$monthly_statistics_enable" in [Yy][Ee][Ss]) check_dns HN=`/bin/hostname` REL=`/usr/bin/uname -r` ARCH=`/usr/bin/uname -m` 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 echo "Posting monthly OS statistics to $checkin_server" case "$monthly_statistics_report_devices" in [Yy][Ee][Ss]) send_devices echo "Posting monthly device statistics to $checkin_server" line=$( sysctl -n hw.model ) 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 echo "Posting monthly CPU statistics to $checkin_server" ;; *) echo "Posting monthly device/CPU statistics disabled" echo ' set monthly_statistics_report_devices="YES" in $periodic_conf' ;; esac do_fetch disable_token.php?key=$TOKEN\&token=$KEY ;; *) echo "Posting monthly OS statistics disabled" echo ' set monthly_statistics_enable="YES" in $periodic_conf' ;; esac umask $oldmask exit $rc