 #!/bin/sh
#
# Kick-start post-configuration script, to do the configuration things
# that need to be done.  See also /etc/rc.d/rc.local which may do
# one-time configuration before it replaces itself.
#
# @(#) Last changed: -EAM 02Aug2003
#
# Eric Myers <myers@umich.edu> - 14 July 2003
# #(@) $Id: robot.sh,v 1.3 2003/06/26 19:13:50 myers Exp myers $
######################################################################

TARBALL=robot-install.tar

####################
# Make custom directories and mount points:

mkdir -p /root/rpm/updates/redhat/7.3/
mkdir -p /floppy/
mkdir -p /cdrom


############
# Configuration changes:

cd /etc/cron.daily
  rm 00-logwatch
  chmod -x logrotate

cd /var/spool/rwho
  rm -f *-gig
  rm -f *localhost

############
# Set the clock from main node

rdate -s 192.168.47.1
hwclock -u -w


####################
# Install and configure autorpm, to use it later and always

cd /root/rpm
X=`ls -1 autorpm*rpm`
if [ "$X" != "" ]; then
  echo " * Installing autorpm..."
  rpm -Uhv $X
else
  echo " ! Cannot find autorpm package :-( "
fi
echo "  "


##############
# Unpack the tar file (copied by robot.cfg) to configure the system

if [ -f /root/$TARBALL.gz ]; then 
  echo " * Unpacking the tar file $TARBALL ..." 
  gunzip /root/$TARBALL
  cd /  
  tar -xvf /root/$TARBALL
else
  echo " ! Cannot find configuration tarball $TARBALL :-( "
fi
echo "  "


##############
# Put newer rc.local (copied by ks.cfg) in place for after reboot

cd /root
echo "  "
if [ -f rc.local ]; then
  /bin/mv -f rc.local /etc/rc.d/rc.local
  chmod +x /etc/rc.d/rc.local
  echo " * Installed one-shot rc.local from /root" 
fi


####################
# Prepare for reversible kernel upgrade later by saving this one

#KVERS=`uname -r | tr -d a-zA-Z`
KVERS=2.4

cd /boot
mkdir -p Save
/bin/cp -f *${KVERS}* Save/

cd /lib/modules
mkdir -p Save
/bin/cp -rp ${KVERS}* Save/


####################
# LILO configuration: boot message, serial console, etc...

if [ -f /boot/boot.txt ]; then
  cd /etc
  cp lilo.conf lilo.conf.ORIG
  sed -e "s%^message=.*$%message=/boot/boot.txt\\
serial=0,9600n8%"\
      -e "s/^[ \t]*read-only/&\\
        append=\"hdc=ide-scsi console=ttyS0,9600\"/" \
      < lilo.conf.ORIG > lilo.conf
  echo " * Modified /etc/lilo.conf, now calling lilo..."
  if [ ! -z /etc/lilo.conf ]; then 
    lilo
  fi
fi


####################
# Install locally selected package and update RH packages with autorpm
# (Assumes untar'd Otto-rpm-?.conf files already in place.)

if [  -f /etc/autorpm.d/Otto-rpm.conf  ]; then
  echo " "
  echo " * Updating packages via autrpm..."
  echo " "
  cd /etc/autorpm.d 
  cp autorpm.conf autorpm.conf,ORIG

  # Replace main config file with our own, which uses #'s 5 & 6
  cat <<EOF > autorpm.conf
# /etc/autorpm.d/autorpm.conf created by robot.sh on `date`
# UPDATE FROM PACKAGES COPIED VIA FTP DURING INSTALLATION
Set_Var("ReportDest", "root");
Set_Var("Arch", "i686|i586|i386|noarch");
Set_Var("Lang", "en");
Eval_Var("RHVersion", "sed 's/\(Red Hat Linux \)\?release \([^ ]*\) (.*)/\2/' /etc/redhat-release");
Report_Queues_To ("\${ReportDest}");

Config_File("/etc/autorpm.d/Otto-rpm-5.conf");	
Config_File("/etc/autorpm.d/Otto-rpm-6.conf");	
Config_File("/etc/autorpm.d/openafs.conf");
Config_File("/etc/autorpm.d/autorpm-updates.conf");



#EOF autorpm.conf
EOF

# Invoke autorpm to do the work

  autorpm "auto --print " 

# Now put in place the network version for later

  cp Otto-rpm.conf autorpm.conf

fi 

####################
# Services (init scripts):

chkconfig sync on
chkconfig ntpd on
chkconfig rwhod on
chkconfig ypbind on
chkconfig portmap on
chkconfig nfslock on
chkconfig nfs on
chkconfig netfs on

chkconfig amd off
chkconfig ipchains off
chkconfig sendmail off
chkconfig postfix off
chkconfig afs off


####################
# We are done

chmod -x /root/robot.sh

echo " * robot.sh finished."

exit 0

# EOF

