#!/bin/sh # rc.updatenodelist # 20090216 1342 Steven Henke, w9sh@xelatec.com # TOPDOMAIN=allstarlink.org SUBDOMAINS="nodes4 nodes3 nodes2 nodes1" FILEPATH=/var/lib/asterisk WGET=`which wget` MYDEBUG= # debugout() { if [ ! -z "$MYDEBUG" ]; then echo "$1" >&2 fi } # debugout "rc.updatenodelist start" while [ 1 ] do for i in $SUBDOMAINS do res=0 while [ $res -eq 0 ] do debugout "rc.updatenodelist trying server $i.$TOPDOMAIN" $WGET -q -O $FILEPATH/rpt_extnodes-temp http://$i.$TOPDOMAIN/cgi-bin/nodes.pl res=$? grep -c extnodes $FILEPATH/rpt_extnodes-temp &> /dev/null enodes=$? if [ $enodes = 1 ]; then res=1 debugout "ERROR: return file does not have extnodes" else debugout "NOTICE: return file has extnodes" fi if [ $res -eq 0 ]; then debugout "Downloaded node list from $i.$TOPDOMAIN" /bin/chmod 700 $FILEPATH/rpt_extnodes-temp /bin/chown asterisk:asterisk $FILEPATH/rpt_extnodes-temp /bin/mv -f $FILEPATH/rpt_extnodes-temp $FILEPATH/rpt_extnodes debugout "sleeping..." sleep 600 else debugout "Problem retrieving node list from $i.$TOPDOMAIN trying next server" sleep 3 fi done done done