#!/bin/bash
# Post install script for ODS specific Linux environment
#
# postinstall_ods :
#   Created:   25 May 1999 Maarten Litmaath & Gerald Guglielmo
#   Modified:  27 May 1999 Gerald Guglielmo
#                          chown to root for flpr
#                          put /local/ups/db last in upsdb_list
#   Modified:   9 Aug 1999 Maarten Litmaath
#			   make it rerunnable, fix tcsh
#
#------------------------------------------------------------------------------
#
# add links for shells, yp exported passwd file from fndaub expects shell
# binaries in /usr/local/bin
#

cd /usr/local/bin

test -f tcsh || rm -f tcsh 	# get rid of broken tcsh 6.06

# what about bash?  in /bin and /usr/local/bin are 2 different versions...

for i in sh csh ksh tcsh
do
    test -f $i || ln -s /bin/$i .
done

#
# Setup NISDOMAIN for ODS
#

domain="NISDOMAIN=ols743across"
file=/etc/sysconfig/network

grep "$domain" $file > /dev/null || echo "$domain" >> $file

#
# update fstab file
#

cd /etc

del='floppy|cdrom|linux-rep'
add='#
/dev/fd0    /mnt/floppy   ext2     noauto,user,exec  0 0
/dev/fd0    /mnt/floppyd  msdos    noauto,user,exec  0 0
/dev/cdrom  /mnt/cdrom    iso9660  noauto,user,ro    0 0
#
linux-rep.fnal.gov:/mirror/ftp/pub/mirrors  /mnt/linrep  nfs  bg,soft,intr 0 0
#'

date=`date +%H%M%S`
temp=temp.$date
file=fstab

if (egrep -v "$del" $file; echo "$add") | uniq > $temp &&
    diff -b -w $file $temp | grep . > /dev/null
then
    mv $file $file.old
    mv $temp $file
else
    rm $temp
fi

for i in /mnt/linrep /mnt/floppyd
do
    test -d $i || mkdir $i
done

#
# update location of ups databases
#

cd /local/ups/etc

file=upsdb_list

new='/usr/products/ups_database
#/usr/products/cluster_disk/d0dist/upsdb
/local/ups/db'

if echo "$new" > $temp && diff -b -w $temp $file | grep . > /dev/null
then
    mv $file $file.old
    mv $temp $file
else
    rm $temp
fi

# Turn on autofs and ypbind

chkconfig autofs on
chkconfig ypbind on
#  added the following because redhat changed default in 6.1
chkconfig portmap on
# This used to be the if afs test then turn off xntp.  They said to hardcode it
chkconfig --level 2345 xntp off
