Index: branches/releng-9.0/nanobsd/files/tools/check-inet-alive
===================================================================
--- branches/releng-9.0/nanobsd/files/tools/check-inet-alive	(revision 10720)
+++ branches/releng-9.0/nanobsd/files/tools/check-inet-alive	(revision 10720)
@@ -0,0 +1,70 @@
+#!/bin/sh
+#
+# Internet Connection Wrapper From Cron
+#
+# a) Disable lvrouted if the internet is down.
+# b) Re-enable lvrouted if the internet is back up.
+#
+# XXX: Do we need build an fail-save for flapping states?
+# XXX: Do we need to manage state, like DHCP here?
+# XXX: Check if page output is actually the output expected and not some weird captive portal somewhere.
+# XXX: For effiently reasons this should be combined with the nagios check_inet check
+# 
+# Rick van der Zwet <info@rickvanderzwet.nl>
+#
+
+TAG=`basename $0`
+logit() {
+  logger -t "$TAG" $*
+}
+
+# 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"}
+: ${service_ileiden="NO"}
+: ${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"
+
+
+service lvrouted onestatus > /dev/null && LVROUTED_STATUS="running" || LVROUTED_STATUS="stopped"
+service tinyproxy onestatus > /dev/null && TINYPROXY_STATUS="running" || TINYPROXY_STATUS="stopped"
+
+check_http() {
+ fetch -o /dev/null -q $* 2>/dev/null
+}
+
+# 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
+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
+
+# Log Network Status
+cat <<EOF > /tmp/network.status
+internet=$INET_STATUS
+proxy=$PROXY_STATUS
+EOF
+
+# Control connections
+if checkyesno control_lvrouted; then
+  if [ $LVROUTED_STATUS = "stopped" ] && [ $INET_STATUS = "up" ]; then
+    service lvrouted start | logit
+  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
+    service tinyproxy start | logit
+  elif [ $TINYPROXY_STATUS = "running" ] && [ $INET_STATUS = "down" ]; then
+    service tinyproxy stop | logit
+  fi
+fi
Index: branches/releng-9.0/nanobsd/files/tools/find-nanostation
===================================================================
--- branches/releng-9.0/nanobsd/files/tools/find-nanostation	(revision 10720)
+++ branches/releng-9.0/nanobsd/files/tools/find-nanostation	(revision 10720)
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Discover nanostation using CDPv1 packets
+# Credits: http://sidewynder.blogspot.com/2005/07/tcpdump-filter-for-capturing-only.html
+
+if [ "x$1" = "x" ]; then
+  echo "Usage: $0 <iface> [count]" 1>&2
+  echo "Find (lost) Nanostation IP using 'count' CDPv1 packet(s)"
+  echo "Normally CDPv1 packets get send every minute" 1>&2
+  echo "Interface hints: `ifconfig -l`" 1>&2
+  exit 1
+fi
+IFACE=$1
+# By default the local and remote will announce a broadcast.
+COUNT=${2-2}
+
+
+tcpdump -nn -v -i $IFACE -s 1500 -c $COUNT 'ether[18:4] == 0x000c2000'
Index: branches/releng-9.0/nanobsd/files/tools/mvim
===================================================================
--- branches/releng-9.0/nanobsd/files/tools/mvim	(revision 10720)
+++ branches/releng-9.0/nanobsd/files/tools/mvim	(revision 10720)
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
+# Wrapper to support file hacking on read-only file systems more easily
+#
+# Rick van der Zwet <info@rickvanderzwet.nl>
+
+
+mount -uwo noatime || exit
+vim $*
+mount -uro noatime /
Index: branches/releng-9.0/nanobsd/files/tools/store-ntpdrift
===================================================================
--- branches/releng-9.0/nanobsd/files/tools/store-ntpdrift	(revision 10720)
+++ branches/releng-9.0/nanobsd/files/tools/store-ntpdrift	(revision 10720)
@@ -0,0 +1,30 @@
+#!/bin/sh
+# Back-up ntp.drift file changes to flash. 
+
+SRC="/var/db/ntp.drift"
+DST="/cfg/local/ntp.drift"
+
+trap "umount /cfg" 1 2 15 EXIT
+
+EX_OK=0
+EX_NOINPUT=66
+EX_CANTCREAT=73
+
+mount -ro noatime /cfg
+
+# Check whether source exists
+if [ ! -r $SRC ]; then
+    echo "ERROR: '$SRC' not readable!" 1>&2
+    exit $EX_NOINPUT
+fi
+
+# Compare files, ignore white spaces, modification, etc
+diff -b -B -q ${SRC} ${DST}; RETVAL=$?
+if [ $RETVAL -ne 0 ]; then
+  # 2: DST does not yet, exists, 1: file differs
+  	mount -uwo noatime /cfg
+	mkdir -p /cfg/local
+  	cp ${SRC} ${DST}
+fi
+
+exit $EX_OK
