Rev 1 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed
#!/bin/bash
#
# Fix things during bootup - run first
# 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 )
# static IP
IPADDR=$( cmdline_value ip )
# gateway
GATEWAY=$( cmdline_value gw )
# netmask
NETMASK=$( cmdline_value netmask )
# 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 )
### -----------------------------------------------------------
### Main
### -----------------------------------------------------------
### disable rpcidmapd, if LiveCD mounted over NFS
if [ $NFSROOT ]; then
chkconfig rpcidmapd off
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
### get resolv.conf
# if we have the LiveCD mounted over NFS
if [ $NFSROOT ]; then
cp -f /$MOUNTDIR/live/etc/resolv.conf /etc/
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
### create AFS mount point
mkdir -p /afs
### 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
### 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
### 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
### set afs cell, if given by boot parameter
if [ $CELL ]; then
echo $CELL > /usr/vice/etc/ThisCell
fi
### do not activate network during bootup, if "nonet"
if [ $NONET ]; then
for iface in eth0 eth1 eth2 eth3; 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
### 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