
#!/bin/sh
# Copy ASML usermap.cfg to ATOS PBS filer
# WRoe 17-4-2007
# Adapted for usage with sudo
# 
#set -x
PATH=$PATH:/appl/tsu/bin
SOURCE=/filers/hwnaf01/usrmap/usermap.cfg
DEST=/filers/hwnaf01/vol0/etc/usermap.cfg
#DEST=/filers/hwnaf01/vol0/etc/test.cfg
#RECIPIENT="wim.roelofs@atosorigin.com"
RECIPIENT="gmnl-msscentral@atosorigin.com, pascal.dukers@asml.com, richard.van.der.ven@asml.com, wim.roelofs@atosorigin.com" 
#
# nfs mount reachable, file exists ?
sudo test -f ${SOURCE}
if [ $? -eq 1 ]; then 
  echo "${SOURCE} no such file" | mailx -s 'ASML Usermap.cfg copy failed' $RECIPIENT
  exit
fi 

sudo diff $SOURCE $DEST > /dev/null 2>&1
if [ $? -ge 1 ]; then
  sudo cp ${DEST}.0 ${DEST}.1 > /dev/null 2>&1
  sudo cp $DEST ${DEST}.0  > /dev/null 2>&1
  sudo cp ${SOURCE} ${DEST}
  RESULT="` sudo ls -l ${SOURCE}`\n` sudo ls -l $DEST`"
  echo $RESULT |mailx -s 'ASML usermap.cfg copy succeeded' $RECIPIENT  
else
  date | mailx -s 'ASML usermap.cfg unchanged, copy skipped' $RECIPIENT
fi 

