#!/bin/sh # $Revision: 1.5 $ # $Date: 2006-10-13 06:32:41 $ # Author: Ferdi Franceschini (ffr@ansto.gov.au) # Last revision by $Author: ffr $ # Deploys SICServer and configuration files to # an instrument control computer. # It requires a MANIFEST.TXT file for each instrument 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"; } if [ $# -eq 0 -o $# -eq 2 -o $# -gt 3 ] then usage exit 1 fi INSTRUMENT=$1 SRCDIR=./ DESTDIR=${3:-/usr/local/} mkdir -p ~/tmp/$DESTDIR rm -fr ~/tmp/$DESTDIR/* # Set the destination host and the # instrument src directory case $INSTRUMENT in hrpd|echidna) DESTHOST=${2:-ic-echidna.nbi.ansto.gov.au} INSTSRC=hrpd;; hipd|wombat) DESTHOST=${2:-ic-wombat.nbi.ansto.gov.au} INSTSRC=hipd;; qld|koala) DESTHOST=${2:-ic-koala.nbi.ansto.gov.au} INSTSRC=qld;; reflectometer|platypus) DESTHOST=${2:-ic-platypus.nbi.ansto.gov.au} INSTSRC=reflectometer;; rsd|kowari) DESTHOST=${2:-ic-kowari.nbi.ansto.gov.au} INSTSRC=qld;; sans|quokka) DESTHOST=${2:-ic-quokka.nbi.ansto.gov.au} INSTSRC=sans;; tas|taipan) DESTHOST=${2:-ic-taipan.nbi.ansto.gov.au} INSTSRC=tas;; test/*) #copy TEST_SICS/fakeDMC #TESTSRC=TEST_SICS cp -a TEST_SICS/* ~/tmp/$DESTDIR rm -fr $(find ~/tmp/$DESTDIR -name CVS) DESTHOST=$2 INSTSRC=$(basename $INSTRUMENT);; esac echo $DESTHOST if [ $DESTHOST = "localhost" ] then EXTRACT="tar vxz -C /" else EXTRACT="ssh $DESTHOST tar vxz -C /" fi if [ ! -e $SRCDIR/MANIFEST.TXT ] then echo "$SRCDIR/MANIFEST.TXT not found" exit 1 fi if [ ! -e $INSTSRC/MANIFEST.TXT ] then echo "$INSTSRC/MANIFEST.TXT not found" echo "You must list the files required for $INSTRUMENT in the manifest" exit 1 fi # Get list of files to copy 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 # 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 cd ~/tmp/ # Strip leading / from DESTDIR and extract to destination tar -cz ${DESTDIR:1} | $EXTRACT