remote_update.sh
1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/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
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
# clean up
rm -rf $tmp 2> /dev/null
# 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
remotePath=`dirname $dir`
remoteDir=`basename $dir`
# now just do it
# TODO: return code handling
deploy
# reminder
echo "don't forget to run fix_perms.sh on the remote machine as root to allow the www user access to the dms"