#!/bin/sh

#**********************************************
#  /etc/syslog.conf
#**********************************************

cd /etc
if [ "$(grep "auth.*							/var/log/secure" /etc/syslog.conf)" = "" ] ; then
	csplit -f auth syslog.conf /"var/log/secure"/+1
	echo "auth.*							/var/log/secure" >> auth00
	cat auth01 >> auth00
	mv auth00 syslog.conf
	rm auth01
fi
	echo "auth.*							@watchlog" >> syslog.conf
sed -e 's/^#kern.*/kern.*/' /etc/syslog.conf >> /etc/syslog.conf.tmp
rm /etc/syslog.conf
mv /etc/syslog.conf.tmp /etc/syslog.conf

#**********************************************
#  /etc/hosts.deny
#**********************************************

cd /etc
mv hosts.deny hosts.deny.orig
cp /etc/$WORKGROUP/configfiles/hosts.deny /etc/hosts.deny

#**********************************************
#  /etc/hosts.allow
#**********************************************

cd /etc
mv hosts.allow hosts.allow.orig
cp /etc/$WORKGROUP/configfiles/hosts.allow /etc/hosts.allow

#**********************************************
#  Configure autorpm not to install by default
#**********************************************

cd /etc/autorpm.d
mv autorpm.conf autorpm.conf.orig
cp /etc/$WORKGROUP/configfiles/autorpm.conf autorpm.conf

#**********************************************
# Configure PCP so that it doesn't fail on startup.
# and put a script to run it daily
#**********************************************

/usr/sbin/install-pcp-config generic
cp /etc/$WORKGROUP/configfiles/pmlogger.cron /etc/cron.daily/pmlogger.cron

#**********************************************
# Edit /etc/hosts to add the short name
#**********************************************

sed -e 's/[	 ]\([a-z0-9-]*\)\.fnal\.gov$/&	\1/' /etc/hosts > /etc/hosts.tmp
mv /etc/hosts /etc.hosts.old
mv /etc/hosts.tmp /etc/hosts

#**********************************************
# Set up NIS.
#**********************************************

/usr/sbin/authconfig --kickstart --enablenis --nisdomain fsun01.fnal.gov

#**********************************************
# Set up .forward.
#**********************************************

echo scs-root@fnal.gov > /root/.forward

#**********************************************
# Restrict logons.
#**********************************************

if ! [ "`tail -1 /etc/passwd`" = "+::0:0:::/bin/true" ] ; then
    cp /etc/passwd /etc/passwd.orig
    cat /etc/$WORKGROUP/configfiles/tail.passwd >> /etc/passwd
fi

#**********************************************
# Configure rstatd to start at boot
#**********************************************

/sbin/chkconfig --level 345 rstatd on

#**********************************************
# Set correct permissions on mounted disks
#**********************************************

/bin/df -k
chmod 777 /usr/scratch/sect*
chmod 777 /usr/diskq/slot*

#**********************************************
# Setup Masquerading in sendmail.cf
#**********************************************

mv /etc/sendmail.cf /etc/sendmail.cf.orig
sed -e 's/^DM/DMfnal.gov/' /etc/sendmail.cf.orig > /etc/sendmail.cf

#**********************************************
# Create courtesy links to setups
#**********************************************

cd /usr/local/etc
ln -s /afs/fnal.gov/ups/etc/setups.sh setups.sh
ln -s /afs/fnal.gov/ups/etc/setups.csh setups.csh


#**********************************************
# Enable kerberized telnet, ftp and rsh
#**********************************************

/sbin/chkconfig telnet on
# /sbin/chkconfig ftp on
/sbin/chkconfig kshell on
/sbin/chkconfig klogin on
/sbin/chkconfig eklogin on

#**********************************************
# Configure rstatd to start at boot
#**********************************************

/sbin/chkconfig --level 345 rstatd on

#**********************************************
# Copy in the SCS root .k5login
#**********************************************

cp /etc/$WORKGROUP/configfiles/SCS.k5login /root/.k5login

#**********************************************
# Configure lsf.
#**********************************************

ln -s /afs/fnal.gov/ups/lsf/v4_1/@sys/nonfbatch/etc/lsf.conf /etc/lsf.conf
cp /etc/FnaluBatch/configfiles/lsf /etc/rc.d/init.d/lsf
cd /etc/rc.d/rc3.d
ln -s ../init.d/lsf S98lsf
mkdir /tmp/nonfbatch/lsf41.log
cd /etc

#**********************************************
# Remove Programs from startup.
#**********************************************

/sbin/chkconfig --del sendmail
/sbin/chkconfig --del kudzu
/sbin/chkconfig --del identd
/sbin/chkconfig --del apmd
/sbin/chkconfig --del lpd
/sbin/chkconfig --del rhnsd
/sbin/chkconfig --del ipchains
/sbin/chkconfig --del iptables
/sbin/chkconfig --del xfs

