#!/bin/sh

#  Get the IP address of the machine and determine the hostname via nslookup.
#  This is needed to build the NFS half of the fstab file.
#  you ought to be able to do this by looking at /mnt/sysimage/etc/HOSTNAME
IPADDR=`/bin/grep IPADDR /etc/sysconfig/network-scripts/ifcfg-eth0 | cut -d= -f 2`

THISHOST=`nslookup $IPADDR | grep -i "Name:" | cut -d":" -f 2 | sed "s/^ *//g"`
NICKNAME=`echo $THISHOST | cut -d. -f 1`

# Set eth0 to full duplex
if `/sbin/lspci | grep -i "Ethernet Pro 100"`
	then
		/bin/cp /etc/modules.conf /etc/modules.conf.orig
		/bin/echo "alias eth0 eepro100
		alias scsi_hostadapter aic7xxx
		options eepro100 options=0x30" > /etc/modules.conf
	elif `/sbin/lspci | grep -i "pcnet"`
	then
		/bin/cp /etc/modules.conf /etc/modules.conf.orig
		/bin/echo "alias eth0 pcnet32
		alias scsi_hostadapter aic7xxx
		options pcnet32 options=0x40" > /etc/modules.conf
	else
		:
fi

# Make directories, change permissions.
/bin/mkdir -p /fnal/ups
/bin/mkdir -p /pnfs/cms
/bin/mkdir -p /home/farms
/bin/mkdir -p /var/adm/krb5/farms
/bin/mkdir -p -m 700 /usr/spool/objy
/bin/mkdir -m 775 /data
/bin/chown 9811.5063 /data

/bin/chmod 1777 /tmp


# put the yp host into the hosts file.
/bin/cp /etc/hosts /etc/hosts.orig

/bin/echo "127.0.0.1       localhost.localdomain localhost
$IPADDR		$THISHOST	$NICKNAME	
131.225.206.41          cmsun1.fnal.gov                 cmsun1" > /etc/hosts

# put in the other name server
/bin/cp /etc/resolv.conf /etc/resolv.conf.orig
/bin/echo "search fnal.gov
nameserver 131.225.8.120
nameserver 131.225.17.150" > /etc/resolv.conf

# hosts.allow and hosts.deny

/bin/cp /etc/hosts.allow /etc/hosts.allow.orig
/bin/cp /etc/hosts.deny /etc/hosts.allow.deny
/bin/echo '#
# hosts.allow   This file describes the names of the hosts which are
#               allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
# 

portmap: 131.225.0.0/255.255.0.0 LOCAL 127.0.0.1
rpc.mountd: 131.225. LOCAL 127.0.0.1
ALL: .fnal.gov 131.225. LOCAL 127.0.0.1 : banners /etc/banners
sshd: ALL' > /etc/hosts.allow

/bin/echo '#
# hosts.deny    This file describes the names of the hosts which are
#               *not* allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow.  In particular
# you should know that NFS uses portmap!


ALL: ALL except 127.0.0.1 : banners /etc/banners' > /etc/hosts.deny


# yp.conf

/bin/cp /etc/CMSserver/configfiles/yp.conf /etc/yp.conf

/bin/cp /etc/CMSserver/configfiles/k5login /root/.k5login

# fix the nsswitch file to get your hostnames via DNS

/bin/cp /etc/nsswitch.conf /etc/nsswitch.conf.orig

/bin/cp /etc/CMSserver/configfiles/nsswitch.conf /etc/nsswitch.conf

# cat some optimizations into rc.local
/bin/cat /etc/CMSserver/configfiles/rc.local >> /etc/rc.d/rc.local

#put in a usable root .bashrc.
/bin/cp /etc/CMSserver/configfiles/root.bashrc /root/.bashrc

# Turn off unnecessary services.
/sbin/chkconfig --level 345 facct on
/sbin/chkconfig --level 345 autofs on
/sbin/chkconfig --level 345 portmap on
/sbin/chkconfig --level 345 rstatd on
/sbin/chkconfig --level 345 ypbind on
/sbin/chkconfig --level 345 kudzu off

/sbin/chkconfig --del sendmail
/sbin/chkconfig --del kudzu
/sbin/chkconfig --del identd
/sbin/chkconfig --del apmd

/sbin/chkconfig --add nfslock


/usr/sbin/install-pcp-config generic

rpm -e kernel-pcmcia-cs

/etc/cron.daily/slocate.cron
echo "/usr/X11R6/lib" >> /etc/ld.so.conf
echo "/usr/i486-linux-libc5/lib" >> /etc/ld.so.conf

/sbin/ldconfig

rm -f /usr/man/man1/rec.1
rm -f /usr/man/man8/rpc.mountd.8.gz
