Changeset 10483 in hybrid for branches/releng-9.0/nanobsd/files/usr/local/sbin/check-inet-alive
- Timestamp:
- Apr 13, 2012, 7:18:42 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/releng-9.0/nanobsd/files/usr/local/sbin/check-inet-alive
r10481 r10483 15 15 16 16 TAG=`basename $0` 17 INET_STATUS=down 17 logit() { 18 logger -t "$TAG" $* 19 } 20 21 # Check if we need to check inet at all 22 . /etc/rc.subr 23 load_rc_config "lvrouted" 24 load_rc_config "tinyproxy" 25 : ${lvouted_enable="NO"} 26 : ${tinyproxy_enable="NO"} 27 : ${service_ileiden="NO"} 28 : ${service_proxy="NO"} 29 30 control_lvrouted="yes" 31 control_tinyproxy="yes" 32 (( checkyesno service_ileiden || checkyesno service_proxy ) && checkyesno lvouted_enable ) || control_lvrouted="no" 33 (( checkyesno service_ileiden || checkyesno service_proxy ) && checkyesno tinyproxy_enable ) || control_tinyproxy="no" 34 35 18 36 service lvrouted onestatus > /dev/null && LVROUTED_STATUS="running" || LVROUTED_STATUS="stopped" 37 service tinyproxy onestatus > /dev/null && TINYPROXY_STATUS="running" || TINYPROXY_STATUS="stopped" 19 38 20 39 check_http() { … … 22 41 } 23 42 24 # Main I-net check 25 check_http http://proxy-test.wirelessleiden.nl && INET_STATUS=up 43 # Get connection stats for internet 44 INET_STATUS=up && check_http http://proxy-test.wirelessleiden.nl || check_http http://ams-ix.net || INET_STATUS=down 45 # Connections statistics for proxy 46 export HTTP_PROXY=${HTTP_PROXY-:http://proxy.wleiden.net:3128} 47 PROXY_STATUS=up && check_http http://tinyproxy.stats || check_http http://ams-ix.net || PROXY_STATUS=down 26 48 27 if [ $INET_STATUS = "down" ]; then 28 # Failback internet check 29 check_http http://ams-ix.net && INET_STATUS=up 49 # Log Network Status 50 cat <<EOF > /tmp/network.status 51 internet=$INET_STATUS 52 echo proxy=$PROXY_STATUS 53 EOF 54 55 # Control connections 56 if checkyesno control_lvrouted; then 57 if [ $LVROUTED_STATUS = "stopped" ] && [ $INET_STATUS = "up" ]; then 58 service lvrouted start | logit 59 elif [ $LVROUTED_STATUS = "running" ] && [ $INET_STATUS = "down" ]; then 60 service lvrouted stop | logit 61 fi 30 62 fi 31 63 32 if [ $LVROUTED_STATUS = "stopped" ] && [ $INET_STATUS = "up" ]; then 33 service lvrouted start | logger -t "$TAG" 34 elif [ $LVROUTED_STATUS = "running" ] && [ $INET_STATUS = "down" ]; then 35 service lvrouted stop | logger -t "$TAG" 64 if checkyesno control_tinyproxy; then 65 if [ $TINYPROXY_STATUS_STATUS = "stopped" ] && [ $INET_STATUS = "up" ]; then 66 service tinyproxy start | logit 67 elif [ $TINYPROXY_STATUS = "running" ] && [ $INET_STATUS = "down" ]; then 68 service tinyproxy stop | logit 69 fi 36 70 fi 37 38 # Retrieve proxy status39 export HTTP_PROXY=${HTTP_PROXY-:http://proxy.wleiden.net:3128}40 PROXY_STATUS=down41 check_http http://proxy-test.wirelessleiden.nl && PROXY_STATUS=down42 43 if [ $INET_STATUS = "down" ]; then44 # Failback internet check45 check_http http://ams-ix.net && PROXY_STATUS=up46 fi47 48 echo -e "internet=$INET_STATUS\nproxy=$PROXY_STATUS" > /tmp/network.status
Note:
See TracChangeset
for help on using the changeset viewer.