Subversion Repositories livecd

Rev

Rev 1 | Rev 75 | Go to most recent revision | Blame | Compare with Previous | 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/live
MOUNTDIR=livecd

# source functions
. /$MOUNTDIR/live/liblinuxlive
. /etc/init.d/functions


### -----------------------------------------------------------
### Get boot parameters
### -----------------------------------------------------------

# do not start network
NONET=$( cmdline_parameter nonet )

# static IP
IPADDR=$( cmdline_value ip )

# gateway
GATEWAY=$( cmdline_value gw )

# netmask
NETMASK=$( cmdline_value netmask )


### -----------------------------------------------------------
### Main
### -----------------------------------------------------------

### run kudzu in quiet mode
action $"Hardware auto-detection, please wait... " /usr/sbin/kudzu -q


### never start on boot the following network devices (wifi0, ath0)
for iface in wifi0 ath0; do
    for file in networking/profiles/default/ifcfg \
        networking/devices/ifcfg \
        network-scripts/ifcfg; do
      if [ -e /etc/sysconfig/${file}-${iface} ]; then
          sed -i "s/ONBOOT=.*/ONBOOT=no/" /etc/sysconfig/${file}-${iface}
      fi
    done
done


### disable start network devices, if NONET is defined
if [ $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; do
        sed -i "s/ONBOOT=.*/ONBOOT=no/" $file
    done
fi


### define static IP and gateway, netmask
if [ $IPADDR ]; then    
    if [ ! $GATEWAY ]; then
        # default gatway x.y.z.1
        GATEWAY=$( echo $IPADDR | awk -F"." '{ print $1"."$2"."$3".1" }' )
        if [ ! $NETMASK ]; then
            NETMASK=255.255.255.0
        fi
    fi
    # create config files for eth0
    for iface in eth0; do
        for file in networking/profiles/default/ifcfg \
                    networking/devices/ifcfg \
                    network-scripts/ifcfg; do
          sed -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}
        done
    done
fi


### activate ipw3945d daemon, if we have Intel IPW3945 WLAN 
lspci | grep -q Intel.*3945ABG
[ "$?" = "0" ] && chkconfig ipw3945d on 2>/dev/null


### activate Atheros WLAN
lspci | grep -q Ethernet.*Atheros
if [ "$?" = "0" ]; then
    # bring ath0 up
    ifconfig ath0 up > /dev/null 2>&1
    # replace wifi with ath0
    for file in networking/profiles/default/ifcfg \
        networking/devices/ifcfg \
        network-scripts/ifcfg; do
      if [ -e /etc/sysconfig/${file}-wifi0 ]; then
          mv /etc/sysconfig/${file}-wifi0 /etc/sysconfig/${file}-ath0
          sed -i "s/wifi0/ath0/" /etc/sysconfig/${file}-ath0
          grep -q Wireless /etc/sysconfig/${file}-ath0
          [ "$?" != "0" ] && echo "TYPE=Wireless" >> /etc/sysconfig/${file}-ath0
      fi
    done
fi