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