]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/initscripts/init.d/networking/red
Stop dhcpcd before starting if it was running
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / networking / red
index a575c0e148eec69e3319f9fe3e9f22b71b3f6227..6a85eb48e65d3d6d1e0153816935501749126e70 100644 (file)
 #
 ########################################################################
 
+
+
 . /etc/sysconfig/rc 
 . ${rc_functions}
+
+eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
+if [ "$RRDLOG" == "" ]; then
+       RRDLOG=/var/log/rrd
+fi
+
 eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
 
 TYPE="${RED_TYPE}"
@@ -116,6 +124,35 @@ case "${1}" in
                        run_subdir ${rc_base}/init.d/networking/red.up/
                        
                elif [ "${TYPE}" == "DHCP" ]; then
+
+                       if [ -e $LEASEINFO ]; then
+                               boot_mesg -n "Stopping dhcpcd on the ${DEVICE} interface..."
+                               . $LEASEINFO
+                               if [ "$LEASETIME" = "4294967295" ]; then
+                                       # do nothing, just echo ok
+                                       echo ""
+                                       echo_ok
+                               else
+                                       if [ -n "$DHCP_STOP" ]; then
+                                               /sbin/dhcpcd ${DEVICE} $DHCP_STOP &> /dev/null
+                                               RET="$?"
+                                               if [ "$RET" -eq 0 ]; then
+                                                       echo ""
+                                                       echo_ok
+                                               elif [ "$RET" -eq 1 ]; then
+                                                       boot_mesg "dhcpcd not running!" ${WARNING}
+                                                       echo_warning
+                                               else
+                                                       echo ""
+                                                       echo_failure
+                                               fi
+                                       else
+                                               echo ""
+                                               killproc dhcpcd
+                                       fi
+                               fi
+                       fi
+
                        boot_mesg -n "Starting dhcpcd on the ${DEVICE} interface..."            
                        echo -n "${DEVICE}" > /var/ipfire/red/iface
 
@@ -172,6 +209,7 @@ case "${1}" in
                                echo "$GATEWAY gateway"  >> /tmp/hosts
                                mv /tmp/hosts /etc/hosts
                                echo "$GATEWAY" > /var/ipfire/red/remote-ipaddress
+                               touch /var/ipfire/red/active
                        else
                                echo ""
                                $(exit "$RET")
@@ -191,7 +229,17 @@ case "${1}" in
                        [ -c "/dev/ppp" ] || mknod /dev/ppp c 108 0
                        
                        PPP_NIC=${DEVICE}
-                       
+
+                       if [ "$TYPE" == "vdsl" ]; then
+                               boot_mesg "Createing VLAN Interface ${DEVICE}.7 ..."
+                               modprobe 8021q
+                               vconfig add ${DEVICE} 7
+                               PPP_NIC=${DEVICE}.7
+                               sleep 0.2
+                               ip link set ${PPP_NIC} up
+                               TYPE="pppoe"
+                       fi
+
                        if [ "$TYPE" == "pppoeatm" ] || [ "$TYPE" == "pptpatm" ]; then
                                PPP_NIC=nas0            
                                boot_mesg "Createing ATM-Bridge as $PPP_NIC ..."
@@ -345,7 +393,10 @@ case "${1}" in
                        ## Create & Enable vnstat
                        /usr/bin/vnstat -u -i ppp0 -r --enable --force > /dev/null 2>&1
                        /etc/rc.d/init.d/connectd start
-
+                       # Add a NaN value to ppp0 rrd to supress spikes at reconnect
+                       rrdtool update $RRDLOG/collectd/localhost/interface/if_octets-ppp0.rrd \
+                               $(date +%s):: > /dev/null 2>&1
+                       exit 0
                fi
                ;;
 
@@ -401,9 +452,21 @@ case "${1}" in
                        rm -f /var/ipfire/red/keepconnected
                        killall -w -s TERM /usr/sbin/pppd 2>/dev/null
                        evaluate_retval
+                       # Add a NaN value to ppp0 rrd to supress spikes at reconnect
+                       rrdtool update $RRDLOG/collectd/localhost/interface/if_octets-ppp0.rrd \
+                               $(date +%s):: > /dev/null 2>&1
                fi
 
                if [ "$DEVICE" != "${GREEN_DEV}" ] && [ "$DEVICE" != "" ]; then
+                       link_status=`ip link show $DEVICE.7 2> /dev/null`
+                       if [ -n "${link_status}" ]; then
+                               if echo "${link_status}" | grep -q UP; then
+                                       boot_mesg "Bringing down the ${DEVICE}.7 interface..."
+                                       ip link set ${DEVICE}.7 down
+                                       vconfig del ${DEVICE} 7
+                                       evaluate_retval
+                               fi
+                       fi
                        link_status=`ip link show $DEVICE 2> /dev/null`
                        if [ -n "${link_status}" ]; then
                                if echo "${link_status}" | grep -q UP; then