#!/bin/bash
# Post install script for OAA specific Linux environment
#
# after.rpms.sh :
#   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
#   Modified:  28 Apr 2003 Dave Slimmer update for Fermi Linux 90x
#   Modified:  27 Jun 2003 Dave Slimmer update for Fermi Linux 901
#
#------------------------------------------------------------------------------
#
# add links for shells, yp exported passwd file from fnods expects shell
# binaries in /usr/local/bin
#
# echo commands
# set -x

cd /usr/local/bin

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

#
# Setup NISDOMAIN for OAA
#

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

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

#
# update fstab file
#

cd /etc

del='linux-rep'
add='#
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
    /bin/rm $temp
fi

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

#
# update location of ups databases
#

cd /fnal/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
    /bin/rm $temp
fi

