extend defaults and cleanup some potential problems

r1295 | dcl | 2006-11-16 14:05:23 +1100 (Thu, 16 Nov 2006) | 2 lines
This commit is contained in:
Douglas Clowes
2006-11-16 14:05:23 +11:00
parent 1eb206b3a1
commit 640e71153c

View File

@@ -1,8 +1,8 @@
#!/bin/sh
# $Revision: 1.10 $
# $Date: 2006-11-10 05:17:13 $
# $Revision: 1.11 $
# $Date: 2006-11-16 03:05:23 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by $Author: ffr $
# Last revision by $Author: dcl $
# Deploys SICServer and configuration files to
# an instrument control computer.
@@ -10,71 +10,103 @@
usage()
{
echo deploySICS.sh copies SICS and the files listed
echo in the MANIFEST.TXT files to the IC host.
echo -e "Usage:\t./deploySICS.sh INSTRUMENT [TARGET_HOST TARGET_DIR]";
echo -e "\t./deploySICS.sh test/INSTRUMENT [TARGET_HOST TARGET_DIR]";
echo -e "\twhere INSTRUMENT can be hrpd, echidna, hipd, wombat ...";
echo -e "\tTARGET_HOST can be a remote host or 'localhost'";
echo -e "\twill create last directory in TARGET_DIR if necessary";
cat <<EOF
deploySICS.sh copies SICS and the files listed
in the MANIFEST.TXT files to the IC host.
Usage:
./deploySICS.sh INSTRUMENT [TARGET_HOST [TARGET_DIR]]
or
./deploySICS.sh test/INSTRUMENT [TARGET_HOST [TARGET_DIR]]
where
INSTRUMENT can be hrpd, echidna, hipd, wombat, ...
TARGET_HOST can be a remote host or 'localhost'
defaults to ics1-<instrument>.nbi... or ics1-test.nbi... for test
TARGET_DIR is the top part of the directory tree
defaults to /usr/local or /usr/local/TEST_SICS/<instrument> for test
tail directories in TARGET_DIR will be created on TARGET_HOST if necessary
EOF
}
if [ $# -eq 0 -o $# -eq 2 -o $# -gt 3 ]
if [ $# -eq 0 -o $# -gt 3 ]
then
usage
exit 1
fi
TESTING=$(dirname "$1")
INSTRUMENT=$(basename "$1")
if [ "$INSTRUMENT" = "test" ]
then
TESTING=$(basename "$1")
INSTRUMENT=$(dirname "$1")
fi
INSTRUMENT=$1
SRCDIR="."
TEMPDIR=$HOME/tmp
SRCDIR=./
DESTDIR=${3:-/usr/local/}
mkdir -p ~/tmp/$DESTDIR
rm -fr ~/tmp/$DESTDIR/*
# Set the destination host and the
# Set the destination host
# instrument name and the
# instrument src directory
TESTING=$(dirname $INSTRUMENT)
INSTRUMENT=$(basename $INSTRUMENT)
case $INSTRUMENT in
echidna)
echidna|hrpd)
INSTRUMENT=echidna
DESTHOST=${2:-ics1-echidna.nbi.ansto.gov.au}
INSTSRC=hrpd;;
wombat)
wombat|hipd)
INSTRUMENT=wombat
DESTHOST=${2:-ics1-wombat.nbi.ansto.gov.au}
INSTSRC=hipd;;
koala)
koala|qld)
INSTRUMENT=koala
DESTHOST=${2:-ics1-koala.nbi.ansto.gov.au}
INSTSRC=qld;;
platypus)
platypus|reflectometer)
INSTRUMENT=platypus
DESTHOST=${2:-ics1-platypus.nbi.ansto.gov.au}
INSTSRC=reflectometer;;
kowari)
kowari|rsd)
INSTRUMENT=kowari
DESTHOST=${2:-ics1-kowari.nbi.ansto.gov.au}
INSTSRC=rsd;;
quokka)
quokka|sans)
INSTRUMENT=quokka
DESTHOST=${2:-ics1-quokka.nbi.ansto.gov.au}
INSTSRC=sans;;
pelican)
pelican|pas)
INSTRUMENT=pelican
DESTHOST=${2:-ics1-pelican.nbi.ansto.gov.au}
INSTSRC=pas;;
taipan)
taipan|tas)
INSTRUMENT=taipan
DESTHOST=${2:-ics1-taipan.nbi.ansto.gov.au}
INSTSRC=tas;;
esac
if [ $TESTING="test" ]; then
#copy TEST_SICS/fakeDMC
#TESTSRC=TEST_SICS
cp -a TEST_SICS/* ~/tmp/$DESTDIR
rm -fr $(find ~/tmp/$DESTDIR -name CVS)
DESTHOST=$2
if [ "$TESTING" = "test" ]
then
DESTHOST=${2:-ics1-test.nbi.ansto.gov.au}
DESTDIR=${3:-/usr/local}/TEST_SICS/$INSTRUMENT
# remove and recreate the temporary directory
rm -fr $TEMPDIR/$DESTDIR
mkdir -p $TEMPDIR/$DESTDIR
#copy TEST_SICS/fakeDMC and remove CVS any directories
cp -a $SRCDIR/TEST_SICS/* $TEMPDIR/$DESTDIR
rm -fr $(find $TEMPDIR/$DESTDIR -name CVS)
# step down to the sics directory
DESTDIR=$DESTDIR/sics
mkdir -p $TEMPDIR/$DESTDIR
else
DESTDIR=${3:-/usr/local}/sics
# remove and recreate the temporary directory
rm -fr $TEMPDIR/$DESTDIR
mkdir -p $TEMPDIR/$DESTDIR
fi
echo $DESTHOST
if [ $DESTHOST = "localhost" ]
echo "Deploying $INSTRUMENT to $DESTHOST:$DESTDIR"
if [ "$DESTHOST" = "localhost" ]
then
EXTRACT="tar vxz -C /"
else
@@ -86,9 +118,9 @@ then
echo "$SRCDIR/MANIFEST.TXT not found"
exit 1
fi
if [ ! -e $INSTSRC/MANIFEST.TXT ]
if [ ! -e $SRCDIR/$INSTSRC/MANIFEST.TXT ]
then
echo "$INSTSRC/MANIFEST.TXT not found"
echo "$SRCDIR/$INSTSRC/MANIFEST.TXT not found"
echo "You must list the files required for $INSTRUMENT in the manifest"
exit 1
fi
@@ -99,16 +131,16 @@ fi
COMMON=$(for f in $(cat $SRCDIR/MANIFEST.TXT); do echo -n "$SRCDIR/$f "; done)
INSTSPEC=$(for f in $(cat $INSTSRC/MANIFEST.TXT); do echo -n "$INSTSRC/$f "; done)
mkdir -p ~/tmp/$DESTDIR/sics/{server,data,log,tmp}
cp $COMMON $INSTSPEC ~/tmp/$DESTDIR/sics/server
cp ../SICServer ~/tmp/$DESTDIR/sics/server
mkdir -p $TEMPDIR/$DESTDIR/{server,data,log,tmp}
cp $COMMON $INSTSPEC $TEMPDIR/$DESTDIR/server
cp ../SICServer $TEMPDIR/$DESTDIR/server
# Create a manifest of the files installed on the IC host
echo "Date: $(date -Iminutes)" > ~/tmp/$DESTDIR/sics/server/MANIFEST.TXT
echo -e "The following files were installed by $USER\n" >> ~/tmp/$DESTDIR/sics/server/MANIFEST.TXT
cat $SRCDIR/MANIFEST.TXT $INSTSRC/MANIFEST.TXT >> ~/tmp/$DESTDIR/sics/server/MANIFEST.TXT
echo "Date: $(date -Iminutes)" > $TEMPDIR/$DESTDIR/server/MANIFEST.TXT
echo -e "The following files were installed by $USER\n" >> $TEMPDIR/$DESTDIR/server/MANIFEST.TXT
cat $SRCDIR/MANIFEST.TXT $SRCDIR/$INSTSRC/MANIFEST.TXT >> $TEMPDIR/$DESTDIR/server/MANIFEST.TXT
cd ~/tmp/
cd $TEMPDIR
# Strip leading / from DESTDIR and extract to destination
tar -cz ${DESTDIR:1} | $EXTRACT
tar -cz ${DESTDIR:1} | $EXTRACT