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