Changeset 10950 in hybrid for branches/releng-9.0/nanobsd/files/usr/local/bin/pen_wrapper
- Timestamp:
- May 20, 2012, 3:24:58 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/releng-9.0/nanobsd/files/usr/local/bin/pen_wrapper
r10926 r10950 23 23 } 24 24 25 update_proxy_list() {25 get_proxy_list() { 26 26 # Get (updated) proxy listing from configuration files. 27 27 . /etc/rc.subr … … 34 34 test_proxy() { 35 35 PROXY=$1 36 retstr=`HTTP_PROXY=http://$PROXY fetch -T 3 -o /dev/null ${TEST_URL} 2>&1` || return 037 BPS=`echo "${retstr}" | awk '/Bps/ {printf $4}'`38 return $BPS36 retstr=`HTTP_PROXY=http://$PROXY fetch -T 3 -o /dev/null ${TEST_URL} 2>&1` 37 bps=`echo "${retstr}" | awk '/Bps/ {printf $4}'` 38 echo ${bps:-"0"} 39 39 } 40 40 41 41 # Sort proxy list on highest bandwidth 42 sort_proxies() {42 test_proxies() { 43 43 result='' 44 44 for host in $*; do 45 45 bps=`test_proxy $host:3128` 46 result="$bps $host:3128" 46 if [ "$bps" != "0" ]; then 47 result="$result $bps:$host:3128" 48 fi 47 49 done 48 50 49 echo $result | xargs -n 2 | sort -r | awk '{print $2}'| xargs51 echo $result | xargs -n1 | sort -t':' -k1 -n -r | cut -d: -f 2,3 | xargs 50 52 } 51 53 … … 55 57 LIVE_PROXY_LIST='' 56 58 while true; do 57 PROXY_LIST=` update_proxy_list`59 PROXY_LIST=`get_proxy_list` 58 60 if [ -z "$PROXY_LIST" ]; then 59 61 logit "Not starting: list_normal_proxies variable not configured" 60 62 else 61 NEW_PROXY_LIST=` sort_proxies $PROXY_LIST`63 NEW_PROXY_LIST=`test_proxies $PROXY_LIST` 62 64 if [ "${LIVE_PROXY_LIST}" != "${NEW_PROXY_LIST}" ]; then 63 65 logit "INFO: New listing to be configured '${NEW_PROXY_LIST}'"
Note:
See TracChangeset
for help on using the changeset viewer.