Index: /branches/releng-9.0/nanobsd/files/tools/check-inet-alive
===================================================================
--- /branches/releng-9.0/nanobsd/files/tools/check-inet-alive	(revision 10828)
+++ /branches/releng-9.0/nanobsd/files/tools/check-inet-alive	(revision 10829)
@@ -11,5 +11,5 @@
 # XXX: For effiently reasons this should be combined with the nagios check_inet check
 # 
-# Rick van der Zwet <info@rickvanderzwet.nl>
+# Rick van der Zwet <rick@wirelessleiden.nl>
 #
 
@@ -21,6 +21,8 @@
 # Check if we need to check inet at all
 . /etc/rc.subr
+
 load_rc_config "lvrouted"
 load_rc_config "tinyproxy"
+
 : ${lvouted_enable="NO"}
 : ${tinyproxy_enable="NO"}
@@ -28,12 +30,15 @@
 : ${service_proxy="NO"}
 
-control_lvrouted="yes"
-control_tinyproxy="yes"
-(( checkyesno service_ileiden || checkyesno service_proxy ) && checkyesno lvouted_enable ) || control_lvrouted="no"
-(( checkyesno service_ileiden || checkyesno service_proxy ) && checkyesno tinyproxy_enable ) || control_tinyproxy="no"
+control_lvrouted=false
+control_tinyproxy=false
+checkyesno service_proxy_ileiden && checkyesno lvouted_enable control_lvrouted=true
+checkyesno service_proxy_normal && checkyesno tinyproxy_enable || control_tinyproxy=false
 
 
-service lvrouted onestatus > /dev/null && LVROUTED_STATUS="running" || LVROUTED_STATUS="stopped"
-service tinyproxy onestatus > /dev/null && TINYPROXY_STATUS="running" || TINYPROXY_STATUS="stopped"
+# Get current state of the daemons
+lvouted_status="stopped"
+tinyproxy_status="stopped"
+service lvrouted onestatus > /dev/null && lvouted_status="running"
+service tinyproxy onestatus > /dev/null && tinyproxy_status="running"
 
 check_http() {
@@ -41,29 +46,30 @@
 }
 
-# Get connection stats for internet
-INET_STATUS=up && check_http http://proxy-test.wirelessleiden.nl || check_http http://ams-ix.net || INET_STATUS=down
-# Connections statistics for proxy
+# Get connection stats for internet direct and via proxy
+inet_status=up
+proxy_status=up
+check_http http://proxy-test.wirelessleiden.nl || check_http http://ams-ix.net || inet_status=down
 export HTTP_PROXY=${HTTP_PROXY-:http://proxy.wleiden.net:3128}
-PROXY_STATUS=up && check_http http://tinyproxy.stats || check_http http://ams-ix.net || PROXY_STATUS=down
+check_http http://tinyproxy.stats || check_http http://ams-ix.net || proxy_status=down
 
 # Log Network Status
 cat <<EOF > /tmp/network.status
-internet=$INET_STATUS
-proxy=$PROXY_STATUS
+internet=$inet_status
+proxy=$proxy_status
 EOF
 
 # Control connections
-if checkyesno control_lvrouted; then
-  if [ $LVROUTED_STATUS = "stopped" ] && [ $INET_STATUS = "up" ]; then
+if $control_lvrouted; then
+  if [ $lvrouted_status = "stopped" ] && [ $inet_status = "up" ]; then
     service lvrouted start | logit
-  elif [ $LVROUTED_STATUS = "running" ] && [ $INET_STATUS = "down" ]; then
+  elif [ $lvrouted_status = "running" ] && [ $inet_status = "down" ]; then
     service lvrouted stop | logit
   fi
 fi
 
-if checkyesno control_tinyproxy; then
-  if [ $TINYPROXY_STATUS_STATUS = "stopped" ] && [ $INET_STATUS = "up" ]; then
+if $control_tinyproxy; then
+  if [ $tinyproxy_status = "stopped" ] && [ $inet_status = "up" ]; then
     service tinyproxy start | logit
-  elif [ $TINYPROXY_STATUS = "running" ] && [ $INET_STATUS = "down" ]; then
+  elif [ $tinyproxy_status = "running" ] && [ $inet_status = "down" ]; then
     service tinyproxy stop | logit
   fi
