]>
git.ipfire.org Git - people/teissler/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
/red stop
41 /etc
/rc.d
/init.d
/red
clear
42 /etc
/rc.d
/init.d
/red start
45 # give 5 s more at pppd to be visible with ps ax after 'red start' end
46 if [ "$RCREDSTART" = '' ]; then
52 #watching if an IP is received in $MAXCONFIGURE time to avoid some pppoa waiting forever even after LCP timeout
54 while [ "$COUNT" -le "$MAXCONFIGURE" ]; do
55 if [ ! -e "/var/ipfire/red/keepconnected" ]; then
56 # user pressed disconnect in gui
59 if [ -e "/var/ipfire/red/active" ]; then
60 # connected in time so exit
61 echo "0" > /var
/ipfire
/red
/keepconnected
64 if [ -e "/var/ipfire/red/dial-on-demand" ]; then
65 # Don't count time when dial-on-demand is not really connected
66 if ( ! /sbin
/ifconfig |
/bin
/grep -q addr
:10.64.64.64 ); then
72 if ( ! /bin
/ps ax |
/bin
/grep -q [p
]ppd
); then
73 #pppd exit, so don't need to wait MAXCONFIGURE
78 msg
"RED fail to connect"
79 RCREDSTART
=`/bin/ps ax | /bin/grep 'red start' | /usr/bin/cut -f1 -d ' '`
80 if [ "$RCREDSTART" != '' ]; then
81 /bin
/kill "$RCREDSTART"
83 # this attempt to connect fail, so retry
85 #Don't erase keepconnected because it is used to watch user actions
86 /usr
/bin
/touch /var
/ipfire
/red
/redial
87 /etc
/rc.d
/init.d
/red stop
88 while ( /bin
/ps ax |
/bin
/grep -q [p
]ppd
); do
89 msg
"waiting pppd exit"
93 if [ ! -e "/var/ipfire/red/keepconnected" ]; then
94 # user pressed disconnect in gui
98 msg
"Restarting $ATTEMPTS/$MAXRETRIES"
99 if [ "$ATTEMPTS" -ge "$MAXRETRIES" ]; then
100 echo "0" > /var
/ipfire
/red
/keepconnected
101 msg
"Clearing RED interface"
102 /etc
/rc.d
/init.d
/red
clear
103 if [ "$BACKUPPROFILE" != '' ]; then
104 /bin
/rm -f /var
/ipfire
/ppp
/settings
105 /bin
/cp "/var/ipfire/ppp/settings-$BACKUPPROFILE" /var
/ipfire
/ppp
/settings
108 echo $ATTEMPTS > /var
/ipfire
/red
/keepconnected
110 /etc
/rc.d
/init.d
/red start
113 while ( /bin
/ps ax |
/bin
/grep -q [p
]ppd
); do
116 msg
"will connect again"
117 /etc
/rc.d
/init.d
/red start
120 /bin
/echo "Usage: $0 {start|reconnect}"