-
Notifications
You must be signed in to change notification settings - Fork 0
/
remotecommands
55 lines (51 loc) · 1.52 KB
/
remotecommands
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
#!/bin/sh
#directory for checkout of the prod-banch
tmpdir="/tmp/copyproduction"
#directory to deploy to (has to exist already)
proddir="/home/vagrant/production"
#link to repository
repository="https://github.com/ckristo/WAE-CM-SS2014-G1.git"
#path of the relevant parts inside of the repository
relevantpath="WAE-CM-SS2014-G1/csdr-g1"
#name of production branch in git
prodbranch="prod"
#path to play script
playpath="/home/vagrant/play-2.2.3/play"
#expression which uniquely identifies the process to kill (server process)
killexpr="java.*csdr-g1"
#delete old tmpdir
rm -rf $tmpdir
#recreate it
mkdir $tmpdir
cd $tmpdir
echo "Cloning branch \"$prodbranch\" from \"$repository\" into a temporary directory..." >&2
#clone prod-branch
git clone -b $prodbranch $repository > /dev/null
#check if git clone failed
OUT=$?
if [ $OUT -ne 0 ];then
echo "cloning failed" >&2
exit -1
fi
echo "done" >&2
echo "killing server..." >&2
#kill old instance of the server
pkill -f \'$killexpr\' >&2
echo "done" >&2
#remove the content of the production directory
rm -rf $proddir/*
echo "copying to production directory..." >&2
#copy contents of temp dir to prod dir
cp -r $tmpdir/$relevantpath/* $proddir
echo "done" >&2
cd $proddir
echo "compiling sources..." >&2
#clean, compile and stage the current implementation
$playpath clean > /dev/null
$playpath compile > /dev/null
$playpath stage > /dev/null
echo "done" >&2
echo "restarting server..." >&2
#restart server
nohup target/universal/stage/bin/csdr-g1 > csdr.out 2> csdr.err < /dev/null &
echo "done" >&2