Subversion Repositories livecd

Rev

Rev 84 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

#!/bin/bash
#
# Fix things during bootup - run first 
# For example: Enable services, etc ...
# Executed at the very end of /etc/rc.d/rc.sysinit
#
# Urs Beyerle, PSI
#

### -----------------------------------------------------------
### Definitions
### -----------------------------------------------------------

# dir of mounted /$MOUNTDIR/live
MOUNTDIR=livecd

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


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

# start afs?
AFS=$( cmdline_parameter afs )
CELL=$( cmdline_value cell )

# or force no afs
[ $( cmdline_parameter noafs ) ] && AFS=""

# start ssh server?
SSH=$( cmdline_parameter ssh )

# root on NFS?
NFSROOT=$( cmdline_value nfsroot )

# PSI setup?
PSI=$( cmdline_parameter psi )

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

# Are PXE/TFTP and NFS Server the same host ? not uesed any more
ONEMASTER=$( cmdline_parameter onemaster )

# fast booting ?
FASTBOOT=$( cmdline_parameter fastboot )

# if run=rdesktop, we do fast boot
if [ "$( cmdline_value run )" = "rdesktop" ]; then
    FASTBOOT="fastboot"
fi

# start ntpd ?
NTPD=$( cmdline_parameter ntpd )

# services on/off
SERVICEON=$( cmdline_value serviceon )
SERVICEOFF=$( cmdline_value serviceoff )

# Xserver configurations
SCREEN=$( cmdline_value screen )


### -----------------------------------------------------------
### Configure services
### -----------------------------------------------------------

### disable rpcidmapd, if LiveCD mounted over NFS
if [ $NFSROOT ]; then
    chkconfig rpcidmapd off
fi

### disable NetworkManager, if LiveCD mounted over NFS
if [ $NFSROOT ]; then
    chkconfig NetworkManager off
    chkconfig NetworkManagerDispatcher off
fi

### disable shutdown of network and nfs, 
# if we have the LiveCD mounted over NFS
if [ $NFSROOT ]; then
    if [ $ONEMASTER ]; then
        # "network off" is only necessary, 
        # if PXE/TFTP and NTS server is on same machine
        chkconfig network off
    fi

    rm -f /etc/rc.d/rc6.d/K75netfs
    rm -f /etc/rc.d/rc6.d/K86nfslock
    rm -f /etc/rc.d/rc6.d/K87portmap
    rm -f /etc/rc.d/rc6.d/K90network

    rm -f /etc/rc.d/rc0.d/K75netfs
    rm -f /etc/rc.d/rc0.d/K86nfslock
    rm -f /etc/rc.d/rc0.d/K87portmap
    rm -f /etc/rc.d/rc0.d/K90network
fi

### enable AFS during start up, if given by boot parameter
if [ $AFS ]; then
    chkconfig afs on
fi

### disable some services for fast booting
if [ $FASTBOOT ]; then    
    echo "Fast booting enabled"
    chkconfig vpnclient_init off
    chkconfig haldaemon off
    chkconfig pcmcia off
    chkconfig ntpd off
    chkconfig atd off
    chkconfig cpuspeed off
    chkconfig gpm off
    chkconfig messagebus off
    rm -rf /etc/rc.d/rc3.d/S04kudzu-auto
    rm -rf /etc/rc.d/rc5.d/S04kudzu-auto
fi
 
### enable ntpd?
if [ $NTPD ]; then
    chkconfig ntpd on
fi

### enable SSH server during start up, if given by boot parameter
if [ $SSH ]; then
    chkconfig sshd on
fi

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

### enable 915resolution on Intel Mobile Display controller
#   and set resolution in /etc/sysconfig/915resolution defined by screen=
lspci | grep -q Display.*Intel.*Mobile
if [ "$?" = "0" ]; then 
    chkconfig 915resolution on 2>/dev/null
    if [ -e /etc/sysconfig/915resolution ]; then
        X=$( echo $SCREEN | cut -d"x" -f1 )
        Y=$( echo $SCREEN | cut -d"x" -f2 )
        if [ $X ]; then
            sed -i "s|^X=.*|X=$X|" /etc/sysconfig/915resolution
        fi
        if [ $Y ]; then
            sed -i "s|^Y=.*|Y=$Y|" /etc/sysconfig/915resolution
        fi
    fi
fi

### services on
if [ -n $SERVICEON ]; then
    for service in `echo "$SERVICEON" | tr ':' ' '`; do
        if [ -f /etc/init.d/$service ]; then
            chkconfig $service on
        fi
    done
fi

### services off
if [ -n $SERVICEOFF ]; then
    for service in `echo "$SERVICEOFF" | tr ':' ' '`; do
        if [ -f /etc/init.d/$service ]; then
            chkconfig $service off
        fi
    done
fi


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

### get resolv.conf, if we have the LiveCD mounted over NFS
if [ $NFSROOT ]; then
    cp -f /$MOUNTDIR/live/etc/resolv.conf /etc/
fi

### restore blacklist (modified in runveryfirst)
if [ $NFSROOT ]; then
    [ -e /etc/hotplug/blacklist ] && BLACKLIST_FILE=/etc/hotplug/blacklist
    [ -e /etc/modprobe.d/blacklist ] && BLACKLIST_FILE=/etc/modprobe.d/blacklist
    mv -f ${BLACKLIST_FILE}.backup ${BLACKLIST_FILE}
fi

### create AFS mount point
mkdir -p /afs

### set afs cell, if given by boot parameter
if [ $CELL ]; then
    echo $CELL > /usr/vice/etc/ThisCell
fi

### fix perm of /tmp
chmod 1777 /tmp

### link /opt -> /usr/opt !
ln -s /usr/opt /opt

### create home
mkdir -p /home

### create /scratch
mkdir -p /scratch
chmod 1777 /scratch

### create /data
if [ $PSI ]; then
    mkdir -p /data
    chmod 1777 /data
fi

### add PSI master
if [ $PSI ]; then
    mkdir -p /mnt/master
    echo "pxeserv01:/master       /mnt/master             nfs     nfsvers=2,noauto,nolock,ro 0 0" >> /etc/fstab
fi