81 |
{ |
{ |
82 |
if [[ -z ${NETWORKING} ]] |
if [[ -z ${NETWORKING} ]] |
83 |
then |
then |
84 |
echo "NETWORKING missing in net.${iface}, 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 |
echo "IP missing in net.${iface}, 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 |
echo -n "NETMASK missing in net.${iface}, " |
rc_echo -n "NETMASK missing in net.${iface}, " |
99 |
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 |
echo -n "BROADCAST missing in net.${iface}, " |
rc_echo -n "BROADCAST missing in net.${iface}, " |
106 |
echo "using default address" |
rc_echo "using default address" |
107 |
fi |
fi |
108 |
;; |
;; |
109 |
|
|
110 |
dhcp) |
dhcp) |
111 |
if [[ -z ${DHCP_PROG} ]] |
if [[ -z ${DHCP_PROG} ]] |
112 |
then |
then |
113 |
echo -n "DHCP_PROG missing in net.${iface}," |
rc_echo -n "DHCP_PROG missing in net.${iface}," |
114 |
echo "using default programm /sbin/dhcpcd" |
rc_echo "using default programm /sbin/dhcpcd" |
115 |
DHCP_PROG="/sbin/dhcpcd" |
DHCP_PROG="/sbin/dhcpcd" |
116 |
fi |
fi |
117 |
[[ -z ${DHCP_START} ]] && DHCP_START="-t 10" |
[[ -z ${DHCP_START} ]] && DHCP_START="-t 10" |
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 |
|
|
155 |
|
|
156 |
if [[ -z ${iface} ]] |
if [[ -z ${iface} ]] |
157 |
then |
then |
158 |
echo "WEP: no \$iface given. Aborting setup." |
rc_echo "WEP: no \$iface given. Aborting setup." |
159 |
return 1 |
return 1 |
160 |
fi |
fi |
161 |
|
|
162 |
${CURS_UP} |
${CURS_UP} |
163 |
${SET_WWCOL} |
${SET_WWCOL} |
164 |
echo "[AUTH: WEP]" |
rc_echo "[AUTH: WEP]" |
165 |
|
|
166 |
iwconfig "${iface}" enc on |
iwconfig "${iface}" enc on |
167 |
[[ -n ${WIRELESS_KEY_LENGTH} ]] && iwconfig "${iface}" enc "${WIRELESS_KEY_LENGTH}" |
[[ -n ${WIRELESS_KEY_LENGTH} ]] && iwconfig "${iface}" enc "${WIRELESS_KEY_LENGTH}" |
175 |
|
|
176 |
if [[ -z ${iface} ]] |
if [[ -z ${iface} ]] |
177 |
then |
then |
178 |
echo "WPA: no \$iface given. Aborting setup." |
rc_echo "WPA: no \$iface given. Aborting setup." |
179 |
return 1 |
return 1 |
180 |
fi |
fi |
181 |
|
|
182 |
if [ ! -x /sbin/wpa_supplicant ] |
if [ ! -x /sbin/wpa_supplicant ] |
183 |
then |
then |
184 |
echo "WPA: wpa_supplicant not installed. Aborting setup." |
rc_echo "WPA: wpa_supplicant not installed. Aborting setup." |
185 |
return 1 |
return 1 |
186 |
fi |
fi |
187 |
|
|
188 |
${CURS_UP} |
${CURS_UP} |
189 |
${SET_WWCOL} |
${SET_WWCOL} |
190 |
echo "[AUTH: WPA]" |
rc_echo "[AUTH: WPA]" |
191 |
|
|
192 |
# get default settings |
# get default settings |
193 |
[[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant |
[[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant |
230 |
${WIRELESS_WPA_OPTS} |
${WIRELESS_WPA_OPTS} |
231 |
|
|
232 |
# echo wait 5 seconds |
# echo wait 5 seconds |
233 |
echo " Waiting 5 seconds to retrieve authentification reply ... " |
rc_echo " Waiting 5 seconds to retrieve authentification reply ... " |
234 |
sleep 5 |
sleep 5 |
235 |
} |
} |
236 |
|
|
240 |
|
|
241 |
if [[ -z ${iface} ]] |
if [[ -z ${iface} ]] |
242 |
then |
then |
243 |
echo "WIRELESS_EXTENSIONS: no \$iface given. Aborting setup." |
rc_echo "WIRELESS_EXTENSIONS: no \$iface given. Aborting setup." |
244 |
return 1 |
return 1 |
245 |
fi |
fi |
246 |
|
|
252 |
[[ -n ${WIRELESS_NICK} ]] || |
[[ -n ${WIRELESS_NICK} ]] || |
253 |
[[ -n ${WIRELESS_AUTH_MODE} ]] |
[[ -n ${WIRELESS_AUTH_MODE} ]] |
254 |
then |
then |
255 |
echo -e ${COLOREDSTAR}"Setting up wlan-ext for ${COLBLUE}${iface}${COLDEFAULT} ... " |
rc_print "Setting up wlan-ext for ${COLBLUE}${iface}${COLDEFAULT} ... " |
256 |
fi |
fi |
257 |
|
|
258 |
[[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}" |
[[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}" |
280 |
# enable spanning-tree protocol |
# enable spanning-tree protocol |
281 |
case ${BRIDGE_STP} in |
case ${BRIDGE_STP} in |
282 |
on|off) brctl stp "${iface}" "${BRIDGE_STP}" ;; |
on|off) brctl stp "${iface}" "${BRIDGE_STP}" ;; |
283 |
*) echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;; |
*) rc_echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;; |
284 |
esac |
esac |
285 |
|
|
286 |
# configure ageing time |
# configure ageing time |
344 |
|
|
345 |
if [[ -z ${iface} ]] |
if [[ -z ${iface} ]] |
346 |
then |
then |
347 |
echo "BRIDGE: no \$iface given. Aborting setup." |
rc_echo "BRIDGE: no \$iface given. Aborting setup." |
348 |
return 1 |
return 1 |
349 |
fi |
fi |
350 |
|
|
351 |
if [[ -z ${method} ]] |
if [[ -z ${method} ]] |
352 |
then |
then |
353 |
echo "BRIDGE: no \$method given. Aborting setup." |
rc_echo "BRIDGE: no \$method given. Aborting setup." |
354 |
return 1 |
return 1 |
355 |
fi |
fi |
356 |
|
|
357 |
# first check for brctl |
# first check for brctl |
358 |
if [[ -z $(which brctl) ]] |
if [[ -z $(which brctl) ]] |
359 |
then |
then |
360 |
echo "brctl not found! Please install 'net-misc/bridge-utils'." |
rc_echo "brctl not found! Please install 'net-misc/bridge-utils'." |
361 |
return 1 |
return 1 |
362 |
fi |
fi |
363 |
|
|
364 |
# check the config |
# check the config |
365 |
if [[ -z ${BRIDGE_INTERFACES} ]] |
if [[ -z ${BRIDGE_INTERFACES} ]] |
366 |
then |
then |
367 |
echo "BRIDGE: no \$BRIDGE_INTERFACES given. Aborting setup." |
rc_echo "BRIDGE: no \$BRIDGE_INTERFACES given. Aborting setup." |
368 |
return 1 |
return 1 |
369 |
fi |
fi |
370 |
|
|
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 |
echo "config_routes: unsupported \$method '${method}'." |
rc_echo "config_routes: unsupported \$method '${method}'." |
415 |
exit 1 |
exit 1 |
416 |
;; |
;; |
417 |
esac |
esac |
425 |
case "${route}" in |
case "${route}" in |
426 |
\#*|"") continue ;; |
\#*|"") continue ;; |
427 |
esac |
esac |
428 |
echo -e ${COLOREDSTAR}"${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 |
446 |
ALL_INTERFACES="$1" |
ALL_INTERFACES="$1" |
447 |
else |
else |
448 |
${FAILURE} |
${FAILURE} |
449 |
echo "Interface $1 does not exist. Aborting" |
rc_echo "Interface $1 does not exist. Aborting" |
450 |
${NORMAL} |
${NORMAL} |
451 |
exit 1 |
exit 1 |
452 |
fi |
fi |
462 |
# setup mac |
# setup mac |
463 |
if [[ -n ${FORCE_MAC_TO} ]] |
if [[ -n ${FORCE_MAC_TO} ]] |
464 |
then |
then |
465 |
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} ... " |
466 |
ifconfig "${iface}" hw ether "${FORCE_MAC_TO}" |
ifconfig "${iface}" hw ether "${FORCE_MAC_TO}" |
467 |
evaluate_retval |
evaluate_retval |
468 |
fi |
fi |
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 |
echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
480 |
|
|
481 |
# activate the interface |
# activate the interface |
482 |
ifconfig "${iface}" up |
ifconfig "${iface}" up |
486 |
dhcp|DHCP) |
dhcp|DHCP) |
487 |
${CURS_UP} |
${CURS_UP} |
488 |
${SET_WWCOL} |
${SET_WWCOL} |
489 |
echo "[DHCP]" |
rc_echo "[DHCP]" |
490 |
loadproc "${DHCP_PROG}" "${DHCP_START}" "${iface}" |
loadproc "${DHCP_PROG}" "${DHCP_START}" "${iface}" |
491 |
;; |
;; |
492 |
static|STATIC) |
static|STATIC) |
493 |
${CURS_UP} |
${CURS_UP} |
494 |
${SET_WWCOL} |
${SET_WWCOL} |
495 |
echo "[STATIC]" |
rc_echo "[STATIC]" |
496 |
ifconfig "${iface}" "${IP}" netmask "${NETMASK}" broadcast "${BROADCAST}" |
ifconfig "${iface}" "${IP}" netmask "${NETMASK}" broadcast "${BROADCAST}" |
497 |
evaluate_retval |
evaluate_retval |
498 |
;; |
;; |
501 |
# setup def gw |
# setup def gw |
502 |
if [[ -n ${GATEWAY} ]] |
if [[ -n ${GATEWAY} ]] |
503 |
then |
then |
504 |
echo -e ${COLOREDSTAR}"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 |
|
|
512 |
# add given nameserver |
# add given nameserver |
513 |
if [[ -n ${NAMESERVER} ]] |
if [[ -n ${NAMESERVER} ]] |
514 |
then |
then |
515 |
echo -e ${COLOREDSTAR}"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 |
556 |
ALL_INTERFACES="$1" |
ALL_INTERFACES="$1" |
557 |
else |
else |
558 |
${FAILURE} |
${FAILURE} |
559 |
echo "Interface $1 does not exist. Aborting" |
rc_echo "Interface $1 does not exist. Aborting" |
560 |
${NORMAL} |
${NORMAL} |
561 |
exit 1 |
exit 1 |
562 |
fi |
fi |
570 |
|
|
571 |
if [[ -n ${GATEWAY} ]] |
if [[ -n ${GATEWAY} ]] |
572 |
then |
then |
573 |
echo -e ${COLOREDSTAR}"Removing default gateway ..." |
rc_print "Removing default gateway ..." |
574 |
route del -net default |
route del -net default |
575 |
evaluate_retval |
evaluate_retval |
576 |
fi |
fi |
577 |
|
|
578 |
echo -e ${COLOREDSTAR}"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 |
588 |
# shutdown dhcp-daemon |
# shutdown dhcp-daemon |
589 |
if [[ ${NETWORKING} = dhcp ]] && [[ -n $(pidof ${DHCP_PROG}) ]] |
if [[ ${NETWORKING} = dhcp ]] && [[ -n $(pidof ${DHCP_PROG}) ]] |
590 |
then |
then |
591 |
echo -e ${COLOREDSTAR}"Stopping the dhcp-daemon ..." |
rc_print "Stopping the dhcp-daemon ..." |
592 |
${CURS_UP} |
${CURS_UP} |
593 |
${SET_WWCOL} |
${SET_WWCOL} |
594 |
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 |