1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/network,v 1.14 2007-12-13 12:06:22 niro Exp $ |
# $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 $ |
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 |
10 |
#%before: |
#%before: |
11 |
#%after: |
#%after: |
12 |
|
|
13 |
source /etc/sysconfig/rc |
source /etc/conf.d/rc |
14 |
source ${rc_functions} |
source ${rc_functions} |
15 |
|
|
16 |
# read values from files |
# read values from files |
24 |
# global |
# global |
25 |
local ONBOOT |
local ONBOOT |
26 |
local NETWORKING |
local NETWORKING |
27 |
|
|
28 |
# static |
# static |
29 |
local IP |
local IP |
30 |
local NETMASK |
local NETMASK |
182 |
# check the configuration |
# check the configuration |
183 |
[[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant.auto |
[[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant.auto |
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} ]] |
|
186 |
then |
# use wext as default driver, do not abort here anymore |
187 |
echo "WPA: WIRELESS_WPA_DRIVER given. Aborting setup." |
[[ -z ${WIRELESS_WPA_DRIVER} ]] && WIRELESS_WPA_DRIVER=wext |
|
return 1 |
|
|
fi |
|
188 |
|
|
189 |
# write a config with the settings from net.${iface} |
# write a config with the settings from net.${iface} |
190 |
# only wpa-psk ! all other needs manual setup |
# only wpa-psk ! all other needs manual setup |
193 |
# write default cfg from skeleton |
# write default cfg from skeleton |
194 |
cat ${WIRELESS_WPA_SKEL} > ${WIRELESS_WPA_CONFIG} |
cat ${WIRELESS_WPA_SKEL} > ${WIRELESS_WPA_CONFIG} |
195 |
|
|
196 |
|
local wpa_proto |
197 |
|
case ${WIRELESS_AUTH_MODE} in |
198 |
|
wpa) wpa_proto="WPA" ;; |
199 |
|
wpa2) wpa_proto="WPA2" ;; |
200 |
|
esac |
201 |
|
|
202 |
# setup the network entry |
# setup the network entry |
203 |
sed -i -e "s:@WIRELESS_ESSID@:${WIRELESS_ESSID}:g" \ |
sed -i -e "s:@WIRELESS_ESSID@:${WIRELESS_ESSID}:g" \ |
204 |
-e "s:@WIRELESS_KEY@:${WIRELESS_KEY}:g" \ |
-e "s:@WIRELESS_KEY@:${WIRELESS_KEY_ASCII}:g" \ |
205 |
|
-e "s:@WIRELESS_AUTH_MODE@:${wpa_proto}:g" \ |
206 |
${WIRELESS_WPA_CONFIG} |
${WIRELESS_WPA_CONFIG} |
207 |
fi |
fi |
208 |
|
|
250 |
[[ -n ${WIRELESS_NICK} ]] && iwconfig "${iface}" nick "${WIRELESS_NICK}" |
[[ -n ${WIRELESS_NICK} ]] && iwconfig "${iface}" nick "${WIRELESS_NICK}" |
251 |
|
|
252 |
case "${WIRELESS_AUTH_MODE}" in |
case "${WIRELESS_AUTH_MODE}" in |
253 |
wpa) config_wireless_wpa "${iface}" ;; |
wpa|wpa2) config_wireless_wpa "${iface}" ;; |
254 |
wep|on) config_wireless_wep "${iface}" ;; |
wep|on) config_wireless_wep "${iface}" ;; |
255 |
off) iwconfig "${iface}" enc off ;; |
off) iwconfig "${iface}" enc off ;; |
256 |
esac |
esac |
257 |
} |
} |
258 |
|
|
282 |
fi |
fi |
283 |
|
|
284 |
# check the config |
# check the config |
285 |
if [[ -z ${BRIDGE_INTERFACE} ]] |
if [[ -z ${BRIDGE_INTERFACES} ]] |
286 |
then |
then |
287 |
echo "BRIDGE: no \$BRIDGE_INTERFACE given. Aborting setup." |
echo "BRIDGE: no \$BRIDGE_INTERFACES given. Aborting setup." |
288 |
return 1 |
return 1 |
289 |
fi |
fi |
290 |
|
|
300 |
brctl addif ${iface} ${bport} |
brctl addif ${iface} ${bport} |
301 |
done |
done |
302 |
# enable spanning-tree protocol |
# enable spanning-tree protocol |
303 |
case BRIDGE_STP in |
case ${BRIDGE_STP} in |
304 |
on|off) brctl stp ${iface} ${BRIDGE_STP} ;; |
on|off) brctl stp ${iface} ${BRIDGE_STP} ;; |
305 |
*) echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;; |
*) echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;; |
306 |
esac |
esac |
395 |
config_bridge_devices ${iface} add |
config_bridge_devices ${iface} add |
396 |
fi |
fi |
397 |
|
|
|
# activate the interface |
|
|
ifconfig "${iface}" up |
|
|
|
|
398 |
# now configure wireless_extensions |
# now configure wireless_extensions |
399 |
[ -x /usr/sbin/iwconfig ] && setup_wireless_extensions "${iface}" |
[ -x /usr/sbin/iwconfig ] && setup_wireless_extensions "${iface}" |
400 |
|
|
401 |
echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..." |
402 |
|
|
403 |
|
# activate the interface |
404 |
|
ifconfig "${iface}" up |
405 |
|
|
406 |
# setup static or dhcp |
# setup static or dhcp |
407 |
case ${NETWORKING} in |
case ${NETWORKING} in |
408 |
dhcp|DHCP) |
dhcp|DHCP) |
426 |
echo -e ${COLOREDSTAR}"Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..." |
echo -e ${COLOREDSTAR}"Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..." |
427 |
route add default gateway ${GATEWAY} metric 1 dev ${iface} |
route add default gateway ${GATEWAY} metric 1 dev ${iface} |
428 |
evaluate_retval |
evaluate_retval |
429 |
|
|
430 |
|
unset GATEWAY |
431 |
fi |
fi |
432 |
|
|
433 |
# setup /etc/resolv.conf |
# setup /etc/resolv.conf |
441 |
do |
do |
442 |
echo "nameserver ${dns}" >> /etc/resolv.conf |
echo "nameserver ${dns}" >> /etc/resolv.conf |
443 |
done |
done |
444 |
|
|
445 |
|
unset NAMESERVER |
446 |
fi |
fi |
447 |
done |
done |
448 |
|
|