1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/network,v 1.19 2008-12-22 22:01:15 niro Exp $ |
# $Id$ |
3 |
|
|
4 |
#%rlevels: 0:k 1:k 2:k 3:s 4:s 5:s 6:k |
#%rlevels: 0:k 1:k 2:k 3:s 4:s 5:s 6:k |
5 |
#%start: 20 |
#%start: 20 |
12 |
|
|
13 |
source /etc/conf.d/rc |
source /etc/conf.d/rc |
14 |
source ${rc_functions} |
source ${rc_functions} |
15 |
|
source /etc/conf.d/network |
16 |
|
|
17 |
|
wait_online() |
18 |
|
{ |
19 |
|
local timeout="1" |
20 |
|
local iface="$2" |
21 |
|
|
22 |
|
(( timeout *= 10 )) |
23 |
|
|
24 |
|
while [ ! -e /sys/class/net/${iface} ] |
25 |
|
do |
26 |
|
(( timeout-- > 0 )) || return 1 |
27 |
|
sleep 0.1 |
28 |
|
done |
29 |
|
|
30 |
|
return 0 |
31 |
|
} |
32 |
|
|
33 |
# read values from files |
# read values from files |
34 |
read_value() |
read_value() |
81 |
|
|
82 |
local BRIDGE_INTERFACES |
local BRIDGE_INTERFACES |
83 |
local BRIDGE_STP |
local BRIDGE_STP |
84 |
|
local BRIDGE_AGEING_TIME |
85 |
|
local BRIDGE_PRIORITY |
86 |
|
local BRIDGE_FORWARD_DELAY |
87 |
|
local BRIDGE_HELLO_TIME |
88 |
|
local BRIDGE_MAX_MESSAGE_AGE |
89 |
|
local BRIDGE_PATH_COST |
90 |
|
local BRIDGE_PORT_PRIORITY |
91 |
|
|
92 |
source ${file} |
source ${file} |
93 |
eval value=\$$(echo ${var}) |
eval value=\$$(echo ${var}) |
98 |
{ |
{ |
99 |
if [[ -z ${NETWORKING} ]] |
if [[ -z ${NETWORKING} ]] |
100 |
then |
then |
101 |
echo "NETWORKING missing in net.${interface}, aborted" |
rc_echo "NETWORKING missing in net.${iface}, aborted" |
102 |
exit 1 |
exit 1 |
103 |
fi |
fi |
104 |
|
|
106 |
static) |
static) |
107 |
if [[ -z ${IP} ]] |
if [[ -z ${IP} ]] |
108 |
then |
then |
109 |
echo "IP missing in net.${interface}, aborted" |
rc_echo "IP missing in net.${iface}, aborted" |
110 |
exit 1 |
exit 1 |
111 |
fi |
fi |
112 |
|
|
113 |
if [[ -z ${NETMASK} ]] |
if [[ -z ${NETMASK} ]] |
114 |
then |
then |
115 |
echo -n "NETMASK missing in net.${interface}, " |
rc_echo -n "NETMASK missing in net.${iface}, " |
116 |
echo "using 255.255.255.0" |
rc_echo "using ${DEFAULT_NETMASK}" |
117 |
NETMASK=255.255.255.0 |
NETMASK="${DEFAULT_NETMASK}" |
118 |
fi |
fi |
119 |
|
|
120 |
if [[ -z ${BROADCAST} ]] |
if [[ -z ${BROADCAST} ]] |
121 |
then |
then |
122 |
echo -n "BROADCAST missing in net.${interface}, " |
rc_echo -n "BROADCAST missing in net.${iface}, " |
123 |
echo "using default address" |
rc_echo "using default address" |
124 |
fi |
fi |
125 |
;; |
;; |
126 |
|
|
127 |
dhcp) |
dhcp) |
128 |
if [[ -z ${DHCP_PROG} ]] |
if [[ -z ${DHCP_PROG} ]] |
129 |
then |
then |
130 |
echo "DHCP_PROG missing in net.${interface}, aborted" |
rc_echo -n "DHCP_PROG missing in net.${iface}," |
131 |
exit 1 |
rc_echo "using default programm ${DEFAULT_DHCP_PROG}" |
132 |
|
DHCP_PROG="${DEFAULT_DHCP_PROG}" |
133 |
fi |
fi |
134 |
|
[[ -z ${DHCP_START} ]] && DHCP_START="${DEFAULT_DHCP_START}" |
135 |
|
[[ -z ${DHCP_STOP} ]] && DHCP_STOP="${DEFAULT_DHCP_STOP}" |
136 |
;; |
;; |
137 |
|
|
138 |
esac |
esac |
148 |
# get list of all devices |
# get list of all devices |
149 |
for file in $@ |
for file in $@ |
150 |
do |
do |
151 |
|
iface="$(basename ${file} | sed s/net.//)" |
152 |
|
|
153 |
|
# exclude backup files and exclude net.routes and net.sample too |
154 |
|
case "${iface}" in |
155 |
|
*~) continue ;; |
156 |
|
routes) continue ;; |
157 |
|
sample) continue ;; |
158 |
|
esac |
159 |
|
|
160 |
if [[ $(read_value ONBOOT ${file}) = yes ]] |
if [[ $(read_value ONBOOT ${file}) = yes ]] |
161 |
then |
then |
162 |
iface="$(basename ${file} | sed s/net.//)" |
devices="${devices} ${iface}" |
|
# exclude backup files and exclude net.routes too |
|
|
case "${iface}" in |
|
|
*~) ;; |
|
|
*/net.routes) ;; |
|
|
*) devices="${devices} $(basename ${file} | sed s/net.//)" ;; |
|
|
esac |
|
163 |
fi |
fi |
164 |
done |
done |
165 |
|
|
172 |
|
|
173 |
if [[ -z ${iface} ]] |
if [[ -z ${iface} ]] |
174 |
then |
then |
175 |
echo "WEP: no \$iface given. Aborting setup." |
rc_echo "WEP: no \$iface given. Aborting setup." |
176 |
return 1 |
return 1 |
177 |
fi |
fi |
178 |
|
|
179 |
${CURS_UP} |
${CURS_UP} |
180 |
${SET_WWCOL} |
${SET_WWCOL} |
181 |
echo "[AUTH: WEP]" |
rc_echo "[AUTH: WEP]" |
182 |
|
|
183 |
iwconfig "${iface}" enc on |
iwconfig "${iface}" enc on |
184 |
[[ -n ${WIRELESS_KEY_LENGTH} ]] && iwconfig "${iface}" enc "${WIRELESS_KEY_LENGTH}" |
[[ -n ${WIRELESS_KEY_LENGTH} ]] && iwconfig "${iface}" enc "${WIRELESS_KEY_LENGTH}" |
192 |
|
|
193 |
if [[ -z ${iface} ]] |
if [[ -z ${iface} ]] |
194 |
then |
then |
195 |
echo "WPA: no \$iface given. Aborting setup." |
rc_echo "WPA: no \$iface given. Aborting setup." |
196 |
return 1 |
return 1 |
197 |
fi |
fi |
198 |
|
|
199 |
if [ ! -x /sbin/wpa_supplicant ] |
if [ ! -x $(type -P wpa_supplicant) ] |
200 |
then |
then |
201 |
echo "WPA: wpa_supplicant not installed. Aborting setup." |
rc_echo "WPA: wpa_supplicant not installed. Aborting setup." |
202 |
return 1 |
return 1 |
203 |
fi |
fi |
204 |
|
|
205 |
${CURS_UP} |
${CURS_UP} |
206 |
${SET_WWCOL} |
${SET_WWCOL} |
207 |
echo "[AUTH: WPA]" |
rc_echo "[AUTH: WPA]" |
208 |
|
|
209 |
# get default settings |
# get default settings |
210 |
[[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant |
[[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant |
211 |
|
|
212 |
# check the configuration |
# check the configuration |
213 |
[[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant.auto |
[[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant/wpa_supplicant.auto |
214 |
[[ -z ${WIRELESS_WPA_SKEL} ]] && WIRELESS_WPA_SKEL=/etc/conf.d/wpa_supplicant.skel |
[[ -z ${WIRELESS_WPA_SKEL} ]] && WIRELESS_WPA_SKEL=/etc/conf.d/wpa_supplicant.skel |
215 |
|
|
216 |
# use wext as default driver, do not abort here anymore |
# use wext as default driver, do not abort here anymore |
237 |
fi |
fi |
238 |
|
|
239 |
# remove old state dir |
# remove old state dir |
240 |
[ -d /var/run/wpa_supplicant ] && rm -rf /var/run/wpa_supplicant |
[ -d /run/wpa_supplicant ] && rm -rf /run/wpa_supplicant |
241 |
|
|
242 |
# now run the wpa_supplicant dameon |
# now run the wpa_supplicant dameon |
243 |
wpa_supplicant -B \ |
wpa_supplicant -B \ |
247 |
${WIRELESS_WPA_OPTS} |
${WIRELESS_WPA_OPTS} |
248 |
|
|
249 |
# echo wait 5 seconds |
# echo wait 5 seconds |
250 |
echo " Waiting 5 seconds to retrieve authentification reply ... " |
rc_echo " Waiting 5 seconds to retrieve authentification reply ... " |
251 |
sleep 5 |
sleep 5 |
252 |
} |
} |
253 |
|
|
257 |
|
|
258 |
if [[ -z ${iface} ]] |
if [[ -z ${iface} ]] |
259 |
then |
then |
260 |
echo "WIRELESS_EXTENSIONS: no \$iface given. Aborting setup." |
rc_echo "WIRELESS_EXTENSIONS: no \$iface given. Aborting setup." |
261 |
return 1 |
return 1 |
262 |
fi |
fi |
263 |
|
|
269 |
[[ -n ${WIRELESS_NICK} ]] || |
[[ -n ${WIRELESS_NICK} ]] || |
270 |
[[ -n ${WIRELESS_AUTH_MODE} ]] |
[[ -n ${WIRELESS_AUTH_MODE} ]] |
271 |
then |
then |
272 |
echo -e ${COLOREDSTAR}"Setting up wlan-ext for ${COLBLUE}${iface}${COLDEFAULT} ... " |
rc_print "Setting up wlan-ext for ${COLBLUE}${iface}${COLDEFAULT} ... " |
273 |
fi |
fi |
274 |
|
|
275 |
[[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}" |
[[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}" |
286 |
esac |
esac |
287 |
} |
} |
288 |
|
|
289 |
|
config_bridge_options() |
290 |
|
{ |
291 |
|
local iface="$1" |
292 |
|
local i |
293 |
|
local port |
294 |
|
local cost |
295 |
|
local prio |
296 |
|
|
297 |
|
# enable spanning-tree protocol |
298 |
|
case ${BRIDGE_STP} in |
299 |
|
on|off) brctl stp "${iface}" "${BRIDGE_STP}" ;; |
300 |
|
*) rc_echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;; |
301 |
|
esac |
302 |
|
|
303 |
|
# configure ageing time |
304 |
|
if [[ ! -z ${BRIDGE_AGEING_TIME} ]] |
305 |
|
then |
306 |
|
brctl setageing "${iface}" "${BRIDGE_AGEING_TIME}" |
307 |
|
fi |
308 |
|
|
309 |
|
# configure bridge priority |
310 |
|
if [[ ! -z ${BRIDGE_PRIORITY} ]] |
311 |
|
then |
312 |
|
brctl setbridgeprio "${iface}" "${BRIDGE_PRIORITY}" |
313 |
|
fi |
314 |
|
|
315 |
|
# configure forward delay |
316 |
|
if [[ ! -z ${BRIDGE_FORWARD_DELAY} ]] |
317 |
|
then |
318 |
|
brctl setfd "${iface}" "${BRIDGE_FORWARD_DELAY}" |
319 |
|
fi |
320 |
|
|
321 |
|
# configure hello time |
322 |
|
if [[ ! -z ${BRIDGE_HELLO_TIME} ]] |
323 |
|
then |
324 |
|
brctl sethello "${iface}" "${BRIDGE_HELLO_TIME}" |
325 |
|
fi |
326 |
|
|
327 |
|
# configure maximal message age |
328 |
|
if [[ ! -z ${BRIDGE_MAX_MESSAGE_AGE} ]] |
329 |
|
then |
330 |
|
brctl setmaxage "${iface}" "${BRIDGE_MAX_MESSAGE_AGE}" |
331 |
|
fi |
332 |
|
|
333 |
|
# configure path cost for every port |
334 |
|
if [[ ! -z ${BRIDGE_PATH_COST} ]] |
335 |
|
then |
336 |
|
for i in ${BRIDGE_PATH_COST} |
337 |
|
do |
338 |
|
port="${i%=*}" |
339 |
|
cost="${i#*=}" |
340 |
|
[[ ! -z ${port} ]] && brctl pathcost "${iface}" "${port}" "${cost}" |
341 |
|
done |
342 |
|
fi |
343 |
|
|
344 |
|
# configure port priority for every port |
345 |
|
if [[ ! -z ${BRIDGE_PORT_PRIORITY} ]] |
346 |
|
then |
347 |
|
for i in ${BRIDGE_PORT_PRIORITY} |
348 |
|
do |
349 |
|
port="${i%=*}" |
350 |
|
prio="${i#*=}" |
351 |
|
[[ ! -z ${port} ]] && brctl setportprio "${iface}" "${port}" "${prio}" |
352 |
|
done |
353 |
|
fi |
354 |
|
} |
355 |
|
|
356 |
config_bridge_devices() |
config_bridge_devices() |
357 |
{ |
{ |
358 |
local iface="$1" |
local iface="$1" |
361 |
|
|
362 |
if [[ -z ${iface} ]] |
if [[ -z ${iface} ]] |
363 |
then |
then |
364 |
echo "BRIDGE: no \$iface given. Aborting setup." |
rc_echo "BRIDGE: no \$iface given. Aborting setup." |
365 |
return 1 |
return 1 |
366 |
fi |
fi |
367 |
|
|
368 |
if [[ -z ${method} ]] |
if [[ -z ${method} ]] |
369 |
then |
then |
370 |
echo "BRIDGE: no \$method given. Aborting setup." |
rc_echo "BRIDGE: no \$method given. Aborting setup." |
371 |
return 1 |
return 1 |
372 |
fi |
fi |
373 |
|
|
374 |
# first check for brctl |
# first check for brctl |
375 |
if [[ -z $(which brctl) ]] |
if [[ -z $(type -P brctl) ]] |
376 |
then |
then |
377 |
echo "brctl not found! Please install 'net-misc/bridge-utils'." |
rc_echo "brctl not found! Please install 'net-misc/bridge-utils'." |
378 |
return 1 |
return 1 |
379 |
fi |
fi |
380 |
|
|
381 |
# check the config |
# check the config |
382 |
if [[ -z ${BRIDGE_INTERFACES} ]] |
if [[ -z ${BRIDGE_INTERFACES} ]] |
383 |
then |
then |
384 |
echo "BRIDGE: no \$BRIDGE_INTERFACES given. Aborting setup." |
rc_echo "BRIDGE: no \$BRIDGE_INTERFACES given. Aborting setup." |
385 |
return 1 |
return 1 |
386 |
fi |
fi |
387 |
|
|
388 |
case ${method} in |
case ${method} in |
389 |
add) |
add) |
390 |
# setup the bridge device |
# setup the bridge device |
391 |
brctl addbr ${iface} |
brctl addbr "${iface}" |
392 |
for bport in ${BRIDGE_INTERFACES} |
for bport in ${BRIDGE_INTERFACES} |
393 |
do |
do |
394 |
# enter promiscous mode |
# enter promiscous mode |
395 |
ifconfig ${bport} 0.0.0.0 promisc |
ifconfig "${bport}" 0.0.0.0 promisc |
396 |
# now setup the bridge |
# now setup the bridge |
397 |
brctl addif ${iface} ${bport} |
brctl addif "${iface}" "${bport}" |
398 |
done |
done |
399 |
# enable spanning-tree protocol |
# configure all other options |
400 |
case ${BRIDGE_STP} in |
config_bridge_options "${iface}" |
|
on|off) brctl stp ${iface} ${BRIDGE_STP} ;; |
|
|
*) echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;; |
|
|
esac |
|
401 |
;; |
;; |
402 |
|
|
403 |
remove) |
remove) |
404 |
for bport in ${BRIDGE_INTERFACE} |
for bport in ${BRIDGE_INTERFACE} |
405 |
do |
do |
406 |
# bring the interface down |
# bring the interface down |
407 |
ifconfig ${bport} down |
ifconfig "${bport}" down |
408 |
# remove the interface from the bridge |
# remove the interface from the bridge |
409 |
brctl delif ${iface} ${bport} |
brctl delif "${iface}" "${bport}" |
410 |
done |
done |
411 |
# bring the bridge down |
# bring the bridge down |
412 |
brctl delbr ${iface} |
brctl delbr "${iface}" |
413 |
;; |
;; |
414 |
esac |
esac |
415 |
|
|
425 |
|
|
426 |
# only add and del are allowed |
# only add and del are allowed |
427 |
case ${method} in |
case ${method} in |
428 |
add) message="Adding route ${COLBLUE}${route}${COLDEFAULT} ..." ;; |
add) message="Adding" ;; |
429 |
del) message="Removing route ${COLBLUE}${route}${COLDEFAULT} ..." ;; |
del) message="Removing" ;; |
430 |
*) |
*) |
431 |
echo "config_routes: unsupported \$method '${method}'." |
rc_echo "config_routes: unsupported \$method '${method}'." |
432 |
exit 1 |
exit 1 |
433 |
;; |
;; |
434 |
esac |
esac |
442 |
case "${route}" in |
case "${route}" in |
443 |
\#*|"") continue ;; |
\#*|"") continue ;; |
444 |
esac |
esac |
445 |
echo -e ${COLOREDSTAR}"${message}" |
rc_print "${message} route ${COLBLUE}${route}${COLDEFAULT} ..." |
446 |
route ${method} ${route} |
# do not esacpe ${route} or it breaks! |
447 |
|
route "${method}" ${route} |
448 |
evaluate_retval |
evaluate_retval |
449 |
done |
done |
450 |
fi |
fi |
456 |
|
|
457 |
if [[ -z $1 ]] |
if [[ -z $1 ]] |
458 |
then |
then |
459 |
ALL_INTERFACES=$(onboot_interface_list ${network_settings}/net.*) |
ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*) |
460 |
else |
else |
461 |
if [[ -e ${network_settings}/net.$1 ]] |
if [[ -e ${rc_network_settings}/net.$1 ]] |
462 |
then |
then |
463 |
ALL_INTERFACES="$1" |
ALL_INTERFACES="$1" |
464 |
else |
else |
465 |
${FAILURE} |
${FAILURE} |
466 |
echo "Interface $1 does not exist. Aborting" |
rc_echo "Interface $1 does not exist. Aborting" |
467 |
${NORMAL} |
${NORMAL} |
468 |
exit 1 |
exit 1 |
469 |
fi |
fi |
473 |
for iface in ${ALL_INTERFACES} |
for iface in ${ALL_INTERFACES} |
474 |
do |
do |
475 |
# checkconfig |
# checkconfig |
476 |
source ${network_settings}/net.${iface} || exit 1 |
source ${rc_network_settings}/net.${iface} || exit 1 |
477 |
checkconfig |
checkconfig |
478 |
|
|
479 |
|
# wait until the device is created |
480 |
|
wait_online 5 "${iface}" || { echo "device '${iface}' does not exist"; continue; } |
481 |
|
|
482 |
# setup mac |
# setup mac |
483 |
if [ -n "${FORCE_MAC_TO}" ] |
if [[ -n ${FORCE_MAC_TO} ]] |
484 |
then |
then |
485 |
echo -e ${COLOREDSTAR}"Faking MAC to ${FORCE_MAC_TO} for ${COLBLUE}${iface}${COLDEFAULT} ... " |
rc_print "Faking MAC to ${FORCE_MAC_TO} for ${COLBLUE}${iface}${COLDEFAULT} ... " |
486 |
ifconfig "${iface}" hw ether "${FORCE_MAC_TO}" |
ifconfig "${iface}" hw ether "${FORCE_MAC_TO}" |
487 |
evaluate_retval |
evaluate_retval |
488 |
fi |
fi |
490 |
# setup bridges |
# setup bridges |
491 |
if [[ ${iface} = br[0-9]* ]] |
if [[ ${iface} = br[0-9]* ]] |
492 |
then |
then |
493 |
config_bridge_devices ${iface} add |
config_bridge_devices "${iface}" add |
494 |
fi |
fi |
495 |
|
|
496 |
# now configure wireless_extensions |
# now configure wireless_extensions |
497 |
[ -x /usr/sbin/iwconfig ] && setup_wireless_extensions "${iface}" |
[ -x $(type -P iwconfig) ] && setup_wireless_extensions "${iface}" |
498 |
|
|
499 |
echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
500 |
|
|
501 |
# activate the interface |
# activate the interface |
502 |
ifconfig "${iface}" up |
ifconfig "${iface}" up |
506 |
dhcp|DHCP) |
dhcp|DHCP) |
507 |
${CURS_UP} |
${CURS_UP} |
508 |
${SET_WWCOL} |
${SET_WWCOL} |
509 |
echo "[DHCP]" |
rc_echo "[DHCP]" |
510 |
loadproc ${DHCP_PROG} ${DHCP_START} "${iface}" |
loadproc ${DHCP_PROG} ${DHCP_START} "${iface}" |
511 |
;; |
;; |
512 |
static|STATIC) |
static|STATIC) |
513 |
${CURS_UP} |
${CURS_UP} |
514 |
${SET_WWCOL} |
${SET_WWCOL} |
515 |
echo "[STATIC]" |
rc_echo "[STATIC]" |
516 |
ifconfig "${iface}" "${IP}" netmask "${NETMASK}" broadcast "${BROADCAST}" |
ifconfig "${iface}" "${IP}" netmask "${NETMASK}" broadcast "${BROADCAST}" |
517 |
evaluate_retval |
evaluate_retval |
518 |
;; |
;; |
521 |
# setup def gw |
# setup def gw |
522 |
if [[ -n ${GATEWAY} ]] |
if [[ -n ${GATEWAY} ]] |
523 |
then |
then |
524 |
echo -e ${COLOREDSTAR}"Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..." |
525 |
route add default gateway ${GATEWAY} metric 1 dev ${iface} |
route add default gateway "${GATEWAY}" metric 1 dev "${iface}" |
526 |
evaluate_retval |
evaluate_retval |
527 |
|
|
528 |
unset GATEWAY |
unset GATEWAY |
529 |
fi |
fi |
530 |
|
|
531 |
# setup /etc/resolv.conf |
# setup /etc/resolv.conf |
532 |
|
# add given nameserver |
533 |
if [[ -n ${NAMESERVER} ]] |
if [[ -n ${NAMESERVER} ]] |
534 |
then |
then |
535 |
echo -e ${COLOREDSTAR}"Setting up all nameserver for ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Setting up all nameserver for ${COLBLUE}${iface}${COLDEFAULT} ..." |
536 |
|
|
537 |
# whipe out the old one |
# wipe out the old one |
538 |
echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf |
echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf |
539 |
|
# include head |
540 |
|
if [ -f /etc/resolv.conf.head ] |
541 |
|
then |
542 |
|
cat /etc/resolv.conf.head >> /etc/resolv.conf |
543 |
|
else |
544 |
|
echo "# /etc/resolv.conf.head can replace this line" >> /etc/resolv.conf |
545 |
|
fi |
546 |
|
|
547 |
for dns in ${NAMESERVER} |
for dns in ${NAMESERVER} |
548 |
do |
do |
549 |
echo "nameserver ${dns}" >> /etc/resolv.conf |
echo "nameserver ${dns}" >> /etc/resolv.conf |
550 |
done |
done |
551 |
|
|
552 |
|
# include tail |
553 |
|
if [ -f /etc/resolv.conf.tail ] |
554 |
|
then |
555 |
|
cat /etc/resolv.conf.tail >> /etc/resolv.conf |
556 |
|
else |
557 |
|
echo "# /etc/resolv.conf.tail can replace this line" >> /etc/resolv.conf |
558 |
|
fi |
559 |
|
|
560 |
unset NAMESERVER |
unset NAMESERVER |
561 |
fi |
fi |
562 |
done |
done |
569 |
{ |
{ |
570 |
if [[ -z $1 ]] |
if [[ -z $1 ]] |
571 |
then |
then |
572 |
ALL_INTERFACES=$(onboot_interface_list ${network_settings}/net.*) |
ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*) |
573 |
else |
else |
574 |
if [[ -e ${network_settings}/net.$1 ]] |
if [[ -e ${rc_network_settings}/net.$1 ]] |
575 |
then |
then |
576 |
ALL_INTERFACES="$1" |
ALL_INTERFACES="$1" |
577 |
else |
else |
578 |
${FAILURE} |
${FAILURE} |
579 |
echo "Interface $1 does not exist. Aborting" |
rc_echo "Interface $1 does not exist. Aborting" |
580 |
${NORMAL} |
${NORMAL} |
581 |
exit 1 |
exit 1 |
582 |
fi |
fi |
585 |
# get list of all devices |
# get list of all devices |
586 |
for iface in ${ALL_INTERFACES} |
for iface in ${ALL_INTERFACES} |
587 |
do |
do |
588 |
source ${network_settings}/net.${iface} || exit 1 |
source ${rc_network_settings}/net.${iface} || exit 1 |
589 |
checkconfig |
checkconfig |
590 |
|
|
591 |
if [[ -n ${GATEWAY} ]] |
if [[ -n ${GATEWAY} ]] |
592 |
then |
then |
593 |
echo -e ${COLOREDSTAR}"Removing default gateway ..." |
rc_print "Removing default gateway ..." |
594 |
route del -net default |
route del -net default |
595 |
evaluate_retval |
evaluate_retval |
596 |
fi |
fi |
597 |
|
|
598 |
echo -e ${COLOREDSTAR}"Bringing down interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Bringing down interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
599 |
ifconfig ${iface} down |
ifconfig "${iface}" down |
600 |
evaluate_retval |
evaluate_retval |
601 |
|
|
602 |
# remove bridges |
# remove bridges |
603 |
if [[ ${iface} = br[0-9]* ]] |
if [[ ${iface} = br[0-9]* ]] |
604 |
then |
then |
605 |
config_bridge_devices ${iface} remove |
config_bridge_devices "${iface}" remove |
606 |
fi |
fi |
607 |
|
|
608 |
# shutdown dhcp-daemon |
# shutdown dhcp-daemon |
609 |
if [[ ${NETWORKING} = dhcp ]] && [[ -n $(pidof ${DHCP_PROG}) ]] |
if [[ ${NETWORKING} = dhcp ]] && [[ -n $(pidof $(basename ${DHCP_PROG})) ]] |
610 |
then |
then |
611 |
echo -e ${COLOREDSTAR}"Stopping the dhcp-daemon ..." |
rc_print "Stopping the dhcp-daemon ..." |
612 |
${CURS_UP} |
${CURS_UP} |
613 |
${SET_WWCOL} |
${SET_WWCOL} |
614 |
echo "[$(basename ${DHCP_PROG})]" |
rc_echo "[$(basename ${DHCP_PROG})]" |
615 |
${DHCP_PROG} ${DHCP_STOP} "${iface}" |
if [[ -z ${DHCP_STOP} ]] |
616 |
evaluate_retval |
then |
617 |
|
killproc ${DHCP_PROG} |
618 |
|
evaluate_retval |
619 |
|
else |
620 |
|
${DHCP_PROG} ${DHCP_STOP} "${iface}" |
621 |
|
evaluate_retval |
622 |
|
fi |
623 |
fi |
fi |
624 |
|
|
625 |
# shutdown wpa_supplicant daemon |
# shutdown wpa_supplicant daemon |
630 |
done |
done |
631 |
|
|
632 |
# remove state dir |
# remove state dir |
633 |
if [ -d /var/run/wpa_supplicant ] |
if [ -d /run/wpa_supplicant ] |
634 |
then |
then |
635 |
rm -rf /var/run/wpa_supplicant |
rm -rf /run/wpa_supplicant |
636 |
fi |
fi |
637 |
|
|
638 |
# delete user routes |
# delete user routes |
659 |
;; |
;; |
660 |
|
|
661 |
*) |
*) |
662 |
echo "Usage: $0 {start|stop|restart} [interface]" |
rc_echo "Usage: $0 {start|stop|restart} [interface]" |
663 |
exit 1 |
exit 1 |
664 |
;; |
;; |
665 |
esac |
esac |