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