]> git.ipfire.org Git - ipfire-2.x.git/blame - src/initscripts/init.d/networking/red
Added recent changes to core 32.
[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
d1e90efc
MT
77fi
78
fd850b7e
AF
79PIDFILE="/var/run/dhcpcd-${DEVICE}.pid"
80LEASEINFO="/var/ipfire/dhcpc/dhcpcd-${DEVICE}.info"
81DHCP_START="-N -R -L /var/ipfire/dhcpc -c /var/ipfire/dhcpc/dhcpcd.exe "
82DHCP_STOP="-k -c /var/ipfire/dhcpc/dhcpcd.exe "
83
d1e90efc
MT
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
ff07f865 253 boot_mesg "Createing VLAN Interface ${DEVICE}.${RED_VDSL_INET_VLAN} ..."
40049855 254 modprobe 8021q
ff07f865
AF
255 vconfig add ${DEVICE} ${RED_VDSL_INET_VLAN}
256 PPP_NIC=${DEVICE}.${RED_VDSL_INET_VLAN}
40049855
AF
257 sleep 0.2
258 ip link set ${PPP_NIC} up
259 TYPE="pppoe"
bbe6aff7 260
ff07f865
AF
261 if [ "${RED_VDSL_IPTV_DISABLE}" == "0" ]; then
262 PIDFILE="/var/run/dhcpcd-${DEVICE}.${RED_VDSL_IPTV_VLAN}.pid"
263 LEASEINFO="/var/ipfire/dhcpc/dhcpcd-${DEVICE}.${RED_VDSL_IPTV_VLAN}.info"
ff07f865
AF
264
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
bbe6aff7 271 fi
bbe6aff7 272
ff07f865
AF
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 boot_mesg -n "Starting dhcpcd on the ${DEVICE}.${RED_VDSL_IPTV_VLAN} interface..."
277 /sbin/dhcpcd ${DEVICE}.${RED_VDSL_IPTV_VLAN} ${DHCP_START} >/dev/null 2>&1
278 RET="$?"
bbe6aff7 279
ff07f865
AF
280 if [ "$RET" = "0" ]; then
281 . /var/ipfire/dhcpc/dhcpcd-${DEVICE}.${RED_VDSL_IPTV_VLAN}.info
282 echo ""
283 echo_ok
284 boot_mesg " DHCP Assigned Settings for ${DEVICE}.${RED_VDSL_IPTV_VLAN}:"
285 boot_mesg_flush
286 boot_mesg " IP Address: $IPADDR"
287 boot_mesg_flush
288 boot_mesg " Hostname: $RED_DHCP_HOSTNAME"
289 boot_mesg_flush
290 boot_mesg " Subnet Mask: $NETMASK"
291 boot_mesg_flush
292 boot_mesg " Default Gateway: $GATEWAY"
293 boot_mesg_flush
294 boot_mesg " DNS Server: $DNS"
295 boot_mesg_flush
bbe6aff7
AF
296
297 else
298 echo ""
299 $(exit "$RET")
300 evaluate_retval
ff07f865 301 fi
bbe6aff7
AF
302 fi
303 fi
40049855
AF
304 fi
305
5aae218d 306 if [ "$TYPE" == "pppoeatm" ] || [ "$TYPE" == "pptpatm" ]; then
a89770fa 307 PPP_NIC=nas0
0dde24fa 308 boot_mesg "Createing ATM-Bridge as $PPP_NIC ..."
a89770fa
MT
309 br2684ctl -c0 -e${ENCAP} -a0.${VPI}.${VCI} >/dev/null 2>&1 &
310 sleep 1
5aae218d
AF
311 if [ "$TYPE" == "pppoeatm" ]; then
312 TYPE="pppoe"
313 fi
314 if [ "$TYPE" == "pptpatm" ]; then
315 TYPE="pptp"
316 fi
a89770fa 317 fi
5aae218d 318 if [ "$TYPE" == "pppoe" ] || [ "$TYPE" == "pptp" ]; then
4cd4876a 319 if [ "$PPP_NIC" == "" ]; then
0dde24fa
MT
320 boot_mesg "No device for red interface given. Check netsetup or dialprofile!" ${FAILURE}
321 echo_failure
cb1fb691 322 exit 0
0dde24fa 323 fi
5aae218d 324 boot_mesg "Bringing up the $TYPE interface on $PPP_NIC ..."
58e9b9dc 325 ip addr flush dev $PPP_NIC >/dev/null 2>&1
5aae218d 326 if [ "$TYPE" == "pptp" ]; then
fd850b7e
AF
327 if [ "$PPTP_NICCFG" == "dhcp" ]; then
328
329 # Test to see if there is a stale pid file
330 if [ -f "$PIDFILE" ]; then
331 ps `cat "$PIDFILE"` | grep dhcpcd > /dev/null
332 if [ $? != 0 ]; then
333 rm -f /var/run/dhcpcd-${DEVICE}.${RED_VDSL_IPTV_VLAN}.pid > /dev/null
334 fi
335 fi
336
337 if [ ! -f "$PIDFILE" ]; then
338 boot_mesg -n "Starting dhcpcd on the ${DEVICE}.${RED_VDSL_IPTV_VLAN} interface..."
339 /sbin/dhcpcd ${DEVICE} ${DHCP_START} >/dev/null 2>&1
340 RET="$?"
341
342 if [ "$RET" = "0" ]; then
343 . /var/ipfire/dhcpc/dhcpcd-${DEVICE}.info
344 echo ""
345 echo_ok
346 boot_mesg " DHCP Assigned Settings for ${DEVICE}:"
347 boot_mesg_flush
348 boot_mesg " IP Address: $IPADDR"
349 boot_mesg_flush
350 boot_mesg " Hostname: $RED_DHCP_HOSTNAME"
351 boot_mesg_flush
352 boot_mesg " Subnet Mask: $NETMASK"
353 boot_mesg_flush
354 boot_mesg " Default Gateway: $GATEWAY"
355 boot_mesg_flush
356 boot_mesg " DNS Server: $DNS"
357 boot_mesg_flush
358
359 else
360 echo ""
361 $(exit "$RET")
362 evaluate_retval
363 fi
364 fi
365 else
366 ip addr add $PPTP_NICCFG dev $PPP_NIC
367 fi
5aae218d 368 fi
58e9b9dc 369 ip link set ${PPP_NIC} up
27b8cc24
MT
370 else
371 boot_mesg "Bringing up the PPP via ${TYPE} on ${COMPORT}..."
372 fi
0dde24fa 373
905fbf3e
MT
374 ### ###
375 ### Configuring the pppd ###
376 ### ###
377
378 ### Plugin Options
379 #
5aae218d
AF
380 if [ "$TYPE" == "pppoe" ]; then
381 [ "${METHOD}" == "PPPOE_PLUGIN" ] && \
382 PLUGOPTS="plugin /usr/lib/pppd/2.4.4/rp-pppoe.so"
383 fi
d1e90efc 384
905fbf3e
MT
385 ### Synchronous Mode
386 #
387 #PPPOE_SYNC=-s
a89770fa
MT
388 #PPPD_SYNC=sync
389
390 ### Access Concentrator Name
391 #
905fbf3e
MT
392 if [ -n "${CONCENTRATORNAME}" ]; then
393 ACNAME="-C ${CONCENTRATORNAME}"
d1e90efc 394 fi
905fbf3e
MT
395
396 ### Service Name
397 #
398 if [ -n "${SERVICENAME}" ]; then
399 if [ "${METHOD}" == "PPPOE_PLUGIN" ]; then
400 PLUGOPTS+=" rp_pppoe_service ${SERVICENAME}"
401 else
402 SERVICENAME="-S ${SERVICENAME}"
403 fi
d1e90efc 404 fi
a89770fa 405
905fbf3e
MT
406 ### Authentication Types
407 #
d1e90efc 408 if [ "${AUTH}" == "pap" ]; then
905fbf3e 409 AUTH="-chap"
d1e90efc 410 elif [ "${AUTH}" == "chap" ]; then
905fbf3e 411 AUTH="-pap"
57cb9775
CS
412 else
413 AUTH=""
d1e90efc 414 fi
a89770fa
MT
415
416 ### DNS Config
417 #
418 if [ "${DNS}" == "Automatic" ]; then
419 DNS="usepeerdns"
420 else
421 DNS=""
422 echo nameserver=$DNS1 > /etc/ppp/resolv.conf
423 echo nameserver=$DNS2 >> /etc/ppp/resolv.conf
a89770fa
MT
424 fi
425
905fbf3e
MT
426 ### Dial On Demand
427 #
d1e90efc
MT
428 if [ "${RECONNECTION}" != "persistent" ]; then
429 if [ "${TIMEOUT}" != "0" ] && [ "${TIMEOUT}" != "" ]; then
430 SECONDS=$[${TIMEOUT} * 60]
905fbf3e
MT
431 else
432 SECONDS=300
d1e90efc
MT
433 fi
434 if [ "${RECONNECTION}" == "dialondemand" ]; then
435 touch /var/ipfire/red/dial-on-demand
905fbf3e 436 DEMAND="demand persist idle ${SECONDS} 10.112.112.112:10.112.112.113"
a89770fa 437 DEMAND+=" ipcp-accept-remote ipcp-accept-local noipdefault ktune"
d1e90efc 438 fi
905fbf3e
MT
439 fi
440
5aae218d
AF
441 if [ "$TYPE" == "pppoe" ]; then
442 ### When using pppoe-plugin the device has to be the last option
443 #
444 [ "${METHOD}" == "PPPOE_PLUGIN" ] && PLUGOPTS+=" $PPP_NIC"
445 fi
27b8cc24
MT
446
447 if [ "$TYPE" == "modem" ]; then
a89770fa 448 PLUGOPTS=" /dev/${COMPORT} ${DTERATE} connect /etc/ppp/dialer lock modem crtscts"
7c653e4b 449 METHOD="PPPOE_PLUGIN"
27b8cc24 450 elif [ "$TYPE" == "serial" ]; then
a89770fa 451 PLUGOPTS=" /dev/${COMPORT} ${DTERATE} connect /bin/true lock modem crtscts"
7c653e4b 452 METHOD="PPPOE_PLUGIN"
27b8cc24 453 fi
905fbf3e
MT
454
455 ### Standard PPP options we always use
456 #
a89770fa 457 PPP_STD_OPTIONS="$PLUGOPTS $DNS defaultroute noipdefault noauth"
905fbf3e
MT
458 PPP_STD_OPTIONS+=" default-asyncmap hide-password nodetach mtu ${MTU}"
459 PPP_STD_OPTIONS+=" mru ${MTU} noaccomp nodeflate nopcomp novj novjccomp"
460 PPP_STD_OPTIONS+=" nobsdcomp user ${USERNAME} lcp-echo-interval 20"
461 PPP_STD_OPTIONS+=" lcp-echo-failure 3 ${AUTH}"
a89770fa 462
905fbf3e
MT
463 ### Debugging
464 #
465 if [ "${DEBUG}" == "on" ]; then
466 DEBUG="debug"
d1e90efc 467 else
905fbf3e 468 DEBUG=""
d1e90efc
MT
469 fi
470
905fbf3e
MT
471 ### PPPoE invocation
472 #
a89770fa
MT
473 if [ "$TYPE" == "pppoe" ]; then
474 PPPOE_CMD="/usr/sbin/pppoe -p /var/run/ppp-ipfire.pid.pppoe -I $PPP_NIC"
27b8cc24
MT
475 PPPOE_CMD+=" -T 80 -U $PPPOE_SYNC $ACNAME $SERVICENAMEOPT"
476 fi
5aae218d
AF
477
478 ### PPTP ###
479 #
480 if [ "$TYPE" == "pptp" ]; then
481 PPPOE_CMD="pptp $PPTP_PEER --nolaunchpppd"
7c653e4b 482 METHOD=""
5aae218d 483 fi
d1e90efc 484
905fbf3e
MT
485 ### Run everything
486 #
7c653e4b 487 if [ "$METHOD" == "PPPOE_PLUGIN" ]; then
905fbf3e
MT
488 /usr/sbin/pppd $PPP_STD_OPTIONS $DEBUG $DEMAND >/dev/null 2>&1 &
489 evaluate_retval
a89770fa 490 # echo PLUGIN: /usr/sbin/pppd $PPP_STD_OPTIONS $DEBUG $DEMAND
905fbf3e
MT
491 else
492 /usr/sbin/pppd pty "$PPPOE_CMD" $PPP_STD_OPTIONS $DEBUG $DEMAND $PPPD_SYNC >/dev/null 2>&1 &
493 evaluate_retval
a89770fa 494 # echo PPP: /usr/sbin/pppd pty "$PPPOE_CMD" $PPP_STD_OPTIONS $DEBUG $DEMAND $PPPD_SYNC
905fbf3e 495 fi
1e4656cd
AF
496 ## Create & Enable vnstat
497 /usr/bin/vnstat -u -i ppp0 -r --enable --force > /dev/null 2>&1
905fbf3e 498 /etc/rc.d/init.d/connectd start
1f2ff0fa 499 # Add a NaN value to ppp0 rrd to supress spikes at reconnect
c772568a 500 rrdtool update $RRDLOG/collectd/localhost/interface/if_octets-ppp0.rrd \
49ab1173 501 $(date +%s):: > /dev/null 2>&1
28ec28bc 502 exit 0
d1e90efc 503 fi
d1e90efc
MT
504 ;;
505
506 stop)
507 if [ "$TYPE" == "STATIC" ]; then
0dde24fa
MT
508 boot_mesg "Stopping default gateway ${GATEWAY}..."
509 ip route del default via ${GATEWAY} >/dev/null 2>&1
510 echo_ok
511 if [ "$DEVICE" != "${GREEN_DEV}" ]; then
70631572
AF
512 boot_mesg "Removing IPv4 addresses from the ${DEVICE} interface..."
513 ip addr flush dev ${DEVICE}
0dde24fa
MT
514 evaluate_retval
515 fi
0e42072a 516 run_subdir ${rc_base}/init.d/networking/red.down/
f8841352 517
5aae218d 518 elif [ "$TYPE" == "PPPOE" ]; then
a89770fa 519 boot_mesg "Bringing down the PPP interface ..."
1e4656cd
AF
520 ## Disable vnstat collection
521 /usr/bin/vnstat -u -i ppp0 -r --disable > /dev/null 2>&1
93b34528 522 rm -f /var/ipfire/red/keepconnected
a89770fa 523 killall -w -s TERM /usr/sbin/pppd 2>/dev/null
352e626f 524 evaluate_retval
1f2ff0fa 525 # Add a NaN value to ppp0 rrd to supress spikes at reconnect
c772568a 526 rrdtool update $RRDLOG/collectd/localhost/interface/if_octets-ppp0.rrd \
49ab1173 527 $(date +%s):: > /dev/null 2>&1
d1e90efc 528 fi
0dde24fa 529
fd850b7e
AF
530 if [ -e $LEASEINFO ]; then
531 boot_mesg -n "Stopping dhcpcd on the ${DEVICE} interface..."
532 . $LEASEINFO
533 if [ "$LEASETIME" = "4294967295" ]; then
534 # do nothing, just echo ok
535 echo ""
536 echo_ok
537 else
538 if [ -n "$DHCP_STOP" ]; then
539 /sbin/dhcpcd ${DEVICE} $DHCP_STOP &> /dev/null
540 RET="$?"
541 if [ "$RET" -eq 0 ]; then
542 echo ""
543 echo_ok
544 elif [ "$RET" -eq 1 ]; then
545 boot_mesg "dhcpcd not running!" ${WARNING}
546 echo_warning
547 else
548 echo ""
549 echo_failure
550 fi
551 else
552 echo ""
553 killproc dhcpcd
554 fi
555 fi
556 fi
557
0dde24fa 558 if [ "$DEVICE" != "${GREEN_DEV}" ] && [ "$DEVICE" != "" ]; then
ff07f865 559 link_status=`ip link show $DEVICE.${RED_VDSL_INET_VLAN} 2> /dev/null`
40049855
AF
560 if [ -n "${link_status}" ]; then
561 if echo "${link_status}" | grep -q UP; then
ff07f865
AF
562 boot_mesg "Bringing down the ${DEVICE}.${RED_VDSL_INET_VLAN} interface..."
563 ip link set ${DEVICE}.${RED_VDSL_INET_VLAN} down
564 vconfig del ${DEVICE} ${RED_VDSL_INET_VLAN}
40049855
AF
565 evaluate_retval
566 fi
bbe6aff7
AF
567 else
568 link_status=`ip link show $DEVICE 2> /dev/null`
569 if [ -n "${link_status}" ]; then
570 if echo "${link_status}" | grep -q UP; then
571 boot_mesg "Bringing down the ${DEVICE} interface..."
572 ip link set ${DEVICE} down
573 evaluate_retval
574 fi
0dde24fa 575 fi
d1e90efc
MT
576 fi
577 fi
cb1fb691 578 killall -w -s KILL /usr/sbin/pppd >/dev/null 2>&1
5aae218d 579 killall -w -s KILL pptp >/dev/null 2>&1
cb1fb691 580 killall -w -s KILL br2684ctl >/dev/null 2>&1
6c33dc5c 581
1e4656cd
AF
582 ## Disable vnstat collection
583 /usr/bin/vnstat -u -i ${DEVICE} -r --disable > /dev/null 2>&1
ed35052a
AF
584
585 rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
6c33dc5c 586 exit 0;
d1e90efc 587 ;;
d1e90efc
MT
588esac
589
590# End