Add wireless client for RED to startup process.
[ipfire-2.x.git] / src / initscripts / init.d / networking / red
CommitLineData
d1e90efc
MT
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}
71ea0d68 20. /etc/init.d/networking/functions.network
1f2ff0fa 21
ff07f865 22#Define some defaults
ff7a3950
AF
23INET_VLAN=7
24IPTV_VLAN=8
ff07f865 25
1f2ff0fa
AF
26eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
27if [ "$RRDLOG" == "" ]; then
28 RRDLOG=/var/log/rrd
29fi
30
d1e90efc 31eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
c3190a33 32eval $(/usr/local/bin/readhash /var/ipfire/dns/settings)
b8c750f3
JPT
33eval $(/usr/local/bin/readhash /var/ipfire/mac/settings)
34
35MAC=$(tr - : <<<$MAC)
1bffb899 36MAC1=$(tr - : <<<$MAC1)
d66c870e 37MAC2=$(tr - : <<<$MAC2)
d1e90efc
MT
38
39TYPE="${RED_TYPE}"
40DEVICE="${RED_DEV}"
41
0dde24fa
MT
42if [ "$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
48fi
49
50if [ "${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
d1e90efc 62 GATEWAY="${DEFAULT_GATEWAY}"
0db33b56
MT
63 # DNS1
64 # DNS2
d1e90efc
MT
65
66 if [ -z "${BROADCAST}" ]; then
0dde24fa 67 boot_mesg "BROADCAST variable missing, cannot continue." ${FAILURE}
d1e90efc
MT
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
d1e90efc
MT
79fi
80
81case "${1}" in
82 start)
0dde24fa
MT
83 if [ "${DEVICE}" != "${GREEN_DEV}" ] && [ "${DEVICE}" != "" ]; then
84 boot_mesg "Bringing up the ${DEVICE} interface..."
85 boot_mesg_flush
86 # Check if an interface is there...
87 if ip link show ${DEVICE} > /dev/null 2>&1; then
88 link_status=`ip link show ${DEVICE} 2> /dev/null`
89 if [ -n "${link_status}" ]; then
90 if ! echo "${link_status}" | grep -q UP; then
b8c750f3
JPT
91 if [ -n "$MAC" ]; then
92 boot_mesg "Setting mac address on ${DEVICE} to ${MAC}"
93 ip link set dev ${DEVICE} address ${MAC}
d66c870e 94 evaluate_retval
b8c750f3 95 fi
0dde24fa
MT
96 ip link set ${DEVICE} up
97 fi
d1e90efc 98 fi
0dde24fa
MT
99 else
100 boot_mesg "Interface ${DEVICE} doesn't exist." ${FAILURE}
101 echo_failure
102 exit 1
d1e90efc 103 fi
d1e90efc 104 fi
6c33dc5c 105
1e4656cd
AF
106 ## Create & Enable vnstat
107 /usr/bin/vnstat -u -i ${DEVICE} -r --enable --force > /dev/null 2>&1
d1e90efc
MT
108
109 if [ "${TYPE}" == "STATIC" ]; then
0dde24fa
MT
110
111 if [ "$DEVICE" != "${GREEN_DEV}" ]; then
112 boot_mesg "Adding IPv4 address ${ADDRESS} to the ${DEVICE} interface..."
113 ip addr add ${args} dev ${DEVICE}
114 evaluate_retval
115 fi
0db33b56
MT
116 echo -n "${DEVICE}" > /var/ipfire/red/iface
117 echo -n "${ADDRESS}" > /var/ipfire/red/local-ipaddress
118 echo -n "${GATEWAY}" > /var/ipfire/red/remote-ipaddress
3d9d5884
AF
119 grep -v -E "\<gateway\>" /etc/hosts > /tmp/hosts
120 echo "$GATEWAY gateway" >> /tmp/hosts
b2f872eb 121 mv /tmp/hosts /etc/hosts
0db33b56
MT
122 echo -n "${DNS1}" > /var/ipfire/red/dns1
123 echo -n "${DNS2}" > /var/ipfire/red/dns2
bcdde652 124 touch /var/ipfire/red/active
d1e90efc 125
040e5040
MT
126 boot_mesg "Setting up default gateway ${GATEWAY}..."
127 ip route add default via ${GATEWAY} dev ${DEVICE}
128 evaluate_retval
129
0e42072a 130 run_subdir ${rc_base}/init.d/networking/red.up/
bbe6aff7
AF
131
132 # Configure aliases only if red static
133 /usr/local/bin/setaliases
134
d1e90efc 135 elif [ "${TYPE}" == "DHCP" ]; then
71ea0d68
SS
136 # Add firewall rules to allow comunication with the dhcp server on red.
137 iptables -A REDINPUT -p tcp --source-port 67 --destination-port 68 -i ${DEVICE} -j ACCEPT
138 iptables -A REDINPUT -p udp --source-port 67 --destination-port 68 -i ${DEVICE} -j ACCEPT
7e0cd11d 139
d1e90efc
MT
140 echo -n "${DEVICE}" > /var/ipfire/red/iface
141
71ea0d68
SS
142 # Check if the wlan-client is used on red.
143 # To determine this we check if a wpa_supplicant is running.
144 pid="$(pidof wpa_supplicant)"
145
146 if [ -z "${pid}" ]; then
147 # No wpa_supplicant is running. So it's save to start dhcpcd.
148 dhcpcd_start "${DEVICE}"
149 fi
150
941e123e
AF
151 ## Create & Enable vnstat
152 /usr/bin/vnstat -u -i ${DEVICE} -r --enable --force > /dev/null 2>&1
153
d1e90efc 154 elif [ "$TYPE" == "PPPOE" ]; then
06b912c5 155
a89770fa 156 if ( ps ax | grep -q [p]ppd ); then
0dde24fa
MT
157 boot_mesg "pppd is still running." ${FAILURE}
158 echo_failure
159 exit 1
a89770fa 160 fi
0dde24fa 161
d1e90efc
MT
162 eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings)
163
905fbf3e 164 [ -c "/dev/ppp" ] || mknod /dev/ppp c 108 0
06b912c5
MT
165
166 # We force the plugin method, anyway.
167 METHOD="PPPOE_PLUGIN"
168
a89770fa 169 PPP_NIC=${DEVICE}
40049855 170
d0c3a0c5
AF
171
172 if [ "$TYPE" == "pppoeatm" ] || [ "$TYPE" == "pptpatm" ]; then
173 PPP_NIC=nas0
174 DEVICE=nas0
175 boot_mesg "Createing ATM-Bridge as $PPP_NIC ..."
176 br2684ctl -c0 -e${ENCAP} -a0.${VPI}.${VCI} >/dev/null 2>&1 &
177 sleep 1
178 if [ "$TYPE" == "pppoeatm" ]; then
179 TYPE="pppoe"
180 fi
181 if [ "$TYPE" == "pptpatm" ]; then
182 TYPE="pptp"
183 fi
184 fi
185
40049855 186 if [ "$TYPE" == "vdsl" ]; then
ff7a3950 187 boot_mesg "Createing VLAN Interface ${DEVICE}.${INET_VLAN} ..."
40049855 188 modprobe 8021q
ff7a3950 189 vconfig add ${DEVICE} ${INET_VLAN}
1bffb899 190 if [ -n "$MAC1" ]; then
ff7a3950
AF
191 boot_mesg "Setting mac address on ${DEVICE}.${INET_VLAN} to ${MAC1}"
192 ip link set dev ${DEVICE}.${INET_VLAN} address ${MAC1}
1bffb899
AF
193 evaluate_retval
194 fi
ff7a3950 195 PPP_NIC=${DEVICE}.${INET_VLAN}
40049855
AF
196 sleep 0.2
197 ip link set ${PPP_NIC} up
198 TYPE="pppoe"
d0c3a0c5
AF
199 fi
200 if [ "${IPTV}" == "enable" ]; then
ff7a3950
AF
201 PIDFILE="/var/run/dhcpcd-${DEVICE}.${IPTV_VLAN}.pid"
202 LEASEINFO="/var/ipfire/dhcpc/dhcpcd-${DEVICE}.${IPTV_VLAN}.info"
d0c3a0c5
AF
203 # Test to see if there is a stale pid file
204 if [ -f "$PIDFILE" ]; then
205 ps `cat "$PIDFILE"` | grep dhcpcd > /dev/null
206 if [ $? != 0 ]; then
ff7a3950 207 rm -f /var/run/dhcpcd-${DEVICE}.${IPTV_VLAN}.pid > /dev/null
bbe6aff7 208 fi
d0c3a0c5 209 fi
bbe6aff7 210
d0c3a0c5 211 if [ ! -f "$PIDFILE" ]; then
ff7a3950 212 boot_mesg "Createing VLAN Interface ${DEVICE}.${IPTV_VLAN} ..."
d0c3a0c5 213 modprobe 8021q
ff7a3950 214 vconfig add ${DEVICE} ${IPTV_VLAN}
d0c3a0c5 215 if [ -n "$MAC2" ]; then
ff7a3950
AF
216 boot_mesg "Setting mac address on ${DEVICE}.${IPTV_VLAN} to ${MAC2}"
217 ip link set dev ${DEVICE}.${IPTV_VLAN} address ${MAC2}
d0c3a0c5
AF
218 evaluate_retval
219 fi
ff7a3950
AF
220 boot_mesg -n "Starting dhcpcd on the ${DEVICE}.${IPTV_VLAN} interface..."
221 /sbin/dhcpcd ${DEVICE}.${IPTV_VLAN} ${DHCP_START} >/dev/null 2>&1
d0c3a0c5 222 RET="$?"
bbe6aff7 223
d0c3a0c5 224 if [ "$RET" = "0" ]; then
ff7a3950 225 . /var/ipfire/dhcpc/dhcpcd-${DEVICE}.${IPTV_VLAN}.info
d0c3a0c5
AF
226 echo ""
227 echo_ok
ff7a3950 228 boot_mesg " DHCP Assigned Settings for ${DEVICE}.${IPTV_VLAN}:"
d0c3a0c5
AF
229 boot_mesg_flush
230 boot_mesg " IP Address: $ip_address"
231 boot_mesg_flush
232 boot_mesg " Hostname: $RED_DHCP_HOSTNAME"
233 boot_mesg_flush
234 boot_mesg " Subnet Mask: $subnet_mask"
235 boot_mesg_flush
236 boot_mesg " Default Gateway: $routers"
237 boot_mesg_flush
238 boot_mesg " DNS Server: $domain_name_servers"
239 boot_mesg_flush
bbe6aff7 240
d0c3a0c5
AF
241 else
242 echo ""
243 $(exit "$RET")
244 evaluate_retval
bbe6aff7
AF
245 fi
246 fi
40049855 247 fi
5aae218d 248 if [ "$TYPE" == "pppoe" ] || [ "$TYPE" == "pptp" ]; then
4cd4876a 249 if [ "$PPP_NIC" == "" ]; then
0dde24fa
MT
250 boot_mesg "No device for red interface given. Check netsetup or dialprofile!" ${FAILURE}
251 echo_failure
cb1fb691 252 exit 0
0dde24fa 253 fi
5aae218d 254 boot_mesg "Bringing up the $TYPE interface on $PPP_NIC ..."
58e9b9dc 255 ip addr flush dev $PPP_NIC >/dev/null 2>&1
5aae218d 256 if [ "$TYPE" == "pptp" ]; then
fd850b7e 257 if [ "$PPTP_NICCFG" == "dhcp" ]; then
fd850b7e
AF
258 # Test to see if there is a stale pid file
259 if [ -f "$PIDFILE" ]; then
260 ps `cat "$PIDFILE"` | grep dhcpcd > /dev/null
261 if [ $? != 0 ]; then
367a7770 262 rm -f /var/run/dhcpcd-${DEVICE}.pid > /dev/null
fd850b7e
AF
263 fi
264 fi
265
266 if [ ! -f "$PIDFILE" ]; then
d9563c55 267 boot_mesg -n "Starting dhcpcd on the ${DEVICE} interface..."
367a7770 268 /sbin/dhcpcd ${DEVICE} ${DHCP_START} >/dev/null 2>&1
fd850b7e
AF
269 RET="$?"
270
271 if [ "$RET" = "0" ]; then
272 . /var/ipfire/dhcpc/dhcpcd-${DEVICE}.info
273 echo ""
274 echo_ok
275 boot_mesg " DHCP Assigned Settings for ${DEVICE}:"
276 boot_mesg_flush
7f8e589b 277 boot_mesg " IP Address: $ip_address"
fd850b7e
AF
278 boot_mesg_flush
279 boot_mesg " Hostname: $RED_DHCP_HOSTNAME"
280 boot_mesg_flush
7f8e589b 281 boot_mesg " Subnet Mask: $subnet_mask"
fd850b7e 282 boot_mesg_flush
7f8e589b 283 boot_mesg " Default Gateway: $routers"
fd850b7e 284 boot_mesg_flush
7f8e589b 285 boot_mesg " DNS Server: $domain_name_servers"
fd850b7e 286 boot_mesg_flush
7f8e589b 287 /sbin/route add $PPTP_PEER gw $routers $PPP_NIC
fd850b7e
AF
288 else
289 echo ""
290 $(exit "$RET")
291 evaluate_retval
292 fi
293 fi
294 else
295 ip addr add $PPTP_NICCFG dev $PPP_NIC
296 fi
5aae218d 297 fi
58e9b9dc 298 ip link set ${PPP_NIC} up
164a3b51
AF
299 if [ -n "${PPTP_ROUTE}" ]; then
300 boot_mesg "Set route ${PPTP_ROUTE} to pptp server..."
301 route add ${PPTP_ROUTE}
302 fi
27b8cc24
MT
303 else
304 boot_mesg "Bringing up the PPP via ${TYPE} on ${COMPORT}..."
305 fi
0dde24fa 306
905fbf3e
MT
307 ### ###
308 ### Configuring the pppd ###
309 ### ###
310
311 ### Plugin Options
312 #
5aae218d
AF
313 if [ "$TYPE" == "pppoe" ]; then
314 [ "${METHOD}" == "PPPOE_PLUGIN" ] && \
d94eba78 315 PLUGOPTS="plugin rp-pppoe.so"
5aae218d 316 fi
d1e90efc 317
905fbf3e
MT
318 ### Synchronous Mode
319 #
320 #PPPOE_SYNC=-s
a89770fa
MT
321 #PPPD_SYNC=sync
322
323 ### Access Concentrator Name
324 #
905fbf3e
MT
325 if [ -n "${CONCENTRATORNAME}" ]; then
326 ACNAME="-C ${CONCENTRATORNAME}"
d1e90efc 327 fi
905fbf3e
MT
328
329 ### Service Name
330 #
331 if [ -n "${SERVICENAME}" ]; then
332 if [ "${METHOD}" == "PPPOE_PLUGIN" ]; then
333 PLUGOPTS+=" rp_pppoe_service ${SERVICENAME}"
334 else
335 SERVICENAME="-S ${SERVICENAME}"
336 fi
d1e90efc 337 fi
a89770fa 338
905fbf3e
MT
339 ### Authentication Types
340 #
d1e90efc 341 if [ "${AUTH}" == "pap" ]; then
905fbf3e 342 AUTH="-chap"
d1e90efc 343 elif [ "${AUTH}" == "chap" ]; then
905fbf3e 344 AUTH="-pap"
57cb9775
CS
345 else
346 AUTH=""
d1e90efc 347 fi
a89770fa
MT
348
349 ### DNS Config
350 #
351 if [ "${DNS}" == "Automatic" ]; then
352 DNS="usepeerdns"
353 else
354 DNS=""
355 echo nameserver=$DNS1 > /etc/ppp/resolv.conf
356 echo nameserver=$DNS2 >> /etc/ppp/resolv.conf
a89770fa
MT
357 fi
358
905fbf3e
MT
359 ### Dial On Demand
360 #
d1e90efc
MT
361 if [ "${RECONNECTION}" != "persistent" ]; then
362 if [ "${TIMEOUT}" != "0" ] && [ "${TIMEOUT}" != "" ]; then
363 SECONDS=$[${TIMEOUT} * 60]
905fbf3e
MT
364 else
365 SECONDS=300
d1e90efc
MT
366 fi
367 if [ "${RECONNECTION}" == "dialondemand" ]; then
368 touch /var/ipfire/red/dial-on-demand
905fbf3e 369 DEMAND="demand persist idle ${SECONDS} 10.112.112.112:10.112.112.113"
a89770fa 370 DEMAND+=" ipcp-accept-remote ipcp-accept-local noipdefault ktune"
d1e90efc 371 fi
905fbf3e
MT
372 fi
373
5aae218d
AF
374 if [ "$TYPE" == "pppoe" ]; then
375 ### When using pppoe-plugin the device has to be the last option
376 #
377 [ "${METHOD}" == "PPPOE_PLUGIN" ] && PLUGOPTS+=" $PPP_NIC"
378 fi
27b8cc24
MT
379
380 if [ "$TYPE" == "modem" ]; then
a89770fa 381 PLUGOPTS=" /dev/${COMPORT} ${DTERATE} connect /etc/ppp/dialer lock modem crtscts"
7c653e4b 382 METHOD="PPPOE_PLUGIN"
27b8cc24 383 elif [ "$TYPE" == "serial" ]; then
a89770fa 384 PLUGOPTS=" /dev/${COMPORT} ${DTERATE} connect /bin/true lock modem crtscts"
7c653e4b 385 METHOD="PPPOE_PLUGIN"
27b8cc24 386 fi
905fbf3e
MT
387
388 ### Standard PPP options we always use
389 #
a89770fa 390 PPP_STD_OPTIONS="$PLUGOPTS $DNS defaultroute noipdefault noauth"
905fbf3e 391 PPP_STD_OPTIONS+=" default-asyncmap hide-password nodetach mtu ${MTU}"
96adb1c9 392 PPP_STD_OPTIONS+=" mru ${MRU} noaccomp nodeflate nopcomp novj novjccomp"
905fbf3e 393 PPP_STD_OPTIONS+=" nobsdcomp user ${USERNAME} lcp-echo-interval 20"
fb27520e 394 PPP_STD_OPTIONS+=" lcp-echo-failure 5 ${AUTH}"
a89770fa 395
905fbf3e
MT
396 ### Debugging
397 #
398 if [ "${DEBUG}" == "on" ]; then
399 DEBUG="debug"
d1e90efc 400 else
905fbf3e 401 DEBUG=""
d1e90efc
MT
402 fi
403
905fbf3e
MT
404 ### PPPoE invocation
405 #
a89770fa
MT
406 if [ "$TYPE" == "pppoe" ]; then
407 PPPOE_CMD="/usr/sbin/pppoe -p /var/run/ppp-ipfire.pid.pppoe -I $PPP_NIC"
27b8cc24
MT
408 PPPOE_CMD+=" -T 80 -U $PPPOE_SYNC $ACNAME $SERVICENAMEOPT"
409 fi
5aae218d
AF
410
411 ### PPTP ###
412 #
413 if [ "$TYPE" == "pptp" ]; then
414 PPPOE_CMD="pptp $PPTP_PEER --nolaunchpppd"
7c653e4b 415 METHOD=""
5aae218d 416 fi
d1e90efc 417
905fbf3e
MT
418 ### Run everything
419 #
7c653e4b 420 if [ "$METHOD" == "PPPOE_PLUGIN" ]; then
905fbf3e
MT
421 /usr/sbin/pppd $PPP_STD_OPTIONS $DEBUG $DEMAND >/dev/null 2>&1 &
422 evaluate_retval
a89770fa 423 # echo PLUGIN: /usr/sbin/pppd $PPP_STD_OPTIONS $DEBUG $DEMAND
905fbf3e
MT
424 else
425 /usr/sbin/pppd pty "$PPPOE_CMD" $PPP_STD_OPTIONS $DEBUG $DEMAND $PPPD_SYNC >/dev/null 2>&1 &
426 evaluate_retval
a89770fa 427 # echo PPP: /usr/sbin/pppd pty "$PPPOE_CMD" $PPP_STD_OPTIONS $DEBUG $DEMAND $PPPD_SYNC
905fbf3e 428 fi
1e4656cd
AF
429 ## Create & Enable vnstat
430 /usr/bin/vnstat -u -i ppp0 -r --enable --force > /dev/null 2>&1
905fbf3e 431 /etc/rc.d/init.d/connectd start
1f2ff0fa 432 # Add a NaN value to ppp0 rrd to supress spikes at reconnect
c772568a 433 rrdtool update $RRDLOG/collectd/localhost/interface/if_octets-ppp0.rrd \
49ab1173 434 $(date +%s):: > /dev/null 2>&1
28ec28bc 435 exit 0
d1e90efc 436 fi
d1e90efc
MT
437 ;;
438
439 stop)
440 if [ "$TYPE" == "STATIC" ]; then
0dde24fa
MT
441 boot_mesg "Stopping default gateway ${GATEWAY}..."
442 ip route del default via ${GATEWAY} >/dev/null 2>&1
443 echo_ok
444 if [ "$DEVICE" != "${GREEN_DEV}" ]; then
70631572
AF
445 boot_mesg "Removing IPv4 addresses from the ${DEVICE} interface..."
446 ip addr flush dev ${DEVICE}
0dde24fa
MT
447 evaluate_retval
448 fi
0e42072a 449 run_subdir ${rc_base}/init.d/networking/red.down/
f8841352 450
5aae218d 451 elif [ "$TYPE" == "PPPOE" ]; then
a89770fa 452 boot_mesg "Bringing down the PPP interface ..."
1e4656cd
AF
453 ## Disable vnstat collection
454 /usr/bin/vnstat -u -i ppp0 -r --disable > /dev/null 2>&1
93b34528 455 rm -f /var/ipfire/red/keepconnected
a89770fa 456 killall -w -s TERM /usr/sbin/pppd 2>/dev/null
352e626f 457 evaluate_retval
1f2ff0fa 458 # Add a NaN value to ppp0 rrd to supress spikes at reconnect
c772568a 459 rrdtool update $RRDLOG/collectd/localhost/interface/if_octets-ppp0.rrd \
49ab1173 460 $(date +%s):: > /dev/null 2>&1
0dde24fa 461
71ea0d68
SS
462 elif [ "$TYPE" == "DHCP" ]; then
463 # Check if the wlan-client is used on red.
464 # To determine this we check if a wpa_supplicant is running.
465 pid="$(pidof wpa_supplicant)"
466
467 if [ -z "${pid}" ]; then
468 # Stop dhcpcd.
469 dhcpcd_stop "${DEVICE}"
fd850b7e
AF
470 fi
471 fi
472
164a3b51
AF
473 if [ -n "${PPTP_ROUTE}" ]; then
474 route del ${PPTP_ROUTE}
475 fi
476
0dde24fa 477 if [ "$DEVICE" != "${GREEN_DEV}" ] && [ "$DEVICE" != "" ]; then
ff7a3950 478 link_status=`ip link show $DEVICE.${INET_VLAN} 2> /dev/null`
40049855
AF
479 if [ -n "${link_status}" ]; then
480 if echo "${link_status}" | grep -q UP; then
ff7a3950
AF
481 boot_mesg "Bringing down the ${DEVICE}.${INET_VLAN} interface..."
482 ip link set ${DEVICE}.${INET_VLAN} down
483 vconfig rem ${DEVICE}.${INET_VLAN}
40049855
AF
484 evaluate_retval
485 fi
bbe6aff7
AF
486 else
487 link_status=`ip link show $DEVICE 2> /dev/null`
488 if [ -n "${link_status}" ]; then
489 if echo "${link_status}" | grep -q UP; then
490 boot_mesg "Bringing down the ${DEVICE} interface..."
491 ip link set ${DEVICE} down
492 evaluate_retval
493 fi
0dde24fa 494 fi
d1e90efc
MT
495 fi
496 fi
cb1fb691 497 killall -w -s KILL /usr/sbin/pppd >/dev/null 2>&1
5aae218d 498 killall -w -s KILL pptp >/dev/null 2>&1
cb1fb691 499 killall -w -s KILL br2684ctl >/dev/null 2>&1
6c33dc5c 500
1e4656cd
AF
501 ## Disable vnstat collection
502 /usr/bin/vnstat -u -i ${DEVICE} -r --disable > /dev/null 2>&1
ed35052a
AF
503
504 rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
6c33dc5c 505 exit 0;
d1e90efc 506 ;;
d1e90efc
MT
507esac
508
509# End