-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·88 lines (79 loc) · 1.51 KB
/
deploy.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh
# This script expects host names setup in .ssh/config :
# soccer-service hosts the web services running in Java
# soccer-web hosts the static web files
#
if [ $# != 1 ]
then
echo "Usage: bash $0 {restart|build|web|download|all}" >&2
exit
fi
PROJECT="soccer"
SCRIPTS="${PROJECT}/scripts/"
build()
{
mvn package assembly:single
STATUS=$?
if [ ${STATUS} -eq 0 ]; then
echo "Build Successful"
else
echo "Build Failed, exiting"
exit
fi
rsync -avr target/soccer-0.1-SNAPSHOT-jar-with-dependencies.jar soccer-service:${PROJECT}
}
deploy()
{
deployService
deployWeb
}
deployService()
{
echo "deploying files"
#rsync -avr data/* soccer-service:${PROJECT}/data
rsync -avr config/prod/ soccer-service:${PROJECT}/config/
rsync -avr scripts/*.sh soccer-service:${SCRIPTS}
ssh soccer-service chmod u+x ${SCRIPTS}*.sh
}
deployWeb()
{
echo "deploying web files"
rsync -avr web/ soccer-web:${PROJECT}.moulliet.com/
}
restart()
{
echo "restarting service"
ssh soccer-service bash ${SCRIPTS}${PROJECT}.sh restart
}
download()
{
echo "downloading and restarting service"
ssh soccer-service bash ${SCRIPTS}${PROJECT}.sh download
}
case $1 in
restart)
deploy
restart
;;
build)
build
deploy
restart
;;
web)
deployWeb
;;
all)
build
deploy
download
restart
;;
download)
deploy
download
restart
;;
*)
echo "Usage: bash $0 {restart|build|web|download|all}" >&2
esac