Rev 102 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed
#!/bin/bash## Noninteractive HW detection and configuration# in particular configure network devices## Urs Beyerle, PSI#### -----------------------------------------------------------### definitions### -----------------------------------------------------------# dir of mounted /$MOUNTDIR/liveMOUNTDIR=livecd# source functions. /$MOUNTDIR/live/liblinuxlive. /etc/init.d/functions# do not run, if we change runlevelstouch /var/lock/subsys/kudzu-auto### -----------------------------------------------------------### Get boot parameters### -----------------------------------------------------------# do not start networkNONET=$( cmdline_parameter nonet )# static IPIPADDR=$( cmdline_value ip )# gatewayGATEWAY=$( cmdline_value gw )# netmaskNETMASK=$( cmdline_value netmask )# start WLAN network on bootWLAN=$( cmdline_parameter wlan )# do not apply any fixes (for debugging)NOFIX=$( cmdline_parameter nofix )### -----------------------------------------------------------### Main### -----------------------------------------------------------### run kudzu in quiet modeaction $"Hardware auto-detection, please wait... " /usr/sbin/kudzu -q### never start on boot the following network devices (wifi0)if [ ! $NOFIX ]; thenfor iface in wifi0; dofor file in networking/profiles/default/ifcfg \networking/devices/ifcfg \network-scripts/ifcfg; doif [ -e /etc/sysconfig/${file}-${iface} ]; thensed -i "s/ONBOOT=.*/ONBOOT=no/" /etc/sysconfig/${file}-${iface}fidonedonefi### do not start network devices, if NONET is definedif [ $NONET ]; then# find all network devices (exclude loopback device)config_files=$( find /etc/sysconfig -name ifcfg-* 2>/dev/null | grep -v ifcfg-lo )for file in $config_files; dosed -i "s/ONBOOT=.*/ONBOOT=no/" $filedonefi### define static IP and gateway, netmaskif [ $IPADDR ]; thenif [ ! $GATEWAY ]; then# default gatway x.y.z.1GATEWAY=$( echo $IPADDR | awk -F"." '{ print $1"."$2"."$3".1" }' )if [ ! $NETMASK ]; thenNETMASK=255.255.255.0fifi# create config files for eth0for iface in eth0; dofor file in networking/profiles/default/ifcfg \networking/devices/ifcfg \network-scripts/ifcfg; dosed -i "s/BOOTPROTO=.*/BOOTPROTO=none/" /etc/sysconfig/${file}-${iface}echo "IPADDR=$IPADDR" > /etc/sysconfig/${file}-${iface}echo "NETMASK=$NETMASK" > /etc/sysconfig/${file}-${iface}echo "GATEWAY=$GATEWAY" > /etc/sysconfig/${file}-${iface}donedonefi### activate Atheros WLANlspci | grep -q Ethernet.*Atherosif [ "$?" = "0" ]; then# bring ath0 upifconfig ath0 up > /dev/null 2>&1# replace wifi0 with ath0for file in networking/profiles/default/ifcfg \networking/devices/ifcfg \network-scripts/ifcfg; doif [ -e /etc/sysconfig/${file}-wifi0 ]; thenmv /etc/sysconfig/${file}-wifi0 /etc/sysconfig/${file}-ath0sed -i "s/wifi0/ath0/" /etc/sysconfig/${file}-ath0grep -q Wireless /etc/sysconfig/${file}-ath0[ "$?" != "0" ] && echo "TYPE=Wireless" >> /etc/sysconfig/${file}-ath0fidonefi### configure iwl4965 Intel WLAN Chiplspci | grep -q Wireless.*4965if [ "$?" = "0" ]; thenfind /lib/modules/ 2>&1 | grep -q iwl4965.koif [ "$?" = "0" ]; thengrep -q iwl4965 /etc/modprobe.confif [ "$?" != "0" ]; thenecho "alias wlan0 iwl4965" >> /etc/modprobe.conffiif [ ! -e /etc/sysconfig/network-scripts/ifcfg-wlan0 ]; thencat > /etc/sysconfig/network-scripts/ifcfg-wlan0 <<EOFTYPE=WirelessDEVICE=wlan0BOOTPROTO=dhcpNETMASK=DHCP_HOSTNAME=IPADDR=DOMAIN=ONBOOT=noUSERCTL=noIPV6INIT=noPEERDNS=yesESSID=CHANNEL=6MODE=ManagedRATE=AutoEOFln /etc/sysconfig/network-scripts/ifcfg-wlan0 /etc/sysconfig/networking/devices/ifcfg-wlan0ln /etc/sysconfig/network-scripts/ifcfg-wlan0 /etc/sysconfig/networking/profiles/default/ifcfg-wlan0fififi### do not start WLAN devices on bootif [ ! $WLAN ]; then# find all network devices (exclude loopback device)config_files=$( find /etc/sysconfig -name ifcfg-* 2>/dev/null | grep -v ifcfg-lo )for file in $config_files; do# WLAN device?grep -q TYPE=Wireless $fileif [ "$?" = "0" ]; thensed -i "s/ONBOOT=.*/ONBOOT=no/" $filefidonefi