Next Previous Contents

10. setup_template script

#!/bin/bash
#-----------------------------------------------------------------------------
# 
# /usr/local/sbin/setup_template
# ftp://ftp.sci.usq.edu.au/pub/jacek/beowulf-utils
#
# Version       : 0.0.4
#
# Date          : 5 Sepetember 1998
#
# Author        : Jacek Radajewski 
#                 jacek@usq.edu.au
#
# OS            : Red Hat Linux 5.0
#
# Purpose       : This script is used to setup an NFS-root  template Beowulf 
#                 disk-less client.  This Template will be used to create the 
#                 NFS root directory for each of the disk-less clients.  setup_template
#                 assumes Red Hat Linux 5.0, and that the /tftpboot
#                 directory is on the same file system as /etc and all
#                 of its sub directories.
#-----------------------------------------------------------------------------

export SERVER=$(/bin/hostname)
export TFTPBOOT=/tftpboot
export TEMPLATE=$TFTPBOOT/Template

if [ -d "$TFTPBOOT" ] ; then
    echo "Directory $TFTPBOOT exists.  Please remove it and try again."
    exit 1
fi
    
# we first create all the directories

/bin/mkdir $TFTPBOOT
/bin/mkdir $TEMPLATE
/bin/mkdir $TEMPLATE/bin
/bin/mkdir $TEMPLATE/boot
/bin/mkdir $TEMPLATE/dev
/bin/mkdir $TEMPLATE/etc
/bin/mkdir $TEMPLATE/home
/bin/mkdir $TEMPLATE/lib
/bin/mkdir $TEMPLATE/mnt
/bin/mkdir $TEMPLATE/root
/bin/mkdir $TEMPLATE/sbin
/bin/mkdir $TEMPLATE/tmp
/bin/mkdir $TEMPLATE/var

/bin/ln -sf /usr $TEMPLATE/usr
/bin/ln -sf /proc $TEMPLATE/proc

# now we copy all the files

echo -n "Copying directories and their contents ... "

echo -n "/bin "
cd /bin
/bin/tar -cpf - * | (cd $TEMPLATE/bin ; tar -xpf -)

echo -n "/boot "
cd /boot
/bin/tar -cpf - * | (cd $TEMPLATE/boot ; tar -xpf -)

echo -n "/dev "
cd /dev
/bin/tar -cpf - * | (cd $TEMPLATE/dev ; tar -xpf -)

echo -n "/etc "
cd /etc
/bin/tar -cpf - * | (cd $TEMPLATE/etc ; tar -xpf -)

echo -n "/lib "
cd /lib
/bin/tar -cpf - * | (cd $TEMPLATE/lib ; tar -xpf -)

echo -n "/mnt "
cd /mnt
/bin/tar -cpf - * | (cd $TEMPLATE/mnt ; tar -xpf -)

echo -n "/root "
cd /root
/bin/tar -cpf - * | (cd $TEMPLATE/root ; tar -xpf -)

echo -n "/sbin "
cd /sbin
/bin/tar -cpf - * | (cd $TEMPLATE/sbin ; tar -xpf -)

echo -n "/var "
cd /var
/bin/tar -cpf - * | (cd $TEMPLATE/var ; tar -xpf -)

# remove network scripts

/bin/rm -f $TEMPLATE/etc/sysconfig/network
/bin/rm -f $TEMPLATE/etc/sysconfig/network-scripts/ifcfg-eth*

# remove fstab and mtab

/bin/rm -f $TEMPLATE/etc/fstab
/bin/rm -f $TEMPLATE/etc/mtab

# remove old and create new, empty log files.
# most of these will not be used because most messages
# will be logged remotely to the server via syslogd

/bin/rm -f $TEMPLATE/var/log/secure*
/bin/touch $TEMPLATE/var/log/secure

/bin/rm -f $TEMPLATE/var/log/messages*
/bin/touch $TEMPLATE/var/log/messages

/bin/rm -f $TEMPLATE/var/log/maillog*
/bin/touch $TEMPLATE/var/log/maillog

/bin/rm -f $TEMPLATE/var/log/cron*
/bin/touch $TEMPLATE/var/log/cron

/bin/rm -f $TEMPLATE/var/log/lastlog*
/bin/touch $TEMPLATE/var/log/lastlog

/bin/rm -f $TEMPLATE/var/log/xferlog*
/bin/touch $TEMPLATE/var/log/xferlog

/bin/rm -f $TEMPLATE/var/log/dmesg*
/bin/touch $TEMPLATE/var/log/dmesg

# clients should not run samba

/bin/rm -f $TEMPLATE/var/log/log.nmb
/bin/rm -f $TEMPLATE/var/log/log.smb
/bin/rm -f $TEMPLATE/var/log/samba*

# clients should not run any cron jobs

/bin/rm -f $TEMPLATE/etc/cron.hourly/*
/bin/rm -f $TEMPLATE/etc/cron.daily/*
/bin/rm -f $TEMPLATE/etc/cron.weekly/*
/bin/rm -f $TEMPLATE/etc/cron.monthly/*

/bin/rm -f $TEMPLATE/var/spool/cron/*

# remove some of the services from /etc/rc.d/rc3.d1
# you might want to change/add/remove lines here

/bin/rm -f $TEMPLATE/etc/rc.d/rc3.d/S*pcmcia
/bin/rm -f $TEMPLATE/etc/rc.d/rc3.d/S*gpm
/bin/rm -f $TEMPLATE/etc/rc.d/rc3.d/S*smb
/bin/rm -f $TEMPLATE/etc/rc.d/rc3.d/S*httpd
/bin/rm -f $TEMPLATE/etc/rc.d/rc3.d/S*snmpd
/bin/rm -f $TEMPLATE/etc/rc.d/rc3.d/S*named
/bin/rm -f $TEMPLATE/etc/rc.d/rc3.d/S*gated

# create a new /etc/syslog.conf file
# we want to log everything on the server
# you will HAVE TO run syslogd on the server with "-r"
# to enable clients to log their messages on the server
# this script doesn't do it.  Modify /etc/rc.d/init.d/syslog :
#-------------------------------------------------------------
#case "$1" in
#  start)
#        echo -n "Starting system loggers: "
#        daemon syslogd -r

/bin/rm -f $TEMPLATE/etc/syslog.conf
echo "*.* @$SERVER" >> $TEMPLATE/etc/syslog.conf


#-----------------------------------------------------------------------------
# there are few files which want to be the same on the server and all clients
# /etc/passwd for example has to be the same on all machines.
# we want our $TEMPLATE/etc/passwd to be a hard link to /etc/passwd
#-----------------------------------------------------------------------------

/bin/ln -f /etc/passwd      $TEMPLATE/etc/passwd
/bin/ln -f /etc/group       $TEMPLATE/etc/group
/bin/ln -f /etc/issue       $TEMPLATE/etc/issue
/bin/ln -f /etc/issue.net   $TEMPLATE/etc/issue.net
/bin/ln -f /etc/profile     $TEMPLATE/etc/profile
/bin/ln -f /etc/bashrc      $TEMPLATE/etc/bashrc

#-----------------------------------------------------------------------------
# create rc script to setup rarp entries
# this script shoud run in both runlevel 3 and 5
#-----------------------------------------------------------------------------

/bin/rm -f /etc/rc.d/init.d/rarp
/bin/touch /etc/rc.d/init.d/rarp
/bin/ln -sf /etc/rc.d/init.d/rarp /etc/rc.d/rc3.d/S95rarp
/bin/ln -sf /etc/rc.d/init.d/rarp /etc/rc.d/rc5.d/S95rarp


Next Previous Contents