#!/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) # ####################################################################### ## If the IP of your server is NOT 192.168.1.11 then you need to change ## the IP below to fit your network. SERVER_IP="192.168.1.11" ####################################################################### ####################################################################### ## If your Folding@Home directories are NOT stored in /opt/fah then you ## need to change the path below to fit your configuration. FAH_ROOT="/opt/fah" ###################################################################### ## No editing of the script should be required beyond this line. ###################################################################### PATH=/bin:$PATH; export PATH . /etc/ltsp_functions /sbin/devfsd /dev # # Mount /proc before /tmp, so that we can display the progress # # # Un-mount the initrd, to free up some space # umount /oldroot >/dev/null 2>&1 echo "Mounting /proc filesystem" mount -n -t proc /proc /proc # # Make sure the lts.conf file exists # if [ ! -f /etc/lts.conf ]; then echo echo "Could not find lts.conf file!" echo echo "Perhaps you haven't run ltspcfg yet" echo read exit 1 fi # # Get the options for this workstation # This will set environment variables for all of the parameters # eval `/bin/getltscfg -a` # # 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 67 "Creating Ramdisk" echo "Creating ramdisk on /tmp" RAMDISK_SIZE=${RAMDISK_SIZE:-"1024"} /sbin/mke2fs -q -m0 /dev/ram1 ${RAMDISK_SIZE} /bin/mount -n /dev/ram1 /tmp # # A place to store information that is retrieved by ltspinfod # mkdir /tmp/info # # Find out if we want to allow local applications # pr_set 68 "Checking for Local Apps" LOCAL_APPS=${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 reg_info LOCAL_APPS # # Find out if we want to swap via NFS # USE_NFS_SWAP=${USE_NFS_SWAP:-"N"} reg_info USE_NFS_SWAP pr_set 70 "Setting Hostname" HOSTNAME=`hostname` echo "Current hostname: ${HOSTNAME}" reg_info 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_SERVER=${SERVER:-${SERVER_IP}} reg_info DEFAULT_SERVER >/tmp/mtab ################################################################################ # # Load some kernel modules # pr_set 71 "Loading Modules" SERIAL_MOD_LOADED="N" PARALLEL_MOD_LOADED="N" PRINTER_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 MODVAR=MODULE_${i} MODULE=${!MODVAR} if [ -n "${MODULE}" ]; then if [ "${MODULE}" = "serial" ]; then SERIAL_MOD_LOADED="Y" fi if [ "${MODULE}" = "lp" ]; then PARALLEL_MOD_LOADED="Y" fi if [ "${MODULE}" = "printer" ]; then PRINTER_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 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 to continue " read CMD exit fi ;; esac fi done reg_info KERNEL_VERSION TYPE_0=${PRINTER_0_TYPE} TYPE_1=${PRINTER_1_TYPE} TYPE_2=${PRINTER_2_TYPE} reg_info TYPE_0 reg_info TYPE_1 reg_info TYPE_2 SERIAL_MOD_NEEDED="N" if [ "${TYPE_0}" = "S" \ -o "${TYPE_1}" = "S" \ -o "${TYPE_2}" = "S" ]; then SERIAL_MOD_NEEDED="Y" else case "${X_MOUSE_DEVICE}" in /dev/ttyS*) SERIAL_MOD_NEEDED="Y" ;; esac fi if [ "${TYPE_0}" = "P" \ -o "${TYPE_1}" = "P" \ -o "${TYPE_2}" = "P" ]; then PARALLEL_MOD_NEEDED="Y" fi if [ "${TYPE_0}" = "U" \ -o "${TYPE_1}" = "U" \ -o "${TYPE_2}" = "U" ]; then PRINTER_MOD_NEEDED="Y" fi # # Now, see if we need to load the serial or parallel driver modules # if [ "${SERIAL_MOD_NEEDED}" = "Y" -a "${SERIAL_MOD_LOADED}" != "Y" ]; then modprobe serial fi if [ "${PARALLEL_MOD_NEEDED}" = "Y" -a "${PARALLEL_MOD_LOADED}" != "Y" ]; then modprobe lp fi if [ "${PRINTER_MOD_NEEDED}" = "Y" -a "${PRINTER_MOD_LOADED}" != "Y" ]; then modprobe printer fi ################################################################################ # # Setup the resolv.conf file # pr_set 72 "Setting up resolv.conf" 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 NFS_SERVER=${NFS_SERVER:-${DEFAULT_SERVER}} reg_info NFS_SERVER ################################################################################ # # Setup swap # if [ "${USE_NFS_SWAP}" = "Y" ]; then pr_set 73 "Checking for NFS swap" modprobe nfsswap mkdir /tmp/swapfiles IPADDR=`ifconfig eth0 | sed -n '/addr:/p' | cut -f2 -d: | cut -f1 -d" "` SWAPFILE=/tmp/swapfiles/${IPADDR}.swap SWAP_SERVER=${SWAP_SERVER:-${NFS_SERVER}} NFS_SWAPDIR=${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 to continue " read CMD exit else pr_set 75 "Preparing swapfile" SWAPFILE_SIZE=${SWAPFILE_SIZE:-"64m"} reg_info SWAPFILE_SIZE /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 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 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 to continue " read CMD exit fi fi fi ################################################################################ # # Mount filesystems # if [ "${LOCAL_APPS}" = "Y" ]; then pr_set 85 "Mounting the Folding@Home working directory..." echo "Mounting the Folding@Home working directory..." mount -t nfs -o nolock ${NFS_SERVER}:/home /home mount -t nfs -o nolock ${NFS_SERVER}:${FAH_ROOT}/${HOSTNAME} /fah 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 # # Some SuSE Xservers expect the xkb/compiled dir in /var/X11R6 # mkdir /tmp/var/X11R6 mkdir /tmp/var/X11R6/xkb ln -sf /tmp/compiled /tmp/var/X11R6/xkb/compiled if [ "${LOCAL_APPS}" = "Y" ]; then mkdir /tmp/var/nis mkdir /tmp/var/yp mkdir /tmp/var/yp/binding cat <<-EOF >/tmp/var/yp/nicknames passwd passwd.byname group group.byname networks networks.byaddr hosts hosts.byname protocols protocols.bynumber services services.byname aliases mail.aliases ethers ethers.byname EOF fi ################################################################################ # # Check the hostname # echo "127.0.0.1 localhost ${HOSTNAME}" >/tmp/hosts echo "${DEFAULT_SERVER} server" >>/tmp/hosts ################################################################################ # # Start the syslog daemon # pr_set 88 "Starting syslogd" SYSLOG_HOST=${SYSLOG_HOST:-${DEFAULT_SERVER}} reg_info SYSLOG_HOST 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 if [ "${NIS_SERVER}" != "" ]; then pr_set 92"Setting NIS server" echo "Setting NIS Server" echo "ypserver ${NIS_SERVER}" >>/tmp/yp.conf reg_info NIS_SERVER fi pr_set 93 "Setting domainname" echo "Setting domainname" NIS_DOMAIN=${NIS_DOMAIN:-"ltsp"} reg_info NIS_DOMAIN echo domainname ${NIS_DOMAIN} domainname ${NIS_DOMAIN} pr_set 94 "Starting ypbind" echo "Starting ypbind" if [ -z "${NIS_SERVER}" ]; then ypbind -broadcast else ypbind -f /tmp/yp.conf fi echo "Starting sshd..." sshd fi ################################################################################ # # Run a rc.usb, if there is one # if [ -x /etc/rc.usb ]; then echo "Running rc.usb" /etc/rc.usb fi ################################################################################ # # Run a rc.local, if there is one # if [ -x /etc/rc.local ]; then echo "Running rc.local" /etc/rc.local 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 RCVAR=RCFILE_${i} RCFILE=${!RCVAR} if [ -n "${RCFILE}" ]; then reg_info ${RCVAR} 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 to continue " read CMD fi fi done ################################################################################ # # Setup the snmpd stuff. # reg_info SNMPD if [ "${SNMPD}" = "Y" ]; then pr_set 97 "Starting snmpd" /etc/rc.snmpd fi ################################################################################ # # Setup the sound stuff. # reg_info SOUND if [ "${SOUND}" = "Y" ]; then pr_set 97 "Setting up sound" /etc/rc.sound fi ################################################################################ # # Setup the local device stuff # if [ -x /etc/rc.localdev ]; then /etc/rc.localdev fi ################################################################################ # # Setup a link in /tmp to give backward compatibility with # earlier versions of ltsp. # ln -s /etc/screen.d/startx /tmp/start_ws pr_set 100 "rc.sysinit completed, switching to multi-session mode" echo "rc.sysinit completed, switching to multi-session mode" echo sleep 1