#!/bin/sh
#
# rc.sysinit
#
#=============================================
# 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
eval `/bin/getltscfg -a`
#=============================================
# A place to store information that is retrieved by ltspinfod
#
mkdir /tmp/info
#=============================================
# 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=${SERVER:-"192.168.0.254"}
reg_info DEFAULT_SERVER
NFS_SERVER=${NFS_SERVER:-${DEFAULT_SERVER}}
reg_info NFS_SERVER
#=============================================
# Setup hostname
#
hostname ${HOSTNAME}
echo "Current hostname: ${HOSTNAME}"
reg_info HOSTNAME
>/tmp/mtab
echo "/dev/hda1 /ideroot ext2 ro 1 1" >/tmp/fstab
#############################################
#
# Setup USB modules
#
echo "Checking for USB host controller..."
for MODULE in ehci-hcd uhci-hcd ohci-hcd; do
modprobe $MODULE >/dev/null 2>&1
done
echo "Checking for USB keyboard and mouse..."
for MODULE in input usbmouse usbkbd; do
modprobe ${MODULE} >/dev/null 2>&1
done
mount -n -t usbfs none /proc/bus/usb
#############################################
#
# Setup the resolv.conf file
#
if [ "${SEARCH_DOMAIN}" != "" ]; then
echo "search ${SEARCH_DOMAIN}" >/tmp/resolv.conf
fi
DNS_SERVER=${DNS_SERVER:-${DEFAULT_SERVER}}
echo "nameserver ${DNS_SERVER}" >>/tmp/resolv.conf
reg_info DNS_SERVER
#=============================================
#
# Mount filesystems
#
echo "Setting up loopback device"
ifconfig lo 127.0.0.1 netmask 255.0.0.0 broadcast 127.255.255.255
echo "Setting up /var"
mkdir /tmp/var
mkdir /var/run
mkdir /var/log
mkdir /var/lock
mkdir /var/lock/subsys
mkdir /var/lib
chmod 0777 /tmp
mkdir /tmp/mnt
mkdir /tmp/.privsep
chown 0:0 /tmp/.privsep
chmod 0700 /tmp/.privsep
#=============================================
#
# Check the hostname
#
IPADDR=`getipaddr`
echo "127.0.0.1 localhost" >/tmp/hosts
echo "${IPADDR} ${HOSTNAME}" >>/tmp/hosts
echo "${DEFAULT_SERVER} server" >>/tmp/hosts
#=============================================
#
# Start the syslog daemon
#
SYSLOG_HOST=${SYSLOG_HOST:-${DEFAULT_SERVER}}
reg_info SYSLOG_HOST
echo "Starting syslogd"
#syslog.conf not used
#echo "*.* @${SYSLOG_HOST}" >/tmp/syslog.conf
#syslogd -m 60 -R ${SYSLOG_HOST}
syslogd -m 60 -L
dmesg | logger
#=============================================
#
# 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.
#
for (( RCNUM=1; RCNUM<=10; RCNUM++)); do
RCVAR=`printf "RCFILE_%02d" ${RCNUM}`
RCFILE=${!RCVAR}
if [ -n "${RCFILE}" ]; then
reg_info ${RCVAR}
if [ -x /etc/rc.d/${RCFILE} ]; then
/etc/rc.d/${RCFILE}
else
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 to continue "
read CMD
fi
fi
done
echo "rc.sysinit completed, switching to multi-session mode"
echo