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