-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgrade.sh
executable file
·51 lines (43 loc) · 1.04 KB
/
upgrade.sh
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
#!/bin/bash
#
# Arguments:
# 1) Jenkins job name. Like "gds-trunk-derby".
# 2) Instance name. "production", "customerA"...
# 3) Node number 0-99. Must be unique across applications, instances and servers
#
# read command line arguments
job=$1
instance=$2
node=`printf "%02i" $3`
# test arguments
if [ ! -n "${job}" ] ||
[ ! -n "${instance}" ] ||
[ ! -n "${node}" ]; then
echo "Usage: $0 job instance node"
exit -1
fi
# set up some variables
jar=$job-$instance.jar
dir=~/deploy/node${node}/
current=$dir/current
prev=$dir/prev
# create node directory
mkdir -p ${dir} ; cd ${dir}
# delete previous previous..
if [ -d $prev ]; then
rm -rf $prev
fi
# stop current and move to previous
if [ -d $current ]; then
(cd $current && bash control.sh stop $node)
mv $current $prev
fi
# establish current and start
mkdir $current $current/logs
cp ~/tmp/{control.sh,$job-$instance*} $current/
(cd $current
echo "node="${node} > .defaults
if [ -f $job-$instance.props ]; then
cat $job-$instance.props >> .defaults
fi
bash control.sh start ${node})