source: hybrid/trunk/nanobsd/files/usr/local/sbin/inet@ 10136

Last change on this file since 10136 was 10136, checked in by richardvm, 13 years ago

domme toevoeging van proxy files

  • Property svn:executable set to *
File size: 1.4 KB
Line 
1#!/bin/sh
2
3PATH=$PATH:/bin:/usr/bin
4export PATH
5
6# Test page to query
7PROXY_TEST='http://www.ams-ix.net/'
8
9# Log file
10LOGFILE='/var/log/inet.log'
11PIDFILE='/var/run/inet.pid'
12
13# Speed periods
14SLEEP_OK='900'
15SLEEP_NOK='60'
16
17# Write pid file
18echo $$ > ${PIDFILE}
19
20# Logging
21log()
22{
23 _datestamp=`date "+%Y-%m-%d %H:%M:%S"`
24 _msg="[${_datestamp}] $*"
25 echo "${_msg}" >> ${LOGFILE}
26}
27
28# Start/stop lvrouted
29lvrouted()
30{
31 script=/usr/local/etc/rc.d/lvrouted
32
33 case $1 in
34
35 enable)
36 ${script} onestart
37 ;;
38
39 disable)
40 ${script} onestop
41 ;;
42
43 esac
44
45}
46
47# Make sure I never die
48while [ true ];
49do
50
51 # Query the webpage
52 fetch -o /dev/null ${PROXY_TEST} > /dev/null 2>/dev/null
53
54 # What is the Exit code of fetch?
55 EXIT=$?
56
57 # Did the status change?
58 if [ "$STATUS" != "$EXIT" ]; then
59 STATUS=${EXIT}
60
61 # New status:
62 case ${STATUS} in
63
64 # Internet is present, let's enable lvrouted
65 0)
66 lvrouted enable
67 log "INET OK: Enabled lvrouted"
68 ;;
69
70 # Internet is not present, let's disabled lvrouted
71 1)
72 lvrouted disable
73 log "INET CRITICAL: Disabled lvrouted"
74 ;;
75
76 esac
77 fi
78
79 # Did my magic, lets sleep
80 case ${STATUS} in
81
82 # I am in ok state, I will wake up in ...
83 0)
84 sleep ${SLEEP_OK}
85 ;;
86
87
88 # I am in nok state, I will wake up in ...
89 1)
90 sleep ${SLEEP_NOK}
91 ;;
92
93 esac
94
95
96done
97
Note: See TracBrowser for help on using the repository browser.