-
Notifications
You must be signed in to change notification settings - Fork 0
/
adapter.sh
192 lines (157 loc) · 3.72 KB
/
adapter.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/bin/bash
# this needs sudo access...
COM1=$1
COM2=$2
install() {
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install nomad
nomad
}
start() {
case $COM2 in
'server')
echo "Starting server"
SERVER_DIR="/etc/nunet-adapter/server"
if [ ! -d $SERVER_DIR ]; then
sudo mkdir -p $SERVER_DIR
fi
sudo cp ./configs/server.hcl $SERVER_DIR/
sudo cp ./configs/nomad_server.service /etc/systemd/system/
sudo systemctl enable nomad_server.service
sudo systemctl start nomad_server.service
;;
'client')
echo "Starting client"
if [ ! -d /etc/nunet-adapter/client ]; then
sudo mkdir -p /etc/nunet-adapter/client
fi
CLIENT_DIR="/etc/nunet-adapter/client"
if [ ! -d $CLIENT_DIR ]; then
sudo mkdir -p $CLIENT_DIR
fi
sudo cp ./configs/client.hcl $CLIENT_DIR/
sudo cp ./configs/nomad_client.service /etc/systemd/system/
sudo systemctl enable nomad_client.service
sudo systemctl start nomad_client.service
;;
'office-client')
echo "Starting client"
if [ ! -d /etc/nunet-adapter/client ]; then
sudo mkdir -p /etc/nunet-adapter/client
fi
CLIENT_DIR="/etc/nunet-adapter/client"
if [ ! -d $CLIENT_DIR ]; then
sudo mkdir -p $CLIENT_DIR
fi
sudo cp ./configs/office-desktop.hcl $CLIENT_DIR/
sudo cp ./configs/nomad_client_office.service /etc/systemd/system/
sudo systemctl enable nomad_client_office.service
sudo systemctl start nomad_client_office.service
;;
'dev')
echo "Starting Dev"
DEV_DIR="/etc/nunet-adapter/dev"
if [ ! -d $DEV_DIR ]; then
sudo mkdir -p $DEV_DIR
fi
stop server
stop client
sudo cp ./configs/dev.hcl $DEV_DIR/
sudo cp ./configs/nomad_dev.service /etc/systemd/system/
sudo systemctl enable nomad_dev.service
sudo systemctl start nomad_dev.service
;;
esac
}
stop() {
case $COM2 in
'server')
echo "Stopping Nomad Server"
sudo systemctl stop nomad_server.service
;;
'client')
echo "Stopping Nomad Client"
sudo systemctl stop nomad_client.service
;;
'office-client')
echo "Stopping Nomad Office Client"
sudo systemctl stop nomad_client_office.service
;;
'dev')
echo "Stopping Nomad Dev"
sudo systemctl stop nomad_dev.service
;;
esac
}
restart() {
case $COM2 in
'server')
echo "Restarting Nomad Server"
sudo systemctl restart nomad_server.service
;;
'client')
echo "Restarting Nomad Client"
sudo systemctl restart nomad_client.service
;;
'office-client')
echo "Restarting Nomad Office Client"
sudo systemctl restart nomad_client_office.service
;;
'dev')
echo "Restarting Nomad Dev"
sudo systemctl restart nomad_dev.service
;;
esac
}
uninstall() {
case $COM2 in
'server')
echo "Uninstalling Nomad Server"
stop server
sudo systemctl disable nomad_server.service
;;
'client')
echo "Uninstalling Nomad Client"
stop client
sudo systemctl disable nomad_client.service
;;
'office-client')
echo "Uninstalling Nomad Office Client"
sudo systemctl disable nomad_client_office.service
;;
'dev')
echo "Uninstalling Nomad Dev"
stop dev
sudo systemctl disable nomad_dev.service
;;
esac
}
status() {
systemctl status nomad_server.service --no-pager
systemctl status nomad_client.service --no-pager
systemctl status nomad_client_office.service --no-pager
systemctl status nomad_dev.service --no-pager
}
case $COM1 in
'start')
echo "Starting nunet-adapter"
start
;;
'stop')
stop
;;
'restart')
restart
;;
'status')
status
;;
'install')
install
;;
'uninstall')
uninstall
;;
esac
exit 0