-
Notifications
You must be signed in to change notification settings - Fork 3
/
manage.sh
executable file
·97 lines (81 loc) · 1.83 KB
/
manage.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
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
set -e
PIDFILE=gh.pid
LOGFILE=gh.log
function startbot() {
java -jar target/grouphug-1.0-SNAPSHOT.jar > $LOGFILE 2>&1 &
echo "$!" > $PIDFILE # save pid
}
function stopbot() {
if [ -e "$PIDFILE" ]
then
kill "$(cat $PIDFILE)" # kill bot
rm "$PIDFILE"
fi
}
function buildbot() {
mvn clean compile package
}
function testgithubpayload() {
java -cp target/grouphug-1.0-SNAPSHOT.jar no.kvikshaug.gh.github.GithubPostReceiveServer
}
function pullfrommaster() {
git pull murr4y master
}
function usage() {
echo "$0 [start|stop|build|restart|rebuild] or any combination of those"
echo "start: starts the bot"
echo "stop: stops the bot"
echo "build: recompiles the bot (not recommended while the bot is running)"
echo "restart: restarts the bot"
echo "rebuild: stops, recompiles, and starts the bot again"
echo "upgrade: stops, pulls from murr4y master, recompiles, and starts the bot again"
echo "test-payload: tries to parse a Github payload from stdin"
}
cd "$(dirname $0)"
if [ $# -lt 1 ]
then
usage
exit 1
fi
for arg in "$@"
do
case "$arg" in
"start")
startbot
;;
"stop")
stopbot
;;
"build")
buildbot
;;
"restart")
stopbot
startbot
;;
"rebuild")
stopbot
buildbot
startbot
;;
"test-payload")
testgithubpayload
;;
"upgrade")
stopbot
pullfrommaster
buildbot
startbot
;;
"upgradeproper")
pullfrommaster
buildbot
stopbot
startbot
;;
*)
usage
exit 1
esac
done