]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/rc.d/rc.connectioncheck
3 # $Id: rc.connectioncheck,v 1.4.2.22 2005/07/07 20:11:58 franck78 Exp $
6 eval $
(/usr
/local
/bin
/readhash CONFIG_ROOT
/ppp
/settings
)
8 # MAXRETRIES is now a count before rc.red clear and if reconnection fail, eventually switching to a backup profil
10 if [ ! $HOLDOFF ]; then
14 # Debugging. Comment it out to stop logging
17 if [ "z$DEBUG" != "z" ] ; then
18 /usr
/bin
/logger
-t red
"Connectioncheck: $*"
23 if [ -s "CONFIG_ROOT/red/keepconnected" ]; then
24 ATTEMPTS
=$
(/bin
/cat CONFIG_ROOT
/red
/keepconnected
)
26 echo "0" > CONFIG_ROOT
/red
/keepconnected
31 # waiting pppd start or sync timout set at 90 s when available in driver
32 #rc.eciadsl/eci-load2 timout after 60s and 5 eci-load2 maximum attempts are done in rc.eciadsl.
33 #So just wait 5 s after 'rc.red start' end where pppd should have been started
35 while ( ! /bin
/ps ax |
/bin
/grep -q [p
]ppd
); do
36 if [ ! -e "CONFIG_ROOT/red/keepconnected" ]; then
37 # user pressed disconnect in gui
40 RCREDSTART
=`/bin/ps ax | /bin/grep '[r]c.red start'`
41 if [ "$TIMETOSTART" -eq 1 ]; then
42 msg
"fail before pppd start : no sync, trying again"
44 /etc
/rc.d
/rc.red
clear
45 /etc
/rc.d
/rc.red start
48 # give 5 s more at pppd to be visible with ps ax after 'rc.red start' end
49 if [ "$RCREDSTART" = '' ]; then
55 #watching if an IP is received in $MAXCONFIGURE time to avoid some pppoa waiting forever even after LCP timeout
57 while [ "$COUNT" -le "$MAXCONFIGURE" ]; do
58 if [ ! -e "CONFIG_ROOT/red/keepconnected" ]; then
59 # user pressed disconnect in gui
62 if [ -e "CONFIG_ROOT/red/active" ]; then
63 # connected in time so exit
64 echo "0" > CONFIG_ROOT
/red
/keepconnected
67 if [ -e "CONFIG_ROOT/red/dial-on-demand" ]; then
68 # Don't count time when dial-on-demand is not really connected
69 if ( ! /sbin
/ifconfig |
/bin
/grep -q addr
:10.64.64.64 ); then
75 if ( ! /bin
/ps ax |
/bin
/grep -q [p
]ppd
); then
76 #pppd exit, so don't need to wait MAXCONFIGURE
81 msg
"RED fail to connect"
82 RCREDSTART
=`/bin/ps ax | /bin/grep '[r]c.red start' | /usr/bin/cut -f1 -d ' '`
83 if [ "$RCREDSTART" != '' ]; then
84 /bin
/kill "$RCREDSTART"
86 # this attempt to connect fail, so retry
88 #Don't erase keepconnected because it is used to watch user actions
89 /bin
/touch CONFIG_ROOT
/red
/redial
91 while ( /bin
/ps ax |
/bin
/grep -q [p
]ppd
); do
92 msg
"waiting pppd exit"
96 if [ ! -e "CONFIG_ROOT/red/keepconnected" ]; then
97 # user pressed disconnect in gui
101 msg
"Restarting $ATTEMPTS/$MAXRETRIES"
102 if [ "$ATTEMPTS" -ge "$MAXRETRIES" ]; then
103 echo "0" > CONFIG_ROOT
/red
/keepconnected
104 msg
"Clearing RED interface"
105 /etc
/rc.d
/rc.red
clear
106 if [ "$BACKUPPROFILE" != '' ]; then
107 /bin
/rm -f CONFIG_ROOT
/ppp
/settings
108 /bin
/cp "CONFIG_ROOT/ppp/settings-$BACKUPPROFILE" CONFIG_ROOT
/ppp
/settings
111 echo $ATTEMPTS > CONFIG_ROOT
/red
/keepconnected
113 /etc
/rc.d
/rc.red start
116 while ( /bin
/ps ax |
/bin
/grep -q [p
]ppd
); do
119 if [ "$PROTOCOL" = RFC1483
]; then
120 # remove bridged/routed user-space programs
121 if [ "$TYPE" = eciadsl
]; then
122 /etc
/rc.d
/rc.eciadsl stop
124 if [ "$TYPE" = alcatelusb
]; then
125 /etc
/rc.d
/rc.alcatelusb stop
128 msg
"will connect again"
129 /etc
/rc.d
/rc.red start
132 /bin
/echo "Usage: $0 {start|reconnect}"