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="-T 10" |
118 |
|
[[ -z ${DHCP_STOP} ]] && DHCP_STOP="-k" |
119 |
;; |
;; |
120 |
|
|
121 |
esac |
esac |
192 |
# check the configuration |
# check the configuration |
193 |
[[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant.auto |
[[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant.auto |
194 |
[[ -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 |
195 |
if [[ -z ${WIRELESS_WPA_DRIVER} ]] |
|
196 |
then |
# use wext as default driver, do not abort here anymore |
197 |
rc_echo "WPA: WIRELESS_WPA_DRIVER given. Aborting setup." |
[[ -z ${WIRELESS_WPA_DRIVER} ]] && WIRELESS_WPA_DRIVER=wext |
|
return 1 |
|
|
fi |
|
198 |
|
|
199 |
# write a config with the settings from net.${iface} |
# write a config with the settings from net.${iface} |
200 |
# only wpa-psk ! all other needs manual setup |
# only wpa-psk ! all other needs manual setup |
203 |
# write default cfg from skeleton |
# write default cfg from skeleton |
204 |
cat ${WIRELESS_WPA_SKEL} > ${WIRELESS_WPA_CONFIG} |
cat ${WIRELESS_WPA_SKEL} > ${WIRELESS_WPA_CONFIG} |
205 |
|
|
206 |
|
local wpa_proto |
207 |
|
case ${WIRELESS_AUTH_MODE} in |
208 |
|
wpa) wpa_proto="WPA" ;; |
209 |
|
wpa2) wpa_proto="WPA2" ;; |
210 |
|
esac |
211 |
|
|
212 |
# setup the network entry |
# setup the network entry |
213 |
sed -i -e "s:@WIRELESS_ESSID@:${WIRELESS_ESSID}:g" \ |
sed -i -e "s:@WIRELESS_ESSID@:${WIRELESS_ESSID}:g" \ |
214 |
-e "s:@WIRELESS_KEY@:${WIRELESS_KEY}:g" \ |
-e "s:@WIRELESS_KEY@:${WIRELESS_KEY_ASCII}:g" \ |
215 |
|
-e "s:@WIRELESS_AUTH_MODE@:${wpa_proto}:g" \ |
216 |
${WIRELESS_WPA_CONFIG} |
${WIRELESS_WPA_CONFIG} |
217 |
fi |
fi |
218 |
|
|
260 |
[[ -n ${WIRELESS_NICK} ]] && iwconfig "${iface}" nick "${WIRELESS_NICK}" |
[[ -n ${WIRELESS_NICK} ]] && iwconfig "${iface}" nick "${WIRELESS_NICK}" |
261 |
|
|
262 |
case "${WIRELESS_AUTH_MODE}" in |
case "${WIRELESS_AUTH_MODE}" in |
263 |
wpa) config_wireless_wpa "${iface}" ;; |
wpa|wpa2) config_wireless_wpa "${iface}" ;; |
264 |
wep|on) config_wireless_wep "${iface}" ;; |
wep|on) config_wireless_wep "${iface}" ;; |
265 |
off) iwconfig "${iface}" enc off ;; |
off) iwconfig "${iface}" enc off ;; |
266 |
esac |
esac |
267 |
} |
} |
268 |
|
|
269 |
|
config_bridge_options() |
270 |
|
{ |
271 |
|
local iface="$1" |
272 |
|
local i |
273 |
|
local port |
274 |
|
local cost |
275 |
|
local prio |
276 |
|
|
277 |
|
# enable spanning-tree protocol |
278 |
|
case ${BRIDGE_STP} in |
279 |
|
on|off) brctl stp "${iface}" "${BRIDGE_STP}" ;; |
280 |
|
*) rc_echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;; |
281 |
|
esac |
282 |
|
|
283 |
|
# configure ageing time |
284 |
|
if [[ ! -z ${BRIDGE_AGEING_TIME} ]] |
285 |
|
then |
286 |
|
brctl setageing "${iface}" "${BRIDGE_AGEING_TIME}" |
287 |
|
fi |
288 |
|
|
289 |
|
# configure bridge priority |
290 |
|
if [[ ! -z ${BRIDGE_PRIORITY} ]] |
291 |
|
then |
292 |
|
brctl setbridgeprio "${iface}" "${BRIDGE_PRIORITY}" |
293 |
|
fi |
294 |
|
|
295 |
|
# configure forward delay |
296 |
|
if [[ ! -z ${BRIDGE_FORWARD_DELAY} ]] |
297 |
|
then |
298 |
|
brctl setfd "${iface}" "${BRIDGE_FORWARD_DELAY}" |
299 |
|
fi |
300 |
|
|
301 |
|
# configure hello time |
302 |
|
if [[ ! -z ${BRIDGE_HELLO_TIME} ]] |
303 |
|
then |
304 |
|
brctl sethello "${iface}" "${BRIDGE_HELLO_TIME}" |
305 |
|
fi |
306 |
|
|
307 |
|
# configure maximal message age |
308 |
|
if [[ ! -z ${BRIDGE_MAX_MESSAGE_AGE} ]] |
309 |
|
then |
310 |
|
brctl setmaxage "${iface}" "${BRIDGE_MAX_MESSAGE_AGE}" |
311 |
|
fi |
312 |
|
|
313 |
|
# configure path cost for every port |
314 |
|
if [[ ! -z ${BRIDGE_PATH_COST} ]] |
315 |
|
then |
316 |
|
for i in ${BRIDGE_PATH_COST} |
317 |
|
do |
318 |
|
port="${i%=*}" |
319 |
|
cost="${i#*=}" |
320 |
|
[[ ! -z ${port} ]] && brctl pathcost "${iface}" "${port}" "${cost}" |
321 |
|
done |
322 |
|
fi |
323 |
|
|
324 |
|
# configure port priority for every port |
325 |
|
if [[ ! -z ${BRIDGE_PORT_PRIORITY} ]] |
326 |
|
then |
327 |
|
for i in ${BRIDGE_PORT_PRIORITY} |
328 |
|
do |
329 |
|
port="${i%=*}" |
330 |
|
prio="${i#*=}" |
331 |
|
[[ ! -z ${port} ]] && brctl setportprio "${iface}" "${port}" "${prio}" |
332 |
|
done |
333 |
|
fi |
334 |
|
} |
335 |
|
|
336 |
config_bridge_devices() |
config_bridge_devices() |
337 |
{ |
{ |
338 |
local iface="$1" |
local iface="$1" |
368 |
case ${method} in |
case ${method} in |
369 |
add) |
add) |
370 |
# setup the bridge device |
# setup the bridge device |
371 |
brctl addbr ${iface} |
brctl addbr "${iface}" |
372 |
for bport in ${BRIDGE_INTERFACES} |
for bport in ${BRIDGE_INTERFACES} |
373 |
do |
do |
374 |
# enter promiscous mode |
# enter promiscous mode |
375 |
ifconfig ${bport} 0.0.0.0 promisc |
ifconfig "${bport}" 0.0.0.0 promisc |
376 |
# now setup the bridge |
# now setup the bridge |
377 |
brctl addif ${iface} ${bport} |
brctl addif "${iface}" "${bport}" |
378 |
done |
done |
379 |
# enable spanning-tree protocol |
# configure all other options |
380 |
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 |
|
381 |
;; |
;; |
382 |
|
|
383 |
remove) |
remove) |
384 |
for bport in ${BRIDGE_INTERFACE} |
for bport in ${BRIDGE_INTERFACE} |
385 |
do |
do |
386 |
# bring the interface down |
# bring the interface down |
387 |
ifconfig ${bport} down |
ifconfig "${bport}" down |
388 |
# remove the interface from the bridge |
# remove the interface from the bridge |
389 |
brctl delif ${iface} ${bport} |
brctl delif "${iface}" "${bport}" |
390 |
done |
done |
391 |
# bring the bridge down |
# bring the bridge down |
392 |
brctl delbr ${iface} |
brctl delbr "${iface}" |
393 |
;; |
;; |
394 |
esac |
esac |
395 |
|
|
423 |
\#*|"") continue ;; |
\#*|"") continue ;; |
424 |
esac |
esac |
425 |
rc_print "${message}" |
rc_print "${message}" |
426 |
route ${method} ${route} |
route "${method}" "${route}" |
427 |
evaluate_retval |
evaluate_retval |
428 |
done |
done |
429 |
fi |
fi |
435 |
|
|
436 |
if [[ -z $1 ]] |
if [[ -z $1 ]] |
437 |
then |
then |
438 |
ALL_INTERFACES=$(onboot_interface_list ${network_settings}/net.*) |
ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*) |
439 |
else |
else |
440 |
if [[ -e ${network_settings}/net.$1 ]] |
if [[ -e ${rc_network_settings}/net.$1 ]] |
441 |
then |
then |
442 |
ALL_INTERFACES="$1" |
ALL_INTERFACES="$1" |
443 |
else |
else |
452 |
for iface in ${ALL_INTERFACES} |
for iface in ${ALL_INTERFACES} |
453 |
do |
do |
454 |
# checkconfig |
# checkconfig |
455 |
source ${network_settings}/net.${iface} || exit 1 |
source ${rc_network_settings}/net.${iface} || exit 1 |
456 |
checkconfig |
checkconfig |
457 |
|
|
458 |
# setup mac |
# setup mac |
459 |
if [ -n "${FORCE_MAC_TO}" ] |
if [[ -n ${FORCE_MAC_TO} ]] |
460 |
then |
then |
461 |
rc_print "Faking MAC to ${FORCE_MAC_TO} for ${COLBLUE}${iface}${COLDEFAULT} ... " |
rc_print "Faking MAC to ${FORCE_MAC_TO} for ${COLBLUE}${iface}${COLDEFAULT} ... " |
462 |
ifconfig "${iface}" hw ether "${FORCE_MAC_TO}" |
ifconfig "${iface}" hw ether "${FORCE_MAC_TO}" |
466 |
# setup bridges |
# setup bridges |
467 |
if [[ ${iface} = br[0-9]* ]] |
if [[ ${iface} = br[0-9]* ]] |
468 |
then |
then |
469 |
config_bridge_devices ${iface} add |
config_bridge_devices "${iface}" add |
470 |
fi |
fi |
471 |
|
|
|
# activate the interface |
|
|
ifconfig "${iface}" up |
|
|
|
|
472 |
# now configure wireless_extensions |
# now configure wireless_extensions |
473 |
[ -x /usr/sbin/iwconfig ] && setup_wireless_extensions "${iface}" |
[ -x /usr/sbin/iwconfig ] && setup_wireless_extensions "${iface}" |
474 |
|
|
475 |
rc_print "Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
476 |
|
|
477 |
|
# activate the interface |
478 |
|
ifconfig "${iface}" up |
479 |
|
|
480 |
# setup static or dhcp |
# setup static or dhcp |
481 |
case ${NETWORKING} in |
case ${NETWORKING} in |
482 |
dhcp|DHCP) |
dhcp|DHCP) |
483 |
${CURS_UP} |
${CURS_UP} |
484 |
${SET_WWCOL} |
${SET_WWCOL} |
485 |
rc_echo "[DHCP]" |
rc_echo "[DHCP]" |
486 |
loadproc ${DHCP_PROG} ${DHCP_START} "${iface}" |
loadproc "${DHCP_PROG}" "${DHCP_START}" "${iface}" |
487 |
;; |
;; |
488 |
static|STATIC) |
static|STATIC) |
489 |
${CURS_UP} |
${CURS_UP} |
498 |
if [[ -n ${GATEWAY} ]] |
if [[ -n ${GATEWAY} ]] |
499 |
then |
then |
500 |
rc_print "Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..." |
501 |
route add default gateway ${GATEWAY} metric 1 dev ${iface} |
route add default gateway "${GATEWAY}" metric 1 dev "${iface}" |
502 |
evaluate_retval |
evaluate_retval |
503 |
|
|
504 |
unset GATEWAY |
unset GATEWAY |
505 |
fi |
fi |
506 |
|
|
507 |
# setup /etc/resolv.conf |
# setup /etc/resolv.conf |
508 |
|
# add given nameserver |
509 |
if [[ -n ${NAMESERVER} ]] |
if [[ -n ${NAMESERVER} ]] |
510 |
then |
then |
511 |
rc_print "Setting up all nameserver for ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Setting up all nameserver for ${COLBLUE}${iface}${COLDEFAULT} ..." |
512 |
|
|
513 |
# whipe out the old one |
# whipe out the old one |
514 |
echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf |
echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf |
515 |
|
# include head |
516 |
|
if [ -f /etc/resolv.conf.head ] |
517 |
|
then |
518 |
|
cat /etc/resolv.conf.head >> /etc/resolv.conf |
519 |
|
else |
520 |
|
echo "# /etc/resolv.conf.head can replace this line" >> /etc/resolv.conf |
521 |
|
fi |
522 |
|
|
523 |
for dns in ${NAMESERVER} |
for dns in ${NAMESERVER} |
524 |
do |
do |
525 |
echo "nameserver ${dns}" >> /etc/resolv.conf |
echo "nameserver ${dns}" >> /etc/resolv.conf |
526 |
done |
done |
527 |
|
|
528 |
|
# include tail |
529 |
|
if [ -f /etc/resolv.conf.tail ] |
530 |
|
then |
531 |
|
cat /etc/resolv.conf.tail >> /etc/resolv.conf |
532 |
|
else |
533 |
|
echo "# /etc/resolv.conf.tail can replace this line" >> /etc/resolv.conf |
534 |
|
fi |
535 |
|
|
536 |
unset NAMESERVER |
unset NAMESERVER |
537 |
fi |
fi |
538 |
done |
done |
545 |
{ |
{ |
546 |
if [[ -z $1 ]] |
if [[ -z $1 ]] |
547 |
then |
then |
548 |
ALL_INTERFACES=$(onboot_interface_list ${network_settings}/net.*) |
ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*) |
549 |
else |
else |
550 |
if [[ -e ${network_settings}/net.$1 ]] |
if [[ -e ${rc_network_settings}/net.$1 ]] |
551 |
then |
then |
552 |
ALL_INTERFACES="$1" |
ALL_INTERFACES="$1" |
553 |
else |
else |
561 |
# get list of all devices |
# get list of all devices |
562 |
for iface in ${ALL_INTERFACES} |
for iface in ${ALL_INTERFACES} |
563 |
do |
do |
564 |
source ${network_settings}/net.${iface} || exit 1 |
source ${rc_network_settings}/net.${iface} || exit 1 |
565 |
checkconfig |
checkconfig |
566 |
|
|
567 |
if [[ -n ${GATEWAY} ]] |
if [[ -n ${GATEWAY} ]] |
572 |
fi |
fi |
573 |
|
|
574 |
rc_print "Bringing down interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Bringing down interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
575 |
ifconfig ${iface} down |
ifconfig "${iface}" down |
576 |
evaluate_retval |
evaluate_retval |
577 |
|
|
578 |
# remove bridges |
# remove bridges |
579 |
if [[ ${iface} = br[0-9]* ]] |
if [[ ${iface} = br[0-9]* ]] |
580 |
then |
then |
581 |
config_bridge_devices ${iface} remove |
config_bridge_devices "${iface}" remove |
582 |
fi |
fi |
583 |
|
|
584 |
# shutdown dhcp-daemon |
# shutdown dhcp-daemon |
629 |
;; |
;; |
630 |
|
|
631 |
*) |
*) |
632 |
echo "Usage: $0 {start|stop|restart} [interface]" |
rc_echo "Usage: $0 {start|stop|restart} [interface]" |
633 |
exit 1 |
exit 1 |
634 |
;; |
;; |
635 |
esac |
esac |