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 |
|
iface_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 |
|
iface_has_link() |
34 |
|
{ |
35 |
|
local interface="$1" |
36 |
|
local flags |
37 |
|
|
38 |
|
[[ -n ${interface} ]] || return 2 |
39 |
|
interface="/sys/class/net/${interface}" |
40 |
|
[[ -d ${interface} ]] || return 2 |
41 |
|
flags=$(cat ${interface}/flags) |
42 |
|
echo $((${flags}|0x41)) > ${interface}/flags # 0x41: IFF_UP|IFF_RUNNING |
43 |
|
[ "$(cat ${interface}/carrier)" = 1 ] || return 1 |
44 |
|
} |
45 |
|
|
46 |
# read values from files |
# read values from files |
47 |
read_value() |
read_value() |
94 |
|
|
95 |
local BRIDGE_INTERFACES |
local BRIDGE_INTERFACES |
96 |
local BRIDGE_STP |
local BRIDGE_STP |
97 |
|
local BRIDGE_AGEING_TIME |
98 |
|
local BRIDGE_PRIORITY |
99 |
|
local BRIDGE_FORWARD_DELAY |
100 |
|
local BRIDGE_HELLO_TIME |
101 |
|
local BRIDGE_MAX_MESSAGE_AGE |
102 |
|
local BRIDGE_PATH_COST |
103 |
|
local BRIDGE_PORT_PRIORITY |
104 |
|
|
105 |
source ${file} |
source ${file} |
106 |
eval value=\$$(echo ${var}) |
eval value=\$$(echo ${var}) |
111 |
{ |
{ |
112 |
if [[ -z ${NETWORKING} ]] |
if [[ -z ${NETWORKING} ]] |
113 |
then |
then |
114 |
echo "NETWORKING missing in net.${interface}, aborted" |
rc_echo "NETWORKING missing in net.${iface}, aborted" |
115 |
exit 1 |
exit 1 |
116 |
fi |
fi |
117 |
|
|
119 |
static) |
static) |
120 |
if [[ -z ${IP} ]] |
if [[ -z ${IP} ]] |
121 |
then |
then |
122 |
echo "IP missing in net.${interface}, aborted" |
rc_echo "IP missing in net.${iface}, aborted" |
123 |
exit 1 |
exit 1 |
124 |
fi |
fi |
125 |
|
|
126 |
if [[ -z ${NETMASK} ]] |
if [[ -z ${NETMASK} ]] |
127 |
then |
then |
128 |
echo -n "NETMASK missing in net.${interface}, " |
rc_echo -n "NETMASK missing in net.${iface}, " |
129 |
echo "using 255.255.255.0" |
rc_echo "using ${DEFAULT_NETMASK}" |
130 |
NETMASK=255.255.255.0 |
NETMASK="${DEFAULT_NETMASK}" |
131 |
fi |
fi |
132 |
|
|
133 |
if [[ -z ${BROADCAST} ]] |
if [[ -z ${BROADCAST} ]] |
134 |
then |
then |
135 |
echo -n "BROADCAST missing in net.${interface}, " |
rc_echo -n "BROADCAST missing in net.${iface}, " |
136 |
echo "using default address" |
rc_echo "using default address" |
137 |
fi |
fi |
138 |
;; |
;; |
139 |
|
|
140 |
dhcp) |
dhcp) |
141 |
if [[ -z ${DHCP_PROG} ]] |
if [[ -z ${DHCP_PROG} ]] |
142 |
then |
then |
143 |
echo "DHCP_PROG missing in net.${interface}, aborted" |
rc_echo -n "DHCP_PROG missing in net.${iface}," |
144 |
exit 1 |
rc_echo "using default programm ${DEFAULT_DHCP_PROG}" |
145 |
|
DHCP_PROG="${DEFAULT_DHCP_PROG}" |
146 |
fi |
fi |
147 |
|
[[ -z ${DHCP_START} ]] && DHCP_START="${DEFAULT_DHCP_START}" |
148 |
|
[[ -z ${DHCP_STOP} ]] && DHCP_STOP="${DEFAULT_DHCP_STOP}" |
149 |
;; |
;; |
150 |
|
|
151 |
esac |
esac |
161 |
# get list of all devices |
# get list of all devices |
162 |
for file in $@ |
for file in $@ |
163 |
do |
do |
164 |
|
iface="$(basename ${file} | sed s/net.//)" |
165 |
|
|
166 |
|
# exclude backup files and exclude net.routes and net.sample too |
167 |
|
case "${iface}" in |
168 |
|
*~) continue ;; |
169 |
|
routes) continue ;; |
170 |
|
sample) continue ;; |
171 |
|
esac |
172 |
|
|
173 |
if [[ $(read_value ONBOOT ${file}) = yes ]] |
if [[ $(read_value ONBOOT ${file}) = yes ]] |
174 |
then |
then |
175 |
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 |
|
176 |
fi |
fi |
177 |
done |
done |
178 |
|
|
185 |
|
|
186 |
if [[ -z ${iface} ]] |
if [[ -z ${iface} ]] |
187 |
then |
then |
188 |
echo "WEP: no \$iface given. Aborting setup." |
rc_echo "WEP: no \$iface given. Aborting setup." |
189 |
return 1 |
return 1 |
190 |
fi |
fi |
191 |
|
|
192 |
${CURS_UP} |
${CURS_UP} |
193 |
${SET_WWCOL} |
${SET_WWCOL} |
194 |
echo "[AUTH: WEP]" |
rc_echo "[AUTH: WEP]" |
195 |
|
|
196 |
iwconfig "${iface}" enc on |
iwconfig "${iface}" enc on |
197 |
[[ -n ${WIRELESS_KEY_LENGTH} ]] && iwconfig "${iface}" enc "${WIRELESS_KEY_LENGTH}" |
[[ -n ${WIRELESS_KEY_LENGTH} ]] && iwconfig "${iface}" enc "${WIRELESS_KEY_LENGTH}" |
205 |
|
|
206 |
if [[ -z ${iface} ]] |
if [[ -z ${iface} ]] |
207 |
then |
then |
208 |
echo "WPA: no \$iface given. Aborting setup." |
rc_echo "WPA: no \$iface given. Aborting setup." |
209 |
return 1 |
return 1 |
210 |
fi |
fi |
211 |
|
|
212 |
if [ ! -x /sbin/wpa_supplicant ] |
if [ ! -x $(type -P wpa_supplicant) ] |
213 |
then |
then |
214 |
echo "WPA: wpa_supplicant not installed. Aborting setup." |
rc_echo "WPA: wpa_supplicant not installed. Aborting setup." |
215 |
return 1 |
return 1 |
216 |
fi |
fi |
217 |
|
|
218 |
${CURS_UP} |
${CURS_UP} |
219 |
${SET_WWCOL} |
${SET_WWCOL} |
220 |
echo "[AUTH: WPA]" |
rc_echo "[AUTH: WPA]" |
221 |
|
|
222 |
# get default settings |
# get default settings |
223 |
[[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant |
[[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant |
224 |
|
|
225 |
# check the configuration |
# check the configuration |
226 |
[[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant.auto |
[[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant/wpa_supplicant.auto |
227 |
[[ -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 |
228 |
|
|
229 |
# use wext as default driver, do not abort here anymore |
# use wext as default driver, do not abort here anymore |
250 |
fi |
fi |
251 |
|
|
252 |
# remove old state dir |
# remove old state dir |
253 |
[ -d /var/run/wpa_supplicant ] && rm -rf /var/run/wpa_supplicant |
[ -d /run/wpa_supplicant ] && rm -rf /run/wpa_supplicant |
254 |
|
|
255 |
# now run the wpa_supplicant dameon |
# now run the wpa_supplicant dameon |
256 |
wpa_supplicant -B \ |
wpa_supplicant -B \ |
260 |
${WIRELESS_WPA_OPTS} |
${WIRELESS_WPA_OPTS} |
261 |
|
|
262 |
# echo wait 5 seconds |
# echo wait 5 seconds |
263 |
echo " Waiting 5 seconds to retrieve authentification reply ... " |
rc_echo " Waiting 5 seconds to retrieve authentification reply ... " |
264 |
sleep 5 |
sleep 5 |
265 |
} |
} |
266 |
|
|
270 |
|
|
271 |
if [[ -z ${iface} ]] |
if [[ -z ${iface} ]] |
272 |
then |
then |
273 |
echo "WIRELESS_EXTENSIONS: no \$iface given. Aborting setup." |
rc_echo "WIRELESS_EXTENSIONS: no \$iface given. Aborting setup." |
274 |
return 1 |
return 1 |
275 |
fi |
fi |
276 |
|
|
282 |
[[ -n ${WIRELESS_NICK} ]] || |
[[ -n ${WIRELESS_NICK} ]] || |
283 |
[[ -n ${WIRELESS_AUTH_MODE} ]] |
[[ -n ${WIRELESS_AUTH_MODE} ]] |
284 |
then |
then |
285 |
echo -e ${COLOREDSTAR}"Setting up wlan-ext for ${COLBLUE}${iface}${COLDEFAULT} ... " |
rc_print "Setting up wlan-ext for ${COLBLUE}${iface}${COLDEFAULT} ... " |
286 |
fi |
fi |
287 |
|
|
288 |
[[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}" |
[[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}" |
299 |
esac |
esac |
300 |
} |
} |
301 |
|
|
302 |
|
config_bridge_options() |
303 |
|
{ |
304 |
|
local iface="$1" |
305 |
|
local i |
306 |
|
local port |
307 |
|
local cost |
308 |
|
local prio |
309 |
|
|
310 |
|
# enable spanning-tree protocol |
311 |
|
case ${BRIDGE_STP} in |
312 |
|
on|off) brctl stp "${iface}" "${BRIDGE_STP}" ;; |
313 |
|
*) rc_echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;; |
314 |
|
esac |
315 |
|
|
316 |
|
# configure ageing time |
317 |
|
if [[ ! -z ${BRIDGE_AGEING_TIME} ]] |
318 |
|
then |
319 |
|
brctl setageing "${iface}" "${BRIDGE_AGEING_TIME}" |
320 |
|
fi |
321 |
|
|
322 |
|
# configure bridge priority |
323 |
|
if [[ ! -z ${BRIDGE_PRIORITY} ]] |
324 |
|
then |
325 |
|
brctl setbridgeprio "${iface}" "${BRIDGE_PRIORITY}" |
326 |
|
fi |
327 |
|
|
328 |
|
# configure forward delay |
329 |
|
if [[ ! -z ${BRIDGE_FORWARD_DELAY} ]] |
330 |
|
then |
331 |
|
brctl setfd "${iface}" "${BRIDGE_FORWARD_DELAY}" |
332 |
|
fi |
333 |
|
|
334 |
|
# configure hello time |
335 |
|
if [[ ! -z ${BRIDGE_HELLO_TIME} ]] |
336 |
|
then |
337 |
|
brctl sethello "${iface}" "${BRIDGE_HELLO_TIME}" |
338 |
|
fi |
339 |
|
|
340 |
|
# configure maximal message age |
341 |
|
if [[ ! -z ${BRIDGE_MAX_MESSAGE_AGE} ]] |
342 |
|
then |
343 |
|
brctl setmaxage "${iface}" "${BRIDGE_MAX_MESSAGE_AGE}" |
344 |
|
fi |
345 |
|
|
346 |
|
# configure path cost for every port |
347 |
|
if [[ ! -z ${BRIDGE_PATH_COST} ]] |
348 |
|
then |
349 |
|
for i in ${BRIDGE_PATH_COST} |
350 |
|
do |
351 |
|
port="${i%=*}" |
352 |
|
cost="${i#*=}" |
353 |
|
[[ ! -z ${port} ]] && brctl pathcost "${iface}" "${port}" "${cost}" |
354 |
|
done |
355 |
|
fi |
356 |
|
|
357 |
|
# configure port priority for every port |
358 |
|
if [[ ! -z ${BRIDGE_PORT_PRIORITY} ]] |
359 |
|
then |
360 |
|
for i in ${BRIDGE_PORT_PRIORITY} |
361 |
|
do |
362 |
|
port="${i%=*}" |
363 |
|
prio="${i#*=}" |
364 |
|
[[ ! -z ${port} ]] && brctl setportprio "${iface}" "${port}" "${prio}" |
365 |
|
done |
366 |
|
fi |
367 |
|
} |
368 |
|
|
369 |
config_bridge_devices() |
config_bridge_devices() |
370 |
{ |
{ |
371 |
local iface="$1" |
local iface="$1" |
374 |
|
|
375 |
if [[ -z ${iface} ]] |
if [[ -z ${iface} ]] |
376 |
then |
then |
377 |
echo "BRIDGE: no \$iface given. Aborting setup." |
rc_echo "BRIDGE: no \$iface given. Aborting setup." |
378 |
return 1 |
return 1 |
379 |
fi |
fi |
380 |
|
|
381 |
if [[ -z ${method} ]] |
if [[ -z ${method} ]] |
382 |
then |
then |
383 |
echo "BRIDGE: no \$method given. Aborting setup." |
rc_echo "BRIDGE: no \$method given. Aborting setup." |
384 |
return 1 |
return 1 |
385 |
fi |
fi |
386 |
|
|
387 |
# first check for brctl |
# first check for brctl |
388 |
if [[ -z $(which brctl) ]] |
if [[ -z $(type -P brctl) ]] |
389 |
then |
then |
390 |
echo "brctl not found! Please install 'net-misc/bridge-utils'." |
rc_echo "brctl not found! Please install 'net-misc/bridge-utils'." |
391 |
return 1 |
return 1 |
392 |
fi |
fi |
393 |
|
|
394 |
# check the config |
# check the config |
395 |
if [[ -z ${BRIDGE_INTERFACES} ]] |
if [[ -z ${BRIDGE_INTERFACES} ]] |
396 |
then |
then |
397 |
echo "BRIDGE: no \$BRIDGE_INTERFACES given. Aborting setup." |
rc_echo "BRIDGE: no \$BRIDGE_INTERFACES given. Aborting setup." |
398 |
return 1 |
return 1 |
399 |
fi |
fi |
400 |
|
|
401 |
case ${method} in |
case ${method} in |
402 |
add) |
add) |
403 |
# setup the bridge device |
# setup the bridge device |
404 |
brctl addbr ${iface} |
brctl addbr "${iface}" |
405 |
for bport in ${BRIDGE_INTERFACES} |
for bport in ${BRIDGE_INTERFACES} |
406 |
do |
do |
407 |
# enter promiscous mode |
# enter promiscous mode |
408 |
ifconfig ${bport} 0.0.0.0 promisc |
ifconfig "${bport}" 0.0.0.0 promisc |
409 |
# now setup the bridge |
# now setup the bridge |
410 |
brctl addif ${iface} ${bport} |
brctl addif "${iface}" "${bport}" |
411 |
done |
done |
412 |
# enable spanning-tree protocol |
# configure all other options |
413 |
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 |
|
414 |
;; |
;; |
415 |
|
|
416 |
remove) |
remove) |
417 |
for bport in ${BRIDGE_INTERFACE} |
for bport in ${BRIDGE_INTERFACE} |
418 |
do |
do |
419 |
# bring the interface down |
# bring the interface down |
420 |
ifconfig ${bport} down |
ifconfig "${bport}" down |
421 |
# remove the interface from the bridge |
# remove the interface from the bridge |
422 |
brctl delif ${iface} ${bport} |
brctl delif "${iface}" "${bport}" |
423 |
done |
done |
424 |
# bring the bridge down |
# bring the bridge down |
425 |
brctl delbr ${iface} |
brctl delbr "${iface}" |
426 |
;; |
;; |
427 |
esac |
esac |
428 |
|
|
438 |
|
|
439 |
# only add and del are allowed |
# only add and del are allowed |
440 |
case ${method} in |
case ${method} in |
441 |
add) message="Adding route ${COLBLUE}${route}${COLDEFAULT} ..." ;; |
add) message="Adding" ;; |
442 |
del) message="Removing route ${COLBLUE}${route}${COLDEFAULT} ..." ;; |
del) message="Removing" ;; |
443 |
*) |
*) |
444 |
echo "config_routes: unsupported \$method '${method}'." |
rc_echo "config_routes: unsupported \$method '${method}'." |
445 |
exit 1 |
exit 1 |
446 |
;; |
;; |
447 |
esac |
esac |
455 |
case "${route}" in |
case "${route}" in |
456 |
\#*|"") continue ;; |
\#*|"") continue ;; |
457 |
esac |
esac |
458 |
echo -e ${COLOREDSTAR}"${message}" |
rc_print "${message} route ${COLBLUE}${route}${COLDEFAULT} ..." |
459 |
route ${method} ${route} |
# do not esacpe ${route} or it breaks! |
460 |
|
route "${method}" ${route} |
461 |
evaluate_retval |
evaluate_retval |
462 |
done |
done |
463 |
fi |
fi |
469 |
|
|
470 |
if [[ -z $1 ]] |
if [[ -z $1 ]] |
471 |
then |
then |
472 |
ALL_INTERFACES=$(onboot_interface_list ${network_settings}/net.*) |
ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*) |
473 |
else |
else |
474 |
if [[ -e ${network_settings}/net.$1 ]] |
if [[ -e ${rc_network_settings}/net.$1 ]] |
475 |
then |
then |
476 |
ALL_INTERFACES="$1" |
ALL_INTERFACES="$1" |
477 |
else |
else |
478 |
${FAILURE} |
${FAILURE} |
479 |
echo "Interface $1 does not exist. Aborting" |
rc_echo "Interface $1 does not exist. Aborting" |
480 |
${NORMAL} |
${NORMAL} |
481 |
exit 1 |
exit 1 |
482 |
fi |
fi |
486 |
for iface in ${ALL_INTERFACES} |
for iface in ${ALL_INTERFACES} |
487 |
do |
do |
488 |
# checkconfig |
# checkconfig |
489 |
source ${network_settings}/net.${iface} || exit 1 |
source ${rc_network_settings}/net.${iface} || exit 1 |
490 |
checkconfig |
checkconfig |
491 |
|
|
492 |
|
# wait until the device is created |
493 |
|
iface_wait_online 5 "${iface}" || { rc_echo "device '${iface}' does not exist"; continue; } |
494 |
|
|
495 |
# setup mac |
# setup mac |
496 |
if [ -n "${FORCE_MAC_TO}" ] |
if [[ -n ${FORCE_MAC_TO} ]] |
497 |
then |
then |
498 |
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} ... " |
499 |
ifconfig "${iface}" hw ether "${FORCE_MAC_TO}" |
ifconfig "${iface}" hw ether "${FORCE_MAC_TO}" |
500 |
evaluate_retval |
evaluate_retval |
501 |
fi |
fi |
503 |
# setup bridges |
# setup bridges |
504 |
if [[ ${iface} = br[0-9]* ]] |
if [[ ${iface} = br[0-9]* ]] |
505 |
then |
then |
506 |
config_bridge_devices ${iface} add |
config_bridge_devices "${iface}" add |
507 |
fi |
fi |
508 |
|
|
509 |
# now configure wireless_extensions |
# now configure wireless_extensions |
510 |
[ -x /usr/sbin/iwconfig ] && setup_wireless_extensions "${iface}" |
[ -x $(type -P iwconfig) ] && setup_wireless_extensions "${iface}" |
511 |
|
|
512 |
echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
513 |
|
|
514 |
# activate the interface |
# activate the interface |
515 |
ifconfig "${iface}" up |
ifconfig "${iface}" up |
519 |
dhcp|DHCP) |
dhcp|DHCP) |
520 |
${CURS_UP} |
${CURS_UP} |
521 |
${SET_WWCOL} |
${SET_WWCOL} |
522 |
echo "[DHCP]" |
rc_echo "[DHCP]" |
523 |
loadproc ${DHCP_PROG} ${DHCP_START} "${iface}" |
if iface_has_link "${iface}" |
524 |
|
then |
525 |
|
loadproc ${DHCP_PROG} ${DHCP_START} "${iface}" |
526 |
|
else |
527 |
|
rc_echo "Interface '${iface}' has no link. Not running '${DHCP_PROG}'." |
528 |
|
fi |
529 |
;; |
;; |
530 |
static|STATIC) |
static|STATIC) |
531 |
${CURS_UP} |
${CURS_UP} |
532 |
${SET_WWCOL} |
${SET_WWCOL} |
533 |
echo "[STATIC]" |
rc_echo "[STATIC]" |
534 |
ifconfig "${iface}" "${IP}" netmask "${NETMASK}" broadcast "${BROADCAST}" |
ifconfig "${iface}" "${IP}" netmask "${NETMASK}" broadcast "${BROADCAST}" |
535 |
evaluate_retval |
evaluate_retval |
536 |
;; |
;; |
539 |
# setup def gw |
# setup def gw |
540 |
if [[ -n ${GATEWAY} ]] |
if [[ -n ${GATEWAY} ]] |
541 |
then |
then |
542 |
echo -e ${COLOREDSTAR}"Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..." |
543 |
route add default gateway ${GATEWAY} metric 1 dev ${iface} |
route add default gateway "${GATEWAY}" metric 1 dev "${iface}" |
544 |
evaluate_retval |
evaluate_retval |
545 |
|
|
546 |
unset GATEWAY |
unset GATEWAY |
547 |
fi |
fi |
548 |
|
|
549 |
# setup /etc/resolv.conf |
# setup /etc/resolv.conf |
550 |
|
# add given nameserver |
551 |
if [[ -n ${NAMESERVER} ]] |
if [[ -n ${NAMESERVER} ]] |
552 |
then |
then |
553 |
echo -e ${COLOREDSTAR}"Setting up all nameserver for ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Setting up all nameserver for ${COLBLUE}${iface}${COLDEFAULT} ..." |
554 |
|
|
555 |
# whipe out the old one |
# wipe out the old one |
556 |
echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf |
echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf |
557 |
|
# include head |
558 |
|
if [ -f /etc/resolv.conf.head ] |
559 |
|
then |
560 |
|
cat /etc/resolv.conf.head >> /etc/resolv.conf |
561 |
|
else |
562 |
|
echo "# /etc/resolv.conf.head can replace this line" >> /etc/resolv.conf |
563 |
|
fi |
564 |
|
|
565 |
for dns in ${NAMESERVER} |
for dns in ${NAMESERVER} |
566 |
do |
do |
567 |
echo "nameserver ${dns}" >> /etc/resolv.conf |
echo "nameserver ${dns}" >> /etc/resolv.conf |
568 |
done |
done |
569 |
|
|
570 |
|
# include tail |
571 |
|
if [ -f /etc/resolv.conf.tail ] |
572 |
|
then |
573 |
|
cat /etc/resolv.conf.tail >> /etc/resolv.conf |
574 |
|
else |
575 |
|
echo "# /etc/resolv.conf.tail can replace this line" >> /etc/resolv.conf |
576 |
|
fi |
577 |
|
|
578 |
unset NAMESERVER |
unset NAMESERVER |
579 |
fi |
fi |
580 |
done |
done |
587 |
{ |
{ |
588 |
if [[ -z $1 ]] |
if [[ -z $1 ]] |
589 |
then |
then |
590 |
ALL_INTERFACES=$(onboot_interface_list ${network_settings}/net.*) |
ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*) |
591 |
else |
else |
592 |
if [[ -e ${network_settings}/net.$1 ]] |
if [[ -e ${rc_network_settings}/net.$1 ]] |
593 |
then |
then |
594 |
ALL_INTERFACES="$1" |
ALL_INTERFACES="$1" |
595 |
else |
else |
596 |
${FAILURE} |
${FAILURE} |
597 |
echo "Interface $1 does not exist. Aborting" |
rc_echo "Interface $1 does not exist. Aborting" |
598 |
${NORMAL} |
${NORMAL} |
599 |
exit 1 |
exit 1 |
600 |
fi |
fi |
603 |
# get list of all devices |
# get list of all devices |
604 |
for iface in ${ALL_INTERFACES} |
for iface in ${ALL_INTERFACES} |
605 |
do |
do |
606 |
source ${network_settings}/net.${iface} || exit 1 |
source ${rc_network_settings}/net.${iface} || exit 1 |
607 |
checkconfig |
checkconfig |
608 |
|
|
609 |
if [[ -n ${GATEWAY} ]] |
if [[ -n ${GATEWAY} ]] |
610 |
then |
then |
611 |
echo -e ${COLOREDSTAR}"Removing default gateway ..." |
rc_print "Removing default gateway ..." |
612 |
route del -net default |
route del -net default |
613 |
evaluate_retval |
evaluate_retval |
614 |
fi |
fi |
615 |
|
|
616 |
echo -e ${COLOREDSTAR}"Bringing down interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Bringing down interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
617 |
ifconfig ${iface} down |
ifconfig "${iface}" down |
618 |
evaluate_retval |
evaluate_retval |
619 |
|
|
620 |
# remove bridges |
# remove bridges |
621 |
if [[ ${iface} = br[0-9]* ]] |
if [[ ${iface} = br[0-9]* ]] |
622 |
then |
then |
623 |
config_bridge_devices ${iface} remove |
config_bridge_devices "${iface}" remove |
624 |
fi |
fi |
625 |
|
|
626 |
# shutdown dhcp-daemon |
# shutdown dhcp-daemon |
627 |
if [[ ${NETWORKING} = dhcp ]] && [[ -n $(pidof ${DHCP_PROG}) ]] |
if [[ ${NETWORKING} = dhcp ]] && [[ -n $(pidof $(basename ${DHCP_PROG})) ]] |
628 |
then |
then |
629 |
echo -e ${COLOREDSTAR}"Stopping the dhcp-daemon ..." |
rc_print "Stopping the dhcp-daemon ..." |
630 |
${CURS_UP} |
${CURS_UP} |
631 |
${SET_WWCOL} |
${SET_WWCOL} |
632 |
echo "[$(basename ${DHCP_PROG})]" |
rc_echo "[$(basename ${DHCP_PROG})]" |
633 |
${DHCP_PROG} ${DHCP_STOP} "${iface}" |
if [[ -z ${DHCP_STOP} ]] |
634 |
evaluate_retval |
then |
635 |
|
killproc ${DHCP_PROG} |
636 |
|
evaluate_retval |
637 |
|
else |
638 |
|
${DHCP_PROG} ${DHCP_STOP} "${iface}" |
639 |
|
evaluate_retval |
640 |
|
fi |
641 |
fi |
fi |
642 |
|
|
643 |
# shutdown wpa_supplicant daemon |
# shutdown wpa_supplicant daemon |
648 |
done |
done |
649 |
|
|
650 |
# remove state dir |
# remove state dir |
651 |
if [ -d /var/run/wpa_supplicant ] |
if [ -d /run/wpa_supplicant ] |
652 |
then |
then |
653 |
rm -rf /var/run/wpa_supplicant |
rm -rf /run/wpa_supplicant |
654 |
fi |
fi |
655 |
|
|
656 |
# delete user routes |
# delete user routes |
677 |
;; |
;; |
678 |
|
|
679 |
*) |
*) |
680 |
echo "Usage: $0 {start|stop|restart} [interface]" |
rc_echo "Usage: $0 {start|stop|restart} [interface]" |
681 |
exit 1 |
exit 1 |
682 |
;; |
;; |
683 |
esac |
esac |