# $Id$ # configures networking on the host via mysql db settings config_networking() { local iface local CONFIG # first of all get the vars evaluate_table cfg_network # get the right nic if [[ -z ${cfg_network_iface} ]] || [[ ${cfg_network_iface} = NULL ]] then # default is 'eth0' iface="eth0" else iface="${cfg_network_iface}" fi # never ever overwrite network settings, if NETWORKING is unknown case ${cfg_network_networking} in static|STATIC|dhcp|DHCP) ;; *) echo -e "${COLRED}Received network-settings are not complete, aborting ...${COLDEFAULT}" return 1 ;; esac # remove all old nics and modules configs find /etc/conf.d -type f -name 'net.*' | xargs rm find /etc/modprobe.d -type f -name 'net.*' | xargs rm # update the preliminary network # set an device alias for modprobe.conf [ ! -d /etc/modprobe.d ] && install -d /etc/modprobe.d # update only if not the same (to speed up bootprocess - no depmod) if [ ! -f /etc/modprobe.d/net.${iface}.conf ] || [[ ${iface} != $(cat /etc/modprobe.d/net.${iface}.conf | cut -d' ' -f2) ]] then CONFIG="/etc/modprobe.d/net.${iface}.conf" clearconfig addconfig "alias ${iface} ${cfg_network_module}" fi # update confd-networking default iface [ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH} CONFIG="${SETTINGSPATH}/confd-networking" clearconfig addconfig "${iface}" # hostname && hosts CONFIG="/etc/hostname" clearconfig addconfig "${cfg_network_hostname}" CONFIG="/etc/hosts" clearconfig addconfig -e "127.0.0.1\tlocalhost.${cfg_network_domain}\tlocalhost\t${cfg_network_hostname}" case ${cfg_network_networking} in static|STATIC) # add hostname with valid ip to hosts addconfig -e "${ALX_IP}\t${cfg_network_hostname}.${cfg_network_domain}\t${cfg_network_hostname}" ;; esac # network devices # always on boot CONFIG="/etc/conf.d/net.${iface}" clearconfig addconfig 'ONBOOT="yes"' addconfig "NETWORKING=\"${cfg_network_networking}\"" case ${cfg_network_networking} in dhcp|DHCP) addconfig "DHCP_PROG=\"${ALX_DHCP_PROG}\"" addconfig "DHCP_STOP=\"${ALX_DHCP_STOP}\"" addconfig "DHCP_START=\"${ALX_DHCP_START}\"" ;; static|STATIC) addconfig "IP=\"${cfg_network_ip}\"" addconfig "NETMASK=\"${cfg_network_netmask}\"" addconfig "BROADCAST=\"${cfg_network_broadcast}\"" ;; esac # force mac address override if [[ ${cfg_network_forcemacto} != NULL ]] && [[ ! -z ${cfg_network_forcemacto} ]] then addconfig "FORCE_MAC_TO=\"${cfg_network_forcemacto}\"" fi # wireless extensions local value local var for var in bitrate \ channel \ essid \ frequency \ mode \ nick \ auth_mode \ key_length \ key \ key_ascii do # get the value of $var eval value="\${cfg_network_wireless_$(echo ${var})}" # write it only if not empty if [[ ! -z ${value} ]] && [[ ${value} != NULL ]] then # add WIRELESS and use uppercases addconfig "WIRELESS_$(echo ${var} | tr [[:lower:] [[:upper:]])=\"${value}\"" fi # clear value unset value done # FIXME !!! # setup wpa-driver (only zydas atm) if [[ ${cfg_network_module} = zd1211 ]] then addconfig "WIRELESS_WPA_DRIVER=zydas" fi CONFIG="/etc/conf.d/net.routes" clearconfig # gateway or gateway overrides if [[ ${cfg_network_gateway} != NULL ]] && [[ ! -z ${cfg_network_gateway} ]] then addconfig "default gw ${cfg_network_gateway}" fi CONFIG="/etc/resolv.conf" clearconfig # nameserver or nameserver overrides if [[ ${cfg_network_dns} != NULL ]] && [[ ! -z ${cfg_network_dns} ]] then addconfig "nameserver ${cfg_network_dns}" fi # netbios daemon if [[ -x /usr/sbin/nmbd ]] then CONFIG="/etc/samba/smb.conf" clearconfig addconfig "[global]" addconfig "workgroup = ${cfg_network_domain}" addconfig "netbios name = ${cfg_network_hostname}" addconfig "dns proxy = no" rc-config add nmbd &> /dev/null else rc-config del nmbd &> /dev/null fi }