##// END OF EJS Templates
rccontrol: version bump
super-admin -
Show More
@@ -1,4124 +1,4124 b''
1 #!/usr/bin/env bash
1 #!/usr/bin/env bash
2 # This script was generated
2 # This script was generated
3 # Modifying it manually is not recommended
3 # Modifying it manually is not recommended
4
4
5 check_bash_version() {
5 check_bash_version() {
6 if [ ! "${BASH_VERSINFO:-0}" -ge 4 ]; then
6 if [ ! "${BASH_VERSINFO:-0}" -ge 4 ]; then
7 echo "Bash version 4 or greater is required (got ${BASH_VERSINFO}), please update your bash version!"
7 echo "Bash version 4 or greater is required (got ${BASH_VERSINFO}), please update your bash version!"
8 exit 1
8 exit 1
9 fi
9 fi
10 }
10 }
11 check_bash_version
11 check_bash_version
12
12
13 # :command.master_script
13 # :command.master_script
14
14
15 # :command.version_command
15 # :command.version_command
16 version_command() {
16 version_command() {
17 echo "$version"
17 echo "$version"
18 }
18 }
19
19
20 # :command.usage
20 # :command.usage
21 rccontrol_usage() {
21 rccontrol_usage() {
22 if [[ -n $long_usage ]]; then
22 if [[ -n $long_usage ]]; then
23 printf "rccontrol - RhodeCode Control - CLI for installing and managing RhodeCode Cluster Stack\n"
23 printf "rccontrol - RhodeCode Control - CLI for installing and managing RhodeCode Cluster Stack\n"
24 echo
24 echo
25
25
26 else
26 else
27 printf "rccontrol - RhodeCode Control - CLI for installing and managing RhodeCode Cluster Stack\n"
27 printf "rccontrol - RhodeCode Control - CLI for installing and managing RhodeCode Cluster Stack\n"
28 echo
28 echo
29
29
30 fi
30 fi
31
31
32 printf "Usage:\n"
32 printf "Usage:\n"
33 printf " rccontrol [OPTIONS] COMMAND\n"
33 printf " rccontrol [OPTIONS] COMMAND\n"
34 printf " rccontrol [COMMAND] --help | -h\n"
34 printf " rccontrol [COMMAND] --help | -h\n"
35 printf " rccontrol --version | -v\n"
35 printf " rccontrol --version | -v\n"
36 echo
36 echo
37 # :command.usage_commands
37 # :command.usage_commands
38 printf "Commands:\n"
38 printf "Commands:\n"
39 echo " self-update update rccontrol and it's docker definitions"
39 echo " self-update update rccontrol and it's docker definitions"
40 echo " bootstrap Bootstrap this machine, check docker version and install rhodecode-network"
40 echo " bootstrap Bootstrap this machine, check docker version and install rhodecode-network"
41 echo
41 echo
42 printf "Build Commands:\n"
42 printf "Build Commands:\n"
43 echo " get-build-artifacts Fetch Artifacts to run installer based build"
43 echo " get-build-artifacts Fetch Artifacts to run installer based build"
44 echo " build Build RhodeCode image from installer"
44 echo " build Build RhodeCode image from installer"
45 echo " get-build-source Fetch RhodeCode sources, store in .source dir to run a source-based builds"
45 echo " get-build-source Fetch RhodeCode sources, store in .source dir to run a source-based builds"
46 echo " build-source Build RhodeCode image from source, requires upgrade-source initially"
46 echo " build-source Build RhodeCode image from source, requires upgrade-source initially"
47 echo
47 echo
48 printf "Stack Commands:\n"
48 printf "Stack Commands:\n"
49 echo " stack run one of available cluster stacks, run stack -h for more details"
49 echo " stack run one of available cluster stacks, run stack -h for more details"
50 echo " stack-status Show stack status"
50 echo " stack-status Show stack status"
51 echo " stack-upgrade upgrade ALL stack status"
51 echo " stack-upgrade upgrade ALL stack status"
52 echo
52 echo
53 printf "CLI Commands:\n"
53 printf "CLI Commands:\n"
54 echo " cli Various CLI tools, run cli -h for more details"
54 echo " cli Various CLI tools, run cli -h for more details"
55 echo
55 echo
56 printf "Backup Commands:\n"
56 printf "Backup Commands:\n"
57 echo " backup-db Backup Database"
57 echo " backup-db Backup Database"
58 echo " backup-data Backup RhodeCode storage"
58 echo " backup-data Backup RhodeCode storage"
59 echo
59 echo
60
60
61 # :command.long_usage
61 # :command.long_usage
62 if [[ -n $long_usage ]]; then
62 if [[ -n $long_usage ]]; then
63 printf "Options:\n"
63 printf "Options:\n"
64
64
65 # :command.usage_fixed_flags
65 # :command.usage_fixed_flags
66 echo " --help, -h"
66 echo " --help, -h"
67 printf " Show this help\n"
67 printf " Show this help\n"
68 echo
68 echo
69 echo " --version, -v"
69 echo " --version, -v"
70 printf " Show version number\n"
70 printf " Show version number\n"
71 echo
71 echo
72
72
73 # :command.usage_flags
73 # :command.usage_flags
74 # :flag.usage
74 # :flag.usage
75 echo " --debug"
75 echo " --debug"
76 printf " Enable debug and detailed output\n"
76 printf " Enable debug and detailed output\n"
77 echo
77 echo
78
78
79 # :command.usage_environment_variables
79 # :command.usage_environment_variables
80 printf "Environment Variables:\n"
80 printf "Environment Variables:\n"
81
81
82 # :environment_variable.usage
82 # :environment_variable.usage
83 echo " RCC_CONFIG"
83 echo " RCC_CONFIG"
84 printf " default config file for rccontrol\n"
84 printf " default config file for rccontrol\n"
85 printf " Default: .rccontrol.ini\n"
85 printf " Default: .rccontrol.ini\n"
86 echo
86 echo
87
87
88 # :environment_variable.usage
88 # :environment_variable.usage
89 echo " AUTH_TOKEN"
89 echo " AUTH_TOKEN"
90 printf " Set your RhodeCode AUTH Token\n"
90 printf " Set your RhodeCode AUTH Token\n"
91 echo
91 echo
92
92
93 # :environment_variable.usage
93 # :environment_variable.usage
94 echo " RC_CLI_VERSION_NAME"
94 echo " RC_CLI_VERSION_NAME"
95 printf " default version to build and install\n"
95 printf " default version to build and install\n"
96 printf " Default: 4.27.0\n"
96 printf " Default: 4.27.0\n"
97 echo
97 echo
98
98
99 # :environment_variable.usage
99 # :environment_variable.usage
100 echo " RC_STACK_ROUTER_EXT"
100 echo " RC_STACK_ROUTER_EXT"
101 printf "\n"
101 printf "\n"
102 printf " Default: .custom/docker-compose-router.override.yaml\n"
102 printf " Default: .custom/docker-compose-router.override.yaml\n"
103 echo
103 echo
104
104
105 # :environment_variable.usage
105 # :environment_variable.usage
106 echo " RC_STACK_METRICS_EXT"
106 echo " RC_STACK_METRICS_EXT"
107 printf "\n"
107 printf "\n"
108 printf " Default: .custom/docker-compose-metrics.override.yaml\n"
108 printf " Default: .custom/docker-compose-metrics.override.yaml\n"
109 echo
109 echo
110
110
111 # :environment_variable.usage
111 # :environment_variable.usage
112 echo " RC_STACK_SERVICES_EXT"
112 echo " RC_STACK_SERVICES_EXT"
113 printf "\n"
113 printf "\n"
114 printf " Default: .custom/docker-compose-services.override.yaml\n"
114 printf " Default: .custom/docker-compose-services.override.yaml\n"
115 echo
115 echo
116
116
117 # :environment_variable.usage
117 # :environment_variable.usage
118 echo " RC_STACK_RHODECODE_EXT"
118 echo " RC_STACK_RHODECODE_EXT"
119 printf "\n"
119 printf "\n"
120 printf " Default: .custom/docker-compose-apps.override.yaml\n"
120 printf " Default: .custom/docker-compose-apps.override.yaml\n"
121 echo
121 echo
122
122
123 # :command.footer
123 # :command.footer
124 printf "RhodeCode Inc 2022\n\n"
124 printf "RhodeCode Inc 2022\n\n"
125 echo
125 echo
126
126
127 fi
127 fi
128 }
128 }
129
129
130 # :command.usage
130 # :command.usage
131 rccontrol_self_update_usage() {
131 rccontrol_self_update_usage() {
132 if [[ -n $long_usage ]]; then
132 if [[ -n $long_usage ]]; then
133 printf "rccontrol self-update - update rccontrol and it's docker definitions\n"
133 printf "rccontrol self-update - update rccontrol and it's docker definitions\n"
134 echo
134 echo
135
135
136 else
136 else
137 printf "rccontrol self-update - update rccontrol and it's docker definitions\n"
137 printf "rccontrol self-update - update rccontrol and it's docker definitions\n"
138 echo
138 echo
139
139
140 fi
140 fi
141
141
142 printf "Usage:\n"
142 printf "Usage:\n"
143 printf " rccontrol self-update [OPTIONS]\n"
143 printf " rccontrol self-update [OPTIONS]\n"
144 printf " rccontrol self-update --help | -h\n"
144 printf " rccontrol self-update --help | -h\n"
145 echo
145 echo
146
146
147 # :command.long_usage
147 # :command.long_usage
148 if [[ -n $long_usage ]]; then
148 if [[ -n $long_usage ]]; then
149 printf "Options:\n"
149 printf "Options:\n"
150
150
151 # :command.usage_fixed_flags
151 # :command.usage_fixed_flags
152 echo " --help, -h"
152 echo " --help, -h"
153 printf " Show this help\n"
153 printf " Show this help\n"
154 echo
154 echo
155
155
156 # :command.usage_flags
156 # :command.usage_flags
157 # :flag.usage
157 # :flag.usage
158 echo " --revision REVISION"
158 echo " --revision REVISION"
159 printf " revision to fetch new installer.\n"
159 printf " revision to fetch new installer.\n"
160 printf " Default: master\n"
160 printf " Default: master\n"
161 echo
161 echo
162
162
163 # :flag.usage
163 # :flag.usage
164 echo " --auth-token AUTH_TOKEN"
164 echo " --auth-token AUTH_TOKEN"
165 printf " Optionally specify AUTH TOKEN to obtain sources\n"
165 printf " Optionally specify AUTH TOKEN to obtain sources\n"
166 echo
166 echo
167
167
168 # :flag.usage
168 # :flag.usage
169 echo " --server-url SERVER_URL"
169 echo " --server-url SERVER_URL"
170 printf " Specify RhodeCode server location where projects should be downloaded\n"
170 printf " Specify RhodeCode server location where projects should be downloaded\n"
171 printf " Default: https://code.rhodecode.com\n"
171 printf " Default: https://code.rhodecode.com\n"
172 echo
172 echo
173
173
174 fi
174 fi
175 }
175 }
176
176
177 # :command.usage
177 # :command.usage
178 rccontrol_bootstrap_usage() {
178 rccontrol_bootstrap_usage() {
179 if [[ -n $long_usage ]]; then
179 if [[ -n $long_usage ]]; then
180 printf "rccontrol bootstrap - Bootstrap this machine, check docker version and install rhodecode-network\n"
180 printf "rccontrol bootstrap - Bootstrap this machine, check docker version and install rhodecode-network\n"
181 echo
181 echo
182
182
183 else
183 else
184 printf "rccontrol bootstrap - Bootstrap this machine, check docker version and install rhodecode-network\n"
184 printf "rccontrol bootstrap - Bootstrap this machine, check docker version and install rhodecode-network\n"
185 echo
185 echo
186
186
187 fi
187 fi
188
188
189 printf "Alias: init\n"
189 printf "Alias: init\n"
190 echo
190 echo
191
191
192 printf "Usage:\n"
192 printf "Usage:\n"
193 printf " rccontrol bootstrap [OPTIONS]\n"
193 printf " rccontrol bootstrap [OPTIONS]\n"
194 printf " rccontrol bootstrap --help | -h\n"
194 printf " rccontrol bootstrap --help | -h\n"
195 echo
195 echo
196
196
197 # :command.long_usage
197 # :command.long_usage
198 if [[ -n $long_usage ]]; then
198 if [[ -n $long_usage ]]; then
199 printf "Options:\n"
199 printf "Options:\n"
200
200
201 # :command.usage_fixed_flags
201 # :command.usage_fixed_flags
202 echo " --help, -h"
202 echo " --help, -h"
203 printf " Show this help\n"
203 printf " Show this help\n"
204 echo
204 echo
205
205
206 # :command.usage_flags
206 # :command.usage_flags
207 # :flag.usage
207 # :flag.usage
208 echo " --force, -f"
208 echo " --force, -f"
209 printf " Overwrite existing files\n"
209 printf " Overwrite existing files\n"
210 echo
210 echo
211
211
212 # :flag.usage
212 # :flag.usage
213 echo " --auth-token AUTH_TOKEN"
213 echo " --auth-token AUTH_TOKEN"
214 printf " Optionally specify AUTH TOKEN to obtain sources\n"
214 printf " Optionally specify AUTH TOKEN to obtain sources\n"
215 echo
215 echo
216
216
217 # :flag.usage
217 # :flag.usage
218 echo " --server-url SERVER_URL"
218 echo " --server-url SERVER_URL"
219 printf " Specify RhodeCode server location where projects should be downloaded\n"
219 printf " Specify RhodeCode server location where projects should be downloaded\n"
220 printf " Default: https://code.rhodecode.com\n"
220 printf " Default: https://code.rhodecode.com\n"
221 echo
221 echo
222
222
223 # :command.usage_examples
223 # :command.usage_examples
224 printf "Examples:\n"
224 printf "Examples:\n"
225 printf " rccontrol init\n"
225 printf " rccontrol init\n"
226 printf " rccontrol bootstrap\n"
226 printf " rccontrol bootstrap\n"
227 printf " rccontrol bootstrap --force\n"
227 printf " rccontrol bootstrap --force\n"
228 echo
228 echo
229
229
230 fi
230 fi
231 }
231 }
232
232
233 # :command.usage
233 # :command.usage
234 rccontrol_get_build_artifacts_usage() {
234 rccontrol_get_build_artifacts_usage() {
235 if [[ -n $long_usage ]]; then
235 if [[ -n $long_usage ]]; then
236 printf "rccontrol get-build-artifacts - Fetch Artifacts to run installer based build\n"
236 printf "rccontrol get-build-artifacts - Fetch Artifacts to run installer based build\n"
237 echo
237 echo
238
238
239 else
239 else
240 printf "rccontrol get-build-artifacts - Fetch Artifacts to run installer based build\n"
240 printf "rccontrol get-build-artifacts - Fetch Artifacts to run installer based build\n"
241 echo
241 echo
242
242
243 fi
243 fi
244
244
245 printf "Usage:\n"
245 printf "Usage:\n"
246 printf " rccontrol get-build-artifacts [OPTIONS]\n"
246 printf " rccontrol get-build-artifacts [OPTIONS]\n"
247 printf " rccontrol get-build-artifacts --help | -h\n"
247 printf " rccontrol get-build-artifacts --help | -h\n"
248 echo
248 echo
249
249
250 # :command.long_usage
250 # :command.long_usage
251 if [[ -n $long_usage ]]; then
251 if [[ -n $long_usage ]]; then
252 printf "Options:\n"
252 printf "Options:\n"
253
253
254 # :command.usage_fixed_flags
254 # :command.usage_fixed_flags
255 echo " --help, -h"
255 echo " --help, -h"
256 printf " Show this help\n"
256 printf " Show this help\n"
257 echo
257 echo
258
258
259 # :command.usage_flags
259 # :command.usage_flags
260 # :flag.usage
260 # :flag.usage
261 echo " --auth AUTH"
261 echo " --auth AUTH"
262 printf " Specify custom auth for curl e.g -u admin:secret\n"
262 printf " Specify custom auth for curl e.g -u admin:secret\n"
263 printf " Default: \n"
263 printf " Default: \n"
264 echo
264 echo
265
265
266 # :flag.usage
266 # :flag.usage
267 echo " --installer-url INSTALLER_URL"
267 echo " --installer-url INSTALLER_URL"
268 printf " Installer Download URL\n"
268 printf " Installer Download URL\n"
269 printf " Default: https://dls.rhodecode.com/dls/N2E2ZTY1NzA3NjYxNDA2NTc1NjI3MTcyNzA2MjcxNzIyZTcwNjI3YQ==/rhodecode-control/latest-linux-ee\n"
269 printf " Default: https://dls.rhodecode.com/dls/N2E2ZTY1NzA3NjYxNDA2NTc1NjI3MTcyNzA2MjcxNzIyZTcwNjI3YQ==/rhodecode-control/latest-linux-ee\n"
270 echo
270 echo
271
271
272 # :flag.usage
272 # :flag.usage
273 echo " --manifest-url MANIFEST_URL"
273 echo " --manifest-url MANIFEST_URL"
274 printf " Manifest file url\n"
274 printf " Manifest file url\n"
275 printf " Default: https://dls.rhodecode.com/linux/MANIFEST\n"
275 printf " Default: https://dls.rhodecode.com/linux/MANIFEST\n"
276 echo
276 echo
277
277
278 # :flag.usage
278 # :flag.usage
279 echo " --version-name VERSION_NAME"
279 echo " --version-name VERSION_NAME"
280 printf " Specify custom build ver e.g $RC_CLI_VERSION_NAME\n"
280 printf " Specify custom build ver e.g $RC_CLI_VERSION_NAME\n"
281 printf " Default: $RC_CLI_VERSION_NAME\n"
281 printf " Default: $RC_CLI_VERSION_NAME\n"
282 echo
282 echo
283
283
284 fi
284 fi
285 }
285 }
286
286
287 # :command.usage
287 # :command.usage
288 rccontrol_build_usage() {
288 rccontrol_build_usage() {
289 if [[ -n $long_usage ]]; then
289 if [[ -n $long_usage ]]; then
290 printf "rccontrol build - Build RhodeCode image from installer\n"
290 printf "rccontrol build - Build RhodeCode image from installer\n"
291 echo
291 echo
292
292
293 else
293 else
294 printf "rccontrol build - Build RhodeCode image from installer\n"
294 printf "rccontrol build - Build RhodeCode image from installer\n"
295 echo
295 echo
296
296
297 fi
297 fi
298
298
299 printf "Usage:\n"
299 printf "Usage:\n"
300 printf " rccontrol build [OPTIONS]\n"
300 printf " rccontrol build [OPTIONS]\n"
301 printf " rccontrol build --help | -h\n"
301 printf " rccontrol build --help | -h\n"
302 echo
302 echo
303
303
304 # :command.long_usage
304 # :command.long_usage
305 if [[ -n $long_usage ]]; then
305 if [[ -n $long_usage ]]; then
306 printf "Options:\n"
306 printf "Options:\n"
307
307
308 # :command.usage_fixed_flags
308 # :command.usage_fixed_flags
309 echo " --help, -h"
309 echo " --help, -h"
310 printf " Show this help\n"
310 printf " Show this help\n"
311 echo
311 echo
312
312
313 # :command.usage_flags
313 # :command.usage_flags
314 # :flag.usage
314 # :flag.usage
315 echo " --version-name VERSION_NAME"
315 echo " --version-name VERSION_NAME"
316 printf " Specify custom build ver e.g $RC_CLI_VERSION_NAME\n"
316 printf " Specify custom build ver e.g $RC_CLI_VERSION_NAME\n"
317 printf " Default: $RC_CLI_VERSION_NAME\n"
317 printf " Default: $RC_CLI_VERSION_NAME\n"
318 echo
318 echo
319
319
320 fi
320 fi
321 }
321 }
322
322
323 # :command.usage
323 # :command.usage
324 rccontrol_get_build_source_usage() {
324 rccontrol_get_build_source_usage() {
325 if [[ -n $long_usage ]]; then
325 if [[ -n $long_usage ]]; then
326 printf "rccontrol get-build-source - Fetch RhodeCode sources, store in .source dir to run a source-based builds\n"
326 printf "rccontrol get-build-source - Fetch RhodeCode sources, store in .source dir to run a source-based builds\n"
327 echo
327 echo
328
328
329 else
329 else
330 printf "rccontrol get-build-source - Fetch RhodeCode sources, store in .source dir to run a source-based builds\n"
330 printf "rccontrol get-build-source - Fetch RhodeCode sources, store in .source dir to run a source-based builds\n"
331 echo
331 echo
332
332
333 fi
333 fi
334
334
335 printf "Usage:\n"
335 printf "Usage:\n"
336 printf " rccontrol get-build-source [OPTIONS]\n"
336 printf " rccontrol get-build-source [OPTIONS]\n"
337 printf " rccontrol get-build-source --help | -h\n"
337 printf " rccontrol get-build-source --help | -h\n"
338 echo
338 echo
339
339
340 # :command.long_usage
340 # :command.long_usage
341 if [[ -n $long_usage ]]; then
341 if [[ -n $long_usage ]]; then
342 printf "Options:\n"
342 printf "Options:\n"
343
343
344 # :command.usage_fixed_flags
344 # :command.usage_fixed_flags
345 echo " --help, -h"
345 echo " --help, -h"
346 printf " Show this help\n"
346 printf " Show this help\n"
347 echo
347 echo
348
348
349 # :command.usage_flags
349 # :command.usage_flags
350 # :flag.usage
350 # :flag.usage
351 echo " --revision REVISION"
351 echo " --revision REVISION"
352 printf " revision to download\n"
352 printf " revision to download\n"
353 printf " Default: default\n"
353 printf " Default: default\n"
354 echo
354 echo
355
355
356 # :flag.usage
356 # :flag.usage
357 echo " --auth-token AUTH_TOKEN"
357 echo " --auth-token AUTH_TOKEN"
358 printf " Specify AUTH TOKEN to obtain sources\n"
358 printf " Specify AUTH TOKEN to obtain sources\n"
359 echo
359 echo
360
360
361 # :flag.usage
361 # :flag.usage
362 echo " --server-url SERVER_URL"
362 echo " --server-url SERVER_URL"
363 printf " Specify RhodeCode server location where projects should be downloaded\n"
363 printf " Specify RhodeCode server location where projects should be downloaded\n"
364 printf " Default: https://code.rhodecode.com\n"
364 printf " Default: https://code.rhodecode.com\n"
365 echo
365 echo
366
366
367 # :command.usage_examples
367 # :command.usage_examples
368 printf "Examples:\n"
368 printf "Examples:\n"
369 printf " ./rccontrol get-sources $RC_CLI_VERSION_NAME\n"
369 printf " ./rccontrol get-sources $RC_CLI_VERSION_NAME\n"
370 printf " ./rccontrol get-sources default --auth-token xyxyxyx --server-url\n https://secret.repo/\n"
370 printf " ./rccontrol get-sources default --auth-token xyxyxyx --server-url\n https://secret.repo/\n"
371 echo
371 echo
372
372
373 fi
373 fi
374 }
374 }
375
375
376 # :command.usage
376 # :command.usage
377 rccontrol_build_source_usage() {
377 rccontrol_build_source_usage() {
378 if [[ -n $long_usage ]]; then
378 if [[ -n $long_usage ]]; then
379 printf "rccontrol build-source - Build RhodeCode image from source, requires upgrade-source initially\n"
379 printf "rccontrol build-source - Build RhodeCode image from source, requires upgrade-source initially\n"
380 echo
380 echo
381
381
382 else
382 else
383 printf "rccontrol build-source - Build RhodeCode image from source, requires upgrade-source initially\n"
383 printf "rccontrol build-source - Build RhodeCode image from source, requires upgrade-source initially\n"
384 echo
384 echo
385
385
386 fi
386 fi
387
387
388 printf "Usage:\n"
388 printf "Usage:\n"
389 printf " rccontrol build-source [OPTIONS]\n"
389 printf " rccontrol build-source [OPTIONS]\n"
390 printf " rccontrol build-source --help | -h\n"
390 printf " rccontrol build-source --help | -h\n"
391 echo
391 echo
392
392
393 # :command.long_usage
393 # :command.long_usage
394 if [[ -n $long_usage ]]; then
394 if [[ -n $long_usage ]]; then
395 printf "Options:\n"
395 printf "Options:\n"
396
396
397 # :command.usage_fixed_flags
397 # :command.usage_fixed_flags
398 echo " --help, -h"
398 echo " --help, -h"
399 printf " Show this help\n"
399 printf " Show this help\n"
400 echo
400 echo
401
401
402 # :command.usage_flags
402 # :command.usage_flags
403 # :flag.usage
403 # :flag.usage
404 echo " --version-name VERSION_NAME"
404 echo " --version-name VERSION_NAME"
405 printf " Specify custom build ver e.g $RC_CLI_VERSION_NAME\n"
405 printf " Specify custom build ver e.g $RC_CLI_VERSION_NAME\n"
406 printf " Default: $RC_CLI_VERSION_NAME\n"
406 printf " Default: $RC_CLI_VERSION_NAME\n"
407 echo
407 echo
408
408
409 # :command.usage_examples
409 # :command.usage_examples
410 printf "Examples:\n"
410 printf "Examples:\n"
411 printf " build foo\n"
411 printf " build foo\n"
412 echo
412 echo
413
413
414 fi
414 fi
415 }
415 }
416
416
417 # :command.usage
417 # :command.usage
418 rccontrol_stack_usage() {
418 rccontrol_stack_usage() {
419 if [[ -n $long_usage ]]; then
419 if [[ -n $long_usage ]]; then
420 printf "rccontrol stack - run one of available cluster stacks, run stack -h for more details\n"
420 printf "rccontrol stack - run one of available cluster stacks, run stack -h for more details\n"
421 echo
421 echo
422
422
423 else
423 else
424 printf "rccontrol stack - run one of available cluster stacks, run stack -h for more details\n"
424 printf "rccontrol stack - run one of available cluster stacks, run stack -h for more details\n"
425 echo
425 echo
426
426
427 fi
427 fi
428
428
429 printf "Usage:\n"
429 printf "Usage:\n"
430 printf " rccontrol stack [OPTIONS] COMMAND\n"
430 printf " rccontrol stack [OPTIONS] COMMAND\n"
431 printf " rccontrol stack [COMMAND] --help | -h\n"
431 printf " rccontrol stack [COMMAND] --help | -h\n"
432 echo
432 echo
433 # :command.usage_commands
433 # :command.usage_commands
434 printf "Commands:\n"
434 printf "Commands:\n"
435 echo " router run the router stack"
435 echo " router run the router stack"
436 echo " metrics run the router stack"
436 echo " metrics run the router stack"
437 echo " services run the router stack"
437 echo " services run the router stack"
438 echo " rhodecode run the router stack"
438 echo " rhodecode run the router stack"
439 echo " all run all stacks"
439 echo " all run all stacks"
440 echo
440 echo
441
441
442 # :command.long_usage
442 # :command.long_usage
443 if [[ -n $long_usage ]]; then
443 if [[ -n $long_usage ]]; then
444 printf "Options:\n"
444 printf "Options:\n"
445
445
446 # :command.usage_fixed_flags
446 # :command.usage_fixed_flags
447 echo " --help, -h"
447 echo " --help, -h"
448 printf " Show this help\n"
448 printf " Show this help\n"
449 echo
449 echo
450
450
451 # :command.usage_flags
451 # :command.usage_flags
452 # :flag.usage
452 # :flag.usage
453 echo " --env-file-path ENV_FILE_PATH"
453 echo " --env-file-path ENV_FILE_PATH"
454 printf " Set custom env file\n"
454 printf " Set custom env file\n"
455 printf " Default: $PWD/.custom/.runtime.env\n"
455 printf " Default: $PWD/.custom/.runtime.env\n"
456 echo
456 echo
457
457
458 # :command.usage_examples
458 # :command.usage_examples
459 printf "Examples:\n"
459 printf "Examples:\n"
460 printf " - ./rccontrol stack router up # run router stack with output to\n console\n - ./rccontrol stack router up --detach # run router stack detached\n - ./rccontrol stack router down # stop whole router stack\n - ./rccontrol stack router ps # check status of router stack\n \n # run router stack with your overrides compose file\n - ./rccontrol stack router -f docker-overrides.yaml up -d\n \n # Upgrade whole metrics stack\n - ./rccontrol stack metrics up --force-recreate --build --detach\n"
460 printf " - ./rccontrol stack router up # run router stack with output to\n stdout\n - ./rccontrol stack router up --detach # run router stack detached\n - ./rccontrol stack router down # stop whole router stack\n - ./rccontrol stack router ps # check status of router stack\n \n # scale a single stack service[s] to more replicas (horizontally)\n - ./rccontrol stack rhodecode up --detach --no-recreate --scale rhodecode=2\n --scale vcsserver=2\n \n # run router stack with your overrides compose file\n - ./rccontrol stack router -f docker-overrides.yaml up -d\n \n # Upgrade whole metrics stack\n - ./rccontrol stack metrics up --force-recreate --build --detach\n"
461 echo
461 echo
462
462
463 fi
463 fi
464 }
464 }
465
465
466 # :command.usage
466 # :command.usage
467 rccontrol_stack_router_usage() {
467 rccontrol_stack_router_usage() {
468 if [[ -n $long_usage ]]; then
468 if [[ -n $long_usage ]]; then
469 printf "rccontrol stack router - run the router stack\n"
469 printf "rccontrol stack router - run the router stack\n"
470 echo
470 echo
471
471
472 else
472 else
473 printf "rccontrol stack router - run the router stack\n"
473 printf "rccontrol stack router - run the router stack\n"
474 echo
474 echo
475
475
476 fi
476 fi
477
477
478 printf "Usage:\n"
478 printf "Usage:\n"
479 printf " rccontrol stack router [SERVICES PARAMS...]\n"
479 printf " rccontrol stack router [SERVICES PARAMS...]\n"
480 printf " rccontrol stack router --help | -h\n"
480 printf " rccontrol stack router --help | -h\n"
481 echo
481 echo
482
482
483 # :command.long_usage
483 # :command.long_usage
484 if [[ -n $long_usage ]]; then
484 if [[ -n $long_usage ]]; then
485 printf "Options:\n"
485 printf "Options:\n"
486
486
487 # :command.usage_fixed_flags
487 # :command.usage_fixed_flags
488 echo " --help, -h"
488 echo " --help, -h"
489 printf " Show this help\n"
489 printf " Show this help\n"
490 echo
490 echo
491
491
492 # :command.usage_args
492 # :command.usage_args
493 printf "Arguments:\n"
493 printf "Arguments:\n"
494
494
495 echo " SERVICES PARAMS..."
495 echo " SERVICES PARAMS..."
496 printf " Additional arguments or flags for services command\n"
496 printf " Additional arguments or flags for services command\n"
497 echo
497 echo
498
498
499 fi
499 fi
500 }
500 }
501
501
502 # :command.usage
502 # :command.usage
503 rccontrol_stack_metrics_usage() {
503 rccontrol_stack_metrics_usage() {
504 if [[ -n $long_usage ]]; then
504 if [[ -n $long_usage ]]; then
505 printf "rccontrol stack metrics - run the router stack\n"
505 printf "rccontrol stack metrics - run the router stack\n"
506 echo
506 echo
507
507
508 else
508 else
509 printf "rccontrol stack metrics - run the router stack\n"
509 printf "rccontrol stack metrics - run the router stack\n"
510 echo
510 echo
511
511
512 fi
512 fi
513
513
514 printf "Usage:\n"
514 printf "Usage:\n"
515 printf " rccontrol stack metrics [SERVICES PARAMS...]\n"
515 printf " rccontrol stack metrics [SERVICES PARAMS...]\n"
516 printf " rccontrol stack metrics --help | -h\n"
516 printf " rccontrol stack metrics --help | -h\n"
517 echo
517 echo
518
518
519 # :command.long_usage
519 # :command.long_usage
520 if [[ -n $long_usage ]]; then
520 if [[ -n $long_usage ]]; then
521 printf "Options:\n"
521 printf "Options:\n"
522
522
523 # :command.usage_fixed_flags
523 # :command.usage_fixed_flags
524 echo " --help, -h"
524 echo " --help, -h"
525 printf " Show this help\n"
525 printf " Show this help\n"
526 echo
526 echo
527
527
528 # :command.usage_args
528 # :command.usage_args
529 printf "Arguments:\n"
529 printf "Arguments:\n"
530
530
531 echo " SERVICES PARAMS..."
531 echo " SERVICES PARAMS..."
532 printf " Additional arguments or flags for services command\n"
532 printf " Additional arguments or flags for services command\n"
533 echo
533 echo
534
534
535 fi
535 fi
536 }
536 }
537
537
538 # :command.usage
538 # :command.usage
539 rccontrol_stack_services_usage() {
539 rccontrol_stack_services_usage() {
540 if [[ -n $long_usage ]]; then
540 if [[ -n $long_usage ]]; then
541 printf "rccontrol stack services - run the router stack\n"
541 printf "rccontrol stack services - run the router stack\n"
542 echo
542 echo
543
543
544 else
544 else
545 printf "rccontrol stack services - run the router stack\n"
545 printf "rccontrol stack services - run the router stack\n"
546 echo
546 echo
547
547
548 fi
548 fi
549
549
550 printf "Usage:\n"
550 printf "Usage:\n"
551 printf " rccontrol stack services [SERVICES PARAMS...]\n"
551 printf " rccontrol stack services [SERVICES PARAMS...]\n"
552 printf " rccontrol stack services --help | -h\n"
552 printf " rccontrol stack services --help | -h\n"
553 echo
553 echo
554
554
555 # :command.long_usage
555 # :command.long_usage
556 if [[ -n $long_usage ]]; then
556 if [[ -n $long_usage ]]; then
557 printf "Options:\n"
557 printf "Options:\n"
558
558
559 # :command.usage_fixed_flags
559 # :command.usage_fixed_flags
560 echo " --help, -h"
560 echo " --help, -h"
561 printf " Show this help\n"
561 printf " Show this help\n"
562 echo
562 echo
563
563
564 # :command.usage_args
564 # :command.usage_args
565 printf "Arguments:\n"
565 printf "Arguments:\n"
566
566
567 echo " SERVICES PARAMS..."
567 echo " SERVICES PARAMS..."
568 printf " Additional arguments or flags for services command\n"
568 printf " Additional arguments or flags for services command\n"
569 echo
569 echo
570
570
571 fi
571 fi
572 }
572 }
573
573
574 # :command.usage
574 # :command.usage
575 rccontrol_stack_rhodecode_usage() {
575 rccontrol_stack_rhodecode_usage() {
576 if [[ -n $long_usage ]]; then
576 if [[ -n $long_usage ]]; then
577 printf "rccontrol stack rhodecode - run the router stack\n"
577 printf "rccontrol stack rhodecode - run the router stack\n"
578 echo
578 echo
579
579
580 else
580 else
581 printf "rccontrol stack rhodecode - run the router stack\n"
581 printf "rccontrol stack rhodecode - run the router stack\n"
582 echo
582 echo
583
583
584 fi
584 fi
585
585
586 printf "Usage:\n"
586 printf "Usage:\n"
587 printf " rccontrol stack rhodecode [SERVICES PARAMS...]\n"
587 printf " rccontrol stack rhodecode [SERVICES PARAMS...]\n"
588 printf " rccontrol stack rhodecode --help | -h\n"
588 printf " rccontrol stack rhodecode --help | -h\n"
589 echo
589 echo
590
590
591 # :command.long_usage
591 # :command.long_usage
592 if [[ -n $long_usage ]]; then
592 if [[ -n $long_usage ]]; then
593 printf "Options:\n"
593 printf "Options:\n"
594
594
595 # :command.usage_fixed_flags
595 # :command.usage_fixed_flags
596 echo " --help, -h"
596 echo " --help, -h"
597 printf " Show this help\n"
597 printf " Show this help\n"
598 echo
598 echo
599
599
600 # :command.usage_args
600 # :command.usage_args
601 printf "Arguments:\n"
601 printf "Arguments:\n"
602
602
603 echo " SERVICES PARAMS..."
603 echo " SERVICES PARAMS..."
604 printf " Additional arguments or flags for services command\n"
604 printf " Additional arguments or flags for services command\n"
605 echo
605 echo
606
606
607 fi
607 fi
608 }
608 }
609
609
610 # :command.usage
610 # :command.usage
611 rccontrol_stack_all_usage() {
611 rccontrol_stack_all_usage() {
612 if [[ -n $long_usage ]]; then
612 if [[ -n $long_usage ]]; then
613 printf "rccontrol stack all - run all stacks\n"
613 printf "rccontrol stack all - run all stacks\n"
614 echo
614 echo
615
615
616 else
616 else
617 printf "rccontrol stack all - run all stacks\n"
617 printf "rccontrol stack all - run all stacks\n"
618 echo
618 echo
619
619
620 fi
620 fi
621
621
622 printf "Usage:\n"
622 printf "Usage:\n"
623 printf " rccontrol stack all [SERVICES PARAMS...]\n"
623 printf " rccontrol stack all [SERVICES PARAMS...]\n"
624 printf " rccontrol stack all --help | -h\n"
624 printf " rccontrol stack all --help | -h\n"
625 echo
625 echo
626
626
627 # :command.long_usage
627 # :command.long_usage
628 if [[ -n $long_usage ]]; then
628 if [[ -n $long_usage ]]; then
629 printf "Options:\n"
629 printf "Options:\n"
630
630
631 # :command.usage_fixed_flags
631 # :command.usage_fixed_flags
632 echo " --help, -h"
632 echo " --help, -h"
633 printf " Show this help\n"
633 printf " Show this help\n"
634 echo
634 echo
635
635
636 # :command.usage_args
636 # :command.usage_args
637 printf "Arguments:\n"
637 printf "Arguments:\n"
638
638
639 echo " SERVICES PARAMS..."
639 echo " SERVICES PARAMS..."
640 printf " Additional arguments or flags for services command\n"
640 printf " Additional arguments or flags for services command\n"
641 echo
641 echo
642
642
643 fi
643 fi
644 }
644 }
645
645
646 # :command.usage
646 # :command.usage
647 rccontrol_stack_status_usage() {
647 rccontrol_stack_status_usage() {
648 if [[ -n $long_usage ]]; then
648 if [[ -n $long_usage ]]; then
649 printf "rccontrol stack-status - Show stack status\n"
649 printf "rccontrol stack-status - Show stack status\n"
650 echo
650 echo
651
651
652 else
652 else
653 printf "rccontrol stack-status - Show stack status\n"
653 printf "rccontrol stack-status - Show stack status\n"
654 echo
654 echo
655
655
656 fi
656 fi
657
657
658 printf "Alias: status\n"
658 printf "Alias: status\n"
659 echo
659 echo
660
660
661 printf "Usage:\n"
661 printf "Usage:\n"
662 printf " rccontrol stack-status [OPTIONS]\n"
662 printf " rccontrol stack-status [OPTIONS]\n"
663 printf " rccontrol stack-status --help | -h\n"
663 printf " rccontrol stack-status --help | -h\n"
664 echo
664 echo
665
665
666 # :command.long_usage
666 # :command.long_usage
667 if [[ -n $long_usage ]]; then
667 if [[ -n $long_usage ]]; then
668 printf "Options:\n"
668 printf "Options:\n"
669
669
670 # :command.usage_fixed_flags
670 # :command.usage_fixed_flags
671 echo " --help, -h"
671 echo " --help, -h"
672 printf " Show this help\n"
672 printf " Show this help\n"
673 echo
673 echo
674
674
675 # :command.usage_flags
675 # :command.usage_flags
676 # :flag.usage
676 # :flag.usage
677 echo " --simple, -s"
677 echo " --simple, -s"
678 printf " Display a simple format using a table\n"
678 printf " Display a simple format using a table\n"
679 echo
679 echo
680
680
681 fi
681 fi
682 }
682 }
683
683
684 # :command.usage
684 # :command.usage
685 rccontrol_stack_upgrade_usage() {
685 rccontrol_stack_upgrade_usage() {
686 if [[ -n $long_usage ]]; then
686 if [[ -n $long_usage ]]; then
687 printf "rccontrol stack-upgrade - upgrade ALL stack status\n"
687 printf "rccontrol stack-upgrade - upgrade ALL stack status\n"
688 echo
688 echo
689
689
690 else
690 else
691 printf "rccontrol stack-upgrade - upgrade ALL stack status\n"
691 printf "rccontrol stack-upgrade - upgrade ALL stack status\n"
692 echo
692 echo
693
693
694 fi
694 fi
695
695
696 printf "Usage:\n"
696 printf "Usage:\n"
697 printf " rccontrol stack-upgrade\n"
697 printf " rccontrol stack-upgrade\n"
698 printf " rccontrol stack-upgrade --help | -h\n"
698 printf " rccontrol stack-upgrade --help | -h\n"
699 echo
699 echo
700
700
701 # :command.long_usage
701 # :command.long_usage
702 if [[ -n $long_usage ]]; then
702 if [[ -n $long_usage ]]; then
703 printf "Options:\n"
703 printf "Options:\n"
704
704
705 # :command.usage_fixed_flags
705 # :command.usage_fixed_flags
706 echo " --help, -h"
706 echo " --help, -h"
707 printf " Show this help\n"
707 printf " Show this help\n"
708 echo
708 echo
709
709
710 fi
710 fi
711 }
711 }
712
712
713 # :command.usage
713 # :command.usage
714 rccontrol_cli_usage() {
714 rccontrol_cli_usage() {
715 if [[ -n $long_usage ]]; then
715 if [[ -n $long_usage ]]; then
716 printf "rccontrol cli - Various CLI tools, run cli -h for more details\n"
716 printf "rccontrol cli - Various CLI tools, run cli -h for more details\n"
717 echo
717 echo
718
718
719 else
719 else
720 printf "rccontrol cli - Various CLI tools, run cli -h for more details\n"
720 printf "rccontrol cli - Various CLI tools, run cli -h for more details\n"
721 echo
721 echo
722
722
723 fi
723 fi
724
724
725 printf "Usage:\n"
725 printf "Usage:\n"
726 printf " rccontrol cli COMMAND\n"
726 printf " rccontrol cli COMMAND\n"
727 printf " rccontrol cli [COMMAND] --help | -h\n"
727 printf " rccontrol cli [COMMAND] --help | -h\n"
728 echo
728 echo
729 # :command.usage_commands
729 # :command.usage_commands
730 printf "Commands:\n"
730 printf "Commands:\n"
731 echo " redis CLI for Redis"
731 echo " redis CLI for Redis"
732 echo " db CLI with Database connection"
732 echo " db CLI with Database connection"
733 echo " db-upgrade CLI to run db upgrade"
733 echo " db-upgrade CLI to run db upgrade"
734 echo " storage CLI for repository storage. Exposes a basic image with mounted data and repositories volumes"
734 echo " storage CLI for repository storage. Exposes a basic image with mounted data and repositories volumes"
735 echo
735 echo
736
736
737 # :command.long_usage
737 # :command.long_usage
738 if [[ -n $long_usage ]]; then
738 if [[ -n $long_usage ]]; then
739 printf "Options:\n"
739 printf "Options:\n"
740
740
741 # :command.usage_fixed_flags
741 # :command.usage_fixed_flags
742 echo " --help, -h"
742 echo " --help, -h"
743 printf " Show this help\n"
743 printf " Show this help\n"
744 echo
744 echo
745
745
746 fi
746 fi
747 }
747 }
748
748
749 # :command.usage
749 # :command.usage
750 rccontrol_cli_redis_usage() {
750 rccontrol_cli_redis_usage() {
751 if [[ -n $long_usage ]]; then
751 if [[ -n $long_usage ]]; then
752 printf "rccontrol cli redis - CLI for Redis\n"
752 printf "rccontrol cli redis - CLI for Redis\n"
753 echo
753 echo
754
754
755 else
755 else
756 printf "rccontrol cli redis - CLI for Redis\n"
756 printf "rccontrol cli redis - CLI for Redis\n"
757 echo
757 echo
758
758
759 fi
759 fi
760
760
761 printf "Usage:\n"
761 printf "Usage:\n"
762 printf " rccontrol cli redis\n"
762 printf " rccontrol cli redis\n"
763 printf " rccontrol cli redis --help | -h\n"
763 printf " rccontrol cli redis --help | -h\n"
764 echo
764 echo
765
765
766 # :command.long_usage
766 # :command.long_usage
767 if [[ -n $long_usage ]]; then
767 if [[ -n $long_usage ]]; then
768 printf "Options:\n"
768 printf "Options:\n"
769
769
770 # :command.usage_fixed_flags
770 # :command.usage_fixed_flags
771 echo " --help, -h"
771 echo " --help, -h"
772 printf " Show this help\n"
772 printf " Show this help\n"
773 echo
773 echo
774
774
775 fi
775 fi
776 }
776 }
777
777
778 # :command.usage
778 # :command.usage
779 rccontrol_cli_db_usage() {
779 rccontrol_cli_db_usage() {
780 if [[ -n $long_usage ]]; then
780 if [[ -n $long_usage ]]; then
781 printf "rccontrol cli db - CLI with Database connection\n"
781 printf "rccontrol cli db - CLI with Database connection\n"
782 echo
782 echo
783
783
784 else
784 else
785 printf "rccontrol cli db - CLI with Database connection\n"
785 printf "rccontrol cli db - CLI with Database connection\n"
786 echo
786 echo
787
787
788 fi
788 fi
789
789
790 printf "Usage:\n"
790 printf "Usage:\n"
791 printf " rccontrol cli db\n"
791 printf " rccontrol cli db\n"
792 printf " rccontrol cli db --help | -h\n"
792 printf " rccontrol cli db --help | -h\n"
793 echo
793 echo
794
794
795 # :command.long_usage
795 # :command.long_usage
796 if [[ -n $long_usage ]]; then
796 if [[ -n $long_usage ]]; then
797 printf "Options:\n"
797 printf "Options:\n"
798
798
799 # :command.usage_fixed_flags
799 # :command.usage_fixed_flags
800 echo " --help, -h"
800 echo " --help, -h"
801 printf " Show this help\n"
801 printf " Show this help\n"
802 echo
802 echo
803
803
804 fi
804 fi
805 }
805 }
806
806
807 # :command.usage
807 # :command.usage
808 rccontrol_cli_db_upgrade_usage() {
808 rccontrol_cli_db_upgrade_usage() {
809 if [[ -n $long_usage ]]; then
809 if [[ -n $long_usage ]]; then
810 printf "rccontrol cli db-upgrade - CLI to run db upgrade\n"
810 printf "rccontrol cli db-upgrade - CLI to run db upgrade\n"
811 echo
811 echo
812
812
813 else
813 else
814 printf "rccontrol cli db-upgrade - CLI to run db upgrade\n"
814 printf "rccontrol cli db-upgrade - CLI to run db upgrade\n"
815 echo
815 echo
816
816
817 fi
817 fi
818
818
819 printf "Usage:\n"
819 printf "Usage:\n"
820 printf " rccontrol cli db-upgrade\n"
820 printf " rccontrol cli db-upgrade\n"
821 printf " rccontrol cli db-upgrade --help | -h\n"
821 printf " rccontrol cli db-upgrade --help | -h\n"
822 echo
822 echo
823
823
824 # :command.long_usage
824 # :command.long_usage
825 if [[ -n $long_usage ]]; then
825 if [[ -n $long_usage ]]; then
826 printf "Options:\n"
826 printf "Options:\n"
827
827
828 # :command.usage_fixed_flags
828 # :command.usage_fixed_flags
829 echo " --help, -h"
829 echo " --help, -h"
830 printf " Show this help\n"
830 printf " Show this help\n"
831 echo
831 echo
832
832
833 fi
833 fi
834 }
834 }
835
835
836 # :command.usage
836 # :command.usage
837 rccontrol_cli_storage_usage() {
837 rccontrol_cli_storage_usage() {
838 if [[ -n $long_usage ]]; then
838 if [[ -n $long_usage ]]; then
839 printf "rccontrol cli storage - CLI for repository storage. Exposes a basic image with mounted data and repositories volumes\n"
839 printf "rccontrol cli storage - CLI for repository storage. Exposes a basic image with mounted data and repositories volumes\n"
840 echo
840 echo
841
841
842 else
842 else
843 printf "rccontrol cli storage - CLI for repository storage. Exposes a basic image with mounted data and repositories volumes\n"
843 printf "rccontrol cli storage - CLI for repository storage. Exposes a basic image with mounted data and repositories volumes\n"
844 echo
844 echo
845
845
846 fi
846 fi
847
847
848 printf "Usage:\n"
848 printf "Usage:\n"
849 printf " rccontrol cli storage\n"
849 printf " rccontrol cli storage\n"
850 printf " rccontrol cli storage --help | -h\n"
850 printf " rccontrol cli storage --help | -h\n"
851 echo
851 echo
852
852
853 # :command.long_usage
853 # :command.long_usage
854 if [[ -n $long_usage ]]; then
854 if [[ -n $long_usage ]]; then
855 printf "Options:\n"
855 printf "Options:\n"
856
856
857 # :command.usage_fixed_flags
857 # :command.usage_fixed_flags
858 echo " --help, -h"
858 echo " --help, -h"
859 printf " Show this help\n"
859 printf " Show this help\n"
860 echo
860 echo
861
861
862 fi
862 fi
863 }
863 }
864
864
865 # :command.usage
865 # :command.usage
866 rccontrol_backup_db_usage() {
866 rccontrol_backup_db_usage() {
867 if [[ -n $long_usage ]]; then
867 if [[ -n $long_usage ]]; then
868 printf "rccontrol backup-db - Backup Database\n"
868 printf "rccontrol backup-db - Backup Database\n"
869 echo
869 echo
870
870
871 else
871 else
872 printf "rccontrol backup-db - Backup Database\n"
872 printf "rccontrol backup-db - Backup Database\n"
873 echo
873 echo
874
874
875 fi
875 fi
876
876
877 printf "Usage:\n"
877 printf "Usage:\n"
878 printf " rccontrol backup-db\n"
878 printf " rccontrol backup-db\n"
879 printf " rccontrol backup-db --help | -h\n"
879 printf " rccontrol backup-db --help | -h\n"
880 echo
880 echo
881
881
882 # :command.long_usage
882 # :command.long_usage
883 if [[ -n $long_usage ]]; then
883 if [[ -n $long_usage ]]; then
884 printf "Options:\n"
884 printf "Options:\n"
885
885
886 # :command.usage_fixed_flags
886 # :command.usage_fixed_flags
887 echo " --help, -h"
887 echo " --help, -h"
888 printf " Show this help\n"
888 printf " Show this help\n"
889 echo
889 echo
890
890
891 # :command.usage_examples
891 # :command.usage_examples
892 printf "Examples:\n"
892 printf "Examples:\n"
893 printf " ./rccontrol backup-db\n"
893 printf " ./rccontrol backup-db\n"
894 echo
894 echo
895
895
896 fi
896 fi
897 }
897 }
898
898
899 # :command.usage
899 # :command.usage
900 rccontrol_backup_data_usage() {
900 rccontrol_backup_data_usage() {
901 if [[ -n $long_usage ]]; then
901 if [[ -n $long_usage ]]; then
902 printf "rccontrol backup-data - Backup RhodeCode storage\n"
902 printf "rccontrol backup-data - Backup RhodeCode storage\n"
903 echo
903 echo
904
904
905 else
905 else
906 printf "rccontrol backup-data - Backup RhodeCode storage\n"
906 printf "rccontrol backup-data - Backup RhodeCode storage\n"
907 echo
907 echo
908
908
909 fi
909 fi
910
910
911 printf "Usage:\n"
911 printf "Usage:\n"
912 printf " rccontrol backup-data\n"
912 printf " rccontrol backup-data\n"
913 printf " rccontrol backup-data --help | -h\n"
913 printf " rccontrol backup-data --help | -h\n"
914 echo
914 echo
915
915
916 # :command.long_usage
916 # :command.long_usage
917 if [[ -n $long_usage ]]; then
917 if [[ -n $long_usage ]]; then
918 printf "Options:\n"
918 printf "Options:\n"
919
919
920 # :command.usage_fixed_flags
920 # :command.usage_fixed_flags
921 echo " --help, -h"
921 echo " --help, -h"
922 printf " Show this help\n"
922 printf " Show this help\n"
923 echo
923 echo
924
924
925 fi
925 fi
926 }
926 }
927
927
928 # :command.usage
928 # :command.usage
929 rccontrol__completions_usage() {
929 rccontrol__completions_usage() {
930 if [[ -n $long_usage ]]; then
930 if [[ -n $long_usage ]]; then
931 printf "rccontrol _completions - Generate completions\n"
931 printf "rccontrol _completions - Generate completions\n"
932 echo
932 echo
933
933
934 else
934 else
935 printf "rccontrol _completions - Generate completions\n"
935 printf "rccontrol _completions - Generate completions\n"
936 echo
936 echo
937
937
938 fi
938 fi
939
939
940 printf "Usage:\n"
940 printf "Usage:\n"
941 printf " rccontrol _completions\n"
941 printf " rccontrol _completions\n"
942 printf " rccontrol _completions --help | -h\n"
942 printf " rccontrol _completions --help | -h\n"
943 echo
943 echo
944
944
945 # :command.long_usage
945 # :command.long_usage
946 if [[ -n $long_usage ]]; then
946 if [[ -n $long_usage ]]; then
947 printf "Options:\n"
947 printf "Options:\n"
948
948
949 # :command.usage_fixed_flags
949 # :command.usage_fixed_flags
950 echo " --help, -h"
950 echo " --help, -h"
951 printf " Show this help\n"
951 printf " Show this help\n"
952 echo
952 echo
953
953
954 fi
954 fi
955 }
955 }
956
956
957 # :command.normalize_input
957 # :command.normalize_input
958 normalize_input() {
958 normalize_input() {
959 local arg flags
959 local arg flags
960
960
961 while [[ $# -gt 0 ]]; do
961 while [[ $# -gt 0 ]]; do
962 arg="$1"
962 arg="$1"
963 if [[ $arg =~ ^(--[a-zA-Z0-9_\-]+)=(.+)$ ]]; then
963 if [[ $arg =~ ^(--[a-zA-Z0-9_\-]+)=(.+)$ ]]; then
964 input+=("${BASH_REMATCH[1]}")
964 input+=("${BASH_REMATCH[1]}")
965 input+=("${BASH_REMATCH[2]}")
965 input+=("${BASH_REMATCH[2]}")
966 elif [[ $arg =~ ^(-[a-zA-Z0-9])=(.+)$ ]]; then
966 elif [[ $arg =~ ^(-[a-zA-Z0-9])=(.+)$ ]]; then
967 input+=("${BASH_REMATCH[1]}")
967 input+=("${BASH_REMATCH[1]}")
968 input+=("${BASH_REMATCH[2]}")
968 input+=("${BASH_REMATCH[2]}")
969 elif [[ $arg =~ ^-([a-zA-Z0-9][a-zA-Z0-9]+)$ ]]; then
969 elif [[ $arg =~ ^-([a-zA-Z0-9][a-zA-Z0-9]+)$ ]]; then
970 flags="${BASH_REMATCH[1]}"
970 flags="${BASH_REMATCH[1]}"
971 for ((i = 0; i < ${#flags}; i++)); do
971 for ((i = 0; i < ${#flags}; i++)); do
972 input+=("-${flags:i:1}")
972 input+=("-${flags:i:1}")
973 done
973 done
974 else
974 else
975 input+=("$arg")
975 input+=("$arg")
976 fi
976 fi
977
977
978 shift
978 shift
979 done
979 done
980 }
980 }
981 # :command.inspect_args
981 # :command.inspect_args
982 inspect_args() {
982 inspect_args() {
983 readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
983 readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
984 if ((${#args[@]})); then
984 if ((${#args[@]})); then
985 echo args:
985 echo args:
986 for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done
986 for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done
987 else
987 else
988 echo args: none
988 echo args: none
989 fi
989 fi
990
990
991 if ((${#other_args[@]})); then
991 if ((${#other_args[@]})); then
992 echo
992 echo
993 echo other_args:
993 echo other_args:
994 echo "- \${other_args[*]} = ${other_args[*]}"
994 echo "- \${other_args[*]} = ${other_args[*]}"
995 for i in "${!other_args[@]}"; do
995 for i in "${!other_args[@]}"; do
996 echo "- \${other_args[$i]} = ${other_args[$i]}"
996 echo "- \${other_args[$i]} = ${other_args[$i]}"
997 done
997 done
998 fi
998 fi
999 }
999 }
1000
1000
1001 # :command.user_lib
1001 # :command.user_lib
1002 # src/lib/check_bootstrap.sh
1002 # src/lib/check_bootstrap.sh
1003
1003
1004 check_bootstrap() {
1004 check_bootstrap() {
1005 # Avoid destroying bootstrapping by simple start/stop
1005 # Avoid destroying bootstrapping by simple start/stop
1006 for stage in $BOOTSTRAP_STAGES; do
1006 for stage in $BOOTSTRAP_STAGES; do
1007
1007
1008 stage_name=$(echo $stage | cut -d ":" -f 1)
1008 stage_name=$(echo $stage | cut -d ":" -f 1)
1009 stage_func=$(echo $stage | cut -d ":" -f 2)
1009 stage_func=$(echo $stage | cut -d ":" -f 2)
1010 if ! config_has_key $stage_name ; then
1010 if ! config_has_key $stage_name ; then
1011 echo "$(yellow WARNING:) bootstrap key $stage_name not found in config file $CONFIG_FILE!"
1011 echo "$(yellow WARNING:) bootstrap key $stage_name not found in config file $CONFIG_FILE!"
1012 echo "$(yellow NOTICE:) Please run ./rccontrol bootstrap first"
1012 echo "$(yellow NOTICE:) Please run ./rccontrol bootstrap first"
1013 exit
1013 exit
1014 fi
1014 fi
1015 done
1015 done
1016
1016
1017 }
1017 }
1018
1018
1019 # src/lib/colors.sh
1019 # src/lib/colors.sh
1020 print_in_color() {
1020 print_in_color() {
1021 local color="$1"
1021 local color="$1"
1022 shift
1022 shift
1023 if [[ -z ${NO_COLOR+x} ]]; then
1023 if [[ -z ${NO_COLOR+x} ]]; then
1024 printf "$color%b\e[0m\n" "$*"
1024 printf "$color%b\e[0m\n" "$*"
1025 else
1025 else
1026 printf "%b\n" "$*"
1026 printf "%b\n" "$*"
1027 fi
1027 fi
1028 }
1028 }
1029
1029
1030 red() { print_in_color "\e[31m" "$*"; }
1030 red() { print_in_color "\e[31m" "$*"; }
1031 green() { print_in_color "\e[32m" "$*"; }
1031 green() { print_in_color "\e[32m" "$*"; }
1032 yellow() { print_in_color "\e[33m" "$*"; }
1032 yellow() { print_in_color "\e[33m" "$*"; }
1033 blue() { print_in_color "\e[34m" "$*"; }
1033 blue() { print_in_color "\e[34m" "$*"; }
1034 magenta() { print_in_color "\e[35m" "$*"; }
1034 magenta() { print_in_color "\e[35m" "$*"; }
1035 cyan() { print_in_color "\e[36m" "$*"; }
1035 cyan() { print_in_color "\e[36m" "$*"; }
1036 bold() { print_in_color "\e[1m" "$*"; }
1036 bold() { print_in_color "\e[1m" "$*"; }
1037 underlined() { print_in_color "\e[4m" "$*"; }
1037 underlined() { print_in_color "\e[4m" "$*"; }
1038 red_bold() { print_in_color "\e[1;31m" "$*"; }
1038 red_bold() { print_in_color "\e[1;31m" "$*"; }
1039 green_bold() { print_in_color "\e[1;32m" "$*"; }
1039 green_bold() { print_in_color "\e[1;32m" "$*"; }
1040 yellow_bold() { print_in_color "\e[1;33m" "$*"; }
1040 yellow_bold() { print_in_color "\e[1;33m" "$*"; }
1041 blue_bold() { print_in_color "\e[1;34m" "$*"; }
1041 blue_bold() { print_in_color "\e[1;34m" "$*"; }
1042 magenta_bold() { print_in_color "\e[1;35m" "$*"; }
1042 magenta_bold() { print_in_color "\e[1;35m" "$*"; }
1043 cyan_bold() { print_in_color "\e[1;36m" "$*"; }
1043 cyan_bold() { print_in_color "\e[1;36m" "$*"; }
1044 red_underlined() { print_in_color "\e[4;31m" "$*"; }
1044 red_underlined() { print_in_color "\e[4;31m" "$*"; }
1045 green_underlined() { print_in_color "\e[4;32m" "$*"; }
1045 green_underlined() { print_in_color "\e[4;32m" "$*"; }
1046 yellow_underlined() { print_in_color "\e[4;33m" "$*"; }
1046 yellow_underlined() { print_in_color "\e[4;33m" "$*"; }
1047 blue_underlined() { print_in_color "\e[4;34m" "$*"; }
1047 blue_underlined() { print_in_color "\e[4;34m" "$*"; }
1048 magenta_underlined() { print_in_color "\e[4;35m" "$*"; }
1048 magenta_underlined() { print_in_color "\e[4;35m" "$*"; }
1049 cyan_underlined() { print_in_color "\e[4;36m" "$*"; }
1049 cyan_underlined() { print_in_color "\e[4;36m" "$*"; }
1050
1050
1051 # src/lib/config.sh
1051 # src/lib/config.sh
1052 config_init() {
1052 config_init() {
1053 CONFIG_FILE=${CONFIG_FILE:=config.ini}
1053 CONFIG_FILE=${CONFIG_FILE:=config.ini}
1054 [[ -f "$CONFIG_FILE" ]] || touch "$CONFIG_FILE"
1054 [[ -f "$CONFIG_FILE" ]] || touch "$CONFIG_FILE"
1055 }
1055 }
1056
1056
1057 config_get() {
1057 config_get() {
1058 local key=$1
1058 local key=$1
1059 local regex="^$key *= *(.+)$"
1059 local regex="^$key *= *(.+)$"
1060 local value=""
1060 local value=""
1061
1061
1062 config_init
1062 config_init
1063
1063
1064 while IFS= read -r line || [ -n "$line" ]; do
1064 while IFS= read -r line || [ -n "$line" ]; do
1065 if [[ $line =~ $regex ]]; then
1065 if [[ $line =~ $regex ]]; then
1066 value="${BASH_REMATCH[1]}"
1066 value="${BASH_REMATCH[1]}"
1067 break
1067 break
1068 fi
1068 fi
1069 done <"$CONFIG_FILE"
1069 done <"$CONFIG_FILE"
1070
1070
1071 echo "$value"
1071 echo "$value"
1072 }
1072 }
1073
1073
1074 config_set() {
1074 config_set() {
1075 local key=$1
1075 local key=$1
1076 shift
1076 shift
1077 local value="$*"
1077 local value="$*"
1078
1078
1079 config_init
1079 config_init
1080
1080
1081 local regex="^($key) *= *.+$"
1081 local regex="^($key) *= *.+$"
1082 local output=""
1082 local output=""
1083 local found_key=""
1083 local found_key=""
1084 local newline
1084 local newline
1085
1085
1086 while IFS= read -r line || [ -n "$line" ]; do
1086 while IFS= read -r line || [ -n "$line" ]; do
1087 newline=$line
1087 newline=$line
1088 if [[ $line =~ $regex ]]; then
1088 if [[ $line =~ $regex ]]; then
1089 found_key="${BASH_REMATCH[1]}"
1089 found_key="${BASH_REMATCH[1]}"
1090 newline="$key = $value"
1090 newline="$key = $value"
1091 output="$output$newline\n"
1091 output="$output$newline\n"
1092 elif [[ $line ]]; then
1092 elif [[ $line ]]; then
1093 output="$output$line\n"
1093 output="$output$line\n"
1094 fi
1094 fi
1095 done <"$CONFIG_FILE"
1095 done <"$CONFIG_FILE"
1096
1096
1097 if [[ -z $found_key ]]; then
1097 if [[ -z $found_key ]]; then
1098 output="$output$key = $value\n"
1098 output="$output$key = $value\n"
1099 fi
1099 fi
1100
1100
1101 printf "%b\n" "$output" >"$CONFIG_FILE"
1101 printf "%b\n" "$output" >"$CONFIG_FILE"
1102 }
1102 }
1103
1103
1104 config_del() {
1104 config_del() {
1105 local key=$1
1105 local key=$1
1106
1106
1107 local regex="^($key) *="
1107 local regex="^($key) *="
1108 local output=""
1108 local output=""
1109
1109
1110 config_init
1110 config_init
1111
1111
1112 while IFS= read -r line || [ -n "$line" ]; do
1112 while IFS= read -r line || [ -n "$line" ]; do
1113 if [[ $line ]] && [[ ! $line =~ $regex ]]; then
1113 if [[ $line ]] && [[ ! $line =~ $regex ]]; then
1114 output="$output$line\n"
1114 output="$output$line\n"
1115 fi
1115 fi
1116 done <"$CONFIG_FILE"
1116 done <"$CONFIG_FILE"
1117
1117
1118 printf "%b\n" "$output" >"$CONFIG_FILE"
1118 printf "%b\n" "$output" >"$CONFIG_FILE"
1119 }
1119 }
1120
1120
1121 config_show() {
1121 config_show() {
1122 config_init
1122 config_init
1123 cat "$CONFIG_FILE"
1123 cat "$CONFIG_FILE"
1124 }
1124 }
1125
1125
1126 config_keys() {
1126 config_keys() {
1127 local regex="^([a-zA-Z0-9_\-\/\.]+) *="
1127 local regex="^([a-zA-Z0-9_\-\/\.]+) *="
1128
1128
1129 config_init
1129 config_init
1130
1130
1131 local keys=()
1131 local keys=()
1132 local key
1132 local key
1133
1133
1134 while IFS= read -r line || [ -n "$line" ]; do
1134 while IFS= read -r line || [ -n "$line" ]; do
1135 if [[ $line =~ $regex ]]; then
1135 if [[ $line =~ $regex ]]; then
1136 key="${BASH_REMATCH[1]}"
1136 key="${BASH_REMATCH[1]}"
1137 keys+=("$key")
1137 keys+=("$key")
1138 fi
1138 fi
1139 done <"$CONFIG_FILE"
1139 done <"$CONFIG_FILE"
1140 echo "${keys[@]}"
1140 echo "${keys[@]}"
1141 }
1141 }
1142
1142
1143 config_has_key() {
1143 config_has_key() {
1144 [[ $(config_get "$1") ]]
1144 [[ $(config_get "$1") ]]
1145 }
1145 }
1146
1146
1147 # src/lib/dotenv.sh
1147 # src/lib/dotenv.sh
1148
1148
1149 __dotenv=
1149 __dotenv=
1150 __dotenv_file=
1150 __dotenv_file=
1151 __dotenv_cmd=.env
1151 __dotenv_cmd=.env
1152
1152
1153 .env() {
1153 .env() {
1154 REPLY=()
1154 REPLY=()
1155 [[ $__dotenv_file || ${1-} == -* ]] || .env.--file .env || return
1155 [[ $__dotenv_file || ${1-} == -* ]] || .env.--file .env || return
1156 if declare -F -- ".env.${1-}" >/dev/null; then .env."$@"; return ; fi
1156 if declare -F -- ".env.${1-}" >/dev/null; then .env."$@"; return ; fi
1157 .env --help >&2; return 64
1157 .env --help >&2; return 64
1158 }
1158 }
1159
1159
1160 .env.-f() { .env.--file "$@"; }
1160 .env.-f() { .env.--file "$@"; }
1161
1161
1162 .env.get() {
1162 .env.get() {
1163 .env::arg "get requires a key" "$@" &&
1163 .env::arg "get requires a key" "$@" &&
1164 [[ "$__dotenv" =~ ^(.*(^|$'\n'))([ ]*)"$1="(.*)$ ]] &&
1164 [[ "$__dotenv" =~ ^(.*(^|$'\n'))([ ]*)"$1="(.*)$ ]] &&
1165 REPLY=${BASH_REMATCH[4]%%$'\n'*} && REPLY=${REPLY%"${REPLY##*[![:space:]]}"}
1165 REPLY=${BASH_REMATCH[4]%%$'\n'*} && REPLY=${REPLY%"${REPLY##*[![:space:]]}"}
1166 }
1166 }
1167
1167
1168 .env.parse() {
1168 .env.parse() {
1169 local line key
1169 local line key
1170 while IFS= read -r line; do
1170 while IFS= read -r line; do
1171 line=${line#"${line%%[![:space:]]*}"} # trim leading whitespace
1171 line=${line#"${line%%[![:space:]]*}"} # trim leading whitespace
1172 line=${line%"${line##*[![:space:]]}"} # trim trailing whitespace
1172 line=${line%"${line##*[![:space:]]}"} # trim trailing whitespace
1173 if [[ ! "$line" || "$line" == '#'* ]]; then continue ; fi
1173 if [[ ! "$line" || "$line" == '#'* ]]; then continue ; fi
1174 if (($#)); then
1174 if (($#)); then
1175 for key; do
1175 for key; do
1176 if [[ $key == "${line%%=*}" ]]; then REPLY+=("$line"); break;
1176 if [[ $key == "${line%%=*}" ]]; then REPLY+=("$line"); break;
1177 fi
1177 fi
1178 done
1178 done
1179 else
1179 else
1180 REPLY+=("$line")
1180 REPLY+=("$line")
1181 fi
1181 fi
1182 done <<<"$__dotenv"
1182 done <<<"$__dotenv"
1183 ((${#REPLY[@]}))
1183 ((${#REPLY[@]}))
1184 }
1184 }
1185
1185
1186 .env.export() { ! .env.parse "$@" || export "${REPLY[@]}"; }
1186 .env.export() { ! .env.parse "$@" || export "${REPLY[@]}"; }
1187
1187
1188 .env.set() {
1188 .env.set() {
1189 .env::file load || return ; local key saved=$__dotenv
1189 .env::file load || return ; local key saved=$__dotenv
1190 while (($#)); do
1190 while (($#)); do
1191 key=${1#+}; key=${key%%=*}
1191 key=${1#+}; key=${key%%=*}
1192 if .env.get "$key"; then
1192 if .env.get "$key"; then
1193 REPLY=()
1193 REPLY=()
1194 if [[ $1 == +* ]]; then shift; continue # skip if already found
1194 if [[ $1 == +* ]]; then shift; continue # skip if already found
1195 elif [[ $1 == *=* ]]; then
1195 elif [[ $1 == *=* ]]; then
1196 __dotenv=${BASH_REMATCH[1]}${BASH_REMATCH[3]}$1$'\n'${BASH_REMATCH[4]#*$'\n'}
1196 __dotenv=${BASH_REMATCH[1]}${BASH_REMATCH[3]}$1$'\n'${BASH_REMATCH[4]#*$'\n'}
1197 else
1197 else
1198 __dotenv=${BASH_REMATCH[1]}${BASH_REMATCH[4]#*$'\n'}
1198 __dotenv=${BASH_REMATCH[1]}${BASH_REMATCH[4]#*$'\n'}
1199 continue # delete all occurrences
1199 continue # delete all occurrences
1200 fi
1200 fi
1201 elif [[ $1 == *=* ]]; then
1201 elif [[ $1 == *=* ]]; then
1202 __dotenv+="${1#+}"$'\n'
1202 __dotenv+="${1#+}"$'\n'
1203 fi
1203 fi
1204 shift
1204 shift
1205 done
1205 done
1206 [[ $__dotenv == "$saved" ]] || .env::file save
1206 [[ $__dotenv == "$saved" ]] || .env::file save
1207 }
1207 }
1208
1208
1209 .env.puts() { echo "${1-}">>"$__dotenv_file" && __dotenv+="$1"$'\n'; }
1209 .env.puts() { echo "${1-}">>"$__dotenv_file" && __dotenv+="$1"$'\n'; }
1210
1210
1211 .env.generate() {
1211 .env.generate() {
1212 .env::arg "key required for generate" "$@" || return
1212 .env::arg "key required for generate" "$@" || return
1213 .env.get "$1" && return || REPLY=$("${@:2}") || return
1213 .env.get "$1" && return || REPLY=$("${@:2}") || return
1214 .env::one "generate: ouptut of '${*:2}' has more than one line" "$REPLY" || return
1214 .env::one "generate: ouptut of '${*:2}' has more than one line" "$REPLY" || return
1215 .env.puts "$1=$REPLY"
1215 .env.puts "$1=$REPLY"
1216 }
1216 }
1217
1217
1218 .env.--file() {
1218 .env.--file() {
1219 .env::arg "filename required for --file" "$@" || return
1219 .env::arg "filename required for --file" "$@" || return
1220 __dotenv_file=$1; .env::file load || return
1220 __dotenv_file=$1; .env::file load || return
1221 (($#<2)) || .env "${@:2}"
1221 (($#<2)) || .env "${@:2}"
1222 }
1222 }
1223
1223
1224 .env::arg() { [[ "${2-}" ]] || { echo "$__dotenv_cmd: $1" >&2; return 64; }; }
1224 .env::arg() { [[ "${2-}" ]] || { echo "$__dotenv_cmd: $1" >&2; return 64; }; }
1225
1225
1226 .env::one() { [[ "$2" != *$'\n'* ]] || .env::arg "$1"; }
1226 .env::one() { [[ "$2" != *$'\n'* ]] || .env::arg "$1"; }
1227
1227
1228 .env::file() {
1228 .env::file() {
1229 local REPLY=$__dotenv_file
1229 local REPLY=$__dotenv_file
1230 case "$1" in
1230 case "$1" in
1231 load)
1231 load)
1232 __dotenv=; ! [[ -f "$REPLY" ]] || __dotenv="$(<"$REPLY")"$'\n' || return ;;
1232 __dotenv=; ! [[ -f "$REPLY" ]] || __dotenv="$(<"$REPLY")"$'\n' || return ;;
1233 save)
1233 save)
1234 if [[ -L "$REPLY" ]] && declare -F -- realpath.resolved >/dev/null; then
1234 if [[ -L "$REPLY" ]] && declare -F -- realpath.resolved >/dev/null; then
1235 realpath.resolved "$REPLY"
1235 realpath.resolved "$REPLY"
1236 fi
1236 fi
1237 { [[ ! -f "$REPLY" ]] || cp -p "$REPLY" "$REPLY.bak"; } &&
1237 { [[ ! -f "$REPLY" ]] || cp -p "$REPLY" "$REPLY.bak"; } &&
1238 printf %s "$__dotenv" >"$REPLY.bak" && mv "$REPLY.bak" "$REPLY"
1238 printf %s "$__dotenv" >"$REPLY.bak" && mv "$REPLY.bak" "$REPLY"
1239 esac
1239 esac
1240 }
1240 }
1241 #
1241 #
1242 #__dotenv() {
1242 #__dotenv() {
1243 # set -eu
1243 # set -eu
1244 # __dotenv_cmd=${0##*/}
1244 # __dotenv_cmd=${0##*/}
1245 # .env.export() { .env.parse "$@" || return 0; printf 'export %q\n' "${REPLY[@]}"; REPLY=(); }
1245 # .env.export() { .env.parse "$@" || return 0; printf 'export %q\n' "${REPLY[@]}"; REPLY=(); }
1246 # .env "$@" || return $?
1246 # .env "$@" || return $?
1247 # ${REPLY[@]+printf '%s\n' "${REPLY[@]}"}
1247 # ${REPLY[@]+printf '%s\n' "${REPLY[@]}"}
1248 #}
1248 #}
1249 #if [[ $0 == "${BASH_SOURCE-}" ]]; then __dotenv "$@"; exit; fi
1249 #if [[ $0 == "${BASH_SOURCE-}" ]]; then __dotenv "$@"; exit; fi
1250
1250
1251 # src/lib/get_docker_definitions.sh
1251 # src/lib/get_docker_definitions.sh
1252
1252
1253 get_docker_definitions() {
1253 get_docker_definitions() {
1254 SOURCE_DIR=$PWD
1254 SOURCE_DIR=$PWD
1255 RHODECODE_DOCKER_HASH=$1
1255 RHODECODE_DOCKER_HASH=$1
1256
1256
1257 # download sources
1257 # download sources
1258 echo "bootstrap_definitions: download rhodecode docker definitions from $SERVER_URL"
1258 echo "bootstrap_definitions: download rhodecode docker definitions from $SERVER_URL"
1259 echo ""
1259 echo ""
1260
1260
1261 if [ $DEBUG ]; then
1261 if [ $DEBUG ]; then
1262 echo "bootstrap_definitions: downloading: $SERVER_URL/rhodecode-enterprise-docker/archive/$RHODECODE_DOCKER_HASH.tgz?with_hash=0"
1262 echo "bootstrap_definitions: downloading: $SERVER_URL/rhodecode-enterprise-docker/archive/$RHODECODE_DOCKER_HASH.tgz?with_hash=0"
1263 curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $SERVER_URL/rhodecode-enterprise-docker/archive/$RHODECODE_DOCKER_HASH.tgz?with_hash=0 | tar -xz -C $SOURCE_DIR
1263 curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $SERVER_URL/rhodecode-enterprise-docker/archive/$RHODECODE_DOCKER_HASH.tgz?with_hash=0 | tar -xz -C $SOURCE_DIR
1264
1264
1265 echo "bootstrap_definitions: running CP $SOURCE_DIR/*rhodecode-enterprise-docker-plain/* $SOURCE_DIR"
1265 echo "bootstrap_definitions: running CP $SOURCE_DIR/*rhodecode-enterprise-docker-plain/* $SOURCE_DIR"
1266 cp -v -r -f --update --backup=numbered $SOURCE_DIR/*rhodecode-enterprise-docker-plain/* $SOURCE_DIR
1266 cp -v -r -f --update --backup=numbered $SOURCE_DIR/*rhodecode-enterprise-docker-plain/* $SOURCE_DIR
1267
1267
1268 echo "bootstrap_definitions: removing $SOURCE_DIR/*rhodecode-enterprise-docker-plain"
1268 echo "bootstrap_definitions: removing $SOURCE_DIR/*rhodecode-enterprise-docker-plain"
1269 rm -r $SOURCE_DIR/*rhodecode-enterprise-docker-plain
1269 rm -r $SOURCE_DIR/*rhodecode-enterprise-docker-plain
1270 else
1270 else
1271 curl -s --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $SERVER_URL/rhodecode-enterprise-docker/archive/$RHODECODE_DOCKER_HASH.tgz?with_hash=0 | tar -xz -C $SOURCE_DIR
1271 curl -s --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $SERVER_URL/rhodecode-enterprise-docker/archive/$RHODECODE_DOCKER_HASH.tgz?with_hash=0 | tar -xz -C $SOURCE_DIR
1272 cp -r -f --update --backup=numbered $SOURCE_DIR/*rhodecode-enterprise-docker-plain/* $SOURCE_DIR
1272 cp -r -f --update --backup=numbered $SOURCE_DIR/*rhodecode-enterprise-docker-plain/* $SOURCE_DIR
1273 rm -r $SOURCE_DIR/*rhodecode-enterprise-docker-plain
1273 rm -r $SOURCE_DIR/*rhodecode-enterprise-docker-plain
1274 fi
1274 fi
1275
1275
1276 echo "$(green bootstrap_definitions: docker definitions extracted to $SOURCE_DIR)"
1276 echo "$(green bootstrap_definitions: docker definitions extracted to $SOURCE_DIR)"
1277
1277
1278 }
1278 }
1279
1279
1280 # src/lib/send_completions.sh
1280 # src/lib/send_completions.sh
1281 send_completions() {
1281 send_completions() {
1282 echo $'# rccontrol completion -*- shell-script -*-'
1282 echo $'# rccontrol completion -*- shell-script -*-'
1283 echo $''
1283 echo $''
1284 echo $'# This bash completions script was generated by'
1284 echo $'# This bash completions script was generated by'
1285 echo $'# completely (https://github.com/dannyben/completely)'
1285 echo $'# completely (https://github.com/dannyben/completely)'
1286 echo $'# Modifying it manually is not recommended'
1286 echo $'# Modifying it manually is not recommended'
1287 echo $''
1287 echo $''
1288 echo $'_rccontrol_completions_filter() {'
1288 echo $'_rccontrol_completions_filter() {'
1289 echo $' local words="$1"'
1289 echo $' local words="$1"'
1290 echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
1290 echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
1291 echo $' local result=()'
1291 echo $' local result=()'
1292 echo $''
1292 echo $''
1293 echo $' if [[ "${cur:0:1}" == "-" ]]; then'
1293 echo $' if [[ "${cur:0:1}" == "-" ]]; then'
1294 echo $' echo "$words"'
1294 echo $' echo "$words"'
1295 echo $' '
1295 echo $' '
1296 echo $' else'
1296 echo $' else'
1297 echo $' for word in $words; do'
1297 echo $' for word in $words; do'
1298 echo $' [[ "${word:0:1}" != "-" ]] && result+=("$word")'
1298 echo $' [[ "${word:0:1}" != "-" ]] && result+=("$word")'
1299 echo $' done'
1299 echo $' done'
1300 echo $''
1300 echo $''
1301 echo $' echo "${result[*]}"'
1301 echo $' echo "${result[*]}"'
1302 echo $''
1302 echo $''
1303 echo $' fi'
1303 echo $' fi'
1304 echo $'}'
1304 echo $'}'
1305 echo $''
1305 echo $''
1306 echo $'_rccontrol_completions() {'
1306 echo $'_rccontrol_completions() {'
1307 echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
1307 echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
1308 echo $' local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")'
1308 echo $' local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")'
1309 echo $' local compline="${compwords[*]}"'
1309 echo $' local compline="${compwords[*]}"'
1310 echo $''
1310 echo $''
1311 echo $' case "$compline" in'
1311 echo $' case "$compline" in'
1312 echo $' *\'get-build-artifacts\'*)'
1312 echo $' *\'get-build-artifacts\'*)'
1313 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--auth --help --installer-url --manifest-url --version-name -h")" -- "$cur" )'
1313 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--auth --help --installer-url --manifest-url --version-name -h")" -- "$cur" )'
1314 echo $' ;;'
1314 echo $' ;;'
1315 echo $''
1315 echo $''
1316 echo $' *\'get-build-source\'*)'
1316 echo $' *\'get-build-source\'*)'
1317 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--auth-token --help --revision --server-url -h")" -- "$cur" )'
1317 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--auth-token --help --revision --server-url -h")" -- "$cur" )'
1318 echo $' ;;'
1318 echo $' ;;'
1319 echo $''
1319 echo $''
1320 echo $' *\'stack\'*\'rhodecode\'*)'
1320 echo $' *\'stack\'*\'rhodecode\'*)'
1321 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1321 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1322 echo $' ;;'
1322 echo $' ;;'
1323 echo $''
1323 echo $''
1324 echo $' *\'stack\'*\'services\'*)'
1324 echo $' *\'stack\'*\'services\'*)'
1325 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1325 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1326 echo $' ;;'
1326 echo $' ;;'
1327 echo $''
1327 echo $''
1328 echo $' *\'cli db-upgrade\'*)'
1328 echo $' *\'cli db-upgrade\'*)'
1329 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1329 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1330 echo $' ;;'
1330 echo $' ;;'
1331 echo $''
1331 echo $''
1332 echo $' *\'stack\'*\'metrics\'*)'
1332 echo $' *\'stack\'*\'metrics\'*)'
1333 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1333 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1334 echo $' ;;'
1334 echo $' ;;'
1335 echo $''
1335 echo $''
1336 echo $' *\'stack-upgrade\'*)'
1336 echo $' *\'stack-upgrade\'*)'
1337 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1337 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1338 echo $' ;;'
1338 echo $' ;;'
1339 echo $''
1339 echo $''
1340 echo $' *\'build-source\'*)'
1340 echo $' *\'build-source\'*)'
1341 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help --version-name -h")" -- "$cur" )'
1341 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help --version-name -h")" -- "$cur" )'
1342 echo $' ;;'
1342 echo $' ;;'
1343 echo $''
1343 echo $''
1344 echo $' *\'stack-status\'*)'
1344 echo $' *\'stack-status\'*)'
1345 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1345 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1346 echo $' ;;'
1346 echo $' ;;'
1347 echo $''
1347 echo $''
1348 echo $' *\'_completions\'*)'
1348 echo $' *\'_completions\'*)'
1349 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1349 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1350 echo $' ;;'
1350 echo $' ;;'
1351 echo $''
1351 echo $''
1352 echo $' *\'stack\'*\'router\'*)'
1352 echo $' *\'stack\'*\'router\'*)'
1353 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1353 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1354 echo $' ;;'
1354 echo $' ;;'
1355 echo $''
1355 echo $''
1356 echo $' *\'cli storage\'*)'
1356 echo $' *\'cli storage\'*)'
1357 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1357 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1358 echo $' ;;'
1358 echo $' ;;'
1359 echo $''
1359 echo $''
1360 echo $' *\'self-update\'*)'
1360 echo $' *\'self-update\'*)'
1361 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--auth-token --help --server-url -h")" -- "$cur" )'
1361 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--auth-token --help --server-url -h")" -- "$cur" )'
1362 echo $' ;;'
1362 echo $' ;;'
1363 echo $''
1363 echo $''
1364 echo $' *\'backup-data\'*)'
1364 echo $' *\'backup-data\'*)'
1365 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1365 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1366 echo $' ;;'
1366 echo $' ;;'
1367 echo $''
1367 echo $''
1368 echo $' *\'stack\'*\'all\'*)'
1368 echo $' *\'stack\'*\'all\'*)'
1369 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1369 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1370 echo $' ;;'
1370 echo $' ;;'
1371 echo $''
1371 echo $''
1372 echo $' *\'backup-db\'*)'
1372 echo $' *\'backup-db\'*)'
1373 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1373 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1374 echo $' ;;'
1374 echo $' ;;'
1375 echo $''
1375 echo $''
1376 echo $' *\'bootstrap\'*)'
1376 echo $' *\'bootstrap\'*)'
1377 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--auth-token --force --help --server-url -f -h")" -- "$cur" )'
1377 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--auth-token --force --help --server-url -f -h")" -- "$cur" )'
1378 echo $' ;;'
1378 echo $' ;;'
1379 echo $''
1379 echo $''
1380 echo $' *\'cli redis\'*)'
1380 echo $' *\'cli redis\'*)'
1381 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1381 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1382 echo $' ;;'
1382 echo $' ;;'
1383 echo $''
1383 echo $''
1384 echo $' *\'cli db\'*)'
1384 echo $' *\'cli db\'*)'
1385 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1385 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1386 echo $' ;;'
1386 echo $' ;;'
1387 echo $''
1387 echo $''
1388 echo $' *\'status\'*)'
1388 echo $' *\'status\'*)'
1389 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1389 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h")" -- "$cur" )'
1390 echo $' ;;'
1390 echo $' ;;'
1391 echo $''
1391 echo $''
1392 echo $' *\'build\'*)'
1392 echo $' *\'build\'*)'
1393 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help --version-name -h")" -- "$cur" )'
1393 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help --version-name -h")" -- "$cur" )'
1394 echo $' ;;'
1394 echo $' ;;'
1395 echo $''
1395 echo $''
1396 echo $' *\'stack\'*)'
1396 echo $' *\'stack\'*)'
1397 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--env-file-path --help -h all metrics rhodecode router services")" -- "$cur" )'
1397 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--env-file-path --help -h all metrics rhodecode router services")" -- "$cur" )'
1398 echo $' ;;'
1398 echo $' ;;'
1399 echo $''
1399 echo $''
1400 echo $' *\'init\'*)'
1400 echo $' *\'init\'*)'
1401 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--auth-token --force --help --server-url -f -h")" -- "$cur" )'
1401 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--auth-token --force --help --server-url -f -h")" -- "$cur" )'
1402 echo $' ;;'
1402 echo $' ;;'
1403 echo $''
1403 echo $''
1404 echo $' *\'cli\'*)'
1404 echo $' *\'cli\'*)'
1405 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h db db-upgrade redis storage")" -- "$cur" )'
1405 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--help -h db db-upgrade redis storage")" -- "$cur" )'
1406 echo $' ;;'
1406 echo $' ;;'
1407 echo $''
1407 echo $''
1408 echo $' *)'
1408 echo $' *)'
1409 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--debug --help --version -h -v _completions backup-data backup-db bootstrap build build-source cli get-build-artifacts get-build-source init self-update stack stack-status stack-upgrade status")" -- "$cur" )'
1409 echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol_completions_filter "--debug --help --version -h -v _completions backup-data backup-db bootstrap build build-source cli get-build-artifacts get-build-source init self-update stack stack-status stack-upgrade status")" -- "$cur" )'
1410 echo $' ;;'
1410 echo $' ;;'
1411 echo $''
1411 echo $''
1412 echo $' esac'
1412 echo $' esac'
1413 echo $'} &&'
1413 echo $'} &&'
1414 echo $'complete -F _rccontrol_completions rccontrol'
1414 echo $'complete -F _rccontrol_completions rccontrol'
1415 echo $''
1415 echo $''
1416 echo $'# ex: filetype=sh'
1416 echo $'# ex: filetype=sh'
1417 }
1417 }
1418
1418
1419 # src/lib/validate_stack_exists.sh
1419 # src/lib/validate_stack_exists.sh
1420
1420
1421 validate_stack_exists() {
1421 validate_stack_exists() {
1422 err=""
1422 err=""
1423 invalid="1"
1423 invalid="1"
1424
1424
1425 for item in $VALID_SERVICES
1425 for item in $VALID_SERVICES
1426 do
1426 do
1427 if [ "$1" == "$item" ]; then
1427 if [ "$1" == "$item" ]; then
1428 invalid=""
1428 invalid=""
1429 break
1429 break
1430 fi
1430 fi
1431 done
1431 done
1432
1432
1433 if [[ -n $invalid ]]; then
1433 if [[ -n $invalid ]]; then
1434 err="command '$1' not in list of $VALID_SERVICES"
1434 err="command '$1' not in list of $VALID_SERVICES"
1435 fi
1435 fi
1436
1436
1437 echo $err
1437 echo $err
1438 }
1438 }
1439
1439
1440 # :command.command_functions
1440 # :command.command_functions
1441 # :command.function
1441 # :command.function
1442 rccontrol_self_update_command() {
1442 rccontrol_self_update_command() {
1443 # src/self_update_command.sh
1443 # src/self_update_command.sh
1444 check_bootstrap
1444 check_bootstrap
1445
1445
1446 AUTH_TOKEN=${args[--auth-token]}
1446 AUTH_TOKEN=${args[--auth-token]}
1447 SERVER_URL=${args[--server-url]}
1447 SERVER_URL=${args[--server-url]}
1448 revision=${args[--revision]}
1448 revision=${args[--revision]}
1449
1449
1450 FETCH_FROM=$SERVER_URL/rhodecode-enterprise-docker/raw/master/scripts/rccontrol/rccontrol
1450 FETCH_FROM=$SERVER_URL/rhodecode-enterprise-docker/raw/master/scripts/rccontrol/rccontrol
1451 TARGET=$PWD/scripts/rccontrol/rccontrol
1451 TARGET=$PWD/scripts/rccontrol/rccontrol
1452
1452
1453 echo "$(green self-update: downloading new rccontrol script from $FETCH_FROM)"
1453 echo "$(green self-update: downloading new rccontrol script from $FETCH_FROM)"
1454 curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -o $TARGET -L $FETCH_FROM
1454 curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -o $TARGET -L $FETCH_FROM
1455 chmod +x $TARGET
1455 chmod +x $TARGET
1456
1456
1457 echo "$(green self-update: done ! File saved in $TARGET)"
1457 echo "$(green self-update: done ! File saved in $TARGET)"
1458
1458
1459 get_docker_definitions $revision
1459 get_docker_definitions $revision
1460
1460
1461 echo "$(green self-update: done ! new version info:)"
1461 echo "$(green self-update: done ! new version info:)"
1462 ./rccontrol --version
1462 ./rccontrol --version
1463
1463
1464 exit
1464 exit
1465 }
1465 }
1466
1466
1467 # :command.function
1467 # :command.function
1468 rccontrol_bootstrap_command() {
1468 rccontrol_bootstrap_command() {
1469 # src/bootstrap_command.sh
1469 # src/bootstrap_command.sh
1470 DEBUG=${args[--debug]}
1470 DEBUG=${args[--debug]}
1471 force=${args[--force]}
1471 force=${args[--force]}
1472
1472
1473 check_docker() {
1473 check_docker() {
1474 (which docker || which docker.io) &>/dev/null
1474 (which docker || which docker.io) &>/dev/null
1475 }
1475 }
1476
1476
1477 bootstrap_docker_install() {
1477 bootstrap_docker_install() {
1478 echo "bootstrap_docker_install: trying to check and configure docker"
1478 echo "bootstrap_docker_install: trying to check and configure docker"
1479 failMsg="Failed to find docker on your PATH"
1479 failMsg="Failed to find docker on your PATH"
1480
1480
1481 if ! check_docker; then
1481 if ! check_docker; then
1482 echo "$failMsg"
1482 echo "$failMsg"
1483 read -p "Enter to install Docker directly from https://get.docker.com/ or Ctrl+C to exit"
1483 read -p "Enter to install Docker directly from https://get.docker.com/ or Ctrl+C to exit"
1484 curl https://get.docker.com/ | sh
1484 curl https://get.docker.com/ | sh
1485
1485
1486 if ! check_docker; then
1486 if ! check_docker; then
1487 echo "$failMsg"
1487 echo "$failMsg"
1488 echo "Docker install failed. Quitting."
1488 echo "Docker install failed. Quitting."
1489 exit
1489 exit
1490 fi
1490 fi
1491 fi
1491 fi
1492 }
1492 }
1493
1493
1494 bootstrap_docker_commons() {
1494 bootstrap_docker_commons() {
1495
1495
1496 echo 'bootstrap_docker_commons: running docker commands.'
1496 echo 'bootstrap_docker_commons: running docker commands.'
1497
1497
1498 echo "bootstrap_docker_commons: creating volume 'rc_datavolume'"
1498 echo "bootstrap_docker_commons: creating volume 'rc_datavolume'"
1499 docker volume create --label keep=1 --name=rc_datavolume
1499 docker volume create --label keep=1 --name=rc_datavolume
1500 echo "bootstrap_docker_commons: done"
1500 echo "bootstrap_docker_commons: done"
1501 echo ""
1501 echo ""
1502
1502
1503 echo "bootstrap_docker_commons: creating volume 'rc_reposvolume'"
1503 echo "bootstrap_docker_commons: creating volume 'rc_reposvolume'"
1504 docker volume create --label keep=1 --name=rc_reposvolume
1504 docker volume create --label keep=1 --name=rc_reposvolume
1505 echo "bootstrap_docker_commons: done"
1505 echo "bootstrap_docker_commons: done"
1506 echo ""
1506 echo ""
1507
1507
1508 echo "bootstrap_docker_commons: creating network 'rhodecode_network'"
1508 echo "bootstrap_docker_commons: creating network 'rhodecode_network'"
1509 docker network inspect rhodecode_network >/dev/null 2>&1 || docker network create rhodecode_network
1509 docker network inspect rhodecode_network >/dev/null 2>&1 || docker network create rhodecode_network
1510 echo "bootstrap_docker_commons: done"
1510 echo "bootstrap_docker_commons: done"
1511 echo ""
1511 echo ""
1512
1512
1513 echo "bootstrap_docker_commons: creating loki logging"
1513 echo "bootstrap_docker_commons: creating loki logging"
1514 loki_driver=$(docker plugin ls --format {{.Name}} --filter enabled=true | grep loki || echo "")
1514 loki_driver=$(docker plugin ls --format {{.Name}} --filter enabled=true | grep loki || echo "")
1515 if [[ $loki_driver == "" ]]; then
1515 if [[ $loki_driver == "" ]]; then
1516 docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
1516 docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
1517 else
1517 else
1518 echo "bootstrap_docker_commons: loki driver already exists"
1518 echo "bootstrap_docker_commons: loki driver already exists"
1519 fi
1519 fi
1520 }
1520 }
1521
1521
1522 random_str() {
1522 random_str() {
1523 len=$1
1523 len=$1
1524 random_generate=$(echo $RANDOM | md5sum | head -c $len)
1524 random_generate=$(echo $RANDOM | md5sum | head -c $len)
1525 echo $random_generate
1525 echo $random_generate
1526 }
1526 }
1527
1527
1528 bootstrap_config() {
1528 bootstrap_config() {
1529 shared_key=$(random_str 32)
1529 shared_key=$(random_str 32)
1530 db_key=$(random_str 32)
1530 db_key=$(random_str 32)
1531 license_token="$(random_str 4)"-"$(random_str 4)"-"$(random_str 4)"-"$(random_str 4)"
1531 license_token="$(random_str 4)"-"$(random_str 4)"-"$(random_str 4)"-"$(random_str 4)"
1532
1532
1533 # TODO: change formatter to json for loki usage
1533 # TODO: change formatter to json for loki usage
1534 log_formatter=generic
1534 log_formatter=generic
1535
1535
1536 base_url=http://docker-dev
1536 base_url=http://docker-dev
1537 DB_USER='rhodecode'
1537 DB_USER='rhodecode'
1538 DB_NAME='rhodecode'
1538 DB_NAME='rhodecode'
1539
1539
1540 if [[ ! -f "$CONFIG_FILE" ]]; then
1540 if [[ ! -f "$CONFIG_FILE" ]]; then
1541 echo "init new config at: $CONFIG_FILE"
1541 echo "init new config at: $CONFIG_FILE"
1542 config_init
1542 config_init
1543 else
1543 else
1544 echo "re-using existing config at: $CONFIG_FILE"
1544 echo "re-using existing config at: $CONFIG_FILE"
1545 fi
1545 fi
1546
1546
1547 mkdir -p $PWD/.custom
1547 mkdir -p $PWD/.custom
1548 BOOTSTRAP_TMPL=$PWD/templates/runtime.env.tmpl
1548 BOOTSTRAP_TMPL=$PWD/templates/runtime.env.tmpl
1549 BOOTSTRAP_RUNTIME_ENV=$PWD/.custom/.runtime.env
1549 BOOTSTRAP_RUNTIME_ENV=$PWD/.custom/.runtime.env
1550
1550
1551 if [[ ! -f "$BOOTSTRAP_RUNTIME_ENV" ]]; then
1551 if [[ ! -f "$BOOTSTRAP_RUNTIME_ENV" ]]; then
1552 echo "bootstrap_config: init runtime env config at: $BOOTSTRAP_RUNTIME_ENV"
1552 echo "bootstrap_config: init runtime env config at: $BOOTSTRAP_RUNTIME_ENV"
1553 touch $BOOTSTRAP_RUNTIME_ENV
1553 touch $BOOTSTRAP_RUNTIME_ENV
1554
1554
1555 echo "## BOOTSTRAP GENERATED" >> $BOOTSTRAP_RUNTIME_ENV
1555 echo "## BOOTSTRAP GENERATED" >> $BOOTSTRAP_RUNTIME_ENV
1556 cat $BOOTSTRAP_TMPL >> $BOOTSTRAP_RUNTIME_ENV
1556 cat $BOOTSTRAP_TMPL >> $BOOTSTRAP_RUNTIME_ENV
1557
1557
1558 # init env generator with env file
1558 # init env generator with env file
1559 .env --file $BOOTSTRAP_RUNTIME_ENV
1559 .env --file $BOOTSTRAP_RUNTIME_ENV
1560
1560
1561 .env set DB_PASSWORD=$db_key
1561 .env set DB_PASSWORD=$db_key
1562
1562
1563 .env set +RC_ENCRYPTED_SECRET=$shared_key
1563 .env set +RC_ENCRYPTED_SECRET=$shared_key
1564 .env set +RC_DB_URL="postgresql://$DB_USER:$db_key@database/$DB_NAME"
1564 .env set +RC_DB_URL="postgresql://$DB_USER:$db_key@database/$DB_NAME"
1565 .env set +RC_SQLALCHEMY_DB1_URL="postgresql://$DB_USER:$db_key@database/$DB_NAME"
1565 .env set +RC_SQLALCHEMY_DB1_URL="postgresql://$DB_USER:$db_key@database/$DB_NAME"
1566
1566
1567 .env set +RC_LICENSE_TOKEN=$license_token
1567 .env set +RC_LICENSE_TOKEN=$license_token
1568 .env set +RC_BASE_URL=$base_url
1568 .env set +RC_BASE_URL=$base_url
1569
1569
1570 .env puts '# Log formatter option'
1570 .env puts '# Log formatter option'
1571 .env set +RC_LOG_FORMATTER=$log_formatter
1571 .env set +RC_LOG_FORMATTER=$log_formatter
1572 .env set +RC_USE_CELERY=true
1572 .env set +RC_USE_CELERY=true
1573
1573
1574 .env puts '# Channelstream config'
1574 .env puts '# Channelstream config'
1575 .env set +RC_CHANNELSTREAM_WS_URL=ws:/docker-dev/_channelstream
1575 .env set +RC_CHANNELSTREAM_WS_URL=ws:/docker-dev/_channelstream
1576 .env set +CHANNELSTREAM_SECRET=$shared_key
1576 .env set +CHANNELSTREAM_SECRET=$shared_key
1577 .env set +CHANNELSTREAM_ADMIN_SECRET=$shared_key
1577 .env set +CHANNELSTREAM_ADMIN_SECRET=$shared_key
1578 .env set +CHANNELSTREAM_ALLOW_POSTING_FROM=0.0.0.0
1578 .env set +CHANNELSTREAM_ALLOW_POSTING_FROM=0.0.0.0
1579
1579
1580 else
1580 else
1581 echo "bootstrap_config: $BOOTSTRAP_RUNTIME_ENV file exists, not adding any configuration..."
1581 echo "bootstrap_config: $BOOTSTRAP_RUNTIME_ENV file exists, not adding any configuration..."
1582 fi
1582 fi
1583 }
1583 }
1584
1584
1585 bootstrap_definitions() {
1585 bootstrap_definitions() {
1586
1586
1587 AUTH_TOKEN=${args[--auth-token]}
1587 AUTH_TOKEN=${args[--auth-token]}
1588 SERVER_URL=${args[--server-url]}
1588 SERVER_URL=${args[--server-url]}
1589
1589
1590 DEFINITIONS_EXIST=""
1590 DEFINITIONS_EXIST=""
1591 CHECK_FILES="\
1591 CHECK_FILES="\
1592 docker-compose-services.yaml \
1592 docker-compose-services.yaml \
1593 docker-compose-apps.yaml \
1593 docker-compose-apps.yaml \
1594 docker-compose-metrics.yaml \
1594 docker-compose-metrics.yaml \
1595 docker-compose-router.yaml \
1595 docker-compose-router.yaml \
1596 "
1596 "
1597 for check_file in $CHECK_FILES; do
1597 for check_file in $CHECK_FILES; do
1598 if [[ -f "$check_file" ]]; then
1598 if [[ -f "$check_file" ]]; then
1599 DEFINITIONS_EXIST="1"
1599 DEFINITIONS_EXIST="1"
1600 fi
1600 fi
1601 done
1601 done
1602
1602
1603 if [[ -n $DEFINITIONS_EXIST && ! $force ]]; then
1603 if [[ -n $DEFINITIONS_EXIST && ! $force ]]; then
1604 echo "$(yellow bootstrap_definitions: skipping docker defs creation, existing files found. Use --force to create them anyway)"
1604 echo "$(yellow bootstrap_definitions: skipping docker defs creation, existing files found. Use --force to create them anyway)"
1605 return
1605 return
1606 fi
1606 fi
1607
1607
1608 if [[ -n $DEFINITIONS_EXIST ]]; then
1608 if [[ -n $DEFINITIONS_EXIST ]]; then
1609 echo "$(yellow docker definitions exists, are you sure to force re-create them?)"
1609 echo "$(yellow docker definitions exists, are you sure to force re-create them?)"
1610 while true; do
1610 while true; do
1611 read -p "Would you like to continue with overriding file? [yn] " yn
1611 read -p "Would you like to continue with overriding file? [yn] " yn
1612 case $yn in
1612 case $yn in
1613 [Yy]*) return 2 ;;
1613 [Yy]*) return 2 ;;
1614 [Nn]*) exit ;;
1614 [Nn]*) exit ;;
1615 *) echo "Please answer y or n." ;;
1615 *) echo "Please answer y or n." ;;
1616 esac
1616 esac
1617 done
1617 done
1618 fi
1618 fi
1619
1619
1620 get_docker_definitions
1620 get_docker_definitions
1621 }
1621 }
1622
1622
1623 bootstrap_overrides() {
1623 bootstrap_overrides() {
1624 templates=$(find $PWD/templates/*.yaml -printf "%f\n")
1624 templates=$(find $PWD/templates/*.yaml -printf "%f\n")
1625
1625
1626 target_dir=$PWD/.custom
1626 target_dir=$PWD/.custom
1627 for o_file in $templates; do
1627 for o_file in $templates; do
1628 target_file=$target_dir/$o_file
1628 target_file=$target_dir/$o_file
1629 if [[ ! -f "$target_file" ]]; then
1629 if [[ ! -f "$target_file" ]]; then
1630 echo "copy override file $o_file"
1630 echo "copy override file $o_file"
1631 cp -v $PWD/templates/$o_file $target_file
1631 cp -v $PWD/templates/$o_file $target_file
1632 else
1632 else
1633 echo "file $target_file existing, skipping..."
1633 echo "file $target_file existing, skipping..."
1634 fi
1634 fi
1635 done
1635 done
1636 echo "$(green bootstrap_overrides: overrides extracted to $target_dir)"
1636 echo "$(green bootstrap_overrides: overrides extracted to $target_dir)"
1637 }
1637 }
1638
1638
1639 cur_date=$(date '+%Y-%m-%d %H:%M:%S')
1639 cur_date=$(date '+%Y-%m-%d %H:%M:%S')
1640
1640
1641 # Init the config !
1641 # Init the config !
1642 if [[ ! -f "$CONFIG_FILE" ]]; then
1642 if [[ ! -f "$CONFIG_FILE" ]]; then
1643 echo "config: init new config at: $CONFIG_FILE"
1643 echo "config: init new config at: $CONFIG_FILE"
1644 config_init
1644 config_init
1645 else
1645 else
1646 echo "config: re-using present config at: $CONFIG_FILE"
1646 echo "config: re-using present config at: $CONFIG_FILE"
1647 fi
1647 fi
1648
1648
1649 for stage in $BOOTSTRAP_STAGES; do
1649 for stage in $BOOTSTRAP_STAGES; do
1650
1650
1651 stage_name=$(echo $stage | cut -d ":" -f 1)
1651 stage_name=$(echo $stage | cut -d ":" -f 1)
1652 stage_func=$(echo $stage | cut -d ":" -f 2)
1652 stage_func=$(echo $stage | cut -d ":" -f 2)
1653
1653
1654 if ! config_has_key $stage_name ; then
1654 if ! config_has_key $stage_name ; then
1655 echo "$(green \* bootstrap: \'$stage_name\' stage not found\; running now... )"
1655 echo "$(green \* bootstrap: \'$stage_name\' stage not found\; running now... )"
1656 $stage_func
1656 $stage_func
1657 config_set "$stage_name" $cur_date
1657 config_set "$stage_name" $cur_date
1658 else
1658 else
1659 if [ $force ]; then
1659 if [ $force ]; then
1660 echo "$(green \* bootstrap: \'$stage_name\' is present!\; FORCE running now... )"
1660 echo "$(green \* bootstrap: \'$stage_name\' is present!\; FORCE running now... )"
1661 $stage_func $force
1661 $stage_func $force
1662 config_set "$stage_name" $cur_date
1662 config_set "$stage_name" $cur_date
1663 else
1663 else
1664 echo "$(yellow \* bootstrap: \'$stage_name\' already present, use --force to run it again)"
1664 echo "$(yellow \* bootstrap: \'$stage_name\' already present, use --force to run it again)"
1665 fi
1665 fi
1666 fi
1666 fi
1667
1667
1668 done
1668 done
1669
1669
1670 echo "~~~~ $(green Bootstrap completed) ~~~~"
1670 echo "~~~~ $(green Bootstrap completed) ~~~~"
1671
1671
1672 get_started
1672 get_started
1673 }
1673 }
1674
1674
1675 # :command.function
1675 # :command.function
1676 rccontrol_get_build_artifacts_command() {
1676 rccontrol_get_build_artifacts_command() {
1677 # src/get_build_artifacts_command.sh
1677 # src/get_build_artifacts_command.sh
1678 check_bootstrap
1678 check_bootstrap
1679
1679
1680 DEBUG=${args[--debug]}
1680 DEBUG=${args[--debug]}
1681 AUTH=${args[--auth]}
1681 AUTH=${args[--auth]}
1682 INSTALLER_URL=${args[--installer-url]}
1682 INSTALLER_URL=${args[--installer-url]}
1683 MANIFEST_URL=${args[--manifest-url]}
1683 MANIFEST_URL=${args[--manifest-url]}
1684 RC_VERSION=${args[--version-name]}
1684 RC_VERSION=${args[--version-name]}
1685 VER=$RC_VERSION
1685 VER=$RC_VERSION
1686
1686
1687 CACHE_DIR=$PWD/.cache
1687 CACHE_DIR=$PWD/.cache
1688 VER_REGEX="$VER+x86_64"
1688 VER_REGEX="$VER+x86_64"
1689
1689
1690 echo "Downloading Artifacts for version: $VER"
1690 echo "Downloading Artifacts for version: $VER"
1691
1691
1692 echo "1/4 Checking available downloads from MANIFEST file"
1692 echo "1/4 Checking available downloads from MANIFEST file"
1693
1693
1694 ARTS=$(curl -s $AUTH $MANIFEST_URL | grep --ignore-case "$VER_REGEX" | cut -d ' ' -f 2)
1694 ARTS=$(curl -s $AUTH $MANIFEST_URL | grep --ignore-case "$VER_REGEX" | cut -d ' ' -f 2)
1695
1695
1696 if [[ $DEBUG ]]; then
1696 if [[ $DEBUG ]]; then
1697 echo "DEBUG START"
1697 echo "DEBUG START"
1698 curl -s $AUTH $MANIFEST_URL | grep --ignore-case "$VER_REGEX" || echo "no regex match"
1698 curl -s $AUTH $MANIFEST_URL | grep --ignore-case "$VER_REGEX" || echo "no regex match"
1699 curl -s $AUTH $MANIFEST_URL | grep --ignore-case "$VER_REGEX" | cut -d ' ' -f 2
1699 curl -s $AUTH $MANIFEST_URL | grep --ignore-case "$VER_REGEX" | cut -d ' ' -f 2
1700 echo "Found following artifacts:"
1700 echo "Found following artifacts:"
1701 echo $ARTS
1701 echo $ARTS
1702 echo "DEBUG END"
1702 echo "DEBUG END"
1703 fi
1703 fi
1704
1704
1705 if [[ $ARTS == "" ]]; then
1705 if [[ $ARTS == "" ]]; then
1706 MSG="Failed to found any MANIFEST entries for version $VER make sure there exists release with that version or use --version to specify different version"
1706 MSG="Failed to found any MANIFEST entries for version $VER make sure there exists release with that version or use --version to specify different version"
1707 echo "$(red $MSG)"
1707 echo "$(red $MSG)"
1708 exit
1708 exit
1709 fi
1709 fi
1710
1710
1711 echo "2/4 Downloading locale-archive"
1711 echo "2/4 Downloading locale-archive"
1712 curl -L https://dls.rhodecode.com/assets/locale-archive -J -O
1712 curl -L https://dls.rhodecode.com/assets/locale-archive -J -O
1713 mv -v locale-archive "$CACHE_DIR"
1713 mv -v locale-archive "$CACHE_DIR"
1714
1714
1715 # vcsserver/ce/ee
1715 # vcsserver/ce/ee
1716 echo "3/4 Downloading installer artifacts"
1716 echo "3/4 Downloading installer artifacts"
1717 for url in $ARTS; do
1717 for url in $ARTS; do
1718 echo "Downloading $url with $AUTH"
1718 echo "Downloading $url with $AUTH"
1719 curl $AUTH --fail-early -L ${url} -J -O
1719 curl $AUTH --fail-early -L ${url} -J -O
1720 done
1720 done
1721
1721
1722 #for url in $(curl -s $MANIFEST_URL | grep --ignore-case -E 'control.+\+x86_64' | cut -d ' ' -f 2); do
1722 #for url in $(curl -s $MANIFEST_URL | grep --ignore-case -E 'control.+\+x86_64' | cut -d ' ' -f 2); do
1723 # echo "Downloading $url"
1723 # echo "Downloading $url"
1724 # curl -L ${url} -J -O
1724 # curl -L ${url} -J -O
1725 #done
1725 #done
1726
1726
1727 echo "4/4 Downloading installer from $INSTALLER_URL"
1727 echo "4/4 Downloading installer from $INSTALLER_URL"
1728 curl $AUTH -L $INSTALLER_URL -J -O
1728 curl $AUTH -L $INSTALLER_URL -J -O
1729
1729
1730 INSTALLER=$(ls -Art RhodeCode-installer-* | tail -n 1)
1730 INSTALLER=$(ls -Art RhodeCode-installer-* | tail -n 1)
1731 if [[ -n $INSTALLER ]]; then
1731 if [[ -n $INSTALLER ]]; then
1732 chmod +x "${INSTALLER}"
1732 chmod +x "${INSTALLER}"
1733 fi
1733 fi
1734
1734
1735 echo "Copying artifacts into $CACHE_DIR"
1735 echo "Copying artifacts into $CACHE_DIR"
1736
1736
1737 mv -v "${INSTALLER}" $CACHE_DIR
1737 mv -v "${INSTALLER}" $CACHE_DIR
1738 mv -v *.bz2 $CACHE_DIR
1738 mv -v *.bz2 $CACHE_DIR
1739 ls -lh $CACHE_DIR
1739 ls -lh $CACHE_DIR
1740
1740
1741 }
1741 }
1742
1742
1743 # :command.function
1743 # :command.function
1744 rccontrol_build_command() {
1744 rccontrol_build_command() {
1745 # src/build_command.sh
1745 # src/build_command.sh
1746 check_bootstrap
1746 check_bootstrap
1747
1747
1748 rc_version=${args[--version-name]}
1748 rc_version=${args[--version-name]}
1749 export RC_VERSION=$rc_version
1749 export RC_VERSION=$rc_version
1750 eval "echo INSTALLER BASED BUILDING${RC_VERSION}"
1750 eval "echo INSTALLER BASED BUILDING${RC_VERSION}"
1751
1751
1752 RC_VERSION=$rc_version ./rccontrol stack rhodecode build --progress plain rhodecode
1752 RC_VERSION=$rc_version ./rccontrol stack rhodecode build --progress plain rhodecode
1753
1753
1754 }
1754 }
1755
1755
1756 # :command.function
1756 # :command.function
1757 rccontrol_get_build_source_command() {
1757 rccontrol_get_build_source_command() {
1758 # src/get_build_source_command.sh
1758 # src/get_build_source_command.sh
1759 check_bootstrap
1759 check_bootstrap
1760
1760
1761 AUTH_TOKEN=${args[--auth-token]}
1761 AUTH_TOKEN=${args[--auth-token]}
1762 SERVER_URL=${args[--server-url]}
1762 SERVER_URL=${args[--server-url]}
1763 revision=${args[--revision]}
1763 revision=${args[--revision]}
1764
1764
1765 SOURCE_DIR=$PWD/.source
1765 SOURCE_DIR=$PWD/.source
1766
1766
1767 RHODECODE_VCS_HASH=$revision
1767 RHODECODE_VCS_HASH=$revision
1768 RHODECODE_CE_HASH=$revision
1768 RHODECODE_CE_HASH=$revision
1769 RHODECODE_EE_HASH=$revision
1769 RHODECODE_EE_HASH=$revision
1770
1770
1771 # download sources
1771 # download sources
1772 echo "** download rhodecode source for build from $SERVER_URL using '$revision' hash**"
1772 echo "** download rhodecode source for build from $SERVER_URL using '$revision' hash**"
1773
1773
1774 echo "getting $SERVER_URL/rhodecode-vcsserver/archive/$RHODECODE_VCS_HASH.tgz"
1774 echo "getting $SERVER_URL/rhodecode-vcsserver/archive/$RHODECODE_VCS_HASH.tgz"
1775 curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $SERVER_URL/rhodecode-vcsserver/archive/$RHODECODE_VCS_HASH.tgz?with_hash=0 | tar -xz -C $SOURCE_DIR
1775 curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $SERVER_URL/rhodecode-vcsserver/archive/$RHODECODE_VCS_HASH.tgz?with_hash=0 | tar -xz -C $SOURCE_DIR
1776
1776
1777 echo "getting $SERVER_URL/rhodecode-enterprise-ce/archive/$RHODECODE_CE_HASH.tgz"
1777 echo "getting $SERVER_URL/rhodecode-enterprise-ce/archive/$RHODECODE_CE_HASH.tgz"
1778 curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $SERVER_URL/rhodecode-enterprise-ce/archive/$RHODECODE_CE_HASH.tgz?with_hash=0 | tar -xz -C $SOURCE_DIR
1778 curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $SERVER_URL/rhodecode-enterprise-ce/archive/$RHODECODE_CE_HASH.tgz?with_hash=0 | tar -xz -C $SOURCE_DIR
1779
1779
1780 echo "getting $SERVER_URL/rhodecode-enterprise-ee/archive/$RHODECODE_EE_HASH.tgz"
1780 echo "getting $SERVER_URL/rhodecode-enterprise-ee/archive/$RHODECODE_EE_HASH.tgz"
1781 curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $SERVER_URL/rhodecode-enterprise-ee/archive/$RHODECODE_EE_HASH.tgz?with_hash=0 | tar -xz -C $SOURCE_DIR
1781 curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $SERVER_URL/rhodecode-enterprise-ee/archive/$RHODECODE_EE_HASH.tgz?with_hash=0 | tar -xz -C $SOURCE_DIR
1782
1782
1783 rm -rf $SOURCE_DIR/rhodecode-vcsserver && \
1783 rm -rf $SOURCE_DIR/rhodecode-vcsserver && \
1784 mv $SOURCE_DIR/*rhodecode-vcsserver-plain $SOURCE_DIR/rhodecode-vcsserver
1784 mv $SOURCE_DIR/*rhodecode-vcsserver-plain $SOURCE_DIR/rhodecode-vcsserver
1785
1785
1786 rm -rf $SOURCE_DIR/rhodecode-enterprise-ce && \
1786 rm -rf $SOURCE_DIR/rhodecode-enterprise-ce && \
1787 mv $SOURCE_DIR/*rhodecode-enterprise-ce-plain $SOURCE_DIR/rhodecode-enterprise-ce
1787 mv $SOURCE_DIR/*rhodecode-enterprise-ce-plain $SOURCE_DIR/rhodecode-enterprise-ce
1788
1788
1789 rm -rf $SOURCE_DIR/rhodecode-enterprise-ee && \
1789 rm -rf $SOURCE_DIR/rhodecode-enterprise-ee && \
1790 mv $SOURCE_DIR/*rhodecode-enterprise-ee-plain $SOURCE_DIR/rhodecode-enterprise-ee
1790 mv $SOURCE_DIR/*rhodecode-enterprise-ee-plain $SOURCE_DIR/rhodecode-enterprise-ee
1791
1791
1792 echo "downloading sources done to $SOURCE_DIR"
1792 echo "downloading sources done to $SOURCE_DIR"
1793 ls -l $SOURCE_DIR
1793 ls -l $SOURCE_DIR
1794
1794
1795 echo "to create source based build run ./rccontrol build-source --version-name 4.28.0.REL.2022.12.10"
1795 echo "to create source based build run ./rccontrol build-source --version-name 4.28.0.REL.2022.12.10"
1796
1796
1797 }
1797 }
1798
1798
1799 # :command.function
1799 # :command.function
1800 rccontrol_build_source_command() {
1800 rccontrol_build_source_command() {
1801 # src/build_source_command.sh
1801 # src/build_source_command.sh
1802 check_bootstrap
1802 check_bootstrap
1803
1803
1804 rc_version=${args[--version-name]}
1804 rc_version=${args[--version-name]}
1805 export RC_VERSION=$rc_version
1805 export RC_VERSION=$rc_version
1806 eval "echo SOURCE BASED BUILDING${RC_VERSION}"
1806 eval "echo SOURCE BASED BUILDING${RC_VERSION}"
1807
1807
1808 RC_VERSION=$rc_version ./rccontrol stack rhodecode -f docker-compose-apps.source.yaml build --progress plain rhodecode
1808 RC_VERSION=$rc_version ./rccontrol stack rhodecode -f docker-compose-apps.source.yaml build --progress plain rhodecode
1809
1809
1810 }
1810 }
1811
1811
1812 # :command.function
1812 # :command.function
1813 rccontrol_stack_router_command() {
1813 rccontrol_stack_router_command() {
1814 # src/stack_router_command.sh
1814 # src/stack_router_command.sh
1815 check_bootstrap
1815 check_bootstrap
1816
1816
1817 DEBUG=${args[--debug]}
1817 DEBUG=${args[--debug]}
1818 ENV_FILE=${args[--env-file-path]}
1818 ENV_FILE=${args[--env-file-path]}
1819
1819
1820 if [[ ! -f $RC_STACK_ROUTER_EXT ]]; then
1820 if [[ ! -f $RC_STACK_ROUTER_EXT ]]; then
1821 RC_STACK_ROUTER_EXT=""
1821 RC_STACK_ROUTER_EXT=""
1822 else
1822 else
1823 RC_STACK_ROUTER_EXT="-f $RC_STACK_ROUTER_EXT"
1823 RC_STACK_ROUTER_EXT="-f $RC_STACK_ROUTER_EXT"
1824 fi
1824 fi
1825
1825
1826 CMD_ROUTER="\
1826 CMD_ROUTER="\
1827 RC_ENV_FILE=$ENV_FILE docker compose \
1827 RC_ENV_FILE=$ENV_FILE docker compose \
1828 --env-file $ENV_FILE \
1828 --env-file $ENV_FILE \
1829 $ENV_EXPAND \
1829 $ENV_EXPAND \
1830 -p rc_cluster_router \
1830 -p rc_cluster_router \
1831 -f docker-compose-base.yaml \
1831 -f docker-compose-base.yaml \
1832 -f docker-compose-router.yaml $RC_STACK_ROUTER_EXT"
1832 -f docker-compose-router.yaml $RC_STACK_ROUTER_EXT"
1833
1833
1834 if [[ $DEBUG ]]; then
1834 if [[ $DEBUG ]]; then
1835 echo "---"
1835 echo "---"
1836 echo "stacks docker: $RC_STACK_ROUTER_EXT_LCL"
1836 echo "stacks docker: $RC_STACK_ROUTER_EXT_LCL"
1837 echo "running command: ${CMD_ROUTER}"
1837 echo "running command: ${CMD_ROUTER}"
1838 echo "ARGS: ${other_args[*]}"
1838 echo "ARGS: ${other_args[*]}"
1839 echo "---"
1839 echo "---"
1840 fi
1840 fi
1841 eval "${CMD_ROUTER} ${other_args[*]}"
1841 eval "${CMD_ROUTER} ${other_args[*]}"
1842
1842
1843 }
1843 }
1844
1844
1845 # :command.function
1845 # :command.function
1846 rccontrol_stack_metrics_command() {
1846 rccontrol_stack_metrics_command() {
1847 # src/stack_metrics_command.sh
1847 # src/stack_metrics_command.sh
1848 check_bootstrap
1848 check_bootstrap
1849
1849
1850 DEBUG=${args[--debug]}
1850 DEBUG=${args[--debug]}
1851 ENV_FILE=${args[--env-file-path]}
1851 ENV_FILE=${args[--env-file-path]}
1852
1852
1853 if [[ ! -f $RC_STACK_METRICS_EXT ]]; then
1853 if [[ ! -f $RC_STACK_METRICS_EXT ]]; then
1854 RC_STACK_METRICS_EXT_LCL=""
1854 RC_STACK_METRICS_EXT_LCL=""
1855 else
1855 else
1856 RC_STACK_METRICS_EXT_LCL="-f $RC_STACK_METRICS_EXT"
1856 RC_STACK_METRICS_EXT_LCL="-f $RC_STACK_METRICS_EXT"
1857 fi
1857 fi
1858
1858
1859 CMD_METRICS="\
1859 CMD_METRICS="\
1860 RC_ENV_FILE=$ENV_FILE docker compose \
1860 RC_ENV_FILE=$ENV_FILE docker compose \
1861 --env-file $ENV_FILE \
1861 --env-file $ENV_FILE \
1862 $ENV_EXPAND \
1862 $ENV_EXPAND \
1863 -p rc_cluster_metrics \
1863 -p rc_cluster_metrics \
1864 -f docker-compose-base.yaml \
1864 -f docker-compose-base.yaml \
1865 -f docker-compose-metrics.yaml $RC_STACK_METRICS_EXT_LCL"
1865 -f docker-compose-metrics.yaml $RC_STACK_METRICS_EXT_LCL"
1866
1866
1867 if [[ $DEBUG ]]; then
1867 if [[ $DEBUG ]]; then
1868 echo "---"
1868 echo "---"
1869 echo "stacks docker: $RC_STACK_METRICS_EXT_LCL"
1869 echo "stacks docker: $RC_STACK_METRICS_EXT_LCL"
1870 echo "running command: ${CMD_METRICS}"
1870 echo "running command: ${CMD_METRICS}"
1871 echo "ARGS: ${other_args[*]}"
1871 echo "ARGS: ${other_args[*]}"
1872 echo "---"
1872 echo "---"
1873 fi
1873 fi
1874 eval "${CMD_METRICS} ${other_args[*]}"
1874 eval "${CMD_METRICS} ${other_args[*]}"
1875 }
1875 }
1876
1876
1877 # :command.function
1877 # :command.function
1878 rccontrol_stack_services_command() {
1878 rccontrol_stack_services_command() {
1879 # src/stack_services_command.sh
1879 # src/stack_services_command.sh
1880 check_bootstrap
1880 check_bootstrap
1881
1881
1882 DEBUG=${args[--debug]}
1882 DEBUG=${args[--debug]}
1883 ENV_FILE=${args[--env-file-path]}
1883 ENV_FILE=${args[--env-file-path]}
1884
1884
1885 if [[ ! -f $RC_STACK_SERVICES_EXT ]]; then
1885 if [[ ! -f $RC_STACK_SERVICES_EXT ]]; then
1886 RC_STACK_SERVICES_EXT_LCL=""
1886 RC_STACK_SERVICES_EXT_LCL=""
1887 else
1887 else
1888 RC_STACK_SERVICES_EXT_LCL="-f $RC_STACK_SERVICES_EXT"
1888 RC_STACK_SERVICES_EXT_LCL="-f $RC_STACK_SERVICES_EXT"
1889 fi
1889 fi
1890
1890
1891 RC_STACK_PROFILES="--profile postgres --profile redis --profile elasticsearch --profile channelstream"
1891 RC_STACK_PROFILES="--profile postgres --profile redis --profile elasticsearch --profile channelstream"
1892
1892
1893 CMD_SERVICES="\
1893 CMD_SERVICES="\
1894 RC_ENV_FILE=$ENV_FILE docker compose \
1894 RC_ENV_FILE=$ENV_FILE docker compose \
1895 --env-file $ENV_FILE \
1895 --env-file $ENV_FILE \
1896 $ENV_EXPAND \
1896 $ENV_EXPAND \
1897 $RC_STACK_PROFILES \
1897 $RC_STACK_PROFILES \
1898 -p rc_cluster_services \
1898 -p rc_cluster_services \
1899 -f docker-compose-base.yaml \
1899 -f docker-compose-base.yaml \
1900 -f docker-compose-services.yaml $RC_STACK_SERVICES_EXT_LCL"
1900 -f docker-compose-services.yaml $RC_STACK_SERVICES_EXT_LCL"
1901
1901
1902 if [[ $DEBUG ]]; then
1902 if [[ $DEBUG ]]; then
1903 echo "---"
1903 echo "---"
1904 echo "stacks docker: $RC_STACK_SERVICES_EXT_LCL"
1904 echo "stacks docker: $RC_STACK_SERVICES_EXT_LCL"
1905 echo "running command: ${CMD_SERVICES}"
1905 echo "running command: ${CMD_SERVICES}"
1906 echo "ARGS: ${other_args[*]}"
1906 echo "ARGS: ${other_args[*]}"
1907 echo "---"
1907 echo "---"
1908 fi
1908 fi
1909
1909
1910 eval "${CMD_SERVICES} ${other_args[*]}"
1910 eval "${CMD_SERVICES} ${other_args[*]}"
1911 }
1911 }
1912
1912
1913 # :command.function
1913 # :command.function
1914 rccontrol_stack_rhodecode_command() {
1914 rccontrol_stack_rhodecode_command() {
1915 # src/stack_rhodecode_command.sh
1915 # src/stack_rhodecode_command.sh
1916 check_bootstrap
1916 check_bootstrap
1917
1917
1918 DEBUG=${args[--debug]}
1918 DEBUG=${args[--debug]}
1919 ENV_FILE=${args[--env-file-path]}
1919 ENV_FILE=${args[--env-file-path]}
1920
1920
1921 if [[ ! -f $RC_STACK_RHODECODE_EXT ]]; then
1921 if [[ ! -f $RC_STACK_RHODECODE_EXT ]]; then
1922 RC_STACK_RHODECODE_EXT_LCL=""
1922 RC_STACK_RHODECODE_EXT_LCL=""
1923 else
1923 else
1924 RC_STACK_RHODECODE_EXT_LCL="-f $RC_STACK_RHODECODE_EXT"
1924 RC_STACK_RHODECODE_EXT_LCL="-f $RC_STACK_RHODECODE_EXT"
1925 fi
1925 fi
1926
1926
1927 CMD_RHODECODE="\
1927 CMD_RHODECODE="\
1928 RC_ENV_FILE=$ENV_FILE docker compose \
1928 RC_ENV_FILE=$ENV_FILE docker compose \
1929 --env-file $ENV_FILE \
1929 --env-file $ENV_FILE \
1930 $ENV_EXPAND \
1930 $ENV_EXPAND \
1931 -p rc_cluster_apps \
1931 -p rc_cluster_apps \
1932 -f docker-compose-base.yaml \
1932 -f docker-compose-base.yaml \
1933 -f docker-compose-apps.yaml $RC_STACK_RHODECODE_EXT_LCL"
1933 -f docker-compose-apps.yaml $RC_STACK_RHODECODE_EXT_LCL"
1934
1934
1935 CMD_RHODECODE_SOURCE="\
1935 CMD_RHODECODE_SOURCE="\
1936 RC_ENV_FILE=$ENV_FILE docker compose \
1936 RC_ENV_FILE=$ENV_FILE docker compose \
1937 --env-file $ENV_FILE \
1937 --env-file $ENV_FILE \
1938 $ENV_EXPAND \
1938 $ENV_EXPAND \
1939 -p rc_cluster_apps \
1939 -p rc_cluster_apps \
1940 -f docker-compose-base.yaml \
1940 -f docker-compose-base.yaml \
1941 -f docker-compose-apps.yaml \
1941 -f docker-compose-apps.yaml \
1942 -f docker-compose-apps.source.yaml $RC_STACK_RHODECODE_EXT_LCL"
1942 -f docker-compose-apps.source.yaml $RC_STACK_RHODECODE_EXT_LCL"
1943
1943
1944 if [[ $DEBUG ]]; then
1944 if [[ $DEBUG ]]; then
1945 echo "---"
1945 echo "---"
1946 echo "stacks docker: $RC_STACK_RHODECODE_EXT_LCL"
1946 echo "stacks docker: $RC_STACK_RHODECODE_EXT_LCL"
1947 echo "running command: ${CMD_RHODECODE}"
1947 echo "running command: ${CMD_RHODECODE}"
1948 echo "ARGS: ${other_args[*]}"
1948 echo "ARGS: ${other_args[*]}"
1949 echo "---"
1949 echo "---"
1950 fi
1950 fi
1951 eval "${CMD_RHODECODE} ${other_args[*]}"
1951 eval "${CMD_RHODECODE} ${other_args[*]}"
1952
1952
1953 }
1953 }
1954
1954
1955 # :command.function
1955 # :command.function
1956 rccontrol_stack_all_command() {
1956 rccontrol_stack_all_command() {
1957 # src/stack_all_command.sh
1957 # src/stack_all_command.sh
1958 check_bootstrap
1958 check_bootstrap
1959
1959
1960 DEBUG=${args[--debug]}
1960 DEBUG=${args[--debug]}
1961
1961
1962 stack_lst=$VALID_SERVICES
1962 stack_lst=$VALID_SERVICES
1963
1963
1964 for stack in $stack_lst; do
1964 for stack in $stack_lst; do
1965 ./rccontrol stack $stack ${other_args[*]}
1965 ./rccontrol stack $stack ${other_args[*]}
1966 done
1966 done
1967
1967
1968 }
1968 }
1969
1969
1970 # :command.function
1970 # :command.function
1971 rccontrol_stack_status_command() {
1971 rccontrol_stack_status_command() {
1972 # src/stack_status_command.sh
1972 # src/stack_status_command.sh
1973 check_bootstrap
1973 check_bootstrap
1974 DEBUG=${args[--debug]}
1974 DEBUG=${args[--debug]}
1975 SIMPLE=${args[--simple]}
1975 SIMPLE=${args[--simple]}
1976
1976
1977 if [[ $DEBUG ]]; then
1977 if [[ $DEBUG ]]; then
1978 echo "---"
1978 echo "---"
1979 ps_cmd=$(docker ps --filter=name=rc_cluster --format="{{.ID}}")
1979 ps_cmd=$(docker ps --filter=name=rc_cluster --format="{{.ID}}")
1980
1980
1981 for service in $ps_cmd; do
1981 for service in $ps_cmd; do
1982
1982
1983 servicename=`docker inspect --format '{{ .Name }}' $service`
1983 servicename=`docker inspect --format '{{ .Name }}' $service`
1984 servicename=${servicename:1}
1984 servicename=${servicename:1}
1985 echo $servicename
1985 echo $servicename
1986 docker inspect $service --format='{{.State.Status}}: {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'
1986 docker inspect $service --format='{{.State.Status}}: {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'
1987 echo ""
1987 echo ""
1988
1988
1989 done
1989 done
1990 echo "---"
1990 echo "---"
1991 fi
1991 fi
1992
1992
1993 if [[ $SIMPLE ]]; then
1993 if [[ $SIMPLE ]]; then
1994 docker ps --filter=name=rc_cluster
1994 docker ps --filter=name=rc_cluster
1995 else
1995 else
1996 ps_cmd=$(docker ps --filter=name=rc_cluster --format="{{.ID}}")
1996 ps_cmd=$(docker ps --filter=name=rc_cluster --format="{{.ID}}")
1997
1997
1998 for service in $ps_cmd; do
1998 for service in $ps_cmd; do
1999
1999
2000 servicename=`docker inspect --format '{{ .Name }}' $service`
2000 servicename=`docker inspect --format '{{ .Name }}' $service`
2001 servicename=${servicename:1}
2001 servicename=${servicename:1}
2002 printf "CONTAINER:\\t$servicename\n"
2002 printf "CONTAINER:\\t$servicename\n"
2003 printf "LOGS:\\t\\tdocker logs --tail=100 $service\n"
2003 printf "LOGS:\\t\\tdocker logs --tail=100 $service\n"
2004 docker ps --filter=name=$servicename --format="ID:\\t\\t{{.ID}}\nIMAGE:\\t\\t{{.Image}}\nSTATUS:\\t\\t{{.Status}}\nPORTS:\\t\\t{{.Ports}}\n"
2004 docker ps --filter=name=$servicename --format="ID:\\t\\t{{.ID}}\nIMAGE:\\t\\t{{.Image}}\nSTATUS:\\t\\t{{.Status}}\nPORTS:\\t\\t{{.Ports}}\n"
2005 echo ""
2005 echo ""
2006
2006
2007 done
2007 done
2008 fi
2008 fi
2009
2009
2010 }
2010 }
2011
2011
2012 # :command.function
2012 # :command.function
2013 rccontrol_stack_upgrade_command() {
2013 rccontrol_stack_upgrade_command() {
2014 # src/stack_upgrade_command.sh
2014 # src/stack_upgrade_command.sh
2015 check_bootstrap
2015 check_bootstrap
2016
2016
2017 echo "To upgrade particular stack run this:"
2017 echo "To upgrade particular stack run this:"
2018 echo "./rccontrol stack STACK_NAME up --force-recreate --build --detach"
2018 echo "./rccontrol stack STACK_NAME up --force-recreate --build --detach"
2019 echo ""
2019 echo ""
2020 echo "To reclaim old image space run: docker image prune -f"
2020 echo "To reclaim old image space run: docker image prune -f"
2021 }
2021 }
2022
2022
2023 # :command.function
2023 # :command.function
2024 rccontrol_cli_redis_command() {
2024 rccontrol_cli_redis_command() {
2025 # src/cli_redis_command.sh
2025 # src/cli_redis_command.sh
2026 check_bootstrap
2026 check_bootstrap
2027
2027
2028 DEBUG=${args[--debug]}
2028 DEBUG=${args[--debug]}
2029
2029
2030 target_container=rc_cluster_services-redis-1
2030 target_container=rc_cluster_services-redis-1
2031 docker_id=$(docker ps --filter name=$target_container -q)
2031 docker_id=$(docker ps --filter name=$target_container -q)
2032
2032
2033 if [[ $DEBUG ]]; then
2033 if [[ $DEBUG ]]; then
2034 echo "container id: $docker_id, based on $target_container filter"
2034 echo "container id: $docker_id, based on $target_container filter"
2035 docker ps
2035 docker ps
2036 fi
2036 fi
2037
2037
2038 if [ "$docker_id" == "" ]; then
2038 if [ "$docker_id" == "" ]; then
2039 MSG="Cannot find container ID with name $target_container"
2039 MSG="Cannot find container ID with name $target_container"
2040 echo "$(red $MSG)"
2040 echo "$(red $MSG)"
2041 exit
2041 exit
2042 fi
2042 fi
2043
2043
2044 if [[ $DEBUG ]]; then
2044 if [[ $DEBUG ]]; then
2045 echo "Running |docker exec --interactive --tty $docker_id $CMD|"
2045 echo "Running |docker exec --interactive --tty $docker_id $CMD|"
2046 echo "docker exec --interactive --tty $docker_id /bin/bash -c 'redis-cli'"
2046 echo "docker exec --interactive --tty $docker_id /bin/bash -c 'redis-cli'"
2047 fi
2047 fi
2048
2048
2049 eval "docker exec --interactive --tty $docker_id /bin/bash -c 'redis-cli'"
2049 eval "docker exec --interactive --tty $docker_id /bin/bash -c 'redis-cli'"
2050
2050
2051 }
2051 }
2052
2052
2053 # :command.function
2053 # :command.function
2054 rccontrol_cli_db_command() {
2054 rccontrol_cli_db_command() {
2055 # src/cli_db_command.sh
2055 # src/cli_db_command.sh
2056 check_bootstrap
2056 check_bootstrap
2057
2057
2058 DEBUG=${args[--debug]}
2058 DEBUG=${args[--debug]}
2059
2059
2060 target_container=rc_cluster_services-database-1
2060 target_container=rc_cluster_services-database-1
2061 docker_id=$(docker ps --filter name=$target_container -q)
2061 docker_id=$(docker ps --filter name=$target_container -q)
2062
2062
2063 if [[ $DEBUG ]]; then
2063 if [[ $DEBUG ]]; then
2064 echo "container id: $docker_id, based on $target_container filter"
2064 echo "container id: $docker_id, based on $target_container filter"
2065 docker ps
2065 docker ps
2066 fi
2066 fi
2067
2067
2068 if [ "$docker_id" == "" ]; then
2068 if [ "$docker_id" == "" ]; then
2069 MSG="Cannot find container ID with name $target_container"
2069 MSG="Cannot find container ID with name $target_container"
2070 echo "$(red $MSG)"
2070 echo "$(red $MSG)"
2071 exit
2071 exit
2072 fi
2072 fi
2073
2073
2074 .env --file $RUNTIME_ENV
2074 .env --file $RUNTIME_ENV
2075
2075
2076 .env get DB_PASSWORD
2076 .env get DB_PASSWORD
2077 DB_PASSWORD=$REPLY
2077 DB_PASSWORD=$REPLY
2078
2078
2079 .env get DB_NAME
2079 .env get DB_NAME
2080 DB_NAME=$REPLY
2080 DB_NAME=$REPLY
2081
2081
2082 .env get DB_USER
2082 .env get DB_USER
2083 DB_USER=$REPLY
2083 DB_USER=$REPLY
2084
2084
2085 if [[ $DEBUG ]]; then
2085 if [[ $DEBUG ]]; then
2086 echo "Running |docker exec --env-file $RUNTIME_ENV --interactive --tty $docker_id $CMD|"
2086 echo "Running |docker exec --env-file $RUNTIME_ENV --interactive --tty $docker_id $CMD|"
2087 echo "docker exec --interactive --tty $docker_id /bin/bash -c 'PGPASSWORD=$DB_PASSWORD psql --username=$DB_USER --dbname=$DB_NAME'"
2087 echo "docker exec --interactive --tty $docker_id /bin/bash -c 'PGPASSWORD=$DB_PASSWORD psql --username=$DB_USER --dbname=$DB_NAME'"
2088 fi
2088 fi
2089
2089
2090 echo
2090 echo
2091 eval "docker exec --env-file $RUNTIME_ENV --interactive --tty $docker_id /bin/bash -c 'PGPASSWORD=$DB_PASSWORD psql --username=$DB_USER --dbname=$DB_NAME'"
2091 eval "docker exec --env-file $RUNTIME_ENV --interactive --tty $docker_id /bin/bash -c 'PGPASSWORD=$DB_PASSWORD psql --username=$DB_USER --dbname=$DB_NAME'"
2092
2092
2093 }
2093 }
2094
2094
2095 # :command.function
2095 # :command.function
2096 rccontrol_cli_db_upgrade_command() {
2096 rccontrol_cli_db_upgrade_command() {
2097 # src/cli_db_upgrade_command.sh
2097 # src/cli_db_upgrade_command.sh
2098 check_bootstrap
2098 check_bootstrap
2099
2099
2100 DEBUG=${args[--debug]}
2100 DEBUG=${args[--debug]}
2101
2101
2102 target_container=rc_cluster_apps-rhodecode-1
2102 target_container=rc_cluster_apps-rhodecode-1
2103 docker_id=$(docker ps --filter name=$target_container -q)
2103 docker_id=$(docker ps --filter name=$target_container -q)
2104
2104
2105 if [[ $DEBUG ]]; then
2105 if [[ $DEBUG ]]; then
2106 echo "container id: $docker_id, based on $target_container filter"
2106 echo "container id: $docker_id, based on $target_container filter"
2107 docker ps
2107 docker ps
2108 fi
2108 fi
2109
2109
2110 if [ "$docker_id" == "" ]; then
2110 if [ "$docker_id" == "" ]; then
2111 MSG="Cannot find container ID with name $target_container"
2111 MSG="Cannot find container ID with name $target_container"
2112 echo "$(red $MSG)"
2112 echo "$(red $MSG)"
2113 exit
2113 exit
2114 fi
2114 fi
2115
2115
2116 if [[ $DEBUG ]]; then
2116 if [[ $DEBUG ]]; then
2117 echo "./rccontrol stack rhodecode exec rhodecode /usr/local/bin/rhodecode_bin/bin/rc-upgrade-db /etc/rhodecode/conf/rhodecode.optimized.ini --force-yes"
2117 echo "./rccontrol stack rhodecode exec rhodecode /usr/local/bin/rhodecode_bin/bin/rc-upgrade-db /etc/rhodecode/conf/rhodecode.optimized.ini --force-yes"
2118 fi
2118 fi
2119
2119
2120 ./rccontrol stack rhodecode exec rhodecode /usr/local/bin/rhodecode_bin/bin/rc-upgrade-db /etc/rhodecode/conf/rhodecode.optimized.ini --force-yes
2120 ./rccontrol stack rhodecode exec rhodecode /usr/local/bin/rhodecode_bin/bin/rc-upgrade-db /etc/rhodecode/conf/rhodecode.optimized.ini --force-yes
2121 }
2121 }
2122
2122
2123 # :command.function
2123 # :command.function
2124 rccontrol_cli_storage_command() {
2124 rccontrol_cli_storage_command() {
2125 # src/cli_storage_command.sh
2125 # src/cli_storage_command.sh
2126 check_bootstrap
2126 check_bootstrap
2127
2127
2128 DEBUG=${args[--debug]}
2128 DEBUG=${args[--debug]}
2129 ENV_FILE=${args[--env-file-path]}
2129 ENV_FILE=${args[--env-file-path]}
2130
2130
2131 target_container=$RC_IMAGE_EE
2131 target_container=$RC_IMAGE_EE
2132
2132
2133 image_id=$(docker image ls $RC_IMAGE_EE -q)
2133 image_id=$(docker image ls $RC_IMAGE_EE -q)
2134
2134
2135 echo "Attaching storage from $target_container"
2135 echo "Attaching storage from $target_container"
2136
2136
2137 if [[ $DEBUG ]]; then
2137 if [[ $DEBUG ]]; then
2138 echo "image id: $image_id, based on $target_container filter"
2138 echo "image id: $image_id, based on $target_container filter"
2139 docker image ls
2139 docker image ls
2140 echo "---"
2140 echo "---"
2141 fi
2141 fi
2142
2142
2143 if [[ $DEBUG ]]; then
2143 if [[ $DEBUG ]]; then
2144 echo "rc_datavolume inspection..."
2144 echo "rc_datavolume inspection..."
2145 docker volume inspect rc_datavolume
2145 docker volume inspect rc_datavolume
2146
2146
2147 echo "rc_reposvolume inspection..."
2147 echo "rc_reposvolume inspection..."
2148 docker volume inspect rc_reposvolume
2148 docker volume inspect rc_reposvolume
2149 fi
2149 fi
2150
2150
2151 #
2151 #
2152 #if [[ $DEBUG ]]; then
2152 #if [[ $DEBUG ]]; then
2153 # echo "image id: $image_id, based on $target_container filter"
2153 # echo "image id: $image_id, based on $target_container filter"
2154 # docker image ls
2154 # docker image ls
2155 # echo "---"
2155 # echo "---"
2156 #fi
2156 #fi
2157
2157
2158 docker run --rm \
2158 docker run --rm \
2159 -it \
2159 -it \
2160 --volume $PWD/.custom/storage:/vol/backupvolume \
2160 --volume $PWD/.custom/storage:/vol/backupvolume \
2161 --volume rc_datavolume:/vol/datavolume \
2161 --volume rc_datavolume:/vol/datavolume \
2162 --volume rc_reposvolume:/vol/repovolume \
2162 --volume rc_reposvolume:/vol/repovolume \
2163 --workdir="/vol" \
2163 --workdir="/vol" \
2164 debian:jessie \
2164 debian:jessie \
2165 /bin/bash
2165 /bin/bash
2166
2166
2167 }
2167 }
2168
2168
2169 # :command.function
2169 # :command.function
2170 rccontrol_backup_db_command() {
2170 rccontrol_backup_db_command() {
2171 # src/backup_db_command.sh
2171 # src/backup_db_command.sh
2172 check_bootstrap
2172 check_bootstrap
2173
2173
2174 DEBUG=${args[--debug]}
2174 DEBUG=${args[--debug]}
2175 DESTINATION=${args[destination]}
2175 DESTINATION=${args[destination]}
2176
2176
2177 target_container=rc_cluster_services-database-1
2177 target_container=rc_cluster_services-database-1
2178
2178
2179 docker_id=$(docker ps --filter name=$target_container -q)
2179 docker_id=$(docker ps --filter name=$target_container -q)
2180 backup_name=rc_db_dump-$(date +%Y-%m-%d).sql.gz
2180 backup_name=rc_db_dump-$(date +%Y-%m-%d).sql.gz
2181
2181
2182 echo "creating backup $backup_name"
2182 echo "creating backup $backup_name"
2183
2183
2184 if [[ $DEBUG ]]; then
2184 if [[ $DEBUG ]]; then
2185 echo "container id: $docker_id, based on $target_container filter"
2185 echo "container id: $docker_id, based on $target_container filter"
2186 docker ps
2186 docker ps
2187 echo "---"
2187 echo "---"
2188 fi
2188 fi
2189
2189
2190 #image_id=$(docker inspect "$docker_id" --format {{.Image}} | cut -c 8-)
2190 #image_id=$(docker inspect "$docker_id" --format {{.Image}} | cut -c 8-)
2191 #
2191 #
2192 #if [[ $DEBUG ]]; then
2192 #if [[ $DEBUG ]]; then
2193 # echo "image id: $image_id, based on $target_container filter"
2193 # echo "image id: $image_id, based on $target_container filter"
2194 # docker image ls
2194 # docker image ls
2195 # echo "---"
2195 # echo "---"
2196 #fi
2196 #fi
2197
2197
2198 if [ "$docker_id" == "" ]; then
2198 if [ "$docker_id" == "" ]; then
2199 MSG="Cannot find container ID with name $target_container"
2199 MSG="Cannot find container ID with name $target_container"
2200 echo "$(red $MSG)"
2200 echo "$(red $MSG)"
2201 exit
2201 exit
2202 fi
2202 fi
2203
2203
2204 #if [ "image_id" == "" ]; then
2204 #if [ "image_id" == "" ]; then
2205 # MSG="Cannot find image ID with name $target_container"
2205 # MSG="Cannot find image ID with name $target_container"
2206 # echo "$(red $MSG)"
2206 # echo "$(red $MSG)"
2207 # exit
2207 # exit
2208 #fi
2208 #fi
2209 # docker exec -i your-db-container psql -U your-db-user -d your-db-name gunzip < your_dump.sql.gz |
2209 # docker exec -i your-db-container psql -U your-db-user -d your-db-name gunzip < your_dump.sql.gz |
2210
2210
2211 if [[ $DEBUG ]]; then
2211 if [[ $DEBUG ]]; then
2212 echo "docker exec -e PGPASSWORD=$DB_PASSWORD $docker_id /bin/bash -c 'mkdir -p /var/rc-data-dump && pg_dump --inserts -U $DB_USER -h 127.0.0.1 --dbname=$DB_NAME | gzip > /var/rc-data-dump/$backup_name'"
2212 echo "docker exec -e PGPASSWORD=$DB_PASSWORD $docker_id /bin/bash -c 'mkdir -p /var/rc-data-dump && pg_dump --inserts -U $DB_USER -h 127.0.0.1 --dbname=$DB_NAME | gzip > /var/rc-data-dump/$backup_name'"
2213 echo "dump placed in /var/rc-data-dump/$backup_name"
2213 echo "dump placed in /var/rc-data-dump/$backup_name"
2214 echo "run docker cp $docker_id:/var/rc-data-dump/$backup_name $PWD to copy the file into your host machine"
2214 echo "run docker cp $docker_id:/var/rc-data-dump/$backup_name $PWD to copy the file into your host machine"
2215 fi
2215 fi
2216
2216
2217 eval "docker exec -e PGPASSWORD=$DB_PASSWORD $docker_id /bin/bash -c 'pg_dump --inserts -U $DB_USER -h 127.0.0.1 --dbname=$DB_NAME | gzip > /var/rc-data-dump/$backup_name'"
2217 eval "docker exec -e PGPASSWORD=$DB_PASSWORD $docker_id /bin/bash -c 'pg_dump --inserts -U $DB_USER -h 127.0.0.1 --dbname=$DB_NAME | gzip > /var/rc-data-dump/$backup_name'"
2218 echo "$(green Backup created in /var/rc-data-dump/ mount !)"
2218 echo "$(green Backup created in /var/rc-data-dump/ mount !)"
2219
2219
2220 }
2220 }
2221
2221
2222 # :command.function
2222 # :command.function
2223 rccontrol_backup_data_command() {
2223 rccontrol_backup_data_command() {
2224 # src/backup_data_command.sh
2224 # src/backup_data_command.sh
2225 echo "# this file is located in 'src/backup_data_command.sh'"
2225 echo "# this file is located in 'src/backup_data_command.sh'"
2226 echo "# code for 'rccontrol backup-data' goes here"
2226 echo "# code for 'rccontrol backup-data' goes here"
2227 echo "# you can edit it freely and regenerate (it will not be overwritten)"
2227 echo "# you can edit it freely and regenerate (it will not be overwritten)"
2228 inspect_args
2228 inspect_args
2229
2229
2230 }
2230 }
2231
2231
2232 # :command.function
2232 # :command.function
2233 rccontrol__completions_command() {
2233 rccontrol__completions_command() {
2234 # src/_completions_command.sh
2234 # src/_completions_command.sh
2235 send_completions
2235 send_completions
2236 }
2236 }
2237
2237
2238 # :command.parse_requirements
2238 # :command.parse_requirements
2239 parse_requirements() {
2239 parse_requirements() {
2240 # :command.fixed_flags_filter
2240 # :command.fixed_flags_filter
2241 while [[ $# -gt 0 ]]; do
2241 while [[ $# -gt 0 ]]; do
2242 case "${1:-}" in
2242 case "${1:-}" in
2243 --version | -v)
2243 --version | -v)
2244 version_command
2244 version_command
2245 exit
2245 exit
2246 ;;
2246 ;;
2247
2247
2248 --help | -h)
2248 --help | -h)
2249 long_usage=yes
2249 long_usage=yes
2250 rccontrol_usage
2250 rccontrol_usage
2251 exit
2251 exit
2252 ;;
2252 ;;
2253
2253
2254 # :flag.case
2254 # :flag.case
2255 --debug)
2255 --debug)
2256
2256
2257 # :flag.case_no_arg
2257 # :flag.case_no_arg
2258 args[--debug]=1
2258 args[--debug]=1
2259 shift
2259 shift
2260 ;;
2260 ;;
2261
2261
2262 *)
2262 *)
2263 break
2263 break
2264 ;;
2264 ;;
2265
2265
2266 esac
2266 esac
2267 done
2267 done
2268
2268
2269 # :command.environment_variables_filter
2269 # :command.environment_variables_filter
2270 # :command.environment_variables_default
2270 # :command.environment_variables_default
2271 export RCC_CONFIG="${RCC_CONFIG:-.rccontrol.ini}"
2271 export RCC_CONFIG="${RCC_CONFIG:-.rccontrol.ini}"
2272 export RC_CLI_VERSION_NAME="${RC_CLI_VERSION_NAME:-4.27.0}"
2272 export RC_CLI_VERSION_NAME="${RC_CLI_VERSION_NAME:-4.27.0}"
2273 export RC_STACK_ROUTER_EXT="${RC_STACK_ROUTER_EXT:-.custom/docker-compose-router.override.yaml}"
2273 export RC_STACK_ROUTER_EXT="${RC_STACK_ROUTER_EXT:-.custom/docker-compose-router.override.yaml}"
2274 export RC_STACK_METRICS_EXT="${RC_STACK_METRICS_EXT:-.custom/docker-compose-metrics.override.yaml}"
2274 export RC_STACK_METRICS_EXT="${RC_STACK_METRICS_EXT:-.custom/docker-compose-metrics.override.yaml}"
2275 export RC_STACK_SERVICES_EXT="${RC_STACK_SERVICES_EXT:-.custom/docker-compose-services.override.yaml}"
2275 export RC_STACK_SERVICES_EXT="${RC_STACK_SERVICES_EXT:-.custom/docker-compose-services.override.yaml}"
2276 export RC_STACK_RHODECODE_EXT="${RC_STACK_RHODECODE_EXT:-.custom/docker-compose-apps.override.yaml}"
2276 export RC_STACK_RHODECODE_EXT="${RC_STACK_RHODECODE_EXT:-.custom/docker-compose-apps.override.yaml}"
2277
2277
2278 # :command.command_filter
2278 # :command.command_filter
2279 action=${1:-}
2279 action=${1:-}
2280
2280
2281 case $action in
2281 case $action in
2282 -*) ;;
2282 -*) ;;
2283
2283
2284 self-update)
2284 self-update)
2285 action="self-update"
2285 action="self-update"
2286 shift
2286 shift
2287 rccontrol_self_update_parse_requirements "$@"
2287 rccontrol_self_update_parse_requirements "$@"
2288 shift $#
2288 shift $#
2289 ;;
2289 ;;
2290
2290
2291 bootstrap | init)
2291 bootstrap | init)
2292 action="bootstrap"
2292 action="bootstrap"
2293 shift
2293 shift
2294 rccontrol_bootstrap_parse_requirements "$@"
2294 rccontrol_bootstrap_parse_requirements "$@"
2295 shift $#
2295 shift $#
2296 ;;
2296 ;;
2297
2297
2298 get-build-artifacts)
2298 get-build-artifacts)
2299 action="get-build-artifacts"
2299 action="get-build-artifacts"
2300 shift
2300 shift
2301 rccontrol_get_build_artifacts_parse_requirements "$@"
2301 rccontrol_get_build_artifacts_parse_requirements "$@"
2302 shift $#
2302 shift $#
2303 ;;
2303 ;;
2304
2304
2305 build)
2305 build)
2306 action="build"
2306 action="build"
2307 shift
2307 shift
2308 rccontrol_build_parse_requirements "$@"
2308 rccontrol_build_parse_requirements "$@"
2309 shift $#
2309 shift $#
2310 ;;
2310 ;;
2311
2311
2312 get-build-source)
2312 get-build-source)
2313 action="get-build-source"
2313 action="get-build-source"
2314 shift
2314 shift
2315 rccontrol_get_build_source_parse_requirements "$@"
2315 rccontrol_get_build_source_parse_requirements "$@"
2316 shift $#
2316 shift $#
2317 ;;
2317 ;;
2318
2318
2319 build-source)
2319 build-source)
2320 action="build-source"
2320 action="build-source"
2321 shift
2321 shift
2322 rccontrol_build_source_parse_requirements "$@"
2322 rccontrol_build_source_parse_requirements "$@"
2323 shift $#
2323 shift $#
2324 ;;
2324 ;;
2325
2325
2326 stack)
2326 stack)
2327 action="stack"
2327 action="stack"
2328 shift
2328 shift
2329 rccontrol_stack_parse_requirements "$@"
2329 rccontrol_stack_parse_requirements "$@"
2330 shift $#
2330 shift $#
2331 ;;
2331 ;;
2332
2332
2333 stack-status | status)
2333 stack-status | status)
2334 action="stack-status"
2334 action="stack-status"
2335 shift
2335 shift
2336 rccontrol_stack_status_parse_requirements "$@"
2336 rccontrol_stack_status_parse_requirements "$@"
2337 shift $#
2337 shift $#
2338 ;;
2338 ;;
2339
2339
2340 stack-upgrade)
2340 stack-upgrade)
2341 action="stack-upgrade"
2341 action="stack-upgrade"
2342 shift
2342 shift
2343 rccontrol_stack_upgrade_parse_requirements "$@"
2343 rccontrol_stack_upgrade_parse_requirements "$@"
2344 shift $#
2344 shift $#
2345 ;;
2345 ;;
2346
2346
2347 cli)
2347 cli)
2348 action="cli"
2348 action="cli"
2349 shift
2349 shift
2350 rccontrol_cli_parse_requirements "$@"
2350 rccontrol_cli_parse_requirements "$@"
2351 shift $#
2351 shift $#
2352 ;;
2352 ;;
2353
2353
2354 backup-db)
2354 backup-db)
2355 action="backup-db"
2355 action="backup-db"
2356 shift
2356 shift
2357 rccontrol_backup_db_parse_requirements "$@"
2357 rccontrol_backup_db_parse_requirements "$@"
2358 shift $#
2358 shift $#
2359 ;;
2359 ;;
2360
2360
2361 backup-data)
2361 backup-data)
2362 action="backup-data"
2362 action="backup-data"
2363 shift
2363 shift
2364 rccontrol_backup_data_parse_requirements "$@"
2364 rccontrol_backup_data_parse_requirements "$@"
2365 shift $#
2365 shift $#
2366 ;;
2366 ;;
2367
2367
2368 _completions)
2368 _completions)
2369 action="_completions"
2369 action="_completions"
2370 shift
2370 shift
2371 rccontrol__completions_parse_requirements "$@"
2371 rccontrol__completions_parse_requirements "$@"
2372 shift $#
2372 shift $#
2373 ;;
2373 ;;
2374
2374
2375 # :command.command_fallback
2375 # :command.command_fallback
2376 "")
2376 "")
2377 rccontrol_usage >&2
2377 rccontrol_usage >&2
2378 exit 1
2378 exit 1
2379 ;;
2379 ;;
2380
2380
2381 *)
2381 *)
2382 printf "invalid command: %s\n" "$action" >&2
2382 printf "invalid command: %s\n" "$action" >&2
2383 exit 1
2383 exit 1
2384 ;;
2384 ;;
2385
2385
2386 esac
2386 esac
2387
2387
2388 # :command.parse_requirements_while
2388 # :command.parse_requirements_while
2389 while [[ $# -gt 0 ]]; do
2389 while [[ $# -gt 0 ]]; do
2390 key="$1"
2390 key="$1"
2391 case "$key" in
2391 case "$key" in
2392
2392
2393 -?*)
2393 -?*)
2394 printf "invalid option: %s\n" "$key" >&2
2394 printf "invalid option: %s\n" "$key" >&2
2395 exit 1
2395 exit 1
2396 ;;
2396 ;;
2397
2397
2398 *)
2398 *)
2399 # :command.parse_requirements_case
2399 # :command.parse_requirements_case
2400 # :command.parse_requirements_case_simple
2400 # :command.parse_requirements_case_simple
2401 printf "invalid argument: %s\n" "$key" >&2
2401 printf "invalid argument: %s\n" "$key" >&2
2402 exit 1
2402 exit 1
2403
2403
2404 ;;
2404 ;;
2405
2405
2406 esac
2406 esac
2407 done
2407 done
2408
2408
2409 }
2409 }
2410
2410
2411 # :command.parse_requirements
2411 # :command.parse_requirements
2412 rccontrol_self_update_parse_requirements() {
2412 rccontrol_self_update_parse_requirements() {
2413 # :command.fixed_flags_filter
2413 # :command.fixed_flags_filter
2414 while [[ $# -gt 0 ]]; do
2414 while [[ $# -gt 0 ]]; do
2415 case "${1:-}" in
2415 case "${1:-}" in
2416 --help | -h)
2416 --help | -h)
2417 long_usage=yes
2417 long_usage=yes
2418 rccontrol_self_update_usage
2418 rccontrol_self_update_usage
2419 exit
2419 exit
2420 ;;
2420 ;;
2421
2421
2422 *)
2422 *)
2423 break
2423 break
2424 ;;
2424 ;;
2425
2425
2426 esac
2426 esac
2427 done
2427 done
2428
2428
2429 # :command.dependencies_filter
2429 # :command.dependencies_filter
2430 if ! command -v curl >/dev/null 2>&1; then
2430 if ! command -v curl >/dev/null 2>&1; then
2431 printf "missing dependency: curl\n" >&2
2431 printf "missing dependency: curl\n" >&2
2432 exit 1
2432 exit 1
2433 fi
2433 fi
2434
2434
2435 if ! command -v tar >/dev/null 2>&1; then
2435 if ! command -v tar >/dev/null 2>&1; then
2436 printf "missing dependency: tar\n" >&2
2436 printf "missing dependency: tar\n" >&2
2437 exit 1
2437 exit 1
2438 fi
2438 fi
2439
2439
2440 # :command.command_filter
2440 # :command.command_filter
2441 action="self-update"
2441 action="self-update"
2442
2442
2443 # :command.parse_requirements_while
2443 # :command.parse_requirements_while
2444 while [[ $# -gt 0 ]]; do
2444 while [[ $# -gt 0 ]]; do
2445 key="$1"
2445 key="$1"
2446 case "$key" in
2446 case "$key" in
2447 # :flag.case
2447 # :flag.case
2448 --revision)
2448 --revision)
2449
2449
2450 # :flag.case_arg
2450 # :flag.case_arg
2451 if [[ -n ${2+x} ]]; then
2451 if [[ -n ${2+x} ]]; then
2452
2452
2453 args[--revision]="$2"
2453 args[--revision]="$2"
2454 shift
2454 shift
2455 shift
2455 shift
2456 else
2456 else
2457 printf "%s\n" "--revision requires an argument: --revision REVISION" >&2
2457 printf "%s\n" "--revision requires an argument: --revision REVISION" >&2
2458 exit 1
2458 exit 1
2459 fi
2459 fi
2460 ;;
2460 ;;
2461
2461
2462 # :flag.case
2462 # :flag.case
2463 --auth-token)
2463 --auth-token)
2464
2464
2465 # :flag.case_arg
2465 # :flag.case_arg
2466 if [[ -n ${2+x} ]]; then
2466 if [[ -n ${2+x} ]]; then
2467
2467
2468 args[--auth-token]="$2"
2468 args[--auth-token]="$2"
2469 shift
2469 shift
2470 shift
2470 shift
2471 else
2471 else
2472 printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
2472 printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
2473 exit 1
2473 exit 1
2474 fi
2474 fi
2475 ;;
2475 ;;
2476
2476
2477 # :flag.case
2477 # :flag.case
2478 --server-url)
2478 --server-url)
2479
2479
2480 # :flag.case_arg
2480 # :flag.case_arg
2481 if [[ -n ${2+x} ]]; then
2481 if [[ -n ${2+x} ]]; then
2482
2482
2483 args[--server-url]="$2"
2483 args[--server-url]="$2"
2484 shift
2484 shift
2485 shift
2485 shift
2486 else
2486 else
2487 printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
2487 printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
2488 exit 1
2488 exit 1
2489 fi
2489 fi
2490 ;;
2490 ;;
2491
2491
2492 -?*)
2492 -?*)
2493 printf "invalid option: %s\n" "$key" >&2
2493 printf "invalid option: %s\n" "$key" >&2
2494 exit 1
2494 exit 1
2495 ;;
2495 ;;
2496
2496
2497 *)
2497 *)
2498 # :command.parse_requirements_case
2498 # :command.parse_requirements_case
2499 # :command.parse_requirements_case_simple
2499 # :command.parse_requirements_case_simple
2500 printf "invalid argument: %s\n" "$key" >&2
2500 printf "invalid argument: %s\n" "$key" >&2
2501 exit 1
2501 exit 1
2502
2502
2503 ;;
2503 ;;
2504
2504
2505 esac
2505 esac
2506 done
2506 done
2507
2507
2508 # :command.default_assignments
2508 # :command.default_assignments
2509 [[ -n ${args[--revision]:-} ]] || args[--revision]="master"
2509 [[ -n ${args[--revision]:-} ]] || args[--revision]="master"
2510 [[ -n ${args[--server-url]:-} ]] || args[--server-url]="https://code.rhodecode.com"
2510 [[ -n ${args[--server-url]:-} ]] || args[--server-url]="https://code.rhodecode.com"
2511
2511
2512 }
2512 }
2513
2513
2514 # :command.parse_requirements
2514 # :command.parse_requirements
2515 rccontrol_bootstrap_parse_requirements() {
2515 rccontrol_bootstrap_parse_requirements() {
2516 # :command.fixed_flags_filter
2516 # :command.fixed_flags_filter
2517 while [[ $# -gt 0 ]]; do
2517 while [[ $# -gt 0 ]]; do
2518 case "${1:-}" in
2518 case "${1:-}" in
2519 --help | -h)
2519 --help | -h)
2520 long_usage=yes
2520 long_usage=yes
2521 rccontrol_bootstrap_usage
2521 rccontrol_bootstrap_usage
2522 exit
2522 exit
2523 ;;
2523 ;;
2524
2524
2525 *)
2525 *)
2526 break
2526 break
2527 ;;
2527 ;;
2528
2528
2529 esac
2529 esac
2530 done
2530 done
2531
2531
2532 # :command.dependencies_filter
2532 # :command.dependencies_filter
2533 if ! command -v curl >/dev/null 2>&1; then
2533 if ! command -v curl >/dev/null 2>&1; then
2534 printf "missing dependency: curl\n" >&2
2534 printf "missing dependency: curl\n" >&2
2535 exit 1
2535 exit 1
2536 fi
2536 fi
2537
2537
2538 if ! command -v tar >/dev/null 2>&1; then
2538 if ! command -v tar >/dev/null 2>&1; then
2539 printf "missing dependency: tar\n" >&2
2539 printf "missing dependency: tar\n" >&2
2540 exit 1
2540 exit 1
2541 fi
2541 fi
2542
2542
2543 if ! command -v md5sum >/dev/null 2>&1; then
2543 if ! command -v md5sum >/dev/null 2>&1; then
2544 printf "missing dependency: md5sum\n" >&2
2544 printf "missing dependency: md5sum\n" >&2
2545 exit 1
2545 exit 1
2546 fi
2546 fi
2547
2547
2548 if ! command -v find >/dev/null 2>&1; then
2548 if ! command -v find >/dev/null 2>&1; then
2549 printf "missing dependency: find\n" >&2
2549 printf "missing dependency: find\n" >&2
2550 exit 1
2550 exit 1
2551 fi
2551 fi
2552
2552
2553 # :command.command_filter
2553 # :command.command_filter
2554 action="bootstrap"
2554 action="bootstrap"
2555
2555
2556 # :command.parse_requirements_while
2556 # :command.parse_requirements_while
2557 while [[ $# -gt 0 ]]; do
2557 while [[ $# -gt 0 ]]; do
2558 key="$1"
2558 key="$1"
2559 case "$key" in
2559 case "$key" in
2560 # :flag.case
2560 # :flag.case
2561 --force | -f)
2561 --force | -f)
2562
2562
2563 # :flag.case_no_arg
2563 # :flag.case_no_arg
2564 args[--force]=1
2564 args[--force]=1
2565 shift
2565 shift
2566 ;;
2566 ;;
2567
2567
2568 # :flag.case
2568 # :flag.case
2569 --auth-token)
2569 --auth-token)
2570
2570
2571 # :flag.case_arg
2571 # :flag.case_arg
2572 if [[ -n ${2+x} ]]; then
2572 if [[ -n ${2+x} ]]; then
2573
2573
2574 args[--auth-token]="$2"
2574 args[--auth-token]="$2"
2575 shift
2575 shift
2576 shift
2576 shift
2577 else
2577 else
2578 printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
2578 printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
2579 exit 1
2579 exit 1
2580 fi
2580 fi
2581 ;;
2581 ;;
2582
2582
2583 # :flag.case
2583 # :flag.case
2584 --server-url)
2584 --server-url)
2585
2585
2586 # :flag.case_arg
2586 # :flag.case_arg
2587 if [[ -n ${2+x} ]]; then
2587 if [[ -n ${2+x} ]]; then
2588
2588
2589 args[--server-url]="$2"
2589 args[--server-url]="$2"
2590 shift
2590 shift
2591 shift
2591 shift
2592 else
2592 else
2593 printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
2593 printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
2594 exit 1
2594 exit 1
2595 fi
2595 fi
2596 ;;
2596 ;;
2597
2597
2598 -?*)
2598 -?*)
2599 printf "invalid option: %s\n" "$key" >&2
2599 printf "invalid option: %s\n" "$key" >&2
2600 exit 1
2600 exit 1
2601 ;;
2601 ;;
2602
2602
2603 *)
2603 *)
2604 # :command.parse_requirements_case
2604 # :command.parse_requirements_case
2605 # :command.parse_requirements_case_simple
2605 # :command.parse_requirements_case_simple
2606 printf "invalid argument: %s\n" "$key" >&2
2606 printf "invalid argument: %s\n" "$key" >&2
2607 exit 1
2607 exit 1
2608
2608
2609 ;;
2609 ;;
2610
2610
2611 esac
2611 esac
2612 done
2612 done
2613
2613
2614 # :command.default_assignments
2614 # :command.default_assignments
2615 [[ -n ${args[--server-url]:-} ]] || args[--server-url]="https://code.rhodecode.com"
2615 [[ -n ${args[--server-url]:-} ]] || args[--server-url]="https://code.rhodecode.com"
2616
2616
2617 }
2617 }
2618
2618
2619 # :command.parse_requirements
2619 # :command.parse_requirements
2620 rccontrol_get_build_artifacts_parse_requirements() {
2620 rccontrol_get_build_artifacts_parse_requirements() {
2621 # :command.fixed_flags_filter
2621 # :command.fixed_flags_filter
2622 while [[ $# -gt 0 ]]; do
2622 while [[ $# -gt 0 ]]; do
2623 case "${1:-}" in
2623 case "${1:-}" in
2624 --help | -h)
2624 --help | -h)
2625 long_usage=yes
2625 long_usage=yes
2626 rccontrol_get_build_artifacts_usage
2626 rccontrol_get_build_artifacts_usage
2627 exit
2627 exit
2628 ;;
2628 ;;
2629
2629
2630 *)
2630 *)
2631 break
2631 break
2632 ;;
2632 ;;
2633
2633
2634 esac
2634 esac
2635 done
2635 done
2636
2636
2637 # :command.command_filter
2637 # :command.command_filter
2638 action="get-build-artifacts"
2638 action="get-build-artifacts"
2639
2639
2640 # :command.parse_requirements_while
2640 # :command.parse_requirements_while
2641 while [[ $# -gt 0 ]]; do
2641 while [[ $# -gt 0 ]]; do
2642 key="$1"
2642 key="$1"
2643 case "$key" in
2643 case "$key" in
2644 # :flag.case
2644 # :flag.case
2645 --auth)
2645 --auth)
2646
2646
2647 # :flag.case_arg
2647 # :flag.case_arg
2648 if [[ -n ${2+x} ]]; then
2648 if [[ -n ${2+x} ]]; then
2649
2649
2650 args[--auth]="$2"
2650 args[--auth]="$2"
2651 shift
2651 shift
2652 shift
2652 shift
2653 else
2653 else
2654 printf "%s\n" "--auth requires an argument: --auth AUTH" >&2
2654 printf "%s\n" "--auth requires an argument: --auth AUTH" >&2
2655 exit 1
2655 exit 1
2656 fi
2656 fi
2657 ;;
2657 ;;
2658
2658
2659 # :flag.case
2659 # :flag.case
2660 --installer-url)
2660 --installer-url)
2661
2661
2662 # :flag.case_arg
2662 # :flag.case_arg
2663 if [[ -n ${2+x} ]]; then
2663 if [[ -n ${2+x} ]]; then
2664
2664
2665 args[--installer-url]="$2"
2665 args[--installer-url]="$2"
2666 shift
2666 shift
2667 shift
2667 shift
2668 else
2668 else
2669 printf "%s\n" "--installer-url requires an argument: --installer-url INSTALLER_URL" >&2
2669 printf "%s\n" "--installer-url requires an argument: --installer-url INSTALLER_URL" >&2
2670 exit 1
2670 exit 1
2671 fi
2671 fi
2672 ;;
2672 ;;
2673
2673
2674 # :flag.case
2674 # :flag.case
2675 --manifest-url)
2675 --manifest-url)
2676
2676
2677 # :flag.case_arg
2677 # :flag.case_arg
2678 if [[ -n ${2+x} ]]; then
2678 if [[ -n ${2+x} ]]; then
2679
2679
2680 args[--manifest-url]="$2"
2680 args[--manifest-url]="$2"
2681 shift
2681 shift
2682 shift
2682 shift
2683 else
2683 else
2684 printf "%s\n" "--manifest-url requires an argument: --manifest-url MANIFEST_URL" >&2
2684 printf "%s\n" "--manifest-url requires an argument: --manifest-url MANIFEST_URL" >&2
2685 exit 1
2685 exit 1
2686 fi
2686 fi
2687 ;;
2687 ;;
2688
2688
2689 # :flag.case
2689 # :flag.case
2690 --version-name)
2690 --version-name)
2691
2691
2692 # :flag.case_arg
2692 # :flag.case_arg
2693 if [[ -n ${2+x} ]]; then
2693 if [[ -n ${2+x} ]]; then
2694
2694
2695 args[--version-name]="$2"
2695 args[--version-name]="$2"
2696 shift
2696 shift
2697 shift
2697 shift
2698 else
2698 else
2699 printf "%s\n" "--version-name requires an argument: --version-name VERSION_NAME" >&2
2699 printf "%s\n" "--version-name requires an argument: --version-name VERSION_NAME" >&2
2700 exit 1
2700 exit 1
2701 fi
2701 fi
2702 ;;
2702 ;;
2703
2703
2704 -?*)
2704 -?*)
2705 printf "invalid option: %s\n" "$key" >&2
2705 printf "invalid option: %s\n" "$key" >&2
2706 exit 1
2706 exit 1
2707 ;;
2707 ;;
2708
2708
2709 *)
2709 *)
2710 # :command.parse_requirements_case
2710 # :command.parse_requirements_case
2711 # :command.parse_requirements_case_simple
2711 # :command.parse_requirements_case_simple
2712 printf "invalid argument: %s\n" "$key" >&2
2712 printf "invalid argument: %s\n" "$key" >&2
2713 exit 1
2713 exit 1
2714
2714
2715 ;;
2715 ;;
2716
2716
2717 esac
2717 esac
2718 done
2718 done
2719
2719
2720 # :command.default_assignments
2720 # :command.default_assignments
2721 [[ -n ${args[--auth]:-} ]] || args[--auth]=""
2721 [[ -n ${args[--auth]:-} ]] || args[--auth]=""
2722 [[ -n ${args[--installer-url]:-} ]] || args[--installer-url]="https://dls.rhodecode.com/dls/N2E2ZTY1NzA3NjYxNDA2NTc1NjI3MTcyNzA2MjcxNzIyZTcwNjI3YQ==/rhodecode-control/latest-linux-ee"
2722 [[ -n ${args[--installer-url]:-} ]] || args[--installer-url]="https://dls.rhodecode.com/dls/N2E2ZTY1NzA3NjYxNDA2NTc1NjI3MTcyNzA2MjcxNzIyZTcwNjI3YQ==/rhodecode-control/latest-linux-ee"
2723 [[ -n ${args[--manifest-url]:-} ]] || args[--manifest-url]="https://dls.rhodecode.com/linux/MANIFEST"
2723 [[ -n ${args[--manifest-url]:-} ]] || args[--manifest-url]="https://dls.rhodecode.com/linux/MANIFEST"
2724 [[ -n ${args[--version-name]:-} ]] || args[--version-name]="$RC_CLI_VERSION_NAME"
2724 [[ -n ${args[--version-name]:-} ]] || args[--version-name]="$RC_CLI_VERSION_NAME"
2725
2725
2726 }
2726 }
2727
2727
2728 # :command.parse_requirements
2728 # :command.parse_requirements
2729 rccontrol_build_parse_requirements() {
2729 rccontrol_build_parse_requirements() {
2730 # :command.fixed_flags_filter
2730 # :command.fixed_flags_filter
2731 while [[ $# -gt 0 ]]; do
2731 while [[ $# -gt 0 ]]; do
2732 case "${1:-}" in
2732 case "${1:-}" in
2733 --help | -h)
2733 --help | -h)
2734 long_usage=yes
2734 long_usage=yes
2735 rccontrol_build_usage
2735 rccontrol_build_usage
2736 exit
2736 exit
2737 ;;
2737 ;;
2738
2738
2739 *)
2739 *)
2740 break
2740 break
2741 ;;
2741 ;;
2742
2742
2743 esac
2743 esac
2744 done
2744 done
2745
2745
2746 # :command.command_filter
2746 # :command.command_filter
2747 action="build"
2747 action="build"
2748
2748
2749 # :command.parse_requirements_while
2749 # :command.parse_requirements_while
2750 while [[ $# -gt 0 ]]; do
2750 while [[ $# -gt 0 ]]; do
2751 key="$1"
2751 key="$1"
2752 case "$key" in
2752 case "$key" in
2753 # :flag.case
2753 # :flag.case
2754 --version-name)
2754 --version-name)
2755
2755
2756 # :flag.case_arg
2756 # :flag.case_arg
2757 if [[ -n ${2+x} ]]; then
2757 if [[ -n ${2+x} ]]; then
2758
2758
2759 args[--version-name]="$2"
2759 args[--version-name]="$2"
2760 shift
2760 shift
2761 shift
2761 shift
2762 else
2762 else
2763 printf "%s\n" "--version-name requires an argument: --version-name VERSION_NAME" >&2
2763 printf "%s\n" "--version-name requires an argument: --version-name VERSION_NAME" >&2
2764 exit 1
2764 exit 1
2765 fi
2765 fi
2766 ;;
2766 ;;
2767
2767
2768 -?*)
2768 -?*)
2769 printf "invalid option: %s\n" "$key" >&2
2769 printf "invalid option: %s\n" "$key" >&2
2770 exit 1
2770 exit 1
2771 ;;
2771 ;;
2772
2772
2773 *)
2773 *)
2774 # :command.parse_requirements_case
2774 # :command.parse_requirements_case
2775 # :command.parse_requirements_case_simple
2775 # :command.parse_requirements_case_simple
2776 printf "invalid argument: %s\n" "$key" >&2
2776 printf "invalid argument: %s\n" "$key" >&2
2777 exit 1
2777 exit 1
2778
2778
2779 ;;
2779 ;;
2780
2780
2781 esac
2781 esac
2782 done
2782 done
2783
2783
2784 # :command.default_assignments
2784 # :command.default_assignments
2785 [[ -n ${args[--version-name]:-} ]] || args[--version-name]="$RC_CLI_VERSION_NAME"
2785 [[ -n ${args[--version-name]:-} ]] || args[--version-name]="$RC_CLI_VERSION_NAME"
2786
2786
2787 }
2787 }
2788
2788
2789 # :command.parse_requirements
2789 # :command.parse_requirements
2790 rccontrol_get_build_source_parse_requirements() {
2790 rccontrol_get_build_source_parse_requirements() {
2791 # :command.fixed_flags_filter
2791 # :command.fixed_flags_filter
2792 while [[ $# -gt 0 ]]; do
2792 while [[ $# -gt 0 ]]; do
2793 case "${1:-}" in
2793 case "${1:-}" in
2794 --help | -h)
2794 --help | -h)
2795 long_usage=yes
2795 long_usage=yes
2796 rccontrol_get_build_source_usage
2796 rccontrol_get_build_source_usage
2797 exit
2797 exit
2798 ;;
2798 ;;
2799
2799
2800 *)
2800 *)
2801 break
2801 break
2802 ;;
2802 ;;
2803
2803
2804 esac
2804 esac
2805 done
2805 done
2806
2806
2807 # :command.dependencies_filter
2807 # :command.dependencies_filter
2808 if ! command -v curl >/dev/null 2>&1; then
2808 if ! command -v curl >/dev/null 2>&1; then
2809 printf "missing dependency: curl\n" >&2
2809 printf "missing dependency: curl\n" >&2
2810 exit 1
2810 exit 1
2811 fi
2811 fi
2812
2812
2813 if ! command -v tar >/dev/null 2>&1; then
2813 if ! command -v tar >/dev/null 2>&1; then
2814 printf "missing dependency: tar\n" >&2
2814 printf "missing dependency: tar\n" >&2
2815 exit 1
2815 exit 1
2816 fi
2816 fi
2817
2817
2818 # :command.command_filter
2818 # :command.command_filter
2819 action="get-build-source"
2819 action="get-build-source"
2820
2820
2821 # :command.parse_requirements_while
2821 # :command.parse_requirements_while
2822 while [[ $# -gt 0 ]]; do
2822 while [[ $# -gt 0 ]]; do
2823 key="$1"
2823 key="$1"
2824 case "$key" in
2824 case "$key" in
2825 # :flag.case
2825 # :flag.case
2826 --revision)
2826 --revision)
2827
2827
2828 # :flag.case_arg
2828 # :flag.case_arg
2829 if [[ -n ${2+x} ]]; then
2829 if [[ -n ${2+x} ]]; then
2830
2830
2831 args[--revision]="$2"
2831 args[--revision]="$2"
2832 shift
2832 shift
2833 shift
2833 shift
2834 else
2834 else
2835 printf "%s\n" "--revision requires an argument: --revision REVISION" >&2
2835 printf "%s\n" "--revision requires an argument: --revision REVISION" >&2
2836 exit 1
2836 exit 1
2837 fi
2837 fi
2838 ;;
2838 ;;
2839
2839
2840 # :flag.case
2840 # :flag.case
2841 --auth-token)
2841 --auth-token)
2842
2842
2843 # :flag.case_arg
2843 # :flag.case_arg
2844 if [[ -n ${2+x} ]]; then
2844 if [[ -n ${2+x} ]]; then
2845
2845
2846 args[--auth-token]="$2"
2846 args[--auth-token]="$2"
2847 shift
2847 shift
2848 shift
2848 shift
2849 else
2849 else
2850 printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
2850 printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
2851 exit 1
2851 exit 1
2852 fi
2852 fi
2853 ;;
2853 ;;
2854
2854
2855 # :flag.case
2855 # :flag.case
2856 --server-url)
2856 --server-url)
2857
2857
2858 # :flag.case_arg
2858 # :flag.case_arg
2859 if [[ -n ${2+x} ]]; then
2859 if [[ -n ${2+x} ]]; then
2860
2860
2861 args[--server-url]="$2"
2861 args[--server-url]="$2"
2862 shift
2862 shift
2863 shift
2863 shift
2864 else
2864 else
2865 printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
2865 printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
2866 exit 1
2866 exit 1
2867 fi
2867 fi
2868 ;;
2868 ;;
2869
2869
2870 -?*)
2870 -?*)
2871 printf "invalid option: %s\n" "$key" >&2
2871 printf "invalid option: %s\n" "$key" >&2
2872 exit 1
2872 exit 1
2873 ;;
2873 ;;
2874
2874
2875 *)
2875 *)
2876 # :command.parse_requirements_case
2876 # :command.parse_requirements_case
2877 # :command.parse_requirements_case_simple
2877 # :command.parse_requirements_case_simple
2878 printf "invalid argument: %s\n" "$key" >&2
2878 printf "invalid argument: %s\n" "$key" >&2
2879 exit 1
2879 exit 1
2880
2880
2881 ;;
2881 ;;
2882
2882
2883 esac
2883 esac
2884 done
2884 done
2885
2885
2886 # :command.default_assignments
2886 # :command.default_assignments
2887 [[ -n ${args[--revision]:-} ]] || args[--revision]="default"
2887 [[ -n ${args[--revision]:-} ]] || args[--revision]="default"
2888 [[ -n ${args[--server-url]:-} ]] || args[--server-url]="https://code.rhodecode.com"
2888 [[ -n ${args[--server-url]:-} ]] || args[--server-url]="https://code.rhodecode.com"
2889
2889
2890 }
2890 }
2891
2891
2892 # :command.parse_requirements
2892 # :command.parse_requirements
2893 rccontrol_build_source_parse_requirements() {
2893 rccontrol_build_source_parse_requirements() {
2894 # :command.fixed_flags_filter
2894 # :command.fixed_flags_filter
2895 while [[ $# -gt 0 ]]; do
2895 while [[ $# -gt 0 ]]; do
2896 case "${1:-}" in
2896 case "${1:-}" in
2897 --help | -h)
2897 --help | -h)
2898 long_usage=yes
2898 long_usage=yes
2899 rccontrol_build_source_usage
2899 rccontrol_build_source_usage
2900 exit
2900 exit
2901 ;;
2901 ;;
2902
2902
2903 *)
2903 *)
2904 break
2904 break
2905 ;;
2905 ;;
2906
2906
2907 esac
2907 esac
2908 done
2908 done
2909
2909
2910 # :command.command_filter
2910 # :command.command_filter
2911 action="build-source"
2911 action="build-source"
2912
2912
2913 # :command.parse_requirements_while
2913 # :command.parse_requirements_while
2914 while [[ $# -gt 0 ]]; do
2914 while [[ $# -gt 0 ]]; do
2915 key="$1"
2915 key="$1"
2916 case "$key" in
2916 case "$key" in
2917 # :flag.case
2917 # :flag.case
2918 --version-name)
2918 --version-name)
2919
2919
2920 # :flag.case_arg
2920 # :flag.case_arg
2921 if [[ -n ${2+x} ]]; then
2921 if [[ -n ${2+x} ]]; then
2922
2922
2923 args[--version-name]="$2"
2923 args[--version-name]="$2"
2924 shift
2924 shift
2925 shift
2925 shift
2926 else
2926 else
2927 printf "%s\n" "--version-name requires an argument: --version-name VERSION_NAME" >&2
2927 printf "%s\n" "--version-name requires an argument: --version-name VERSION_NAME" >&2
2928 exit 1
2928 exit 1
2929 fi
2929 fi
2930 ;;
2930 ;;
2931
2931
2932 -?*)
2932 -?*)
2933 printf "invalid option: %s\n" "$key" >&2
2933 printf "invalid option: %s\n" "$key" >&2
2934 exit 1
2934 exit 1
2935 ;;
2935 ;;
2936
2936
2937 *)
2937 *)
2938 # :command.parse_requirements_case
2938 # :command.parse_requirements_case
2939 # :command.parse_requirements_case_simple
2939 # :command.parse_requirements_case_simple
2940 printf "invalid argument: %s\n" "$key" >&2
2940 printf "invalid argument: %s\n" "$key" >&2
2941 exit 1
2941 exit 1
2942
2942
2943 ;;
2943 ;;
2944
2944
2945 esac
2945 esac
2946 done
2946 done
2947
2947
2948 # :command.default_assignments
2948 # :command.default_assignments
2949 [[ -n ${args[--version-name]:-} ]] || args[--version-name]="$RC_CLI_VERSION_NAME"
2949 [[ -n ${args[--version-name]:-} ]] || args[--version-name]="$RC_CLI_VERSION_NAME"
2950
2950
2951 }
2951 }
2952
2952
2953 # :command.parse_requirements
2953 # :command.parse_requirements
2954 rccontrol_stack_parse_requirements() {
2954 rccontrol_stack_parse_requirements() {
2955 # :command.fixed_flags_filter
2955 # :command.fixed_flags_filter
2956 while [[ $# -gt 0 ]]; do
2956 while [[ $# -gt 0 ]]; do
2957 case "${1:-}" in
2957 case "${1:-}" in
2958 --help | -h)
2958 --help | -h)
2959 long_usage=yes
2959 long_usage=yes
2960 rccontrol_stack_usage
2960 rccontrol_stack_usage
2961 exit
2961 exit
2962 ;;
2962 ;;
2963
2963
2964 # :flag.case
2964 # :flag.case
2965 --env-file-path)
2965 --env-file-path)
2966
2966
2967 # :flag.case_arg
2967 # :flag.case_arg
2968 if [[ -n ${2+x} ]]; then
2968 if [[ -n ${2+x} ]]; then
2969
2969
2970 args[--env-file-path]="$2"
2970 args[--env-file-path]="$2"
2971 shift
2971 shift
2972 shift
2972 shift
2973 else
2973 else
2974 printf "%s\n" "--env-file-path requires an argument: --env-file-path ENV_FILE_PATH" >&2
2974 printf "%s\n" "--env-file-path requires an argument: --env-file-path ENV_FILE_PATH" >&2
2975 exit 1
2975 exit 1
2976 fi
2976 fi
2977 ;;
2977 ;;
2978
2978
2979 *)
2979 *)
2980 break
2980 break
2981 ;;
2981 ;;
2982
2982
2983 esac
2983 esac
2984 done
2984 done
2985
2985
2986 # :command.command_filter
2986 # :command.command_filter
2987 action=${1:-}
2987 action=${1:-}
2988
2988
2989 case $action in
2989 case $action in
2990 -*) ;;
2990 -*) ;;
2991
2991
2992 router)
2992 router)
2993 action="router"
2993 action="router"
2994 shift
2994 shift
2995 rccontrol_stack_router_parse_requirements "$@"
2995 rccontrol_stack_router_parse_requirements "$@"
2996 shift $#
2996 shift $#
2997 ;;
2997 ;;
2998
2998
2999 metrics)
2999 metrics)
3000 action="metrics"
3000 action="metrics"
3001 shift
3001 shift
3002 rccontrol_stack_metrics_parse_requirements "$@"
3002 rccontrol_stack_metrics_parse_requirements "$@"
3003 shift $#
3003 shift $#
3004 ;;
3004 ;;
3005
3005
3006 services)
3006 services)
3007 action="services"
3007 action="services"
3008 shift
3008 shift
3009 rccontrol_stack_services_parse_requirements "$@"
3009 rccontrol_stack_services_parse_requirements "$@"
3010 shift $#
3010 shift $#
3011 ;;
3011 ;;
3012
3012
3013 rhodecode)
3013 rhodecode)
3014 action="rhodecode"
3014 action="rhodecode"
3015 shift
3015 shift
3016 rccontrol_stack_rhodecode_parse_requirements "$@"
3016 rccontrol_stack_rhodecode_parse_requirements "$@"
3017 shift $#
3017 shift $#
3018 ;;
3018 ;;
3019
3019
3020 all)
3020 all)
3021 action="all"
3021 action="all"
3022 shift
3022 shift
3023 rccontrol_stack_all_parse_requirements "$@"
3023 rccontrol_stack_all_parse_requirements "$@"
3024 shift $#
3024 shift $#
3025 ;;
3025 ;;
3026
3026
3027 # :command.command_fallback
3027 # :command.command_fallback
3028 "")
3028 "")
3029 rccontrol_stack_usage >&2
3029 rccontrol_stack_usage >&2
3030 exit 1
3030 exit 1
3031 ;;
3031 ;;
3032
3032
3033 *)
3033 *)
3034 printf "invalid command: %s\n" "$action" >&2
3034 printf "invalid command: %s\n" "$action" >&2
3035 exit 1
3035 exit 1
3036 ;;
3036 ;;
3037
3037
3038 esac
3038 esac
3039
3039
3040 # :command.parse_requirements_while
3040 # :command.parse_requirements_while
3041 while [[ $# -gt 0 ]]; do
3041 while [[ $# -gt 0 ]]; do
3042 key="$1"
3042 key="$1"
3043 case "$key" in
3043 case "$key" in
3044
3044
3045 -?*)
3045 -?*)
3046 printf "invalid option: %s\n" "$key" >&2
3046 printf "invalid option: %s\n" "$key" >&2
3047 exit 1
3047 exit 1
3048 ;;
3048 ;;
3049
3049
3050 *)
3050 *)
3051 # :command.parse_requirements_case
3051 # :command.parse_requirements_case
3052 # :command.parse_requirements_case_simple
3052 # :command.parse_requirements_case_simple
3053 printf "invalid argument: %s\n" "$key" >&2
3053 printf "invalid argument: %s\n" "$key" >&2
3054 exit 1
3054 exit 1
3055
3055
3056 ;;
3056 ;;
3057
3057
3058 esac
3058 esac
3059 done
3059 done
3060
3060
3061 # :command.default_assignments
3061 # :command.default_assignments
3062 [[ -n ${args[--env-file-path]:-} ]] || args[--env-file-path]="$PWD/.custom/.runtime.env"
3062 [[ -n ${args[--env-file-path]:-} ]] || args[--env-file-path]="$PWD/.custom/.runtime.env"
3063
3063
3064 }
3064 }
3065
3065
3066 # :command.parse_requirements
3066 # :command.parse_requirements
3067 rccontrol_stack_router_parse_requirements() {
3067 rccontrol_stack_router_parse_requirements() {
3068 # :command.fixed_flags_filter
3068 # :command.fixed_flags_filter
3069 while [[ $# -gt 0 ]]; do
3069 while [[ $# -gt 0 ]]; do
3070 case "${1:-}" in
3070 case "${1:-}" in
3071 --help | -h)
3071 --help | -h)
3072 long_usage=yes
3072 long_usage=yes
3073 rccontrol_stack_router_usage
3073 rccontrol_stack_router_usage
3074 exit
3074 exit
3075 ;;
3075 ;;
3076
3076
3077 *)
3077 *)
3078 break
3078 break
3079 ;;
3079 ;;
3080
3080
3081 esac
3081 esac
3082 done
3082 done
3083
3083
3084 # :command.command_filter
3084 # :command.command_filter
3085 action="stack router"
3085 action="stack router"
3086
3086
3087 # :command.parse_requirements_while
3087 # :command.parse_requirements_while
3088 while [[ $# -gt 0 ]]; do
3088 while [[ $# -gt 0 ]]; do
3089 key="$1"
3089 key="$1"
3090 case "$key" in
3090 case "$key" in
3091
3091
3092 -?*)
3092 -?*)
3093 other_args+=("$1")
3093 other_args+=("$1")
3094 shift
3094 shift
3095 ;;
3095 ;;
3096
3096
3097 *)
3097 *)
3098 # :command.parse_requirements_case
3098 # :command.parse_requirements_case
3099 # :command.parse_requirements_case_catch_all
3099 # :command.parse_requirements_case_catch_all
3100 other_args+=("$1")
3100 other_args+=("$1")
3101 shift
3101 shift
3102
3102
3103 ;;
3103 ;;
3104
3104
3105 esac
3105 esac
3106 done
3106 done
3107
3107
3108 }
3108 }
3109
3109
3110 # :command.parse_requirements
3110 # :command.parse_requirements
3111 rccontrol_stack_metrics_parse_requirements() {
3111 rccontrol_stack_metrics_parse_requirements() {
3112 # :command.fixed_flags_filter
3112 # :command.fixed_flags_filter
3113 while [[ $# -gt 0 ]]; do
3113 while [[ $# -gt 0 ]]; do
3114 case "${1:-}" in
3114 case "${1:-}" in
3115 --help | -h)
3115 --help | -h)
3116 long_usage=yes
3116 long_usage=yes
3117 rccontrol_stack_metrics_usage
3117 rccontrol_stack_metrics_usage
3118 exit
3118 exit
3119 ;;
3119 ;;
3120
3120
3121 *)
3121 *)
3122 break
3122 break
3123 ;;
3123 ;;
3124
3124
3125 esac
3125 esac
3126 done
3126 done
3127
3127
3128 # :command.command_filter
3128 # :command.command_filter
3129 action="stack metrics"
3129 action="stack metrics"
3130
3130
3131 # :command.parse_requirements_while
3131 # :command.parse_requirements_while
3132 while [[ $# -gt 0 ]]; do
3132 while [[ $# -gt 0 ]]; do
3133 key="$1"
3133 key="$1"
3134 case "$key" in
3134 case "$key" in
3135
3135
3136 -?*)
3136 -?*)
3137 other_args+=("$1")
3137 other_args+=("$1")
3138 shift
3138 shift
3139 ;;
3139 ;;
3140
3140
3141 *)
3141 *)
3142 # :command.parse_requirements_case
3142 # :command.parse_requirements_case
3143 # :command.parse_requirements_case_catch_all
3143 # :command.parse_requirements_case_catch_all
3144 other_args+=("$1")
3144 other_args+=("$1")
3145 shift
3145 shift
3146
3146
3147 ;;
3147 ;;
3148
3148
3149 esac
3149 esac
3150 done
3150 done
3151
3151
3152 }
3152 }
3153
3153
3154 # :command.parse_requirements
3154 # :command.parse_requirements
3155 rccontrol_stack_services_parse_requirements() {
3155 rccontrol_stack_services_parse_requirements() {
3156 # :command.fixed_flags_filter
3156 # :command.fixed_flags_filter
3157 while [[ $# -gt 0 ]]; do
3157 while [[ $# -gt 0 ]]; do
3158 case "${1:-}" in
3158 case "${1:-}" in
3159 --help | -h)
3159 --help | -h)
3160 long_usage=yes
3160 long_usage=yes
3161 rccontrol_stack_services_usage
3161 rccontrol_stack_services_usage
3162 exit
3162 exit
3163 ;;
3163 ;;
3164
3164
3165 *)
3165 *)
3166 break
3166 break
3167 ;;
3167 ;;
3168
3168
3169 esac
3169 esac
3170 done
3170 done
3171
3171
3172 # :command.command_filter
3172 # :command.command_filter
3173 action="stack services"
3173 action="stack services"
3174
3174
3175 # :command.parse_requirements_while
3175 # :command.parse_requirements_while
3176 while [[ $# -gt 0 ]]; do
3176 while [[ $# -gt 0 ]]; do
3177 key="$1"
3177 key="$1"
3178 case "$key" in
3178 case "$key" in
3179
3179
3180 -?*)
3180 -?*)
3181 other_args+=("$1")
3181 other_args+=("$1")
3182 shift
3182 shift
3183 ;;
3183 ;;
3184
3184
3185 *)
3185 *)
3186 # :command.parse_requirements_case
3186 # :command.parse_requirements_case
3187 # :command.parse_requirements_case_catch_all
3187 # :command.parse_requirements_case_catch_all
3188 other_args+=("$1")
3188 other_args+=("$1")
3189 shift
3189 shift
3190
3190
3191 ;;
3191 ;;
3192
3192
3193 esac
3193 esac
3194 done
3194 done
3195
3195
3196 }
3196 }
3197
3197
3198 # :command.parse_requirements
3198 # :command.parse_requirements
3199 rccontrol_stack_rhodecode_parse_requirements() {
3199 rccontrol_stack_rhodecode_parse_requirements() {
3200 # :command.fixed_flags_filter
3200 # :command.fixed_flags_filter
3201 while [[ $# -gt 0 ]]; do
3201 while [[ $# -gt 0 ]]; do
3202 case "${1:-}" in
3202 case "${1:-}" in
3203 --help | -h)
3203 --help | -h)
3204 long_usage=yes
3204 long_usage=yes
3205 rccontrol_stack_rhodecode_usage
3205 rccontrol_stack_rhodecode_usage
3206 exit
3206 exit
3207 ;;
3207 ;;
3208
3208
3209 *)
3209 *)
3210 break
3210 break
3211 ;;
3211 ;;
3212
3212
3213 esac
3213 esac
3214 done
3214 done
3215
3215
3216 # :command.command_filter
3216 # :command.command_filter
3217 action="stack rhodecode"
3217 action="stack rhodecode"
3218
3218
3219 # :command.parse_requirements_while
3219 # :command.parse_requirements_while
3220 while [[ $# -gt 0 ]]; do
3220 while [[ $# -gt 0 ]]; do
3221 key="$1"
3221 key="$1"
3222 case "$key" in
3222 case "$key" in
3223
3223
3224 -?*)
3224 -?*)
3225 other_args+=("$1")
3225 other_args+=("$1")
3226 shift
3226 shift
3227 ;;
3227 ;;
3228
3228
3229 *)
3229 *)
3230 # :command.parse_requirements_case
3230 # :command.parse_requirements_case
3231 # :command.parse_requirements_case_catch_all
3231 # :command.parse_requirements_case_catch_all
3232 other_args+=("$1")
3232 other_args+=("$1")
3233 shift
3233 shift
3234
3234
3235 ;;
3235 ;;
3236
3236
3237 esac
3237 esac
3238 done
3238 done
3239
3239
3240 }
3240 }
3241
3241
3242 # :command.parse_requirements
3242 # :command.parse_requirements
3243 rccontrol_stack_all_parse_requirements() {
3243 rccontrol_stack_all_parse_requirements() {
3244 # :command.fixed_flags_filter
3244 # :command.fixed_flags_filter
3245 while [[ $# -gt 0 ]]; do
3245 while [[ $# -gt 0 ]]; do
3246 case "${1:-}" in
3246 case "${1:-}" in
3247 --help | -h)
3247 --help | -h)
3248 long_usage=yes
3248 long_usage=yes
3249 rccontrol_stack_all_usage
3249 rccontrol_stack_all_usage
3250 exit
3250 exit
3251 ;;
3251 ;;
3252
3252
3253 *)
3253 *)
3254 break
3254 break
3255 ;;
3255 ;;
3256
3256
3257 esac
3257 esac
3258 done
3258 done
3259
3259
3260 # :command.command_filter
3260 # :command.command_filter
3261 action="stack all"
3261 action="stack all"
3262
3262
3263 # :command.parse_requirements_while
3263 # :command.parse_requirements_while
3264 while [[ $# -gt 0 ]]; do
3264 while [[ $# -gt 0 ]]; do
3265 key="$1"
3265 key="$1"
3266 case "$key" in
3266 case "$key" in
3267
3267
3268 -?*)
3268 -?*)
3269 other_args+=("$1")
3269 other_args+=("$1")
3270 shift
3270 shift
3271 ;;
3271 ;;
3272
3272
3273 *)
3273 *)
3274 # :command.parse_requirements_case
3274 # :command.parse_requirements_case
3275 # :command.parse_requirements_case_catch_all
3275 # :command.parse_requirements_case_catch_all
3276 other_args+=("$1")
3276 other_args+=("$1")
3277 shift
3277 shift
3278
3278
3279 ;;
3279 ;;
3280
3280
3281 esac
3281 esac
3282 done
3282 done
3283
3283
3284 }
3284 }
3285
3285
3286 # :command.parse_requirements
3286 # :command.parse_requirements
3287 rccontrol_stack_status_parse_requirements() {
3287 rccontrol_stack_status_parse_requirements() {
3288 # :command.fixed_flags_filter
3288 # :command.fixed_flags_filter
3289 while [[ $# -gt 0 ]]; do
3289 while [[ $# -gt 0 ]]; do
3290 case "${1:-}" in
3290 case "${1:-}" in
3291 --help | -h)
3291 --help | -h)
3292 long_usage=yes
3292 long_usage=yes
3293 rccontrol_stack_status_usage
3293 rccontrol_stack_status_usage
3294 exit
3294 exit
3295 ;;
3295 ;;
3296
3296
3297 *)
3297 *)
3298 break
3298 break
3299 ;;
3299 ;;
3300
3300
3301 esac
3301 esac
3302 done
3302 done
3303
3303
3304 # :command.command_filter
3304 # :command.command_filter
3305 action="stack-status"
3305 action="stack-status"
3306
3306
3307 # :command.parse_requirements_while
3307 # :command.parse_requirements_while
3308 while [[ $# -gt 0 ]]; do
3308 while [[ $# -gt 0 ]]; do
3309 key="$1"
3309 key="$1"
3310 case "$key" in
3310 case "$key" in
3311 # :flag.case
3311 # :flag.case
3312 --simple | -s)
3312 --simple | -s)
3313
3313
3314 # :flag.case_no_arg
3314 # :flag.case_no_arg
3315 args[--simple]=1
3315 args[--simple]=1
3316 shift
3316 shift
3317 ;;
3317 ;;
3318
3318
3319 -?*)
3319 -?*)
3320 printf "invalid option: %s\n" "$key" >&2
3320 printf "invalid option: %s\n" "$key" >&2
3321 exit 1
3321 exit 1
3322 ;;
3322 ;;
3323
3323
3324 *)
3324 *)
3325 # :command.parse_requirements_case
3325 # :command.parse_requirements_case
3326 # :command.parse_requirements_case_simple
3326 # :command.parse_requirements_case_simple
3327 printf "invalid argument: %s\n" "$key" >&2
3327 printf "invalid argument: %s\n" "$key" >&2
3328 exit 1
3328 exit 1
3329
3329
3330 ;;
3330 ;;
3331
3331
3332 esac
3332 esac
3333 done
3333 done
3334
3334
3335 }
3335 }
3336
3336
3337 # :command.parse_requirements
3337 # :command.parse_requirements
3338 rccontrol_stack_upgrade_parse_requirements() {
3338 rccontrol_stack_upgrade_parse_requirements() {
3339 # :command.fixed_flags_filter
3339 # :command.fixed_flags_filter
3340 while [[ $# -gt 0 ]]; do
3340 while [[ $# -gt 0 ]]; do
3341 case "${1:-}" in
3341 case "${1:-}" in
3342 --help | -h)
3342 --help | -h)
3343 long_usage=yes
3343 long_usage=yes
3344 rccontrol_stack_upgrade_usage
3344 rccontrol_stack_upgrade_usage
3345 exit
3345 exit
3346 ;;
3346 ;;
3347
3347
3348 *)
3348 *)
3349 break
3349 break
3350 ;;
3350 ;;
3351
3351
3352 esac
3352 esac
3353 done
3353 done
3354
3354
3355 # :command.command_filter
3355 # :command.command_filter
3356 action="stack-upgrade"
3356 action="stack-upgrade"
3357
3357
3358 # :command.parse_requirements_while
3358 # :command.parse_requirements_while
3359 while [[ $# -gt 0 ]]; do
3359 while [[ $# -gt 0 ]]; do
3360 key="$1"
3360 key="$1"
3361 case "$key" in
3361 case "$key" in
3362
3362
3363 -?*)
3363 -?*)
3364 printf "invalid option: %s\n" "$key" >&2
3364 printf "invalid option: %s\n" "$key" >&2
3365 exit 1
3365 exit 1
3366 ;;
3366 ;;
3367
3367
3368 *)
3368 *)
3369 # :command.parse_requirements_case
3369 # :command.parse_requirements_case
3370 # :command.parse_requirements_case_simple
3370 # :command.parse_requirements_case_simple
3371 printf "invalid argument: %s\n" "$key" >&2
3371 printf "invalid argument: %s\n" "$key" >&2
3372 exit 1
3372 exit 1
3373
3373
3374 ;;
3374 ;;
3375
3375
3376 esac
3376 esac
3377 done
3377 done
3378
3378
3379 }
3379 }
3380
3380
3381 # :command.parse_requirements
3381 # :command.parse_requirements
3382 rccontrol_cli_parse_requirements() {
3382 rccontrol_cli_parse_requirements() {
3383 # :command.fixed_flags_filter
3383 # :command.fixed_flags_filter
3384 while [[ $# -gt 0 ]]; do
3384 while [[ $# -gt 0 ]]; do
3385 case "${1:-}" in
3385 case "${1:-}" in
3386 --help | -h)
3386 --help | -h)
3387 long_usage=yes
3387 long_usage=yes
3388 rccontrol_cli_usage
3388 rccontrol_cli_usage
3389 exit
3389 exit
3390 ;;
3390 ;;
3391
3391
3392 *)
3392 *)
3393 break
3393 break
3394 ;;
3394 ;;
3395
3395
3396 esac
3396 esac
3397 done
3397 done
3398
3398
3399 # :command.command_filter
3399 # :command.command_filter
3400 action=${1:-}
3400 action=${1:-}
3401
3401
3402 case $action in
3402 case $action in
3403 -*) ;;
3403 -*) ;;
3404
3404
3405 redis)
3405 redis)
3406 action="redis"
3406 action="redis"
3407 shift
3407 shift
3408 rccontrol_cli_redis_parse_requirements "$@"
3408 rccontrol_cli_redis_parse_requirements "$@"
3409 shift $#
3409 shift $#
3410 ;;
3410 ;;
3411
3411
3412 db)
3412 db)
3413 action="db"
3413 action="db"
3414 shift
3414 shift
3415 rccontrol_cli_db_parse_requirements "$@"
3415 rccontrol_cli_db_parse_requirements "$@"
3416 shift $#
3416 shift $#
3417 ;;
3417 ;;
3418
3418
3419 db-upgrade)
3419 db-upgrade)
3420 action="db-upgrade"
3420 action="db-upgrade"
3421 shift
3421 shift
3422 rccontrol_cli_db_upgrade_parse_requirements "$@"
3422 rccontrol_cli_db_upgrade_parse_requirements "$@"
3423 shift $#
3423 shift $#
3424 ;;
3424 ;;
3425
3425
3426 storage)
3426 storage)
3427 action="storage"
3427 action="storage"
3428 shift
3428 shift
3429 rccontrol_cli_storage_parse_requirements "$@"
3429 rccontrol_cli_storage_parse_requirements "$@"
3430 shift $#
3430 shift $#
3431 ;;
3431 ;;
3432
3432
3433 # :command.command_fallback
3433 # :command.command_fallback
3434 "")
3434 "")
3435 rccontrol_cli_usage >&2
3435 rccontrol_cli_usage >&2
3436 exit 1
3436 exit 1
3437 ;;
3437 ;;
3438
3438
3439 *)
3439 *)
3440 printf "invalid command: %s\n" "$action" >&2
3440 printf "invalid command: %s\n" "$action" >&2
3441 exit 1
3441 exit 1
3442 ;;
3442 ;;
3443
3443
3444 esac
3444 esac
3445
3445
3446 # :command.parse_requirements_while
3446 # :command.parse_requirements_while
3447 while [[ $# -gt 0 ]]; do
3447 while [[ $# -gt 0 ]]; do
3448 key="$1"
3448 key="$1"
3449 case "$key" in
3449 case "$key" in
3450
3450
3451 -?*)
3451 -?*)
3452 printf "invalid option: %s\n" "$key" >&2
3452 printf "invalid option: %s\n" "$key" >&2
3453 exit 1
3453 exit 1
3454 ;;
3454 ;;
3455
3455
3456 *)
3456 *)
3457 # :command.parse_requirements_case
3457 # :command.parse_requirements_case
3458 # :command.parse_requirements_case_simple
3458 # :command.parse_requirements_case_simple
3459 printf "invalid argument: %s\n" "$key" >&2
3459 printf "invalid argument: %s\n" "$key" >&2
3460 exit 1
3460 exit 1
3461
3461
3462 ;;
3462 ;;
3463
3463
3464 esac
3464 esac
3465 done
3465 done
3466
3466
3467 }
3467 }
3468
3468
3469 # :command.parse_requirements
3469 # :command.parse_requirements
3470 rccontrol_cli_redis_parse_requirements() {
3470 rccontrol_cli_redis_parse_requirements() {
3471 # :command.fixed_flags_filter
3471 # :command.fixed_flags_filter
3472 while [[ $# -gt 0 ]]; do
3472 while [[ $# -gt 0 ]]; do
3473 case "${1:-}" in
3473 case "${1:-}" in
3474 --help | -h)
3474 --help | -h)
3475 long_usage=yes
3475 long_usage=yes
3476 rccontrol_cli_redis_usage
3476 rccontrol_cli_redis_usage
3477 exit
3477 exit
3478 ;;
3478 ;;
3479
3479
3480 *)
3480 *)
3481 break
3481 break
3482 ;;
3482 ;;
3483
3483
3484 esac
3484 esac
3485 done
3485 done
3486
3486
3487 # :command.command_filter
3487 # :command.command_filter
3488 action="cli redis"
3488 action="cli redis"
3489
3489
3490 # :command.parse_requirements_while
3490 # :command.parse_requirements_while
3491 while [[ $# -gt 0 ]]; do
3491 while [[ $# -gt 0 ]]; do
3492 key="$1"
3492 key="$1"
3493 case "$key" in
3493 case "$key" in
3494
3494
3495 -?*)
3495 -?*)
3496 printf "invalid option: %s\n" "$key" >&2
3496 printf "invalid option: %s\n" "$key" >&2
3497 exit 1
3497 exit 1
3498 ;;
3498 ;;
3499
3499
3500 *)
3500 *)
3501 # :command.parse_requirements_case
3501 # :command.parse_requirements_case
3502 # :command.parse_requirements_case_simple
3502 # :command.parse_requirements_case_simple
3503 printf "invalid argument: %s\n" "$key" >&2
3503 printf "invalid argument: %s\n" "$key" >&2
3504 exit 1
3504 exit 1
3505
3505
3506 ;;
3506 ;;
3507
3507
3508 esac
3508 esac
3509 done
3509 done
3510
3510
3511 }
3511 }
3512
3512
3513 # :command.parse_requirements
3513 # :command.parse_requirements
3514 rccontrol_cli_db_parse_requirements() {
3514 rccontrol_cli_db_parse_requirements() {
3515 # :command.fixed_flags_filter
3515 # :command.fixed_flags_filter
3516 while [[ $# -gt 0 ]]; do
3516 while [[ $# -gt 0 ]]; do
3517 case "${1:-}" in
3517 case "${1:-}" in
3518 --help | -h)
3518 --help | -h)
3519 long_usage=yes
3519 long_usage=yes
3520 rccontrol_cli_db_usage
3520 rccontrol_cli_db_usage
3521 exit
3521 exit
3522 ;;
3522 ;;
3523
3523
3524 *)
3524 *)
3525 break
3525 break
3526 ;;
3526 ;;
3527
3527
3528 esac
3528 esac
3529 done
3529 done
3530
3530
3531 # :command.command_filter
3531 # :command.command_filter
3532 action="cli db"
3532 action="cli db"
3533
3533
3534 # :command.parse_requirements_while
3534 # :command.parse_requirements_while
3535 while [[ $# -gt 0 ]]; do
3535 while [[ $# -gt 0 ]]; do
3536 key="$1"
3536 key="$1"
3537 case "$key" in
3537 case "$key" in
3538
3538
3539 -?*)
3539 -?*)
3540 printf "invalid option: %s\n" "$key" >&2
3540 printf "invalid option: %s\n" "$key" >&2
3541 exit 1
3541 exit 1
3542 ;;
3542 ;;
3543
3543
3544 *)
3544 *)
3545 # :command.parse_requirements_case
3545 # :command.parse_requirements_case
3546 # :command.parse_requirements_case_simple
3546 # :command.parse_requirements_case_simple
3547 printf "invalid argument: %s\n" "$key" >&2
3547 printf "invalid argument: %s\n" "$key" >&2
3548 exit 1
3548 exit 1
3549
3549
3550 ;;
3550 ;;
3551
3551
3552 esac
3552 esac
3553 done
3553 done
3554
3554
3555 }
3555 }
3556
3556
3557 # :command.parse_requirements
3557 # :command.parse_requirements
3558 rccontrol_cli_db_upgrade_parse_requirements() {
3558 rccontrol_cli_db_upgrade_parse_requirements() {
3559 # :command.fixed_flags_filter
3559 # :command.fixed_flags_filter
3560 while [[ $# -gt 0 ]]; do
3560 while [[ $# -gt 0 ]]; do
3561 case "${1:-}" in
3561 case "${1:-}" in
3562 --help | -h)
3562 --help | -h)
3563 long_usage=yes
3563 long_usage=yes
3564 rccontrol_cli_db_upgrade_usage
3564 rccontrol_cli_db_upgrade_usage
3565 exit
3565 exit
3566 ;;
3566 ;;
3567
3567
3568 *)
3568 *)
3569 break
3569 break
3570 ;;
3570 ;;
3571
3571
3572 esac
3572 esac
3573 done
3573 done
3574
3574
3575 # :command.command_filter
3575 # :command.command_filter
3576 action="cli db-upgrade"
3576 action="cli db-upgrade"
3577
3577
3578 # :command.parse_requirements_while
3578 # :command.parse_requirements_while
3579 while [[ $# -gt 0 ]]; do
3579 while [[ $# -gt 0 ]]; do
3580 key="$1"
3580 key="$1"
3581 case "$key" in
3581 case "$key" in
3582
3582
3583 -?*)
3583 -?*)
3584 printf "invalid option: %s\n" "$key" >&2
3584 printf "invalid option: %s\n" "$key" >&2
3585 exit 1
3585 exit 1
3586 ;;
3586 ;;
3587
3587
3588 *)
3588 *)
3589 # :command.parse_requirements_case
3589 # :command.parse_requirements_case
3590 # :command.parse_requirements_case_simple
3590 # :command.parse_requirements_case_simple
3591 printf "invalid argument: %s\n" "$key" >&2
3591 printf "invalid argument: %s\n" "$key" >&2
3592 exit 1
3592 exit 1
3593
3593
3594 ;;
3594 ;;
3595
3595
3596 esac
3596 esac
3597 done
3597 done
3598
3598
3599 }
3599 }
3600
3600
3601 # :command.parse_requirements
3601 # :command.parse_requirements
3602 rccontrol_cli_storage_parse_requirements() {
3602 rccontrol_cli_storage_parse_requirements() {
3603 # :command.fixed_flags_filter
3603 # :command.fixed_flags_filter
3604 while [[ $# -gt 0 ]]; do
3604 while [[ $# -gt 0 ]]; do
3605 case "${1:-}" in
3605 case "${1:-}" in
3606 --help | -h)
3606 --help | -h)
3607 long_usage=yes
3607 long_usage=yes
3608 rccontrol_cli_storage_usage
3608 rccontrol_cli_storage_usage
3609 exit
3609 exit
3610 ;;
3610 ;;
3611
3611
3612 *)
3612 *)
3613 break
3613 break
3614 ;;
3614 ;;
3615
3615
3616 esac
3616 esac
3617 done
3617 done
3618
3618
3619 # :command.command_filter
3619 # :command.command_filter
3620 action="cli storage"
3620 action="cli storage"
3621
3621
3622 # :command.parse_requirements_while
3622 # :command.parse_requirements_while
3623 while [[ $# -gt 0 ]]; do
3623 while [[ $# -gt 0 ]]; do
3624 key="$1"
3624 key="$1"
3625 case "$key" in
3625 case "$key" in
3626
3626
3627 -?*)
3627 -?*)
3628 printf "invalid option: %s\n" "$key" >&2
3628 printf "invalid option: %s\n" "$key" >&2
3629 exit 1
3629 exit 1
3630 ;;
3630 ;;
3631
3631
3632 *)
3632 *)
3633 # :command.parse_requirements_case
3633 # :command.parse_requirements_case
3634 # :command.parse_requirements_case_simple
3634 # :command.parse_requirements_case_simple
3635 printf "invalid argument: %s\n" "$key" >&2
3635 printf "invalid argument: %s\n" "$key" >&2
3636 exit 1
3636 exit 1
3637
3637
3638 ;;
3638 ;;
3639
3639
3640 esac
3640 esac
3641 done
3641 done
3642
3642
3643 }
3643 }
3644
3644
3645 # :command.parse_requirements
3645 # :command.parse_requirements
3646 rccontrol_backup_db_parse_requirements() {
3646 rccontrol_backup_db_parse_requirements() {
3647 # :command.fixed_flags_filter
3647 # :command.fixed_flags_filter
3648 while [[ $# -gt 0 ]]; do
3648 while [[ $# -gt 0 ]]; do
3649 case "${1:-}" in
3649 case "${1:-}" in
3650 --help | -h)
3650 --help | -h)
3651 long_usage=yes
3651 long_usage=yes
3652 rccontrol_backup_db_usage
3652 rccontrol_backup_db_usage
3653 exit
3653 exit
3654 ;;
3654 ;;
3655
3655
3656 *)
3656 *)
3657 break
3657 break
3658 ;;
3658 ;;
3659
3659
3660 esac
3660 esac
3661 done
3661 done
3662
3662
3663 # :command.dependencies_filter
3663 # :command.dependencies_filter
3664 if ! command -v tar >/dev/null 2>&1; then
3664 if ! command -v tar >/dev/null 2>&1; then
3665 printf "missing dependency: tar\n" >&2
3665 printf "missing dependency: tar\n" >&2
3666 exit 1
3666 exit 1
3667 fi
3667 fi
3668
3668
3669 if ! command -v gzip >/dev/null 2>&1; then
3669 if ! command -v gzip >/dev/null 2>&1; then
3670 printf "missing dependency: gzip\n" >&2
3670 printf "missing dependency: gzip\n" >&2
3671 exit 1
3671 exit 1
3672 fi
3672 fi
3673
3673
3674 # :command.command_filter
3674 # :command.command_filter
3675 action="backup-db"
3675 action="backup-db"
3676
3676
3677 # :command.parse_requirements_while
3677 # :command.parse_requirements_while
3678 while [[ $# -gt 0 ]]; do
3678 while [[ $# -gt 0 ]]; do
3679 key="$1"
3679 key="$1"
3680 case "$key" in
3680 case "$key" in
3681
3681
3682 -?*)
3682 -?*)
3683 printf "invalid option: %s\n" "$key" >&2
3683 printf "invalid option: %s\n" "$key" >&2
3684 exit 1
3684 exit 1
3685 ;;
3685 ;;
3686
3686
3687 *)
3687 *)
3688 # :command.parse_requirements_case
3688 # :command.parse_requirements_case
3689 # :command.parse_requirements_case_simple
3689 # :command.parse_requirements_case_simple
3690 printf "invalid argument: %s\n" "$key" >&2
3690 printf "invalid argument: %s\n" "$key" >&2
3691 exit 1
3691 exit 1
3692
3692
3693 ;;
3693 ;;
3694
3694
3695 esac
3695 esac
3696 done
3696 done
3697
3697
3698 }
3698 }
3699
3699
3700 # :command.parse_requirements
3700 # :command.parse_requirements
3701 rccontrol_backup_data_parse_requirements() {
3701 rccontrol_backup_data_parse_requirements() {
3702 # :command.fixed_flags_filter
3702 # :command.fixed_flags_filter
3703 while [[ $# -gt 0 ]]; do
3703 while [[ $# -gt 0 ]]; do
3704 case "${1:-}" in
3704 case "${1:-}" in
3705 --help | -h)
3705 --help | -h)
3706 long_usage=yes
3706 long_usage=yes
3707 rccontrol_backup_data_usage
3707 rccontrol_backup_data_usage
3708 exit
3708 exit
3709 ;;
3709 ;;
3710
3710
3711 *)
3711 *)
3712 break
3712 break
3713 ;;
3713 ;;
3714
3714
3715 esac
3715 esac
3716 done
3716 done
3717
3717
3718 # :command.dependencies_filter
3718 # :command.dependencies_filter
3719 if ! command -v tar >/dev/null 2>&1; then
3719 if ! command -v tar >/dev/null 2>&1; then
3720 printf "missing dependency: tar\n" >&2
3720 printf "missing dependency: tar\n" >&2
3721 exit 1
3721 exit 1
3722 fi
3722 fi
3723
3723
3724 # :command.command_filter
3724 # :command.command_filter
3725 action="backup-data"
3725 action="backup-data"
3726
3726
3727 # :command.parse_requirements_while
3727 # :command.parse_requirements_while
3728 while [[ $# -gt 0 ]]; do
3728 while [[ $# -gt 0 ]]; do
3729 key="$1"
3729 key="$1"
3730 case "$key" in
3730 case "$key" in
3731
3731
3732 -?*)
3732 -?*)
3733 printf "invalid option: %s\n" "$key" >&2
3733 printf "invalid option: %s\n" "$key" >&2
3734 exit 1
3734 exit 1
3735 ;;
3735 ;;
3736
3736
3737 *)
3737 *)
3738 # :command.parse_requirements_case
3738 # :command.parse_requirements_case
3739 # :command.parse_requirements_case_simple
3739 # :command.parse_requirements_case_simple
3740 printf "invalid argument: %s\n" "$key" >&2
3740 printf "invalid argument: %s\n" "$key" >&2
3741 exit 1
3741 exit 1
3742
3742
3743 ;;
3743 ;;
3744
3744
3745 esac
3745 esac
3746 done
3746 done
3747
3747
3748 }
3748 }
3749
3749
3750 # :command.parse_requirements
3750 # :command.parse_requirements
3751 rccontrol__completions_parse_requirements() {
3751 rccontrol__completions_parse_requirements() {
3752 # :command.fixed_flags_filter
3752 # :command.fixed_flags_filter
3753 while [[ $# -gt 0 ]]; do
3753 while [[ $# -gt 0 ]]; do
3754 case "${1:-}" in
3754 case "${1:-}" in
3755 --help | -h)
3755 --help | -h)
3756 long_usage=yes
3756 long_usage=yes
3757 rccontrol__completions_usage
3757 rccontrol__completions_usage
3758 exit
3758 exit
3759 ;;
3759 ;;
3760
3760
3761 *)
3761 *)
3762 break
3762 break
3763 ;;
3763 ;;
3764
3764
3765 esac
3765 esac
3766 done
3766 done
3767
3767
3768 # :command.command_filter
3768 # :command.command_filter
3769 action="_completions"
3769 action="_completions"
3770
3770
3771 # :command.parse_requirements_while
3771 # :command.parse_requirements_while
3772 while [[ $# -gt 0 ]]; do
3772 while [[ $# -gt 0 ]]; do
3773 key="$1"
3773 key="$1"
3774 case "$key" in
3774 case "$key" in
3775
3775
3776 -?*)
3776 -?*)
3777 printf "invalid option: %s\n" "$key" >&2
3777 printf "invalid option: %s\n" "$key" >&2
3778 exit 1
3778 exit 1
3779 ;;
3779 ;;
3780
3780
3781 *)
3781 *)
3782 # :command.parse_requirements_case
3782 # :command.parse_requirements_case
3783 # :command.parse_requirements_case_simple
3783 # :command.parse_requirements_case_simple
3784 printf "invalid argument: %s\n" "$key" >&2
3784 printf "invalid argument: %s\n" "$key" >&2
3785 exit 1
3785 exit 1
3786
3786
3787 ;;
3787 ;;
3788
3788
3789 esac
3789 esac
3790 done
3790 done
3791
3791
3792 }
3792 }
3793
3793
3794 # :command.initialize
3794 # :command.initialize
3795 initialize() {
3795 initialize() {
3796 version="4.28.0.rel2022.12.12.3"
3796 version="4.28.0.rel2022.12.13.1"
3797 long_usage=''
3797 long_usage=''
3798 set -e
3798 set -e
3799
3799
3800 # :command.environment_variables_default
3800 # :command.environment_variables_default
3801 export RCC_CONFIG="${RCC_CONFIG:-.rccontrol.ini}"
3801 export RCC_CONFIG="${RCC_CONFIG:-.rccontrol.ini}"
3802 export RC_CLI_VERSION_NAME="${RC_CLI_VERSION_NAME:-4.27.0}"
3802 export RC_CLI_VERSION_NAME="${RC_CLI_VERSION_NAME:-4.27.0}"
3803 export RC_STACK_ROUTER_EXT="${RC_STACK_ROUTER_EXT:-.custom/docker-compose-router.override.yaml}"
3803 export RC_STACK_ROUTER_EXT="${RC_STACK_ROUTER_EXT:-.custom/docker-compose-router.override.yaml}"
3804 export RC_STACK_METRICS_EXT="${RC_STACK_METRICS_EXT:-.custom/docker-compose-metrics.override.yaml}"
3804 export RC_STACK_METRICS_EXT="${RC_STACK_METRICS_EXT:-.custom/docker-compose-metrics.override.yaml}"
3805 export RC_STACK_SERVICES_EXT="${RC_STACK_SERVICES_EXT:-.custom/docker-compose-services.override.yaml}"
3805 export RC_STACK_SERVICES_EXT="${RC_STACK_SERVICES_EXT:-.custom/docker-compose-services.override.yaml}"
3806 export RC_STACK_RHODECODE_EXT="${RC_STACK_RHODECODE_EXT:-.custom/docker-compose-apps.override.yaml}"
3806 export RC_STACK_RHODECODE_EXT="${RC_STACK_RHODECODE_EXT:-.custom/docker-compose-apps.override.yaml}"
3807
3807
3808 # src/initialize.sh
3808 # src/initialize.sh
3809
3809
3810 # bootstrap file is a config file at the same time
3810 # bootstrap file is a config file at the same time
3811 CONFIG_FILE=${RCC_CONFIG:=.rccontrol.ini}
3811 CONFIG_FILE=${RCC_CONFIG:=.rccontrol.ini}
3812
3812
3813 # runtime env file
3813 # runtime env file
3814 RUNTIME_ENV=$PWD/.custom/.runtime.env
3814 RUNTIME_ENV=$PWD/.custom/.runtime.env
3815
3815
3816 # STACK_LIST
3816 # STACK_LIST
3817 VALID_SERVICES="router metrics services rhodecode"
3817 VALID_SERVICES="router metrics services rhodecode"
3818 DOCKER_DEFS_WORK_DIR="docker_defs"
3818 DOCKER_DEFS_WORK_DIR="docker_defs"
3819
3819
3820 # stage key, saved in .rccontrol.ini : stage func to execute
3820 # stage key, saved in .rccontrol.ini : stage func to execute
3821 BOOTSTRAP_STAGES="\
3821 BOOTSTRAP_STAGES="\
3822 bootstrap_v1_docker_install:bootstrap_docker_install \
3822 bootstrap_v1_docker_install:bootstrap_docker_install \
3823 bootstrap_v1_docker_commons:bootstrap_docker_commons \
3823 bootstrap_v1_docker_commons:bootstrap_docker_commons \
3824 bootstrap_v1_config:bootstrap_config \
3824 bootstrap_v1_config:bootstrap_config \
3825 bootstrap_v1_definitions:bootstrap_definitions \
3825 bootstrap_v1_definitions:bootstrap_definitions \
3826 bootstrap_v1_overrides:bootstrap_overrides \
3826 bootstrap_v1_overrides:bootstrap_overrides \
3827 "
3827 "
3828
3828
3829 #echo "1 ----"
3829 #echo "1 ----"
3830 #echo $RC_STACK_SERVICES_EXT
3830 #echo $RC_STACK_SERVICES_EXT
3831 #echo $RC_STACK_METRICS_EXT
3831 #echo $RC_STACK_METRICS_EXT
3832 #echo "1 -----"
3832 #echo "1 -----"
3833
3833
3834 #echo '2 ----'
3834 #echo '2 ----'
3835 #grep -v -e '^#' "$ENV_FILE" | xargs -I {} echo \'{}\'
3835 #grep -v -e '^#' "$ENV_FILE" | xargs -I {} echo \'{}\'
3836 #echo '2 ----'
3836 #echo '2 ----'
3837
3837
3838 #expose env vars from rccontrol donfig
3838 #expose env vars from rccontrol donfig
3839 #if [[ -f $ENV_FILE ]]; then
3839 #if [[ -f $ENV_FILE ]]; then
3840 # eval $(grep -v -e '^#' "$ENV_FILE" | xargs -I {} echo export \'{}\')
3840 # eval $(grep -v -e '^#' "$ENV_FILE" | xargs -I {} echo export \'{}\')
3841 #fi
3841 #fi
3842
3842
3843 #ENV_EXPAND=""
3843 #ENV_EXPAND=""
3844 #for k in $(config_keys); do
3844 #for k in $(config_keys); do
3845 # k_upper=${k^^}
3845 # k_upper=${k^^}
3846 # env_entry="-e $k_upper='$(config_get "$k")' "
3846 # env_entry="-e $k_upper='$(config_get "$k")' "
3847 # ENV_EXPAND+=$env_entry;
3847 # ENV_EXPAND+=$env_entry;
3848 # #echo $env_expand
3848 # #echo $env_expand
3849 #done
3849 #done
3850
3850
3851 #
3851 #
3852 #echo "3 ----"
3852 #echo "3 ----"
3853 #echo $RC_STACK_SERVICES_EXT
3853 #echo $RC_STACK_SERVICES_EXT
3854 #echo $RC_STACK_METRICS_EXT
3854 #echo $RC_STACK_METRICS_EXT
3855 #echo $RC_STACK_RHODECODE_EXT
3855 #echo $RC_STACK_RHODECODE_EXT
3856 #echo "3 -----"
3856 #echo "3 -----"
3857
3857
3858 #env | grep RC_
3858 #env | grep RC_
3859
3859
3860 docker_ping_host() {
3860 docker_ping_host() {
3861 PING_HOST="$1"
3861 PING_HOST="$1"
3862 docker run --network rhodecode_network --rm alpine ping "$PING_HOST"
3862 docker run --network rhodecode_network --rm alpine ping "$PING_HOST"
3863 }
3863 }
3864
3864
3865 # backup files from a docker volume into /tmp/backup.tar.gz
3865 # backup files from a docker volume into /tmp/backup.tar.gz
3866 docker-volume-backup-compressed() {
3866 docker-volume-backup-compressed() {
3867 docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie tar -czvf /backup/backup.tar.gz "${@:2}"
3867 docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie tar -czvf /backup/backup.tar.gz "${@:2}"
3868 }
3868 }
3869
3869
3870 # restore files from /tmp/backup.tar.gz into a docker volume
3870 # restore files from /tmp/backup.tar.gz into a docker volume
3871 docker-volume-restore-compressed() {
3871 docker-volume-restore-compressed() {
3872 docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie tar -xzvf /backup/backup.tar.gz "${@:2}"
3872 docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie tar -xzvf /backup/backup.tar.gz "${@:2}"
3873 echo "Double checking files..."
3873 echo "Double checking files..."
3874 docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie ls -lh "${@:2}"
3874 docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie ls -lh "${@:2}"
3875 }
3875 }
3876
3876
3877 # backup files from a docker volume into /tmp/backup.tar
3877 # backup files from a docker volume into /tmp/backup.tar
3878 docker-volume-backup() {
3878 docker-volume-backup() {
3879 docker run --rm -v /tmp:/backup --volumes-from "$1" busybox tar -cvf /backup/backup.tar "${@:2}"
3879 docker run --rm -v /tmp:/backup --volumes-from "$1" busybox tar -cvf /backup/backup.tar "${@:2}"
3880 }
3880 }
3881
3881
3882 # restore files from /tmp/backup.tar into a docker volume
3882 # restore files from /tmp/backup.tar into a docker volume
3883 docker-volume-restore() {
3883 docker-volume-restore() {
3884 docker run --rm -v /tmp:/backup --volumes-from "$1" busybox tar -xvf /backup/backup.tar "${@:2}"
3884 docker run --rm -v /tmp:/backup --volumes-from "$1" busybox tar -xvf /backup/backup.tar "${@:2}"
3885 echo "Double checking files..."
3885 echo "Double checking files..."
3886 docker run --rm -v /tmp:/backup --volumes-from "$1" busybox ls -lh "${@:2}"
3886 docker run --rm -v /tmp:/backup --volumes-from "$1" busybox ls -lh "${@:2}"
3887 }
3887 }
3888
3888
3889 get_started() {
3889 get_started() {
3890 echo ""
3890 echo ""
3891 echo "To start using RhodeCode run the following stacks using ./rccontrol stack [STACK_NAME]"
3891 echo "To start using RhodeCode run the following stacks using ./rccontrol stack [STACK_NAME]"
3892 echo ""
3892 echo ""
3893 echo "$(yellow_bold [Optional]): run the edge router to control domain and SSL"
3893 echo "$(yellow_bold [Optional]): run the edge router to control domain and SSL"
3894 echo "./rccontrol stack router up --detach"
3894 echo "./rccontrol stack router up --detach"
3895 echo ""
3895 echo ""
3896 echo "$(green_bold [Mandatory]): run the services, like database, redis, channelstream etc..."
3896 echo "$(green_bold [Mandatory]): run the services, like database, redis, channelstream etc..."
3897 echo "./rccontrol stack services up --detach"
3897 echo "./rccontrol stack services up --detach"
3898 echo ""
3898 echo ""
3899 echo "$(green_bold [Mandatory]): run the rhodecode app stack"
3899 echo "$(green_bold [Mandatory]): run the rhodecode app stack"
3900 echo "./rccontrol stack rhodecode up --detach"
3900 echo "./rccontrol stack rhodecode up --detach"
3901 echo ""
3901 echo ""
3902 echo "$(yellow_bold [Optional]): run the monitoring stack, this includes grafana/promethues logging/metrics system"
3902 echo "$(yellow_bold [Optional]): run the monitoring stack, this includes grafana/promethues logging/metrics system"
3903 echo "./rccontrol stack metrics up --detach"
3903 echo "./rccontrol stack metrics up --detach"
3904 echo ""
3904 echo ""
3905 echo "$(bold [Status]): check services run status, ports etc.."
3905 echo "$(bold [Status]): check services run status, ports etc.."
3906 echo "./rccontrol status"
3906 echo "./rccontrol status"
3907 echo ""
3907 echo ""
3908 echo "$(bold [Logs]): check service logs"
3908 echo "$(bold [Logs]): check service logs"
3909 echo "./rccontrol logs SERVICE_NAME"
3909 echo "./rccontrol logs SERVICE_NAME"
3910 }
3910 }
3911 }
3911 }
3912
3912
3913 # :command.run
3913 # :command.run
3914 run() {
3914 run() {
3915 declare -A args=()
3915 declare -A args=()
3916 declare -a other_args=()
3916 declare -a other_args=()
3917 declare -a input=()
3917 declare -a input=()
3918 normalize_input "$@"
3918 normalize_input "$@"
3919 parse_requirements "${input[@]}"
3919 parse_requirements "${input[@]}"
3920
3920
3921 case "$action" in
3921 case "$action" in
3922 "self-update")
3922 "self-update")
3923 if [[ ${args[--help]:-} ]]; then
3923 if [[ ${args[--help]:-} ]]; then
3924 long_usage=yes
3924 long_usage=yes
3925 rccontrol_self_update_usage
3925 rccontrol_self_update_usage
3926 else
3926 else
3927 rccontrol_self_update_command
3927 rccontrol_self_update_command
3928 fi
3928 fi
3929 ;;
3929 ;;
3930
3930
3931 "bootstrap")
3931 "bootstrap")
3932 if [[ ${args[--help]:-} ]]; then
3932 if [[ ${args[--help]:-} ]]; then
3933 long_usage=yes
3933 long_usage=yes
3934 rccontrol_bootstrap_usage
3934 rccontrol_bootstrap_usage
3935 else
3935 else
3936 rccontrol_bootstrap_command
3936 rccontrol_bootstrap_command
3937 fi
3937 fi
3938 ;;
3938 ;;
3939
3939
3940 "get-build-artifacts")
3940 "get-build-artifacts")
3941 if [[ ${args[--help]:-} ]]; then
3941 if [[ ${args[--help]:-} ]]; then
3942 long_usage=yes
3942 long_usage=yes
3943 rccontrol_get_build_artifacts_usage
3943 rccontrol_get_build_artifacts_usage
3944 else
3944 else
3945 rccontrol_get_build_artifacts_command
3945 rccontrol_get_build_artifacts_command
3946 fi
3946 fi
3947 ;;
3947 ;;
3948
3948
3949 "build")
3949 "build")
3950 if [[ ${args[--help]:-} ]]; then
3950 if [[ ${args[--help]:-} ]]; then
3951 long_usage=yes
3951 long_usage=yes
3952 rccontrol_build_usage
3952 rccontrol_build_usage
3953 else
3953 else
3954 rccontrol_build_command
3954 rccontrol_build_command
3955 fi
3955 fi
3956 ;;
3956 ;;
3957
3957
3958 "get-build-source")
3958 "get-build-source")
3959 if [[ ${args[--help]:-} ]]; then
3959 if [[ ${args[--help]:-} ]]; then
3960 long_usage=yes
3960 long_usage=yes
3961 rccontrol_get_build_source_usage
3961 rccontrol_get_build_source_usage
3962 else
3962 else
3963 rccontrol_get_build_source_command
3963 rccontrol_get_build_source_command
3964 fi
3964 fi
3965 ;;
3965 ;;
3966
3966
3967 "build-source")
3967 "build-source")
3968 if [[ ${args[--help]:-} ]]; then
3968 if [[ ${args[--help]:-} ]]; then
3969 long_usage=yes
3969 long_usage=yes
3970 rccontrol_build_source_usage
3970 rccontrol_build_source_usage
3971 else
3971 else
3972 rccontrol_build_source_command
3972 rccontrol_build_source_command
3973 fi
3973 fi
3974 ;;
3974 ;;
3975
3975
3976 "stack")
3976 "stack")
3977 if [[ ${args[--help]:-} ]]; then
3977 if [[ ${args[--help]:-} ]]; then
3978 long_usage=yes
3978 long_usage=yes
3979 rccontrol_stack_usage
3979 rccontrol_stack_usage
3980 else
3980 else
3981 rccontrol_stack_command
3981 rccontrol_stack_command
3982 fi
3982 fi
3983 ;;
3983 ;;
3984
3984
3985 "stack router")
3985 "stack router")
3986 if [[ ${args[--help]:-} ]]; then
3986 if [[ ${args[--help]:-} ]]; then
3987 long_usage=yes
3987 long_usage=yes
3988 rccontrol_stack_router_usage
3988 rccontrol_stack_router_usage
3989 else
3989 else
3990 rccontrol_stack_router_command
3990 rccontrol_stack_router_command
3991 fi
3991 fi
3992 ;;
3992 ;;
3993
3993
3994 "stack metrics")
3994 "stack metrics")
3995 if [[ ${args[--help]:-} ]]; then
3995 if [[ ${args[--help]:-} ]]; then
3996 long_usage=yes
3996 long_usage=yes
3997 rccontrol_stack_metrics_usage
3997 rccontrol_stack_metrics_usage
3998 else
3998 else
3999 rccontrol_stack_metrics_command
3999 rccontrol_stack_metrics_command
4000 fi
4000 fi
4001 ;;
4001 ;;
4002
4002
4003 "stack services")
4003 "stack services")
4004 if [[ ${args[--help]:-} ]]; then
4004 if [[ ${args[--help]:-} ]]; then
4005 long_usage=yes
4005 long_usage=yes
4006 rccontrol_stack_services_usage
4006 rccontrol_stack_services_usage
4007 else
4007 else
4008 rccontrol_stack_services_command
4008 rccontrol_stack_services_command
4009 fi
4009 fi
4010 ;;
4010 ;;
4011
4011
4012 "stack rhodecode")
4012 "stack rhodecode")
4013 if [[ ${args[--help]:-} ]]; then
4013 if [[ ${args[--help]:-} ]]; then
4014 long_usage=yes
4014 long_usage=yes
4015 rccontrol_stack_rhodecode_usage
4015 rccontrol_stack_rhodecode_usage
4016 else
4016 else
4017 rccontrol_stack_rhodecode_command
4017 rccontrol_stack_rhodecode_command
4018 fi
4018 fi
4019 ;;
4019 ;;
4020
4020
4021 "stack all")
4021 "stack all")
4022 if [[ ${args[--help]:-} ]]; then
4022 if [[ ${args[--help]:-} ]]; then
4023 long_usage=yes
4023 long_usage=yes
4024 rccontrol_stack_all_usage
4024 rccontrol_stack_all_usage
4025 else
4025 else
4026 rccontrol_stack_all_command
4026 rccontrol_stack_all_command
4027 fi
4027 fi
4028 ;;
4028 ;;
4029
4029
4030 "stack-status")
4030 "stack-status")
4031 if [[ ${args[--help]:-} ]]; then
4031 if [[ ${args[--help]:-} ]]; then
4032 long_usage=yes
4032 long_usage=yes
4033 rccontrol_stack_status_usage
4033 rccontrol_stack_status_usage
4034 else
4034 else
4035 rccontrol_stack_status_command
4035 rccontrol_stack_status_command
4036 fi
4036 fi
4037 ;;
4037 ;;
4038
4038
4039 "stack-upgrade")
4039 "stack-upgrade")
4040 if [[ ${args[--help]:-} ]]; then
4040 if [[ ${args[--help]:-} ]]; then
4041 long_usage=yes
4041 long_usage=yes
4042 rccontrol_stack_upgrade_usage
4042 rccontrol_stack_upgrade_usage
4043 else
4043 else
4044 rccontrol_stack_upgrade_command
4044 rccontrol_stack_upgrade_command
4045 fi
4045 fi
4046 ;;
4046 ;;
4047
4047
4048 "cli")
4048 "cli")
4049 if [[ ${args[--help]:-} ]]; then
4049 if [[ ${args[--help]:-} ]]; then
4050 long_usage=yes
4050 long_usage=yes
4051 rccontrol_cli_usage
4051 rccontrol_cli_usage
4052 else
4052 else
4053 rccontrol_cli_command
4053 rccontrol_cli_command
4054 fi
4054 fi
4055 ;;
4055 ;;
4056
4056
4057 "cli redis")
4057 "cli redis")
4058 if [[ ${args[--help]:-} ]]; then
4058 if [[ ${args[--help]:-} ]]; then
4059 long_usage=yes
4059 long_usage=yes
4060 rccontrol_cli_redis_usage
4060 rccontrol_cli_redis_usage
4061 else
4061 else
4062 rccontrol_cli_redis_command
4062 rccontrol_cli_redis_command
4063 fi
4063 fi
4064 ;;
4064 ;;
4065
4065
4066 "cli db")
4066 "cli db")
4067 if [[ ${args[--help]:-} ]]; then
4067 if [[ ${args[--help]:-} ]]; then
4068 long_usage=yes
4068 long_usage=yes
4069 rccontrol_cli_db_usage
4069 rccontrol_cli_db_usage
4070 else
4070 else
4071 rccontrol_cli_db_command
4071 rccontrol_cli_db_command
4072 fi
4072 fi
4073 ;;
4073 ;;
4074
4074
4075 "cli db-upgrade")
4075 "cli db-upgrade")
4076 if [[ ${args[--help]:-} ]]; then
4076 if [[ ${args[--help]:-} ]]; then
4077 long_usage=yes
4077 long_usage=yes
4078 rccontrol_cli_db_upgrade_usage
4078 rccontrol_cli_db_upgrade_usage
4079 else
4079 else
4080 rccontrol_cli_db_upgrade_command
4080 rccontrol_cli_db_upgrade_command
4081 fi
4081 fi
4082 ;;
4082 ;;
4083
4083
4084 "cli storage")
4084 "cli storage")
4085 if [[ ${args[--help]:-} ]]; then
4085 if [[ ${args[--help]:-} ]]; then
4086 long_usage=yes
4086 long_usage=yes
4087 rccontrol_cli_storage_usage
4087 rccontrol_cli_storage_usage
4088 else
4088 else
4089 rccontrol_cli_storage_command
4089 rccontrol_cli_storage_command
4090 fi
4090 fi
4091 ;;
4091 ;;
4092
4092
4093 "backup-db")
4093 "backup-db")
4094 if [[ ${args[--help]:-} ]]; then
4094 if [[ ${args[--help]:-} ]]; then
4095 long_usage=yes
4095 long_usage=yes
4096 rccontrol_backup_db_usage
4096 rccontrol_backup_db_usage
4097 else
4097 else
4098 rccontrol_backup_db_command
4098 rccontrol_backup_db_command
4099 fi
4099 fi
4100 ;;
4100 ;;
4101
4101
4102 "backup-data")
4102 "backup-data")
4103 if [[ ${args[--help]:-} ]]; then
4103 if [[ ${args[--help]:-} ]]; then
4104 long_usage=yes
4104 long_usage=yes
4105 rccontrol_backup_data_usage
4105 rccontrol_backup_data_usage
4106 else
4106 else
4107 rccontrol_backup_data_command
4107 rccontrol_backup_data_command
4108 fi
4108 fi
4109 ;;
4109 ;;
4110
4110
4111 "_completions")
4111 "_completions")
4112 if [[ ${args[--help]:-} ]]; then
4112 if [[ ${args[--help]:-} ]]; then
4113 long_usage=yes
4113 long_usage=yes
4114 rccontrol__completions_usage
4114 rccontrol__completions_usage
4115 else
4115 else
4116 rccontrol__completions_command
4116 rccontrol__completions_command
4117 fi
4117 fi
4118 ;;
4118 ;;
4119
4119
4120 esac
4120 esac
4121 }
4121 }
4122
4122
4123 initialize
4123 initialize
4124 run "$@"
4124 run "$@"
General Comments 0
You need to be logged in to leave comments. Login now