Subversion Repositories livecd

Rev

Rev 81 | Rev 84 | 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 )

# start WLAN network on boot
WLAN=$( cmdline_parameter wlan )

# do not apply any fixes (for debugging)
NOFIX=$( cmdline_parameter nofix )



### -----------------------------------------------------------
### 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)
if [ ! $NOFIX ]; then
    for iface in wifi0; 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
fi


### do not 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
if [ "$?" = "0" ]; then
    chkconfig ipw3945d on 2>/dev/null
    /etc/init.d/ipw3945d start >/dev/null 2>&1 &
fi

### activate Atheros WLAN
lspci | grep -q Ethernet.*Atheros
if [ "$?" = "0" ]; then
    # bring ath0 up
    ifconfig ath0 up > /dev/null 2>&1
    # replace wifi0 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


### do not start WLAN devices on boot
if [ ! $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 $file
        if [ "$?" = "0" ]; then
            sed -i "s/ONBOOT=.*/ONBOOT=no/" $file
        fi
    done
fi

    
### enable 915resolution on Intel Mobile Display controller
lspci | grep -q Display.*Intel.*Mobile
if [ "$?" = "0" ]; then 
    chkconfig 915resolution on
    /etc/init.d/915resolution start >/dev/null 2>&1 &
fi