diff --git a/bin/remote_update.sh b/bin/remote_update.sh index 4615e9a..3118191 100755 --- a/bin/remote_update.sh +++ b/bin/remote_update.sh @@ -1,32 +1,68 @@ #!/bin/sh +# +# script to checkout the latest tagged build from cvs and upload +# to the remote server of your choice +## functions + +# displays the script usage message +# +usage() { + echo "usage: `basename $0` -t cvstag -h user@host -d remoteDir" + echo " eg. `basename $0` -t DMS_ITERATION1_29012003 -h michael@gobbler.jamwarehouse.com -d /usr/local/www/owl/dms" + exit 1 +} + +deploy() { + # cleanup + rm -rf $tmp* 2> /dev/null + mkdir $tmp + + # export owl + cd $tmp + #cvs -d $cvsroot co -r $tag owl + cvs -d $cvsroot co owl + cd owl/Documents + cvs update -d + # remove CVS directories + find $tmp -name CVS -exec rm -rf {} \; 2> /dev/null + + # tar it up + tar -czvf /tmp/owl.tgz $tmp + # punt it over the wall + scp /tmp/owl.tgz $host:/tmp/ + + # untar it remotely + ssh $host "cd $remotePath; mv $remoteDir $remoteDir-`date +%Y-%m-%d`; tar -zxvf /tmp/owl.tgz; rm /tmp/owl.tgz; mv tmp/dms/owl $remoteDir; rm -rf tmp" +} + +# check the command line options +if [ $# -lt 3 ]; then + usage +fi + +# process the params +while getopts ":t:h:d:" Option +do + case $Option in + t ) tag=$OPTARG;; + h ) host=$OPTARG;; + d ) dir=$OPTARG ;; + * ) usage;; + esac +done + +# check that everything we want is set +if [ -z $tag -o -z $host -o -z $dir ]; then + usage +fi + +# setup up some paths and stuff cvsroot=/usr/local/cvsroot tmp=/tmp/dms -tag=DMS_ITERATION1_29012003 -scpUser=michael -remote=gobbler.jamwarehouse.com -remotePath=/usr/local/www/owl -remoteDir=dms - -# cleanup -rm -rf $tmp* 2> /dev/null -mkdir $tmp - -# export owl -cd $tmp -#cvs -d $cvsroot co -r $tag owl -cvs -d $cvsroot co owl -cd owl/Documents -cvs update -d - -# remove CVS directories -find $tmp -name CVS -exec rm -rf {} \; 2> /dev/null - -# tar it up -tar -czvf /tmp/owl.tgz $tmp - -# punt it over the wall -scp /tmp/owl.tgz $scpUser@$remote:$remotePath - -# untar it remotely -ssh $scpUser@$remote "cd $remotePath; mv $remoteDir $remoteDir-`date +%Y-%m-%d`; tar -zxvf owl.tgz; rm owl.tgz; mv tmp/dms/owl $remoteDir; rm -rf tmp" +remotePath=`dirname $dir` +remoteDir=`basename $dir` + +# now just do it +# TODO: return code handling +deploy