source: hybrid/branches/releng-9.0/nanobsd/files/usr/local/sbin/check-inet-alive@ 10469

Last change on this file since 10469 was 10469, checked in by rick, 13 years ago

This one-liner hurt the brain, but basically checks if we need to start/stop lvrouted at all.

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/bin/sh
2#
3# Internet Connection Wrapper From Cron
4#
5# a) Disable lvrouted if the internet is down.
6# b) Re-enable lvrouted if the internet is back up.
7#
8# XXX: Do we need build an fail-save for flapping states?
9# XXX: Do we need to manage state, like DHCP here?
10# XXX: Check if page output is actually the output expected and not some weird captive portal somewhere.
11#
12# Rick van der Zwet <info@rickvanderzwet.nl>
13#
14
15# Check if we need to check inet at all
16. /etc/rc.subr
17load_rc_config "lvrouted"
18: ${lvouted_enable="NO"}
19: ${service_ileiden="NO"}
20: ${service_proxy="NO"}
21(( checkyesno service_ileiden || checkyesno service_proxy ) && checkyesno lvouted_enable ) || exit 0
22
23
24
25TAG=`basename $0`
26INET_STATUS=down
27service lvrouted onestatus > /dev/null && LVROUTED_STATUS="running" || LVROUTED_STATUS="stopped"
28
29# Main I-net check
30fetch -o /dev/null -q http://proxy-test.wirelessleiden.nl && INET_STATUS=up
31
32if [ $INET_STATUS = "down" ]; then
33 # Failback internet check
34 fetch -o /dev/null http://ams-ix.net && INET_STATUS=up
35fi
36
37if [ $LVROUTED_STATUS = "stopped" ] && [ $INET_STATUS = "up" ]; then
38 service lvrouted start | logger -t "$TAG"
39elif [ $LVROUTED_STATUS = "running" ] && [ $INET_STATUS = "down" ]; then
40 service lvrouted stop | logger -t "$TAG"
41fi
Note: See TracBrowser for help on using the repository browser.