--- trunk/magellan-initscripts/etc/rc.d/init.d/network 2008/03/20 12:43:14 684 +++ trunk/magellan-initscripts/etc/rc.d/init.d/network 2010/07/14 07:29:53 1091 @@ -1,5 +1,5 @@ #!/bin/bash -# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/network,v 1.17 2008-03-20 12:43:14 niro Exp $ +# $Id$ #%rlevels: 0:k 1:k 2:k 3:s 4:s 5:s 6:k #%start: 20 @@ -10,7 +10,7 @@ #%before: #%after: -source /etc/sysconfig/rc +source /etc/conf.d/rc source ${rc_functions} # read values from files @@ -24,7 +24,7 @@ # global local ONBOOT local NETWORKING - + # static local IP local NETMASK @@ -103,9 +103,12 @@ dhcp) if [[ -z ${DHCP_PROG} ]] then - echo "DHCP_PROG missing in net.${interface}, aborted" - exit 1 + echo -n "DHCP_PROG missing in net.${interface}," + echo "using default programm" + DHCP_PROG="/sbin/dhcpcd" fi + [[ -z ${DHCP_START} ]] && DHCP_START="-t 10" + [[ -z ${DHCP_STOP} ]] && DHCP_STOP="-k" ;; esac @@ -182,11 +185,9 @@ # check the configuration [[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant.auto [[ -z ${WIRELESS_WPA_SKEL} ]] && WIRELESS_WPA_SKEL=/etc/conf.d/wpa_supplicant.skel - if [[ -z ${WIRELESS_WPA_DRIVER} ]] - then - echo "WPA: WIRELESS_WPA_DRIVER given. Aborting setup." - return 1 - fi + + # use wext as default driver, do not abort here anymore + [[ -z ${WIRELESS_WPA_DRIVER} ]] && WIRELESS_WPA_DRIVER=wext # write a config with the settings from net.${iface} # only wpa-psk ! all other needs manual setup @@ -195,9 +196,16 @@ # write default cfg from skeleton cat ${WIRELESS_WPA_SKEL} > ${WIRELESS_WPA_CONFIG} + local wpa_proto + case ${WIRELESS_AUTH_MODE} in + wpa) wpa_proto="WPA" ;; + wpa2) wpa_proto="WPA2" ;; + esac + # setup the network entry sed -i -e "s:@WIRELESS_ESSID@:${WIRELESS_ESSID}:g" \ - -e "s:@WIRELESS_KEY@:${WIRELESS_KEY}:g" \ + -e "s:@WIRELESS_KEY@:${WIRELESS_KEY_ASCII}:g" \ + -e "s:@WIRELESS_AUTH_MODE@:${wpa_proto}:g" \ ${WIRELESS_WPA_CONFIG} fi @@ -245,9 +253,9 @@ [[ -n ${WIRELESS_NICK} ]] && iwconfig "${iface}" nick "${WIRELESS_NICK}" case "${WIRELESS_AUTH_MODE}" in - wpa) config_wireless_wpa "${iface}" ;; - wep|on) config_wireless_wep "${iface}" ;; - off) iwconfig "${iface}" enc off ;; + wpa|wpa2) config_wireless_wpa "${iface}" ;; + wep|on) config_wireless_wep "${iface}" ;; + off) iwconfig "${iface}" enc off ;; esac } @@ -356,9 +364,9 @@ if [[ -z $1 ]] then - ALL_INTERFACES=$(onboot_interface_list ${network_settings}/net.*) + ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*) else - if [[ -e ${network_settings}/net.$1 ]] + if [[ -e ${rc_network_settings}/net.$1 ]] then ALL_INTERFACES="$1" else @@ -373,11 +381,11 @@ for iface in ${ALL_INTERFACES} do # checkconfig - source ${network_settings}/net.${iface} || exit 1 + source ${rc_network_settings}/net.${iface} || exit 1 checkconfig # setup mac - if [ -n "${FORCE_MAC_TO}" ] + if [[ -n ${FORCE_MAC_TO} ]] then echo -e ${COLOREDSTAR}"Faking MAC to ${FORCE_MAC_TO} for ${COLBLUE}${iface}${COLDEFAULT} ... " ifconfig "${iface}" hw ether "${FORCE_MAC_TO}" @@ -390,21 +398,21 @@ config_bridge_devices ${iface} add fi - # activate the interface - ifconfig "${iface}" up - # now configure wireless_extensions [ -x /usr/sbin/iwconfig ] && setup_wireless_extensions "${iface}" echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..." + # activate the interface + ifconfig "${iface}" up + # setup static or dhcp case ${NETWORKING} in dhcp|DHCP) ${CURS_UP} ${SET_WWCOL} echo "[DHCP]" - loadproc ${DHCP_PROG} ${DHCP_START} "${iface}" + loadproc "${DHCP_PROG}" "${DHCP_START}" "${iface}" ;; static|STATIC) ${CURS_UP} @@ -426,12 +434,20 @@ fi # setup /etc/resolv.conf + # whipe out the old one + echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf + # include head + if [ -f /etc/resolv.conf.head ] + then + cat /etc/resolv.conf.head >> /etc/resolv.conf + else + echo "# /etc/resolv.conf.head can replace this line" >> /etc/resolv.conf + fi + # add given nameserver if [[ -n ${NAMESERVER} ]] then echo -e ${COLOREDSTAR}"Setting up all nameserver for ${COLBLUE}${iface}${COLDEFAULT} ..." - - # whipe out the old one - echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf + for dns in ${NAMESERVER} do echo "nameserver ${dns}" >> /etc/resolv.conf @@ -439,6 +455,13 @@ unset NAMESERVER fi + # include tail + if [ -f /etc/resolv.conf.tail ] + then + cat /etc/resolv.conf.tail >> /etc/resolv.conf + else + echo "# /etc/resolv.conf.tail can replace this line" >> /etc/resolv.conf + fi done # setup user routes @@ -449,9 +472,9 @@ { if [[ -z $1 ]] then - ALL_INTERFACES=$(onboot_interface_list ${network_settings}/net.*) + ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*) else - if [[ -e ${network_settings}/net.$1 ]] + if [[ -e ${rc_network_settings}/net.$1 ]] then ALL_INTERFACES="$1" else @@ -465,7 +488,7 @@ # get list of all devices for iface in ${ALL_INTERFACES} do - source ${network_settings}/net.${iface} || exit 1 + source ${rc_network_settings}/net.${iface} || exit 1 checkconfig if [[ -n ${GATEWAY} ]]