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