#!/bin/sh
#
# rc.local
#
# This script will setup the environment
# for a diskless workstation, as part of
# the Linux Terminal Server Project (http://www.LTSP.org)
#
PATH=/bin:$PATH; export PATH
. /etc/ltsp_functions
/sbin/devfsd /dev
#
# Mount /proc before /tmp, so that we can display the progress
#
echo "Mounting /proc filesystem"
mount -n -t proc /proc /proc
#
# Un-mount the initrd, to free up some space
#
umount /oldroot >/dev/null 2>&1
#
# Get the runlevel for this workstation
#
RUNLEVEL=`get_cfg RUNLEVEL 5`
#
# Find out if we want to allow local applications
#
pr_set 67 "Checking for Local Apps"
LOCAL_APPS=`get_cfg LOCAL_APPS N`
if [ "${LOCAL_APPS}" = "Y" ]; then
if [ ! -d /home ]; then
pr_warn
echo
echo "WARNING! You have Local apps enabled in lts.conf, but"
echo " you don't have the local_apps package loaded"
echo " Local apps will be disabled."
echo
LOCAL_APPS="N"
fi
fi
#
# Find out if we want to swap via NFS
#
USE_NFS_SWAP=`get_cfg USE_NFS_SWAP N`
#
# Create and mount the ramdisk as the /tmp filesystem This
# is the only place we can write files, because everything else
# is read-only.
#
pr_set 69 "Creating Ramdisk"
echo "Creating ramdisk on /tmp"
RAMDISK_SIZE=`get_cfg RAMDISK_SIZE 1024`
/sbin/mke2fs -q -m0 /dev/ram1 ${RAMDISK_SIZE}
/bin/mount -n /dev/ram1 /tmp
pr_set 70 "Setting Hostname"
HOSTNAME=`hostname`
echo "Current hostname: ${HOSTNAME}"
#############################################################
# Get the IP address of the default server. This is used for
# XDM_SERVER,TELNET_HOST and SYSLOG_HOST if any of them are
# not set explicitly. Default to '192.168.0.254' if it is NOT
# set in the config file.
#
DEFAULT_SERVER=`get_cfg SERVER 192.168.2.100`
>/tmp/mtab
#############################################################
# Load some kernel modules
#
pr_set 71 "Loading Modules"
SERIAL_MOD_LOADED="N"
PARALLEL_MOD_LOADED="N"
KERNEL_VERSION=`cut -d " " -f3 /proc/version`
MODULE_DIR=/lib/modules
for i in 01 02 03 04 05 06 07 08 09 10; do
MODULE=`get_cfg MODULE_${i}`
if [ -n "${MODULE}" ]; then
if [ "${MODULE}" = "serial" ]; then
SERIAL_MOD_LOADED="Y"
fi
if [ "${MODULE}" = "lp" ]; then
PARALLEL_MOD_LOADED="Y"
fi
case "${MODULE}" in
/*) # If it starts with a slash, we use insmod
#
MODULE_PATH="${MODULE_DIR}/${KERNEL_VERSION}${MODULE}"
/sbin/insmod ${MODULE_PATH}
ERR=$?
if [ ${ERR} -ne 0 ]; then
pr_fail
echo
echo "ERROR! loading module: ${MODULE} failed !"
echo
echo -n "Press <enter> to continue "
read CMD
exit
fi
;;
*) # Otherwise, we use modprobe
#
echo "Loading: ${MODULE}"
/sbin/modprobe ${MODULE}
ERR=$?
if [ ${ERR} -ne 0 ]; then
pr_fail
echo
echo "ERROR! loading module: ${MODULE} failed !"
echo
echo -n "Press <enter> to continue "
read CMD
exit
fi
;;
esac
fi
done
################################################################
#
# Setup the resolv.conf file
#
pr_set 72 "Setting up resolv.conf"
SEARCH_DOMAIN=`get_cfg SEARCH_DOMAIN`
if [ "${SEARCH_DOMAIN}" != "" ]; then
echo "search ${SEARCH_DOMAIN}" >/tmp/resolv.conf
fi
DNS_SERVER=`get_cfg DNS_SERVER ${DEFAULT_SERVER}`
echo "nameserver ${DNS_SERVER}" >>/tmp/resolv.conf
NFS_SERVER=`get_cfg NFS_SERVER ${DEFAULT_SERVER}`
################################################################
#
# Setup swap
#
if [ "${USE_NFS_SWAP}" = "Y" ]; then
pr_set 73 "Checking for NFS swap"
modprobe nfsswap
mkdir /tmp/swapfiles
SWAPFILE=/tmp/swapfiles/${HOSTNAME}.swap
SWAP_SERVER=`get_cfg SWAP_SERVER ${NFS_SERVER}`
NFS_SWAPDIR=`get_cfg NFS_SWAPDIR /var/opt/ltsp`
pr_set 74 "Mounting swapfiles directory"
echo "Mounting swapfiles directory"
mount -t nfs -o rsize=2048,wsize=2048,nolock \
${SWAP_SERVER}:${NFS_SWAPDIR}/swapfiles \
/tmp/swapfiles
ERR=$?
if [ ${ERR} -ne 0 ]; then
pr_set 74 "Mounting of swap filesystem failed, err=${ERR}"
pr_fail
echo "Mounting of swap filesystem failed, err=${ERR}"
echo "Attempted to NFS mount ${SWAP_SERVER}:${LTSP_SWAPDIR}"
echo -n "Press <enter> to continue "
read CMD
exit
else
pr_set 75 "Preparing swapfile"
SWAPFILE_SIZE=`get_cfg SWAPFILE_SIZE 64m`
/sbin/prep_swap -s ${SWAPFILE_SIZE} -f ${SWAPFILE}
ERR=$?
if [ ${ERR} -ne 0 ]; then
pr_set 75 "Error creating swapfile, ERR=${ERR}"
pr_fail
echo "Error creating swapfile, ERR=${ERR}"
echo -n "Press <enter> to continue "
read CMD
exit
fi
pr_set 80 "Formatting Swapfile"
mkswap ${SWAPFILE}
ERR=$?
if [ ${ERR} -ne 0 ]; then
pr_set 80 "Error running mkswapswapfile, ERR=${ERR}"
pr_fail
echo "Error running mkswapswapfile, ERR=${ERR}"
echo -n "Press <enter> to continue "
read CMD
exit
fi
pr_set 83"Enabling swap via NFS"
echo "Enabling swap via NFS"
swapon ${SWAPFILE}
ERR=$?
if [ ${ERR} -ne 0 ]; then
pr_set 83 "swapon failed, ERR=${ERR}"
pr_fail
echo "swapon failed, ERR=${ERR}"
echo
echo "Are you sure the NFS/Swap patch has "
echo "been applied to the workstation kernel?"
echo
echo -n "Press <enter> to continue "
read CMD
exit
fi
fi
fi
##################################################################
#
# Mount filesystems for the FAH client.
# The stucture of the mount directory is
# /fah/name_of_workstation Eg /fah/ws001
# The mount point is the same for all workstations:
# /fah
#
if [ "Y" = "Y" ]; then
pr_set 85 "Mounting additional filesystems"
echo "Mounting additional filesystems..."
mount -t nfs -o nolock ${NFS_SERVER}:/fah/${HOSTNAME} /fah
fi
##################################################################
#
# Mount filesystems
#
#
# if [ "${LOCAL_APPS}" = "Y" ]; then
# pr_set 85 "Mounting additional filesystems"
# echo "Mounting additional filesystems..."
# mount -t nfs -o nolock ${NFS_SERVER}:/home /home
# fi
pr_set 86 "Setting up loopback device"
echo "Setting up loopback device"
ifconfig lo 127.0.0.1 netmask 255.0.0.0 broadcast 127.255.255.255
mkdir /tmp/compiled
mkdir /tmp/var
mkdir /tmp/var/run
mkdir /tmp/var/log
mkdir /tmp/var/lock
mkdir /tmp/var/lock/subsys
mkdir /tmp/var/lib
mkdir /tmp/var/lib/xkb
mkdir /tmp/mnt
################################################################
#
# Check the hostname
#
echo "127.0.0.1 localhost ${HOSTNAME}" >/tmp/hosts
echo "${DEFAULT_SERVER} server" >>/tmp/hosts
################################################################
#
# Setup the hosts.equiv file
#
echo "${DEFAULT_SERVER}" >/tmp/hosts.equiv
################################################################
#
# Start the syslog daemon
#
pr_set 88 "Starting syslogd"
SYSLOG_HOST=`get_cfg SYSLOG_HOST ${DEFAULT_SERVER}`
echo "Starting syslogd"
echo "*.* @${SYSLOG_HOST}" >/tmp/syslog.conf
syslogd -m 60 -R ${SYSLOG_HOST}
################################################################
#
# Local app daemon stuff
#
if [ "${LOCAL_APPS}" = "Y" ]; then
pr_set 90 "Starting Portmapper"
echo "Starting portmapper"
portmap
pr_set 91 "Starting xinetd"
echo "Starting xinetd"
xinetd
NIS_SERVER=`get_cfg NIS_SERVER`
if [ "${NIS_SERVER}" != "" ]; then
pr_set 92"Setting NIS server"
echo "Setting NIS Server"
echo "ypserver ${NIS_SERVER}" >>/etc/yp.conf
fi
pr_set 93 "Setting domainname"
echo "Setting domainname"
NIS_DOMAIN=`get_cfg NIS_DOMAIN "ltsp"`
echo domainname ${NIS_DOMAIN}
domainname ${NIS_DOMAIN}
pr_set 94 "Starting ypbind"
echo "Starting ypbind"
if [ -z "${NIS_SERVER}" ]; then
ypbind -broadcast
else
ypbind
fi
#
# Need to give ypbind a chance to bind to the server,
# hopefully this is long enough
#
sleep 1
fi
#################################################################
#
# Run the additional rc files.
# These are to make it easier to integrate additional
# functionality into an ltsp system. Add your scripts to etc/rc.d,
# and put the name of the script in the lts.conf file, and it will
# be executed.
#
pr_set 95 "Checking for rcfiles"
for i in 01 02 03 04 05 06 07 08 09 10; do
RCFILE=`get_cfg RCFILE_${i}`
if [ -n "${RCFILE}" ]; then
if [ -x /etc/rc.d/${RCFILE} ]; then
/etc/rc.d/${RCFILE}
else
pr_fail
echo
echo " ERROR: RCFILE_${i} is setup in lts.conf, but"
echo " it does not exist in the /etc/rc.d directory"
echo
echo -n "Press <enter> to continue "
read CMD
fi
fi
done
pr_set 100 "Completed"
|