Commit 79c52e7625fe9ee593b4bd677b7ab90ce18c0fc7

Authored by Michael Joseph
1 parent a39284ed

added option handling to script


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@708 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 64 additions and 28 deletions
bin/remote_update.sh
1 #!/bin/sh 1 #!/bin/sh
  2 +#
  3 +# script to checkout the latest tagged build from cvs and upload
  4 +# to the remote server of your choice
2 5
  6 +## functions
  7 +
  8 +# displays the script usage message
  9 +#
  10 +usage() {
  11 + echo "usage: `basename $0` -t cvstag -h user@host -d remoteDir"
  12 + echo " eg. `basename $0` -t DMS_ITERATION1_29012003 -h michael@gobbler.jamwarehouse.com -d /usr/local/www/owl/dms"
  13 + exit 1
  14 +}
  15 +
  16 +deploy() {
  17 + # cleanup
  18 + rm -rf $tmp* 2> /dev/null
  19 + mkdir $tmp
  20 +
  21 + # export owl
  22 + cd $tmp
  23 + #cvs -d $cvsroot co -r $tag owl
  24 + cvs -d $cvsroot co owl
  25 + cd owl/Documents
  26 + cvs update -d
  27 + # remove CVS directories
  28 + find $tmp -name CVS -exec rm -rf {} \; 2> /dev/null
  29 +
  30 + # tar it up
  31 + tar -czvf /tmp/owl.tgz $tmp
  32 + # punt it over the wall
  33 + scp /tmp/owl.tgz $host:/tmp/
  34 +
  35 + # untar it remotely
  36 + 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"
  37 +}
  38 +
  39 +# check the command line options
  40 +if [ $# -lt 3 ]; then
  41 + usage
  42 +fi
  43 +
  44 +# process the params
  45 +while getopts ":t:h:d:" Option
  46 +do
  47 + case $Option in
  48 + t ) tag=$OPTARG;;
  49 + h ) host=$OPTARG;;
  50 + d ) dir=$OPTARG ;;
  51 + * ) usage;;
  52 + esac
  53 +done
  54 +
  55 +# check that everything we want is set
  56 +if [ -z $tag -o -z $host -o -z $dir ]; then
  57 + usage
  58 +fi
  59 +
  60 +# setup up some paths and stuff
3 cvsroot=/usr/local/cvsroot 61 cvsroot=/usr/local/cvsroot
4 tmp=/tmp/dms 62 tmp=/tmp/dms
5 -tag=DMS_ITERATION1_29012003  
6 -scpUser=michael  
7 -remote=gobbler.jamwarehouse.com  
8 -remotePath=/usr/local/www/owl  
9 -remoteDir=dms  
10 -  
11 -# cleanup  
12 -rm -rf $tmp* 2> /dev/null  
13 -mkdir $tmp  
14 -  
15 -# export owl  
16 -cd $tmp  
17 -#cvs -d $cvsroot co -r $tag owl  
18 -cvs -d $cvsroot co owl  
19 -cd owl/Documents  
20 -cvs update -d  
21 -  
22 -# remove CVS directories  
23 -find $tmp -name CVS -exec rm -rf {} \; 2> /dev/null  
24 -  
25 -# tar it up  
26 -tar -czvf /tmp/owl.tgz $tmp  
27 -  
28 -# punt it over the wall  
29 -scp /tmp/owl.tgz $scpUser@$remote:$remotePath  
30 -  
31 -# untar it remotely  
32 -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" 63 +remotePath=`dirname $dir`
  64 +remoteDir=`basename $dir`
  65 +
  66 +# now just do it
  67 +# TODO: return code handling
  68 +deploy