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