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