Subversion Repositories livecd

Rev

Rev 138 | 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 )

# no (auto) kudzu ?
NOKUDZU=$( cmdline_parameter nokudzu )

# 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
### -----------------------------------------------------------

### save status of services that may be disabled, 
#   if LiveCD mounted over NFS
if [ $NFSROOT ]; then
    NFS_SERVICES="rpcidmapd NetworkManager NetworkManagerDispatcher \
                  netfs nfslock portmap network"
    for serv in $NFS_SERVICES; do
        chkconfig --list $serv | grep -q ":on" && echo $serv >> /$MOUNTDIR/service.on
    done
fi

### disable rpcidmapd, if LiveCD mounted over NFS
if [ $NFSROOT ]; then
    $MOUNTDIR
    chkconfig rpcidmapd off >/dev/null 2>&1
fi

### disable NetworkManager, if LiveCD mounted over NFS
if [ $NFSROOT ]; then
    chkconfig NetworkManager off           >/dev/null 2>&1
    chkconfig NetworkManagerDispatcher off >/dev/null 2>&1 
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/K*netfs
    rm -f /etc/rc.d/rc6.d/K*nfslock
    rm -f /etc/rc.d/rc6.d/K*portmap
    rm -f /etc/rc.d/rc6.d/K*network

    rm -f /etc/rc.d/rc0.d/K*netfs
    rm -f /etc/rc.d/rc0.d/K*nfslock
    rm -f /etc/rc.d/rc0.d/K*portmap
    rm -f /etc/rc.d/rc0.d/K*network
fi

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

### disable auto-kudzu ?
if [ $NOKUDZU ]; then
    chkconfig kudzu-auto off
fi

### disable some services for fast booting
if [ $FASTBOOT ]; then    
    echo "Fast booting enabled"
    chkconfig vpnclient_init off  2>/dev/null
    chkconfig haldaemon off       2>/dev/null
    chkconfig pcmcia off          2>/dev/null
    chkconfig ntpd off            2>/dev/null
    chkconfig atd off             2>/dev/null
    chkconfig cpuspeed off        2>/dev/null
    chkconfig gpm off             2>/dev/null
    chkconfig messagebus off      2>/dev/null
    chkconfig avahi-daemon off    2>/dev/null
    chkconfig kudzu-auto off      2>/dev/null
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

### create home
mkdir -p /home

### create /media, /misc, /net
mkdir -p /media /misc /net

### 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     noauto,nolock,ro 0 0" >> /etc/fstab
fi