74 |
{ |
{ |
75 |
if [[ -z ${NETWORKING} ]] |
if [[ -z ${NETWORKING} ]] |
76 |
then |
then |
77 |
echo "NETWORKING missing in net.${interface}, aborted" |
rc_echo "NETWORKING missing in net.${interface}, aborted" |
78 |
exit 1 |
exit 1 |
79 |
fi |
fi |
80 |
|
|
82 |
static) |
static) |
83 |
if [[ -z ${IP} ]] |
if [[ -z ${IP} ]] |
84 |
then |
then |
85 |
echo "IP missing in net.${interface}, aborted" |
rc_echo "IP missing in net.${interface}, aborted" |
86 |
exit 1 |
exit 1 |
87 |
fi |
fi |
88 |
|
|
89 |
if [[ -z ${NETMASK} ]] |
if [[ -z ${NETMASK} ]] |
90 |
then |
then |
91 |
echo -n "NETMASK missing in net.${interface}, " |
rc_echo -n "NETMASK missing in net.${interface}, " |
92 |
echo "using 255.255.255.0" |
rc_echo "using 255.255.255.0" |
93 |
NETMASK=255.255.255.0 |
NETMASK=255.255.255.0 |
94 |
fi |
fi |
95 |
|
|
96 |
if [[ -z ${BROADCAST} ]] |
if [[ -z ${BROADCAST} ]] |
97 |
then |
then |
98 |
echo -n "BROADCAST missing in net.${interface}, " |
rc_echo -n "BROADCAST missing in net.${interface}, " |
99 |
echo "using default address" |
rc_echo "using default address" |
100 |
fi |
fi |
101 |
;; |
;; |
102 |
|
|
103 |
dhcp) |
dhcp) |
104 |
if [[ -z ${DHCP_PROG} ]] |
if [[ -z ${DHCP_PROG} ]] |
105 |
then |
then |
106 |
echo "DHCP_PROG missing in net.${interface}, aborted" |
rc_echo "DHCP_PROG missing in net.${interface}, aborted" |
107 |
exit 1 |
exit 1 |
108 |
fi |
fi |
109 |
;; |
;; |
142 |
|
|
143 |
if [[ -z ${iface} ]] |
if [[ -z ${iface} ]] |
144 |
then |
then |
145 |
echo "WEP: no \$iface given. Aborting setup." |
rc_echo "WEP: no \$iface given. Aborting setup." |
146 |
return 1 |
return 1 |
147 |
fi |
fi |
148 |
|
|
149 |
${CURS_UP} |
${CURS_UP} |
150 |
${SET_WWCOL} |
${SET_WWCOL} |
151 |
echo "[AUTH: WEP]" |
rc_echo "[AUTH: WEP]" |
152 |
|
|
153 |
iwconfig "${iface}" enc on |
iwconfig "${iface}" enc on |
154 |
[[ -n ${WIRELESS_KEY_LENGTH} ]] && iwconfig "${iface}" enc "${WIRELESS_KEY_LENGTH}" |
[[ -n ${WIRELESS_KEY_LENGTH} ]] && iwconfig "${iface}" enc "${WIRELESS_KEY_LENGTH}" |
162 |
|
|
163 |
if [[ -z ${iface} ]] |
if [[ -z ${iface} ]] |
164 |
then |
then |
165 |
echo "WPA: no \$iface given. Aborting setup." |
rc_echo "WPA: no \$iface given. Aborting setup." |
166 |
return 1 |
return 1 |
167 |
fi |
fi |
168 |
|
|
169 |
if [ ! -x /sbin/wpa_supplicant ] |
if [ ! -x /sbin/wpa_supplicant ] |
170 |
then |
then |
171 |
echo "WPA: wpa_supplicant not installed. Aborting setup." |
rc_echo "WPA: wpa_supplicant not installed. Aborting setup." |
172 |
return 1 |
return 1 |
173 |
fi |
fi |
174 |
|
|
175 |
${CURS_UP} |
${CURS_UP} |
176 |
${SET_WWCOL} |
${SET_WWCOL} |
177 |
echo "[AUTH: WPA]" |
rc_echo "[AUTH: WPA]" |
178 |
|
|
179 |
# get default settings |
# get default settings |
180 |
[[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant |
[[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant |
184 |
[[ -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 |
185 |
if [[ -z ${WIRELESS_WPA_DRIVER} ]] |
if [[ -z ${WIRELESS_WPA_DRIVER} ]] |
186 |
then |
then |
187 |
echo "WPA: WIRELESS_WPA_DRIVER given. Aborting setup." |
rc_echo "WPA: WIRELESS_WPA_DRIVER given. Aborting setup." |
188 |
return 1 |
return 1 |
189 |
fi |
fi |
190 |
|
|
212 |
${WIRELESS_WPA_OPTS} |
${WIRELESS_WPA_OPTS} |
213 |
|
|
214 |
# echo wait 5 seconds |
# echo wait 5 seconds |
215 |
echo " Waiting 5 seconds to retrieve authentification reply ... " |
rc_echo " Waiting 5 seconds to retrieve authentification reply ... " |
216 |
sleep 5 |
sleep 5 |
217 |
} |
} |
218 |
|
|
222 |
|
|
223 |
if [[ -z ${iface} ]] |
if [[ -z ${iface} ]] |
224 |
then |
then |
225 |
echo "WIRELESS_EXTENSIONS: no \$iface given. Aborting setup." |
rc_echo "WIRELESS_EXTENSIONS: no \$iface given. Aborting setup." |
226 |
return 1 |
return 1 |
227 |
fi |
fi |
228 |
|
|
234 |
[[ -n ${WIRELESS_NICK} ]] || |
[[ -n ${WIRELESS_NICK} ]] || |
235 |
[[ -n ${WIRELESS_AUTH_MODE} ]] |
[[ -n ${WIRELESS_AUTH_MODE} ]] |
236 |
then |
then |
237 |
echo -e ${COLOREDSTAR}"Setting up wlan-ext for ${COLBLUE}${iface}${COLDEFAULT} ... " |
rc_print "Setting up wlan-ext for ${COLBLUE}${iface}${COLDEFAULT} ... " |
238 |
fi |
fi |
239 |
|
|
240 |
[[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}" |
[[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}" |
259 |
|
|
260 |
if [[ -z ${iface} ]] |
if [[ -z ${iface} ]] |
261 |
then |
then |
262 |
echo "BRIDGE: no \$iface given. Aborting setup." |
rc_echo "BRIDGE: no \$iface given. Aborting setup." |
263 |
return 1 |
return 1 |
264 |
fi |
fi |
265 |
|
|
266 |
if [[ -z ${method} ]] |
if [[ -z ${method} ]] |
267 |
then |
then |
268 |
echo "BRIDGE: no \$method given. Aborting setup." |
rc_echo "BRIDGE: no \$method given. Aborting setup." |
269 |
return 1 |
return 1 |
270 |
fi |
fi |
271 |
|
|
272 |
# first check for brctl |
# first check for brctl |
273 |
if [[ -z $(which brctl) ]] |
if [[ -z $(which brctl) ]] |
274 |
then |
then |
275 |
echo "brctl not found! Please install 'net-misc/bridge-utils'." |
rc_echo "brctl not found! Please install 'net-misc/bridge-utils'." |
276 |
return 1 |
return 1 |
277 |
fi |
fi |
278 |
|
|
279 |
# check the config |
# check the config |
280 |
if [[ -z ${BRIDGE_INTERFACES} ]] |
if [[ -z ${BRIDGE_INTERFACES} ]] |
281 |
then |
then |
282 |
echo "BRIDGE: no \$BRIDGE_INTERFACES given. Aborting setup." |
rc_echo "BRIDGE: no \$BRIDGE_INTERFACES given. Aborting setup." |
283 |
return 1 |
return 1 |
284 |
fi |
fi |
285 |
|
|
297 |
# enable spanning-tree protocol |
# enable spanning-tree protocol |
298 |
case ${BRIDGE_STP} in |
case ${BRIDGE_STP} in |
299 |
on|off) brctl stp ${iface} ${BRIDGE_STP} ;; |
on|off) brctl stp ${iface} ${BRIDGE_STP} ;; |
300 |
*) echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;; |
*) rc_echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;; |
301 |
esac |
esac |
302 |
;; |
;; |
303 |
|
|
329 |
add) message="Adding route ${COLBLUE}${route}${COLDEFAULT} ..." ;; |
add) message="Adding route ${COLBLUE}${route}${COLDEFAULT} ..." ;; |
330 |
del) message="Removing route ${COLBLUE}${route}${COLDEFAULT} ..." ;; |
del) message="Removing route ${COLBLUE}${route}${COLDEFAULT} ..." ;; |
331 |
*) |
*) |
332 |
echo "config_routes: unsupported \$method '${method}'." |
rc_echo "config_routes: unsupported \$method '${method}'." |
333 |
exit 1 |
exit 1 |
334 |
;; |
;; |
335 |
esac |
esac |
343 |
case "${route}" in |
case "${route}" in |
344 |
\#*|"") continue ;; |
\#*|"") continue ;; |
345 |
esac |
esac |
346 |
echo -e ${COLOREDSTAR}"${message}" |
rc_print "${message}" |
347 |
route ${method} ${route} |
route ${method} ${route} |
348 |
evaluate_retval |
evaluate_retval |
349 |
done |
done |
363 |
ALL_INTERFACES="$1" |
ALL_INTERFACES="$1" |
364 |
else |
else |
365 |
${FAILURE} |
${FAILURE} |
366 |
echo "Interface $1 does not exist. Aborting" |
rc_echo "Interface $1 does not exist. Aborting" |
367 |
${NORMAL} |
${NORMAL} |
368 |
exit 1 |
exit 1 |
369 |
fi |
fi |
379 |
# setup mac |
# setup mac |
380 |
if [ -n "${FORCE_MAC_TO}" ] |
if [ -n "${FORCE_MAC_TO}" ] |
381 |
then |
then |
382 |
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} ... " |
383 |
ifconfig "${iface}" hw ether "${FORCE_MAC_TO}" |
ifconfig "${iface}" hw ether "${FORCE_MAC_TO}" |
384 |
evaluate_retval |
evaluate_retval |
385 |
fi |
fi |
396 |
# now configure wireless_extensions |
# now configure wireless_extensions |
397 |
[ -x /usr/sbin/iwconfig ] && setup_wireless_extensions "${iface}" |
[ -x /usr/sbin/iwconfig ] && setup_wireless_extensions "${iface}" |
398 |
|
|
399 |
echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
400 |
|
|
401 |
# setup static or dhcp |
# setup static or dhcp |
402 |
case ${NETWORKING} in |
case ${NETWORKING} in |
403 |
dhcp|DHCP) |
dhcp|DHCP) |
404 |
${CURS_UP} |
${CURS_UP} |
405 |
${SET_WWCOL} |
${SET_WWCOL} |
406 |
echo "[DHCP]" |
rc_echo "[DHCP]" |
407 |
loadproc ${DHCP_PROG} ${DHCP_START} "${iface}" |
loadproc ${DHCP_PROG} ${DHCP_START} "${iface}" |
408 |
;; |
;; |
409 |
static|STATIC) |
static|STATIC) |
410 |
${CURS_UP} |
${CURS_UP} |
411 |
${SET_WWCOL} |
${SET_WWCOL} |
412 |
echo "[STATIC]" |
rc_echo "[STATIC]" |
413 |
ifconfig "${iface}" "${IP}" netmask "${NETMASK}" broadcast "${BROADCAST}" |
ifconfig "${iface}" "${IP}" netmask "${NETMASK}" broadcast "${BROADCAST}" |
414 |
evaluate_retval |
evaluate_retval |
415 |
;; |
;; |
418 |
# setup def gw |
# setup def gw |
419 |
if [[ -n ${GATEWAY} ]] |
if [[ -n ${GATEWAY} ]] |
420 |
then |
then |
421 |
echo -e ${COLOREDSTAR}"Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..." |
422 |
route add default gateway ${GATEWAY} metric 1 dev ${iface} |
route add default gateway ${GATEWAY} metric 1 dev ${iface} |
423 |
evaluate_retval |
evaluate_retval |
424 |
|
|
428 |
# setup /etc/resolv.conf |
# setup /etc/resolv.conf |
429 |
if [[ -n ${NAMESERVER} ]] |
if [[ -n ${NAMESERVER} ]] |
430 |
then |
then |
431 |
echo -e ${COLOREDSTAR}"Setting up all nameserver for ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Setting up all nameserver for ${COLBLUE}${iface}${COLDEFAULT} ..." |
432 |
|
|
433 |
# whipe out the old one |
# whipe out the old one |
434 |
echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf |
echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf |
435 |
for dns in ${NAMESERVER} |
for dns in ${NAMESERVER} |
456 |
ALL_INTERFACES="$1" |
ALL_INTERFACES="$1" |
457 |
else |
else |
458 |
${FAILURE} |
${FAILURE} |
459 |
echo "Interface $1 does not exist. Aborting" |
rc_echo "Interface $1 does not exist. Aborting" |
460 |
${NORMAL} |
${NORMAL} |
461 |
exit 1 |
exit 1 |
462 |
fi |
fi |
470 |
|
|
471 |
if [[ -n ${GATEWAY} ]] |
if [[ -n ${GATEWAY} ]] |
472 |
then |
then |
473 |
echo -e ${COLOREDSTAR}"Removing default gateway ..." |
rc_print "Removing default gateway ..." |
474 |
route del -net default |
route del -net default |
475 |
evaluate_retval |
evaluate_retval |
476 |
fi |
fi |
477 |
|
|
478 |
echo -e ${COLOREDSTAR}"Bringing down interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
rc_print "Bringing down interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
479 |
ifconfig ${iface} down |
ifconfig ${iface} down |
480 |
evaluate_retval |
evaluate_retval |
481 |
|
|
488 |
# shutdown dhcp-daemon |
# shutdown dhcp-daemon |
489 |
if [[ ${NETWORKING} = dhcp ]] && [[ -n $(pidof ${DHCP_PROG}) ]] |
if [[ ${NETWORKING} = dhcp ]] && [[ -n $(pidof ${DHCP_PROG}) ]] |
490 |
then |
then |
491 |
echo -e ${COLOREDSTAR}"Stopping the dhcp-daemon ..." |
rc_print "Stopping the dhcp-daemon ..." |
492 |
${CURS_UP} |
${CURS_UP} |
493 |
${SET_WWCOL} |
${SET_WWCOL} |
494 |
echo "[$(basename ${DHCP_PROG})]" |
rc_echo "[$(basename ${DHCP_PROG})]" |
495 |
${DHCP_PROG} ${DHCP_STOP} "${iface}" |
${DHCP_PROG} ${DHCP_STOP} "${iface}" |
496 |
evaluate_retval |
evaluate_retval |
497 |
fi |
fi |