64 |
|
|
65 |
local BRIDGE_INTERFACES |
local BRIDGE_INTERFACES |
66 |
local BRIDGE_STP |
local BRIDGE_STP |
67 |
|
local BRIDGE_AGEING_TIME |
68 |
|
local BRIDGE_PRIORITY |
69 |
|
local BRIDGE_FORWARD_DELAY |
70 |
|
local BRIDGE_HELLO_TIME |
71 |
|
local BRIDGE_MAX_MESSAGE_AGE |
72 |
|
local BRIDGE_PATH_COST |
73 |
|
local BRIDGE_PORT_PRIORITY |
74 |
|
|
75 |
source ${file} |
source ${file} |
76 |
eval value=\$$(echo ${var}) |
eval value=\$$(echo ${var}) |
81 |
{ |
{ |
82 |
if [[ -z ${NETWORKING} ]] |
if [[ -z ${NETWORKING} ]] |
83 |
then |
then |
84 |
rc_echo "NETWORKING missing in net.${interface}, aborted" |
rc_echo "NETWORKING missing in net.${iface}, aborted" |
85 |
exit 1 |
exit 1 |
86 |
fi |
fi |
87 |
|
|
89 |
static) |
static) |
90 |
if [[ -z ${IP} ]] |
if [[ -z ${IP} ]] |
91 |
then |
then |
92 |
rc_echo "IP missing in net.${interface}, aborted" |
rc_echo "IP missing in net.${iface}, aborted" |
93 |
exit 1 |
exit 1 |
94 |
fi |
fi |
95 |
|
|
96 |
if [[ -z ${NETMASK} ]] |
if [[ -z ${NETMASK} ]] |
97 |
then |
then |
98 |
rc_echo -n "NETMASK missing in net.${interface}, " |
rc_echo -n "NETMASK missing in net.${iface}, " |
99 |
rc_echo "using 255.255.255.0" |
rc_echo "using 255.255.255.0" |
100 |
NETMASK=255.255.255.0 |
NETMASK=255.255.255.0 |
101 |
fi |
fi |
102 |
|
|
103 |
if [[ -z ${BROADCAST} ]] |
if [[ -z ${BROADCAST} ]] |
104 |
then |
then |
105 |
rc_echo -n "BROADCAST missing in net.${interface}, " |
rc_echo -n "BROADCAST missing in net.${iface}, " |
106 |
rc_echo "using default address" |
rc_echo "using default address" |
107 |
fi |
fi |
108 |
;; |
;; |
110 |
dhcp) |
dhcp) |
111 |
if [[ -z ${DHCP_PROG} ]] |
if [[ -z ${DHCP_PROG} ]] |
112 |
then |
then |
113 |
rc_echo "DHCP_PROG missing in net.${interface}, aborted" |
rc_echo -n "DHCP_PROG missing in net.${iface}," |
114 |
exit 1 |
rc_echo "using default programm /sbin/udhcpc" |
115 |
fi |
DHCP_PROG="/sbin/udhcpc" |
116 |
|
fi |
117 |
|
[[ -z ${DHCP_START} ]] && DHCP_START="-T10" |
118 |
|
[[ -z ${DHCP_STOP} ]] && DHCP_STOP="" |
119 |
;; |
;; |
120 |
|
|
121 |
esac |
esac |
131 |
# get list of all devices |
# get list of all devices |
132 |
for file in $@ |
for file in $@ |
133 |
do |
do |
134 |
|
iface="$(basename ${file} | sed s/net.//)" |
135 |
|
|
136 |
|
# exclude backup files and exclude net.routes and net.sample too |
137 |
|
case "${iface}" in |
138 |
|
*~) continue ;; |
139 |
|
routes) continue ;; |
140 |
|
sample) continue ;; |
141 |
|
esac |
142 |
|
|
143 |
if [[ $(read_value ONBOOT ${file}) = yes ]] |
if [[ $(read_value ONBOOT ${file}) = yes ]] |
144 |
then |
then |
145 |
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 |
|
146 |
fi |
fi |
147 |
done |
done |
148 |
|
|
195 |
# check the configuration |
# check the configuration |
196 |
[[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant.auto |
[[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant.auto |
197 |
[[ -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 |
198 |
if [[ -z ${WIRELESS_WPA_DRIVER} ]] |
|
199 |
then |
# use wext as default driver, do not abort here anymore |
200 |
rc_echo "WPA: WIRELESS_WPA_DRIVER given. Aborting setup." |
[[ -z ${WIRELESS_WPA_DRIVER} ]] && WIRELESS_WPA_DRIVER=wext |
|
return 1 |
|
|
fi |
|
201 |
|
|
202 |
# write a config with the settings from net.${iface} |
# write a config with the settings from net.${iface} |
203 |
# only wpa-psk ! all other needs manual setup |
# only wpa-psk ! all other needs manual setup |
206 |
# write default cfg from skeleton |
# write default cfg from skeleton |
207 |
cat ${WIRELESS_WPA_SKEL} > ${WIRELESS_WPA_CONFIG} |
cat ${WIRELESS_WPA_SKEL} > ${WIRELESS_WPA_CONFIG} |
208 |
|
|
209 |
|
local wpa_proto |
210 |
|
case ${WIRELESS_AUTH_MODE} in |
211 |
|
wpa) wpa_proto="WPA" ;; |
212 |
|
wpa2) wpa_proto="WPA2" ;; |
213 |
|
esac |
214 |
|
|
215 |
# setup the network entry |
# setup the network entry |
216 |
sed -i -e "s:@WIRELESS_ESSID@:${WIRELESS_ESSID}:g" \ |
sed -i -e "s:@WIRELESS_ESSID@:${WIRELESS_ESSID}:g" \ |
217 |
-e "s:@WIRELESS_KEY@:${WIRELESS_KEY}:g" \ |
-e "s:@WIRELESS_KEY@:${WIRELESS_KEY_ASCII}:g" \ |
218 |
|
-e "s:@WIRELESS_AUTH_MODE@:${wpa_proto}:g" \ |
219 |
${WIRELESS_WPA_CONFIG} |
${WIRELESS_WPA_CONFIG} |
220 |
fi |
fi |
221 |
|
|
263 |
[[ -n ${WIRELESS_NICK} ]] && iwconfig "${iface}" nick "${WIRELESS_NICK}" |
[[ -n ${WIRELESS_NICK} ]] && iwconfig "${iface}" nick "${WIRELESS_NICK}" |
264 |
|
|
265 |
case "${WIRELESS_AUTH_MODE}" in |
case "${WIRELESS_AUTH_MODE}" in |
266 |
wpa) config_wireless_wpa "${iface}" ;; |
wpa|wpa2) config_wireless_wpa "${iface}" ;; |
267 |
wep|on) config_wireless_wep "${iface}" ;; |
wep|on) config_wireless_wep "${iface}" ;; |
268 |
off) iwconfig "${iface}" enc off ;; |
off) iwconfig "${iface}" enc off ;; |
269 |
esac |
esac |
270 |
} |
} |
271 |
|
|
272 |
|
config_bridge_options() |
273 |
|
{ |
274 |
|
local iface="$1" |
275 |
|
local i |
276 |
|
local port |
277 |
|
local cost |
278 |
|
local prio |
279 |
|
|
280 |
|
# enable spanning-tree protocol |
281 |
|
case ${BRIDGE_STP} in |
282 |
|
on|off) brctl stp "${iface}" "${BRIDGE_STP}" ;; |
283 |
|
*) rc_echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;; |
284 |
|
esac |
285 |
|
|
286 |
|
# configure ageing time |
287 |
|
if [[ ! -z ${BRIDGE_AGEING_TIME} ]] |
288 |
|
then |
289 |
|
brctl setageing "${iface}" "${BRIDGE_AGEING_TIME}" |
290 |
|
fi |
291 |
|
|
292 |
|
# configure bridge priority |
293 |
|
if [[ ! -z ${BRIDGE_PRIORITY} ]] |
294 |
|
then |
295 |
|
brctl setbridgeprio "${iface}" "${BRIDGE_PRIORITY}" |
296 |
|
fi |
297 |
|
|
298 |
|
# configure forward delay |
299 |
|
if [[ ! -z ${BRIDGE_FORWARD_DELAY} ]] |
300 |
|
then |
301 |
|
brctl setfd "${iface}" "${BRIDGE_FORWARD_DELAY}" |
302 |
|
fi |
303 |
|
|
304 |
|
# configure hello time |
305 |
|
if [[ ! -z ${BRIDGE_HELLO_TIME} ]] |
306 |
|
then |
307 |
|
brctl sethello "${iface}" "${BRIDGE_HELLO_TIME}" |
308 |
|
fi |
309 |
|
|
310 |
|
# configure maximal message age |
311 |
|
if [[ ! -z ${BRIDGE_MAX_MESSAGE_AGE} ]] |
312 |
|
then |
313 |
|
brctl setmaxage "${iface}" "${BRIDGE_MAX_MESSAGE_AGE}" |
314 |
|
fi |
315 |
|
|
316 |
|
# configure path cost for every port |
317 |
|
if [[ ! -z ${BRIDGE_PATH_COST} ]] |
318 |
|
then |
319 |
|
for i in ${BRIDGE_PATH_COST} |
320 |
|
do |
321 |
|
port="${i%=*}" |
322 |
|
cost="${i#*=}" |
323 |
|
[[ ! -z ${port} ]] && brctl pathcost "${iface}" "${port}" "${cost}" |
324 |
|
done |
325 |
|
fi |
326 |
|
|
327 |
|
# configure port priority for every port |
328 |
|
if [[ ! -z ${BRIDGE_PORT_PRIORITY} ]] |
329 |
|
then |
330 |
|
for i in ${BRIDGE_PORT_PRIORITY} |
331 |
|
do |
332 |
|
port="${i%=*}" |
333 |
|
prio="${i#*=}" |
334 |
|
[[ ! -z ${port} ]] && brctl setportprio "${iface}" "${port}" "${prio}" |
335 |
|
done |
336 |
|
fi |
337 |
|
} |
338 |
|
|
339 |
config_bridge_devices() |
config_bridge_devices() |
340 |
{ |
{ |
341 |
local iface="$1" |
local iface="$1" |
371 |
case ${method} in |
case ${method} in |
372 |
add) |
add) |
373 |
# setup the bridge device |
# setup the bridge device |
374 |
brctl addbr ${iface} |
brctl addbr "${iface}" |
375 |
for bport in ${BRIDGE_INTERFACES} |
for bport in ${BRIDGE_INTERFACES} |
376 |
do |
do |
377 |
# enter promiscous mode |
# enter promiscous mode |
378 |
ifconfig ${bport} 0.0.0.0 promisc |
ifconfig "${bport}" 0.0.0.0 promisc |
379 |
# now setup the bridge |
# now setup the bridge |
380 |
brctl addif ${iface} ${bport} |
brctl addif "${iface}" "${bport}" |
381 |
done |
done |
382 |
# enable spanning-tree protocol |
# configure all other options |
383 |
case ${BRIDGE_STP} in |
config_bridge_options "${iface}" |
|
on|off) brctl stp ${iface} ${BRIDGE_STP} ;; |
|
|
*) rc_echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;; |
|
|
esac |
|
384 |
;; |
;; |
385 |
|
|
386 |
remove) |
remove) |
387 |
for bport in ${BRIDGE_INTERFACE} |
for bport in ${BRIDGE_INTERFACE} |
388 |
do |
do |
389 |
# bring the interface down |
# bring the interface down |
390 |
ifconfig ${bport} down |
ifconfig "${bport}" down |
391 |
# remove the interface from the bridge |
# remove the interface from the bridge |
392 |
brctl delif ${iface} ${bport} |
brctl delif "${iface}" "${bport}" |
393 |
done |
done |
394 |
# bring the bridge down |
# bring the bridge down |
395 |
brctl delbr ${iface} |
brctl delbr "${iface}" |
396 |
;; |
;; |
397 |
esac |
esac |
398 |
|
|
408 |
|
|
409 |
# only add and del are allowed |
# only add and del are allowed |
410 |
case ${method} in |
case ${method} in |
411 |
add) message="Adding route ${COLBLUE}${route}${COLDEFAULT} ..." ;; |
add) message="Adding" ;; |
412 |
del) message="Removing route ${COLBLUE}${route}${COLDEFAULT} ..." ;; |
del) message="Removing" ;; |
413 |
*) |
*) |
414 |
rc_echo "config_routes: unsupported \$method '${method}'." |
rc_echo "config_routes: unsupported \$method '${method}'." |
415 |
exit 1 |
exit 1 |
425 |
case "${route}" in |
case "${route}" in |
426 |
\#*|"") continue ;; |
\#*|"") continue ;; |
427 |
esac |
esac |
428 |
rc_print "${message}" |
rc_print "${message} route ${COLBLUE}${route}${COLDEFAULT} ..." |
429 |
route ${method} ${route} |
# do not esacpe ${route} or it breaks! |
430 |
|
route "${method}" ${route} |
431 |
evaluate_retval |
evaluate_retval |
432 |
done |
done |
433 |
fi |
fi |
439 |
|
|
440 |
if [[ -z $1 ]] |
if [[ -z $1 ]] |
441 |
then |
then |
442 |
ALL_INTERFACES=$(onboot_interface_list ${network_settings}/net.*) |
ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*) |
443 |
else |
else |
444 |
if [[ -e ${network_settings}/net.$1 ]] |
if [[ -e ${rc_network_settings}/net.$1 ]] |
445 |
then |
then |
446 |
ALL_INTERFACES="$1" |
ALL_INTERFACES="$1" |
447 |
else |
else |
456 |
for iface in ${ALL_INTERFACES} |
for iface in ${ALL_INTERFACES} |
457 |
do |
do |
458 |
# checkconfig |
# checkconfig |
459 |
source ${network_settings}/net.${iface} || exit 1 |
source ${rc_network_settings}/net.${iface} || exit 1 |
460 |
checkconfig |
checkconfig |
461 |
|
|
462 |
# setup mac |
# setup mac |
463 |
if [ -n "${FORCE_MAC_TO}" ] |
if [[ -n ${FORCE_MAC_TO} ]] |
464 |
then |
then |
465 |
rc_print "Faking MAC to ${FORCE_MAC_TO} for ${COLBLUE}${iface}${COLDEFAULT} ... " |
rc_print "Faking MAC to ${FORCE_MAC_TO} for ${COLBLUE}${iface}${COLDEFAULT} ... " |
466 |
ifconfig "${iface}" hw ether "${FORCE_MAC_TO}" |
ifconfig "${iface}" hw ether "${FORCE_MAC_TO}" |
470 |
# setup bridges |
# setup bridges |
471 |
if [[ ${iface} = br[0-9]* ]] |
if [[ ${iface} = br[0-9]* ]] |
472 |
then |
then |
473 |
config_bridge_devices ${iface} add |
config_bridge_devices "${iface}" add |
474 |
fi |
fi |
475 |
|
|
|
# activate the interface |
|
|
ifconfig "${iface}" up |
|
|
|
|
476 |
# now configure wireless_extensions |
# now configure wireless_extensions |
477 |
[ -x /usr/sbin/iwconfig ] && setup_wireless_extensions "${iface}" |
[ -x /usr/sbin/iwconfig ] && setup_wireless_extensions "${iface}" |
478 |
|
|
479 |
rc_print "Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
480 |
|
|
481 |
|
# activate the interface |
482 |
|
ifconfig "${iface}" up |
483 |
|
|
484 |
# setup static or dhcp |
# setup static or dhcp |
485 |
case ${NETWORKING} in |
case ${NETWORKING} in |
486 |
dhcp|DHCP) |
dhcp|DHCP) |
502 |
if [[ -n ${GATEWAY} ]] |
if [[ -n ${GATEWAY} ]] |
503 |
then |
then |
504 |
rc_print "Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..." |
505 |
route add default gateway ${GATEWAY} metric 1 dev ${iface} |
route add default gateway "${GATEWAY}" metric 1 dev "${iface}" |
506 |
evaluate_retval |
evaluate_retval |
507 |
|
|
508 |
unset GATEWAY |
unset GATEWAY |
509 |
fi |
fi |
510 |
|
|
511 |
# setup /etc/resolv.conf |
# setup /etc/resolv.conf |
512 |
|
# add given nameserver |
513 |
if [[ -n ${NAMESERVER} ]] |
if [[ -n ${NAMESERVER} ]] |
514 |
then |
then |
515 |
rc_print "Setting up all nameserver for ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Setting up all nameserver for ${COLBLUE}${iface}${COLDEFAULT} ..." |
516 |
|
|
517 |
# whipe out the old one |
# whipe out the old one |
518 |
echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf |
echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf |
519 |
|
# include head |
520 |
|
if [ -f /etc/resolv.conf.head ] |
521 |
|
then |
522 |
|
cat /etc/resolv.conf.head >> /etc/resolv.conf |
523 |
|
else |
524 |
|
echo "# /etc/resolv.conf.head can replace this line" >> /etc/resolv.conf |
525 |
|
fi |
526 |
|
|
527 |
for dns in ${NAMESERVER} |
for dns in ${NAMESERVER} |
528 |
do |
do |
529 |
echo "nameserver ${dns}" >> /etc/resolv.conf |
echo "nameserver ${dns}" >> /etc/resolv.conf |
530 |
done |
done |
531 |
|
|
532 |
|
# include tail |
533 |
|
if [ -f /etc/resolv.conf.tail ] |
534 |
|
then |
535 |
|
cat /etc/resolv.conf.tail >> /etc/resolv.conf |
536 |
|
else |
537 |
|
echo "# /etc/resolv.conf.tail can replace this line" >> /etc/resolv.conf |
538 |
|
fi |
539 |
|
|
540 |
unset NAMESERVER |
unset NAMESERVER |
541 |
fi |
fi |
542 |
done |
done |
549 |
{ |
{ |
550 |
if [[ -z $1 ]] |
if [[ -z $1 ]] |
551 |
then |
then |
552 |
ALL_INTERFACES=$(onboot_interface_list ${network_settings}/net.*) |
ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*) |
553 |
else |
else |
554 |
if [[ -e ${network_settings}/net.$1 ]] |
if [[ -e ${rc_network_settings}/net.$1 ]] |
555 |
then |
then |
556 |
ALL_INTERFACES="$1" |
ALL_INTERFACES="$1" |
557 |
else |
else |
565 |
# get list of all devices |
# get list of all devices |
566 |
for iface in ${ALL_INTERFACES} |
for iface in ${ALL_INTERFACES} |
567 |
do |
do |
568 |
source ${network_settings}/net.${iface} || exit 1 |
source ${rc_network_settings}/net.${iface} || exit 1 |
569 |
checkconfig |
checkconfig |
570 |
|
|
571 |
if [[ -n ${GATEWAY} ]] |
if [[ -n ${GATEWAY} ]] |
576 |
fi |
fi |
577 |
|
|
578 |
rc_print "Bringing down interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Bringing down interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
579 |
ifconfig ${iface} down |
ifconfig "${iface}" down |
580 |
evaluate_retval |
evaluate_retval |
581 |
|
|
582 |
# remove bridges |
# remove bridges |
583 |
if [[ ${iface} = br[0-9]* ]] |
if [[ ${iface} = br[0-9]* ]] |
584 |
then |
then |
585 |
config_bridge_devices ${iface} remove |
config_bridge_devices "${iface}" remove |
586 |
fi |
fi |
587 |
|
|
588 |
# shutdown dhcp-daemon |
# shutdown dhcp-daemon |
589 |
if [[ ${NETWORKING} = dhcp ]] && [[ -n $(pidof ${DHCP_PROG}) ]] |
if [[ ${NETWORKING} = dhcp ]] && [[ -n $(pidof $(basename ${DHCP_PROG})) ]] |
590 |
then |
then |
591 |
rc_print "Stopping the dhcp-daemon ..." |
rc_print "Stopping the dhcp-daemon ..." |
592 |
${CURS_UP} |
${CURS_UP} |
593 |
${SET_WWCOL} |
${SET_WWCOL} |
594 |
rc_echo "[$(basename ${DHCP_PROG})]" |
rc_echo "[$(basename ${DHCP_PROG})]" |
595 |
${DHCP_PROG} ${DHCP_STOP} "${iface}" |
if [[ -z ${DHCP_STOP} ]] |
596 |
evaluate_retval |
then |
597 |
|
killproc ${DHCP_PROG} |
598 |
|
evaluate_retval |
599 |
|
else |
600 |
|
${DHCP_PROG} ${DHCP_STOP} "${iface}" |
601 |
|
evaluate_retval |
602 |
|
fi |
603 |
fi |
fi |
604 |
|
|
605 |
# shutdown wpa_supplicant daemon |
# shutdown wpa_supplicant daemon |
639 |
;; |
;; |
640 |
|
|
641 |
*) |
*) |
642 |
echo "Usage: $0 {start|stop|restart} [interface]" |
rc_echo "Usage: $0 {start|stop|restart} [interface]" |
643 |
exit 1 |
exit 1 |
644 |
;; |
;; |
645 |
esac |
esac |