#!/bin/bash
#

# Set up some NFS mount points

[ -d /fnal/ups ] || mkdir -p /fnal/ups

[ -d /scr/cepa01 ] || mkdir -p /scr/cepa01
[ -d /scr/cepa02 ] || mkdir -p /scr/cepa02

[ -d /ilc ] || mkdir /ilc


# edit fstab
if [ `grep cepasrv1.fnal.gov:/fnal/ups /etc/fstab | wc -l` -eq 0 ]
then
  echo 'cepasrv1.fnal.gov:/fnal/ups /fnal/ups nfs timeo=14,intr,rsize=8192,wsize=8192' >> /etc/fstab
fi

if [ `grep cepasrv1.fnal.gov:/scr/cepa01 /etc/fstab | wc -l` -eq 0 ]
then
  echo 'cepasrv1.fnal.gov:/scr/cepa01  /scr/cepa01 nfs timeo=14,intr,rsize=8192,wsize=8192' >> /etc/fstab
  echo 'cepasrv1.fnal.gov:/scr/cepa02  /scr/cepa02 nfs timeo=14,intr,rsize=8192,wsize=8192' >> /etc/fstab
fi

if [ `grep blue1.fnal.gov:/ilc /etc/fstab | wc -l` -eq 0 ]
then
  echo 'blue1.fnal.gov:/ilc	/ilc	nfs rsize=32768,wsize=32768,timeo=600,proto=tcp,vers=3,hard,intr,bg 0 0' >> /etc/fstab
fi

# check for products account
if [ `grep products /etc/passwd | wc -l` -eq 0 ]
then
  echo 'products:x:1342:4525:UPS Products:/fnal/ups:/bin/tcsh' >> /etc/passwd
fi
if [ `grep products /etc/group | wc -l` -eq 0 ]
then
  echo 'products:-:4525:' >> /etc/group
fi


# establish ups
mount /fnal/ups
if [ -f "/fnal/ups/etc/setups.sh" ]
then
  . "/fnal/ups/etc/setups.sh"
  # start ups at boot time
  if [ ! -f /etc/rc.d/init.d/ups ] 
  then
     cp $UPS_DIR/init.d/ups /etc/rc.d/init.d/ups
     /etc/rc.d/init.d/ups config
  fi
fi

#  send root mail to garren
if [ `grep root: /etc/aliases | grep -v \# | wc -l` -eq 0 ]
then
  echo 'root: garren@fnal.gov' >> /etc/aliases
  /usr/bin/newaliases
fi

# create .k5login for root
if [ ! -f "/root/.k5login" ]
then
    echo "garren@FNAL.GOV" > /root/.k5login
    echo "wenzel@FNAL.GOV" >> /root/.k5login
fi
