Merge commit 'ms/ppp-update'
[ipfire-2.x.git] / src / initscripts / init.d / networking / red
1 #!/bin/sh
2 ########################################################################
3 # Begin
4 #
5 # Description : RED Device Script
6 #
7 # Authors     : Michael Tremer - mitch@ipfire.org
8 #               Maniacikarus - maniacikarus@ipfire.org
9 # Inspired by : Nathan Coulson - nathan@linuxfromscratch.org
10 #               Kevin P. Fleming - kpfleming@linuxfromscratch.org
11 #
12 # Version     : 01.00
13 #
14 # Notes       : 
15 #
16 ########################################################################
17
18 . /etc/sysconfig/rc 
19 . ${rc_functions}
20
21 #Define some defaults
22 RED_VDSL_INET_VLAN=7
23 RED_VDSL_IPTV_VLAN=8
24 RED_VDSL_IPTV_DISABLE=0
25
26 eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
27 if [ "$RRDLOG" == "" ]; then
28         RRDLOG=/var/log/rrd
29 fi
30
31 eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
32 eval $(/usr/local/bin/readhash /var/ipfire/dns/settings)
33 eval $(/usr/local/bin/readhash /var/ipfire/mac/settings)
34
35 MAC=$(tr - : <<<$MAC)
36 MAC1=$(tr - : <<<$MAC1)
37 MAC2=$(tr - : <<<$MAC2)
38
39 TYPE="${RED_TYPE}"
40 DEVICE="${RED_DEV}"
41
42 if [ "$TYPE" == "STATIC" ] || [ "$TYPE" == "DHCP" ]; then
43         if [ "$DEVICE" == "" ]; then
44                 boot_mesg "No device for red network. Please run setup." ${FAILURE}
45                 echo_failure
46                 [ "${1}" == "start" ] && exit 0
47         fi
48 fi
49         
50 if [ "${TYPE}" == "STATIC" ]; then
51         if [ "${DEVICE}" != "${GREEN_DEV}" ]; then
52                 ADDRESS="${RED_ADDRESS}"
53                 BROADCAST="${RED_BROADCAST}"
54                 NETADDRESS="${RED_NETADDRESS}"
55                 NETMASK="${RED_NETMASK}"
56         else
57                 ADDRESS="${GREEN_ADDRESS}"
58                 BROADCAST="${GREEN_BROADCAST}"
59                 NETADDRESS="${GREEN_NETADDRESS}"
60                 NETMASK="${GREEN_NETMASK}"
61         fi
62         GATEWAY="${DEFAULT_GATEWAY}"
63         # DNS1
64         # DNS2
65
66         if [ -z "${BROADCAST}" ]; then
67                 boot_mesg "BROADCAST variable missing, cannot continue." ${FAILURE}
68                 echo_failure
69                 exit 1
70         fi
71         if [ -n "${ADDRESS}" -a -n "${NETMASK}" ]; then
72                 PREFIX=`whatmask ${NETMASK} | grep -e ^CIDR | awk -F': ' '{ print $2 }' | cut -c 2-`
73                 args="${args} ${ADDRESS}/${PREFIX} broadcast ${BROADCAST}"
74         else
75                 boot_mesg "ADDRESS and/or NETMASK variable missing from input, cannot continue." ${FAILURE}
76                 echo_failure
77                 exit 1
78         fi
79 fi
80
81 PIDFILE="/var/run/dhcpcd-${DEVICE}.pid"
82 LEASEINFO="/var/ipfire/dhcpc/dhcpcd-${DEVICE}.info"
83 DHCP_START=" "
84 DHCP_STOP="-k "
85
86 case "${1}" in
87         start)
88                 if [ "${DEVICE}" != "${GREEN_DEV}" ] && [ "${DEVICE}" != "" ]; then
89                         boot_mesg "Bringing up the ${DEVICE} interface..."
90                         boot_mesg_flush
91                         # Check if an interface is there...
92                         if ip link show ${DEVICE} > /dev/null 2>&1; then
93                                 link_status=`ip link show ${DEVICE} 2> /dev/null`
94                                 if [ -n "${link_status}" ]; then
95                                         if ! echo "${link_status}" | grep -q UP; then
96                                                 if [ -n "$MAC" ]; then
97                                                         boot_mesg "Setting mac address on ${DEVICE} to ${MAC}"  
98                                                         ip link set dev ${DEVICE} address ${MAC}
99                                                         evaluate_retval
100                                                 fi
101                                                 ip link set ${DEVICE} up
102                                         fi
103                                 fi
104                         else
105                                 boot_mesg "Interface ${DEVICE} doesn't exist." ${FAILURE}
106                                 echo_failure
107                                 exit 1
108                         fi
109                 fi
110
111                 ## Create & Enable vnstat
112                 /usr/bin/vnstat -u -i ${DEVICE} -r --enable --force > /dev/null 2>&1
113                 
114                 if [ "${TYPE}" == "STATIC" ]; then
115                 
116                         if [ "$DEVICE" != "${GREEN_DEV}" ]; then
117                                 boot_mesg "Adding IPv4 address ${ADDRESS} to the ${DEVICE} interface..."
118                                 ip addr add ${args} dev ${DEVICE}
119                                 evaluate_retval
120                         fi
121                         echo -n "${DEVICE}" > /var/ipfire/red/iface
122                         echo -n "${ADDRESS}"  > /var/ipfire/red/local-ipaddress
123                         echo -n "${GATEWAY}" > /var/ipfire/red/remote-ipaddress
124                         grep -v "gateway" /etc/hosts > /tmp/hosts
125                         echo "$GATEWAY gateway"  >> /tmp/hosts
126                         mv /tmp/hosts /etc/hosts
127                         echo -n "${DNS1}" > /var/ipfire/red/dns1
128                         echo -n "${DNS2}" > /var/ipfire/red/dns2
129                         touch /var/ipfire/red/active
130                         
131                         boot_mesg "Setting up default gateway ${GATEWAY}..."
132                         ip route add default via ${GATEWAY} dev ${DEVICE}
133                         evaluate_retval
134                         
135                         run_subdir ${rc_base}/init.d/networking/red.up/
136
137                         # Configure aliases only if red static
138                         /usr/local/bin/setaliases
139
140                 elif [ "${TYPE}" == "DHCP" ]; then
141
142                         if [ -e $LEASEINFO ]; then
143                                 boot_mesg -n "Stopping dhcpcd on the ${DEVICE} interface..."
144                                 . $LEASEINFO
145                                 if [ "$dhcp_lease_time" = "4294967295" ]; then
146                                         # do nothing, just echo ok
147                                         echo ""
148                                         echo_ok
149                                 else
150                                         if [ -n "$DHCP_STOP" ]; then
151                                                 /sbin/dhcpcd ${DEVICE} $DHCP_STOP &> /dev/null
152                                                 RET="$?"
153                                                 if [ "$RET" -eq 0 ]; then
154                                                         echo ""
155                                                         echo_ok
156                                                 elif [ "$RET" -eq 1 ]; then
157                                                         boot_mesg "dhcpcd not running!" ${WARNING}
158                                                         echo_warning
159                                                 else
160                                                         echo ""
161                                                         echo_failure
162                                                 fi
163                                         else
164                                                 echo ""
165                                                 killproc dhcpcd
166                                         fi
167                                 fi
168                         fi
169
170                         boot_mesg -n "Starting dhcpcd on the ${DEVICE} interface..."
171                         echo -n "${DEVICE}" > /var/ipfire/red/iface
172
173                         ## Create & Enable vnstat
174                         /usr/bin/vnstat -u -i ${DEVICE} -r --enable --force > /dev/null 2>&1
175
176                         # Test to see if there is a stale pid file
177                         if [ -f "$PIDFILE" ]; then
178                                 ps `cat "$PIDFILE"` | grep dhcpcd > /dev/null
179                                 if [ $? != 0 ]; then
180                                         rm -f /var/run/dhcpcd-${DEVICE}.pid > /dev/null
181                                 else
182                                         boot_mesg "dhcpcd already running!" ${WARNING}
183                                         echo_warning
184                                         exit 2
185                                 fi
186                         fi
187                         
188                         iptables -A REDINPUT -p tcp --source-port 67 --destination-port 68 -i ${DEVICE} -j ACCEPT
189                         iptables -A REDINPUT -p udp --source-port 67 --destination-port 68 -i ${DEVICE} -j ACCEPT
190                         
191                         if [ -n "${RED_DHCP_HOSTNAME}" ]; then
192                                 DHCP_START+="-h ${RED_DHCP_HOSTNAME} "
193                 fi
194                 
195                 /sbin/dhcpcd ${DEVICE} ${DHCP_START} >/dev/null 2>&1
196                 RET="$?"
197                 
198                 if [ "$RET" = "0" ]; then
199                                 . /var/ipfire/dhcpc/dhcpcd-${DEVICE}.info
200                                 echo ""
201                                 echo_ok
202                                 boot_mesg "           DHCP Assigned Settings for ${DEVICE}:"
203                                 boot_mesg_flush
204                                 boot_mesg "           IP Address:      $ip_address"
205                                 boot_mesg_flush
206                                 if [ -n "${RED_DHCP_HOSTNAME}" ]; then
207                                         boot_mesg "           Hostname:        $RED_DHCP_HOSTNAME"
208                                         boot_mesg_flush
209                                 fi
210                                 boot_mesg "           Subnet Mask:     $subnet_mask"
211                                 boot_mesg_flush
212                                 boot_mesg "           Default Gateway: $routers"
213                                 boot_mesg_flush
214                                 boot_mesg "           DNS Server:      $domain_name_servers"
215                                 boot_mesg_flush
216                         else
217                                 echo ""
218                                 $(exit "$RET")
219                                 evaluate_retval
220                         fi
221                 
222                 elif [ "$TYPE" == "PPPOE" ]; then
223
224                         if ( ps ax | grep -q [p]ppd ); then 
225                             boot_mesg "pppd is still running." ${FAILURE}
226                             echo_failure
227                             exit 1
228                         fi
229                         
230                         eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings)
231                         
232                         [ -c "/dev/ppp" ] || mknod /dev/ppp c 108 0
233
234                         # We force the plugin method, anyway.
235                         METHOD="PPPOE_PLUGIN"
236
237                         PPP_NIC=${DEVICE}
238
239                         if [ "$TYPE" == "vdsl" ]; then
240                                 boot_mesg "Createing VLAN Interface ${DEVICE}.${RED_VDSL_INET_VLAN} ..."
241                                 modprobe 8021q
242                                 vconfig add ${DEVICE} ${RED_VDSL_INET_VLAN}
243                                 if [ -n "$MAC1" ]; then
244                                         boot_mesg "Setting mac address on ${DEVICE}.${RED_VDSL_INET_VLAN} to ${MAC1}"   
245                                         ip link set dev ${DEVICE}.${RED_VDSL_INET_VLAN} address ${MAC1}
246                                         evaluate_retval
247                                 fi
248                                 PPP_NIC=${DEVICE}.${RED_VDSL_INET_VLAN}
249                                 sleep 0.2
250                                 ip link set ${PPP_NIC} up
251                                 TYPE="pppoe"
252                                 if [ "${RED_VDSL_IPTV_DISABLE}" == "0" ]; then
253                                         PIDFILE="/var/run/dhcpcd-${DEVICE}.${RED_VDSL_IPTV_VLAN}.pid"
254                                         LEASEINFO="/var/ipfire/dhcpc/dhcpcd-${DEVICE}.${RED_VDSL_IPTV_VLAN}.info"
255                                         # Test to see if there is a stale pid file
256                                         if [ -f "$PIDFILE" ]; then
257                                                 ps `cat "$PIDFILE"` | grep dhcpcd > /dev/null
258                                                 if [ $? != 0 ]; then
259                                                         rm -f /var/run/dhcpcd-${DEVICE}.${RED_VDSL_IPTV_VLAN}.pid > /dev/null
260                                                 fi
261                                         fi
262
263                                         if [ ! -f "$PIDFILE" ]; then
264                                                 boot_mesg "Createing VLAN Interface ${DEVICE}.${RED_VDSL_IPTV_VLAN} ..."
265                                                 vconfig add ${DEVICE} ${RED_VDSL_IPTV_VLAN}
266                                                 if [ -n "$MAC2" ]; then
267                                                         boot_mesg "Setting mac address on ${DEVICE}.${RED_VDSL_IPTV_VLAN} to ${MAC2}"   
268                                                         ip link set dev ${DEVICE}.${RED_VDSL_IPTV_VLAN} address ${MAC2}
269                                                         evaluate_retval
270                                                 fi
271                                                 boot_mesg -n "Starting dhcpcd on the ${DEVICE}.${RED_VDSL_IPTV_VLAN} interface..."
272                                                 /sbin/dhcpcd ${DEVICE}.${RED_VDSL_IPTV_VLAN} ${DHCP_START} >/dev/null 2>&1
273                                                 RET="$?"
274
275                                                 if [ "$RET" = "0" ]; then
276                                                         . /var/ipfire/dhcpc/dhcpcd-${DEVICE}.${RED_VDSL_IPTV_VLAN}.info
277                                                         echo ""
278                                                         echo_ok
279                                                         boot_mesg "           DHCP Assigned Settings for ${DEVICE}.${RED_VDSL_IPTV_VLAN}:"
280                                                         boot_mesg_flush
281                                                         boot_mesg "           IP Address:      $ip_address"
282                                                         boot_mesg_flush
283                                                         boot_mesg "           Hostname:        $RED_DHCP_HOSTNAME"
284                                                         boot_mesg_flush
285                                                         boot_mesg "           Subnet Mask:     $subnet_mask"
286                                                         boot_mesg_flush
287                                                         boot_mesg "           Default Gateway: $routers"
288                                                         boot_mesg_flush
289                                                         boot_mesg "           DNS Server:      $domain_name_servers"
290                                                         boot_mesg_flush
291
292                                                 else
293                                                         echo ""
294                                                         $(exit "$RET")
295                                                         evaluate_retval
296                                                 fi
297                                         fi
298                                 fi
299                         fi
300
301                         if [ "$TYPE" == "pppoeatm" ] || [ "$TYPE" == "pptpatm" ]; then
302                                 PPP_NIC=nas0            
303                                 boot_mesg "Createing ATM-Bridge as $PPP_NIC ..."
304                                 br2684ctl -c0 -e${ENCAP} -a0.${VPI}.${VCI} >/dev/null 2>&1 &
305                                 sleep 1
306                                 if [ "$TYPE" == "pppoeatm" ]; then
307                                         TYPE="pppoe"
308                                 fi
309                                 if [ "$TYPE" == "pptpatm" ]; then
310                                         TYPE="pptp"
311                                 fi
312                         fi
313                         if [ "$TYPE" == "pppoe" ] || [ "$TYPE" == "pptp" ]; then
314                                 if [ "$PPP_NIC" == "" ]; then
315                                         boot_mesg "No device for red interface given. Check netsetup or dialprofile!" ${FAILURE}
316                                         echo_failure
317                                         exit 0
318                                 fi
319                                 boot_mesg "Bringing up the $TYPE interface on $PPP_NIC ..."
320                                 ip addr flush dev $PPP_NIC >/dev/null 2>&1
321                                 if [ "$TYPE" == "pptp" ]; then
322                                         if [ "$PPTP_NICCFG" == "dhcp" ]; then
323                                                 # Test to see if there is a stale pid file
324                                                 if [ -f "$PIDFILE" ]; then
325                                                         ps `cat "$PIDFILE"` | grep dhcpcd > /dev/null
326                                                         if [ $? != 0 ]; then
327                                                                 rm -f /var/run/dhcpcd-${DEVICE}.pid > /dev/null
328                                                         fi
329                                                 fi
330
331                                                 if [ ! -f "$PIDFILE" ]; then
332                                                         boot_mesg -n "Starting dhcpcd on the ${DEVICE} interface..."
333                                                         /sbin/dhcpcd ${DEVICE} ${DHCP_START} >/dev/null 2>&1
334                                                         RET="$?"
335
336                                                         if [ "$RET" = "0" ]; then
337                                                                 . /var/ipfire/dhcpc/dhcpcd-${DEVICE}.info
338                                                                 echo ""
339                                                                 echo_ok
340                                                                 boot_mesg "           DHCP Assigned Settings for ${DEVICE}:"
341                                                                 boot_mesg_flush
342                                                                 boot_mesg "           IP Address:      $ip_address"
343                                                                 boot_mesg_flush
344                                                                 boot_mesg "           Hostname:        $RED_DHCP_HOSTNAME"
345                                                                 boot_mesg_flush
346                                                                 boot_mesg "           Subnet Mask:     $subnet_mask"
347                                                                 boot_mesg_flush
348                                                                 boot_mesg "           Default Gateway: $routers"
349                                                                 boot_mesg_flush
350                                                                 boot_mesg "           DNS Server:      $domain_name_servers"
351                                                                 boot_mesg_flush
352                                                                 /sbin/route add $PPTP_PEER gw $routers $PPP_NIC
353                                                         else
354                                                                 echo ""
355                                                                 $(exit "$RET")
356                                                                 evaluate_retval
357                                                         fi
358                                                 fi
359                                         else
360                                                 ip addr add $PPTP_NICCFG dev $PPP_NIC
361                                         fi
362                                 fi
363                                 ip link set ${PPP_NIC} up
364                         else
365                                 boot_mesg "Bringing up the PPP via ${TYPE} on ${COMPORT}..."
366                         fi
367                         
368                         ###                      ###
369                         ### Configuring the pppd ###
370                         ###                      ###
371                         
372                         ### Plugin Options
373                         #                       
374                         if [ "$TYPE" == "pppoe" ]; then
375                                 [ "${METHOD}" == "PPPOE_PLUGIN" ] && \
376                                         PLUGOPTS="plugin /usr/lib/pppd/2.4.4/rp-pppoe.so"
377                         fi
378
379                         ### Synchronous Mode
380                         #
381                         #PPPOE_SYNC=-s
382                         #PPPD_SYNC=sync
383         
384                         ### Access Concentrator Name
385                         #
386                         if [ -n "${CONCENTRATORNAME}" ]; then
387                                 ACNAME="-C ${CONCENTRATORNAME}"
388                         fi
389
390                         ### Service Name
391                         #
392                         if [ -n "${SERVICENAME}" ]; then
393                                 if [ "${METHOD}" == "PPPOE_PLUGIN" ]; then
394                                         PLUGOPTS+=" rp_pppoe_service ${SERVICENAME}"
395                                 else
396                                         SERVICENAME="-S ${SERVICENAME}"
397                                 fi
398                         fi
399
400                         ### Authentication Types
401                         #
402                         if [ "${AUTH}" == "pap" ]; then
403                                 AUTH="-chap"
404                         elif [ "${AUTH}" == "chap" ]; then
405                                 AUTH="-pap"
406                         else
407                                 AUTH=""
408                         fi
409
410                         ### DNS Config
411                         #
412                         if [ "${DNS}" == "Automatic" ]; then
413                                 DNS="usepeerdns"
414                         else
415                                 DNS=""
416                                 echo nameserver=$DNS1 > /etc/ppp/resolv.conf
417                                 echo nameserver=$DNS2 >> /etc/ppp/resolv.conf
418                         fi
419
420                         ### Dial On Demand              
421                         #
422                         if [ "${RECONNECTION}" != "persistent" ]; then
423                                 if [ "${TIMEOUT}" != "0" ] && [ "${TIMEOUT}" != "" ]; then
424                                         SECONDS=$[${TIMEOUT} * 60]
425                                 else
426                                         SECONDS=300
427                                 fi
428                                 if [ "${RECONNECTION}" == "dialondemand" ]; then
429                                         touch /var/ipfire/red/dial-on-demand
430                                         DEMAND="demand persist idle ${SECONDS} 10.112.112.112:10.112.112.113"
431                                         DEMAND+=" ipcp-accept-remote ipcp-accept-local noipdefault ktune"
432                                 fi
433                         fi
434                         
435                         if [ "$TYPE" == "pppoe" ]; then
436                                 ### When using pppoe-plugin the device has to be the last option
437                                 #
438                                 [ "${METHOD}" == "PPPOE_PLUGIN" ] && PLUGOPTS+=" $PPP_NIC"
439                         fi
440                         
441                         if [ "$TYPE" == "modem" ]; then
442                                 PLUGOPTS=" /dev/${COMPORT} ${DTERATE} connect /etc/ppp/dialer lock modem crtscts"
443                                 METHOD="PPPOE_PLUGIN"
444                         elif [ "$TYPE" == "serial" ]; then
445                                 PLUGOPTS=" /dev/${COMPORT} ${DTERATE} connect /bin/true lock modem crtscts"
446                                 METHOD="PPPOE_PLUGIN"
447                         fi
448                 
449                         ### Standard PPP options we always use
450                         #
451                         PPP_STD_OPTIONS="$PLUGOPTS $DNS defaultroute noipdefault noauth"
452                         PPP_STD_OPTIONS+=" default-asyncmap hide-password nodetach mtu ${MTU}"
453                         PPP_STD_OPTIONS+=" mru ${MTU} noaccomp nodeflate nopcomp novj novjccomp"
454                         PPP_STD_OPTIONS+=" nobsdcomp user ${USERNAME} lcp-echo-interval 20"
455                         PPP_STD_OPTIONS+=" lcp-echo-failure 3 ${AUTH}"
456                                 
457                         ### Debugging
458                         #
459                         if [ "${DEBUG}" == "on" ]; then
460                                 DEBUG="debug"
461                         else
462                                 DEBUG=""
463                         fi
464                         
465                         ### PPPoE invocation
466                         #
467                         if [ "$TYPE" == "pppoe" ]; then
468                                 PPPOE_CMD="/usr/sbin/pppoe -p /var/run/ppp-ipfire.pid.pppoe -I $PPP_NIC"
469                                 PPPOE_CMD+=" -T 80 -U $PPPOE_SYNC $ACNAME $SERVICENAMEOPT"
470                         fi
471
472                         ### PPTP ###
473                         #
474                         if [ "$TYPE" == "pptp" ]; then
475                                 PPPOE_CMD="pptp $PPTP_PEER --nolaunchpppd"
476                                 METHOD=""
477                         fi
478                         
479                         ### Run everything
480                         #
481                         if [ "$METHOD" == "PPPOE_PLUGIN" ]; then
482                                 /usr/sbin/pppd $PPP_STD_OPTIONS $DEBUG $DEMAND >/dev/null 2>&1 &
483                                 evaluate_retval
484                                 # echo PLUGIN: /usr/sbin/pppd $PPP_STD_OPTIONS $DEBUG $DEMAND
485                         else
486                                 /usr/sbin/pppd pty "$PPPOE_CMD" $PPP_STD_OPTIONS $DEBUG $DEMAND $PPPD_SYNC >/dev/null 2>&1 &
487                                 evaluate_retval
488                                 # echo PPP: /usr/sbin/pppd pty "$PPPOE_CMD" $PPP_STD_OPTIONS $DEBUG $DEMAND $PPPD_SYNC
489                         fi
490                         ## Create & Enable vnstat
491                         /usr/bin/vnstat -u -i ppp0 -r --enable --force > /dev/null 2>&1
492                         /etc/rc.d/init.d/connectd start
493                         # Add a NaN value to ppp0 rrd to supress spikes at reconnect
494                         rrdtool update $RRDLOG/collectd/localhost/interface/if_octets-ppp0.rrd \
495                                 $(date +%s):: > /dev/null 2>&1
496                         exit 0
497                 fi
498                 ;;
499
500         stop)
501                 if [ "$TYPE" == "STATIC" ]; then
502                         boot_mesg "Stopping default gateway ${GATEWAY}..."
503                         ip route del default via ${GATEWAY} >/dev/null 2>&1
504                         echo_ok
505                         if [ "$DEVICE" != "${GREEN_DEV}" ]; then
506                                 boot_mesg "Removing IPv4 addresses from the ${DEVICE} interface..."
507                                 ip addr flush dev ${DEVICE}
508                                 evaluate_retval
509                         fi
510                         run_subdir ${rc_base}/init.d/networking/red.down/
511
512                 elif [ "$TYPE" == "PPPOE" ]; then
513                         boot_mesg "Bringing down the PPP interface ..."
514                         ## Disable vnstat collection
515                         /usr/bin/vnstat -u -i ppp0 -r --disable > /dev/null 2>&1
516                         rm -f /var/ipfire/red/keepconnected
517                         killall -w -s TERM /usr/sbin/pppd 2>/dev/null
518                         evaluate_retval
519                         # Add a NaN value to ppp0 rrd to supress spikes at reconnect
520                         rrdtool update $RRDLOG/collectd/localhost/interface/if_octets-ppp0.rrd \
521                                 $(date +%s):: > /dev/null 2>&1
522                 fi
523
524                 if [ -e $LEASEINFO ]; then
525                         boot_mesg -n "Stopping dhcpcd on the ${DEVICE} interface..."
526                         . $LEASEINFO
527                         if [ "$dchp_lease_time" = "4294967295" ]; then
528                                 # do nothing, just echo ok
529                                 echo ""
530                                 echo_ok
531                         else
532                                 if [ -n "$DHCP_STOP" ]; then
533                                         /sbin/dhcpcd ${DEVICE} $DHCP_STOP &> /dev/null
534                                         RET="$?"
535                                         if [ "$RET" -eq 0 ]; then
536                                                 echo ""
537                                                 echo_ok
538                                         elif [ "$RET" -eq 1 ]; then
539                                                 boot_mesg "dhcpcd not running!" ${WARNING}
540                                                 echo_warning
541                                         else
542                                                 echo ""
543                                                 echo_failure
544                                         fi
545                                 else
546                                         echo ""
547                                         killproc dhcpcd
548                                 fi
549                         fi
550                 fi
551
552                 if [ "$DEVICE" != "${GREEN_DEV}" ] && [ "$DEVICE" != "" ]; then
553                         link_status=`ip link show $DEVICE.${RED_VDSL_INET_VLAN} 2> /dev/null`
554                         if [ -n "${link_status}" ]; then
555                                 if echo "${link_status}" | grep -q UP; then
556                                         boot_mesg "Bringing down the ${DEVICE}.${RED_VDSL_INET_VLAN} interface..."
557                                         ip link set ${DEVICE}.${RED_VDSL_INET_VLAN} down
558                                         vconfig rem ${DEVICE}.${RED_VDSL_INET_VLAN}
559                                         evaluate_retval
560                                 fi
561                         else
562                                 link_status=`ip link show $DEVICE 2> /dev/null`
563                                 if [ -n "${link_status}" ]; then
564                                         if echo "${link_status}" | grep -q UP; then
565                                                 boot_mesg "Bringing down the ${DEVICE} interface..."
566                                                 ip link set ${DEVICE} down
567                                                 evaluate_retval
568                                         fi
569                                 fi
570                         fi
571                 fi
572                 killall -w -s KILL /usr/sbin/pppd >/dev/null 2>&1
573                 killall -w -s KILL pptp >/dev/null 2>&1
574                 killall -w -s KILL br2684ctl >/dev/null 2>&1
575
576                 ## Disable vnstat collection
577                 /usr/bin/vnstat -u -i ${DEVICE} -r --disable > /dev/null 2>&1
578
579                 rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
580                 exit 0;
581                 ;;
582 esac
583
584 # End