]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/initscripts/init.d/connectioncheck
4 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/ppp
/settings
)
6 # MAXRETRIES is now a count before red clear and if reconnection fail, eventually switching to a backup profil
8 if [ ! $HOLDOFF ]; then
12 # Debugging. Comment it out to stop logging
15 if [ "z$DEBUG" != "z" ] ; then
16 /usr
/bin
/logger
-t red
"Connectioncheck: $*"
21 if [ -s "/var/ipfire/red/keepconnected" ]; then
22 ATTEMPTS
=$
(/bin
/cat /var
/ipfire
/red
/keepconnected
)
24 echo "0" > /var
/ipfire
/red
/keepconnected
29 # waiting pppd start or sync timout set at 90 s when available in driver
30 # So just wait 5 s after 'red start' end where pppd should have been started
32 while ( ! /bin
/ps ax |
/bin
/grep -q [p
]ppd
); do
33 if [ ! -e "/var/ipfire/red/keepconnected" ]; then
34 # user pressed disconnect in gui
37 RCREDSTART
=`/bin/ps ax | /bin/grep 'red start'`
38 if [ "$TIMETOSTART" -eq 1 ]; then
39 msg
"fail before pppd start : no sync, trying again"
40 /etc
/rc.d
/init.d
/network restart red
43 # give 5 s more at pppd to be visible with ps ax after 'red start' end
44 if [ "$RCREDSTART" = '' ]; then
50 #watching if an IP is received in $MAXCONFIGURE time to avoid some pppoa waiting forever even after LCP timeout
52 while [ "$COUNT" -le "$MAXCONFIGURE" ]; do
53 if [ ! -e "/var/ipfire/red/keepconnected" ]; then
54 # user pressed disconnect in gui
57 if [ -e "/var/ipfire/red/active" ]; then
58 # connected in time so exit
59 echo "0" > /var
/ipfire
/red
/keepconnected
62 if [ -e "/var/ipfire/red/dial-on-demand" ]; then
63 # Don't count time when dial-on-demand is not really connected
64 if ( ! /sbin
/ifconfig |
/bin
/grep -q addr
:10.64.64.64 ); then
70 if ( ! /bin
/ps ax |
/bin
/grep -q [p
]ppd
); then
71 #pppd exit, so don't need to wait MAXCONFIGURE
76 msg
"RED fail to connect"
77 RCREDSTART
=`/bin/ps ax | /bin/grep 'red start' | /usr/bin/cut -f1 -d ' '`
78 if [ "$RCREDSTART" != '' ]; then
79 /bin
/kill "$RCREDSTART"
81 # this attempt to connect fail, so retry
83 #Don't erase keepconnected because it is used to watch user actions
84 /usr
/bin
/touch /var
/ipfire
/red
/redial
85 /etc
/rc.d
/init.d
/network stop red
86 while ( /bin
/ps ax |
/bin
/grep -q [p
]ppd
); do
87 msg
"waiting pppd exit"
91 if [ ! -e "/var/ipfire/red/keepconnected" ]; then
92 # user pressed disconnect in gui
96 msg
"Restarting $ATTEMPTS/$MAXRETRIES"
97 if [ "$ATTEMPTS" -ge "$MAXRETRIES" ]; then
98 echo "0" > /var
/ipfire
/red
/keepconnected
99 msg
"Clearing RED interface"
100 /etc
/rc.d
/init.d
/network stop red
101 if [ "$BACKUPPROFILE" != '' ]; then
102 /bin
/rm -f /var
/ipfire
/ppp
/settings
103 /bin
/cp "/var/ipfire/ppp/settings-$BACKUPPROFILE" /var
/ipfire
/ppp
/settings
106 echo $ATTEMPTS > /var
/ipfire
/red
/keepconnected
108 /etc
/rc.d
/init.d
/network start red
111 while ( /bin
/ps ax |
/bin
/grep -q [p
]ppd
); do
114 msg
"will connect again"
115 /etc
/rc.d
/init.d
/network start red
118 /bin
/echo "Usage: $0 {start|reconnect}"