#!/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 08Aug2003
#
# Eric Myers <myers@umich.edu> - 14 December 2001
# #(@) $Id: ks.sh,v 1.3 2003/06/26 19:13:50 myers Exp myers $
######################################################################

TARBALL=kick-me-install.tar

# Be sure no sendmail running

service sendmail stop
service postfix stop


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

mkdir -p /root/rpm/updates/redhat/
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


####################
# 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 ks.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


##########
# Add nsf:/usr/local to the filesystem table

X=`grep /usr/local /etc/fstab`
if [ "$X" = "-DISABLED-" ]; then 
   cat <<EOF >>/etc/fstab
# added by ks.sh on `date`
noether:/usr/local       /usr/local         nfs     defaults 0 0
EOF
fi


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

KVERS=2.4

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

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


####################
# Change LILO boot message & #read-only

if [ -f /boot/boot.txt ]; then
  cd /etc
  cp lilo.conf lilo.conf.ORIG
  sed -e "s%^message=.*$%message=/boot/boot.txt%" \
      -e "s/[ \t]*read-only/        read-only/" \
      < 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 " * Updating packages via autrpm..."
  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 ks.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) for boot time:

chkconfig ypbind off
chkconfig portmap off
chkconfig nfslock off
chkconfig nfs off
chkconfig netfs off
chkconfig amd off

chkconfig ipchains off
chkconfig sendmail off
chkconfig condor   off
chkconfig postfix  off
chkconfig afs      off

chkconfig wine   off
chkconfig pcmcia off

chkconfig rwhod on
chkconfig ntpd  on


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

chmod -x /root/ks.sh

echo " * ks.sh finished."

exit 0

# EOF

