]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - src/initscripts/init.d/connectd
Merge branch 'iptables-upnpfw' into core67-merge
[people/teissler/ipfire-2.x.git] / src / initscripts / init.d / connectd
index 0be9eb321681f68edd815f5bbed6e18cf352b2fc..75d51d26005e0ecd182f75d4d5b70130717f38a7 100644 (file)
@@ -4,6 +4,11 @@
 . /etc/sysconfig/rc 
 . ${rc_functions}
 
+# Stop if nothing is configured
+if [ ! -s "/var/ipfire/ppp/settings" ];then
+ exit 0
+fi
+
 eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings)
 
 MAX=160
@@ -13,6 +18,10 @@ if [ ! $HOLDOFF ]; then
        HOLDOFF=30
 fi
 
+if [ "$RECONNECTION" = "dialondemand" ]; then
+       exit 0
+fi
+
 msg_log () {
        logger -t $(basename $0)[$$] $*
 }
@@ -31,25 +40,25 @@ case "$1" in
        boot_mesg "Starting connection daemon..."
        echo_ok
                
-       while [ "$COUNT" -lt "$MAX" ]; do
-               if [ ! -e "/var/ipfire/red/keepconnected" ]; then
-                       # User pressed disconnect in gui
-                       msg_log "Stopping by user request. Exiting."
-                       /etc/rc.d/init.d/network stop red
-                       exit 0
-               fi
-               if [ -e "/var/ipfire/red/active" ]; then
-                       # Successfully connected in time
-                       echo "0" > /var/ipfire/red/keepconnected
-                       msg_log "System is online. Exiting."; exit 0
-               fi
-               if ( ! ps ax | grep -q [p]ppd ); then
-                       msg_log "No pppd is running. Trying reconnect."
-                       break # because pppd died
-               fi
-               sleep 5
-               (( COUNT+=1 ))
-       done
+               while [ "$COUNT" -lt "$MAX" ]; do
+                       if [ ! -e "/var/ipfire/red/keepconnected" ]; then
+                               # User pressed disconnect in gui
+                               msg_log "Stopping by user request. Exiting."
+                               /etc/rc.d/init.d/network stop red
+                               exit 0
+                       fi
+                       if [ -e "/var/ipfire/red/active" ]; then
+                               # Successfully connected in time
+                               echo "0" > /var/ipfire/red/keepconnected
+                               msg_log "System is online. Exiting."; exit 0
+                       fi
+                       if ( ! ps ax | grep -q [p]ppd ); then
+                               msg_log "No pppd is running. Trying reconnect."
+                               break # because pppd died
+                       fi
+                       sleep 5
+                       (( COUNT+=1 ))
+               done
                
                /etc/rc.d/init.d/network stop red
                
@@ -61,6 +70,9 @@ case "$1" in
                                rm -f /var/ipfire/ppp/settings
                                cp "/var/ipfire/ppp/settings-${BACKUPPROFILE}" /var/ipfire/ppp/settings
                                msg_log "Switched to backup profile ${BACKUPPROFILE}"
+                               # to be shure the right secrets are used
+        eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings-${BACKUPPROFILE})
+        echo "'$USERNAME' * '$PASSWORD'" > /var/ipfire/ppp/secrets
                        else
                                msg_log "No backup profile given. Exiting."
                                exit 0
@@ -69,16 +81,16 @@ case "$1" in
                        echo $ATTEMPTS > /var/ipfire/red/keepconnected
                        sleep ${HOLDOFF}
                fi
-               
-               /etc/rc.d/init.d/network start red &
+               /etc/rc.d/init.d/network start red >/dev/tty12 2>&1 </dev/tty12 &
                ;;
                
   reconnect)
                while ( ps ax | grep -q [p]ppd ); do
+                       msg_log "There is a pppd still running. Waiting 2 seconds for exit."
                        sleep 2
                done
                
-               /etc/rc.d/init.d/network restart red &
+               /etc/rc.d/init.d/network restart red
                ;;
                
   *)