Changeset 10950 in hybrid for branches


Ignore:
Timestamp:
May 20, 2012, 3:24:58 PM (13 years ago)
Author:
rick
Message:

I guess not awake during rewrite. Did it right now.

Related-To: nodefactory:ticket:187

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/releng-9.0/nanobsd/files/usr/local/bin/pen_wrapper

    r10926 r10950  
    2323}
    2424
    25 update_proxy_list() {
     25get_proxy_list() {
    2626  # Get (updated) proxy listing from configuration files.
    2727  . /etc/rc.subr
     
    3434test_proxy() {
    3535  PROXY=$1
    36   retstr=`HTTP_PROXY=http://$PROXY fetch -T 3 -o /dev/null ${TEST_URL} 2>&1` || return 0
    37   BPS=`echo "${retstr}" | awk '/Bps/ {printf $4}'`
    38   return $BPS
     36  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"}
    3939}
    4040
    4141# Sort proxy list on highest bandwidth
    42 sort_proxies() {
     42test_proxies() {
    4343  result=''
    4444  for host in $*; do
    4545    bps=`test_proxy $host:3128`
    46     result="$bps $host:3128"
     46    if [ "$bps" != "0" ]; then
     47      result="$result $bps:$host:3128"
     48    fi
    4749  done
    4850
    49   echo $result | xargs -n2 | sort -r | awk '{print $2}' | xargs
     51  echo $result | xargs -n1 | sort -t':' -k1 -n -r | cut -d: -f 2,3 | xargs
    5052}
    5153
     
    5557LIVE_PROXY_LIST=''
    5658while true; do
    57   PROXY_LIST=`update_proxy_list`
     59  PROXY_LIST=`get_proxy_list`
    5860  if [ -z "$PROXY_LIST" ]; then
    5961    logit "Not starting: list_normal_proxies variable not configured"
    6062  else
    61     NEW_PROXY_LIST=`sort_proxies $PROXY_LIST`
     63    NEW_PROXY_LIST=`test_proxies $PROXY_LIST`
    6264    if [ "${LIVE_PROXY_LIST}" != "${NEW_PROXY_LIST}" ]; then
    6365      logit "INFO: New listing to be configured '${NEW_PROXY_LIST}'"
Note: See TracChangeset for help on using the changeset viewer.