-
Notifications
You must be signed in to change notification settings - Fork 13
/
djs.sh
executable file
·84 lines (72 loc) · 1.53 KB
/
djs.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
#!/bin/bash
JENKINS_PORT=8080
show_help() {
echo "Jenkins-In-Container Management"
echo " -h show this help"
echo
echo "Available commands:"
echo " up"
echo " build <template>"
echo " add <template> <name>"
echo " stop <template> <name>"
}
djs_up() {
cd master
vagrant up
cd - > /dev/null
echo -e "\n=================================================="
djs_ip
echo -e "Start using slaves with adding one\n e.g. # ./djs.sh add centos7-java Luke"
}
djs_destroy() {
cd master
vagrant destroy -f
cd - > /dev/null
}
djs_ip() {
cd master
IP=$(vagrant ssh-config | grep 'HostName' | awk '{print $2}')
echo -e "Jenkins should be available on $IP:$JENKINS_PORT"
cd - > /dev/null
}
djs_build() {
cd master
vagrant ssh -c "cd /djs/slaves/$1 && sudo bash build.sh"
cd - > /dev/null
}
djs_add() {
cd master
vagrant ssh -c "cd /djs/slaves/$1 && sudo bash add_slave.sh $2"
cd - > /dev/null
}
djs_stop() {
cd master
vagrant ssh -c "cd /djs/slaves/$1 && sudo bash stop_slave.sh $2"
cd - > /dev/null
}
while getopts "h?" opt; do
case "$opt" in
h|\?)
show_help
exit 0
;;
esac
done
if [ -z "$1" ]; then
show_help
exit 0
fi
if [ "$1" == "up" ]; then
djs_up
elif [ "$1" == "ip" ]; then
djs_ip
elif [ "$1" == "destroy" ]; then
djs_destroy
elif [ "$1" == "build" ]; then
djs_build "$2"
elif [ "$1" == "add" ]; then
djs_add "$2" "$3"
else
echo "Unrecognized command"
show_help
fi