##// END OF EJS Templates
feat: commands, renamed set-runtime-image to set-image...
super-admin -
Show More
@@ -1,7991 +1,8103 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 rcstack_usage() {
21 rcstack_usage() {
22 if [[ -n $long_usage ]]; then
22 if [[ -n $long_usage ]]; then
23 printf "rcstack\n"
23 printf "rcstack\n"
24 echo
24 echo
25
25
26 printf " CLI for installing and managing RhodeCode Cluster Stack \nSupport:\n https://community.rhodecode.com\nDocs: https://docs.rhodecode.com/rcstack\n"
26 printf " CLI for installing and managing RhodeCode Cluster Stack \nSupport:\n https://community.rhodecode.com\nDocs: https://docs.rhodecode.com/rcstack\n"
27 echo
27 echo
28
28
29 else
29 else
30 printf "rcstack - CLI for installing and managing RhodeCode Cluster Stack \nSupport: https://community.rhodecode.com\nDocs: https://docs.rhodecode.com/rcstack\n"
30 printf "rcstack - CLI for installing and managing RhodeCode Cluster Stack \nSupport: https://community.rhodecode.com\nDocs: https://docs.rhodecode.com/rcstack\n"
31 echo
31 echo
32
32
33 fi
33 fi
34
34
35 printf "%s\n" "Usage:"
35 printf "%s\n" "Usage:"
36 printf " rcstack [OPTIONS] COMMAND\n"
36 printf " rcstack [OPTIONS] COMMAND\n"
37 printf " rcstack [COMMAND] --help | -h\n"
37 printf " rcstack [COMMAND] --help | -h\n"
38 printf " rcstack --version | -v\n"
38 printf " rcstack --version | -v\n"
39 echo
39 echo
40 # :command.usage_commands
40 # :command.usage_commands
41 printf "%s\n" "Commands:"
41 printf "%s\n" "Commands:"
42 printf " %s Print instructions to get started with rhodecode docker stack\n" "get-started "
42 printf " %s Print instructions to get started with rhodecode docker stack\n" "get-started "
43 printf " %s Bootstrap this machine, check docker version and install rhodecode-network\n" "init "
43 printf " %s Bootstrap this machine, check docker version and install rhodecode-network\n" "init "
44 printf " %s Update rcstack and it's docker definitions\n" "self-update "
44 printf " %s Update rcstack and it's docker definitions\n" "self-update "
45 printf " %s Perform rcstack upgrade procedure. This aims at changing existing installations with some changes required that are not backward compatible\n" "self-upgrade "
45 printf " %s Perform rcstack upgrade procedure. This aims at changing existing installations with some changes required that are not backward compatible\n" "self-upgrade "
46 echo
46 echo
47 printf "%s\n" "Stack Commands:"
47 printf "%s\n" "Stack Commands:"
48 printf " %s Run one of available cluster stacks, run stack -h for more details\n" "stack "
48 printf " %s Run one of available cluster stacks, run stack -h for more details\n" "stack "
49 printf " %s Show stack status\n" "stack-status "
49 printf " %s Show stack status\n" "stack-status "
50 printf " %s Upgrade a stack, run stack-upgrade -h for more details\n" "stack-upgrade"
50 printf " %s Upgrade a stack, run stack-upgrade -h for more details\n" "stack-upgrade"
51 printf " %s run monitoring on stack items\n" "stack-monitor"
51 printf " %s run monitoring on stack items\n" "stack-monitor"
52 echo
52 echo
53 printf "%s\n" "CLI Commands:"
53 printf "%s\n" "CLI Commands:"
54 printf " %s Various CLI tools, run cli -h for more details\n" "cli "
54 printf " %s Various CLI tools, run cli -h for more details\n" "cli "
55 echo
55 echo
56 printf "%s\n" "Backup Commands:"
56 printf "%s\n" "Backup Commands:"
57 printf " %s Backup Database\n" "backup-db "
57 printf " %s Backup Database\n" "backup-db "
58 printf " %s Backup RhodeCode storage\n" "backup-data "
58 printf " %s Backup RhodeCode storage\n" "backup-data "
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 "%s\n" "Options:"
63 printf "%s\n" "Options:"
64
64
65 # :command.usage_flags
65 # :command.usage_flags
66 # :flag.usage
66 # :flag.usage
67 printf " %s\n" "--debug"
67 printf " %s\n" "--debug"
68 printf " Enable debug and detailed output. Add --debug right after ./rcstack command.\n E.g. ./rcstack --debug COMMAND\n"
68 printf " Enable debug and detailed output. Add --debug right after ./rcstack command.\n E.g. ./rcstack --debug COMMAND\n"
69 echo
69 echo
70
70
71 # :flag.usage
71 # :flag.usage
72 printf " %s\n" "--no-init-check"
72 printf " %s\n" "--no-init-check"
73 printf " Skip check for ./rcstack init call\n"
73 printf " Skip check for ./rcstack init call\n"
74 echo
74 echo
75
75
76 # :command.usage_fixed_flags
76 # :command.usage_fixed_flags
77 printf " %s\n" "--help, -h"
77 printf " %s\n" "--help, -h"
78 printf " Show this help\n"
78 printf " Show this help\n"
79 echo
79 echo
80 printf " %s\n" "--version, -v"
80 printf " %s\n" "--version, -v"
81 printf " Show version number\n"
81 printf " Show version number\n"
82 echo
82 echo
83
83
84 # :command.usage_environment_variables
84 # :command.usage_environment_variables
85 printf "%s\n" "Environment Variables:"
85 printf "%s\n" "Environment Variables:"
86
86
87 # :environment_variable.usage
87 # :environment_variable.usage
88 printf " %s\n" "RCC_CONFIG"
88 printf " %s\n" "RCC_CONFIG"
89 printf " default config file for rcstack\n"
89 printf " default config file for rcstack\n"
90 printf " Default: .rcstack.ini\n"
90 printf " Default: .rcstack.ini\n"
91 echo
91 echo
92
92
93 # :environment_variable.usage
93 # :environment_variable.usage
94 printf " %s\n" "AUTH_TOKEN"
94 printf " %s\n" "AUTH_TOKEN"
95 printf " Set your RhodeCode AUTH Token\n"
95 printf " Set your RhodeCode AUTH Token\n"
96 echo
96 echo
97
97
98 # :environment_variable.usage
98 # :environment_variable.usage
99 printf " %s\n" "RC_STACK_ROUTER_EXT"
99 printf " %s\n" "RC_STACK_ROUTER_EXT"
100 printf "\n"
100 printf "\n"
101 printf " Default: .custom/docker-compose-router.override.yaml\n"
101 printf " Default: .custom/docker-compose-router.override.yaml\n"
102 echo
102 echo
103
103
104 # :environment_variable.usage
104 # :environment_variable.usage
105 printf " %s\n" "RC_STACK_METRICS_EXT"
105 printf " %s\n" "RC_STACK_METRICS_EXT"
106 printf "\n"
106 printf "\n"
107 printf " Default: .custom/docker-compose-metrics.override.yaml\n"
107 printf " Default: .custom/docker-compose-metrics.override.yaml\n"
108 echo
108 echo
109
109
110 # :environment_variable.usage
110 # :environment_variable.usage
111 printf " %s\n" "RC_STACK_SERVICES_EXT"
111 printf " %s\n" "RC_STACK_SERVICES_EXT"
112 printf "\n"
112 printf "\n"
113 printf " Default: .custom/docker-compose-services.override.yaml\n"
113 printf " Default: .custom/docker-compose-services.override.yaml\n"
114 echo
114 echo
115
115
116 # :environment_variable.usage
116 # :environment_variable.usage
117 printf " %s\n" "RC_STACK_RHODECODE_EXT"
117 printf " %s\n" "RC_STACK_RHODECODE_EXT"
118 printf "\n"
118 printf "\n"
119 printf " Default: .custom/docker-compose-apps.override.yaml\n"
119 printf " Default: .custom/docker-compose-apps.override.yaml\n"
120 echo
120 echo
121
121
122 # :command.footer
122 # :command.footer
123 printf "RhodeCode Inc 2024\n\n"
123 printf "RhodeCode Inc 2024\n\n"
124 echo
124 echo
125
125
126 fi
126 fi
127 }
127 }
128
128
129 # :command.usage
129 # :command.usage
130 rcstack_get_started_usage() {
130 rcstack_get_started_usage() {
131 if [[ -n $long_usage ]]; then
131 if [[ -n $long_usage ]]; then
132 printf "rcstack get-started - Print instructions to get started with rhodecode docker stack\n"
132 printf "rcstack get-started - Print instructions to get started with rhodecode docker stack\n"
133 echo
133 echo
134
134
135 else
135 else
136 printf "rcstack get-started - Print instructions to get started with rhodecode docker stack\n"
136 printf "rcstack get-started - Print instructions to get started with rhodecode docker stack\n"
137 echo
137 echo
138
138
139 fi
139 fi
140
140
141 printf "%s\n" "Usage:"
141 printf "%s\n" "Usage:"
142 printf " rcstack get-started\n"
142 printf " rcstack get-started\n"
143 printf " rcstack get-started --help | -h\n"
143 printf " rcstack get-started --help | -h\n"
144 echo
144 echo
145
145
146 # :command.long_usage
146 # :command.long_usage
147 if [[ -n $long_usage ]]; then
147 if [[ -n $long_usage ]]; then
148 printf "%s\n" "Options:"
148 printf "%s\n" "Options:"
149
149
150 # :command.usage_fixed_flags
150 # :command.usage_fixed_flags
151 printf " %s\n" "--help, -h"
151 printf " %s\n" "--help, -h"
152 printf " Show this help\n"
152 printf " Show this help\n"
153 echo
153 echo
154
154
155 fi
155 fi
156 }
156 }
157
157
158 # :command.usage
158 # :command.usage
159 rcstack_init_usage() {
159 rcstack_init_usage() {
160 if [[ -n $long_usage ]]; then
160 if [[ -n $long_usage ]]; then
161 printf "rcstack init - Bootstrap this machine, check docker version and install rhodecode-network\n"
161 printf "rcstack init - Bootstrap this machine, check docker version and install rhodecode-network\n"
162 echo
162 echo
163
163
164 else
164 else
165 printf "rcstack init - Bootstrap this machine, check docker version and install rhodecode-network\n"
165 printf "rcstack init - Bootstrap this machine, check docker version and install rhodecode-network\n"
166 echo
166 echo
167
167
168 fi
168 fi
169
169
170 printf "%s\n" "Usage:"
170 printf "%s\n" "Usage:"
171 printf " rcstack init [OPTIONS]\n"
171 printf " rcstack init [OPTIONS]\n"
172 printf " rcstack init --help | -h\n"
172 printf " rcstack init --help | -h\n"
173 echo
173 echo
174
174
175 # :command.long_usage
175 # :command.long_usage
176 if [[ -n $long_usage ]]; then
176 if [[ -n $long_usage ]]; then
177 printf "%s\n" "Options:"
177 printf "%s\n" "Options:"
178
178
179 # :command.usage_flags
179 # :command.usage_flags
180 # :flag.usage
180 # :flag.usage
181 printf " %s\n" "--arg-accept-eula"
181 printf " %s\n" "--arg-accept-eula"
182 printf " accept EULA automatically\n"
182 printf " accept EULA automatically\n"
183 echo
183 echo
184
184
185 # :flag.usage
185 # :flag.usage
186 printf " %s\n" "--arg-rc-edition ARG_RC_EDITION"
186 printf " %s\n" "--arg-rc-edition ARG_RC_EDITION"
187 printf " specify rc_edition [ee|ce] for setup\n"
187 printf " specify rc_edition [ee|ce] for setup\n"
188 printf " Allowed: ce, ee\n"
188 printf " Allowed: ce, ee\n"
189 echo
189 echo
190
190
191 # :flag.usage
191 # :flag.usage
192 printf " %s\n" "--arg-rc-version ARG_RC_VERSION"
192 printf " %s\n" "--arg-rc-version ARG_RC_VERSION"
193 printf " specify version to install, e.g 5.0.1\n"
193 printf " specify version to install, e.g 5.0.1\n"
194 echo
194 echo
195
195
196 # :flag.usage
196 # :flag.usage
197 printf " %s\n" "--arg-hostname ARG_HOSTNAME"
197 printf " %s\n" "--arg-hostname ARG_HOSTNAME"
198 printf " specify hostname [hostname.example.com] for setup\n"
198 printf " specify hostname [hostname.example.com] for setup\n"
199 echo
199 echo
200
200
201 # :flag.usage
201 # :flag.usage
202 printf " %s\n" "--arg-database-type ARG_DATABASE_TYPE"
202 printf " %s\n" "--arg-database-type ARG_DATABASE_TYPE"
203 printf " pick database type for installation, 'postgres', 'mysql', 'none', choose\n none for sqlite or own DB hosting\n"
203 printf " pick database type for installation, 'postgres', 'mysql', 'none', choose\n none for sqlite or own DB hosting\n"
204 printf " Allowed: postgres, mysql, none\n"
204 printf " Allowed: postgres, mysql, none\n"
205 echo
205 echo
206
206
207 # :flag.usage
207 # :flag.usage
208 printf " %s\n" "--arg-use-ssl ARG_USE_SSL"
208 printf " %s\n" "--arg-use-ssl ARG_USE_SSL"
209 printf " specify use_ssl [y|n] for setup\n"
209 printf " specify use_ssl [y|n] for setup\n"
210 printf " Allowed: y, n\n"
210 printf " Allowed: y, n\n"
211 echo
211 echo
212
212
213 # :flag.usage
213 # :flag.usage
214 printf " %s\n" "--arg-admin-email ARG_ADMIN_EMAIL"
214 printf " %s\n" "--arg-admin-email ARG_ADMIN_EMAIL"
215 printf " specify admin_email [foo@example.com] for setup\n"
215 printf " specify admin_email [foo@example.com] for setup\n"
216 echo
216 echo
217
217
218 # :flag.usage
218 # :flag.usage
219 printf " %s\n" "--arg-admin-user ARG_ADMIN_USER"
219 printf " %s\n" "--arg-admin-user ARG_ADMIN_USER"
220 printf " specify admin_user [admin] for setup\n"
220 printf " specify admin_user [admin] for setup\n"
221 echo
221 echo
222
222
223 # :flag.usage
223 # :flag.usage
224 printf " %s\n" "--arg-admin-pass ARG_ADMIN_PASS"
224 printf " %s\n" "--arg-admin-pass ARG_ADMIN_PASS"
225 printf " specify admin_pass [secretpassword] for setup\n"
225 printf " specify admin_pass [secretpassword] for setup\n"
226 echo
226 echo
227
227
228 # :flag.usage
228 # :flag.usage
229 printf " %s\n" "--arg-license-token ARG_ADMIN_TOKEN"
229 printf " %s\n" "--arg-license-token ARG_ADMIN_TOKEN"
230 printf " specify license_token [abcd-abcd-abcd-abcd] for setup\n"
230 printf " specify license_token [abcd-abcd-abcd-abcd] for setup\n"
231 echo
231 echo
232
232
233 # :flag.usage
233 # :flag.usage
234 printf " %s\n" "--no-prompt"
234 printf " %s\n" "--no-prompt"
235 printf " Don't use interactive prompt to ask setup questions. Use defaults instead\n"
235 printf " Don't use interactive prompt to ask setup questions. Use defaults instead\n"
236 echo
236 echo
237
237
238 # :flag.usage
238 # :flag.usage
239 printf " %s\n" "--force, -f"
239 printf " %s\n" "--force, -f"
240 printf " Overwrite existing files\n"
240 printf " Overwrite existing files\n"
241 echo
241 echo
242
242
243 # :flag.usage
243 # :flag.usage
244 printf " %s\n" "--stage STAGE (repeatable)"
244 printf " %s\n" "--stage STAGE (repeatable)"
245 printf " specify one or more stages to run\n"
245 printf " specify one or more stages to run, e.g --force --stage\n bootstrap_v1_docker_install\n"
246 echo
246 echo
247
247
248 # :flag.usage
248 # :flag.usage
249 printf " %s\n" "--docker-revision DOCKER_REVISION"
249 printf " %s\n" "--docker-revision DOCKER_REVISION"
250 printf " revision to fetch new docker definitions.\n"
250 printf " revision to fetch new docker definitions.\n"
251 printf " Default: stable\n"
251 printf " Default: stable\n"
252 echo
252 echo
253
253
254 # :flag.usage
254 # :flag.usage
255 printf " %s\n" "--install-docker INSTALL_DOCKER"
255 printf " %s\n" "--install-docker INSTALL_DOCKER"
256 printf " answer [y]es or [n]o to question to install docker\n"
256 printf " answer [y]es or [n]o to question to install docker\n"
257 echo
257 echo
258
258
259 # :flag.usage
259 # :flag.usage
260 printf " %s\n" "--server-url SERVER_URL"
260 printf " %s\n" "--server-url SERVER_URL"
261 printf " Specify RhodeCode server location where the rcstack archive should be\n downloaded from\n"
261 printf " Specify RhodeCode server location where the rcstack archive should be\n downloaded from\n"
262 printf " Default: https://dls.rhodecode.com/get_archive\n"
262 printf " Default: https://dls.rhodecode.com/get_archive\n"
263 echo
263 echo
264
264
265 # :flag.usage
265 # :flag.usage
266 printf " %s\n" "--auth-token AUTH_TOKEN"
266 printf " %s\n" "--auth-token AUTH_TOKEN"
267 printf " Optionally specify AUTH TOKEN to obtain sources\n"
267 printf " Optionally specify AUTH TOKEN to obtain sources\n"
268 echo
268 echo
269
269
270 # :command.usage_fixed_flags
270 # :command.usage_fixed_flags
271 printf " %s\n" "--help, -h"
271 printf " %s\n" "--help, -h"
272 printf " Show this help\n"
272 printf " Show this help\n"
273 echo
273 echo
274
274
275 # :command.usage_examples
275 # :command.usage_examples
276 printf "%s\n" "Examples:"
276 printf "%s\n" "Examples:"
277 printf " - ./rcstack init\n - ./rcstack init --force\n # non-interactive mode to say yes to install docker question [n] always does\n not install docker\n - ./rcstack init --install-docker=y\n # non-interactive mode to answer setup questions use --help to check all\n --arg-NAME options\n - ./rcstack init --install-docker=y --arg-hostname=docker-dev --arg-use-ssl=n\n --arg-rc-edition=ee\n"
277 printf " - ./rcstack init\n - ./rcstack init --force\n # non-interactive mode to say yes to install docker question [n] always does\n not install docker\n - ./rcstack init --install-docker=y\n # non-interactive mode to answer setup questions use --help to check all\n --arg-NAME options\n - ./rcstack init --install-docker=y --arg-hostname=docker-dev --arg-use-ssl=n\n --arg-rc-edition=ee\n"
278 echo
278 echo
279
279
280 fi
280 fi
281 }
281 }
282
282
283 # :command.usage
283 # :command.usage
284 rcstack_self_update_usage() {
284 rcstack_self_update_usage() {
285 if [[ -n $long_usage ]]; then
285 if [[ -n $long_usage ]]; then
286 printf "rcstack self-update - Update rcstack and it's docker definitions\n"
286 printf "rcstack self-update - Update rcstack and it's docker definitions\n"
287 echo
287 echo
288
288
289 else
289 else
290 printf "rcstack self-update - Update rcstack and it's docker definitions\n"
290 printf "rcstack self-update - Update rcstack and it's docker definitions\n"
291 echo
291 echo
292
292
293 fi
293 fi
294
294
295 printf "%s\n" "Usage:"
295 printf "%s\n" "Usage:"
296 printf " rcstack self-update [OPTIONS]\n"
296 printf " rcstack self-update [OPTIONS]\n"
297 printf " rcstack self-update --help | -h\n"
297 printf " rcstack self-update --help | -h\n"
298 echo
298 echo
299
299
300 # :command.long_usage
300 # :command.long_usage
301 if [[ -n $long_usage ]]; then
301 if [[ -n $long_usage ]]; then
302 printf "%s\n" "Options:"
302 printf "%s\n" "Options:"
303
303
304 # :command.usage_flags
304 # :command.usage_flags
305 # :flag.usage
305 # :flag.usage
306 printf " %s\n" "--force"
306 printf " %s\n" "--force"
307 printf " Ignore same-version skip check. Runs same logic as there would be new\n version available\n"
307 printf " Ignore same-version skip check. Runs same logic as there would be new\n version available\n"
308 echo
308 echo
309
309
310 # :flag.usage
310 # :flag.usage
311 printf " %s\n" "--update-docker-image UPDATE_DOCKER_IMAGE"
311 printf " %s\n" "--update-docker-image UPDATE_DOCKER_IMAGE"
312 printf " answer [y]es or [n]o to question to set docker image from installer stored\n version.\n"
312 printf " answer [y]es or [n]o to question to set docker image from installer stored\n version.\n"
313 echo
313 echo
314
314
315 # :flag.usage
315 # :flag.usage
316 printf " %s\n" "--cli-file CLI_FILE"
316 printf " %s\n" "--cli-file CLI_FILE"
317 printf " file path to fetch new rcstack cli tool.\n"
317 printf " file path to fetch new rcstack cli tool.\n"
318 echo
318 echo
319
319
320 # :flag.usage
320 # :flag.usage
321 printf " %s\n" "--cli-revision CLI_REVISION"
321 printf " %s\n" "--cli-revision CLI_REVISION"
322 printf " commit or branch to fetch new rcstack cli tool.\n"
322 printf " commit or branch to fetch new rcstack cli tool.\n"
323 printf " Default: stable\n"
323 printf " Default: stable\n"
324 echo
324 echo
325
325
326 # :flag.usage
326 # :flag.usage
327 printf " %s\n" "--docker-revision DOCKER_REVISION"
327 printf " %s\n" "--docker-revision DOCKER_REVISION"
328 printf " commit or branch to fetch new docker definitions.\n"
328 printf " commit or branch to fetch new docker definitions.\n"
329 printf " Default: stable\n"
329 printf " Default: stable\n"
330 echo
330 echo
331
331
332 # :flag.usage
332 # :flag.usage
333 printf " %s\n" "--server-url SERVER_URL"
333 printf " %s\n" "--server-url SERVER_URL"
334 printf " Specify RhodeCode server location where the rcstack archive should be\n downloaded from\n"
334 printf " Specify RhodeCode server location where the rcstack archive should be\n downloaded from\n"
335 printf " Default: https://dls.rhodecode.com/get_archive\n"
335 printf " Default: https://dls.rhodecode.com/get_archive\n"
336 echo
336 echo
337
337
338 # :flag.usage
338 # :flag.usage
339 printf " %s\n" "--auth-token AUTH_TOKEN"
339 printf " %s\n" "--auth-token AUTH_TOKEN"
340 printf " Optionally specify AUTH TOKEN to obtain sources\n"
340 printf " Optionally specify AUTH TOKEN to obtain sources\n"
341 echo
341 echo
342
342
343 # :command.usage_fixed_flags
343 # :command.usage_fixed_flags
344 printf " %s\n" "--help, -h"
344 printf " %s\n" "--help, -h"
345 printf " Show this help\n"
345 printf " Show this help\n"
346 echo
346 echo
347
347
348 # :command.usage_examples
348 # :command.usage_examples
349 printf "%s\n" "Examples:"
349 printf "%s\n" "Examples:"
350 printf " # simply to update it to a new version\n - ./rccstack self-update \n \n # to fetch dev branch and install it\n - ./rccstack self-update --cli-revision=master --docker-revision=master\n \n # In case rcstack breaks, you can re-download the stack script using curl\n curl -L -s -o rcstack https://dls.rhodecode.com/get/stable && chmod +x rcstack\n"
350 printf " # simply to update it to a new version\n - ./rccstack self-update \n \n # to fetch dev branch and install it\n - ./rccstack self-update --cli-revision=master --docker-revision=master\n \n # In case rcstack breaks, you can re-download the stack script using curl\n curl -L -s -o rcstack https://dls.rhodecode.com/get/stable && chmod +x rcstack\n"
351 echo
351 echo
352
352
353 fi
353 fi
354 }
354 }
355
355
356 # :command.usage
356 # :command.usage
357 rcstack_self_upgrade_usage() {
357 rcstack_self_upgrade_usage() {
358 if [[ -n $long_usage ]]; then
358 if [[ -n $long_usage ]]; then
359 printf "rcstack self-upgrade - Perform rcstack upgrade procedure. This aims at changing existing installations with some changes required that are not backward compatible\n"
359 printf "rcstack self-upgrade - Perform rcstack upgrade procedure. This aims at changing existing installations with some changes required that are not backward compatible\n"
360 echo
360 echo
361
361
362 else
362 else
363 printf "rcstack self-upgrade - Perform rcstack upgrade procedure. This aims at changing existing installations with some changes required that are not backward compatible\n"
363 printf "rcstack self-upgrade - Perform rcstack upgrade procedure. This aims at changing existing installations with some changes required that are not backward compatible\n"
364 echo
364 echo
365
365
366 fi
366 fi
367
367
368 printf "%s\n" "Usage:"
368 printf "%s\n" "Usage:"
369 printf " rcstack self-upgrade [OPTIONS]\n"
369 printf " rcstack self-upgrade [OPTIONS]\n"
370 printf " rcstack self-upgrade --help | -h\n"
370 printf " rcstack self-upgrade --help | -h\n"
371 echo
371 echo
372
372
373 # :command.long_usage
373 # :command.long_usage
374 if [[ -n $long_usage ]]; then
374 if [[ -n $long_usage ]]; then
375 printf "%s\n" "Options:"
375 printf "%s\n" "Options:"
376
376
377 # :command.usage_flags
377 # :command.usage_flags
378 # :flag.usage
378 # :flag.usage
379 printf " %s\n" "--from-ver FROM_VER"
379 printf " %s\n" "--from-ver FROM_VER"
380 printf " optionally define from which version we upgrade\n"
380 printf " optionally define from which version we upgrade\n"
381 echo
381 echo
382
382
383 # :flag.usage
383 # :flag.usage
384 printf " %s\n" "--to-ver TO_VER"
384 printf " %s\n" "--to-ver TO_VER"
385 printf " optionally define to which version we upgrade\n"
385 printf " optionally define to which version we upgrade\n"
386 echo
386 echo
387
387
388 # :command.usage_fixed_flags
388 # :command.usage_fixed_flags
389 printf " %s\n" "--help, -h"
389 printf " %s\n" "--help, -h"
390 printf " Show this help\n"
390 printf " Show this help\n"
391 echo
391 echo
392
392
393 # :command.usage_examples
393 # :command.usage_examples
394 printf "%s\n" "Examples:"
394 printf "%s\n" "Examples:"
395 printf " # simply to update it to a new version\n - ./rccstack self-upgrade \n \n # simply to update it to a new version\n - ./rccstack self-upgrade --from-ver=5.7.0 --to-ver=5.9.0\n"
395 printf " # simply to update it to a new version\n - ./rccstack self-upgrade \n \n # simply to update it to a new version\n - ./rccstack self-upgrade --from-ver=5.7.0 --to-ver=5.9.0\n"
396 echo
396 echo
397
397
398 fi
398 fi
399 }
399 }
400
400
401 # :command.usage
401 # :command.usage
402 rcstack_stack_usage() {
402 rcstack_stack_usage() {
403 if [[ -n $long_usage ]]; then
403 if [[ -n $long_usage ]]; then
404 printf "rcstack stack - Run one of available cluster stacks, run stack -h for more details\n"
404 printf "rcstack stack - Run one of available cluster stacks, run stack -h for more details\n"
405 echo
405 echo
406
406
407 else
407 else
408 printf "rcstack stack - Run one of available cluster stacks, run stack -h for more details\n"
408 printf "rcstack stack - Run one of available cluster stacks, run stack -h for more details\n"
409 echo
409 echo
410
410
411 fi
411 fi
412
412
413 printf "%s\n" "Usage:"
413 printf "%s\n" "Usage:"
414 printf " rcstack stack [OPTIONS] COMMAND\n"
414 printf " rcstack stack [OPTIONS] COMMAND\n"
415 printf " rcstack stack [COMMAND] --help | -h\n"
415 printf " rcstack stack [COMMAND] --help | -h\n"
416 echo
416 echo
417 # :command.usage_commands
417 # :command.usage_commands
418 printf "%s\n" "Commands:"
418 printf "%s\n" "Commands:"
419 printf " %s execute commands for the router stack\n" "router "
419 printf " %s execute commands for the router stack\n" "router "
420 printf " %s execute commands for the router stack\n" "metrics "
420 printf " %s execute commands for the router stack\n" "metrics "
421 printf " %s execute commands for the router stack\n" "services "
421 printf " %s execute commands for the router stack\n" "services "
422 printf " %s execute commands for the router stack\n" "rhodecode"
422 printf " %s execute commands for the router stack\n" "rhodecode"
423 printf " %s execute commands for all stacks in order\n" "all "
423 printf " %s execute commands for all stacks in order\n" "all "
424 echo
424 echo
425
425
426 # :command.long_usage
426 # :command.long_usage
427 if [[ -n $long_usage ]]; then
427 if [[ -n $long_usage ]]; then
428 printf "%s\n" "Options:"
428 printf "%s\n" "Options:"
429
429
430 # :command.usage_flags
430 # :command.usage_flags
431 # :flag.usage
431 # :flag.usage
432 printf " %s\n" "--env-file-path ENV_FILE_PATH"
432 printf " %s\n" "--env-file-path ENV_FILE_PATH"
433 printf " Set custom env file\n"
433 printf " Set custom env file\n"
434 printf " Default: $PWD/.custom/.runtime.env\n"
434 printf " Default: $PWD/.custom/.runtime.env\n"
435 echo
435 echo
436
436
437 # :flag.usage
437 # :flag.usage
438 printf " %s\n" "--stack-prefix STACK_PREFIX"
438 printf " %s\n" "--stack-prefix STACK_PREFIX"
439 printf " Set custom stack prefix, e.g rc_cluster_apps_ci\n"
439 printf " Set custom stack prefix, e.g rc_cluster_apps_ci\n"
440 echo
440 echo
441
441
442 # :command.usage_fixed_flags
442 # :command.usage_fixed_flags
443 printf " %s\n" "--help, -h"
443 printf " %s\n" "--help, -h"
444 printf " Show this help\n"
444 printf " Show this help\n"
445 echo
445 echo
446
446
447 # :command.usage_examples
447 # :command.usage_examples
448 printf "%s\n" "Examples:"
448 printf "%s\n" "Examples:"
449 printf " # running stack (example for router stack)\n - ./rcstack stack router up # run router stack with output to stdout\n - ./rcstack stack router up --detach # run router stack detached\n - ./rcstack stack router down # stop whole router stack\n - ./rcstack stack router restart # restart the stack\n - ./rcstack stack router ps # check status of router stack\n \n # logs, use logs -f to follow/tail --until 1h to limit for last time\n - ./rcstack stack services logs -f database\n \n # scale a single stack service[s] to more replicas (horizontally), use\n overrides files to permanently set scale\n - ./rcstack stack rhodecode up --detach --no-recreate --scale rhodecode=2\n --scale vcsserver=2\n \n # run router stack with your overrides compose file\n - ./rcstack stack router -f docker-overrides.yaml up -d\n \n # run command in the stack image\n - ./rcstack stack rhodecode run rhodecode bash\n"
449 printf " # running stack (example for router stack)\n - ./rcstack stack router up # run router stack with output to stdout\n - ./rcstack stack router up --detach # run router stack detached\n - ./rcstack stack router down # stop whole router stack\n - ./rcstack stack router restart # restart the stack\n - ./rcstack stack router ps # check status of router stack\n \n # logs, use logs -f to follow/tail --until 1h to limit for last time\n - ./rcstack stack services logs -f database\n \n # scale a single stack service[s] to more replicas (horizontally), use\n overrides files to permanently set scale\n - ./rcstack stack rhodecode up --detach --no-recreate --scale rhodecode=2\n --scale vcsserver=2\n \n # run router stack with your overrides compose file\n - ./rcstack stack router -f docker-overrides.yaml up -d\n \n # run command in the stack image\n - ./rcstack stack rhodecode run rhodecode bash\n"
450 echo
450 echo
451
451
452 fi
452 fi
453 }
453 }
454
454
455 # :command.usage
455 # :command.usage
456 rcstack_stack_router_usage() {
456 rcstack_stack_router_usage() {
457 if [[ -n $long_usage ]]; then
457 if [[ -n $long_usage ]]; then
458 printf "rcstack stack router - execute commands for the router stack\n"
458 printf "rcstack stack router - execute commands for the router stack\n"
459 echo
459 echo
460
460
461 else
461 else
462 printf "rcstack stack router - execute commands for the router stack\n"
462 printf "rcstack stack router - execute commands for the router stack\n"
463 echo
463 echo
464
464
465 fi
465 fi
466
466
467 printf "%s\n" "Usage:"
467 printf "%s\n" "Usage:"
468 printf " rcstack stack router [SERVICES PARAMS...]\n"
468 printf " rcstack stack router [SERVICES PARAMS...]\n"
469 printf " rcstack stack router --help | -h\n"
469 printf " rcstack stack router --help | -h\n"
470 echo
470 echo
471
471
472 # :command.long_usage
472 # :command.long_usage
473 if [[ -n $long_usage ]]; then
473 if [[ -n $long_usage ]]; then
474 printf "%s\n" "Options:"
474 printf "%s\n" "Options:"
475
475
476 # :command.usage_fixed_flags
476 # :command.usage_fixed_flags
477 printf " %s\n" "--help, -h"
477 printf " %s\n" "--help, -h"
478 printf " Show this help\n"
478 printf " Show this help\n"
479 echo
479 echo
480
480
481 # :command.usage_args
481 # :command.usage_args
482 printf "%s\n" "Arguments:"
482 printf "%s\n" "Arguments:"
483
483
484 echo " SERVICES PARAMS..."
484 echo " SERVICES PARAMS..."
485 printf " Additional arguments or flags for services command\n"
485 printf " Additional arguments or flags for services command\n"
486 echo
486 echo
487
487
488 fi
488 fi
489 }
489 }
490
490
491 # :command.usage
491 # :command.usage
492 rcstack_stack_metrics_usage() {
492 rcstack_stack_metrics_usage() {
493 if [[ -n $long_usage ]]; then
493 if [[ -n $long_usage ]]; then
494 printf "rcstack stack metrics - execute commands for the router stack\n"
494 printf "rcstack stack metrics - execute commands for the router stack\n"
495 echo
495 echo
496
496
497 else
497 else
498 printf "rcstack stack metrics - execute commands for the router stack\n"
498 printf "rcstack stack metrics - execute commands for the router stack\n"
499 echo
499 echo
500
500
501 fi
501 fi
502
502
503 printf "%s\n" "Usage:"
503 printf "%s\n" "Usage:"
504 printf " rcstack stack metrics [SERVICES PARAMS...]\n"
504 printf " rcstack stack metrics [SERVICES PARAMS...]\n"
505 printf " rcstack stack metrics --help | -h\n"
505 printf " rcstack stack metrics --help | -h\n"
506 echo
506 echo
507
507
508 # :command.long_usage
508 # :command.long_usage
509 if [[ -n $long_usage ]]; then
509 if [[ -n $long_usage ]]; then
510 printf "%s\n" "Options:"
510 printf "%s\n" "Options:"
511
511
512 # :command.usage_fixed_flags
512 # :command.usage_fixed_flags
513 printf " %s\n" "--help, -h"
513 printf " %s\n" "--help, -h"
514 printf " Show this help\n"
514 printf " Show this help\n"
515 echo
515 echo
516
516
517 # :command.usage_args
517 # :command.usage_args
518 printf "%s\n" "Arguments:"
518 printf "%s\n" "Arguments:"
519
519
520 echo " SERVICES PARAMS..."
520 echo " SERVICES PARAMS..."
521 printf " Additional arguments or flags for services command\n"
521 printf " Additional arguments or flags for services command\n"
522 echo
522 echo
523
523
524 fi
524 fi
525 }
525 }
526
526
527 # :command.usage
527 # :command.usage
528 rcstack_stack_services_usage() {
528 rcstack_stack_services_usage() {
529 if [[ -n $long_usage ]]; then
529 if [[ -n $long_usage ]]; then
530 printf "rcstack stack services - execute commands for the router stack\n"
530 printf "rcstack stack services - execute commands for the router stack\n"
531 echo
531 echo
532
532
533 else
533 else
534 printf "rcstack stack services - execute commands for the router stack\n"
534 printf "rcstack stack services - execute commands for the router stack\n"
535 echo
535 echo
536
536
537 fi
537 fi
538
538
539 printf "%s\n" "Usage:"
539 printf "%s\n" "Usage:"
540 printf " rcstack stack services [SERVICES PARAMS...]\n"
540 printf " rcstack stack services [SERVICES PARAMS...]\n"
541 printf " rcstack stack services --help | -h\n"
541 printf " rcstack stack services --help | -h\n"
542 echo
542 echo
543
543
544 # :command.long_usage
544 # :command.long_usage
545 if [[ -n $long_usage ]]; then
545 if [[ -n $long_usage ]]; then
546 printf "%s\n" "Options:"
546 printf "%s\n" "Options:"
547
547
548 # :command.usage_fixed_flags
548 # :command.usage_fixed_flags
549 printf " %s\n" "--help, -h"
549 printf " %s\n" "--help, -h"
550 printf " Show this help\n"
550 printf " Show this help\n"
551 echo
551 echo
552
552
553 # :command.usage_args
553 # :command.usage_args
554 printf "%s\n" "Arguments:"
554 printf "%s\n" "Arguments:"
555
555
556 echo " SERVICES PARAMS..."
556 echo " SERVICES PARAMS..."
557 printf " Additional arguments or flags for services command\n"
557 printf " Additional arguments or flags for services command\n"
558 echo
558 echo
559
559
560 fi
560 fi
561 }
561 }
562
562
563 # :command.usage
563 # :command.usage
564 rcstack_stack_rhodecode_usage() {
564 rcstack_stack_rhodecode_usage() {
565 if [[ -n $long_usage ]]; then
565 if [[ -n $long_usage ]]; then
566 printf "rcstack stack rhodecode - execute commands for the router stack\n"
566 printf "rcstack stack rhodecode - execute commands for the router stack\n"
567 echo
567 echo
568
568
569 else
569 else
570 printf "rcstack stack rhodecode - execute commands for the router stack\n"
570 printf "rcstack stack rhodecode - execute commands for the router stack\n"
571 echo
571 echo
572
572
573 fi
573 fi
574
574
575 printf "%s\n" "Usage:"
575 printf "%s\n" "Usage:"
576 printf " rcstack stack rhodecode [SERVICES PARAMS...]\n"
576 printf " rcstack stack rhodecode [SERVICES PARAMS...]\n"
577 printf " rcstack stack rhodecode --help | -h\n"
577 printf " rcstack stack rhodecode --help | -h\n"
578 echo
578 echo
579
579
580 # :command.long_usage
580 # :command.long_usage
581 if [[ -n $long_usage ]]; then
581 if [[ -n $long_usage ]]; then
582 printf "%s\n" "Options:"
582 printf "%s\n" "Options:"
583
583
584 # :command.usage_fixed_flags
584 # :command.usage_fixed_flags
585 printf " %s\n" "--help, -h"
585 printf " %s\n" "--help, -h"
586 printf " Show this help\n"
586 printf " Show this help\n"
587 echo
587 echo
588
588
589 # :command.usage_args
589 # :command.usage_args
590 printf "%s\n" "Arguments:"
590 printf "%s\n" "Arguments:"
591
591
592 echo " SERVICES PARAMS..."
592 echo " SERVICES PARAMS..."
593 printf " Additional arguments or flags for services command\n"
593 printf " Additional arguments or flags for services command\n"
594 echo
594 echo
595
595
596 fi
596 fi
597 }
597 }
598
598
599 # :command.usage
599 # :command.usage
600 rcstack_stack_all_usage() {
600 rcstack_stack_all_usage() {
601 if [[ -n $long_usage ]]; then
601 if [[ -n $long_usage ]]; then
602 printf "rcstack stack all - execute commands for all stacks in order\n"
602 printf "rcstack stack all - execute commands for all stacks in order\n"
603 echo
603 echo
604
604
605 else
605 else
606 printf "rcstack stack all - execute commands for all stacks in order\n"
606 printf "rcstack stack all - execute commands for all stacks in order\n"
607 echo
607 echo
608
608
609 fi
609 fi
610
610
611 printf "%s\n" "Usage:"
611 printf "%s\n" "Usage:"
612 printf " rcstack stack all [SERVICES PARAMS...]\n"
612 printf " rcstack stack all [SERVICES PARAMS...]\n"
613 printf " rcstack stack all --help | -h\n"
613 printf " rcstack stack all --help | -h\n"
614 echo
614 echo
615
615
616 # :command.long_usage
616 # :command.long_usage
617 if [[ -n $long_usage ]]; then
617 if [[ -n $long_usage ]]; then
618 printf "%s\n" "Options:"
618 printf "%s\n" "Options:"
619
619
620 # :command.usage_fixed_flags
620 # :command.usage_fixed_flags
621 printf " %s\n" "--help, -h"
621 printf " %s\n" "--help, -h"
622 printf " Show this help\n"
622 printf " Show this help\n"
623 echo
623 echo
624
624
625 # :command.usage_args
625 # :command.usage_args
626 printf "%s\n" "Arguments:"
626 printf "%s\n" "Arguments:"
627
627
628 echo " SERVICES PARAMS..."
628 echo " SERVICES PARAMS..."
629 printf " Additional arguments or flags for services command\n"
629 printf " Additional arguments or flags for services command\n"
630 echo
630 echo
631
631
632 fi
632 fi
633 }
633 }
634
634
635 # :command.usage
635 # :command.usage
636 rcstack_stack_status_usage() {
636 rcstack_stack_status_usage() {
637 if [[ -n $long_usage ]]; then
637 if [[ -n $long_usage ]]; then
638 printf "rcstack stack-status - Show stack status\n"
638 printf "rcstack stack-status - Show stack status\n"
639 echo
639 echo
640
640
641 else
641 else
642 printf "rcstack stack-status - Show stack status\n"
642 printf "rcstack stack-status - Show stack status\n"
643 echo
643 echo
644
644
645 fi
645 fi
646
646
647 printf "Alias: status\n"
647 printf "Alias: status\n"
648 echo
648 echo
649
649
650 printf "%s\n" "Usage:"
650 printf "%s\n" "Usage:"
651 printf " rcstack stack-status [OPTIONS]\n"
651 printf " rcstack stack-status [OPTIONS]\n"
652 printf " rcstack stack-status --help | -h\n"
652 printf " rcstack stack-status --help | -h\n"
653 echo
653 echo
654
654
655 # :command.long_usage
655 # :command.long_usage
656 if [[ -n $long_usage ]]; then
656 if [[ -n $long_usage ]]; then
657 printf "%s\n" "Options:"
657 printf "%s\n" "Options:"
658
658
659 # :command.usage_flags
659 # :command.usage_flags
660 # :flag.usage
660 # :flag.usage
661 printf " %s\n" "--detailed"
661 printf " %s\n" "--detailed"
662 printf " Display a detailed format\n"
662 printf " Display a detailed format\n"
663 echo
663 echo
664
664
665 # :flag.usage
665 # :flag.usage
666 printf " %s\n" "--configs, -c"
666 printf " %s\n" "--configs, -c"
667 printf " Display a detailed info about configuration files\n"
667 printf " Display a detailed info about configuration files\n"
668 echo
668 echo
669
669
670 # :flag.usage
670 # :flag.usage
671 printf " %s\n" "--verbose, -v"
671 printf " %s\n" "--verbose, -v"
672 printf " Verbose output for details on the stack\n"
672 printf " Verbose output for details on the stack\n"
673 echo
673 echo
674
674
675 # :command.usage_fixed_flags
675 # :command.usage_fixed_flags
676 printf " %s\n" "--help, -h"
676 printf " %s\n" "--help, -h"
677 printf " Show this help\n"
677 printf " Show this help\n"
678 echo
678 echo
679
679
680 fi
680 fi
681 }
681 }
682
682
683 # :command.usage
683 # :command.usage
684 rcstack_stack_upgrade_usage() {
684 rcstack_stack_upgrade_usage() {
685 if [[ -n $long_usage ]]; then
685 if [[ -n $long_usage ]]; then
686 printf "rcstack stack-upgrade - Upgrade a stack, run stack-upgrade -h for more details\n"
686 printf "rcstack stack-upgrade - Upgrade a stack, run stack-upgrade -h for more details\n"
687 echo
687 echo
688
688
689 else
689 else
690 printf "rcstack stack-upgrade - Upgrade a stack, run stack-upgrade -h for more details\n"
690 printf "rcstack stack-upgrade - Upgrade a stack, run stack-upgrade -h for more details\n"
691 echo
691 echo
692
692
693 fi
693 fi
694
694
695 printf "%s\n" "Usage:"
695 printf "%s\n" "Usage:"
696 printf " rcstack stack-upgrade [OPTIONS] COMMAND\n"
696 printf " rcstack stack-upgrade [OPTIONS] COMMAND\n"
697 printf " rcstack stack-upgrade [COMMAND] --help | -h\n"
697 printf " rcstack stack-upgrade [COMMAND] --help | -h\n"
698 echo
698 echo
699 # :command.usage_commands
699 # :command.usage_commands
700 printf "%s\n" "Commands:"
700 printf "%s\n" "Commands:"
701 printf " %s upgrade the router stack\n" "router "
701 printf " %s upgrade the router stack\n" "router "
702 printf " %s upgrade the services stack\n" "services "
702 printf " %s upgrade the services stack\n" "services "
703 printf " %s upgrade the metrics stack\n" "metrics "
703 printf " %s upgrade the metrics stack\n" "metrics "
704 printf " %s upgrade the rhodecode stack\n" "rhodecode"
704 printf " %s upgrade the rhodecode stack\n" "rhodecode"
705 echo
705 echo
706
706
707 # :command.long_usage
707 # :command.long_usage
708 if [[ -n $long_usage ]]; then
708 if [[ -n $long_usage ]]; then
709 printf "%s\n" "Options:"
709 printf "%s\n" "Options:"
710
710
711 # :command.usage_flags
711 # :command.usage_flags
712 # :flag.usage
712 # :flag.usage
713 printf " %s\n" "--stack-prefix STACK_PREFIX"
713 printf " %s\n" "--stack-prefix STACK_PREFIX"
714 printf " Set custom stack prefix, e.g rc_cluster_apps_ci\n"
714 printf " Set custom stack prefix, e.g rc_cluster_apps_ci\n"
715 echo
715 echo
716
716
717 # :command.usage_fixed_flags
717 # :command.usage_fixed_flags
718 printf " %s\n" "--help, -h"
718 printf " %s\n" "--help, -h"
719 printf " Show this help\n"
719 printf " Show this help\n"
720 echo
720 echo
721
721
722 # :command.usage_examples
722 # :command.usage_examples
723 printf "%s\n" "Examples:"
723 printf "%s\n" "Examples:"
724 printf " # Upgrading stack\n - ./rcstack stack-upgrade router\n \n # RhodeCode stack upgrades with 0 downtime using container rotation\n - ./rcstack stack-upgrade rhodecode\n \n # RhodeCode stack upgrades with fast container restart recycle, might cause\n slight downtime\n - ./rcstack stack-upgrade rhodecode --stop-wait=10 --docker-stop-wait=5\n"
724 printf " # Upgrading stack\n - ./rcstack stack-upgrade router\n \n # RhodeCode stack upgrades with 0 downtime using container rotation\n - ./rcstack stack-upgrade rhodecode\n \n # RhodeCode stack upgrades with fast container restart recycle, might cause\n slight downtime\n - ./rcstack stack-upgrade rhodecode --stop-wait=10 --docker-stop-wait=5\n"
725 echo
725 echo
726
726
727 fi
727 fi
728 }
728 }
729
729
730 # :command.usage
730 # :command.usage
731 rcstack_stack_upgrade_router_usage() {
731 rcstack_stack_upgrade_router_usage() {
732 if [[ -n $long_usage ]]; then
732 if [[ -n $long_usage ]]; then
733 printf "rcstack stack-upgrade router - upgrade the router stack\n"
733 printf "rcstack stack-upgrade router - upgrade the router stack\n"
734 echo
734 echo
735
735
736 else
736 else
737 printf "rcstack stack-upgrade router - upgrade the router stack\n"
737 printf "rcstack stack-upgrade router - upgrade the router stack\n"
738 echo
738 echo
739
739
740 fi
740 fi
741
741
742 printf "%s\n" "Usage:"
742 printf "%s\n" "Usage:"
743 printf " rcstack stack-upgrade router\n"
743 printf " rcstack stack-upgrade router\n"
744 printf " rcstack stack-upgrade router --help | -h\n"
744 printf " rcstack stack-upgrade router --help | -h\n"
745 echo
745 echo
746
746
747 # :command.long_usage
747 # :command.long_usage
748 if [[ -n $long_usage ]]; then
748 if [[ -n $long_usage ]]; then
749 printf "%s\n" "Options:"
749 printf "%s\n" "Options:"
750
750
751 # :command.usage_fixed_flags
751 # :command.usage_fixed_flags
752 printf " %s\n" "--help, -h"
752 printf " %s\n" "--help, -h"
753 printf " Show this help\n"
753 printf " Show this help\n"
754 echo
754 echo
755
755
756 fi
756 fi
757 }
757 }
758
758
759 # :command.usage
759 # :command.usage
760 rcstack_stack_upgrade_services_usage() {
760 rcstack_stack_upgrade_services_usage() {
761 if [[ -n $long_usage ]]; then
761 if [[ -n $long_usage ]]; then
762 printf "rcstack stack-upgrade services - upgrade the services stack\n"
762 printf "rcstack stack-upgrade services - upgrade the services stack\n"
763 echo
763 echo
764
764
765 else
765 else
766 printf "rcstack stack-upgrade services - upgrade the services stack\n"
766 printf "rcstack stack-upgrade services - upgrade the services stack\n"
767 echo
767 echo
768
768
769 fi
769 fi
770
770
771 printf "%s\n" "Usage:"
771 printf "%s\n" "Usage:"
772 printf " rcstack stack-upgrade services\n"
772 printf " rcstack stack-upgrade services\n"
773 printf " rcstack stack-upgrade services --help | -h\n"
773 printf " rcstack stack-upgrade services --help | -h\n"
774 echo
774 echo
775
775
776 # :command.long_usage
776 # :command.long_usage
777 if [[ -n $long_usage ]]; then
777 if [[ -n $long_usage ]]; then
778 printf "%s\n" "Options:"
778 printf "%s\n" "Options:"
779
779
780 # :command.usage_fixed_flags
780 # :command.usage_fixed_flags
781 printf " %s\n" "--help, -h"
781 printf " %s\n" "--help, -h"
782 printf " Show this help\n"
782 printf " Show this help\n"
783 echo
783 echo
784
784
785 fi
785 fi
786 }
786 }
787
787
788 # :command.usage
788 # :command.usage
789 rcstack_stack_upgrade_metrics_usage() {
789 rcstack_stack_upgrade_metrics_usage() {
790 if [[ -n $long_usage ]]; then
790 if [[ -n $long_usage ]]; then
791 printf "rcstack stack-upgrade metrics - upgrade the metrics stack\n"
791 printf "rcstack stack-upgrade metrics - upgrade the metrics stack\n"
792 echo
792 echo
793
793
794 else
794 else
795 printf "rcstack stack-upgrade metrics - upgrade the metrics stack\n"
795 printf "rcstack stack-upgrade metrics - upgrade the metrics stack\n"
796 echo
796 echo
797
797
798 fi
798 fi
799
799
800 printf "%s\n" "Usage:"
800 printf "%s\n" "Usage:"
801 printf " rcstack stack-upgrade metrics\n"
801 printf " rcstack stack-upgrade metrics\n"
802 printf " rcstack stack-upgrade metrics --help | -h\n"
802 printf " rcstack stack-upgrade metrics --help | -h\n"
803 echo
803 echo
804
804
805 # :command.long_usage
805 # :command.long_usage
806 if [[ -n $long_usage ]]; then
806 if [[ -n $long_usage ]]; then
807 printf "%s\n" "Options:"
807 printf "%s\n" "Options:"
808
808
809 # :command.usage_fixed_flags
809 # :command.usage_fixed_flags
810 printf " %s\n" "--help, -h"
810 printf " %s\n" "--help, -h"
811 printf " Show this help\n"
811 printf " Show this help\n"
812 echo
812 echo
813
813
814 fi
814 fi
815 }
815 }
816
816
817 # :command.usage
817 # :command.usage
818 rcstack_stack_upgrade_rhodecode_usage() {
818 rcstack_stack_upgrade_rhodecode_usage() {
819 if [[ -n $long_usage ]]; then
819 if [[ -n $long_usage ]]; then
820 printf "rcstack stack-upgrade rhodecode - upgrade the rhodecode stack\n"
820 printf "rcstack stack-upgrade rhodecode - upgrade the rhodecode stack\n"
821 echo
821 echo
822
822
823 else
823 else
824 printf "rcstack stack-upgrade rhodecode - upgrade the rhodecode stack\n"
824 printf "rcstack stack-upgrade rhodecode - upgrade the rhodecode stack\n"
825 echo
825 echo
826
826
827 fi
827 fi
828
828
829 printf "%s\n" "Usage:"
829 printf "%s\n" "Usage:"
830 printf " rcstack stack-upgrade rhodecode [OPTIONS]\n"
830 printf " rcstack stack-upgrade rhodecode [OPTIONS]\n"
831 printf " rcstack stack-upgrade rhodecode --help | -h\n"
831 printf " rcstack stack-upgrade rhodecode --help | -h\n"
832 echo
832 echo
833
833
834 # :command.long_usage
834 # :command.long_usage
835 if [[ -n $long_usage ]]; then
835 if [[ -n $long_usage ]]; then
836 printf "%s\n" "Options:"
836 printf "%s\n" "Options:"
837
837
838 # :command.usage_flags
838 # :command.usage_flags
839 # :flag.usage
839 # :flag.usage
840 printf " %s\n" "--stop-wait STOP_WAIT"
840 printf " %s\n" "--stop-wait STOP_WAIT"
841 printf " Number of seconds to wait for stopping old containers, use low value to\n quickly restart and recycle containers\n"
841 printf " Number of seconds to wait for stopping old containers, use low value to\n quickly restart and recycle containers\n"
842 printf " Default: 120\n"
842 printf " Default: 120\n"
843 echo
843 echo
844
844
845 # :flag.usage
845 # :flag.usage
846 printf " %s\n" "--docker-stop-wait DOCKER_STOP_WAIT"
846 printf " %s\n" "--docker-stop-wait DOCKER_STOP_WAIT"
847 printf " Number of seconds to pass to docker stop command that will wait for\n container to gracefully stop\n"
847 printf " Number of seconds to pass to docker stop command that will wait for\n container to gracefully stop\n"
848 printf " Default: 3600\n"
848 printf " Default: 3600\n"
849 echo
849 echo
850
850
851 # :command.usage_fixed_flags
851 # :command.usage_fixed_flags
852 printf " %s\n" "--help, -h"
852 printf " %s\n" "--help, -h"
853 printf " Show this help\n"
853 printf " Show this help\n"
854 echo
854 echo
855
855
856 fi
856 fi
857 }
857 }
858
858
859 # :command.usage
859 # :command.usage
860 rcstack_stack_monitor_usage() {
860 rcstack_stack_monitor_usage() {
861 if [[ -n $long_usage ]]; then
861 if [[ -n $long_usage ]]; then
862 printf "rcstack stack-monitor - run monitoring on stack items\n"
862 printf "rcstack stack-monitor - run monitoring on stack items\n"
863 echo
863 echo
864
864
865 else
865 else
866 printf "rcstack stack-monitor - run monitoring on stack items\n"
866 printf "rcstack stack-monitor - run monitoring on stack items\n"
867 echo
867 echo
868
868
869 fi
869 fi
870
870
871 printf "%s\n" "Usage:"
871 printf "%s\n" "Usage:"
872 printf " rcstack stack-monitor COMMAND\n"
872 printf " rcstack stack-monitor COMMAND\n"
873 printf " rcstack stack-monitor [COMMAND] --help | -h\n"
873 printf " rcstack stack-monitor [COMMAND] --help | -h\n"
874 echo
874 echo
875 # :command.usage_commands
875 # :command.usage_commands
876 printf "%s\n" "Stack Commands:"
876 printf "%s\n" "Stack Commands:"
877 printf " %s monitor stack containers that are unhealthy and restart them\n" "restart-unhealthy"
877 printf " %s monitor stack containers that are unhealthy and restart them\n" "restart-unhealthy"
878 echo
878 echo
879
879
880 # :command.long_usage
880 # :command.long_usage
881 if [[ -n $long_usage ]]; then
881 if [[ -n $long_usage ]]; then
882 printf "%s\n" "Options:"
882 printf "%s\n" "Options:"
883
883
884 # :command.usage_fixed_flags
884 # :command.usage_fixed_flags
885 printf " %s\n" "--help, -h"
885 printf " %s\n" "--help, -h"
886 printf " Show this help\n"
886 printf " Show this help\n"
887 echo
887 echo
888
888
889 fi
889 fi
890 }
890 }
891
891
892 # :command.usage
892 # :command.usage
893 rcstack_stack_monitor_restart_unhealthy_usage() {
893 rcstack_stack_monitor_restart_unhealthy_usage() {
894 if [[ -n $long_usage ]]; then
894 if [[ -n $long_usage ]]; then
895 printf "rcstack stack-monitor restart-unhealthy - monitor stack containers that are unhealthy and restart them\n"
895 printf "rcstack stack-monitor restart-unhealthy - monitor stack containers that are unhealthy and restart them\n"
896 echo
896 echo
897
897
898 else
898 else
899 printf "rcstack stack-monitor restart-unhealthy - monitor stack containers that are unhealthy and restart them\n"
899 printf "rcstack stack-monitor restart-unhealthy - monitor stack containers that are unhealthy and restart them\n"
900 echo
900 echo
901
901
902 fi
902 fi
903
903
904 printf "%s\n" "Usage:"
904 printf "%s\n" "Usage:"
905 printf " rcstack stack-monitor restart-unhealthy [OPTIONS]\n"
905 printf " rcstack stack-monitor restart-unhealthy [OPTIONS]\n"
906 printf " rcstack stack-monitor restart-unhealthy --help | -h\n"
906 printf " rcstack stack-monitor restart-unhealthy --help | -h\n"
907 echo
907 echo
908
908
909 # :command.long_usage
909 # :command.long_usage
910 if [[ -n $long_usage ]]; then
910 if [[ -n $long_usage ]]; then
911 printf "%s\n" "Options:"
911 printf "%s\n" "Options:"
912
912
913 # :command.usage_flags
913 # :command.usage_flags
914 # :flag.usage
914 # :flag.usage
915 printf " %s\n" "--loop LOOP"
915 printf " %s\n" "--loop LOOP"
916 printf " run in a loop to monitor continuously every N seconds\n"
916 printf " run in a loop to monitor continuously every N seconds\n"
917 printf " Default: 0\n"
917 printf " Default: 0\n"
918 echo
918 echo
919
919
920 # :command.usage_fixed_flags
920 # :command.usage_fixed_flags
921 printf " %s\n" "--help, -h"
921 printf " %s\n" "--help, -h"
922 printf " Show this help\n"
922 printf " Show this help\n"
923 echo
923 echo
924
924
925 # :command.usage_examples
925 # :command.usage_examples
926 printf "%s\n" "Examples:"
926 printf "%s\n" "Examples:"
927 printf " # check and restart for unhealthy containers\n ./rcstack stack-monitor restart-unhealthy\n \n # check and restart for unhealthy containers, and continue in a loop every 5\n minutes (300s)\n ./rcstack stack-monitor restart-unhealthy --loop=300\n \n # run this script in background with logs\n nohup ./rcstack stack-monitor restart-unhealthy --loop=300 >\n unhealthy-checks.log &\n"
927 printf " # check and restart for unhealthy containers\n ./rcstack stack-monitor restart-unhealthy\n \n # check and restart for unhealthy containers, and continue in a loop every 5\n minutes (300s)\n ./rcstack stack-monitor restart-unhealthy --loop=300\n \n # run this script in background with logs\n nohup ./rcstack stack-monitor restart-unhealthy --loop=300 >\n unhealthy-checks.log &\n"
928 echo
928 echo
929
929
930 fi
930 fi
931 }
931 }
932
932
933 # :command.usage
933 # :command.usage
934 rcstack_cli_usage() {
934 rcstack_cli_usage() {
935 if [[ -n $long_usage ]]; then
935 if [[ -n $long_usage ]]; then
936 printf "rcstack cli - Various CLI tools, run cli -h for more details\n"
936 printf "rcstack cli - Various CLI tools, run cli -h for more details\n"
937 echo
937 echo
938
938
939 else
939 else
940 printf "rcstack cli - Various CLI tools, run cli -h for more details\n"
940 printf "rcstack cli - Various CLI tools, run cli -h for more details\n"
941 echo
941 echo
942
942
943 fi
943 fi
944
944
945 printf "%s\n" "Usage:"
945 printf "%s\n" "Usage:"
946 printf " rcstack cli COMMAND\n"
946 printf " rcstack cli COMMAND\n"
947 printf " rcstack cli [COMMAND] --help | -h\n"
947 printf " rcstack cli [COMMAND] --help | -h\n"
948 echo
948 echo
949 # :command.usage_commands
949 # :command.usage_commands
950 printf "%s\n" "Commands:"
950 printf "%s\n" "Commands:"
951 printf " %s run a custom command on top of docker image from RhodeCode\n" "cmd "
951 printf " %s run a custom command on top of docker image from RhodeCode\n" "cmd "
952 printf " %s ishell attached to running RhodeCode instance\n" "ishell "
952 printf " %s ishell attached to running RhodeCode instance\n" "ishell "
953 printf " %s print out stored docker image version\n" "image-info "
953 printf " %s print out stored docker image version\n" "image-info "
954 printf " %s set version to .runtime.env file\n" "set-runtime-image "
954 printf " %s set version to .runtime.env file\n" "set-image "
955 printf " %s get current docker info\n" "docker-info "
955 printf " %s get current docker info\n" "docker-info "
956 printf " %s force upgrade docker\n" "docker-upgrade "
956 printf " %s force upgrade docker\n" "docker-upgrade "
957 printf " %s CLI for Redis\n" "redis "
957 printf " %s CLI for Redis\n" "redis "
958 printf " %s CLI with Database connection\n" "db "
958 printf " %s CLI with Database connection\n" "db "
959 printf " %s CLI to run db upgrade\n" "db-upgrade "
959 printf " %s CLI to run db upgrade\n" "db-upgrade "
960 printf " %s CLI for repository storage. Exposes a basic image with mounted data and repositories volumes or attach to currently running containers storage\n" "storage "
960 printf " %s CLI for repository storage. Exposes a basic image with mounted data and repositories volumes or attach to currently running containers storage\n" "storage "
961 printf " %s attach to running instance of RhodeCode, by default it attaches to rhodecode main web app\n" "attach "
961 printf " %s attach to running instance of RhodeCode, by default it attaches to rhodecode main web app\n" "attach "
962 printf " %s set current setup to either CE (Community) or EE (Enterprise) type\n" "set-edition "
962 printf " %s set current setup to either CE (Community) or EE (Enterprise) type\n" "set-edition "
963 printf " %s reconfigure the vcsserver.ini file\n" "configure-vcsserver"
963 printf " %s reconfigure the vcsserver.ini file\n" "configure-vcsserver"
964 printf " %s reconfigure the rhodecode.ini file\n" "configure-rhodecode"
964 printf " %s reconfigure the rhodecode.ini file\n" "configure-rhodecode"
965 echo
965 echo
966
966
967 # :command.long_usage
967 # :command.long_usage
968 if [[ -n $long_usage ]]; then
968 if [[ -n $long_usage ]]; then
969 printf "%s\n" "Options:"
969 printf "%s\n" "Options:"
970
970
971 # :command.usage_fixed_flags
971 # :command.usage_fixed_flags
972 printf " %s\n" "--help, -h"
972 printf " %s\n" "--help, -h"
973 printf " Show this help\n"
973 printf " Show this help\n"
974 echo
974 echo
975
975
976 fi
976 fi
977 }
977 }
978
978
979 # :command.usage
979 # :command.usage
980 rcstack_cli_cmd_usage() {
980 rcstack_cli_cmd_usage() {
981 if [[ -n $long_usage ]]; then
981 if [[ -n $long_usage ]]; then
982 printf "rcstack cli cmd - run a custom command on top of docker image from RhodeCode\n"
982 printf "rcstack cli cmd - run a custom command on top of docker image from RhodeCode\n"
983 echo
983 echo
984
984
985 else
985 else
986 printf "rcstack cli cmd - run a custom command on top of docker image from RhodeCode\n"
986 printf "rcstack cli cmd - run a custom command on top of docker image from RhodeCode\n"
987 echo
987 echo
988
988
989 fi
989 fi
990
990
991 printf "%s\n" "Usage:"
991 printf "%s\n" "Usage:"
992 printf " rcstack cli cmd [OPTIONS] [CALL ARGUMENTS...]\n"
992 printf " rcstack cli cmd [OPTIONS] [CALL ARGUMENTS...]\n"
993 printf " rcstack cli cmd --help | -h\n"
993 printf " rcstack cli cmd --help | -h\n"
994 echo
994 echo
995
995
996 # :command.long_usage
996 # :command.long_usage
997 if [[ -n $long_usage ]]; then
997 if [[ -n $long_usage ]]; then
998 printf "%s\n" "Options:"
998 printf "%s\n" "Options:"
999
999
1000 # :command.usage_flags
1000 # :command.usage_flags
1001 # :flag.usage
1001 # :flag.usage
1002 printf " %s\n" "--no-tty"
1002 printf " %s\n" "--no-tty"
1003 printf " when running docker command don't attach to TTY. Useful for running a script\n out of shell context, e.g crontab\n"
1003 printf " when running docker command don't attach to TTY. Useful for running a script\n out of shell context, e.g crontab\n"
1004 echo
1004 echo
1005
1005
1006 # :flag.usage
1006 # :flag.usage
1007 printf " %s\n" "--user"
1007 printf " %s\n" "--user"
1008 printf " User to run the command as, e.g root / rhodecode\n"
1008 printf " User to run the command as, e.g root / rhodecode\n"
1009 echo
1009 echo
1010
1010
1011 # :flag.usage
1011 # :flag.usage
1012 printf " %s\n" "--env-file-path ENV_FILE_PATH"
1012 printf " %s\n" "--env-file-path ENV_FILE_PATH"
1013 printf " Set custom env file\n"
1013 printf " Set custom env file\n"
1014 printf " Default: $PWD/.custom/.runtime.env\n"
1014 printf " Default: $PWD/.custom/.runtime.env\n"
1015 echo
1015 echo
1016
1016
1017 # :command.usage_fixed_flags
1017 # :command.usage_fixed_flags
1018 printf " %s\n" "--help, -h"
1018 printf " %s\n" "--help, -h"
1019 printf " Show this help\n"
1019 printf " Show this help\n"
1020 echo
1020 echo
1021
1021
1022 # :command.usage_args
1022 # :command.usage_args
1023 printf "%s\n" "Arguments:"
1023 printf "%s\n" "Arguments:"
1024
1024
1025 echo " CALL ARGUMENTS..."
1025 echo " CALL ARGUMENTS..."
1026 printf " call arguments\n"
1026 printf " call arguments\n"
1027 echo
1027 echo
1028
1028
1029 fi
1029 fi
1030 }
1030 }
1031
1031
1032 # :command.usage
1032 # :command.usage
1033 rcstack_cli_ishell_usage() {
1033 rcstack_cli_ishell_usage() {
1034 if [[ -n $long_usage ]]; then
1034 if [[ -n $long_usage ]]; then
1035 printf "rcstack cli ishell - ishell attached to running RhodeCode instance\n"
1035 printf "rcstack cli ishell - ishell attached to running RhodeCode instance\n"
1036 echo
1036 echo
1037
1037
1038 else
1038 else
1039 printf "rcstack cli ishell - ishell attached to running RhodeCode instance\n"
1039 printf "rcstack cli ishell - ishell attached to running RhodeCode instance\n"
1040 echo
1040 echo
1041
1041
1042 fi
1042 fi
1043
1043
1044 printf "%s\n" "Usage:"
1044 printf "%s\n" "Usage:"
1045 printf " rcstack cli ishell [OPTIONS]\n"
1045 printf " rcstack cli ishell [OPTIONS]\n"
1046 printf " rcstack cli ishell --help | -h\n"
1046 printf " rcstack cli ishell --help | -h\n"
1047 echo
1047 echo
1048
1048
1049 # :command.long_usage
1049 # :command.long_usage
1050 if [[ -n $long_usage ]]; then
1050 if [[ -n $long_usage ]]; then
1051 printf "%s\n" "Options:"
1051 printf "%s\n" "Options:"
1052
1052
1053 # :command.usage_flags
1053 # :command.usage_flags
1054 # :flag.usage
1054 # :flag.usage
1055 printf " %s\n" "--no-tty"
1055 printf " %s\n" "--no-tty"
1056 printf " when running docker command don't attach to TTY. Useful for running a script\n out of shell context, e.g crontab\n"
1056 printf " when running docker command don't attach to TTY. Useful for running a script\n out of shell context, e.g crontab\n"
1057 echo
1057 echo
1058
1058
1059 # :flag.usage
1059 # :flag.usage
1060 printf " %s\n" "--user"
1060 printf " %s\n" "--user"
1061 printf " User to run the command as, e.g root / rhodecode\n"
1061 printf " User to run the command as, e.g root / rhodecode\n"
1062 echo
1062 echo
1063
1063
1064 # :flag.usage
1064 # :flag.usage
1065 printf " %s\n" "--env-file-path ENV_FILE_PATH"
1065 printf " %s\n" "--env-file-path ENV_FILE_PATH"
1066 printf " Set custom env file\n"
1066 printf " Set custom env file\n"
1067 printf " Default: $PWD/.custom/.runtime.env\n"
1067 printf " Default: $PWD/.custom/.runtime.env\n"
1068 echo
1068 echo
1069
1069
1070 # :command.usage_fixed_flags
1070 # :command.usage_fixed_flags
1071 printf " %s\n" "--help, -h"
1071 printf " %s\n" "--help, -h"
1072 printf " Show this help\n"
1072 printf " Show this help\n"
1073 echo
1073 echo
1074
1074
1075 fi
1075 fi
1076 }
1076 }
1077
1077
1078 # :command.usage
1078 # :command.usage
1079 rcstack_cli_image_info_usage() {
1079 rcstack_cli_image_info_usage() {
1080 if [[ -n $long_usage ]]; then
1080 if [[ -n $long_usage ]]; then
1081 printf "rcstack cli image-info - print out stored docker image version\n"
1081 printf "rcstack cli image-info - print out stored docker image version\n"
1082 echo
1082 echo
1083
1083
1084 else
1084 else
1085 printf "rcstack cli image-info - print out stored docker image version\n"
1085 printf "rcstack cli image-info - print out stored docker image version\n"
1086 echo
1086 echo
1087
1087
1088 fi
1088 fi
1089
1089
1090 printf "%s\n" "Usage:"
1090 printf "%s\n" "Usage:"
1091 printf " rcstack cli image-info [OPTIONS]\n"
1091 printf " rcstack cli image-info [OPTIONS]\n"
1092 printf " rcstack cli image-info --help | -h\n"
1092 printf " rcstack cli image-info --help | -h\n"
1093 echo
1093 echo
1094
1094
1095 # :command.long_usage
1095 # :command.long_usage
1096 if [[ -n $long_usage ]]; then
1096 if [[ -n $long_usage ]]; then
1097 printf "%s\n" "Options:"
1097 printf "%s\n" "Options:"
1098
1098
1099 # :command.usage_flags
1099 # :command.usage_flags
1100 # :flag.usage
1100 # :flag.usage
1101 printf " %s\n" "--verbose"
1101 printf " %s\n" "--verbose"
1102 printf " rich output about image\n"
1102 printf " rich output about image\n"
1103 echo
1103 echo
1104
1104
1105 # :command.usage_fixed_flags
1105 # :command.usage_fixed_flags
1106 printf " %s\n" "--help, -h"
1106 printf " %s\n" "--help, -h"
1107 printf " Show this help\n"
1107 printf " Show this help\n"
1108 echo
1108 echo
1109
1109
1110 fi
1110 fi
1111 }
1111 }
1112
1112
1113 # :command.usage
1113 # :command.usage
1114 rcstack_cli_set_runtime_image_usage() {
1114 rcstack_cli_set_image_usage() {
1115 if [[ -n $long_usage ]]; then
1115 if [[ -n $long_usage ]]; then
1116 printf "rcstack cli set-runtime-image - set version to .runtime.env file\n"
1116 printf "rcstack cli set-image - set version to .runtime.env file\n"
1117 echo
1117 echo
1118
1118
1119 else
1119 else
1120 printf "rcstack cli set-runtime-image - set version to .runtime.env file\n"
1120 printf "rcstack cli set-image - set version to .runtime.env file\n"
1121 echo
1122
1123 fi
1124
1125 printf "%s\n" "Usage:"
1126 printf " rcstack cli set-image VERSION\n"
1127 printf " rcstack cli set-image --help | -h\n"
1128 echo
1129
1130 # :command.long_usage
1131 if [[ -n $long_usage ]]; then
1132 printf "%s\n" "Options:"
1133
1134 # :command.usage_fixed_flags
1135 printf " %s\n" "--help, -h"
1136 printf " Show this help\n"
1137 echo
1138
1139 # :command.usage_args
1140 printf "%s\n" "Arguments:"
1141
1142 # :argument.usage
1143 printf " %s\n" "VERSION"
1144 printf " Version of docker image to set e.g '5.0.0'\n"
1145 echo
1146
1147 fi
1148 }
1149
1150 # :command.usage
1151 deprecated_cli_set_runtime_image_usage() {
1152 if [[ -n $long_usage ]]; then
1153 printf "rcstack cli set-runtime-image - DEPRECATED - use 'set-image' instead\n"
1154 echo
1155
1156 else
1157 printf "rcstack cli set-runtime-image - DEPRECATED - use 'set-image' instead\n"
1121 echo
1158 echo
1122
1159
1123 fi
1160 fi
1124
1161
1125 printf "%s\n" "Usage:"
1162 printf "%s\n" "Usage:"
1126 printf " rcstack cli set-runtime-image VERSION\n"
1163 printf " rcstack cli set-runtime-image VERSION\n"
1127 printf " rcstack cli set-runtime-image --help | -h\n"
1164 printf " rcstack cli set-runtime-image --help | -h\n"
1128 echo
1165 echo
1129
1166
1130 # :command.long_usage
1167 # :command.long_usage
1131 if [[ -n $long_usage ]]; then
1168 if [[ -n $long_usage ]]; then
1132 printf "%s\n" "Options:"
1169 printf "%s\n" "Options:"
1133
1170
1134 # :command.usage_fixed_flags
1171 # :command.usage_fixed_flags
1135 printf " %s\n" "--help, -h"
1172 printf " %s\n" "--help, -h"
1136 printf " Show this help\n"
1173 printf " Show this help\n"
1137 echo
1174 echo
1138
1175
1139 # :command.usage_args
1176 # :command.usage_args
1140 printf "%s\n" "Arguments:"
1177 printf "%s\n" "Arguments:"
1141
1178
1142 # :argument.usage
1179 # :argument.usage
1143 printf " %s\n" "VERSION"
1180 printf " %s\n" "VERSION"
1144 printf " Version of docker image to set e.g '5.0.0'\n"
1181 printf " Version of docker image to set e.g '5.0.0'\n"
1145 echo
1182 echo
1146
1183
1184 # :command.footer
1185 printf "DEPRECATED - This command is deprecated, use 'set-image' instead\n"
1186 echo
1187
1147 fi
1188 fi
1148 }
1189 }
1149
1190
1150 # :command.usage
1191 # :command.usage
1151 rcstack_cli_docker_info_usage() {
1192 rcstack_cli_docker_info_usage() {
1152 if [[ -n $long_usage ]]; then
1193 if [[ -n $long_usage ]]; then
1153 printf "rcstack cli docker-info - get current docker info\n"
1194 printf "rcstack cli docker-info - get current docker info\n"
1154 echo
1195 echo
1155
1196
1156 else
1197 else
1157 printf "rcstack cli docker-info - get current docker info\n"
1198 printf "rcstack cli docker-info - get current docker info\n"
1158 echo
1199 echo
1159
1200
1160 fi
1201 fi
1161
1202
1162 printf "%s\n" "Usage:"
1203 printf "%s\n" "Usage:"
1163 printf " rcstack cli docker-info [OPTIONS]\n"
1204 printf " rcstack cli docker-info [OPTIONS]\n"
1164 printf " rcstack cli docker-info --help | -h\n"
1205 printf " rcstack cli docker-info --help | -h\n"
1165 echo
1206 echo
1166
1207
1167 # :command.long_usage
1208 # :command.long_usage
1168 if [[ -n $long_usage ]]; then
1209 if [[ -n $long_usage ]]; then
1169 printf "%s\n" "Options:"
1210 printf "%s\n" "Options:"
1170
1211
1171 # :command.usage_flags
1212 # :command.usage_flags
1172 # :flag.usage
1213 # :flag.usage
1173 printf " %s\n" "--verbose"
1214 printf " %s\n" "--verbose"
1174 printf " rich output about docker\n"
1215 printf " rich output about docker\n"
1175 echo
1216 echo
1176
1217
1177 # :command.usage_fixed_flags
1218 # :command.usage_fixed_flags
1178 printf " %s\n" "--help, -h"
1219 printf " %s\n" "--help, -h"
1179 printf " Show this help\n"
1220 printf " Show this help\n"
1180 echo
1221 echo
1181
1222
1182 fi
1223 fi
1183 }
1224 }
1184
1225
1185 # :command.usage
1226 # :command.usage
1186 rcstack_cli_docker_upgrade_usage() {
1227 rcstack_cli_docker_upgrade_usage() {
1187 if [[ -n $long_usage ]]; then
1228 if [[ -n $long_usage ]]; then
1188 printf "rcstack cli docker-upgrade - force upgrade docker\n"
1229 printf "rcstack cli docker-upgrade - force upgrade docker\n"
1189 echo
1230 echo
1190
1231
1191 else
1232 else
1192 printf "rcstack cli docker-upgrade - force upgrade docker\n"
1233 printf "rcstack cli docker-upgrade - force upgrade docker\n"
1193 echo
1234 echo
1194
1235
1195 fi
1236 fi
1196
1237
1197 printf "%s\n" "Usage:"
1238 printf "%s\n" "Usage:"
1198 printf " rcstack cli docker-upgrade [OPTIONS]\n"
1239 printf " rcstack cli docker-upgrade [OPTIONS]\n"
1199 printf " rcstack cli docker-upgrade --help | -h\n"
1240 printf " rcstack cli docker-upgrade --help | -h\n"
1200 echo
1241 echo
1201
1242
1202 # :command.long_usage
1243 # :command.long_usage
1203 if [[ -n $long_usage ]]; then
1244 if [[ -n $long_usage ]]; then
1204 printf "%s\n" "Options:"
1245 printf "%s\n" "Options:"
1205
1246
1206 # :command.usage_flags
1247 # :command.usage_flags
1207 # :flag.usage
1248 # :flag.usage
1208 printf " %s\n" "--compose"
1249 printf " %s\n" "--compose"
1209 printf " run an upgrade of docker compose to latest version\n"
1250 printf " run an upgrade of docker compose to latest version\n"
1210 echo
1251 echo
1211
1252
1212 # :command.usage_fixed_flags
1253 # :command.usage_fixed_flags
1213 printf " %s\n" "--help, -h"
1254 printf " %s\n" "--help, -h"
1214 printf " Show this help\n"
1255 printf " Show this help\n"
1215 echo
1256 echo
1216
1257
1217 fi
1258 fi
1218 }
1259 }
1219
1260
1220 # :command.usage
1261 # :command.usage
1221 rcstack_cli_redis_usage() {
1262 rcstack_cli_redis_usage() {
1222 if [[ -n $long_usage ]]; then
1263 if [[ -n $long_usage ]]; then
1223 printf "rcstack cli redis - CLI for Redis\n"
1264 printf "rcstack cli redis - CLI for Redis\n"
1224 echo
1265 echo
1225
1266
1226 else
1267 else
1227 printf "rcstack cli redis - CLI for Redis\n"
1268 printf "rcstack cli redis - CLI for Redis\n"
1228 echo
1269 echo
1229
1270
1230 fi
1271 fi
1231
1272
1232 printf "%s\n" "Usage:"
1273 printf "%s\n" "Usage:"
1233 printf " rcstack cli redis [OPTIONS]\n"
1274 printf " rcstack cli redis [OPTIONS]\n"
1234 printf " rcstack cli redis --help | -h\n"
1275 printf " rcstack cli redis --help | -h\n"
1235 echo
1276 echo
1236
1277
1237 # :command.long_usage
1278 # :command.long_usage
1238 if [[ -n $long_usage ]]; then
1279 if [[ -n $long_usage ]]; then
1239 printf "%s\n" "Options:"
1280 printf "%s\n" "Options:"
1240
1281
1241 # :command.usage_flags
1282 # :command.usage_flags
1242 # :flag.usage
1283 # :flag.usage
1243 printf " %s\n" "--no-tty"
1284 printf " %s\n" "--no-tty"
1244 printf " when running docker command don't attach to TTY. Useful for running a script\n out of shell context, e.g crontab\n"
1285 printf " when running docker command don't attach to TTY. Useful for running a script\n out of shell context, e.g crontab\n"
1245 echo
1286 echo
1246
1287
1247 # :flag.usage
1288 # :flag.usage
1248 printf " %s\n" "--user"
1289 printf " %s\n" "--user"
1249 printf " User to run the command as, e.g root / rhodecode\n"
1290 printf " User to run the command as, e.g root / rhodecode\n"
1250 echo
1291 echo
1251
1292
1252 # :flag.usage
1293 # :flag.usage
1253 printf " %s\n" "--env-file-path ENV_FILE_PATH"
1294 printf " %s\n" "--env-file-path ENV_FILE_PATH"
1254 printf " Set custom env file\n"
1295 printf " Set custom env file\n"
1255 printf " Default: $PWD/.custom/.runtime.env\n"
1296 printf " Default: $PWD/.custom/.runtime.env\n"
1256 echo
1297 echo
1257
1298
1258 # :flag.usage
1299 # :flag.usage
1259 printf " %s\n" "--db DB"
1300 printf " %s\n" "--db DB"
1260 printf " select Redis db, defaults 0\n"
1301 printf " select Redis db, defaults 0\n"
1261 printf " Default: 0\n"
1302 printf " Default: 0\n"
1262 echo
1303 echo
1263
1304
1264 # :command.usage_fixed_flags
1305 # :command.usage_fixed_flags
1265 printf " %s\n" "--help, -h"
1306 printf " %s\n" "--help, -h"
1266 printf " Show this help\n"
1307 printf " Show this help\n"
1267 echo
1308 echo
1268
1309
1269 # :command.usage_examples
1310 # :command.usage_examples
1270 printf "%s\n" "Examples:"
1311 printf "%s\n" "Examples:"
1271 printf " # run the redis CLI\n - ./rcstack cli redis\n # run a command without TTY\n - echo 'KEYS *' | ./rcstack cli redis --no-tty\n"
1312 printf " # run the redis CLI\n - ./rcstack cli redis\n # run a command without TTY\n - echo 'KEYS *' | ./rcstack cli redis --no-tty\n"
1272 echo
1313 echo
1273
1314
1274 fi
1315 fi
1275 }
1316 }
1276
1317
1277 # :command.usage
1318 # :command.usage
1278 rcstack_cli_db_usage() {
1319 rcstack_cli_db_usage() {
1279 if [[ -n $long_usage ]]; then
1320 if [[ -n $long_usage ]]; then
1280 printf "rcstack cli db - CLI with Database connection\n"
1321 printf "rcstack cli db - CLI with Database connection\n"
1281 echo
1322 echo
1282
1323
1283 else
1324 else
1284 printf "rcstack cli db - CLI with Database connection\n"
1325 printf "rcstack cli db - CLI with Database connection\n"
1285 echo
1326 echo
1286
1327
1287 fi
1328 fi
1288
1329
1289 printf "%s\n" "Usage:"
1330 printf "%s\n" "Usage:"
1290 printf " rcstack cli db [OPTIONS]\n"
1331 printf " rcstack cli db [OPTIONS]\n"
1291 printf " rcstack cli db --help | -h\n"
1332 printf " rcstack cli db --help | -h\n"
1292 echo
1333 echo
1293
1334
1294 # :command.long_usage
1335 # :command.long_usage
1295 if [[ -n $long_usage ]]; then
1336 if [[ -n $long_usage ]]; then
1296 printf "%s\n" "Options:"
1337 printf "%s\n" "Options:"
1297
1338
1298 # :command.usage_flags
1339 # :command.usage_flags
1299 # :flag.usage
1340 # :flag.usage
1300 printf " %s\n" "--no-tty"
1341 printf " %s\n" "--no-tty"
1301 printf " when running docker command don't attach to TTY. Useful for running a script\n out of shell context, e.g crontab\n"
1342 printf " when running docker command don't attach to TTY. Useful for running a script\n out of shell context, e.g crontab\n"
1302 echo
1343 echo
1303
1344
1304 # :flag.usage
1345 # :flag.usage
1305 printf " %s\n" "--user"
1346 printf " %s\n" "--user"
1306 printf " User to run the command as, e.g root / rhodecode\n"
1347 printf " User to run the command as, e.g root / rhodecode\n"
1307 echo
1348 echo
1308
1349
1309 # :flag.usage
1350 # :flag.usage
1310 printf " %s\n" "--env-file-path ENV_FILE_PATH"
1351 printf " %s\n" "--env-file-path ENV_FILE_PATH"
1311 printf " Set custom env file\n"
1352 printf " Set custom env file\n"
1312 printf " Default: $PWD/.custom/.runtime.env\n"
1353 printf " Default: $PWD/.custom/.runtime.env\n"
1313 echo
1354 echo
1314
1355
1315 # :command.usage_fixed_flags
1356 # :command.usage_fixed_flags
1316 printf " %s\n" "--help, -h"
1357 printf " %s\n" "--help, -h"
1317 printf " Show this help\n"
1358 printf " Show this help\n"
1318 echo
1359 echo
1319
1360
1320 # :command.usage_examples
1361 # :command.usage_examples
1321 printf "%s\n" "Examples:"
1362 printf "%s\n" "Examples:"
1322 printf " # restore backup\n - \i /var/rc-data-dump/your_dump.sql\n"
1363 printf " # restore backup\n - \i /var/rc-data-dump/your_dump.sql\n"
1323 echo
1364 echo
1324
1365
1325 fi
1366 fi
1326 }
1367 }
1327
1368
1328 # :command.usage
1369 # :command.usage
1329 rcstack_cli_db_upgrade_usage() {
1370 rcstack_cli_db_upgrade_usage() {
1330 if [[ -n $long_usage ]]; then
1371 if [[ -n $long_usage ]]; then
1331 printf "rcstack cli db-upgrade - CLI to run db upgrade\n"
1372 printf "rcstack cli db-upgrade - CLI to run db upgrade\n"
1332 echo
1373 echo
1333
1374
1334 else
1375 else
1335 printf "rcstack cli db-upgrade - CLI to run db upgrade\n"
1376 printf "rcstack cli db-upgrade - CLI to run db upgrade\n"
1336 echo
1377 echo
1337
1378
1338 fi
1379 fi
1339
1380
1340 printf "%s\n" "Usage:"
1381 printf "%s\n" "Usage:"
1341 printf " rcstack cli db-upgrade\n"
1382 printf " rcstack cli db-upgrade\n"
1342 printf " rcstack cli db-upgrade --help | -h\n"
1383 printf " rcstack cli db-upgrade --help | -h\n"
1343 echo
1384 echo
1344
1385
1345 # :command.long_usage
1386 # :command.long_usage
1346 if [[ -n $long_usage ]]; then
1387 if [[ -n $long_usage ]]; then
1347 printf "%s\n" "Options:"
1388 printf "%s\n" "Options:"
1348
1389
1349 # :command.usage_fixed_flags
1390 # :command.usage_fixed_flags
1350 printf " %s\n" "--help, -h"
1391 printf " %s\n" "--help, -h"
1351 printf " Show this help\n"
1392 printf " Show this help\n"
1352 echo
1393 echo
1353
1394
1354 fi
1395 fi
1355 }
1396 }
1356
1397
1357 # :command.usage
1398 # :command.usage
1358 rcstack_cli_storage_usage() {
1399 rcstack_cli_storage_usage() {
1359 if [[ -n $long_usage ]]; then
1400 if [[ -n $long_usage ]]; then
1360 printf "rcstack cli storage - CLI for repository storage. Exposes a basic image with mounted data and repositories volumes or attach to currently running containers storage\n"
1401 printf "rcstack cli storage - CLI for repository storage. Exposes a basic image with mounted data and repositories volumes or attach to currently running containers storage\n"
1361 echo
1402 echo
1362
1403
1363 else
1404 else
1364 printf "rcstack cli storage - CLI for repository storage. Exposes a basic image with mounted data and repositories volumes or attach to currently running containers storage\n"
1405 printf "rcstack cli storage - CLI for repository storage. Exposes a basic image with mounted data and repositories volumes or attach to currently running containers storage\n"
1365 echo
1406 echo
1366
1407
1367 fi
1408 fi
1368
1409
1369 printf "%s\n" "Usage:"
1410 printf "%s\n" "Usage:"
1370 printf " rcstack cli storage [OPTIONS]\n"
1411 printf " rcstack cli storage [OPTIONS]\n"
1371 printf " rcstack cli storage --help | -h\n"
1412 printf " rcstack cli storage --help | -h\n"
1372 echo
1413 echo
1373
1414
1374 # :command.long_usage
1415 # :command.long_usage
1375 if [[ -n $long_usage ]]; then
1416 if [[ -n $long_usage ]]; then
1376 printf "%s\n" "Options:"
1417 printf "%s\n" "Options:"
1377
1418
1378 # :command.usage_flags
1419 # :command.usage_flags
1379 # :flag.usage
1420 # :flag.usage
1380 printf " %s\n" "--no-tty"
1421 printf " %s\n" "--no-tty"
1381 printf " when running docker command don't attach to TTY. Useful for running a script\n out of shell context, e.g crontab\n"
1422 printf " when running docker command don't attach to TTY. Useful for running a script\n out of shell context, e.g crontab\n"
1382 echo
1423 echo
1383
1424
1384 # :flag.usage
1425 # :flag.usage
1385 printf " %s\n" "--attached ATTACHED"
1426 printf " %s\n" "--attached ATTACHED"
1386 printf " attach to storage of already running vcsserver container instead\n"
1427 printf " attach to storage of already running vcsserver container instead\n"
1387 echo
1428 echo
1388
1429
1389 # :command.usage_fixed_flags
1430 # :command.usage_fixed_flags
1390 printf " %s\n" "--help, -h"
1431 printf " %s\n" "--help, -h"
1391 printf " Show this help\n"
1432 printf " Show this help\n"
1392 echo
1433 echo
1393
1434
1394 fi
1435 fi
1395 }
1436 }
1396
1437
1397 # :command.usage
1438 # :command.usage
1398 rcstack_cli_attach_usage() {
1439 rcstack_cli_attach_usage() {
1399 if [[ -n $long_usage ]]; then
1440 if [[ -n $long_usage ]]; then
1400 printf "rcstack cli attach - attach to running instance of RhodeCode, by default it attaches to rhodecode main web app\n"
1441 printf "rcstack cli attach - attach to running instance of RhodeCode, by default it attaches to rhodecode main web app\n"
1401 echo
1442 echo
1402
1443
1403 else
1444 else
1404 printf "rcstack cli attach - attach to running instance of RhodeCode, by default it attaches to rhodecode main web app\n"
1445 printf "rcstack cli attach - attach to running instance of RhodeCode, by default it attaches to rhodecode main web app\n"
1405 echo
1446 echo
1406
1447
1407 fi
1448 fi
1408
1449
1409 printf "%s\n" "Usage:"
1450 printf "%s\n" "Usage:"
1410 printf " rcstack cli attach [OPTIONS]\n"
1451 printf " rcstack cli attach [OPTIONS]\n"
1411 printf " rcstack cli attach --help | -h\n"
1452 printf " rcstack cli attach --help | -h\n"
1412 echo
1453 echo
1413
1454
1414 # :command.long_usage
1455 # :command.long_usage
1415 if [[ -n $long_usage ]]; then
1456 if [[ -n $long_usage ]]; then
1416 printf "%s\n" "Options:"
1457 printf "%s\n" "Options:"
1417
1458
1418 # :command.usage_flags
1459 # :command.usage_flags
1419 # :flag.usage
1460 # :flag.usage
1420 printf " %s\n" "--no-tty"
1461 printf " %s\n" "--no-tty"
1421 printf " when running docker command don't attach to TTY. Useful for running a script\n out of shell context, e.g crontab\n"
1462 printf " when running docker command don't attach to TTY. Useful for running a script\n out of shell context, e.g crontab\n"
1422 echo
1463 echo
1423
1464
1424 # :flag.usage
1465 # :flag.usage
1425 printf " %s\n" "--instance-type INSTANCE_TYPE"
1466 printf " %s\n" "--instance-type INSTANCE_TYPE"
1426 printf " type of instance to attach to\n"
1467 printf " type of instance to attach to\n"
1427 printf " Default: rhodecode\n"
1468 printf " Default: rhodecode\n"
1428 echo
1469 echo
1429
1470
1430 # :command.usage_fixed_flags
1471 # :command.usage_fixed_flags
1431 printf " %s\n" "--help, -h"
1472 printf " %s\n" "--help, -h"
1432 printf " Show this help\n"
1473 printf " Show this help\n"
1433 echo
1474 echo
1434
1475
1435 # :command.usage_examples
1476 # :command.usage_examples
1436 printf "%s\n" "Examples:"
1477 printf "%s\n" "Examples:"
1437 printf " ./rcstack cli attach --instance-type sshd\n ./rcstack cli attach --instance-type vcsserver\n ./rcstack cli attach --instance-type celery\n ./rcstack cli attach --instance-type celery-beat\n"
1478 printf " ./rcstack cli attach --instance-type sshd\n ./rcstack cli attach --instance-type vcsserver\n ./rcstack cli attach --instance-type celery\n ./rcstack cli attach --instance-type celery-beat\n"
1438 echo
1479 echo
1439
1480
1440 fi
1481 fi
1441 }
1482 }
1442
1483
1443 # :command.usage
1484 # :command.usage
1444 rcstack_cli_set_edition_usage() {
1485 rcstack_cli_set_edition_usage() {
1445 if [[ -n $long_usage ]]; then
1486 if [[ -n $long_usage ]]; then
1446 printf "rcstack cli set-edition - set current setup to either CE (Community) or EE (Enterprise) type\n"
1487 printf "rcstack cli set-edition - set current setup to either CE (Community) or EE (Enterprise) type\n"
1447 echo
1488 echo
1448
1489
1449 else
1490 else
1450 printf "rcstack cli set-edition - set current setup to either CE (Community) or EE (Enterprise) type\n"
1491 printf "rcstack cli set-edition - set current setup to either CE (Community) or EE (Enterprise) type\n"
1451 echo
1492 echo
1452
1493
1453 fi
1494 fi
1454
1495
1455 printf "%s\n" "Usage:"
1496 printf "%s\n" "Usage:"
1456 printf " rcstack cli set-edition EDITION_TYPE\n"
1497 printf " rcstack cli set-edition EDITION_TYPE\n"
1457 printf " rcstack cli set-edition --help | -h\n"
1498 printf " rcstack cli set-edition --help | -h\n"
1458 echo
1499 echo
1459
1500
1460 # :command.long_usage
1501 # :command.long_usage
1461 if [[ -n $long_usage ]]; then
1502 if [[ -n $long_usage ]]; then
1462 printf "%s\n" "Options:"
1503 printf "%s\n" "Options:"
1463
1504
1464 # :command.usage_fixed_flags
1505 # :command.usage_fixed_flags
1465 printf " %s\n" "--help, -h"
1506 printf " %s\n" "--help, -h"
1466 printf " Show this help\n"
1507 printf " Show this help\n"
1467 echo
1508 echo
1468
1509
1469 # :command.usage_args
1510 # :command.usage_args
1470 printf "%s\n" "Arguments:"
1511 printf "%s\n" "Arguments:"
1471
1512
1472 # :argument.usage
1513 # :argument.usage
1473 printf " %s\n" "EDITION_TYPE"
1514 printf " %s\n" "EDITION_TYPE"
1474 printf " pick type CE or EE\n"
1515 printf " pick type CE or EE\n"
1475 printf " Allowed: ce, ee\n"
1516 printf " Allowed: ce, ee\n"
1476 echo
1517 echo
1477
1518
1478 # :command.usage_examples
1519 # :command.usage_examples
1479 printf "%s\n" "Examples:"
1520 printf "%s\n" "Examples:"
1480 printf " ./rcstack set-edition ce\n"
1521 printf " ./rcstack set-edition ce\n"
1481 printf " ./rcstack set-edition ee\n"
1522 printf " ./rcstack set-edition ee\n"
1482 echo
1523 echo
1483
1524
1484 fi
1525 fi
1485 }
1526 }
1486
1527
1487 # :command.usage
1528 # :command.usage
1488 rcstack_cli_configure_vcsserver_usage() {
1529 rcstack_cli_configure_vcsserver_usage() {
1489 if [[ -n $long_usage ]]; then
1530 if [[ -n $long_usage ]]; then
1490 printf "rcstack cli configure-vcsserver - reconfigure the vcsserver.ini file\n"
1531 printf "rcstack cli configure-vcsserver - reconfigure the vcsserver.ini file\n"
1491 echo
1532 echo
1492
1533
1493 else
1534 else
1494 printf "rcstack cli configure-vcsserver - reconfigure the vcsserver.ini file\n"
1535 printf "rcstack cli configure-vcsserver - reconfigure the vcsserver.ini file\n"
1495 echo
1536 echo
1496
1537
1497 fi
1538 fi
1498
1539
1499 printf "%s\n" "Usage:"
1540 printf "%s\n" "Usage:"
1500 printf " rcstack cli configure-vcsserver INI_PATH\n"
1541 printf " rcstack cli configure-vcsserver INI_PATH\n"
1501 printf " rcstack cli configure-vcsserver --help | -h\n"
1542 printf " rcstack cli configure-vcsserver --help | -h\n"
1502 echo
1543 echo
1503
1544
1504 # :command.long_usage
1545 # :command.long_usage
1505 if [[ -n $long_usage ]]; then
1546 if [[ -n $long_usage ]]; then
1506 printf "%s\n" "Options:"
1547 printf "%s\n" "Options:"
1507
1548
1508 # :command.usage_fixed_flags
1549 # :command.usage_fixed_flags
1509 printf " %s\n" "--help, -h"
1550 printf " %s\n" "--help, -h"
1510 printf " Show this help\n"
1551 printf " Show this help\n"
1511 echo
1552 echo
1512
1553
1513 # :command.usage_args
1554 # :command.usage_args
1514 printf "%s\n" "Arguments:"
1555 printf "%s\n" "Arguments:"
1515
1556
1516 # :argument.usage
1557 # :argument.usage
1517 printf " %s\n" "INI_PATH"
1558 printf " %s\n" "INI_PATH"
1518 printf " Path to vcsserver.ini to reconfigure\n"
1559 printf " Path to vcsserver.ini to reconfigure\n"
1519 echo
1560 echo
1520
1561
1521 # :command.usage_examples
1562 # :command.usage_examples
1522 printf "%s\n" "Examples:"
1563 printf "%s\n" "Examples:"
1523 printf " ./rcstack cli configure-vcs config/_shared/vcsserver.ini\n"
1564 printf " ./rcstack cli configure-vcs config/_shared/vcsserver.ini\n"
1524 echo
1565 echo
1525
1566
1526 fi
1567 fi
1527 }
1568 }
1528
1569
1529 # :command.usage
1570 # :command.usage
1530 rcstack_cli_configure_rhodecode_usage() {
1571 rcstack_cli_configure_rhodecode_usage() {
1531 if [[ -n $long_usage ]]; then
1572 if [[ -n $long_usage ]]; then
1532 printf "rcstack cli configure-rhodecode - reconfigure the rhodecode.ini file\n"
1573 printf "rcstack cli configure-rhodecode - reconfigure the rhodecode.ini file\n"
1533 echo
1574 echo
1534
1575
1535 else
1576 else
1536 printf "rcstack cli configure-rhodecode - reconfigure the rhodecode.ini file\n"
1577 printf "rcstack cli configure-rhodecode - reconfigure the rhodecode.ini file\n"
1537 echo
1578 echo
1538
1579
1539 fi
1580 fi
1540
1581
1541 printf "%s\n" "Usage:"
1582 printf "%s\n" "Usage:"
1542 printf " rcstack cli configure-rhodecode INI_PATH\n"
1583 printf " rcstack cli configure-rhodecode INI_PATH\n"
1543 printf " rcstack cli configure-rhodecode --help | -h\n"
1584 printf " rcstack cli configure-rhodecode --help | -h\n"
1544 echo
1585 echo
1545
1586
1546 # :command.long_usage
1587 # :command.long_usage
1547 if [[ -n $long_usage ]]; then
1588 if [[ -n $long_usage ]]; then
1548 printf "%s\n" "Options:"
1589 printf "%s\n" "Options:"
1549
1590
1550 # :command.usage_fixed_flags
1591 # :command.usage_fixed_flags
1551 printf " %s\n" "--help, -h"
1592 printf " %s\n" "--help, -h"
1552 printf " Show this help\n"
1593 printf " Show this help\n"
1553 echo
1594 echo
1554
1595
1555 # :command.usage_args
1596 # :command.usage_args
1556 printf "%s\n" "Arguments:"
1597 printf "%s\n" "Arguments:"
1557
1598
1558 # :argument.usage
1599 # :argument.usage
1559 printf " %s\n" "INI_PATH"
1600 printf " %s\n" "INI_PATH"
1560 printf " Path to rhodecode.ini to reconfigure\n"
1601 printf " Path to rhodecode.ini to reconfigure\n"
1561 echo
1602 echo
1562
1603
1563 # :command.usage_examples
1604 # :command.usage_examples
1564 printf "%s\n" "Examples:"
1605 printf "%s\n" "Examples:"
1565 printf " ./rcstack cli configure-rhodecode config/_shared/rhodecode.ini\n"
1606 printf " ./rcstack cli configure-rhodecode config/_shared/rhodecode.ini\n"
1566 echo
1607 echo
1567
1608
1568 fi
1609 fi
1569 }
1610 }
1570
1611
1571 # :command.usage
1612 # :command.usage
1572 rcstack_backup_db_usage() {
1613 rcstack_backup_db_usage() {
1573 if [[ -n $long_usage ]]; then
1614 if [[ -n $long_usage ]]; then
1574 printf "rcstack backup-db - Backup Database\n"
1615 printf "rcstack backup-db - Backup Database\n"
1575 echo
1616 echo
1576
1617
1577 else
1618 else
1578 printf "rcstack backup-db - Backup Database\n"
1619 printf "rcstack backup-db - Backup Database\n"
1579 echo
1620 echo
1580
1621
1581 fi
1622 fi
1582
1623
1583 printf "%s\n" "Usage:"
1624 printf "%s\n" "Usage:"
1584 printf " rcstack backup-db DESTINATION\n"
1625 printf " rcstack backup-db DESTINATION\n"
1585 printf " rcstack backup-db --help | -h\n"
1626 printf " rcstack backup-db --help | -h\n"
1586 echo
1627 echo
1587
1628
1588 # :command.long_usage
1629 # :command.long_usage
1589 if [[ -n $long_usage ]]; then
1630 if [[ -n $long_usage ]]; then
1590 printf "%s\n" "Options:"
1631 printf "%s\n" "Options:"
1591
1632
1592 # :command.usage_fixed_flags
1633 # :command.usage_fixed_flags
1593 printf " %s\n" "--help, -h"
1634 printf " %s\n" "--help, -h"
1594 printf " Show this help\n"
1635 printf " Show this help\n"
1595 echo
1636 echo
1596
1637
1597 # :command.usage_args
1638 # :command.usage_args
1598 printf "%s\n" "Arguments:"
1639 printf "%s\n" "Arguments:"
1599
1640
1600 # :argument.usage
1641 # :argument.usage
1601 printf " %s\n" "DESTINATION"
1642 printf " %s\n" "DESTINATION"
1602 printf " Destination directory to store backup archive\n"
1643 printf " Destination directory to store backup archive\n"
1603 echo
1644 echo
1604
1645
1605 # :command.usage_examples
1646 # :command.usage_examples
1606 printf "%s\n" "Examples:"
1647 printf "%s\n" "Examples:"
1607 printf " # make backup gz compressed from container DB\n - ./rcstack backup-db /home/my-db-backup\n \n # restore backup\n - gunzip your_dump.sql.gz\n - ./rcstack cli db\n - \i /var/rc-data-dump/your_dump.sql\n"
1648 printf " # make backup gz compressed from container DB\n - ./rcstack backup-db /home/my-db-backup\n \n # restore backup\n - gunzip your_dump.sql.gz\n - ./rcstack cli db\n - \i /var/rc-data-dump/your_dump.sql\n"
1608 echo
1649 echo
1609
1650
1610 fi
1651 fi
1611 }
1652 }
1612
1653
1613 # :command.usage
1654 # :command.usage
1614 rcstack_backup_data_usage() {
1655 rcstack_backup_data_usage() {
1615 if [[ -n $long_usage ]]; then
1656 if [[ -n $long_usage ]]; then
1616 printf "rcstack backup-data - Backup RhodeCode storage\n"
1657 printf "rcstack backup-data - Backup RhodeCode storage\n"
1617 echo
1658 echo
1618
1659
1619 else
1660 else
1620 printf "rcstack backup-data - Backup RhodeCode storage\n"
1661 printf "rcstack backup-data - Backup RhodeCode storage\n"
1621 echo
1662 echo
1622
1663
1623 fi
1664 fi
1624
1665
1625 printf "%s\n" "Usage:"
1666 printf "%s\n" "Usage:"
1626 printf " rcstack backup-data DESTINATION\n"
1667 printf " rcstack backup-data DESTINATION\n"
1627 printf " rcstack backup-data --help | -h\n"
1668 printf " rcstack backup-data --help | -h\n"
1628 echo
1669 echo
1629
1670
1630 # :command.long_usage
1671 # :command.long_usage
1631 if [[ -n $long_usage ]]; then
1672 if [[ -n $long_usage ]]; then
1632 printf "%s\n" "Options:"
1673 printf "%s\n" "Options:"
1633
1674
1634 # :command.usage_fixed_flags
1675 # :command.usage_fixed_flags
1635 printf " %s\n" "--help, -h"
1676 printf " %s\n" "--help, -h"
1636 printf " Show this help\n"
1677 printf " Show this help\n"
1637 echo
1678 echo
1638
1679
1639 # :command.usage_args
1680 # :command.usage_args
1640 printf "%s\n" "Arguments:"
1681 printf "%s\n" "Arguments:"
1641
1682
1642 # :argument.usage
1683 # :argument.usage
1643 printf " %s\n" "DESTINATION"
1684 printf " %s\n" "DESTINATION"
1644 printf " Destination directory to store backup archive\n"
1685 printf " Destination directory to store backup archive\n"
1645 echo
1686 echo
1646
1687
1647 # :command.usage_examples
1688 # :command.usage_examples
1648 printf "%s\n" "Examples:"
1689 printf "%s\n" "Examples:"
1649 printf " # make backup gz compressed for rhodecode containers, and all volumes\n - ./rcstack backup-data /home/my-data-backup\n"
1690 printf " # make backup gz compressed for rhodecode containers, and all volumes\n - ./rcstack backup-data /home/my-data-backup\n"
1650 echo
1691 echo
1651
1692
1652 fi
1693 fi
1653 }
1694 }
1654
1695
1655 # :command.usage
1696 # :command.usage
1656 rcstack__completions_usage() {
1697 rcstack__completions_usage() {
1657 if [[ -n $long_usage ]]; then
1698 if [[ -n $long_usage ]]; then
1658 printf "rcstack _completions - Generate completions\n"
1699 printf "rcstack _completions - Generate completions\n"
1659 echo
1700 echo
1660
1701
1661 else
1702 else
1662 printf "rcstack _completions - Generate completions\n"
1703 printf "rcstack _completions - Generate completions\n"
1663 echo
1704 echo
1664
1705
1665 fi
1706 fi
1666
1707
1667 printf "%s\n" "Usage:"
1708 printf "%s\n" "Usage:"
1668 printf " rcstack _completions\n"
1709 printf " rcstack _completions\n"
1669 printf " rcstack _completions --help | -h\n"
1710 printf " rcstack _completions --help | -h\n"
1670 echo
1711 echo
1671
1712
1672 # :command.long_usage
1713 # :command.long_usage
1673 if [[ -n $long_usage ]]; then
1714 if [[ -n $long_usage ]]; then
1674 printf "%s\n" "Options:"
1715 printf "%s\n" "Options:"
1675
1716
1676 # :command.usage_fixed_flags
1717 # :command.usage_fixed_flags
1677 printf " %s\n" "--help, -h"
1718 printf " %s\n" "--help, -h"
1678 printf " Show this help\n"
1719 printf " Show this help\n"
1679 echo
1720 echo
1680
1721
1681 fi
1722 fi
1682 }
1723 }
1683
1724
1684 # :command.normalize_input
1725 # :command.normalize_input
1685 normalize_input() {
1726 normalize_input() {
1686 local arg flags
1727 local arg flags
1687
1728
1688 while [[ $# -gt 0 ]]; do
1729 while [[ $# -gt 0 ]]; do
1689 arg="$1"
1730 arg="$1"
1690 if [[ $arg =~ ^(--[a-zA-Z0-9_\-]+)=(.+)$ ]]; then
1731 if [[ $arg =~ ^(--[a-zA-Z0-9_\-]+)=(.+)$ ]]; then
1691 input+=("${BASH_REMATCH[1]}")
1732 input+=("${BASH_REMATCH[1]}")
1692 input+=("${BASH_REMATCH[2]}")
1733 input+=("${BASH_REMATCH[2]}")
1693 elif [[ $arg =~ ^(-[a-zA-Z0-9])=(.+)$ ]]; then
1734 elif [[ $arg =~ ^(-[a-zA-Z0-9])=(.+)$ ]]; then
1694 input+=("${BASH_REMATCH[1]}")
1735 input+=("${BASH_REMATCH[1]}")
1695 input+=("${BASH_REMATCH[2]}")
1736 input+=("${BASH_REMATCH[2]}")
1696 elif [[ $arg =~ ^-([a-zA-Z0-9][a-zA-Z0-9]+)$ ]]; then
1737 elif [[ $arg =~ ^-([a-zA-Z0-9][a-zA-Z0-9]+)$ ]]; then
1697 flags="${BASH_REMATCH[1]}"
1738 flags="${BASH_REMATCH[1]}"
1698 for ((i = 0; i < ${#flags}; i++)); do
1739 for ((i = 0; i < ${#flags}; i++)); do
1699 input+=("-${flags:i:1}")
1740 input+=("-${flags:i:1}")
1700 done
1741 done
1701 else
1742 else
1702 input+=("$arg")
1743 input+=("$arg")
1703 fi
1744 fi
1704
1745
1705 shift
1746 shift
1706 done
1747 done
1707 }
1748 }
1708 # :command.inspect_args
1749 # :command.inspect_args
1709 inspect_args() {
1750 inspect_args() {
1710 if ((${#args[@]})); then
1751 if ((${#args[@]})); then
1711 readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
1752 readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
1712 echo args:
1753 echo args:
1713 for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done
1754 for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done
1714 else
1755 else
1715 echo args: none
1756 echo args: none
1716 fi
1757 fi
1717
1758
1718 if ((${#other_args[@]})); then
1759 if ((${#other_args[@]})); then
1719 echo
1760 echo
1720 echo other_args:
1761 echo other_args:
1721 echo "- \${other_args[*]} = ${other_args[*]}"
1762 echo "- \${other_args[*]} = ${other_args[*]}"
1722 for i in "${!other_args[@]}"; do
1763 for i in "${!other_args[@]}"; do
1723 echo "- \${other_args[$i]} = ${other_args[$i]}"
1764 echo "- \${other_args[$i]} = ${other_args[$i]}"
1724 done
1765 done
1725 fi
1766 fi
1726
1767
1727 if ((${#deps[@]})); then
1768 if ((${#deps[@]})); then
1728 readarray -t sorted_keys < <(printf '%s\n' "${!deps[@]}" | sort)
1769 readarray -t sorted_keys < <(printf '%s\n' "${!deps[@]}" | sort)
1729 echo
1770 echo
1730 echo deps:
1771 echo deps:
1731 for k in "${sorted_keys[@]}"; do echo "- \${deps[$k]} = ${deps[$k]}"; done
1772 for k in "${sorted_keys[@]}"; do echo "- \${deps[$k]} = ${deps[$k]}"; done
1732 fi
1773 fi
1733
1774
1734 }
1775 }
1735
1776
1736 # :command.user_lib
1777 # :command.user_lib
1737 # src/lib/check_bootstrap.sh
1778 # src/lib/check_bootstrap.sh
1738
1779
1739 check_bootstrap() {
1780 check_bootstrap() {
1740 # Avoid destroying bootstrapping by simple start/stop
1781 # Avoid destroying bootstrapping by simple start/stop
1741 for stage_name in $BOOTSTRAP_STAGES; do
1782 for stage_name in $BOOTSTRAP_STAGES; do
1742 if ! config_has_key $stage_name ; then
1783 if ! config_has_key $stage_name ; then
1743 echo "$(yellow WARNING:) Bootstrap key $stage_name not found in config file $CONFIG_FILE!"
1784 echo "$(yellow WARNING:) Bootstrap key $stage_name not found in config file $CONFIG_FILE!"
1744 echo "$(yellow NOTICE:) Run this first: ./$RC_SCRIPT_NAME init"
1785 echo "$(yellow NOTICE:) Run this first: ./$RC_SCRIPT_NAME init"
1745 exit
1786 exit
1746 fi
1787 fi
1747 done
1788 done
1748
1789
1749 }
1790 }
1750
1791
1751 # src/lib/colors.sh
1792 # src/lib/colors.sh
1752 print_in_color() {
1793 print_in_color() {
1753 local color="$1"
1794 local color="$1"
1754 shift
1795 shift
1755 if [[ -z ${NO_COLOR+x} ]]; then
1796 if [[ -z ${NO_COLOR+x} ]]; then
1756 printf "$color%b\e[0m\n" "$*"
1797 printf "$color%b\e[0m\n" "$*"
1757 else
1798 else
1758 printf "%b\n" "$*"
1799 printf "%b\n" "$*"
1759 fi
1800 fi
1760 }
1801 }
1761
1802
1762 red() { print_in_color "\e[31m" "$*"; }
1803 red() { print_in_color "\e[31m" "$*"; }
1763 green() { print_in_color "\e[32m" "$*"; }
1804 green() { print_in_color "\e[32m" "$*"; }
1764 yellow() { print_in_color "\e[33m" "$*"; }
1805 yellow() { print_in_color "\e[33m" "$*"; }
1765 blue() { print_in_color "\e[34m" "$*"; }
1806 blue() { print_in_color "\e[34m" "$*"; }
1766 magenta() { print_in_color "\e[35m" "$*"; }
1807 magenta() { print_in_color "\e[35m" "$*"; }
1767 cyan() { print_in_color "\e[36m" "$*"; }
1808 cyan() { print_in_color "\e[36m" "$*"; }
1768 bold() { print_in_color "\e[1m" "$*"; }
1809 bold() { print_in_color "\e[1m" "$*"; }
1769 underlined() { print_in_color "\e[4m" "$*"; }
1810 underlined() { print_in_color "\e[4m" "$*"; }
1770 red_bold() { print_in_color "\e[1;31m" "$*"; }
1811 red_bold() { print_in_color "\e[1;31m" "$*"; }
1771 green_bold() { print_in_color "\e[1;32m" "$*"; }
1812 green_bold() { print_in_color "\e[1;32m" "$*"; }
1772 yellow_bold() { print_in_color "\e[1;33m" "$*"; }
1813 yellow_bold() { print_in_color "\e[1;33m" "$*"; }
1773 blue_bold() { print_in_color "\e[1;34m" "$*"; }
1814 blue_bold() { print_in_color "\e[1;34m" "$*"; }
1774 magenta_bold() { print_in_color "\e[1;35m" "$*"; }
1815 magenta_bold() { print_in_color "\e[1;35m" "$*"; }
1775 cyan_bold() { print_in_color "\e[1;36m" "$*"; }
1816 cyan_bold() { print_in_color "\e[1;36m" "$*"; }
1776 red_underlined() { print_in_color "\e[4;31m" "$*"; }
1817 red_underlined() { print_in_color "\e[4;31m" "$*"; }
1777 green_underlined() { print_in_color "\e[4;32m" "$*"; }
1818 green_underlined() { print_in_color "\e[4;32m" "$*"; }
1778 yellow_underlined() { print_in_color "\e[4;33m" "$*"; }
1819 yellow_underlined() { print_in_color "\e[4;33m" "$*"; }
1779 blue_underlined() { print_in_color "\e[4;34m" "$*"; }
1820 blue_underlined() { print_in_color "\e[4;34m" "$*"; }
1780 magenta_underlined() { print_in_color "\e[4;35m" "$*"; }
1821 magenta_underlined() { print_in_color "\e[4;35m" "$*"; }
1781 cyan_underlined() { print_in_color "\e[4;36m" "$*"; }
1822 cyan_underlined() { print_in_color "\e[4;36m" "$*"; }
1782
1823
1783 # src/lib/config.sh
1824 # src/lib/config.sh
1784
1825
1785 config_show() {
1826 config_show() {
1786 config_load
1827 config_load
1787 ini_show
1828 ini_show
1788 }
1829 }
1789
1830
1790 config_get() {
1831 config_get() {
1791 local key="$1"
1832 local key="$1"
1792 local default_value="$2"
1833 local default_value="$2"
1793
1834
1794 config_load
1835 config_load
1795 echo "${ini["$key"]:-$default_value}"
1836 echo "${ini["$key"]:-$default_value}"
1796 }
1837 }
1797
1838
1798 config_set() {
1839 config_set() {
1799 local key="$1"
1840 local key="$1"
1800 shift
1841 shift
1801 local value="$*"
1842 local value="$*"
1802
1843
1803 config_load
1844 config_load
1804 ini["$key"]="$value"
1845 ini["$key"]="$value"
1805 config_save
1846 config_save
1806 }
1847 }
1807
1848
1808 config_del() {
1849 config_del() {
1809 local key="$1"
1850 local key="$1"
1810
1851
1811 config_load
1852 config_load
1812 unset "ini[$key]"
1853 unset "ini[$key]"
1813 config_save
1854 config_save
1814 }
1855 }
1815
1856
1816 config_keys() {
1857 config_keys() {
1817 config_load
1858 config_load
1818 ini_keys
1859 ini_keys
1819 }
1860 }
1820
1861
1821 config_has_key() {
1862 config_has_key() {
1822 [[ $(config_get "$1") ]]
1863 [[ $(config_get "$1") ]]
1823 }
1864 }
1824
1865
1825 config_reload() {
1866 config_reload() {
1826 declare -g config_loaded=false
1867 declare -g config_loaded=false
1827 config_load
1868 config_load
1828 }
1869 }
1829
1870
1830 config_load() {
1871 config_load() {
1831 [[ "$config_loaded" == "true" ]] && return
1872 [[ "$config_loaded" == "true" ]] && return
1832
1873
1833 declare -g CONFIG_FILE=${CONFIG_FILE:=config.ini}
1874 declare -g CONFIG_FILE=${CONFIG_FILE:=config.ini}
1834 declare -g config_loaded=true
1875 declare -g config_loaded=true
1835 [[ -f "$CONFIG_FILE" ]] || touch "$CONFIG_FILE"
1876 [[ -f "$CONFIG_FILE" ]] || touch "$CONFIG_FILE"
1836 ini_load "$CONFIG_FILE"
1877 ini_load "$CONFIG_FILE"
1837 }
1878 }
1838
1879
1839 config_save() {
1880 config_save() {
1840 ini_save "$CONFIG_FILE"
1881 ini_save "$CONFIG_FILE"
1841 }
1882 }
1842
1883
1843 # src/lib/dotenv.sh
1884 # src/lib/dotenv.sh
1844
1885
1845 __dotenv=
1886 __dotenv=
1846 __dotenv_file=
1887 __dotenv_file=
1847 __dotenv_cmd=.env
1888 __dotenv_cmd=.env
1848
1889
1849 .env() {
1890 .env() {
1850 REPLY=()
1891 REPLY=()
1851 [[ $__dotenv_file || ${1-} == -* ]] || .env.--file .env || return
1892 [[ $__dotenv_file || ${1-} == -* ]] || .env.--file .env || return
1852 if declare -F -- ".env.${1-}" >/dev/null; then .env."$@"; return ; fi
1893 if declare -F -- ".env.${1-}" >/dev/null; then .env."$@"; return ; fi
1853 .env --help >&2; return 64
1894 .env --help >&2; return 64
1854 }
1895 }
1855
1896
1856 .env.-f() { .env.--file "$@"; }
1897 .env.-f() { .env.--file "$@"; }
1857
1898
1858 .env.get() {
1899 .env.get() {
1859 .env::arg "get requires a key" "$@" &&
1900 .env::arg "get requires a key" "$@" &&
1860 [[ "$__dotenv" =~ ^(.*(^|$'\n'))([ ]*)"$1="(.*)$ ]] &&
1901 [[ "$__dotenv" =~ ^(.*(^|$'\n'))([ ]*)"$1="(.*)$ ]] &&
1861 REPLY=${BASH_REMATCH[4]%%$'\n'*} && REPLY=${REPLY%"${REPLY##*[![:space:]]}"}
1902 REPLY=${BASH_REMATCH[4]%%$'\n'*} && REPLY=${REPLY%"${REPLY##*[![:space:]]}"}
1862 }
1903 }
1863
1904
1864 .env.get_or_error() {
1905 .env.get_or_error() {
1865 .env.get "$@" || { echo "$(red ERROR required key $@ not set in $RUNTIME_ENV file)"; exit 1; }
1906 .env.get "$@" || { echo "$(red ERROR required key $@ not set in $RUNTIME_ENV file)"; exit 1; }
1866 }
1907 }
1867
1908
1868 .env.parse() {
1909 .env.parse() {
1869 local line key
1910 local line key
1870 while IFS= read -r line; do
1911 while IFS= read -r line; do
1871 line=${line#"${line%%[![:space:]]*}"} # trim leading whitespace
1912 line=${line#"${line%%[![:space:]]*}"} # trim leading whitespace
1872 line=${line%"${line##*[![:space:]]}"} # trim trailing whitespace
1913 line=${line%"${line##*[![:space:]]}"} # trim trailing whitespace
1873 if [[ ! "$line" || "$line" == '#'* ]]; then continue ; fi
1914 if [[ ! "$line" || "$line" == '#'* ]]; then continue ; fi
1874 if (($#)); then
1915 if (($#)); then
1875 for key; do
1916 for key; do
1876 if [[ $key == "${line%%=*}" ]]; then REPLY+=("$line"); break;
1917 if [[ $key == "${line%%=*}" ]]; then REPLY+=("$line"); break;
1877 fi
1918 fi
1878 done
1919 done
1879 else
1920 else
1880 REPLY+=("$line")
1921 REPLY+=("$line")
1881 fi
1922 fi
1882 done <<<"$__dotenv"
1923 done <<<"$__dotenv"
1883 ((${#REPLY[@]}))
1924 ((${#REPLY[@]}))
1884 }
1925 }
1885
1926
1886 .env.export() { ! .env.parse "$@" || export "${REPLY[@]}"; }
1927 .env.export() { ! .env.parse "$@" || export "${REPLY[@]}"; }
1887
1928
1888 .env.set() {
1929 .env.set() {
1889 .env::file load || return ; local key saved=$__dotenv
1930 .env::file load || return ; local key saved=$__dotenv
1890 while (($#)); do
1931 while (($#)); do
1891 key=${1#+}; key=${key%%=*}
1932 key=${1#+}; key=${key%%=*}
1892 if .env.get "$key"; then
1933 if .env.get "$key"; then
1893 REPLY=()
1934 REPLY=()
1894 if [[ $1 == +* ]]; then shift; continue # skip if already found
1935 if [[ $1 == +* ]]; then shift; continue # skip if already found
1895 elif [[ $1 == *=* ]]; then
1936 elif [[ $1 == *=* ]]; then
1896 __dotenv=${BASH_REMATCH[1]}${BASH_REMATCH[3]}$1$'\n'${BASH_REMATCH[4]#*$'\n'}
1937 __dotenv=${BASH_REMATCH[1]}${BASH_REMATCH[3]}$1$'\n'${BASH_REMATCH[4]#*$'\n'}
1897 else
1938 else
1898 __dotenv=${BASH_REMATCH[1]}${BASH_REMATCH[4]#*$'\n'}
1939 __dotenv=${BASH_REMATCH[1]}${BASH_REMATCH[4]#*$'\n'}
1899 continue # delete all occurrences
1940 continue # delete all occurrences
1900 fi
1941 fi
1901 elif [[ $1 == *=* ]]; then
1942 elif [[ $1 == *=* ]]; then
1902 __dotenv+="${1#+}"$'\n'
1943 __dotenv+="${1#+}"$'\n'
1903 fi
1944 fi
1904 shift
1945 shift
1905 done
1946 done
1906 [[ $__dotenv == "$saved" ]] || .env::file save
1947 [[ $__dotenv == "$saved" ]] || .env::file save
1907 }
1948 }
1908
1949
1909 .env.puts() { echo "${1-}">>"$__dotenv_file" && __dotenv+="$1"$'\n'; }
1950 .env.puts() { echo "${1-}">>"$__dotenv_file" && __dotenv+="$1"$'\n'; }
1910
1951
1911 .env.generate() {
1952 .env.generate() {
1912 .env::arg "key required for generate" "$@" || return
1953 .env::arg "key required for generate" "$@" || return
1913 .env.get "$1" && return || REPLY=$("${@:2}") || return
1954 .env.get "$1" && return || REPLY=$("${@:2}") || return
1914 .env::one "generate: ouptut of '${*:2}' has more than one line" "$REPLY" || return
1955 .env::one "generate: ouptut of '${*:2}' has more than one line" "$REPLY" || return
1915 .env.puts "$1=$REPLY"
1956 .env.puts "$1=$REPLY"
1916 }
1957 }
1917
1958
1918 .env.--file() {
1959 .env.--file() {
1919 .env::arg "filename required for --file" "$@" || return
1960 .env::arg "filename required for --file" "$@" || return
1920 __dotenv_file=$1; .env::file load || return
1961 __dotenv_file=$1; .env::file load || return
1921 (($#<2)) || .env "${@:2}"
1962 (($#<2)) || .env "${@:2}"
1922 }
1963 }
1923
1964
1924 .env::arg() { [[ "${2-}" ]] || { echo "$__dotenv_cmd: $1" >&2; return 64; }; }
1965 .env::arg() { [[ "${2-}" ]] || { echo "$__dotenv_cmd: $1" >&2; return 64; }; }
1925
1966
1926 .env::one() { [[ "$2" != *$'\n'* ]] || .env::arg "$1"; }
1967 .env::one() { [[ "$2" != *$'\n'* ]] || .env::arg "$1"; }
1927
1968
1928 .env::file() {
1969 .env::file() {
1929 local REPLY=$__dotenv_file
1970 local REPLY=$__dotenv_file
1930 case "$1" in
1971 case "$1" in
1931 load)
1972 load)
1932 __dotenv=; ! [[ -f "$REPLY" ]] || __dotenv="$(<"$REPLY")"$'\n' || return ;;
1973 __dotenv=; ! [[ -f "$REPLY" ]] || __dotenv="$(<"$REPLY")"$'\n' || return ;;
1933 save)
1974 save)
1934 if [[ -L "$REPLY" ]] && declare -F -- realpath.resolved >/dev/null; then
1975 if [[ -L "$REPLY" ]] && declare -F -- realpath.resolved >/dev/null; then
1935 realpath.resolved "$REPLY"
1976 realpath.resolved "$REPLY"
1936 fi
1977 fi
1937 { [[ ! -f "$REPLY" ]] || cp -p "$REPLY" "$REPLY.bak"; } &&
1978 { [[ ! -f "$REPLY" ]] || cp -p "$REPLY" "$REPLY.bak"; } &&
1938 printf %s "$__dotenv" >"$REPLY.bak" && cp -f "$REPLY.bak" "$REPLY" && rm -f "$REPLY.bak"
1979 printf %s "$__dotenv" >"$REPLY.bak" && cp -f "$REPLY.bak" "$REPLY" && rm -f "$REPLY.bak"
1939 esac
1980 esac
1940 }
1981 }
1941
1982
1942 #
1983 #
1943 #__dotenv() {
1984 #__dotenv() {
1944 # set -eu
1985 # set -eu
1945 # __dotenv_cmd=${0##*/}
1986 # __dotenv_cmd=${0##*/}
1946 # .env.export() { .env.parse "$@" || return 0; printf 'export %q\n' "${REPLY[@]}"; REPLY=(); }
1987 # .env.export() { .env.parse "$@" || return 0; printf 'export %q\n' "${REPLY[@]}"; REPLY=(); }
1947 # .env "$@" || return $?
1988 # .env "$@" || return $?
1948 # ${REPLY[@]+printf '%s\n' "${REPLY[@]}"}
1989 # ${REPLY[@]+printf '%s\n' "${REPLY[@]}"}
1949 #}
1990 #}
1950 #if [[ $0 == "${BASH_SOURCE-}" ]]; then __dotenv "$@"; exit; fi
1991 #if [[ $0 == "${BASH_SOURCE-}" ]]; then __dotenv "$@"; exit; fi
1951
1992
1952 # src/lib/get_docker_definitions.sh
1993 # src/lib/get_docker_definitions.sh
1953
1994
1954 get_docker_definitions() {
1995 get_docker_definitions() {
1955 SOURCE_DIR=$PWD
1996 SOURCE_DIR=$PWD
1956 RHODECODE_DOCKER_HASH=$1
1997 RHODECODE_DOCKER_HASH=$1
1957 FULL_MODE=$2
1998 FULL_MODE=$2
1958 DEBUG=$3
1999 DEBUG=$3
1959
2000
1960 final_archive_url="$SERVER_URL/$RHODECODE_DOCKER_HASH.tgz"
2001 final_archive_url="$SERVER_URL/$RHODECODE_DOCKER_HASH.tgz"
1961 extracted_archive_dir="rhodecode-enterprise-docker-id-bacb-sub-0-archive-all"
2002 extracted_archive_dir="rhodecode-enterprise-docker-id-bacb-sub-0-archive-all"
1962
2003
1963 # download sources
2004 # download sources
1964 echo "bootstrap_definitions: download rhodecode docker definitions from: $final_archive_url"
2005 echo "bootstrap_definitions: download rhodecode docker definitions from: $final_archive_url"
1965 echo ""
2006 echo ""
1966
2007
1967 if [ $DEBUG ]; then
2008 if [ $DEBUG ]; then
1968 echo "bootstrap_definitions: downloading: $SERVER_URL/$RHODECODE_DOCKER_HASH.tgz"
2009 echo "bootstrap_definitions: downloading: $SERVER_URL/$RHODECODE_DOCKER_HASH.tgz"
1969 curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $final_archive_url | tar -xz -C "$SOURCE_DIR"
2010 curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $final_archive_url | tar -xz -C "$SOURCE_DIR"
1970
2011
1971 echo "extracted archive to $SOURCE_DIR"
2012 echo "extracted archive to $SOURCE_DIR"
1972 echo "bootstrap_definitions: running CP $SOURCE_DIR/$extracted_archive_dir/* $SOURCE_DIR"
2013 echo "bootstrap_definitions: running CP $SOURCE_DIR/$extracted_archive_dir/* $SOURCE_DIR"
1973 cp -r -f -v $SOURCE_DIR/$extracted_archive_dir/* $SOURCE_DIR
2014 cp -r -f -v $SOURCE_DIR/$extracted_archive_dir/* $SOURCE_DIR
1974
2015
1975 echo "bootstrap_definitions: removing $SOURCE_DIR/$extracted_archive_dir"
2016 echo "bootstrap_definitions: removing $SOURCE_DIR/$extracted_archive_dir"
1976 rm -r "$SOURCE_DIR/$extracted_archive_dir"
2017 rm -r "$SOURCE_DIR/$extracted_archive_dir"
1977 else
2018 else
1978 curl -s --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $final_archive_url | tar -xz -C "$SOURCE_DIR"
2019 curl -s --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $final_archive_url | tar -xz -C "$SOURCE_DIR"
1979
2020
1980 cp -r -f $SOURCE_DIR/$extracted_archive_dir/* $SOURCE_DIR
2021 cp -r -f $SOURCE_DIR/$extracted_archive_dir/* $SOURCE_DIR
1981
2022
1982 rm -r "$SOURCE_DIR/$extracted_archive_dir"
2023 rm -r "$SOURCE_DIR/$extracted_archive_dir"
1983 fi
2024 fi
1984
2025
1985 echo "$(green bootstrap_definitions: docker definitions extracted to $SOURCE_DIR)"
2026 echo "$(green bootstrap_definitions: docker definitions extracted to $SOURCE_DIR)"
1986
2027
1987 # cleanup of backup files, just good to have, ignore any warnings
2028 # cleanup of backup files, just good to have, ignore any warnings
1988 # NOTE: Disabled for backward compat
2029 # NOTE: Disabled for backward compat
1989 #find "$SOURCE_DIR" -nowarn -ignore_readdir_race -iname "*.~*~" -delete 2> /dev/null
2030 #find "$SOURCE_DIR" -nowarn -ignore_readdir_race -iname "*.~*~" -delete 2> /dev/null
1990
2031
1991 # some cleanup of things we don't need in cli
2032 # some cleanup of things we don't need in cli
1992 if [[ ! $FULL_MODE ]]; then
2033 if [[ ! $FULL_MODE ]]; then
1993 rm dev-tools
2034 rm dev-tools
1994 rm -r scripts/dev-tools
2035 rm -r scripts/dev-tools
1995 rm -r entrypoints.d
2036 rm -r entrypoints.d
1996 fi
2037 fi
1997 }
2038 }
1998
2039
1999 # src/lib/ini.sh
2040 # src/lib/ini.sh
2000
2041
2001 ini_load() {
2042 ini_load() {
2002 declare -gA ini
2043 declare -gA ini
2003
2044
2004 local ini_file="$1"
2045 local ini_file="$1"
2005
2046
2006 local section=""
2047 local section=""
2007 local key=""
2048 local key=""
2008 local value=""
2049 local value=""
2009 local section_regex="^\[(.+)\]"
2050 local section_regex="^\[(.+)\]"
2010 local key_regex="^([^ =]+) *= *(.*) *$"
2051 local key_regex="^([^ =]+) *= *(.*) *$"
2011 local comment_regex="^;"
2052 local comment_regex="^;"
2012
2053
2013 while IFS= read -r line; do
2054 while IFS= read -r line; do
2014 if [[ $line =~ $comment_regex ]]; then
2055 if [[ $line =~ $comment_regex ]]; then
2015 continue
2056 continue
2016 elif [[ $line =~ $section_regex ]]; then
2057 elif [[ $line =~ $section_regex ]]; then
2017 section="${BASH_REMATCH[1]}."
2058 section="${BASH_REMATCH[1]}."
2018 elif [[ $line =~ $key_regex ]]; then
2059 elif [[ $line =~ $key_regex ]]; then
2019 key="${BASH_REMATCH[1]}"
2060 key="${BASH_REMATCH[1]}"
2020 value="${BASH_REMATCH[2]}"
2061 value="${BASH_REMATCH[2]}"
2021 ini["${section}${key}"]="$value"
2062 ini["${section}${key}"]="$value"
2022 fi
2063 fi
2023 done <"$ini_file"
2064 done <"$ini_file"
2024 }
2065 }
2025
2066
2026 ini_save() {
2067 ini_save() {
2027 declare -gA ini
2068 declare -gA ini
2028
2069
2029 local ini_file="$1"
2070 local ini_file="$1"
2030
2071
2031 local current_section=""
2072 local current_section=""
2032 local has_free_keys=false
2073 local has_free_keys=false
2033
2074
2034 rm -f "$ini_file"
2075 rm -f "$ini_file"
2035
2076
2036 for key in $(ini_keys); do
2077 for key in $(ini_keys); do
2037 [[ $key == *.* ]] && continue
2078 [[ $key == *.* ]] && continue
2038 has_free_keys=true
2079 has_free_keys=true
2039 value="${ini[$key]}"
2080 value="${ini[$key]}"
2040 echo "$key = $value" >>"$ini_file"
2081 echo "$key = $value" >>"$ini_file"
2041 done
2082 done
2042
2083
2043 [[ "${has_free_keys}" == "true" ]] && echo >>"$ini_file"
2084 [[ "${has_free_keys}" == "true" ]] && echo >>"$ini_file"
2044
2085
2045 for key in $(ini_keys); do
2086 for key in $(ini_keys); do
2046 [[ $key == *.* ]] || continue
2087 [[ $key == *.* ]] || continue
2047 value="${ini[$key]}"
2088 value="${ini[$key]}"
2048 IFS="." read -r section_name key_name <<<"$key"
2089 IFS="." read -r section_name key_name <<<"$key"
2049
2090
2050 if [[ "$current_section" != "$section_name" ]]; then
2091 if [[ "$current_section" != "$section_name" ]]; then
2051 [[ $current_section ]] && echo >>"$ini_file"
2092 [[ $current_section ]] && echo >>"$ini_file"
2052 echo "[$section_name]" >>"$ini_file"
2093 echo "[$section_name]" >>"$ini_file"
2053 current_section="$section_name"
2094 current_section="$section_name"
2054 fi
2095 fi
2055
2096
2056 echo "$key_name = $value" >>"$ini_file"
2097 echo "$key_name = $value" >>"$ini_file"
2057 done
2098 done
2058 }
2099 }
2059
2100
2060 ini_show() {
2101 ini_show() {
2061 declare -gA ini
2102 declare -gA ini
2062
2103
2063 for key in $(ini_keys); do
2104 for key in $(ini_keys); do
2064 echo "$key = ${ini[$key]}"
2105 echo "$key = ${ini[$key]}"
2065 done
2106 done
2066 }
2107 }
2067
2108
2068 ini_keys() {
2109 ini_keys() {
2069 declare -gA ini
2110 declare -gA ini
2070
2111
2071 local keys=("${!ini[@]}")
2112 local keys=("${!ini[@]}")
2072 for a in "${keys[@]}"; do echo "$a"; done | sort
2113 for a in "${keys[@]}"; do echo "$a"; done | sort
2073 }
2114 }
2074
2115
2075 # src/lib/reconfigure_ini.sh
2116 # src/lib/reconfigure_ini.sh
2076 sed_replace() {
2117 sed_replace() {
2077 if [[ $ini_path == "" ]]; then
2118 if [[ $ini_path == "" ]]; then
2078 echo "ERROR: missing 'ini_path' variable"
2119 echo "ERROR: missing 'ini_path' variable"
2079 fi
2120 fi
2080
2121
2081 sed_func "$1" "$2" "$ini_path"
2122 sed_func "$1" "$2" "$ini_path"
2082 }
2123 }
2083
2124
2084 sed_safe_path() {
2125 sed_safe_path() {
2085 echo $((echo $1|sed -r 's/([\$\.\*\/\[\\^])/\\\1/g'|sed 's/[]]/\[]]/g')>&1)
2126 echo $((echo $1|sed -r 's/([\$\.\*\/\[\\^])/\\\1/g'|sed 's/[]]/\[]]/g')>&1)
2086 }
2127 }
2087
2128
2088 config_vcsserver_ini() {
2129 config_vcsserver_ini() {
2089
2130
2090 #host/port
2131 #host/port
2091 sed_replace '^#?host = .*' 'host = 0\.0\.0\.0'
2132 sed_replace '^#?host = .*' 'host = 0\.0\.0\.0'
2092 sed_replace '^#?port = .*' 'port = 10010'
2133 sed_replace '^#?port = .*' 'port = 10010'
2093
2134
2094 # workers adjustment
2135 # workers adjustment
2095 sed_replace '^#?workers = .*' 'workers = 1'
2136 sed_replace '^#?workers = .*' 'workers = 1'
2096 sed_replace '^#?memory_max_usage = .*' 'memory_max_usage = 2147483648'
2137 sed_replace '^#?memory_max_usage = .*' 'memory_max_usage = 2147483648'
2097 sed_replace '^#?core\.binary_dir = .*' 'core.binary_dir = \/usr\/local\/bin\/rhodecode_bin\/vcs_bin'
2138 sed_replace '^#?core\.binary_dir = .*' 'core.binary_dir = \/usr\/local\/bin\/rhodecode_bin\/vcs_bin'
2098
2139
2099 sed_replace '^#?cache_dir = .*' 'cache_dir = \/var\/opt\/rhodecode_data'
2140 sed_replace '^#?cache_dir = .*' 'cache_dir = \/var\/opt\/rhodecode_data'
2100
2141
2101 sed_replace '^#?rc_cache\.repo_object\.expiration_time = .*' '#rc_cache.repo_object.expiration_time = 2592000'
2142 sed_replace '^#?rc_cache\.repo_object\.expiration_time = .*' '#rc_cache.repo_object.expiration_time = 2592000'
2102 sed_replace '^#?rc_cache\.repo_object\.backend = dogpile\.cache\.rc\.redis_msgpack' 'rc_cache.repo_object.backend = dogpile.cache.rc.redis_msgpack'
2143 sed_replace '^#?rc_cache\.repo_object\.backend = dogpile\.cache\.rc\.redis_msgpack' 'rc_cache.repo_object.backend = dogpile.cache.rc.redis_msgpack'
2103
2144
2104 sed_replace '^#?rc_cache\.repo_object\.arguments\.socket_timeout = .*' 'rc_cache.repo_object.arguments.socket_timeout = 30'
2145 sed_replace '^#?rc_cache\.repo_object\.arguments\.socket_timeout = .*' 'rc_cache.repo_object.arguments.socket_timeout = 30'
2105 sed_replace '^#?rc_cache\.repo_object\.arguments\.db = .*' 'rc_cache.repo_object.arguments.db = 5'
2146 sed_replace '^#?rc_cache\.repo_object\.arguments\.db = .*' 'rc_cache.repo_object.arguments.db = 5'
2106 sed_replace '^#?rc_cache\.repo_object\.arguments\.port = .*' 'rc_cache.repo_object.arguments.port = 6379'
2147 sed_replace '^#?rc_cache\.repo_object\.arguments\.port = .*' 'rc_cache.repo_object.arguments.port = 6379'
2107 sed_replace '^#?rc_cache\.repo_object\.arguments\.host = .*' 'rc_cache.repo_object.arguments.host = redis'
2148 sed_replace '^#?rc_cache\.repo_object\.arguments\.host = .*' 'rc_cache.repo_object.arguments.host = redis'
2108 sed_replace '^#?rc_cache\.repo_object\.arguments\.redis_expiration_time = .*' 'rc_cache.repo_object.arguments.redis_expiration_time = 3592000'
2149 sed_replace '^#?rc_cache\.repo_object\.arguments\.redis_expiration_time = .*' 'rc_cache.repo_object.arguments.redis_expiration_time = 3592000'
2109
2150
2110 #statsd enable
2151 #statsd enable
2111 sed_replace '^#?statsd.enabled = .*' 'statsd.enabled = true'
2152 sed_replace '^#?statsd.enabled = .*' 'statsd.enabled = true'
2112 sed_replace '^#?statsd.statsd_host = .*' 'statsd.statsd_host = statsd-exporter'
2153 sed_replace '^#?statsd.statsd_host = .*' 'statsd.statsd_host = statsd-exporter'
2113 sed_replace '^#?statsd.statsd_port = .*' 'statsd.statsd_port = 9125'
2154 sed_replace '^#?statsd.statsd_port = .*' 'statsd.statsd_port = 9125'
2114
2155
2115 }
2156 }
2116
2157
2117 config_rhodecode_ini() {
2158 config_rhodecode_ini() {
2118 #host/port
2159 #host/port
2119 sed_replace '^#?host = .*' 'host = 0\.0\.0\.0'
2160 sed_replace '^#?host = .*' 'host = 0\.0\.0\.0'
2120 sed_replace '^#?port = .*' 'port = 10020'
2161 sed_replace '^#?port = .*' 'port = 10020'
2121
2162
2122 # email
2163 # email
2123 sed_replace '^#?email_prefix = .*' 'email_prefix = [RhodeCode]'
2164 sed_replace '^#?email_prefix = .*' 'email_prefix = [RhodeCode]'
2124 sed_replace '^#?app_email_from = .*' "app_email_from = rhodecode-noreply@$RC_HOSTNAME"
2165 sed_replace '^#?app_email_from = .*' "app_email_from = rhodecode-noreply@$RC_HOSTNAME"
2125
2166
2126 # app-instance-uuid
2167 # app-instance-uuid
2127 sed_replace '^app_instance_uuid = .*' "app_instance_uuid = $RC_APP_INSTANCE_UUID"
2168 sed_replace '^app_instance_uuid = .*' "app_instance_uuid = $RC_APP_INSTANCE_UUID"
2128
2169
2129 # app base
2170 # app base
2130 sed_replace '^app\.base_url = .*' "app\.base_url = $RC_APP_BASE_URL"
2171 sed_replace '^app\.base_url = .*' "app\.base_url = $RC_APP_BASE_URL"
2131
2172
2132 sed_replace '^app\.service_api\.host = .*' "app\.service_api\.host = http:\/\/rhodecode:10020"
2173 sed_replace '^app\.service_api\.host = .*' "app\.service_api\.host = http:\/\/rhodecode:10020"
2133 sed_replace '^app\.service_api\.token = .*' "app\.service_api\.token = $RC_SHARED_KEY"
2174 sed_replace '^app\.service_api\.token = .*' "app\.service_api\.token = $RC_SHARED_KEY"
2134
2175
2135 # set license_token
2176 # set license_token
2136 sed_replace '^#?license_token =.*' "license_token = $RC_LICENSE_TOKEN"
2177 sed_replace '^#?license_token =.*' "license_token = $RC_LICENSE_TOKEN"
2137 # set Edition
2178 # set Edition
2138 sed_replace '^use = egg:rhodecode-enterprise.*' "use = egg:rhodecode-enterprise-$RC_EDITION"
2179 sed_replace '^use = egg:rhodecode-enterprise.*' "use = egg:rhodecode-enterprise-$RC_EDITION"
2139
2180
2140 # enable celery
2181 # enable celery
2141 sed_replace '^#?use_celery = .*' 'use_celery = true'
2182 sed_replace '^#?use_celery = .*' 'use_celery = true'
2142
2183
2143 # DB
2184 # DB
2144 sed_replace '^sqlalchemy\.db1\.url =.*' "sqlalchemy\.db1\.url = $RC_SQLALCHEMY_DB1_URL"
2185 sed_replace '^sqlalchemy\.db1\.url =.*' "sqlalchemy\.db1\.url = $RC_SQLALCHEMY_DB1_URL"
2145
2186
2146 #CHANNELSTREAM WS_URL
2187 #CHANNELSTREAM WS_URL
2147 sed_replace '^#?channelstream\.ws_url =.*' "channelstream\.ws_url = $RC_CHANNELSTREAM_WS_URL"
2188 sed_replace '^#?channelstream\.ws_url =.*' "channelstream\.ws_url = $RC_CHANNELSTREAM_WS_URL"
2148
2189
2149 # set cache dir
2190 # set cache dir
2150 sed_replace '^#?cache_dir = .*' 'cache_dir = \/var\/opt\/rhodecode_data'
2191 sed_replace '^#?cache_dir = .*' 'cache_dir = \/var\/opt\/rhodecode_data'
2151
2192
2152 # set archive cache dir
2193 # set archive cache dir
2153 sed_replace '^#?archive_cache_dir = .*' 'archive_cache_dir = \/var\/opt\/rhodecode_data\/tarballcache'
2194 sed_replace '^#?archive_cache_dir = .*' 'archive_cache_dir = \/var\/opt\/rhodecode_data\/tarballcache'
2154
2195
2155 # set file_store path
2196 # set file_store path
2156 sed_replace '^#?file_store\.storage_path = .*' 'file_store.storage_path = \/var\/opt\/rhodecode_data\/file_store'
2197 sed_replace '^#?file_store\.storage_path = .*' 'file_store.storage_path = \/var\/opt\/rhodecode_data\/file_store'
2157
2198
2158 # cleanup rabbitmq example entry
2199 # cleanup rabbitmq example entry
2159 sed_replace '^#celery\.broker_url = amqp.*' ''
2200 sed_replace '^#celery\.broker_url = amqp.*' ''
2160 sed_replace '^#?celery\.broker_url = .*' 'celery\.broker_url = redis:\/\/redis:6379\/8'
2201 sed_replace '^#?celery\.broker_url = .*' 'celery\.broker_url = redis:\/\/redis:6379\/8'
2161 sed_replace '^#?celery\.result_backend = .*' 'celery\.result_backend = redis:\/\/redis:6379\/8'
2202 sed_replace '^#?celery\.result_backend = .*' 'celery\.result_backend = redis:\/\/redis:6379\/8'
2162
2203
2163 # switch beaker sessions to Redis based
2204 # switch beaker sessions to Redis based
2164 sed_replace '^#?beaker.session.type = file.*' '#beaker.session.type = file'
2205 sed_replace '^#?beaker.session.type = file.*' '#beaker.session.type = file'
2165 sed_replace '^#?beaker.session.data_dir = .*' '#beaker.session.data_dir = \/tmp\/data\/sessions'
2206 sed_replace '^#?beaker.session.data_dir = .*' '#beaker.session.data_dir = \/tmp\/data\/sessions'
2166
2207
2167 # enable redis db2
2208 # enable redis db2
2168 sed_replace '^#?beaker\.session\.type = ext:redis' 'beaker.session.type = ext:redis'
2209 sed_replace '^#?beaker\.session\.type = ext:redis' 'beaker.session.type = ext:redis'
2169 sed_replace '^#?beaker\.session\.url = redis:\/\/.+\/2' 'beaker.session.url = redis:\/\/redis:6379\/2'
2210 sed_replace '^#?beaker\.session\.url = redis:\/\/.+\/2' 'beaker.session.url = redis:\/\/redis:6379\/2'
2170
2211
2171 # sed_replace '^#?beaker.session.type = ext:database.*' 'beaker.session.type = ext:database'
2212 # sed_replace '^#?beaker.session.type = ext:database.*' 'beaker.session.type = ext:database'
2172 # sed_replace '^#?beaker.session.sa.url = postgresql.*' 'beaker.session.sa.url = postgresql://{{rhodecode_db_username}}:{{rhodecode_db_password}}@localhost/{{rhodecode_db_name}}'
2213 # sed_replace '^#?beaker.session.sa.url = postgresql.*' 'beaker.session.sa.url = postgresql://{{rhodecode_db_username}}:{{rhodecode_db_password}}@localhost/{{rhodecode_db_name}}'
2173
2214
2174 # hooks reconfigure for auto-bind to host
2215 # hooks reconfigure for auto-bind to host
2175 sed_replace '^#?vcs.hooks.host = .*' 'vcs.hooks.host = \*'
2216 sed_replace '^#?vcs.hooks.host = .*' 'vcs.hooks.host = \*'
2176 sed_replace '^#?vcs.server = .*' 'vcs.server = vcsserver:10010'
2217 sed_replace '^#?vcs.server = .*' 'vcs.server = vcsserver:10010'
2177
2218
2178 # enable SVN
2219 # enable SVN
2179 sed_replace '^#?svn.proxy.generate_config = .*' 'svn.proxy.generate_config = true'
2220 sed_replace '^#?svn.proxy.generate_config = .*' 'svn.proxy.generate_config = true'
2180
2221
2181 # enable SSH
2222 # enable SSH
2182 sed_replace '^#?ssh.generate_authorized_keyfile = .*' 'ssh.generate_authorized_keyfile = true'
2223 sed_replace '^#?ssh.generate_authorized_keyfile = .*' 'ssh.generate_authorized_keyfile = true'
2183
2224
2184 #statsd enable
2225 #statsd enable
2185 sed_replace '^#?statsd.enabled = .*' 'statsd.enabled = true'
2226 sed_replace '^#?statsd.enabled = .*' 'statsd.enabled = true'
2186 sed_replace '^#?statsd.statsd_host = .*' 'statsd.statsd_host = statsd-exporter'
2227 sed_replace '^#?statsd.statsd_host = .*' 'statsd.statsd_host = statsd-exporter'
2187 sed_replace '^#?statsd.statsd_port = .*' 'statsd.statsd_port = 9125'
2228 sed_replace '^#?statsd.statsd_port = .*' 'statsd.statsd_port = 9125'
2188
2229
2189 # the wrapper_cmd
2230 # the wrapper_cmd
2190 sed_replace '^#?ssh.wrapper_cmd = .*' 'ssh.wrapper_cmd = \/usr\/local\/bin\/rhodecode_bin\/bin\/rc-ssh-wrapper'
2231 sed_replace '^#?ssh.wrapper_cmd = .*' 'ssh.wrapper_cmd = \/usr\/local\/bin\/rhodecode_bin\/bin\/rc-ssh-wrapper'
2191
2232
2192 sed_replace '^#?api_access_controllers_whitelist = .*' 'api_access_controllers_whitelist = RepoFilesView:repo_archivefile, RepoFilesView:repo_file_raw'
2233 sed_replace '^#?api_access_controllers_whitelist = .*' 'api_access_controllers_whitelist = RepoFilesView:repo_archivefile, RepoFilesView:repo_file_raw'
2193
2234
2194 # # set search to elasticsearch
2235 # # set search to elasticsearch
2195 # # enabled modules for Whoosh we remove, we have duplicates there..
2236 # # enabled modules for Whoosh we remove, we have duplicates there..
2196 # '^search.module = .*' ''
2237 # '^search.module = .*' ''
2197 # '^search.location = .*' ''
2238 # '^search.location = .*' ''
2198 #
2239 #
2199 # '^#?search.module = .*' 'search.module = rc_elasticsearch'
2240 # '^#?search.module = .*' 'search.module = rc_elasticsearch'
2200 # '^#?search.location = .*' 'search.location = http://localhost:9200'
2241 # '^#?search.location = .*' 'search.location = http://localhost:9200'
2201 # '^#?search.es_version = .*' 'search.es_version = 6'
2242 # '^#?search.es_version = .*' 'search.es_version = 6'
2202
2243
2203 # enable Chat
2244 # enable Chat
2204 sed_replace '^#?chat.enabled = .*' 'chat.enabled = true'
2245 sed_replace '^#?chat.enabled = .*' 'chat.enabled = true'
2205
2246
2206 }
2247 }
2207
2248
2208 # src/lib/send_completions.sh
2249 # src/lib/send_completions.sh
2209
2250
2210 # src/lib/utils.sh
2251 # src/lib/utils.sh
2211
2252
2212 generate_md5() {
2253 generate_md5() {
2213 local input_string="$1"
2254 local input_string="$1"
2214
2255
2215 if command -v md5 &> /dev/null; then
2256 if command -v md5 &> /dev/null; then
2216 echo -n "$input_string" | md5
2257 echo -n "$input_string" | md5
2217 elif command -v md5sum &> /dev/null; then
2258 elif command -v md5sum &> /dev/null; then
2218 echo -n "$input_string" | md5sum | awk '{print $1}'
2259 echo -n "$input_string" | md5sum | awk '{print $1}'
2219 else
2260 else
2220 echo "Error: Neither md5 nor md5sum command is available. Please make sure this is installed in your system"
2261 echo "Error: Neither md5 nor md5sum command is available. Please make sure this is installed in your system"
2221 return 1
2262 return 1
2222 fi
2263 fi
2223 }
2264 }
2224
2265
2225 random_str() {
2266 random_str() {
2226 len=$1
2267 len=$1
2227 random_generate=$(generate_md5 $RANDOM | head -c $len)
2268 random_generate=$(generate_md5 $RANDOM | head -c $len)
2228 echo "$random_generate"
2269 echo "$random_generate"
2229 }
2270 }
2230
2271
2231 semver_debug() {
2272 semver_debug() {
2232 if [ "$semver_debug" = "debug" ]; then printf "DEBUG: %s$1 \n"; fi
2273 if [ "$semver_debug" = "debug" ]; then printf "DEBUG: %s$1 \n"; fi
2233 }
2274 }
2234
2275
2235 # params char
2276 # params char
2236 # returns Integer
2277 # returns Integer
2237 ord() {
2278 ord() {
2238 printf '%d' "'$1"
2279 printf '%d' "'$1"
2239 }
2280 }
2240
2281
2241 isNumber() {
2282 isNumber() {
2242 string=$1
2283 string=$1
2243 char=""
2284 char=""
2244 while true; do
2285 while true; do
2245 substract="${string#?}" # All but the first character of the string
2286 substract="${string#?}" # All but the first character of the string
2246 char="${string%"$substract"}" # Remove $rest, and you're left with the first character
2287 char="${string%"$substract"}" # Remove $rest, and you're left with the first character
2247 string="$substract"
2288 string="$substract"
2248 # no more chars to compare then success
2289 # no more chars to compare then success
2249 if [ -z "$char" ]; then
2290 if [ -z "$char" ]; then
2250 printf "true"
2291 printf "true"
2251 return 1
2292 return 1
2252 fi
2293 fi
2253 # break if some of the chars is not a number
2294 # break if some of the chars is not a number
2254 if [ "$(ord "$char")" -lt 48 ] || [ "$(ord "$char")" -gt 57 ]; then
2295 if [ "$(ord "$char")" -lt 48 ] || [ "$(ord "$char")" -gt 57 ]; then
2255 printf "false"
2296 printf "false"
2256 return 0
2297 return 0
2257 fi
2298 fi
2258 done
2299 done
2259 }
2300 }
2260
2301
2261 # params string {String}, Index {Number}
2302 # params string {String}, Index {Number}
2262 # returns char
2303 # returns char
2263 getChar() {
2304 getChar() {
2264 string=$1
2305 string=$1
2265 index=$2
2306 index=$2
2266 cursor=-1
2307 cursor=-1
2267 char=""
2308 char=""
2268 while [ "$cursor" != "$index" ]; do
2309 while [ "$cursor" != "$index" ]; do
2269 substract="${string#?}" # All but the first character of the string
2310 substract="${string#?}" # All but the first character of the string
2270 char="${string%"$substract"}" # Remove $rest, and you're left with the first character
2311 char="${string%"$substract"}" # Remove $rest, and you're left with the first character
2271 string="$substract"
2312 string="$substract"
2272 cursor=$((cursor + 1))
2313 cursor=$((cursor + 1))
2273 done
2314 done
2274 printf "%s$char"
2315 printf "%s$char"
2275 }
2316 }
2276
2317
2277 outcome() {
2318 outcome() {
2278 semver_result=$1
2319 semver_result=$1
2279 #printf "%s$semver_result\n"
2320 #printf "%s$semver_result\n"
2280 }
2321 }
2281
2322
2282 compareNumber() {
2323 compareNumber() {
2283 if [ -z "$1" ] && [ -z "$2" ]; then
2324 if [ -z "$1" ] && [ -z "$2" ]; then
2284 printf "%s" "0"
2325 printf "%s" "0"
2285 return
2326 return
2286 fi
2327 fi
2287
2328
2288 [ $(($2 - $1)) -gt 0 ] && printf "%s" "-1"
2329 [ $(($2 - $1)) -gt 0 ] && printf "%s" "-1"
2289 [ $(($2 - $1)) -lt 0 ] && printf "1"
2330 [ $(($2 - $1)) -lt 0 ] && printf "1"
2290 [ $(($2 - $1)) = 0 ] && printf "0"
2331 [ $(($2 - $1)) = 0 ] && printf "0"
2291 }
2332 }
2292
2333
2293 compareString() {
2334 compareString() {
2294 semver_result=false
2335 semver_result=false
2295 index=0
2336 index=0
2296 while true
2337 while true
2297 do
2338 do
2298 a=$(getChar "$1" $index)
2339 a=$(getChar "$1" $index)
2299 b=$(getChar "$2" $index)
2340 b=$(getChar "$2" $index)
2300
2341
2301 if [ -z "$a" ] && [ -z "$b" ]
2342 if [ -z "$a" ] && [ -z "$b" ]
2302 then
2343 then
2303 printf "0"
2344 printf "0"
2304 return
2345 return
2305 fi
2346 fi
2306
2347
2307 ord_a=$(ord "$a")
2348 ord_a=$(ord "$a")
2308 ord_b=$(ord "$b")
2349 ord_b=$(ord "$b")
2309
2350
2310 if [ "$(compareNumber "$ord_a" "$ord_b")" != "0" ]; then
2351 if [ "$(compareNumber "$ord_a" "$ord_b")" != "0" ]; then
2311 printf "%s" "$(compareNumber "$ord_a" "$ord_b")"
2352 printf "%s" "$(compareNumber "$ord_a" "$ord_b")"
2312 return
2353 return
2313 fi
2354 fi
2314
2355
2315 index=$((index + 1))
2356 index=$((index + 1))
2316 done
2357 done
2317 }
2358 }
2318
2359
2319 includesString() {
2360 includesString() {
2320 string="$1"
2361 string="$1"
2321 substring="$2"
2362 substring="$2"
2322 if [ "${string#*"$substring"}" != "$string" ]
2363 if [ "${string#*"$substring"}" != "$string" ]
2323 then
2364 then
2324 printf "1"
2365 printf "1"
2325 return 1 # $substring is in $string
2366 return 1 # $substring is in $string
2326 fi
2367 fi
2327 printf "0"
2368 printf "0"
2328 return 0 # $substring is not in $string
2369 return 0 # $substring is not in $string
2329 }
2370 }
2330
2371
2331 removeLeadingV() {
2372 removeLeadingV() {
2332 printf "%s${1#v}"
2373 printf "%s${1#v}"
2333 }
2374 }
2334
2375
2335 # https://github.com/Ariel-Rodriguez/sh-semversion-2/pull/2
2376 # https://github.com/Ariel-Rodriguez/sh-semversion-2/pull/2
2336 # Spec #2 https://semver.org/#spec-item-2
2377 # Spec #2 https://semver.org/#spec-item-2
2337 # MUST NOT contain leading zeroes
2378 # MUST NOT contain leading zeroes
2338 normalizeZero() {
2379 normalizeZero() {
2339 next=$(printf %s "${1#0}")
2380 next=$(printf %s "${1#0}")
2340 if [ -z "$next" ]; then
2381 if [ -z "$next" ]; then
2341 printf %s "$1"
2382 printf %s "$1"
2342 fi
2383 fi
2343 printf %s "$next"
2384 printf %s "$next"
2344 }
2385 }
2345
2386
2346 semver_compare() {
2387 semver_compare() {
2347
2388
2348 # returns 1 when A greater than B
2389 # returns 1 when A greater than B
2349 # returns 0 when A equals B
2390 # returns 0 when A equals B
2350 # returns -1 when A lower than B
2391 # returns -1 when A lower than B
2351
2392
2352 firstParam=$1 #1.2.4-alpha.beta+METADATA
2393 firstParam=$1 #1.2.4-alpha.beta+METADATA
2353 secondParam=$2 #1.2.4-alpha.beta.2+METADATA
2394 secondParam=$2 #1.2.4-alpha.beta.2+METADATA
2354 semver_debug=${3:-1}
2395 semver_debug=${3:-1}
2355 semver_verbose=${4:-1}
2396 semver_verbose=${4:-1}
2356
2397
2357 [ "$semver_verbose" = "verbose" ] && set -x
2398 [ "$semver_verbose" = "verbose" ] && set -x
2358
2399
2359 version_a=$(printf %s "$firstParam" | cut -d'+' -f 1)
2400 version_a=$(printf %s "$firstParam" | cut -d'+' -f 1)
2360 version_a=$(removeLeadingV "$version_a")
2401 version_a=$(removeLeadingV "$version_a")
2361 version_b=$(printf %s "$secondParam" | cut -d'+' -f 1)
2402 version_b=$(printf %s "$secondParam" | cut -d'+' -f 1)
2362 version_b=$(removeLeadingV "$version_b")
2403 version_b=$(removeLeadingV "$version_b")
2363
2404
2364 a_major=$(printf %s "$version_a" | cut -d'.' -f 1)
2405 a_major=$(printf %s "$version_a" | cut -d'.' -f 1)
2365 a_minor=$(printf %s "$version_a" | cut -d'.' -f 2)
2406 a_minor=$(printf %s "$version_a" | cut -d'.' -f 2)
2366 a_patch=$(printf %s "$version_a" | cut -d'.' -f 3 | cut -d'-' -f 1)
2407 a_patch=$(printf %s "$version_a" | cut -d'.' -f 3 | cut -d'-' -f 1)
2367 a_pre=""
2408 a_pre=""
2368 if [ "$(includesString "$version_a" -)" = 1 ]; then
2409 if [ "$(includesString "$version_a" -)" = 1 ]; then
2369 a_pre=$(printf %s"${version_a#"$a_major.$a_minor.$a_patch-"}")
2410 a_pre=$(printf %s"${version_a#"$a_major.$a_minor.$a_patch-"}")
2370 fi
2411 fi
2371
2412
2372 b_major=$(printf %s "$version_b" | cut -d'.' -f 1)
2413 b_major=$(printf %s "$version_b" | cut -d'.' -f 1)
2373 b_minor=$(printf %s "$version_b" | cut -d'.' -f 2)
2414 b_minor=$(printf %s "$version_b" | cut -d'.' -f 2)
2374 b_patch=$(printf %s "$version_b" | cut -d'.' -f 3 | cut -d'-' -f 1)
2415 b_patch=$(printf %s "$version_b" | cut -d'.' -f 3 | cut -d'-' -f 1)
2375 b_pre=""
2416 b_pre=""
2376 if [ "$(includesString "$version_b" -)" = 1 ]; then
2417 if [ "$(includesString "$version_b" -)" = 1 ]; then
2377 b_pre=$(printf %s"${version_b#"$b_major.$b_minor.$b_patch-"}")
2418 b_pre=$(printf %s"${version_b#"$b_major.$b_minor.$b_patch-"}")
2378 fi
2419 fi
2379
2420
2380 a_major=$(normalizeZero "$a_major")
2421 a_major=$(normalizeZero "$a_major")
2381 a_minor=$(normalizeZero "$a_minor")
2422 a_minor=$(normalizeZero "$a_minor")
2382 a_patch=$(normalizeZero "$a_patch")
2423 a_patch=$(normalizeZero "$a_patch")
2383 b_major=$(normalizeZero "$b_major")
2424 b_major=$(normalizeZero "$b_major")
2384 b_minor=$(normalizeZero "$b_minor")
2425 b_minor=$(normalizeZero "$b_minor")
2385 b_patch=$(normalizeZero "$b_patch")
2426 b_patch=$(normalizeZero "$b_patch")
2386
2427
2387 unit_types="MAJOR MINOR PATCH"
2428 unit_types="MAJOR MINOR PATCH"
2388 a_normalized="$a_major $a_minor $a_patch"
2429 a_normalized="$a_major $a_minor $a_patch"
2389 b_normalized="$b_major $b_minor $b_patch"
2430 b_normalized="$b_major $b_minor $b_patch"
2390
2431
2391 semver_debug "Detected: $a_major $a_minor $a_patch identifiers: $a_pre"
2432 semver_debug "Detected: $a_major $a_minor $a_patch identifiers: $a_pre"
2392 semver_debug "Detected: $b_major $b_minor $b_patch identifiers: $b_pre"
2433 semver_debug "Detected: $b_major $b_minor $b_patch identifiers: $b_pre"
2393
2434
2394 #
2435 #
2395 # Find difference between Major Minor or Patch
2436 # Find difference between Major Minor or Patch
2396 #
2437 #
2397
2438
2398 cursor=1
2439 cursor=1
2399 while [ "$cursor" -lt 4 ]
2440 while [ "$cursor" -lt 4 ]
2400 do
2441 do
2401 a=$(printf %s "$a_normalized" | cut -d' ' -f $cursor)
2442 a=$(printf %s "$a_normalized" | cut -d' ' -f $cursor)
2402 b=$(printf %s "$b_normalized" | cut -d' ' -f $cursor)
2443 b=$(printf %s "$b_normalized" | cut -d' ' -f $cursor)
2403 if [ "$a" != "$b" ]
2444 if [ "$a" != "$b" ]
2404 then
2445 then
2405 semver_debug "$(printf %s "$unit_types" | cut -d' ' -f $cursor) is different"
2446 semver_debug "$(printf %s "$unit_types" | cut -d' ' -f $cursor) is different"
2406 outcome "$(compareNumber "$a" "$b")"
2447 outcome "$(compareNumber "$a" "$b")"
2407 return
2448 return
2408 fi;
2449 fi;
2409 semver_debug "$(printf "%s" "$unit_types" | cut -d' ' -f $cursor) are equal"
2450 semver_debug "$(printf "%s" "$unit_types" | cut -d' ' -f $cursor) are equal"
2410 cursor=$((cursor + 1))
2451 cursor=$((cursor + 1))
2411 done
2452 done
2412
2453
2413 #
2454 #
2414 # Find difference between pre release identifiers
2455 # Find difference between pre release identifiers
2415 #
2456 #
2416
2457
2417 if [ -z "$a_pre" ] && [ -z "$b_pre" ]; then
2458 if [ -z "$a_pre" ] && [ -z "$b_pre" ]; then
2418 semver_debug "Because both are equals"
2459 semver_debug "Because both are equals"
2419 outcome "0"
2460 outcome "0"
2420 return
2461 return
2421 fi
2462 fi
2422
2463
2423 # Spec 11.3 a pre-release version has lower precedence than a normal version:
2464 # Spec 11.3 a pre-release version has lower precedence than a normal version:
2424 # 1.0.0 < 1.0.0-alpha
2465 # 1.0.0 < 1.0.0-alpha
2425 if [ -z "$a_pre" ]; then
2466 if [ -z "$a_pre" ]; then
2426 semver_debug "Because A is the stable release. Pre-release version has lower precedence than a released version"
2467 semver_debug "Because A is the stable release. Pre-release version has lower precedence than a released version"
2427 outcome "1"
2468 outcome "1"
2428 return
2469 return
2429 fi
2470 fi
2430 # 1.0.0-alpha < 1.0.0
2471 # 1.0.0-alpha < 1.0.0
2431 if [ -z "$b_pre" ]; then
2472 if [ -z "$b_pre" ]; then
2432 semver_debug "Because B is the stable release. Pre-release version has lower precedence than a released version"
2473 semver_debug "Because B is the stable release. Pre-release version has lower precedence than a released version"
2433 outcome "-1"
2474 outcome "-1"
2434 return
2475 return
2435 fi
2476 fi
2436
2477
2437 isSingleIdentifier() {
2478 isSingleIdentifier() {
2438 substract="${2#?}"
2479 substract="${2#?}"
2439 if [ "${1%"$2"}" = "" ]; then
2480 if [ "${1%"$2"}" = "" ]; then
2440 printf "true"
2481 printf "true"
2441 return 1;
2482 return 1;
2442 fi
2483 fi
2443 return 0
2484 return 0
2444 }
2485 }
2445
2486
2446 cursor=1
2487 cursor=1
2447 while [ $cursor -lt 5 ]
2488 while [ $cursor -lt 5 ]
2448 do
2489 do
2449 a=$(printf %s "$a_pre" | cut -d'.' -f $cursor)
2490 a=$(printf %s "$a_pre" | cut -d'.' -f $cursor)
2450 b=$(printf %s "$b_pre" | cut -d'.' -f $cursor)
2491 b=$(printf %s "$b_pre" | cut -d'.' -f $cursor)
2451
2492
2452 semver_debug "Comparing identifier $a with $b"
2493 semver_debug "Comparing identifier $a with $b"
2453
2494
2454 # Exit when there is nothing else to compare.
2495 # Exit when there is nothing else to compare.
2455 # Most likely because they are equals
2496 # Most likely because they are equals
2456 if [ -z "$a" ] && [ -z "$b" ]
2497 if [ -z "$a" ] && [ -z "$b" ]
2457 then
2498 then
2458 semver_debug "are equals"
2499 semver_debug "are equals"
2459 outcome "0"
2500 outcome "0"
2460 return
2501 return
2461 fi;
2502 fi;
2462
2503
2463 # Spec #11 https://semver.org/#spec-item-11
2504 # Spec #11 https://semver.org/#spec-item-11
2464 # Precedence for two pre-release versions with the same major, minor, and patch version
2505 # Precedence for two pre-release versions with the same major, minor, and patch version
2465 # MUST be determined by comparing each dot separated identifier from left to right until a difference is found
2506 # MUST be determined by comparing each dot separated identifier from left to right until a difference is found
2466
2507
2467 # Spec 11.4.4: A larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal.
2508 # Spec 11.4.4: A larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal.
2468
2509
2469 if [ -n "$a" ] && [ -z "$b" ]; then
2510 if [ -n "$a" ] && [ -z "$b" ]; then
2470 # When A is larger than B and preidentifiers are 1+n
2511 # When A is larger than B and preidentifiers are 1+n
2471 # 1.0.0-alpha.beta.1 1.0.0-alpha.beta
2512 # 1.0.0-alpha.beta.1 1.0.0-alpha.beta
2472 # 1.0.0-alpha.beta.1.2 1.0.0-alpha.beta.1
2513 # 1.0.0-alpha.beta.1.2 1.0.0-alpha.beta.1
2473 semver_debug "Because A has larger set of pre-identifiers"
2514 semver_debug "Because A has larger set of pre-identifiers"
2474 outcome "1"
2515 outcome "1"
2475 return
2516 return
2476 fi
2517 fi
2477
2518
2478 # When A is shorter than B and preidentifiers are 1+n
2519 # When A is shorter than B and preidentifiers are 1+n
2479 # 1.0.0-alpha.beta 1.0.0-alpha.beta.d
2520 # 1.0.0-alpha.beta 1.0.0-alpha.beta.d
2480 # 1.0.0-alpha.beta 1.0.0-alpha.beta.1.2
2521 # 1.0.0-alpha.beta 1.0.0-alpha.beta.1.2
2481 if [ -z "$a" ] && [ -n "$b" ]; then
2522 if [ -z "$a" ] && [ -n "$b" ]; then
2482 semver_debug "Because B has larger set of pre-identifiers"
2523 semver_debug "Because B has larger set of pre-identifiers"
2483 outcome "-1"
2524 outcome "-1"
2484 return
2525 return
2485 fi
2526 fi
2486
2527
2487 # Spec #11.4.1
2528 # Spec #11.4.1
2488 # Identifiers consisting of only digits are compared numerically.
2529 # Identifiers consisting of only digits are compared numerically.
2489 if [ "$(isNumber "$a")" = "true" ] || [ "$(isNumber "$b")" = "true" ]; then
2530 if [ "$(isNumber "$a")" = "true" ] || [ "$(isNumber "$b")" = "true" ]; then
2490
2531
2491 # if both identifiers are numbers, then compare and proceed
2532 # if both identifiers are numbers, then compare and proceed
2492 # 1.0.0-beta.3 1.0.0-beta.2
2533 # 1.0.0-beta.3 1.0.0-beta.2
2493 if [ "$(isNumber "$a")" = "true" ] && [ "$(isNumber "$b")" = "true" ]; then
2534 if [ "$(isNumber "$a")" = "true" ] && [ "$(isNumber "$b")" = "true" ]; then
2494 if [ "$(compareNumber "$a" "$b")" != "0" ]; then
2535 if [ "$(compareNumber "$a" "$b")" != "0" ]; then
2495 semver_debug "Number is not equal $(compareNumber "$a" "$b")"
2536 semver_debug "Number is not equal $(compareNumber "$a" "$b")"
2496 outcome "$(compareNumber "$a" "$b")"
2537 outcome "$(compareNumber "$a" "$b")"
2497 return
2538 return
2498 fi
2539 fi
2499 fi
2540 fi
2500
2541
2501 # Spec 11.4.3
2542 # Spec 11.4.3
2502 # 1.0.0-alpha.1 1.0.0-alpha.beta.d
2543 # 1.0.0-alpha.1 1.0.0-alpha.beta.d
2503 # 1.0.0-beta.3 1.0.0-1.2
2544 # 1.0.0-beta.3 1.0.0-1.2
2504 if [ "$(isNumber "$a")" = "false" ]; then
2545 if [ "$(isNumber "$a")" = "false" ]; then
2505 semver_debug "Because Numeric identifiers always have lower precedence than non-numeric identifiers."
2546 semver_debug "Because Numeric identifiers always have lower precedence than non-numeric identifiers."
2506 outcome "1"
2547 outcome "1"
2507 return
2548 return
2508 fi
2549 fi
2509 # 1.0.0-alpha.d 1.0.0-alpha.beta.1
2550 # 1.0.0-alpha.d 1.0.0-alpha.beta.1
2510 # 1.0.0-1.1 1.0.0-beta.1.2
2551 # 1.0.0-1.1 1.0.0-beta.1.2
2511 if [ "$(isNumber "$b")" = "false" ]; then
2552 if [ "$(isNumber "$b")" = "false" ]; then
2512 semver_debug "Because Numeric identifiers always have lower precedence than non-numeric identifiers."
2553 semver_debug "Because Numeric identifiers always have lower precedence than non-numeric identifiers."
2513 outcome "-1"
2554 outcome "-1"
2514 return
2555 return
2515 fi
2556 fi
2516 else
2557 else
2517 # Spec 11.4.2
2558 # Spec 11.4.2
2518 # Identifiers with letters or hyphens are compared lexically in ASCII sort order.
2559 # Identifiers with letters or hyphens are compared lexically in ASCII sort order.
2519 # 1.0.0-alpha 1.0.0-beta.alpha
2560 # 1.0.0-alpha 1.0.0-beta.alpha
2520 if [ "$(compareString "$a" "$b")" != "0" ]; then
2561 if [ "$(compareString "$a" "$b")" != "0" ]; then
2521 semver_debug "cardinal is not equal $(compareString a b)"
2562 semver_debug "cardinal is not equal $(compareString a b)"
2522 outcome "$(compareString "$a" "$b")"
2563 outcome "$(compareString "$a" "$b")"
2523 return
2564 return
2524 fi
2565 fi
2525 fi
2566 fi
2526
2567
2527 # Edge case when there is single identifier exaple: x.y.z-beta
2568 # Edge case when there is single identifier exaple: x.y.z-beta
2528 if [ "$cursor" = 1 ]; then
2569 if [ "$cursor" = 1 ]; then
2529
2570
2530 # When both versions are single return equals
2571 # When both versions are single return equals
2531 # 1.0.0-alpha 1.0.0-alpha
2572 # 1.0.0-alpha 1.0.0-alpha
2532 if [ -n "$(isSingleIdentifier "$b_pre" "$b")" ] && [ -n "$(isSingleIdentifier "$a_pre" "$a")" ]; then
2573 if [ -n "$(isSingleIdentifier "$b_pre" "$b")" ] && [ -n "$(isSingleIdentifier "$a_pre" "$a")" ]; then
2533 semver_debug "Because both have single identifier"
2574 semver_debug "Because both have single identifier"
2534 outcome "0"
2575 outcome "0"
2535 return
2576 return
2536 fi
2577 fi
2537
2578
2538 # Return greater when has more identifiers
2579 # Return greater when has more identifiers
2539 # Spec 11.4.4: A larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal.
2580 # Spec 11.4.4: A larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal.
2540
2581
2541 # When A is larger than B
2582 # When A is larger than B
2542 # 1.0.0-alpha.beta 1.0.0-alpha
2583 # 1.0.0-alpha.beta 1.0.0-alpha
2543 if [ -n "$(isSingleIdentifier "$b_pre" "$b")" ] && [ -z "$(isSingleIdentifier "$a_pre" "$a")" ]; then
2584 if [ -n "$(isSingleIdentifier "$b_pre" "$b")" ] && [ -z "$(isSingleIdentifier "$a_pre" "$a")" ]; then
2544 semver_debug "Because of single identifier, A has more pre-identifiers"
2585 semver_debug "Because of single identifier, A has more pre-identifiers"
2545 outcome "1"
2586 outcome "1"
2546 return
2587 return
2547 fi
2588 fi
2548
2589
2549 # When A is shorter than B
2590 # When A is shorter than B
2550 # 1.0.0-alpha 1.0.0-alpha.beta
2591 # 1.0.0-alpha 1.0.0-alpha.beta
2551 if [ -z "$(isSingleIdentifier "$b_pre" "$b")" ] && [ -n "$(isSingleIdentifier "$a_pre" "$a")" ]; then
2592 if [ -z "$(isSingleIdentifier "$b_pre" "$b")" ] && [ -n "$(isSingleIdentifier "$a_pre" "$a")" ]; then
2552 semver_debug "Because of single identifier, B has more pre-identifiers"
2593 semver_debug "Because of single identifier, B has more pre-identifiers"
2553 outcome "-1"
2594 outcome "-1"
2554 return
2595 return
2555 fi
2596 fi
2556 fi
2597 fi
2557
2598
2558 # Proceed to the next identifier because previous comparition was equal.
2599 # Proceed to the next identifier because previous comparition was equal.
2559 cursor=$((cursor + 1))
2600 cursor=$((cursor + 1))
2560 done
2601 done
2561 }
2602 }
2562
2603
2563 # consistent sed function
2604 # consistent sed function
2564 # example sed_func x y file.txt
2605 # example sed_func x y file.txt
2565 sed_func() {
2606 sed_func() {
2566 if [[ $DEBUG ]]; then
2607 if [[ $DEBUG ]]; then
2567 echo
2608 echo
2568 echo "sed -i .replaced -E \"s/$1/$2/\" $in_file"
2609 echo "sed -i .replaced -E \"s/$1/$2/\" $in_file"
2569 echo "pat1: $1"
2610 echo "pat1: $1"
2570 echo "pat2: $2"
2611 echo "pat2: $2"
2571 fi
2612 fi
2572
2613
2573 in_file=$3
2614 in_file=$3
2574 sed -i.replaced -E "s/$1/$2/" $in_file
2615 sed -i.replaced -E "s/$1/$2/" $in_file
2575 }
2616 }
2576
2617
2577 # create a slug from a name
2618 # create a slug from a name
2578 slugify() {
2619 slugify() {
2579 local input="$1"
2620 local input="$1"
2580 local slug
2621 local slug
2581
2622
2582 # Convert to lowercase
2623 # Convert to lowercase
2583 slug="${input,,}"
2624 slug="${input,,}"
2584
2625
2585 # Replace slashes with underscores
2626 # Replace slashes with underscores
2586 slug="${slug//\//_}"
2627 slug="${slug//\//_}"
2587
2628
2588 # Replace spaces with hyphens
2629 # Replace spaces with hyphens
2589 slug="${slug// /_}"
2630 slug="${slug// /_}"
2590
2631
2591 # Remove characters that are not letters, numbers, or hyphens, or underscores
2632 # Remove characters that are not letters, numbers, or hyphens, or underscores
2592 slug="${slug//[^a-zA-Z0-9-_]/}"
2633 slug="${slug//[^a-zA-Z0-9-_]/}"
2593
2634
2594 echo "$slug"
2635 echo "$slug"
2595 }
2636 }
2596
2637
2597 check_os() {
2638 check_os() {
2598 echo `uname -s`
2639 echo `uname -s`
2599 }
2640 }
2600
2641
2601 check_macos_memory() {
2642 check_macos_memory() {
2602 echo $(($(memory_pressure | head -n 1 | awk '{ print $4 }') / 1024 / 1024 / 1024))
2643 echo $(($(memory_pressure | head -n 1 | awk '{ print $4 }') / 1024 / 1024 / 1024))
2603 }
2644 }
2604
2645
2605 check_linux_memory() {
2646 check_linux_memory() {
2606 mem=`free -m --si | awk ' /Mem:/ {print $2}'`
2647 mem=`free -m --si | awk ' /Mem:/ {print $2}'`
2607 if [ "$mem" -ge 990 -a "$mem" -lt 1000 ]; then
2648 if [ "$mem" -ge 990 -a "$mem" -lt 1000 ]; then
2608 echo 1
2649 echo 1
2609 else
2650 else
2610 echo `free -g --si | awk ' /Mem:/ {print $2} '`
2651 echo `free -g --si | awk ' /Mem:/ {print $2} '`
2611 fi
2652 fi
2612 }
2653 }
2613
2654
2614 # src/lib/validate_stack_exists.sh
2655 # src/lib/validate_stack_exists.sh
2615
2656
2616 validate_stack_exists() {
2657 validate_stack_exists() {
2617 err=""
2658 err=""
2618 invalid="1"
2659 invalid="1"
2619
2660
2620 for item in $VALID_SERVICES
2661 for item in $VALID_SERVICES
2621 do
2662 do
2622 if [ "$1" == "$item" ]; then
2663 if [ "$1" == "$item" ]; then
2623 invalid=""
2664 invalid=""
2624 break
2665 break
2625 fi
2666 fi
2626 done
2667 done
2627
2668
2628 if [[ -n $invalid ]]; then
2669 if [[ -n $invalid ]]; then
2629 err="command '$1' not in list of $VALID_SERVICES"
2670 err="command '$1' not in list of $VALID_SERVICES"
2630 fi
2671 fi
2631
2672
2632 echo $err
2673 echo $err
2633 }
2674 }
2634
2675
2635 # src/lib/validations/validate_dir_exists.sh
2676 # src/lib/validations/validate_dir_exists.sh
2636 validate_dir_exists() {
2677 validate_dir_exists() {
2637 [[ -d "$1" ]] || echo "must be an existing directory"
2678 [[ -d "$1" ]] || echo "must be an existing directory"
2638 }
2679 }
2639
2680
2640 # src/lib/validations/validate_file_exists.sh
2681 # src/lib/validations/validate_file_exists.sh
2641 validate_file_exists() {
2682 validate_file_exists() {
2642 [[ -f "$1" ]] || echo "must be an existing file"
2683 [[ -f "$1" ]] || echo "must be an existing file"
2643 }
2684 }
2644
2685
2645 # src/lib/validations/validate_integer.sh
2686 # src/lib/validations/validate_integer.sh
2646 validate_integer() {
2687 validate_integer() {
2647 [[ "$1" =~ ^[0-9]+$ ]] || echo "must be an integer"
2688 [[ "$1" =~ ^[0-9]+$ ]] || echo "must be an integer"
2648 }
2689 }
2649
2690
2650 # src/lib/validations/validate_not_empty.sh
2691 # src/lib/validations/validate_not_empty.sh
2651 validate_not_empty() {
2692 validate_not_empty() {
2652 [[ -z "$1" ]] && echo "must not be empty"
2693 [[ -z "$1" ]] && echo "must not be empty"
2653 }
2694 }
2654
2695
2655 # :command.command_functions
2696 # :command.command_functions
2656 # :command.function
2697 # :command.function
2657 rcstack_get_started_command() {
2698 rcstack_get_started_command() {
2658 # src/get_started_command.sh
2699 # src/get_started_command.sh
2659 get_started_full
2700 get_started_full
2660 }
2701 }
2661
2702
2662 # :command.function
2703 # :command.function
2663 rcstack_init_command() {
2704 rcstack_init_command() {
2664 # src/init_command.sh
2705 # src/init_command.sh
2665 DEBUG=${args[--debug]}
2706 DEBUG=${args[--debug]}
2666 force=${args[--force]}
2707 force=${args[--force]}
2667 docker_revision=${args[--docker-revision]}
2708 docker_revision=${args[--docker-revision]}
2668 install_docker=${args[--install-docker]}
2709 install_docker=${args[--install-docker]}
2669 no_prompt=${args[--no-prompt]}
2710 no_prompt=${args[--no-prompt]}
2670
2711
2671 eval "stages_from_cli=(${args[--stage]})"
2712 eval "stages_from_cli=(${args[--stage]})"
2672
2713
2673 # CLI passed args / defaults
2714 # CLI passed args / defaults
2674
2715
2675 if [[ -z ${args['--arg-rc-edition']} ]]; then
2716 if [[ -z ${args['--arg-rc-edition']} ]]; then
2676 # set default
2717 # set default
2677 args['--arg-rc-edition']="ee"
2718 args['--arg-rc-edition']="ee"
2678 else
2719 else
2679 # mark we used flag and don't ask in prompts
2720 # mark we used flag and don't ask in prompts
2680 args['__arg_rc_edition']=1
2721 args['__arg_rc_edition']=1
2681 fi
2722 fi
2682
2723
2683 if [[ -z ${args['--arg-rc-version']} ]]; then
2724 if [[ -z ${args['--arg-rc-version']} ]]; then
2684 # set default
2725 # set default
2685 args['--arg-rc-version']=$rc_image_ver
2726 args['--arg-rc-version']=$rc_image_ver
2686 else
2727 else
2687 # mark we used flag and don't ask in prompts
2728 # mark we used flag and don't ask in prompts
2688 args['__arg_rc_version']=1
2729 args['__arg_rc_version']=1
2689 fi
2730 fi
2690
2731
2691 if [[ -z ${args['--arg-accept-eula']} ]]; then
2732 if [[ -z ${args['--arg-accept-eula']} ]]; then
2692 # set default
2733 # set default
2693 args['--arg-accept-eula']="yes"
2734 args['--arg-accept-eula']="yes"
2694 else
2735 else
2695 # mark we used flag and don't ask in prompts
2736 # mark we used flag and don't ask in prompts
2696 args['__arg_accept_eula']=1
2737 args['__arg_accept_eula']=1
2697 fi
2738 fi
2698
2739
2699 if [[ -z ${args['--arg-hostname']} ]]; then
2740 if [[ -z ${args['--arg-hostname']} ]]; then
2700 # set default
2741 # set default
2701 args['--arg-hostname']="rhodecode.local"
2742 args['--arg-hostname']="rhodecode.local"
2702 else
2743 else
2703 # mark we used flag and don't ask in prompts
2744 # mark we used flag and don't ask in prompts
2704 args['__arg_hostname']=1
2745 args['__arg_hostname']=1
2705 fi
2746 fi
2706
2747
2707 if [[ -z ${args['--arg-use-ssl']} ]]; then
2748 if [[ -z ${args['--arg-use-ssl']} ]]; then
2708 # set default
2749 # set default
2709 args['--arg-use-ssl']="n"
2750 args['--arg-use-ssl']="n"
2710 else
2751 else
2711 # mark we used flag and don't ask in prompts
2752 # mark we used flag and don't ask in prompts
2712 args['__arg_use_ssl']=1
2753 args['__arg_use_ssl']=1
2713 fi
2754 fi
2714
2755
2715 if [[ -z ${args['--arg-database-type']} ]]; then
2756 if [[ -z ${args['--arg-database-type']} ]]; then
2716 # set default
2757 # set default
2717 args['--arg-database-type']="postgres"
2758 args['--arg-database-type']="postgres"
2718 else
2759 else
2719 # mark we used flag and don't ask in prompts
2760 # mark we used flag and don't ask in prompts
2720 args['__arg_database_type']=1
2761 args['__arg_database_type']=1
2721 fi
2762 fi
2722
2763
2723 if [[ -z ${args['--arg-admin-email']} ]]; then
2764 if [[ -z ${args['--arg-admin-email']} ]]; then
2724 # set default
2765 # set default
2725 args['--arg-admin-email']="admin@${args['--arg-hostname']}"
2766 args['--arg-admin-email']="admin@${args['--arg-hostname']}"
2726 else
2767 else
2727 # mark we used flag and don't ask in prompts
2768 # mark we used flag and don't ask in prompts
2728 args['__arg_admin_email']=1
2769 args['__arg_admin_email']=1
2729 fi
2770 fi
2730
2771
2731 if [[ -z ${args['--arg-admin-user']} ]]; then
2772 if [[ -z ${args['--arg-admin-user']} ]]; then
2732 # set default
2773 # set default
2733 args['--arg-admin-user']="admin"
2774 args['--arg-admin-user']="admin"
2734 else
2775 else
2735 # mark we used flag and don't ask in prompts
2776 # mark we used flag and don't ask in prompts
2736 args['__arg_admin_user']=1
2777 args['__arg_admin_user']=1
2737 fi
2778 fi
2738
2779
2739 if [[ -z ${args['--arg-admin-pass']} ]]; then
2780 if [[ -z ${args['--arg-admin-pass']} ]]; then
2740 # set default
2781 # set default
2741 args['--arg-admin-pass']="secret4"
2782 args['--arg-admin-pass']="secret4"
2742 else
2783 else
2743 # mark we used flag and don't ask in prompts
2784 # mark we used flag and don't ask in prompts
2744 args['__arg_admin_pass']=1
2785 args['__arg_admin_pass']=1
2745 fi
2786 fi
2746
2787
2747 if [[ -z ${args['--arg-license-token']} ]]; then
2788 if [[ -z ${args['--arg-license-token']} ]]; then
2748 # set default
2789 # set default
2749 args['--arg-license-token']="$(random_str 4)"-"$(random_str 4)"-"$(random_str 4)"-"$(random_str 4)"
2790 args['--arg-license-token']="$(random_str 4)"-"$(random_str 4)"-"$(random_str 4)"-"$(random_str 4)"
2750 else
2791 else
2751 # mark we used flag and don't ask in prompts
2792 # mark we used flag and don't ask in prompts
2752 args['__arg_license_token']=1
2793 args['__arg_license_token']=1
2753 fi
2794 fi
2754
2795
2755 arg_rc_edition=${args[--arg-rc-edition]}
2796 arg_rc_edition=${args[--arg-rc-edition]}
2756 arg_rc_version=${args[--arg-rc-version]}
2797 arg_rc_version=${args[--arg-rc-version]}
2757 arg_accept_eula=${args[--arg-accept-eula]}
2798 arg_accept_eula=${args[--arg-accept-eula]}
2758 arg_hostname=${args[--arg-hostname]}
2799 arg_hostname=${args[--arg-hostname]}
2759 arg_database_type=${args[--arg-database-type]}
2800 arg_database_type=${args[--arg-database-type]}
2760 arg_use_ssl=${args[--arg-use-ssl]}
2801 arg_use_ssl=${args[--arg-use-ssl]}
2761 arg_admin_email=${args[--arg-admin-email]}
2802 arg_admin_email=${args[--arg-admin-email]}
2762 arg_admin_user=${args[--arg-admin-user]}
2803 arg_admin_user=${args[--arg-admin-user]}
2763 arg_admin_pass=${args[--arg-admin-pass]}
2804 arg_admin_pass=${args[--arg-admin-pass]}
2764 arg_license_token=${args[--arg-license-token]}
2805 arg_license_token=${args[--arg-license-token]}
2765
2806
2766 ask_user_for_config() {
2807 ask_user_for_config() {
2767 local config_done="n"
2808 local config_done="n"
2768
2809
2769 echo "Starting interactive setup for v:$arg_rc_version..."
2810 echo "Starting interactive setup for v:$arg_rc_version..."
2770 echo ""
2811 echo ""
2771
2812
2772 while [[ "$config_done" == "n" ]]
2813 while [[ "$config_done" == "n" ]]
2773 # config loop start
2814 # config loop start
2774 do
2815 do
2775 # edition to install
2816 # edition to install
2776 if [ ! -z "$arg_rc_edition" ] && [ -z ${args['__arg_rc_edition']} ]
2817 if [ ! -z "$arg_rc_edition" ] && [ -z ${args['__arg_rc_edition']} ]
2777 then
2818 then
2778 read -p "Select 'ee' to use Enterprise edition or type 'ce' to use Community free edition: rhodecode-[$arg_rc_edition]: " new_value
2819 read -p "Select 'ee' to use Enterprise edition or type 'ce' to use Community free edition: rhodecode-[$arg_rc_edition]: " new_value
2779 if [ ! -z "$new_value" ]
2820 if [ ! -z "$new_value" ]
2780 then
2821 then
2781 arg_rc_edition="$new_value"
2822 arg_rc_edition="$new_value"
2782 fi
2823 fi
2783
2824
2784 # validation
2825 # validation
2785 if [[ ! $arg_rc_edition =~ ^(ce|ee)$ ]]; then
2826 if [[ ! $arg_rc_edition =~ ^(ce|ee)$ ]]; then
2786 echo
2827 echo
2787 echo "$(red edition_type must be one of: ce, ee not $arg_rc_edition, defaulting to ee)"
2828 echo "$(red edition_type must be one of: ce, ee not $arg_rc_edition, defaulting to ee)"
2788 echo
2829 echo
2789 arg_rc_edition="ee"
2830 arg_rc_edition="ee"
2790 fi
2831 fi
2791
2832
2792 fi
2833 fi
2793
2834
2794 if [ ! -z "$arg_accept_eula" ] && [ -z ${args['__arg_accept_eula']} ]
2835 if [ ! -z "$arg_accept_eula" ] && [ -z ${args['__arg_accept_eula']} ]
2795 then
2836 then
2796 if [[ $arg_rc_edition == "ee" ]]; then
2837 if [[ $arg_rc_edition == "ee" ]]; then
2797 #EE EULA
2838 #EE EULA
2798 read -p "Do you accept RhodeCode EULA (see: https://docs.rhodecode.com/rcstack/eula/ee.txt) accept: 'yes' deny: 'no' ? [$arg_accept_eula]: " new_value
2839 read -p "Do you accept RhodeCode EULA (see: https://docs.rhodecode.com/rcstack/eula/ee.txt) accept: 'yes' deny: 'no' ? [$arg_accept_eula]: " new_value
2799 else
2840 else
2800 #CE EULA
2841 #CE EULA
2801 read -p "Do you accept RhodeCode EULA (see: https://docs.rhodecode.com/rcstack/eula/ce.txt) accept: 'yes' deny: 'no' ? [$arg_accept_eula]: " new_value
2842 read -p "Do you accept RhodeCode EULA (see: https://docs.rhodecode.com/rcstack/eula/ce.txt) accept: 'yes' deny: 'no' ? [$arg_accept_eula]: " new_value
2802 fi
2843 fi
2803
2844
2804 if [ ! -z "$new_value" ]
2845 if [ ! -z "$new_value" ]
2805 then
2846 then
2806 arg_accept_eula="$new_value"
2847 arg_accept_eula="$new_value"
2807 fi
2848 fi
2808
2849
2809 if [[ $arg_accept_eula != "yes" ]]; then
2850 if [[ $arg_accept_eula != "yes" ]]; then
2810 echo "$(red please accept EULA by typing yes, no installation is possible without accepted EULA)"
2851 echo "$(red please accept EULA by typing yes, no installation is possible without accepted EULA)"
2811 exit
2852 exit
2812 fi
2853 fi
2813 fi
2854 fi
2814
2855
2815 # ask for license-token IF edition is ee
2856 # ask for license-token IF edition is ee
2816 if [[ $arg_rc_edition == "ee" ]]; then
2857 if [[ $arg_rc_edition == "ee" ]]; then
2817 if [ ! -z "$arg_license_token" ] && [ -z ${args['__arg_license_token']} ]
2858 if [ ! -z "$arg_license_token" ] && [ -z ${args['__arg_license_token']} ]
2818 then
2859 then
2819 read -p "enter a valid license-token or use pre-generated one [$arg_license_token]: " new_value
2860 read -p "enter a valid license-token or use pre-generated one [$arg_license_token]: " new_value
2820 if [ ! -z "$new_value" ]
2861 if [ ! -z "$new_value" ]
2821 then
2862 then
2822 arg_license_token="$new_value"
2863 arg_license_token="$new_value"
2823 fi
2864 fi
2824 fi
2865 fi
2825 fi
2866 fi
2826
2867
2827 # hostname
2868 # hostname
2828 if [ ! -z "$arg_hostname" ] && [ -z ${args['__arg_hostname']} ]
2869 if [ ! -z "$arg_hostname" ] && [ -z ${args['__arg_hostname']} ]
2829 then
2870 then
2830 read -p "Enter a valid hostname for RhodeCode Stack? [$arg_hostname]: " new_value
2871 read -p "Enter a valid hostname for RhodeCode Stack? [$arg_hostname]: " new_value
2831 if [ ! -z "$new_value" ]
2872 if [ ! -z "$new_value" ]
2832 then
2873 then
2833 arg_hostname="$new_value"
2874 arg_hostname="$new_value"
2834 fi
2875 fi
2835
2876
2836 # validation
2877 # validation
2837 if [[ $arg_hostname =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]
2878 if [[ $arg_hostname =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]
2838 then
2879 then
2839 echo
2880 echo
2840 echo "$(red IP addresses are unsupported and will not work. Please provide a DNS hostname)"
2881 echo "$(red IP addresses are unsupported and will not work. Please provide a DNS hostname)"
2841 echo
2882 echo
2842 arg_hostname="rc-docker.local"
2883 arg_hostname="rc-docker.local"
2843 fi
2884 fi
2844 fi
2885 fi
2845
2886
2846 # database type
2887 # database type
2847 if [ ! -z "$arg_database_type" ] && [ -z ${args['__arg_database_type']} ]
2888 if [ ! -z "$arg_database_type" ] && [ -z ${args['__arg_database_type']} ]
2848 then
2889 then
2849 read -p "Enter a database type? postgres, mysql, none [$arg_database_type]: " new_value
2890 read -p "Enter a database type? postgres, mysql, none [$arg_database_type]: " new_value
2850 if [ ! -z "$new_value" ]
2891 if [ ! -z "$new_value" ]
2851 then
2892 then
2852 arg_database_type="$new_value"
2893 arg_database_type="$new_value"
2853 fi
2894 fi
2854
2895
2855 # validation
2896 # validation
2856 if [[ ! $arg_database_type =~ ^(postgres|mysql|none)$ ]]
2897 if [[ ! $arg_database_type =~ ^(postgres|mysql|none)$ ]]
2857 then
2898 then
2858 echo
2899 echo
2859 echo "$(red database type must be one of postgres, mysql, none, defaulting to postgres)"
2900 echo "$(red database type must be one of postgres, mysql, none, defaulting to postgres)"
2860 echo
2901 echo
2861 arg_database_type="postgres"
2902 arg_database_type="postgres"
2862 fi
2903 fi
2863 fi
2904 fi
2864
2905
2865 # use SSL
2906 # use SSL
2866 if [ ! -z "$arg_use_ssl" ] && [ -z ${args['__arg_use_ssl']} ]
2907 if [ ! -z "$arg_use_ssl" ] && [ -z ${args['__arg_use_ssl']} ]
2867 then
2908 then
2868 read -p "Do you want to enable SSL/HTTPS now (can be changed later) 'y' for yes 'n' for no? [$arg_use_ssl]: " new_value
2909 read -p "Do you want to enable SSL/HTTPS now (can be changed later) 'y' for yes 'n' for no? [$arg_use_ssl]: " new_value
2869 if [ ! -z "$new_value" ]
2910 if [ ! -z "$new_value" ]
2870 then
2911 then
2871 arg_use_ssl="$new_value"
2912 arg_use_ssl="$new_value"
2872 fi
2913 fi
2873 fi
2914 fi
2874
2915
2875 # admin email
2916 # admin email
2876 if [ ! -z "$arg_admin_email" ] && [ -z ${args['__arg_admin_email']} ]
2917 if [ ! -z "$arg_admin_email" ] && [ -z ${args['__arg_admin_email']} ]
2877 then
2918 then
2878 read -p "Enter first super-admin email? [$arg_admin_email]: " new_value
2919 read -p "Enter first super-admin email? [$arg_admin_email]: " new_value
2879 if [ ! -z "$new_value" ]
2920 if [ ! -z "$new_value" ]
2880 then
2921 then
2881 arg_admin_email="$new_value"
2922 arg_admin_email="$new_value"
2882 fi
2923 fi
2883 fi
2924 fi
2884
2925
2885 # admin user
2926 # admin user
2886 if [ ! -z "$arg_admin_user" ] && [ -z ${args['__arg_admin_user']} ]
2927 if [ ! -z "$arg_admin_user" ] && [ -z ${args['__arg_admin_user']} ]
2887 then
2928 then
2888 read -p "Enter first super-admin account name? [$arg_admin_user]: " new_value
2929 read -p "Enter first super-admin account name? [$arg_admin_user]: " new_value
2889 if [ ! -z "$new_value" ]
2930 if [ ! -z "$new_value" ]
2890 then
2931 then
2891 arg_admin_user="$new_value"
2932 arg_admin_user="$new_value"
2892 fi
2933 fi
2893 fi
2934 fi
2894
2935
2895 # admin password
2936 # admin password
2896 if [ ! -z "$arg_admin_pass" ] && [ -z ${args['__arg_admin_pass']} ]
2937 if [ ! -z "$arg_admin_pass" ] && [ -z ${args['__arg_admin_pass']} ]
2897 then
2938 then
2898 read -p "Enter first super-admin account password? [$arg_admin_pass]: " new_value
2939 read -p "Enter first super-admin account password? [$arg_admin_pass]: " new_value
2899 if [ ! -z "$new_value" ]
2940 if [ ! -z "$new_value" ]
2900 then
2941 then
2901 arg_admin_pass="$new_value"
2942 arg_admin_pass="$new_value"
2902 fi
2943 fi
2903 fi
2944 fi
2904
2945
2905 echo -e "\nDoes this look right?\n"
2946 echo -e "\nDoes this look right?\n"
2906 echo "RhodeCode Edition : rhodecode-$arg_rc_edition @v:$arg_rc_version"
2947 echo "RhodeCode Edition : rhodecode-$arg_rc_edition @v:$arg_rc_version"
2907 echo "License Token : $arg_license_token"
2948 echo "License Token : $arg_license_token"
2908 echo "Hostname : $arg_hostname"
2949 echo "Hostname : $arg_hostname"
2909 echo "Database : $arg_database_type"
2950 echo "Database : $arg_database_type"
2910 echo "Use SSL : $arg_use_ssl"
2951 echo "Use SSL : $arg_use_ssl"
2911 echo "Email : $arg_admin_email"
2952 echo "Email : $arg_admin_email"
2912 echo "Admin user : $arg_admin_user"
2953 echo "Admin user : $arg_admin_user"
2913 echo "Admin password : $arg_admin_pass"
2954 echo "Admin password : $arg_admin_pass"
2914 echo ""
2955 echo ""
2915 read -p "ENTER to continue, 'n' to try again, Ctrl+C to exit: " config_done
2956 read -p "ENTER to continue, 'n' to try again, Ctrl+C to exit: " config_done
2916
2957
2917 # config loop end
2958 # config loop end
2918 done
2959 done
2919
2960
2920 }
2961 }
2921
2962
2922 check_docker() {
2963 check_docker() {
2923 (which docker || which docker.io) &>/dev/null
2964 (which docker || which docker.io) &>/dev/null
2924 }
2965 }
2925
2966
2926 bootstrap_docker_install() {
2967 bootstrap_docker_install() {
2927 # systemctl enable docker on debian
2968 # systemctl enable docker on debian
2928 echo "bootstrap_docker_install: trying to check and configure docker"
2969 echo "bootstrap_docker_install: trying to check and configure docker"
2929 failMsg="Failed to find docker on your PATH"
2970 failMsg="Failed to find docker on your PATH"
2930
2971
2931 if ! check_docker; then
2972 if ! check_docker; then
2932
2973
2933 if [[ $install_docker == "n" ]]; then
2974 if [[ $install_docker == "n" ]]; then
2934 echo "$(red $failMsg, exiting without docker install)"
2975 echo "$(red $failMsg, exiting without docker install)"
2935 fi
2976 fi
2936
2977
2937 echo "$(yellow $failMsg, trying docker install)"
2978 echo "$(yellow $failMsg, trying docker install)"
2938
2979
2939 if [[ $install_docker == "y" ]]; then
2980 if [[ $install_docker == "y" ]]; then
2940 echo "continuing with automated docker installation from https://get.docker.com/ "
2981 echo "continuing with automated docker installation from https://get.docker.com/ "
2941 else
2982 else
2942 read -p "Enter to install Docker directly from https://get.docker.com/ or Ctrl+C to exit and install it manually"
2983 read -p "Enter to install Docker directly from https://get.docker.com/ or Ctrl+C to exit and install it manually"
2943 fi
2984 fi
2944
2985
2945 curl -fsSL https://get.docker.com -o install-docker.sh
2986 curl -fsSL https://get.docker.com -o install-docker.sh
2946 sh install-docker.sh
2987 sh install-docker.sh
2947 rm install-docker.sh
2988 rm install-docker.sh
2948
2989
2949 if ! check_docker; then
2990 if ! check_docker; then
2950 echo "$failMsg"
2991 echo "$failMsg"
2951 echo "Docker install failed. Quitting."
2992 echo "Docker install failed. Quitting."
2952 exit 1
2993 exit 1
2953 fi
2994 fi
2954
2995
2955 docker --version
2996 docker --version
2956
2997
2957 fi
2998 fi
2958 }
2999 }
2959
3000
2960 bootstrap_docker_commons() {
3001 bootstrap_docker_commons() {
2961
3002
2962 echo 'bootstrap_docker_commons: running docker commands.'
3003 echo 'bootstrap_docker_commons: running docker commands.'
2963
3004
2964 echo "bootstrap_docker_commons: creating volume 'rc_datavolume'"
3005 echo "bootstrap_docker_commons: creating volume 'rc_datavolume'"
2965 docker volume create --label keep=1 --name=rc_datavolume
3006 docker volume create --label keep=1 --name=rc_datavolume
2966 echo "bootstrap_docker_commons (rc_datavolume): done"
3007 echo "bootstrap_docker_commons (rc_datavolume): done"
2967 echo ""
3008 echo ""
2968
3009
2969 echo "bootstrap_docker_commons: creating volume 'rc_reposvolume'"
3010 echo "bootstrap_docker_commons: creating volume 'rc_reposvolume'"
2970 docker volume create --label keep=1 --name=rc_reposvolume
3011 docker volume create --label keep=1 --name=rc_reposvolume
2971 echo "bootstrap_docker_commons (rc_reposvolume): done"
3012 echo "bootstrap_docker_commons (rc_reposvolume): done"
2972 echo ""
3013 echo ""
2973
3014
2974 echo "bootstrap_docker_commons: creating network 'rhodecode_network'"
3015 echo "bootstrap_docker_commons: creating network 'rhodecode_network'"
2975 docker network inspect rhodecode_network >/dev/null 2>&1 || docker network create rhodecode_network
3016 docker network inspect rhodecode_network >/dev/null 2>&1 || docker network create rhodecode_network
2976 echo "bootstrap_docker_commons (rhodecode_network): done"
3017 echo "bootstrap_docker_commons (rhodecode_network): done"
2977 echo ""
3018 echo ""
2978
3019
2979 echo "bootstrap_docker_commons: creating loki logging"
3020 echo "bootstrap_docker_commons: creating loki logging"
2980 loki_driver=$(docker plugin ls --format {{.Name}} --filter enabled=true | grep loki || echo "")
3021 loki_driver=$(docker plugin ls --format {{.Name}} --filter enabled=true | grep loki || echo "")
2981 if [[ $loki_driver == "" ]]; then
3022 if [[ $loki_driver == "" ]]; then
2982 docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
3023 docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
2983 else
3024 else
2984 echo "bootstrap_docker_commons: loki driver already exists"
3025 echo "bootstrap_docker_commons: loki driver already exists"
2985 fi
3026 fi
2986 }
3027 }
2987
3028
2988 config_init() {
3029 config_init() {
2989 loc_config_file=${CONFIG_FILE:=config.ini}
3030 loc_config_file=${CONFIG_FILE:=config.ini}
2990 [[ -f "$loc_config_file" ]] || touch "$loc_config_file"
3031 [[ -f "$loc_config_file" ]] || touch "$loc_config_file"
2991 }
3032 }
2992
3033
2993 bootstrap_config() {
3034 bootstrap_config() {
2994 shared_key=$(random_str 32)
3035 shared_key=$(random_str 32)
2995 shared_key_md5=$(generate_md5 $shared_key | head -c 32)
3036 shared_key_md5=$(generate_md5 $shared_key | head -c 32)
2996 db_key=$(random_str 32)
3037 db_key=$(random_str 32)
2997
3038
2998 if [[ ! $no_prompt ]]; then
3039 if [[ ! $no_prompt ]]; then
2999 ask_user_for_config
3040 ask_user_for_config
3000 fi
3041 fi
3001
3042
3002 # setup args
3043 # setup args
3003 license_token=$arg_license_token
3044 license_token=$arg_license_token
3004 log_formatter=$arg_log_formatter
3045 log_formatter=$arg_log_formatter
3005 base_domain=$arg_hostname
3046 base_domain=$arg_hostname
3006 rc_edition=$arg_rc_edition
3047 rc_edition=$arg_rc_edition
3007 rc_version=$arg_rc_version
3048 rc_version=$arg_rc_version
3008 database_type=$arg_database_type
3049 database_type=$arg_database_type
3009
3050
3010 is_https=0
3051 is_https=0
3011 if [[ $arg_use_ssl == "y" ]]; then is_https=1; fi
3052 if [[ $arg_use_ssl == "y" ]]; then is_https=1; fi
3012
3053
3013 DB_USER='rhodecode'
3054 DB_USER='rhodecode'
3014 DB_NAME='rhodecode'
3055 DB_NAME='rhodecode'
3015
3056
3016 if [[ ! -f "$CONFIG_FILE" ]]; then
3057 if [[ ! -f "$CONFIG_FILE" ]]; then
3017 echo "init new config at: $CONFIG_FILE"
3058 echo "init new config at: $CONFIG_FILE"
3018 config_init
3059 config_init
3019 else
3060 else
3020 echo "re-using existing config at: $CONFIG_FILE"
3061 echo "re-using existing config at: $CONFIG_FILE"
3021 fi
3062 fi
3022
3063
3023 CUSTOM_DIR_PATH=$PWD/.custom
3064 CUSTOM_DIR_PATH=$PWD/.custom
3024 mkdir -p "$CUSTOM_DIR_PATH"
3065 mkdir -p "$CUSTOM_DIR_PATH"
3025 BOOTSTRAP_TMPL=$PWD/templates/runtime.env.tmpl
3066 BOOTSTRAP_TMPL=$PWD/templates/runtime.env.tmpl
3026 BOOTSTRAP_RUNTIME_ENV=$PWD/.custom/.runtime.env
3067 BOOTSTRAP_RUNTIME_ENV=$PWD/.custom/.runtime.env
3027
3068
3028 ver1="$(echo "$rc_version" | cut -d'.' -f1)"
3069 ver1="$(echo "$rc_version" | cut -d'.' -f1)"
3029 ver2="$(echo "$rc_version" | cut -d'.' -f2)"
3070 ver2="$(echo "$rc_version" | cut -d'.' -f2)"
3030
3071
3031 tmpl_ver="$ver1.$ver2"
3072 tmpl_ver="$ver1.$ver2"
3032
3073
3033 if [[ ! -d $PWD/templates/ini/$tmpl_ver ]]; then
3074 if [[ ! -d $PWD/templates/ini/$tmpl_ver ]]; then
3034 # no config dir exist, assume latest...
3075 # no config dir exist, assume latest...
3035 tmpl_ver=edge
3076 tmpl_ver=edge
3036 fi
3077 fi
3037
3078
3038 INI_TARGET=$PWD/config/_shared
3079 INI_TARGET=$PWD/config/_shared
3039 RHODECODE_INI_NAME=rhodecode.ini
3080 RHODECODE_INI_NAME=rhodecode.ini
3040 RHODECODE_INI_TMPL=$PWD/templates/ini/$tmpl_ver/$RHODECODE_INI_NAME
3081 RHODECODE_INI_TMPL=$PWD/templates/ini/$tmpl_ver/$RHODECODE_INI_NAME
3041 VCSSERVER_INI_NAME=vcsserver.ini
3082 VCSSERVER_INI_NAME=vcsserver.ini
3042 VCSSERVER_INI_TMPL=$PWD/templates/ini/$tmpl_ver/$VCSSERVER_INI_NAME
3083 VCSSERVER_INI_TMPL=$PWD/templates/ini/$tmpl_ver/$VCSSERVER_INI_NAME
3043
3084
3044 # break if we didn't use force and definitions exist
3085 # break if we didn't use force and definitions exist
3045 if [[ -f $BOOTSTRAP_RUNTIME_ENV && ! $force ]]; then
3086 if [[ -f $BOOTSTRAP_RUNTIME_ENV && ! $force ]]; then
3046 echo "$(yellow bootstrap_config: $BOOTSTRAP_RUNTIME_ENV file exists, not adding any configuration. Use --force to create it anyway)"
3087 echo "$(yellow bootstrap_config: $BOOTSTRAP_RUNTIME_ENV file exists, not adding any configuration. Use --force to create it anyway)"
3047 return
3088 return
3048 fi
3089 fi
3049
3090
3050 if [[ -f $BOOTSTRAP_RUNTIME_ENV ]]; then
3091 if [[ -f $BOOTSTRAP_RUNTIME_ENV ]]; then
3051 echo "$(yellow $BOOTSTRAP_RUNTIME_ENV file exists, are you sure to force re-create it?)"
3092 echo "$(yellow $BOOTSTRAP_RUNTIME_ENV file exists, are you sure to force re-create it?)"
3052 while true; do
3093 while true; do
3053 read -p "Would you like to continue with overriding file? [yn] " yn
3094 read -p "Would you like to continue with overriding file? [yn] " yn
3054 case $yn in
3095 case $yn in
3055 [Yy]*) break ;;
3096 [Yy]*) break ;;
3056 [Nn]*) exit ;;
3097 [Nn]*) exit ;;
3057 *) echo "Please answer y or n." ;;
3098 *) echo "Please answer y or n." ;;
3058 esac
3099 esac
3059 done
3100 done
3060 fi
3101 fi
3061
3102
3062 echo "bootstrap_config: init runtime env config at: $BOOTSTRAP_RUNTIME_ENV"
3103 echo "bootstrap_config: init runtime env config at: $BOOTSTRAP_RUNTIME_ENV"
3063
3104
3064 # Make runtime file
3105 # Make runtime file
3065 echo "## BOOTSTRAP GENERATED $(date) ##" > $BOOTSTRAP_RUNTIME_ENV
3106 echo "## BOOTSTRAP GENERATED $(date) ##" > $BOOTSTRAP_RUNTIME_ENV
3066 echo "" >> "$BOOTSTRAP_RUNTIME_ENV"
3107 echo "" >> "$BOOTSTRAP_RUNTIME_ENV"
3067
3108
3068 cat $BOOTSTRAP_TMPL >> $BOOTSTRAP_RUNTIME_ENV
3109 cat $BOOTSTRAP_TMPL >> $BOOTSTRAP_RUNTIME_ENV
3069
3110
3070 # Make .ini files
3111 # Make .ini files
3071 cp -v $RHODECODE_INI_TMPL $INI_TARGET
3112 cp -v $RHODECODE_INI_TMPL $INI_TARGET
3072 echo "## rcstack config ver:$rc_version" | cat - "$INI_TARGET/$RHODECODE_INI_NAME" > temp_rc_ini && mv temp_rc_ini "$INI_TARGET/$RHODECODE_INI_NAME"
3113 echo "## rcstack config ver:$rc_version" | cat - "$INI_TARGET/$RHODECODE_INI_NAME" > temp_rc_ini && mv temp_rc_ini "$INI_TARGET/$RHODECODE_INI_NAME"
3073
3114
3074 cp -v $VCSSERVER_INI_TMPL $INI_TARGET
3115 cp -v $VCSSERVER_INI_TMPL $INI_TARGET
3075 echo "## rcstack config ver:$rc_version" | cat - "$INI_TARGET/$VCSSERVER_INI_NAME" > temp_vcs_ini && mv temp_vcs_ini "$INI_TARGET/$VCSSERVER_INI_NAME"
3116 echo "## rcstack config ver:$rc_version" | cat - "$INI_TARGET/$VCSSERVER_INI_NAME" > temp_vcs_ini && mv temp_vcs_ini "$INI_TARGET/$VCSSERVER_INI_NAME"
3076
3117
3077 # init env generator with env file
3118 # init env generator with env file
3078 .env --file "$BOOTSTRAP_RUNTIME_ENV"
3119 .env --file "$BOOTSTRAP_RUNTIME_ENV"
3079
3120
3080 .env set RC_EDITION=$rc_edition
3121 .env set RC_EDITION=$rc_edition
3081 .env set RC_VERSION=$rc_version
3122 .env set RC_VERSION=$rc_version
3082 .env set DB_PASSWORD=$db_key
3123 .env set DB_PASSWORD=$db_key
3083
3124
3084 .env set RHODECODE_USER_EMAIL=$arg_admin_email
3125 .env set RHODECODE_USER_EMAIL=$arg_admin_email
3085 .env set RHODECODE_USER_NAME=$arg_admin_user
3126 .env set RHODECODE_USER_NAME=$arg_admin_user
3086 .env set RHODECODE_USER_PASS=$arg_admin_pass
3127 .env set RHODECODE_USER_PASS=$arg_admin_pass
3087
3128
3088 .env set RC_ENCRYPTED_SECRET=$shared_key
3129 .env set RC_ENCRYPTED_SECRET=$shared_key
3089 .env set RC_SHARED_KEY=$shared_key
3130 .env set RC_SHARED_KEY=$shared_key
3090
3131
3091 if [[ $database_type == "postgres" ]]; then
3132 if [[ $database_type == "postgres" ]]; then
3092 rc_db1="postgresql://$DB_USER:$db_key@database/$DB_NAME"
3133 rc_db1="postgresql://$DB_USER:$db_key@database/$DB_NAME"
3093 elif [[ $database_type == "mysql" ]]; then
3134 elif [[ $database_type == "mysql" ]]; then
3094 rc_db1="mysql://$DB_USER:$db_key@database-mysql/$DB_NAME?charset=utf8"
3135 rc_db1="mysql://$DB_USER:$db_key@database-mysql/$DB_NAME?charset=utf8"
3095 else
3136 else
3096 rc_db1="sqlite:///%(here)s/rhodecode.db?timeout=30"
3137 rc_db1="sqlite:///%(here)s/rhodecode.db?timeout=30"
3097 fi
3138 fi
3098
3139
3099 .env set DB_TYPE=$database_type
3140 .env set DB_TYPE=$database_type
3100 .env set RC_DB_URL="$rc_db1"
3141 .env set RC_DB_URL="$rc_db1"
3101 .env set RC_SQLALCHEMY_DB1_URL="$rc_db1"
3142 .env set RC_SQLALCHEMY_DB1_URL="$rc_db1"
3102
3143
3103 .env set RC_LICENSE_TOKEN=$license_token
3144 .env set RC_LICENSE_TOKEN=$license_token
3104 .env set RC_HOSTNAME=$base_domain
3145 .env set RC_HOSTNAME=$base_domain
3105
3146
3106 if [[ $is_https == 1 ]]; then
3147 if [[ $is_https == 1 ]]; then
3107 app_base_url=https://$base_domain
3148 app_base_url=https://$base_domain
3108 else
3149 else
3109 app_base_url=http://$base_domain
3150 app_base_url=http://$base_domain
3110 fi
3151 fi
3111
3152
3112 .env set RC_APP_BASE_URL=$app_base_url
3153 .env set RC_APP_BASE_URL=$app_base_url
3113
3154
3114 .env set RC_LOKI_AUTH=loki-auth:$shared_key@
3155 .env set RC_LOKI_AUTH=loki-auth:$shared_key@
3115
3156
3116 .env puts ''
3157 .env puts ''
3117 .env puts '# Log formatter option'
3158 .env puts '# Log formatter option'
3118 .env set RC_LOGGING_FORMATTER=$log_formatter
3159 .env set RC_LOGGING_FORMATTER=$log_formatter
3119 .env set RC_USE_CELERY=true
3160 .env set RC_USE_CELERY=true
3120
3161
3121 .env puts ''
3162 .env puts ''
3122 .env puts '# Channelstream config'
3163 .env puts '# Channelstream config'
3123 .env set RC_CHANNELSTREAM_SERVER=channelstream:8000
3164 .env set RC_CHANNELSTREAM_SERVER=channelstream:8000
3124
3165
3125 if [[ $is_https == 1 ]]; then
3166 if [[ $is_https == 1 ]]; then
3126 rc_channelstream_url="wss://$base_domain/_channelstream"
3167 rc_channelstream_url="wss://$base_domain/_channelstream"
3127 else
3168 else
3128 rc_channelstream_url="ws://$base_domain/_channelstream"
3169 rc_channelstream_url="ws://$base_domain/_channelstream"
3129 fi
3170 fi
3130
3171
3131 .env set RC_CHANNELSTREAM_WS_URL=$rc_channelstream_url
3172 .env set RC_CHANNELSTREAM_WS_URL=$rc_channelstream_url
3132
3173
3133 .env set CHANNELSTREAM_ALLOW_POSTING_FROM=0.0.0.0
3174 .env set CHANNELSTREAM_ALLOW_POSTING_FROM=0.0.0.0
3134
3175
3135 .env puts ''
3176 .env puts ''
3136 .env puts '# Channelstream secrets'
3177 .env puts '# Channelstream secrets'
3137 .env set CHANNELSTREAM_SECRET=$shared_key
3178 .env set CHANNELSTREAM_SECRET=$shared_key
3138 .env set RC_CHANNELSTREAM_SECRET=$shared_key
3179 .env set RC_CHANNELSTREAM_SECRET=$shared_key
3139
3180
3140 .env puts ''
3181 .env puts ''
3141 .env puts '# Channelstream admin'
3182 .env puts '# Channelstream admin'
3142 .env set CHANNELSTREAM_ADMIN_SECRET=$shared_key
3183 .env set CHANNELSTREAM_ADMIN_SECRET=$shared_key
3143 .env set RC_CHANNELSTREAM_ADMIN_SECRET=$shared_key
3184 .env set RC_CHANNELSTREAM_ADMIN_SECRET=$shared_key
3144
3185
3145 .env puts ''
3186 .env puts ''
3146 .env puts '# SSH PORT'
3187 .env puts '# SSH PORT'
3147 .env set RC_SSH_PORT=9022
3188 .env set RC_SSH_PORT=9022
3148
3189
3149 ini_path="$INI_TARGET/$VCSSERVER_INI_NAME"
3190 ini_path="$INI_TARGET/$VCSSERVER_INI_NAME"
3150 config_vcsserver_ini
3191 config_vcsserver_ini
3151
3192
3152 ini_path="$INI_TARGET/$RHODECODE_INI_NAME"
3193 ini_path="$INI_TARGET/$RHODECODE_INI_NAME"
3153 RC_EDITION=$rc_edition
3194 RC_EDITION=$rc_edition
3154 RC_LICENSE_TOKEN=$license_token
3195 RC_LICENSE_TOKEN=$license_token
3155 RC_HOSTNAME=$(sed_safe_path $base_domain)
3196 RC_HOSTNAME=$(sed_safe_path $base_domain)
3156 RC_APP_BASE_URL=$(sed_safe_path $app_base_url)
3197 RC_APP_BASE_URL=$(sed_safe_path $app_base_url)
3157 RC_SQLALCHEMY_DB1_URL=$(sed_safe_path $rc_db1)
3198 RC_SQLALCHEMY_DB1_URL=$(sed_safe_path $rc_db1)
3158 RC_CHANNELSTREAM_WS_URL=$(sed_safe_path $rc_channelstream_url)
3199 RC_CHANNELSTREAM_WS_URL=$(sed_safe_path $rc_channelstream_url)
3159 RC_SHARED_KEY=$shared_key
3200 RC_SHARED_KEY=$shared_key
3160 config_rhodecode_ini
3201 config_rhodecode_ini
3161
3202
3162 touch $BOOTSTRAP_RUNTIME_ENV
3203 touch $BOOTSTRAP_RUNTIME_ENV
3163
3204
3164 }
3205 }
3165
3206
3166 bootstrap_definitions() {
3207 bootstrap_definitions() {
3167
3208
3168 # This is needed for bootstrap_definitions
3209 # This is needed for bootstrap_definitions
3169 AUTH_TOKEN=${args[--auth-token]}
3210 AUTH_TOKEN=${args[--auth-token]}
3170 SERVER_URL=${args[--server-url]}
3211 SERVER_URL=${args[--server-url]}
3171
3212
3172 DEFINITIONS_EXIST=""
3213 DEFINITIONS_EXIST=""
3173 CHECK_FILES="\
3214 CHECK_FILES="\
3174 docker-compose-services.yaml \
3215 docker-compose-services.yaml \
3175 docker-compose-apps.yaml \
3216 docker-compose-apps.yaml \
3176 docker-compose-metrics.yaml \
3217 docker-compose-metrics.yaml \
3177 docker-compose-router.yaml \
3218 docker-compose-router.yaml \
3178 "
3219 "
3179 for check_file in $CHECK_FILES; do
3220 for check_file in $CHECK_FILES; do
3180 if [[ -f "$check_file" ]]; then
3221 if [[ -f "$check_file" ]]; then
3181 DEFINITIONS_EXIST="1"
3222 DEFINITIONS_EXIST="1"
3182 fi
3223 fi
3183 done
3224 done
3184
3225
3185 # break if we didn't use force and definitions exist
3226 # break if we didn't use force and definitions exist
3186 if [[ -n $DEFINITIONS_EXIST && ! $force ]]; then
3227 if [[ -n $DEFINITIONS_EXIST && ! $force ]]; then
3187 echo "$(yellow bootstrap_definitions: skipping docker defs creation, existing files found. Use --force to create them anyway)"
3228 echo "$(yellow bootstrap_definitions: skipping docker defs creation, existing files found. Use --force to create them anyway)"
3188 return
3229 return
3189 fi
3230 fi
3190 definitions_override_decision=true
3231 definitions_override_decision=true
3191
3232
3192 if [[ -n $DEFINITIONS_EXIST ]]; then
3233 if [[ -n $DEFINITIONS_EXIST ]]; then
3193 echo "$(yellow docker definitions exists, are you sure to force re-create them?)"
3234 echo "$(yellow docker definitions exists, are you sure to force re-create them?)"
3194 definitions_override_decision=false
3235 definitions_override_decision=false
3195 while true; do
3236 while true; do
3196 read -p "Would you like to continue with overriding files? [yn] " yn
3237 read -p "Would you like to continue with overriding files? [yn] " yn
3197 case $yn in
3238 case $yn in
3198 [Yy]*)
3239 [Yy]*)
3199 definitions_override_decision=true
3240 definitions_override_decision=true
3200 break
3241 break
3201 ;;
3242 ;;
3202 [Nn]*)
3243 [Nn]*)
3203 definitions_override_decision=false
3244 definitions_override_decision=false
3204 break
3245 break
3205 ;;
3246 ;;
3206 *)
3247 *)
3207 echo "Please answer y or n."
3248 echo "Please answer y or n."
3208 ;;
3249 ;;
3209 esac
3250 esac
3210 done
3251 done
3211 fi
3252 fi
3212
3253
3213 if [[ "$definitions_override_decision" == true ]]; then
3254 if [[ "$definitions_override_decision" == true ]]; then
3214 FULL_MODE=1
3255 FULL_MODE=1
3215 # This expects the $AUTH_TOKEN and $SERVER_URL be present
3256 # This expects the $AUTH_TOKEN and $SERVER_URL be present
3216 get_docker_definitions $docker_revision $FULL_MODE $DEBUG
3257 get_docker_definitions $docker_revision $FULL_MODE $DEBUG
3217 else
3258 else
3218 echo "$(yellow No docker definition override)"
3259 echo "$(yellow No docker definition override)"
3219 # Add commands for cancellation or other actions here.
3260 # Add commands for cancellation or other actions here.
3220 fi
3261 fi
3221
3262
3222 }
3263 }
3223
3264
3224 bootstrap_overrides() {
3265 bootstrap_overrides() {
3225 templates=$YAML_TEMPLATES
3266 templates=$YAML_TEMPLATES
3226
3267
3227 target_dir=$PWD/.custom
3268 target_dir=$PWD/.custom
3228
3269
3229 for o_file in $templates; do
3270 for o_file in $templates; do
3230 target_file=$target_dir/$o_file
3271 target_file=$target_dir/$o_file
3231 if [[ ! -f "$target_file" ]]; then
3272 if [[ ! -f "$target_file" ]]; then
3232 echo "copy override file $o_file"
3273 echo "copy override file $o_file"
3233 cp -v $PWD/templates/$o_file $target_file
3274 cp -v $PWD/templates/$o_file $target_file
3234 else
3275 else
3235 echo "file $target_file existing, skipping..."
3276 echo "file $target_file existing, skipping..."
3236 fi
3277 fi
3237 done
3278 done
3238 mkdir -p $target_dir/traefik_custom
3279 mkdir -p $target_dir/traefik_custom
3239 cp -r $PWD/config/traefik/* $target_dir/traefik_custom/
3280 cp -r $PWD/config/traefik/* $target_dir/traefik_custom/
3240
3281
3241 echo "$(green bootstrap_overrides: overrides extracted to $target_dir)"
3282 echo "$(green bootstrap_overrides: overrides extracted to $target_dir)"
3242
3283
3243 # save our loki auth using md5 encryption so the auth works OOTB
3284 # save our loki auth using md5 encryption so the auth works OOTB
3244 echo "loki-auth:$shared_key_md5" >> $target_dir/traefik_custom/dynamic/.htpasswd
3285 echo "loki-auth:$shared_key_md5" >> $target_dir/traefik_custom/dynamic/.htpasswd
3245
3286
3246 services_tmpl=$target_dir/docker-compose-services.override.yaml
3287 services_tmpl=$target_dir/docker-compose-services.override.yaml
3247 metrics_tmpl=$target_dir/docker-compose-metrics.override.yaml
3288 metrics_tmpl=$target_dir/docker-compose-metrics.override.yaml
3248 apps_tmpl=$target_dir/docker-compose-apps.override.yaml
3289 apps_tmpl=$target_dir/docker-compose-apps.override.yaml
3249
3290
3250 # change our templates and adjust using enable SSH
3291 # change our templates and adjust using enable SSH
3251 if [[ $arg_use_ssl == "y" ]]; then
3292 if [[ $arg_use_ssl == "y" ]]; then
3252 echo "enabling SSL on .override.yaml templates"
3293 echo "enabling SSL on .override.yaml templates"
3253
3294
3254 metrics_replace() {
3295 metrics_replace() {
3255 sed_func "$1" "$2" "$metrics_tmpl"
3296 sed_func "$1" "$2" "$metrics_tmpl"
3256 }
3297 }
3257
3298
3258 metrics_replace '# # Enable http\+https' ' # Enable http\+https'
3299 metrics_replace '# # Enable http\+https' ' # Enable http\+https'
3259 metrics_replace '# - "traefik.http.routers.grafana.entrypoints=http,https"' ' - "traefik.http.routers.grafana.entrypoints=http,https"'
3300 metrics_replace '# - "traefik.http.routers.grafana.entrypoints=http,https"' ' - "traefik.http.routers.grafana.entrypoints=http,https"'
3260
3301
3261 services_replace() {
3302 services_replace() {
3262 sed_func "$1" "$2" "$services_tmpl"
3303 sed_func "$1" "$2" "$services_tmpl"
3263 }
3304 }
3264
3305
3265 services_replace '# # Enable http\+https' ' # Enable http\+https'
3306 services_replace '# # Enable http\+https' ' # Enable http\+https'
3266 services_replace '# - "traefik.http.routers.channelstream.entrypoints=http,https"' ' - "traefik.http.routers.channelstream.entrypoints=http,https"'
3307 services_replace '# - "traefik.http.routers.channelstream.entrypoints=http,https"' ' - "traefik.http.routers.channelstream.entrypoints=http,https"'
3267 services_replace '# - "traefik.http.routers.nginx-statics.entrypoints=http,https"' ' - "traefik.http.routers.nginx-statics.entrypoints=http,https"'
3308 services_replace '# - "traefik.http.routers.nginx-statics.entrypoints=http,https"' ' - "traefik.http.routers.nginx-statics.entrypoints=http,https"'
3268
3309
3269 apps_replace() {
3310 apps_replace() {
3270 sed_func "$1" "$2" "$apps_tmpl"
3311 sed_func "$1" "$2" "$apps_tmpl"
3271 }
3312 }
3272
3313
3273 apps_replace '# # Enable http\+https' ' # Enable http\+https'
3314 apps_replace '# # Enable http\+https' ' # Enable http\+https'
3274 apps_replace '# - "traefik.http.routers.rhodecode.entrypoints=http,https"' ' - "traefik.http.routers.rhodecode.entrypoints=http,https"'
3315 apps_replace '# - "traefik.http.routers.rhodecode.entrypoints=http,https"' ' - "traefik.http.routers.rhodecode.entrypoints=http,https"'
3275
3316
3276 fi
3317 fi
3277
3318
3278 if [[ $arg_database_type == "postgres" ]]; then
3319 if [[ $arg_database_type == "postgres" ]]; then
3279 sed -i -E '/^ database:/,/replicas: [0-9]+/ s/replicas: [0-9]+/replicas: 1/' $services_tmpl
3320 sed -i -E '/^ database:/,/replicas: [0-9]+/ s/replicas: [0-9]+/replicas: 1/' $services_tmpl
3280 sed -i -E '/^ database-mysql:/,/replicas: [0-9]+/ s/replicas: [0-9]+/replicas: 0/' $services_tmpl
3321 sed -i -E '/^ database-mysql:/,/replicas: [0-9]+/ s/replicas: [0-9]+/replicas: 0/' $services_tmpl
3281 elif [[ $arg_database_type == "mysql" ]]; then
3322 elif [[ $arg_database_type == "mysql" ]]; then
3282 sed -i -E '/^ database:/,/replicas: [0-9]+/ s/replicas: [0-9]+/replicas: 0/' $services_tmpl
3323 sed -i -E '/^ database:/,/replicas: [0-9]+/ s/replicas: [0-9]+/replicas: 0/' $services_tmpl
3283 sed -i -E '/^ database-mysql:/,/replicas: [0-9]+/ s/replicas: [0-9]+/replicas: 1/' $services_tmpl
3324 sed -i -E '/^ database-mysql:/,/replicas: [0-9]+/ s/replicas: [0-9]+/replicas: 1/' $services_tmpl
3284 else
3325 else
3285 # BOTH Disabled
3326 # BOTH Disabled
3286 sed -i -E '/^ database:/,/replicas: [0-9]+/ s/replicas: [0-9]+/replicas: 0/' $services_tmpl
3327 sed -i -E '/^ database:/,/replicas: [0-9]+/ s/replicas: [0-9]+/replicas: 0/' $services_tmpl
3287 sed -i -E '/^ database-mysql:/,/replicas: [0-9]+/ s/replicas: [0-9]+/replicas: 0/' $services_tmpl
3328 sed -i -E '/^ database-mysql:/,/replicas: [0-9]+/ s/replicas: [0-9]+/replicas: 0/' $services_tmpl
3288 fi
3329 fi
3289
3330
3290 }
3331 }
3291
3332
3292 cur_date=$(date '+%Y-%m-%d %H:%M:%S')
3333 cur_date=$(date '+%Y-%m-%d %H:%M:%S')
3293
3334
3294 # Init the config !
3335 # Init the config !
3295 if [[ ! -f "$CONFIG_FILE" ]]; then
3336 if [[ ! -f "$CONFIG_FILE" ]]; then
3296 echo "config: init new config at: $CONFIG_FILE"
3337 echo "config: init new config at: $CONFIG_FILE"
3297 config_init
3338 config_init
3298 else
3339 else
3299 echo "config: re-using present config at: $CONFIG_FILE"
3340 echo "config: re-using present config at: $CONFIG_FILE"
3300 fi
3341 fi
3301
3342
3302 run_stages=$BOOTSTRAP_STAGES
3343 run_stages=$BOOTSTRAP_STAGES
3303
3344
3304 if [ ! ${#stages_from_cli[@]} -eq 0 ]; then
3345 if [ ! ${#stages_from_cli[@]} -eq 0 ]; then
3305 echo "Using custom stages to run init command..."
3346 echo "Using custom stages to run init command..."
3306 run_stages=${stages_from_cli[@]}
3347 run_stages=${stages_from_cli[@]}
3307 fi
3348 fi
3308
3349
3309 for stage_name in $run_stages; do
3350 for stage_name in $run_stages; do
3310
3351
3311 stage_func=$(get_stage_function $stage_name)
3352 stage_func=$(get_stage_function $stage_name)
3312
3353
3313 if ! config_has_key $stage_name ; then
3354 if ! config_has_key $stage_name ; then
3314 echo "$(green \* bootstrap: \'$stage_name\' stage not found\; running now... )"
3355 echo "$(green \* bootstrap: \'$stage_name\' stage not found\; running now... )"
3315 $stage_func
3356 $stage_func
3316 config_set "$stage_name" $cur_date
3357 config_set "$stage_name" $cur_date
3317 else
3358 else
3318 if [ $force ]; then
3359 if [ $force ]; then
3319 echo "$(green \* bootstrap: \'$stage_name\' is present!\; FORCE running now... )"
3360 echo "$(green \* bootstrap: \'$stage_name\' is present!\; FORCE running now... )"
3320 $stage_func $force
3361 $stage_func $force
3321 config_set "$stage_name" $cur_date
3362 config_set "$stage_name" $cur_date
3322 else
3363 else
3323 echo "$(yellow \* bootstrap: \'$stage_name\' stage already present, use --force to run it again)"
3364 echo "$(yellow \* bootstrap: \'$stage_name\' stage already present, use --force to run it again)"
3324 fi
3365 fi
3325 fi
3366 fi
3326
3367
3327 done
3368 done
3328
3369
3329 echo ""
3370 echo ""
3330 echo "~~~~ $(green Bootstrap completed) ~~~~"
3371 echo "~~~~ $(green Bootstrap completed) ~~~~"
3331
3372
3332 get_started
3373 get_started
3333
3374
3334 }
3375 }
3335
3376
3336 # :command.function
3377 # :command.function
3337 rcstack_self_update_command() {
3378 rcstack_self_update_command() {
3338 # src/self_update_command.sh
3379 # src/self_update_command.sh
3339 check_bootstrap
3380 check_bootstrap
3340
3381
3341 FORCE=${args[--force]}
3382 FORCE=${args[--force]}
3342 DEBUG=${args[--debug]}
3383 DEBUG=${args[--debug]}
3343
3384
3344 # This is needed for bootstrap_definitions
3385 # This is needed for bootstrap_definitions
3345 AUTH_TOKEN=${args[--auth-token]}
3386 AUTH_TOKEN=${args[--auth-token]}
3346 SERVER_URL=${args[--server-url]}
3387 SERVER_URL=${args[--server-url]}
3347
3388
3348 update_docker_image=${args[--update-docker-image]}
3389 update_docker_image=${args[--update-docker-image]}
3349
3390
3350 rcstack_channel=${args[--cli-revision]}
3391 rcstack_channel=${args[--cli-revision]}
3351 rcstack_file_channel=${args[--cli-file]}
3392 rcstack_file_channel=${args[--cli-file]}
3352 docker_channel=${args[--docker-revision]}
3393 docker_channel=${args[--docker-revision]}
3353
3394
3354 FETCH_FROM=https://dls.rhodecode.com/get/$rcstack_channel
3395 FETCH_FROM=https://dls.rhodecode.com/get/$rcstack_channel
3355
3396
3356 RCSCRIPT_FINAL_TARGET=$PWD/scripts/rcstack/rcstack
3397 RCSCRIPT_FINAL_TARGET=$PWD/scripts/rcstack/rcstack
3357
3398
3358 RCSTACK_DL_TARGET=$PWD/scripts/rcstack/rcstack.tmp
3399 RCSTACK_DL_TARGET=$PWD/scripts/rcstack/rcstack.tmp
3359
3400
3360 #ensure we have this dir !
3401 #ensure we have this dir !
3361 mkdir -p $PWD/scripts/rcstack
3402 mkdir -p $PWD/scripts/rcstack
3362
3403
3363 .env --file $RUNTIME_ENV
3404 .env --file $RUNTIME_ENV
3364 .env get_or_error RC_VERSION
3405 .env get_or_error RC_VERSION
3365
3406
3366 ENV_VER=$REPLY
3407 ENV_VER=$REPLY
3367
3408
3368 echo "self-update: downloading new $RC_SCRIPT_NAME script from $FETCH_FROM"
3409 echo "self-update: downloading new $RC_SCRIPT_NAME script from $FETCH_FROM"
3369
3410
3370 if [[ $FORCE ]]; then
3411 if [[ $FORCE ]]; then
3371 echo "$(yellow self-update: --force used, doing forced update)"
3412 echo "$(yellow self-update: --force used, doing forced update)"
3372 fi
3413 fi
3373
3414
3374 if [[ $DEBUG ]]; then
3415 if [[ $DEBUG ]]; then
3375 echo "running: curl -L -ss --fail -o $RCSTACK_DL_TARGET $FETCH_FROM"
3416 echo "running: curl -L -ss --fail -o $RCSTACK_DL_TARGET $FETCH_FROM"
3376 fi
3417 fi
3377
3418
3378 curl -L -ss --fail -o $RCSTACK_DL_TARGET $FETCH_FROM
3419 curl -L -ss --fail -o $RCSTACK_DL_TARGET $FETCH_FROM
3379
3420
3380 # if we specified --cli-file, now USE this to obtain final script
3421 # if we specified --cli-file, now USE this to obtain final script
3381
3422
3382 if [[ -n $rcstack_file_channel ]]; then
3423 if [[ -n $rcstack_file_channel ]]; then
3383 echo "getting rcstack file from path $rcstack_file_channel"
3424 echo "getting rcstack file from path $rcstack_file_channel"
3384 cp -v $rcstack_file_channel $RCSTACK_DL_TARGET
3425 cp -v $rcstack_file_channel $RCSTACK_DL_TARGET
3385 fi
3426 fi
3386
3427
3387 chmod +x $RCSTACK_DL_TARGET
3428 chmod +x $RCSTACK_DL_TARGET
3388
3429
3389 version_old=0
3430 version_old=0
3390 rc_version_old=0
3431 rc_version_old=0
3391
3432
3392 # check if we have OLD file, in case we don't just set versions to 0
3433 # check if we have OLD file, in case we don't just set versions to 0
3393 if [[ -f "$RCSCRIPT_FINAL_TARGET" ]]; then
3434 if [[ -f "$RCSCRIPT_FINAL_TARGET" ]]; then
3394 version_old=$($RCSCRIPT_FINAL_TARGET --version)
3435 version_old=$($RCSCRIPT_FINAL_TARGET --version)
3395 rc_version_old=$($RCSCRIPT_FINAL_TARGET cli image-info)
3436 rc_version_old=$($RCSCRIPT_FINAL_TARGET cli image-info)
3396 fi
3437 fi
3397
3438
3398 version_dl=$($RCSTACK_DL_TARGET --version)
3439 version_dl=$($RCSTACK_DL_TARGET --version)
3399 rc_version_dl=$($RCSTACK_DL_TARGET cli image-info)
3440 rc_version_dl=$($RCSTACK_DL_TARGET cli image-info)
3400
3441
3401 echo "self-update: $RC_SCRIPT_NAME version downloaded: $version_dl"
3442 echo "self-update: $RC_SCRIPT_NAME version downloaded: $version_dl"
3402
3443
3403 if [[ $DEBUG ]]; then
3444 if [[ $DEBUG ]]; then
3404 echo "DEBUG: old-script ver: $version_old"
3445 echo "DEBUG: old-script ver: $version_old"
3405 echo "DEBUG: new-script ver: $version_dl"
3446 echo "DEBUG: new-script ver: $version_dl"
3406 echo "DEBUG: "
3447 echo "DEBUG: "
3407 echo "DEBUG: .runtime.env set version $ENV_VER"
3448 echo "DEBUG: .runtime.env set version $ENV_VER"
3408 echo "DEBUG: "
3449 echo "DEBUG: "
3409 echo "DEBUG: old-script: RC VERSION: $rc_version_old"
3450 echo "DEBUG: old-script: RC VERSION: $rc_version_old"
3410 echo "DEBUG: new-script: RC VERSION: $rc_version_dl"
3451 echo "DEBUG: new-script: RC VERSION: $rc_version_dl"
3411 fi
3452 fi
3412
3453
3413 # returns 1 when A greater than B
3454 # returns 1 when A greater than B
3414 # returns 0 when A equals B
3455 # returns 0 when A equals B
3415 # returns -1 when A lower than B
3456 # returns -1 when A lower than B
3416 # defines $semver_result
3457 # defines $semver_result
3417 semver_compare "$version_old" "$version_dl"
3458 semver_compare "$version_old" "$version_dl"
3418
3459
3419 # logic if 0, 1 we have lower or equal version vs the new one
3460 # logic if 0, 1 we have lower or equal version vs the new one
3420 if [[ $semver_result == "-1" ]]; then
3461 if [[ $semver_result == "-1" ]]; then
3421 # if -1 the DL version is never than we have locally
3462 # if -1 the DL version is never than we have locally
3422 echo "Found new version of rcstack $version_dl, continuing with update ..."
3463 echo "Found new version of rcstack $version_dl, continuing with update ..."
3423 else
3464 else
3424 # otherwise we use older or same...
3465 # otherwise we use older or same...
3425 if [[ $FORCE ]]; then
3466 if [[ $FORCE ]]; then
3426 echo "$(yellow "self-update: downloaded rcstack version ($version_dl) is old or same as current ($version_old), continuing update with --force flag")"
3467 echo "$(yellow "self-update: downloaded rcstack version ($version_dl) is old or same as current ($version_old), continuing update with --force flag")"
3427 else
3468 else
3428 echo "self-update: downloaded rcstack version ($version_dl) is old or same as current ($version_old), exiting..."
3469 echo "self-update: downloaded rcstack version ($version_dl) is old or same as current ($version_old), exiting..."
3429 exit
3470 exit
3430 fi
3471 fi
3431 fi
3472 fi
3432
3473
3433 docker_image_update() {
3474 docker_image_update() {
3434
3475
3435 echo "$(green self-update: checking if RC_VERSION=$rc_version_dl should be saved to runtime.env file)"
3476 echo "$(green self-update: checking if RC_VERSION=$rc_version_dl should be saved to runtime.env file)"
3436 echo "self-update: currently .runtime.env file uses image: $ENV_VER"
3477 echo "self-update: currently .runtime.env file uses image: $ENV_VER"
3437
3478
3438 if [[ $update_docker_image == "y" ]]; then
3479 if [[ $update_docker_image == "y" ]]; then
3439 echo "continuing with automated forced installer version saved into .runtime.env"
3480 echo "continuing with automated forced installer version saved into .runtime.env"
3440 .env set RC_VERSION=$rc_version_dl
3481 .env set RC_VERSION=$rc_version_dl
3441 else
3482 else
3442 while true; do
3483 while true; do
3443 read -p "self-update: Would you like to continue with setting RC_VERSION=$rc_version_dl over RC_VERSION=$ENV_VER into .runtime.env file? [yn] " yn
3484 read -p "self-update: Would you like to continue with setting RC_VERSION=$rc_version_dl over RC_VERSION=$ENV_VER into .runtime.env file? [yn] " yn
3444 case $yn in
3485 case $yn in
3445 [Yy]*)
3486 [Yy]*)
3446 .env set RC_VERSION=$rc_version_dl
3487 .env set RC_VERSION=$rc_version_dl
3447 echo "self-update: new version set into config"
3488 echo "self-update: new version set into config"
3448 break ;;
3489 break ;;
3449 [Nn]*)
3490 [Nn]*)
3450 break ;;
3491 break ;;
3451 *) echo "Please answer y or n." ;;
3492 *) echo "Please answer y or n." ;;
3452 esac
3493 esac
3453 done
3494 done
3454 fi
3495 fi
3455 }
3496 }
3456
3497
3457 # returns 1 when A greater than B
3498 # returns 1 when A greater than B
3458 # returns 0 when A equals B
3499 # returns 0 when A equals B
3459 # returns -1 when A lower than B
3500 # returns -1 when A lower than B
3460 # defines $semver_result
3501 # defines $semver_result
3461 semver_compare "$rc_version_old" "$rc_version_dl"
3502 semver_compare "$rc_version_old" "$rc_version_dl"
3462
3503
3463 # logic if 0, 1 we have lower or equal version vs the new one
3504 # logic if 0, 1 we have lower or equal version vs the new one
3464 if [[ $semver_result == "-1" ]]; then
3505 if [[ $semver_result == "-1" ]]; then
3465 # if -1 the DL version is never than we have locally
3506 # if -1 the DL version is never than we have locally
3466 docker_image_update
3507 docker_image_update
3467 else
3508 else
3468 # otherwise we use older or same...
3509 # otherwise we use older or same...
3469 echo "self-update: docker image defined by RC_VERSION=$rc_version_dl seems to be up-to date"
3510 echo "self-update: docker image defined by RC_VERSION=$rc_version_dl seems to be up-to date"
3470 if [[ $FORCE ]]; then
3511 if [[ $FORCE ]]; then
3471 echo "$(yellow self-update: continuing update with --force flag)"
3512 echo "$(yellow self-update: continuing update with --force flag)"
3472 docker_image_update
3513 docker_image_update
3473 fi
3514 fi
3474 fi
3515 fi
3475
3516
3476 echo "$(green self-update: updating docker definitions to $docker_channel)"
3517 echo "$(green self-update: updating docker definitions to $docker_channel)"
3477
3518
3478 FULL_MODE=1
3519 FULL_MODE=1
3479 # This expects the $AUTH_TOKEN and $SERVER_URL be present
3520 # This expects the $AUTH_TOKEN and $SERVER_URL be present
3480 get_docker_definitions $docker_channel $FULL_MODE $DEBUG
3521 get_docker_definitions $docker_channel $FULL_MODE $DEBUG
3481
3522
3482 # run self upgrade from the NEW script...
3523 # run self upgrade from the NEW script...
3483 if [[ $DEBUG ]]; then
3524 if [[ $DEBUG ]]; then
3484 eval "$RCSTACK_DL_TARGET --debug self-upgrade --from-ver=$version_old --to-ver=$version"
3525 eval "$RCSTACK_DL_TARGET --debug self-upgrade --from-ver=$version_old --to-ver=$version"
3485 else
3526 else
3486 eval "$RCSTACK_DL_TARGET self-upgrade --from-ver=$version_old --to-ver=$version"
3527 eval "$RCSTACK_DL_TARGET self-upgrade --from-ver=$version_old --to-ver=$version"
3487 fi
3528 fi
3488
3529
3489 echo "self-update: updating cli $RC_SCRIPT_NAME script to new version: $version_dl"
3530 echo "self-update: updating cli $RC_SCRIPT_NAME script to new version: $version_dl"
3490 if [[ -f "$RCSCRIPT_FINAL_TARGET" ]]; then
3531 if [[ -f "$RCSCRIPT_FINAL_TARGET" ]]; then
3491 rm $RCSCRIPT_FINAL_TARGET && mv -v $RCSTACK_DL_TARGET $RCSCRIPT_FINAL_TARGET
3532 rm $RCSCRIPT_FINAL_TARGET && mv -v $RCSTACK_DL_TARGET $RCSCRIPT_FINAL_TARGET
3492 else
3533 else
3493 mv -v $RCSTACK_DL_TARGET $RCSCRIPT_FINAL_TARGET
3534 mv -v $RCSTACK_DL_TARGET $RCSCRIPT_FINAL_TARGET
3494 fi
3535 fi
3495
3536
3496 echo "$(green self-update: successfully update to $version_dl)"
3537 echo "$(green self-update: successfully update to $version_dl)"
3497 exit
3538 exit
3498 }
3539 }
3499
3540
3500 # :command.function
3541 # :command.function
3501 rcstack_self_upgrade_command() {
3542 rcstack_self_upgrade_command() {
3502 # src/self_upgrade_command.sh
3543 # src/self_upgrade_command.sh
3503
3544
3504 DEBUG=${args[--debug]}
3545 DEBUG=${args[--debug]}
3505
3546
3506 version_old=${args[--from-ver]}
3547 version_old=${args[--from-ver]}
3507 version_new=${args[--to-ver]}
3548 version_new=${args[--to-ver]}
3508 internal_version_old=$(./$RC_SCRIPT_NAME --version)
3549 internal_version_old=$(./$RC_SCRIPT_NAME --version)
3509
3550
3510 if [[ -z $version_old ]]; then
3551 if [[ -z $version_old ]]; then
3511 # use internal version
3552 # use internal version
3512 version_old=$internal_version_old
3553 version_old=$internal_version_old
3513
3554
3514 fi
3555 fi
3515
3556
3516 semver_compare "$version_old" "5.7.0"
3557 semver_compare "$version_old" "5.7.0"
3517 if [[ $DEBUG ]]; then
3558 if [[ $DEBUG ]]; then
3518 echo "Checking if $version_old >= 5.7.0, $semver_result"
3559 echo "Checking if $version_old >= 5.7.0, $semver_result"
3519 semver_compare "$version_old" "5.7.0" "debug"
3560 semver_compare "$version_old" "5.7.0" "debug"
3520 else
3561 else
3521 semver_compare "$version_old" "5.7.0"
3562 semver_compare "$version_old" "5.7.0"
3522 fi
3563 fi
3523
3564
3524 if [[ $semver_result == "-1" ]]; then
3565 if [[ $semver_result == "-1" ]]; then
3525 echo "rcstack post 5.7.0 upgrade..."
3566 echo "rcstack post 5.7.0 upgrade..."
3526
3567
3527 .env get RC_USE_CELERY || .env set RC_USE_CELERY=true
3568 .env get RC_USE_CELERY || .env set RC_USE_CELERY=true
3528 .env get RC_SSH_PORT || .env set RC_SSH_PORT=9022
3569 .env get RC_SSH_PORT || .env set RC_SSH_PORT=9022
3529
3570
3530 fi
3571 fi
3531
3572
3532 if [[ $DEBUG ]]; then
3573 if [[ $DEBUG ]]; then
3533 echo "Checking if $version_old >= 5.9.0, $semver_result"
3574 echo "Checking if $version_old >= 5.9.0, $semver_result"
3534 semver_compare "$version_old" "5.9.0" "debug"
3575 semver_compare "$version_old" "5.9.0" "debug"
3535 else
3576 else
3536 semver_compare "$version_old" "5.9.0"
3577 semver_compare "$version_old" "5.9.0"
3537 fi
3578 fi
3538
3579
3539 if [[ $semver_result == "-1" ]]; then
3580 if [[ $semver_result == "-1" ]]; then
3540 echo "rcstack post 5.9.0 upgrade..."
3581 echo "rcstack post 5.9.0 upgrade..."
3541 shared_key=$(random_str 32)
3582 shared_key=$(random_str 32)
3542
3583
3543 .env get RC_ENCRYPTED_SECRET || .env set RC_ENCRYPTED_SECRET=$shared_key
3584 .env get RC_ENCRYPTED_SECRET || .env set RC_ENCRYPTED_SECRET=$shared_key
3544 .env get DB_TYPE || .env set DB_TYPE="postgres"
3585 .env get DB_TYPE || .env set DB_TYPE="postgres"
3545 .env get RC_SHARED_KEY || .env set RC_SHARED_KEY=$shared_key
3586 .env get RC_SHARED_KEY || .env set RC_SHARED_KEY=$shared_key
3546
3587
3547 fi
3588 fi
3548
3589
3549 echo "$(green self-upgrade: upgraded rcstack)"
3590 echo "$(green self-upgrade: upgraded rcstack)"
3550
3591
3551 }
3592 }
3552
3593
3553 # :command.function
3594 # :command.function
3554 rcstack_stack_router_command() {
3595 rcstack_stack_router_command() {
3555 # src/stack_router_command.sh
3596 # src/stack_router_command.sh
3556 check_bootstrap
3597 check_bootstrap
3557
3598
3558 DEBUG=${args[--debug]}
3599 DEBUG=${args[--debug]}
3559 ENV_FILE=${args[--env-file-path]}
3600 ENV_FILE=${args[--env-file-path]}
3560
3601
3561 if [[ ! -f $RC_STACK_ROUTER_EXT ]]; then
3602 if [[ ! -f $RC_STACK_ROUTER_EXT ]]; then
3562 RC_STACK_ROUTER_EXT=""
3603 RC_STACK_ROUTER_EXT=""
3563 else
3604 else
3564 RC_STACK_ROUTER_EXT="-f $RC_STACK_ROUTER_EXT"
3605 RC_STACK_ROUTER_EXT="-f $RC_STACK_ROUTER_EXT"
3565 fi
3606 fi
3566
3607
3567 CMD_ROUTER="\
3608 CMD_ROUTER="\
3568 RC_ENV_FILE=$ENV_FILE docker compose \
3609 RC_ENV_FILE=$ENV_FILE docker compose \
3569 --env-file $ENV_FILE \
3610 --env-file $ENV_FILE \
3570 $ENV_EXPAND \
3611 $ENV_EXPAND \
3571 -p rc_cluster_router \
3612 -p rc_cluster_router \
3572 -f docker-compose-base.yaml \
3613 -f docker-compose-base.yaml \
3573 -f docker-compose-router.yaml $RC_STACK_ROUTER_EXT"
3614 -f docker-compose-router.yaml $RC_STACK_ROUTER_EXT"
3574
3615
3575 if [[ $DEBUG ]]; then
3616 if [[ $DEBUG ]]; then
3576 echo "---"
3617 echo "---"
3577 echo "stacks docker: $RC_STACK_ROUTER_EXT_LCL"
3618 echo "stacks docker: $RC_STACK_ROUTER_EXT_LCL"
3578 echo "running command: ${CMD_ROUTER}"
3619 echo "running command: ${CMD_ROUTER}"
3579 echo "ARGS: ${other_args[*]}"
3620 echo "ARGS: ${other_args[*]}"
3580 echo "---"
3621 echo "---"
3581 fi
3622 fi
3582 eval "${CMD_ROUTER} ${other_args[*]}"
3623 eval "${CMD_ROUTER} ${other_args[*]}"
3583
3624
3584 }
3625 }
3585
3626
3586 # :command.function
3627 # :command.function
3587 rcstack_stack_metrics_command() {
3628 rcstack_stack_metrics_command() {
3588 # src/stack_metrics_command.sh
3629 # src/stack_metrics_command.sh
3589 check_bootstrap
3630 check_bootstrap
3590
3631
3591 DEBUG=${args[--debug]}
3632 DEBUG=${args[--debug]}
3592 ENV_FILE=${args[--env-file-path]}
3633 ENV_FILE=${args[--env-file-path]}
3593
3634
3594 if [[ ! -f $RC_STACK_METRICS_EXT ]]; then
3635 if [[ ! -f $RC_STACK_METRICS_EXT ]]; then
3595 RC_STACK_METRICS_EXT_LCL=""
3636 RC_STACK_METRICS_EXT_LCL=""
3596 else
3637 else
3597 RC_STACK_METRICS_EXT_LCL="-f $RC_STACK_METRICS_EXT"
3638 RC_STACK_METRICS_EXT_LCL="-f $RC_STACK_METRICS_EXT"
3598 fi
3639 fi
3599
3640
3600 CMD_METRICS="\
3641 CMD_METRICS="\
3601 RC_ENV_FILE=$ENV_FILE docker compose \
3642 RC_ENV_FILE=$ENV_FILE docker compose \
3602 --env-file $ENV_FILE \
3643 --env-file $ENV_FILE \
3603 $ENV_EXPAND \
3644 $ENV_EXPAND \
3604 -p rc_cluster_metrics \
3645 -p rc_cluster_metrics \
3605 -f docker-compose-base.yaml \
3646 -f docker-compose-base.yaml \
3606 -f docker-compose-metrics.yaml $RC_STACK_METRICS_EXT_LCL"
3647 -f docker-compose-metrics.yaml $RC_STACK_METRICS_EXT_LCL"
3607
3648
3608 if [[ $DEBUG ]]; then
3649 if [[ $DEBUG ]]; then
3609 echo "---"
3650 echo "---"
3610 echo "stacks docker: $RC_STACK_METRICS_EXT_LCL"
3651 echo "stacks docker: $RC_STACK_METRICS_EXT_LCL"
3611 echo "running command: ${CMD_METRICS}"
3652 echo "running command: ${CMD_METRICS}"
3612 echo "ARGS: ${other_args[*]}"
3653 echo "ARGS: ${other_args[*]}"
3613 echo "---"
3654 echo "---"
3614 fi
3655 fi
3615 eval "${CMD_METRICS} ${other_args[*]}"
3656 eval "${CMD_METRICS} ${other_args[*]}"
3616 }
3657 }
3617
3658
3618 # :command.function
3659 # :command.function
3619 rcstack_stack_services_command() {
3660 rcstack_stack_services_command() {
3620 # src/stack_services_command.sh
3661 # src/stack_services_command.sh
3621 check_bootstrap
3662 check_bootstrap
3622
3663
3623 DEBUG=${args[--debug]}
3664 DEBUG=${args[--debug]}
3624 ENV_FILE=${args[--env-file-path]}
3665 ENV_FILE=${args[--env-file-path]}
3625
3666
3626 if [[ ! -f $RC_STACK_SERVICES_EXT ]]; then
3667 if [[ ! -f $RC_STACK_SERVICES_EXT ]]; then
3627 RC_STACK_SERVICES_EXT_LCL=""
3668 RC_STACK_SERVICES_EXT_LCL=""
3628 else
3669 else
3629 RC_STACK_SERVICES_EXT_LCL="-f $RC_STACK_SERVICES_EXT"
3670 RC_STACK_SERVICES_EXT_LCL="-f $RC_STACK_SERVICES_EXT"
3630 fi
3671 fi
3631
3672
3632 RC_STACK_PROFILES="--profile database --profile redis --profile elasticsearch --profile channelstream"
3673 RC_STACK_PROFILES="--profile database --profile redis --profile elasticsearch --profile channelstream"
3633
3674
3634 CMD_SERVICES="\
3675 CMD_SERVICES="\
3635 RC_ENV_FILE=$ENV_FILE docker compose \
3676 RC_ENV_FILE=$ENV_FILE docker compose \
3636 --env-file $ENV_FILE \
3677 --env-file $ENV_FILE \
3637 $ENV_EXPAND \
3678 $ENV_EXPAND \
3638 $RC_STACK_PROFILES \
3679 $RC_STACK_PROFILES \
3639 --project-name rc_cluster_services \
3680 --project-name rc_cluster_services \
3640 -f docker-compose-base.yaml \
3681 -f docker-compose-base.yaml \
3641 -f docker-compose-services.yaml $RC_STACK_SERVICES_EXT_LCL"
3682 -f docker-compose-services.yaml $RC_STACK_SERVICES_EXT_LCL"
3642
3683
3643 if [[ $DEBUG ]]; then
3684 if [[ $DEBUG ]]; then
3644 echo "---"
3685 echo "---"
3645 echo "stacks docker: $RC_STACK_SERVICES_EXT_LCL"
3686 echo "stacks docker: $RC_STACK_SERVICES_EXT_LCL"
3646 echo "running command: ${CMD_SERVICES}"
3687 echo "running command: ${CMD_SERVICES}"
3647 echo "ARGS: ${other_args[*]}"
3688 echo "ARGS: ${other_args[*]}"
3648 echo "---"
3689 echo "---"
3649 fi
3690 fi
3650
3691
3651 eval "${CMD_SERVICES} ${other_args[*]}"
3692 eval "${CMD_SERVICES} ${other_args[*]}"
3652 }
3693 }
3653
3694
3654 # :command.function
3695 # :command.function
3655 rcstack_stack_rhodecode_command() {
3696 rcstack_stack_rhodecode_command() {
3656 # src/stack_rhodecode_command.sh
3697 # src/stack_rhodecode_command.sh
3657 check_bootstrap
3698 check_bootstrap
3658
3699
3659 DEBUG=${args[--debug]}
3700 DEBUG=${args[--debug]}
3660 ENV_FILE=${args[--env-file-path]}
3701 ENV_FILE=${args[--env-file-path]}
3661
3702
3662 stack_prefix=${args[--stack-prefix]}
3703 stack_prefix=${args[--stack-prefix]}
3663 if [[ $stack_prefix == "" ]]; then
3704 if [[ $stack_prefix == "" ]]; then
3664 stack_prefix="rc_cluster_apps"
3705 stack_prefix="rc_cluster_apps"
3665 fi
3706 fi
3666
3707
3667 if [[ ! -f $RC_STACK_RHODECODE_EXT ]]; then
3708 if [[ ! -f $RC_STACK_RHODECODE_EXT ]]; then
3668 RC_STACK_RHODECODE_EXT_LCL=""
3709 RC_STACK_RHODECODE_EXT_LCL=""
3669 else
3710 else
3670 RC_STACK_RHODECODE_EXT_LCL="-f $RC_STACK_RHODECODE_EXT"
3711 RC_STACK_RHODECODE_EXT_LCL="-f $RC_STACK_RHODECODE_EXT"
3671 fi
3712 fi
3672
3713
3673 CMD_RHODECODE="\
3714 CMD_RHODECODE="\
3674 RC_ENV_FILE=$ENV_FILE docker compose \
3715 RC_ENV_FILE=$ENV_FILE docker compose \
3675 --env-file $ENV_FILE \
3716 --env-file $ENV_FILE \
3676 $ENV_EXPAND \
3717 $ENV_EXPAND \
3677 -p $stack_prefix \
3718 -p $stack_prefix \
3678 -f docker-compose-base.yaml \
3719 -f docker-compose-base.yaml \
3679 -f docker-compose-apps.yaml $RC_STACK_RHODECODE_EXT_LCL"
3720 -f docker-compose-apps.yaml $RC_STACK_RHODECODE_EXT_LCL"
3680
3721
3681 sub_cmd=${other_args[0]}
3722 sub_cmd=${other_args[0]}
3682
3723
3683 if [[ $sub_cmd == "up" ]]; then
3724 if [[ $sub_cmd == "up" ]]; then
3684 declare -a final_args=( "$sub_cmd" "--no-color" "--no-build" "${other_args[@]:1}" )
3725 declare -a final_args=( "$sub_cmd" "--no-color" "--no-build" "${other_args[@]:1}" )
3685 else
3726 else
3686 declare -a final_args=( "$sub_cmd" "${other_args[@]:1}" )
3727 declare -a final_args=( "$sub_cmd" "${other_args[@]:1}" )
3687 fi
3728 fi
3688
3729
3689 if [[ $DEBUG ]]; then
3730 if [[ $DEBUG ]]; then
3690 echo "---"
3731 echo "---"
3691 echo "stacks docker: $RC_STACK_RHODECODE_EXT_LCL"
3732 echo "stacks docker: $RC_STACK_RHODECODE_EXT_LCL"
3692 echo "running command: ${CMD_RHODECODE}"
3733 echo "running command: ${CMD_RHODECODE}"
3693 echo "ARGS: ${final_args[*]}"
3734 echo "ARGS: ${final_args[*]}"
3694 echo "---"
3735 echo "---"
3695 fi
3736 fi
3696 eval "${CMD_RHODECODE} ${final_args[*]}"
3737 eval "${CMD_RHODECODE} ${final_args[*]}"
3697
3738
3698 }
3739 }
3699
3740
3700 # :command.function
3741 # :command.function
3701 rcstack_stack_all_command() {
3742 rcstack_stack_all_command() {
3702 # src/stack_all_command.sh
3743 # src/stack_all_command.sh
3703 check_bootstrap
3744 check_bootstrap
3704
3745
3705 DEBUG=${args[--debug]}
3746 DEBUG=${args[--debug]}
3706
3747
3707 stack_lst=$VALID_SERVICES
3748 stack_lst=$VALID_SERVICES
3708
3749
3709 for stack in $stack_lst; do
3750 for stack in $stack_lst; do
3710 ./$RC_SCRIPT_NAME stack $stack ${other_args[*]}
3751 ./$RC_SCRIPT_NAME stack $stack ${other_args[*]}
3711 done
3752 done
3712
3753
3713 }
3754 }
3714
3755
3715 # :command.function
3756 # :command.function
3716 rcstack_stack_status_command() {
3757 rcstack_stack_status_command() {
3717 # src/stack_status_command.sh
3758 # src/stack_status_command.sh
3718 check_bootstrap
3759 check_bootstrap
3719 DEBUG=${args[--debug]}
3760 DEBUG=${args[--debug]}
3720 DETAILED=${args[--detailed]}
3761 DETAILED=${args[--detailed]}
3721 CONFIGS=${args[--configs]}
3762 CONFIGS=${args[--configs]}
3722 VERBOSE=${args[-v]}
3763 VERBOSE=${args[-v]}
3723
3764
3724 .env --file $RUNTIME_ENV
3765 .env --file $RUNTIME_ENV
3725 .env get_or_error RC_APP_BASE_URL
3766 .env get_or_error RC_APP_BASE_URL
3726 RC_APP_BASE_URL=$REPLY
3767 RC_APP_BASE_URL=$REPLY
3727
3768
3728 .env get_or_error RC_VERSION
3769 .env get_or_error RC_VERSION
3729 RC_VERSION=$REPLY
3770 RC_VERSION=$REPLY
3730
3771
3731 .env get_or_error RC_SSH_PORT
3772 .env get_or_error RC_SSH_PORT
3732 RC_SSH_PORT=$REPLY
3773 RC_SSH_PORT=$REPLY
3733
3774
3734 .env get_or_error RC_EDITION
3775 .env get_or_error RC_EDITION
3735 RC_EDITION=$REPLY
3776 RC_EDITION=$REPLY
3736
3777
3737 .env get_or_error RC_LICENSE_TOKEN
3778 .env get_or_error RC_LICENSE_TOKEN
3738 RC_LICENSE_TOKEN=$REPLY
3779 RC_LICENSE_TOKEN=$REPLY
3739
3780
3740 if [[ $DEBUG ]]; then
3781 if [[ $DEBUG ]]; then
3741 echo "---"
3782 echo "---"
3742 ps_cmd=$(docker ps --filter=name=rc_cluster --format="{{.ID}}")
3783 ps_cmd=$(docker ps --filter=name=rc_cluster --format="{{.ID}}")
3743
3784
3744 for service in $ps_cmd; do
3785 for service in $ps_cmd; do
3745
3786
3746 servicename=`docker inspect --format '{{ .Name }}' $service`
3787 servicename=`docker inspect --format '{{ .Name }}' $service`
3747 servicename=${servicename:1}
3788 servicename=${servicename:1}
3748 echo $servicename
3789 echo $servicename
3749 docker inspect $service --format='{{.State.Status}}: {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'
3790 docker inspect $service --format='{{.State.Status}}: {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'
3750 echo ""
3791 echo ""
3751
3792
3752 done
3793 done
3753 echo "---"
3794 echo "---"
3754 fi
3795 fi
3755
3796
3756 echo "Running hostname: $RC_APP_BASE_URL"
3797 echo "Running hostname: $RC_APP_BASE_URL"
3757 if [[ $VERBOSE ]]; then
3798 if [[ $VERBOSE ]]; then
3758 printf "SSH Port: $RC_SSH_PORT\n"
3799 printf "SSH Port: $RC_SSH_PORT\n"
3759 printf "Edition: $RC_EDITION:$RC_VERSION\n"
3800 printf "Edition: $RC_EDITION:$RC_VERSION\n"
3760 printf "License: $RC_LICENSE_TOKEN\n"
3801 printf "License: $RC_LICENSE_TOKEN\n"
3761 printf "\n"
3802 printf "\n"
3762 fi
3803 fi
3763
3804
3764 if [[ $CONFIGS ]]; then
3805 if [[ $CONFIGS ]]; then
3765 printf "rcstack:\n"
3806 printf "rcstack:\n"
3766 printf " config (in-host): $RUNTIME_ENV\n"
3807 printf " config (in-host): $RUNTIME_ENV\n"
3767
3808
3768 printf "RhodeCode:\n"
3809 printf "RhodeCode:\n"
3769 printf " ini (in-host): $rhodecode_default_config_path\n"
3810 printf " ini (in-host): $rhodecode_default_config_path\n"
3770 printf " volumes (in-container):\n"
3811 printf " volumes (in-container):\n"
3771 printf " repo-store: /var/opt/rhodecode_repo_store\n"
3812 printf " repo-store: /var/opt/rhodecode_repo_store\n"
3772 printf " data-store: /var/opt/rhodecode_data\n"
3813 printf " data-store: /var/opt/rhodecode_data\n"
3773
3814
3774 printf "VCSServer:\n"
3815 printf "VCSServer:\n"
3775 printf " ini (in-host): $vcsserver_default_config_path\n"
3816 printf " ini (in-host): $vcsserver_default_config_path\n"
3776 printf " volumes (in-container):\n"
3817 printf " volumes (in-container):\n"
3777 printf " repo-store: /var/opt/rhodecode_repo_store\n"
3818 printf " repo-store: /var/opt/rhodecode_repo_store\n"
3778 printf " data-store: /var/opt/rhodecode_data\n"
3819 printf " data-store: /var/opt/rhodecode_data\n"
3779
3820
3780 printf "Traefik (router):\n"
3821 printf "Traefik (router):\n"
3781 printf " ssl-certs definitions: .custom/traefik_custom/dynamic/traefik_dynamic_custom.yaml\n"
3822 printf " ssl-certs definitions: .custom/traefik_custom/dynamic/traefik_dynamic_custom.yaml\n"
3782 printf " ssl-certs dir: .custom/traefik_custom/dynamic/certs/\n"
3823 printf " ssl-certs dir: .custom/traefik_custom/dynamic/certs/\n"
3783
3824
3784 fi
3825 fi
3785
3826
3786 if [[ $DETAILED ]]; then
3827 if [[ $DETAILED ]]; then
3787 ps_cmd=$(docker ps --filter=name=rc_cluster --format="{{.ID}}")
3828 ps_cmd=$(docker ps --filter=name=rc_cluster --format="{{.ID}}")
3788
3829
3789 for service in $ps_cmd; do
3830 for service in $ps_cmd; do
3790 servicename=`docker inspect --format '{{ .Name }}' $service`
3831 servicename=`docker inspect --format '{{ .Name }}' $service`
3791 servicename=${servicename:1}
3832 servicename=${servicename:1}
3792 printf "CONTAINER:\\t$servicename\n"
3833 printf "CONTAINER:\\t$servicename\n"
3793 printf "LOGS:\\t\\tdocker logs --tail=100 $service\n"
3834 printf "LOGS:\\t\\tdocker logs --tail=100 $service\n"
3794 docker ps --filter=name=$servicename --format="ID:\\t\\t{{.ID}}\nIMAGE:\\t\\t{{.Image}}\nSTATUS:\\t\\t{{.Status}}\nPORTS:\\t\\t{{.Ports}}\n"
3835 docker ps --filter=name=$servicename --format="ID:\\t\\t{{.ID}}\nIMAGE:\\t\\t{{.Image}}\nSTATUS:\\t\\t{{.Status}}\nPORTS:\\t\\t{{.Ports}}\n"
3795 echo ""
3836 echo ""
3796 done
3837 done
3797 else
3838 else
3798 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 )
3839 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 )
3799 fi
3840 fi
3800
3841
3801 }
3842 }
3802
3843
3803 # :command.function
3844 # :command.function
3804 rcstack_stack_upgrade_router_command() {
3845 rcstack_stack_upgrade_router_command() {
3805 # src/stack_upgrade_router_command.sh
3846 # src/stack_upgrade_router_command.sh
3806 echo "Upgrading this stack with:"
3847 echo "Upgrading this stack with:"
3807 echo "./$RC_SCRIPT_NAME stack router up --force-recreate --detach"
3848 echo "./$RC_SCRIPT_NAME stack router up --force-recreate --detach"
3808 echo ""
3849 echo ""
3809 echo "NOTE: To reclaim space occupied by old images, run:"
3850 echo "NOTE: To reclaim space occupied by old images, run:"
3810 echo "docker image prune -f"
3851 echo "docker image prune -f"
3811
3852
3812 ./$RC_SCRIPT_NAME stack router up --force-recreate --detach
3853 ./$RC_SCRIPT_NAME stack router up --force-recreate --detach
3813
3854
3814 }
3855 }
3815
3856
3816 # :command.function
3857 # :command.function
3817 rcstack_stack_upgrade_services_command() {
3858 rcstack_stack_upgrade_services_command() {
3818 # src/stack_upgrade_services_command.sh
3859 # src/stack_upgrade_services_command.sh
3819 echo "Upgrading this stack with:"
3860 echo "Upgrading this stack with:"
3820 echo "./$RC_SCRIPT_NAME stack services up --force-recreate --detach"
3861 echo "./$RC_SCRIPT_NAME stack services up --force-recreate --detach"
3821 echo ""
3862 echo ""
3822 echo "NOTE: To reclaim space occupied by old images, run:"
3863 echo "NOTE: To reclaim space occupied by old images, run:"
3823 echo "docker image prune -f"
3864 echo "docker image prune -f"
3824
3865
3825 ./$RC_SCRIPT_NAME stack services up --force-recreate --detach
3866 ./$RC_SCRIPT_NAME stack services up --force-recreate --detach
3826
3867
3827 }
3868 }
3828
3869
3829 # :command.function
3870 # :command.function
3830 rcstack_stack_upgrade_metrics_command() {
3871 rcstack_stack_upgrade_metrics_command() {
3831 # src/stack_upgrade_metrics_command.sh
3872 # src/stack_upgrade_metrics_command.sh
3832 echo "To upgrading this stack with:"
3873 echo "To upgrading this stack with:"
3833 echo "./$RC_SCRIPT_NAME stack metrics up --force-recreate --detach"
3874 echo "./$RC_SCRIPT_NAME stack metrics up --force-recreate --detach"
3834 echo ""
3875 echo ""
3835 echo "NOTE: To reclaim space occupied by old images, run:"
3876 echo "NOTE: To reclaim space occupied by old images, run:"
3836 echo "docker image prune -f"
3877 echo "docker image prune -f"
3837
3878
3838 ./$RC_SCRIPT_NAME stack metrics up --force-recreate --detach
3879 ./$RC_SCRIPT_NAME stack metrics up --force-recreate --detach
3839
3880
3840 }
3881 }
3841
3882
3842 # :command.function
3883 # :command.function
3843 rcstack_stack_upgrade_rhodecode_command() {
3884 rcstack_stack_upgrade_rhodecode_command() {
3844 # src/stack_upgrade_rhodecode_command.sh
3885 # src/stack_upgrade_rhodecode_command.sh
3845 check_bootstrap
3886 check_bootstrap
3846
3887
3847 stop_wait=${args[--stop-wait]}
3888 stop_wait=${args[--stop-wait]}
3848 docker_stop_wait=${args[--docker-stop-wait]}
3889 docker_stop_wait=${args[--docker-stop-wait]}
3849
3890
3850 stack_prefix=${args[--stack-prefix]}
3891 stack_prefix=${args[--stack-prefix]}
3851 if [[ $stack_prefix == "" ]]; then
3892 if [[ $stack_prefix == "" ]]; then
3852 stack_prefix="rc_cluster_apps"
3893 stack_prefix="rc_cluster_apps"
3853 fi
3894 fi
3854
3895
3855 # search docker IDs for current service
3896 # search docker IDs for current service
3856 .env --file $RUNTIME_ENV
3897 .env --file $RUNTIME_ENV
3857
3898
3858 .env get_or_error RC_VERSION
3899 .env get_or_error RC_VERSION
3859 RC_VERSION=$REPLY
3900 RC_VERSION=$REPLY
3860
3901
3861 .env get_or_error RC_EDITION
3902 .env get_or_error RC_EDITION
3862 RC_EDITION=$REPLY
3903 RC_EDITION=$REPLY
3863
3904
3864 echo "Pulling new image: rhodecode/rhodecode-${RC_EDITION}:${RC_VERSION}"
3905 echo "Pulling new image: rhodecode/rhodecode-${RC_EDITION}:${RC_VERSION}"
3865 echo "WARNING: about to start downloading the RhodeCode base image"
3906 echo "WARNING: about to start downloading the RhodeCode base image"
3866 echo "This process may take anywhere between a few minutes to an hour, depending on your network speed"
3907 echo "This process may take anywhere between a few minutes to an hour, depending on your network speed"
3867 echo "running: docker pull -q rhodecode/rhodecode-${RC_EDITION}:${RC_VERSION}"
3908 echo "running: docker pull -q rhodecode/rhodecode-${RC_EDITION}:${RC_VERSION}"
3868
3909
3869 eval "docker pull -q rhodecode/rhodecode-${RC_EDITION}:${RC_VERSION}"
3910 eval "docker pull -q rhodecode/rhodecode-${RC_EDITION}:${RC_VERSION}"
3870
3911
3871 have_tty=1
3912 have_tty=1
3872 # Set a dummy terminal type if none set
3913 # Set a dummy terminal type if none set
3873 [[ -z "$TERM" ]] && export have_tty=0
3914 [[ -z "$TERM" ]] && export have_tty=0
3874 [[ ! -t 1 ]] && export have_tty=0
3915 [[ ! -t 1 ]] && export have_tty=0
3875
3916
3876 set_cursor() {
3917 set_cursor() {
3877 if [[ $have_tty == 1 ]]; then
3918 if [[ $have_tty == 1 ]]; then
3878 tput $1
3919 tput $1
3879 fi
3920 fi
3880 }
3921 }
3881
3922
3882 stop_containers() {
3923 stop_containers() {
3883 target_container=$1
3924 target_container=$1
3884 docker_stop_wait=$2
3925 docker_stop_wait=$2
3885 stop_wait=$3
3926 stop_wait=$3
3886 target_containers_pat="$stack_prefix-$target_container-*"
3927 target_containers_pat="$stack_prefix-$target_container-*"
3887
3928
3888 # array with OLD containers
3929 # array with OLD containers
3889 local -a old_docker_ids
3930 local -a old_docker_ids
3890 readarray -t old_docker_ids < <(docker ps --filter name="$target_containers_pat" -q)
3931 readarray -t old_docker_ids < <(docker ps --filter name="$target_containers_pat" -q)
3891
3932
3892 scale=${#old_docker_ids[@]}
3933 scale=${#old_docker_ids[@]}
3893 scale_2=$(( scale * 2 ))
3934 scale_2=$(( scale * 2 ))
3894
3935
3895 echo ""
3936 echo ""
3896 echo "Found $scale old container[s] for $target_container"
3937 echo "Found $scale old container[s] for $target_container"
3897 echo "Old container-ids:" "${old_docker_ids[@]}"
3938 echo "Old container-ids:" "${old_docker_ids[@]}"
3898 echo ""
3939 echo ""
3899
3940
3900 if [[ $scale == "0" ]]; then
3941 if [[ $scale == "0" ]]; then
3901 echo "No previous services found, doing a regular start for $target_container"
3942 echo "No previous services found, doing a regular start for $target_container"
3902 ./$RC_SCRIPT_NAME stack rhodecode up $target_container --detach
3943 ./$RC_SCRIPT_NAME stack rhodecode up $target_container --detach
3903 return
3944 return
3904 else
3945 else
3905 echo "Scaling to 2x ($scale_2 total) containers for $target_container"
3946 echo "Scaling to 2x ($scale_2 total) containers for $target_container"
3906 ./$RC_SCRIPT_NAME stack rhodecode up $target_container --no-recreate --detach --scale $target_container=$scale_2
3947 ./$RC_SCRIPT_NAME stack rhodecode up $target_container --no-recreate --detach --scale $target_container=$scale_2
3907 fi
3948 fi
3908
3949
3909 # array with ALL new containers
3950 # array with ALL new containers
3910 local -a scaled_docker_ids
3951 local -a scaled_docker_ids
3911 readarray -t scaled_docker_ids < <(docker ps --filter name="$target_containers_pat" -q)
3952 readarray -t scaled_docker_ids < <(docker ps --filter name="$target_containers_pat" -q)
3912
3953
3913 echo "Scaling completed, running $scale_2 services for upgrade purpose..."
3954 echo "Scaling completed, running $scale_2 services for upgrade purpose..."
3914 echo "new docker-ids:" "${scaled_docker_ids[@]}"
3955 echo "new docker-ids:" "${scaled_docker_ids[@]}"
3915
3956
3916 # calculate just NEW containers
3957 # calculate just NEW containers
3917 declare -A new_container_check
3958 declare -A new_container_check
3918
3959
3919 # Mark elements of the first initial docker
3960 # Mark elements of the first initial docker
3920 for docker_id in "${old_docker_ids[@]}"; do
3961 for docker_id in "${old_docker_ids[@]}"; do
3921 new_container_check[$docker_id]=1
3962 new_container_check[$docker_id]=1
3922 done
3963 done
3923
3964
3924 local new_docker_ids_str
3965 local new_docker_ids_str
3925 new_docker_ids_str=""
3966 new_docker_ids_str=""
3926
3967
3927 # Check if elements of the second array are not in the first
3968 # Check if elements of the second array are not in the first
3928 for n_docker_id in "${scaled_docker_ids[@]}"; do
3969 for n_docker_id in "${scaled_docker_ids[@]}"; do
3929 # if $docker_id in new services is empty in the last array we ADD it :)
3970 # if $docker_id in new services is empty in the last array we ADD it :)
3930 if [[ -z ${new_container_check[$n_docker_id]} ]]; then
3971 if [[ -z ${new_container_check[$n_docker_id]} ]]; then
3931 new_docker_ids_str+=" $n_docker_id "
3972 new_docker_ids_str+=" $n_docker_id "
3932 fi
3973 fi
3933 done
3974 done
3934
3975
3935 echo "Stopping $scale old $target_container containers "
3976 echo "Stopping $scale old $target_container containers "
3936 echo "killing docker-ids:" "${old_docker_ids[@]}"
3977 echo "killing docker-ids:" "${old_docker_ids[@]}"
3937
3978
3938 spin='⠾⠽⠻⠟⠯⠷'
3979 spin='⠾⠽⠻⠟⠯⠷'
3939 charwidth=1
3980 charwidth=1
3940
3981
3941 # wait the required stop-wait time
3982 # wait the required stop-wait time
3942 #HC: docker inspect --format='{{.Name}}: {{json .ContainerId .State.Health.Status}}' <container-id>
3983 #HC: docker inspect --format='{{.Name}}: {{json .ContainerId .State.Health.Status}}' <container-id>
3943 local i
3984 local i
3944 i=$(($stop_wait * 10))
3985 i=$(($stop_wait * 10))
3945
3986
3946 local status
3987 local status
3947 status=''
3988 status=''
3948
3989
3949 # cursor invisible
3990 # cursor invisible
3950 set_cursor civis
3991 set_cursor civis
3951 while true
3992 while true
3952 s=$((i / 10))
3993 s=$((i / 10))
3953 do
3994 do
3954 i=$(($i-1))
3995 i=$(($i-1))
3955 if [[ $i -lt 1 ]]; then
3996 if [[ $i -lt 1 ]]; then
3956 break
3997 break
3957 fi
3998 fi
3958
3999
3959 if [[ "$(($i % 10))" == 0 ]];
4000 if [[ "$(($i % 10))" == 0 ]];
3960 then
4001 then
3961 is_at_sec=1
4002 is_at_sec=1
3962 else
4003 else
3963 is_at_sec=0
4004 is_at_sec=0
3964 fi
4005 fi
3965
4006
3966 local new_docker_ids_status_cnt
4007 local new_docker_ids_status_cnt
3967
4008
3968 if [[ $is_at_sec == 1 ]]; then
4009 if [[ $is_at_sec == 1 ]]; then
3969
4010
3970 new_docker_ids_status_cnt=$(docker inspect --format='{{.State.Health.Status}}' $new_docker_ids_str | grep -c "healthy" || echo "")
4011 new_docker_ids_status_cnt=$(docker inspect --format='{{.State.Health.Status}}' $new_docker_ids_str | grep -c "healthy" || echo "")
3971
4012
3972 if [[ $new_docker_ids_status_cnt -eq $scale ]]; then
4013 if [[ $new_docker_ids_status_cnt -eq $scale ]]; then
3973 echo "All $target_container are in HEALTHY state; stopping old ones now"
4014 echo "All $target_container are in HEALTHY state; stopping old ones now"
3974 echo ""
4015 echo ""
3975 break
4016 break
3976 fi
4017 fi
3977
4018
3978 fi
4019 fi
3979
4020
3980 k=$(((k + $charwidth) % ${#spin}))
4021 k=$(((k + $charwidth) % ${#spin}))
3981
4022
3982 if [[ $have_tty == 1 ]]; then
4023 if [[ $have_tty == 1 ]]; then
3983 printf "%s stopping $scale old containers once they are in HEALTHY state, or in $s s..." "${spin:$k:$charwidth}"
4024 printf "%s stopping $scale old containers once they are in HEALTHY state, or in $s s..." "${spin:$k:$charwidth}"
3984 printf "\r"
4025 printf "\r"
3985 else
4026 else
3986 if [[ $is_at_sec == 1 ]]; then
4027 if [[ $is_at_sec == 1 ]]; then
3987 echo "stopping $scale old containers once they are in HEALTHY state, or in $s s..."
4028 echo "stopping $scale old containers once they are in HEALTHY state, or in $s s..."
3988 fi
4029 fi
3989 fi
4030 fi
3990
4031
3991 sleep .1
4032 sleep .1
3992 done
4033 done
3993 set_cursor cnorm
4034 set_cursor cnorm
3994
4035
3995 for container in "${old_docker_ids[@]}"
4036 for container in "${old_docker_ids[@]}"
3996 do
4037 do
3997 echo "now running container $container stop with --time $docker_stop_wait"
4038 echo "now running container $container stop with --time $docker_stop_wait"
3998 docker stop --time "$docker_stop_wait" "$container" > /dev/null
4039 docker stop --time "$docker_stop_wait" "$container" > /dev/null
3999 docker rm "$container" > /dev/null
4040 docker rm "$container" > /dev/null
4000 echo "Stopped $container"
4041 echo "Stopped $container"
4001 done
4042 done
4002
4043
4003 }
4044 }
4004
4045
4005 # VCSSERVER Containers
4046 # VCSSERVER Containers
4006 stop_containers "vcsserver" $docker_stop_wait $stop_wait
4047 stop_containers "vcsserver" $docker_stop_wait $stop_wait
4007
4048
4008 # RHODECODE Containers
4049 # RHODECODE Containers
4009 stop_containers "rhodecode" $docker_stop_wait $stop_wait
4050 stop_containers "rhodecode" $docker_stop_wait $stop_wait
4010
4051
4011 # SSHD Containers
4052 # SSHD Containers
4012 stop_containers "sshd" $docker_stop_wait $stop_wait
4053 stop_containers "sshd" $docker_stop_wait $stop_wait
4013
4054
4014 # SVN Containers
4055 # SVN Containers
4015 stop_containers "svn" $docker_stop_wait $stop_wait
4056 stop_containers "svn" $docker_stop_wait $stop_wait
4016
4057
4017 ./$RC_SCRIPT_NAME stack rhodecode up celery --force-recreate --detach
4058 ./$RC_SCRIPT_NAME stack rhodecode up celery --force-recreate --detach
4018 ./$RC_SCRIPT_NAME stack rhodecode up celery-beat --force-recreate --detach
4059 ./$RC_SCRIPT_NAME stack rhodecode up celery-beat --force-recreate --detach
4019
4060
4020 echo "Upgrade to rhodecode/rhodecode-${RC_EDITION}:${RC_VERSION} completed"
4061 echo "Upgrade to rhodecode/rhodecode-${RC_EDITION}:${RC_VERSION} completed"
4021 exit
4062 exit
4022
4063
4023 }
4064 }
4024
4065
4025 # :command.function
4066 # :command.function
4026 rcstack_stack_monitor_restart_unhealthy_command() {
4067 rcstack_stack_monitor_restart_unhealthy_command() {
4027 # src/stack_monitor_restart_unhealthy_command.sh
4068 # src/stack_monitor_restart_unhealthy_command.sh
4028 check_bootstrap
4069 check_bootstrap
4029
4070
4030 DEBUG=${args[--debug]}
4071 DEBUG=${args[--debug]}
4031 loop=${args[--loop]}
4072 loop=${args[--loop]}
4032
4073
4033 get_unhealthy() {
4074 get_unhealthy() {
4034 unhealthy=$(docker ps --filter health=unhealthy --filter label=autoheal=true --format "{{.ID}}")
4075 unhealthy=$(docker ps --filter health=unhealthy --filter label=autoheal=true --format "{{.ID}}")
4035
4076
4036 if [[ $unhealthy == "" ]]; then
4077 if [[ $unhealthy == "" ]]; then
4037 echo "$(green stack-monitor: no unhealthy containers found)"
4078 echo "$(green stack-monitor: no unhealthy containers found)"
4038 else
4079 else
4039 echo "$(yellow stack-monitor: found unhealthy containers $unhealthy)"
4080 echo "$(yellow stack-monitor: found unhealthy containers $unhealthy)"
4040 fi
4081 fi
4041
4082
4042 for container in $unhealthy
4083 for container in $unhealthy
4043 do
4084 do
4044 docker stats --no-stream --format '{{.ID}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}\t{{.BlockIO}}' $container
4085 docker stats --no-stream --format '{{.ID}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}\t{{.BlockIO}}' $container
4045 echo "stack-monitor: restart $container"
4086 echo "stack-monitor: restart $container"
4046 docker restart --time=10 $container
4087 docker restart --time=10 $container
4047 done
4088 done
4048
4089
4049 }
4090 }
4050
4091
4051 if [[ ! $loop == "0" ]]; then
4092 if [[ ! $loop == "0" ]]; then
4052
4093
4053 while true
4094 while true
4054 do
4095 do
4055 date_formatted=$(date)
4096 date_formatted=$(date)
4056 echo "stack-monitor: loop-run every $loop seconds..., $date_formatted"
4097 echo "stack-monitor: loop-run every $loop seconds..., $date_formatted"
4057 # loop run
4098 # loop run
4058 NO_COLOR=1 get_unhealthy
4099 NO_COLOR=1 get_unhealthy
4059 echo "Next execution in $loop s..." && \
4100 echo "Next execution in $loop s..." && \
4060 sleep $loop
4101 sleep $loop
4061 echo ""
4102 echo ""
4062 done
4103 done
4063
4104
4064 else
4105 else
4065
4106
4066 # one time run
4107 # one time run
4067 get_unhealthy
4108 get_unhealthy
4068 fi
4109 fi
4069
4110
4070 exit
4111 exit
4071
4112
4072 }
4113 }
4073
4114
4074 # :command.function
4115 # :command.function
4075 rcstack_cli_cmd_command() {
4116 rcstack_cli_cmd_command() {
4076 # src/cli_cmd_command.sh
4117 # src/cli_cmd_command.sh
4077 check_bootstrap
4118 check_bootstrap
4078
4119
4079 if [[ -z ${args['--user']} ]]; then
4120 if [[ -z ${args['--user']} ]]; then
4080 # set default, user if the flag is not used
4121 # set default, user if the flag is not used
4081 args['--user']='root'
4122 args['--user']='root'
4082 fi
4123 fi
4083
4124
4084 DEBUG=${args[--debug]}
4125 DEBUG=${args[--debug]}
4085 RUN_WITHOUT_TTY=${args[--no-tty]}
4126 RUN_WITHOUT_TTY=${args[--no-tty]}
4086 ENV_FILE=${args[--env-file-path]}
4127 ENV_FILE=${args[--env-file-path]}
4087 EXEC_USER=${args[--user]}
4128 EXEC_USER=${args[--user]}
4088
4129
4089 INTERACTIVE_FLAGS="--interactive --tty"
4130 INTERACTIVE_FLAGS="--interactive --tty"
4090 if [[ $RUN_WITHOUT_TTY ]]; then
4131 if [[ $RUN_WITHOUT_TTY ]]; then
4091 INTERACTIVE_FLAGS="--interactive"
4132 INTERACTIVE_FLAGS="--interactive"
4092 fi
4133 fi
4093
4134
4094 proj_name=rc_cluster_apps
4135 proj_name=rc_cluster_apps
4095 # use vcsserver here because it won't do any extra logic like rhodecode image does
4136 # use vcsserver here because it won't do any extra logic like rhodecode image does
4096 instance_type=vcsserver
4137 instance_type=vcsserver
4097
4138
4098 if [ ${#other_args[@]} -eq 0 ]; then
4139 if [ ${#other_args[@]} -eq 0 ]; then
4099 other_args[${#other_args[@]}]="echo 'please provide a valid cmd arg...'"
4140 other_args[${#other_args[@]}]="echo 'please provide a valid cmd arg...'"
4100 fi
4141 fi
4101
4142
4102 printf "*Volumes*:\n"
4143 printf "*Volumes*:\n"
4103 printf " attaching $PWD/config/_shared \t\tunder: /vol/confvolume\n"
4144 printf " attaching $PWD/config/_shared \t\tunder: /vol/confvolume\n"
4104 printf "\n"
4145 printf "\n"
4105
4146
4106 #printf "attaching rc_reposvolume \t\tunder: /vol/repovolume\n"
4147 #printf "attaching rc_reposvolume \t\tunder: /vol/repovolume\n"
4107 #printf "attaching \$PWD/.custom/storage \t\tunder: /vol/backupvolume\n"
4148 #printf "attaching \$PWD/.custom/storage \t\tunder: /vol/backupvolume\n"
4108
4149
4109 CMD_EXEC="\
4150 CMD_EXEC="\
4110 RC_ENV_FILE=$ENV_FILE docker compose \
4151 RC_ENV_FILE=$ENV_FILE docker compose \
4111 --env-file $ENV_FILE \
4152 --env-file $ENV_FILE \
4112 $ENV_EXPAND \
4153 $ENV_EXPAND \
4113 --project-name $proj_name \
4154 --project-name $proj_name \
4114 -f docker-compose-base.yaml \
4155 -f docker-compose-base.yaml \
4115 -f docker-compose-apps.yaml \
4156 -f docker-compose-apps.yaml \
4116 run \
4157 run \
4117 --user $EXEC_USER \
4158 --user $EXEC_USER \
4118 --rm \
4159 --rm \
4119 $INTERACTIVE_FLAGS \
4160 $INTERACTIVE_FLAGS \
4120 --volume=$PWD/config/_shared:/vol/confvolume \
4161 --volume=$PWD/config/_shared:/vol/confvolume \
4121 --workdir=/vol/confvolume \
4162 --workdir=/vol/confvolume \
4122 $instance_type"
4163 $instance_type"
4123
4164
4124 if [[ $DEBUG ]]; then
4165 if [[ $DEBUG ]]; then
4125 echo $CMD_EXEC
4166 echo $CMD_EXEC
4126 echo ${other_args[*]}
4167 echo ${other_args[*]}
4127 fi
4168 fi
4128
4169
4129 eval "${CMD_EXEC} ${other_args[*]}"
4170 eval "${CMD_EXEC} ${other_args[*]}"
4130
4171
4131 }
4172 }
4132
4173
4133 # :command.function
4174 # :command.function
4134 rcstack_cli_ishell_command() {
4175 rcstack_cli_ishell_command() {
4135 # src/cli_ishell_command.sh
4176 # src/cli_ishell_command.sh
4136 check_bootstrap
4177 check_bootstrap
4137
4178
4138 if [[ -z ${args['--user']} ]]; then
4179 if [[ -z ${args['--user']} ]]; then
4139 # set default, user if the flag is not used
4180 # set default, user if the flag is not used
4140 args['--user']='rhodecode'
4181 args['--user']='rhodecode'
4141 fi
4182 fi
4142
4183
4143 DEBUG=${args[--debug]}
4184 DEBUG=${args[--debug]}
4144 RUN_WITHOUT_TTY=${args[--no-tty]}
4185 RUN_WITHOUT_TTY=${args[--no-tty]}
4145 ENV_FILE=${args[--env-file-path]}
4186 ENV_FILE=${args[--env-file-path]}
4146 EXEC_USER=${args[--user]}
4187 EXEC_USER=${args[--user]}
4147
4188
4148 INTERACTIVE_FLAGS="--interactive --tty"
4189 INTERACTIVE_FLAGS="--interactive --tty"
4149 if [[ $RUN_WITHOUT_TTY ]]; then
4190 if [[ $RUN_WITHOUT_TTY ]]; then
4150 INTERACTIVE_FLAGS="--interactive"
4191 INTERACTIVE_FLAGS="--interactive"
4151 fi
4192 fi
4152
4193
4153 proj_name=rc_cluster_apps
4194 proj_name=rc_cluster_apps
4154 instance_type=rhodecode
4195 instance_type=rhodecode
4155
4196
4156 docker_id=$(docker ps --filter name=$proj_name-$instance_type -q | head -n1)
4197 docker_id=$(docker ps --filter name=$proj_name-$instance_type -q | head -n1)
4157 if [[ $docker_id == "" ]]; then
4198 if [[ $docker_id == "" ]]; then
4158 echo "$(yellow cannot find docker instance \($proj_name-$instance_type\) for command execution. Please make sure it is running.)"
4199 echo "$(yellow cannot find docker instance \($proj_name-$instance_type\) for command execution. Please make sure it is running.)"
4159 exit 1
4200 exit 1
4160 fi
4201 fi
4161
4202
4162 index_num=$(docker inspect "$docker_id" --format '{{ index .Config.Labels "com.docker.compose.container-number" }}')
4203 index_num=$(docker inspect "$docker_id" --format '{{ index .Config.Labels "com.docker.compose.container-number" }}')
4163 if [[ -z "$index_num" ]]
4204 if [[ -z "$index_num" ]]
4164 then
4205 then
4165 index_num="0"
4206 index_num="0"
4166 fi
4207 fi
4167
4208
4168 RC_STACK_PROFILES="--profile database --profile redis --profile elasticsearch --profile channelstream"
4209 RC_STACK_PROFILES="--profile database --profile redis --profile elasticsearch --profile channelstream"
4169
4210
4170 CMD_EXEC="\
4211 CMD_EXEC="\
4171 RC_ENV_FILE=$ENV_FILE docker compose \
4212 RC_ENV_FILE=$ENV_FILE docker compose \
4172 --env-file $ENV_FILE \
4213 --env-file $ENV_FILE \
4173 $ENV_EXPAND \
4214 $ENV_EXPAND \
4174 $RC_STACK_PROFILES \
4215 $RC_STACK_PROFILES \
4175 --project-name $proj_name \
4216 --project-name $proj_name \
4176 -f docker-compose-base.yaml \
4217 -f docker-compose-base.yaml \
4177 -f docker-compose-apps.yaml \
4218 -f docker-compose-apps.yaml \
4178 exec \
4219 exec \
4179 --index $index_num \
4220 --index $index_num \
4180 --user $EXEC_USER \
4221 --user $EXEC_USER \
4181 $INTERACTIVE_FLAGS \
4222 $INTERACTIVE_FLAGS \
4182 $instance_type \
4223 $instance_type \
4183 /usr/local/bin/rhodecode_bin/bin/rc-ishell \
4224 /usr/local/bin/rhodecode_bin/bin/rc-ishell \
4184 /etc/rhodecode/conf/rhodecode.ini"
4225 /etc/rhodecode/conf/rhodecode.ini"
4185
4226
4186 if [[ $DEBUG ]]; then
4227 if [[ $DEBUG ]]; then
4187 echo $CMD_EXEC
4228 echo $CMD_EXEC
4188 echo ${other_args[*]}
4229 echo ${other_args[*]}
4189 fi
4230 fi
4190
4231
4191 eval "${CMD_EXEC}"
4232 eval "${CMD_EXEC}"
4192
4233
4193 }
4234 }
4194
4235
4195 # :command.function
4236 # :command.function
4196 rcstack_cli_image_info_command() {
4237 rcstack_cli_image_info_command() {
4197 # src/cli_image_info_command.sh
4238 # src/cli_image_info_command.sh
4198
4239
4199 verbose=${args[--verbose]}
4240 verbose=${args[--verbose]}
4200
4241
4201 if [[ $verbose ]]; then
4242 if [[ $verbose ]]; then
4202
4243
4203 ver="unknown"
4244 ver="unknown"
4204 if [[ -f $RUNTIME_ENV ]]; then
4245 if [[ -f $RUNTIME_ENV ]]; then
4205 .env --file $RUNTIME_ENV
4246 .env --file $RUNTIME_ENV
4206 .env get_or_error RC_VERSION
4247 .env get_or_error RC_VERSION
4207 ver=$REPLY
4248 ver=$REPLY
4208 fi
4249 fi
4209
4250
4210 echo "Image stored version: $rc_image_ver"
4251 echo "Image stored version: $rc_image_ver"
4211 echo "Image from runtime: $ver"
4252 echo "Image from runtime: $ver"
4212 echo "runtime-file=$RUNTIME_ENV"
4253 echo "runtime-file=$RUNTIME_ENV"
4213 echo "RC_VERSION=$ver"
4254 echo "RC_VERSION=$ver"
4214 else
4255 else
4215 echo $rc_image_ver
4256 echo $rc_image_ver
4216 fi
4257 fi
4217
4258
4218 }
4259 }
4219
4260
4220 # :command.function
4261 # :command.function
4221 rcstack_cli_set_runtime_image_command() {
4262 rcstack_cli_set_image_command() {
4222 # src/cli_set_runtime_image_command.sh
4263 # src/cli_set_image_command.sh
4223 set_ver=${args[version]}
4264 set_ver=${args[version]}
4224
4265
4225 .env --file $RUNTIME_ENV
4266 .env --file $RUNTIME_ENV
4226 echo "setting runtime version to $set_ver into $RUNTIME_ENV"
4267 echo "setting runtime version to $set_ver into $RUNTIME_ENV"
4227
4268
4228 .env set RC_VERSION=$set_ver
4269 .env set RC_VERSION=$set_ver
4229
4270
4230 echo "New version set to $set_ver"
4271 echo "New version set to $set_ver"
4272 }
4273
4274 # :command.function
4275 deprecated_cli_set_runtime_image_command() {
4276 # src/cli_set_runtime_image_command.sh
4277 echo "$(red DEPRECATED: Use 'cli set-image' instead)" >&2
4278 rcstack_cli_set_image_command "$@"
4231
4279
4232 }
4280 }
4233
4281
4234 # :command.function
4282 # :command.function
4235 rcstack_cli_docker_info_command() {
4283 rcstack_cli_docker_info_command() {
4236 # src/cli_docker_info_command.sh
4284 # src/cli_docker_info_command.sh
4237 verbose=${args[--verbose]}
4285 verbose=${args[--verbose]}
4238
4286
4239 docker --version
4287 docker --version
4240 docker compose version
4288 docker compose version
4241
4289
4242 if [[ $verbose ]]; then
4290 if [[ $verbose ]]; then
4243 echo "-- DETAILED DOCKER INFO --"
4291 echo "-- DETAILED DOCKER INFO --"
4244 docker version
4292 docker version
4245 fi
4293 fi
4246
4294
4247 }
4295 }
4248
4296
4249 # :command.function
4297 # :command.function
4250 rcstack_cli_docker_upgrade_command() {
4298 rcstack_cli_docker_upgrade_command() {
4251 # src/cli_docker_upgrade_command.sh
4299 # src/cli_docker_upgrade_command.sh
4252 DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
4300 DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
4253 DOCKER_CLI_PLUGINS=$DOCKER_CONFIG/cli-plugins
4301 DOCKER_CLI_PLUGINS=$DOCKER_CONFIG/cli-plugins
4254 upgrade_compose=${args[--compose]}
4302 upgrade_compose=${args[--compose]}
4255
4303
4256 compose_script_name="install-docker.sh"
4304 compose_script_name="install-docker.sh"
4257
4305
4258 curl -fsSL https://get.docker.com -o "$compose_script_name"
4306 curl -fsSL https://get.docker.com -o "$compose_script_name"
4259 # sh install-docker.sh --version 23.0
4307 # sh install-docker.sh --version 23.0
4260 sh "$compose_script_name"
4308 sh "$compose_script_name"
4261 rm -rf "$compose_script_name"
4309 rm -rf "$compose_script_name"
4262
4310
4263 if [[ $upgrade_compose ]]; then
4311 if [[ $upgrade_compose ]]; then
4264
4312
4265 os_type=$(check_os)
4313 os_type=$(check_os)
4266 if [ "$os_type" != "Linux" ]; then
4314 if [ "$os_type" != "Linux" ]; then
4267 echo "$(red compose upgrade is only available for Linux architecture, got \'$os_type\' instead)"
4315 echo "$(red compose upgrade is only available for Linux architecture, got \'$os_type\' instead)"
4268 exit
4316 exit
4269 fi
4317 fi
4270
4318
4271 # just ensure we have this dir
4319 # just ensure we have this dir
4272 mkdir -p "$DOCKER_CLI_PLUGINS"
4320 mkdir -p "$DOCKER_CLI_PLUGINS"
4273
4321
4274 if [[ -f "$DOCKER_CLI_PLUGINS/docker-compose" ]]; then
4322 if [[ -f "$DOCKER_CLI_PLUGINS/docker-compose" ]]; then
4275 echo "found docker-compose at $DOCKER_CLI_PLUGINS, removing it now..."
4323 echo "found docker-compose at $DOCKER_CLI_PLUGINS, removing it now..."
4276 rm -rf "$DOCKER_CLI_PLUGINS/docker-compose"
4324 rm -rf "$DOCKER_CLI_PLUGINS/docker-compose"
4277 fi
4325 fi
4278
4326
4279 NEW_COMPOSE_VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | grep -Po '"tag_name": "\K.*\d')
4327 NEW_COMPOSE_VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | grep -Po '"tag_name": "\K.*\d')
4280 echo "new compose version $NEW_COMPOSE_VERSION to be installed in $DOCKER_CLI_PLUGINS"
4328 echo "new compose version $NEW_COMPOSE_VERSION to be installed in $DOCKER_CLI_PLUGINS"
4281 curl -fsSL https://github.com/docker/compose/releases/download/$NEW_COMPOSE_VERSION/docker-compose-linux-x86_64 -o $DOCKER_CLI_PLUGINS/docker-compose
4329 curl -fsSL https://github.com/docker/compose/releases/download/$NEW_COMPOSE_VERSION/docker-compose-linux-x86_64 -o $DOCKER_CLI_PLUGINS/docker-compose
4282 chmod +x $DOCKER_CLI_PLUGINS/docker-compose
4330 chmod +x $DOCKER_CLI_PLUGINS/docker-compose
4283 echo "updated compose to $NEW_COMPOSE_VERSION"
4331 echo "updated compose to $NEW_COMPOSE_VERSION"
4284 fi
4332 fi
4285
4333
4286 }
4334 }
4287
4335
4288 # :command.function
4336 # :command.function
4289 rcstack_cli_redis_command() {
4337 rcstack_cli_redis_command() {
4290 # src/cli_redis_command.sh
4338 # src/cli_redis_command.sh
4291 check_bootstrap
4339 check_bootstrap
4292
4340
4293 if [[ -z ${args['--user']} ]]; then
4341 if [[ -z ${args['--user']} ]]; then
4294 # set default, user if the flag is not used
4342 # set default, user if the flag is not used
4295 args['--user']='root'
4343 args['--user']='root'
4296 fi
4344 fi
4297
4345
4298 DEBUG=${args[--debug]}
4346 DEBUG=${args[--debug]}
4299 RUN_WITHOUT_TTY=${args[--no-tty]}
4347 RUN_WITHOUT_TTY=${args[--no-tty]}
4300 ENV_FILE=${args[--env-file-path]}
4348 ENV_FILE=${args[--env-file-path]}
4301 EXEC_USER=${args[--user]}
4349 EXEC_USER=${args[--user]}
4302 db_num=${args[--db]}
4350 db_num=${args[--db]}
4303
4351
4304 INTERACTIVE_FLAGS="--interactive --tty"
4352 INTERACTIVE_FLAGS="--interactive --tty"
4305 if [[ $RUN_WITHOUT_TTY ]]; then
4353 if [[ $RUN_WITHOUT_TTY ]]; then
4306 INTERACTIVE_FLAGS="--interactive"
4354 INTERACTIVE_FLAGS="--interactive"
4307 fi
4355 fi
4308
4356
4309 proj_name=rc_cluster_services
4357 proj_name=rc_cluster_services
4310 instance_type=redis
4358 instance_type=redis
4311
4359
4312 docker_id=$(docker ps --filter name=$proj_name-$instance_type -q | head -n1)
4360 docker_id=$(docker ps --filter name=$proj_name-$instance_type -q | head -n1)
4313 if [[ $docker_id == "" ]]; then
4361 if [[ $docker_id == "" ]]; then
4314 echo "$(yellow cannot find docker instance \($proj_name-$instance_type\) for command execution. Please make sure it is running.)"
4362 echo "$(yellow cannot find docker instance \($proj_name-$instance_type\) for command execution. Please make sure it is running.)"
4315 exit 1
4363 exit 1
4316 fi
4364 fi
4317
4365
4318 index_num=$(docker inspect "$docker_id" --format '{{ index .Config.Labels "com.docker.compose.container-number" }}')
4366 index_num=$(docker inspect "$docker_id" --format '{{ index .Config.Labels "com.docker.compose.container-number" }}')
4319 if [[ -z "$index_num" ]]
4367 if [[ -z "$index_num" ]]
4320 then
4368 then
4321 index_num="0"
4369 index_num="0"
4322 fi
4370 fi
4323
4371
4324 RC_STACK_PROFILES="--profile database --profile redis --profile elasticsearch --profile channelstream"
4372 RC_STACK_PROFILES="--profile database --profile redis --profile elasticsearch --profile channelstream"
4325
4373
4326 CMD_EXEC="\
4374 CMD_EXEC="\
4327 RC_ENV_FILE=$ENV_FILE docker compose \
4375 RC_ENV_FILE=$ENV_FILE docker compose \
4328 --env-file $ENV_FILE \
4376 --env-file $ENV_FILE \
4329 $ENV_EXPAND \
4377 $ENV_EXPAND \
4330 $RC_STACK_PROFILES \
4378 $RC_STACK_PROFILES \
4331 --project-name $proj_name \
4379 --project-name $proj_name \
4332 -f docker-compose-base.yaml \
4380 -f docker-compose-base.yaml \
4333 -f docker-compose-services.yaml \
4381 -f docker-compose-services.yaml \
4334 exec \
4382 exec \
4335 --user $EXEC_USER \
4383 --user $EXEC_USER \
4336 $INTERACTIVE_FLAGS \
4384 $INTERACTIVE_FLAGS \
4337 $instance_type \
4385 $instance_type \
4338 /bin/bash -c 'redis-cli -n $db_num'"
4386 /bin/bash -c 'redis-cli -n $db_num'"
4339
4387
4340 if [[ $DEBUG ]]; then
4388 if [[ $DEBUG ]]; then
4341 echo $CMD_EXEC
4389 echo $CMD_EXEC
4342 echo ${other_args[*]}
4390 echo ${other_args[*]}
4343 fi
4391 fi
4344
4392
4345 eval "${CMD_EXEC}"
4393 eval "${CMD_EXEC}"
4346
4394
4347 }
4395 }
4348
4396
4349 # :command.function
4397 # :command.function
4350 rcstack_cli_db_command() {
4398 rcstack_cli_db_command() {
4351 # src/cli_db_command.sh
4399 # src/cli_db_command.sh
4352 check_bootstrap
4400 check_bootstrap
4353
4401
4354 if [[ -z ${args['--user']} ]]; then
4402 if [[ -z ${args['--user']} ]]; then
4355 # set default, user if the flag is not used
4403 # set default, user if the flag is not used
4356 args['--user']='root'
4404 args['--user']='root'
4357 fi
4405 fi
4358
4406
4359 DEBUG=${args[--debug]}
4407 DEBUG=${args[--debug]}
4360 RUN_WITHOUT_TTY=${args[--no-tty]}
4408 RUN_WITHOUT_TTY=${args[--no-tty]}
4361 ENV_FILE=${args[--env-file-path]}
4409 ENV_FILE=${args[--env-file-path]}
4362 EXEC_USER=${args[--user]}
4410 EXEC_USER=${args[--user]}
4363
4411
4364 INTERACTIVE_FLAGS="--interactive --tty"
4412 INTERACTIVE_FLAGS="--interactive --tty"
4365 if [[ $RUN_WITHOUT_TTY ]]; then
4413 if [[ $RUN_WITHOUT_TTY ]]; then
4366 INTERACTIVE_FLAGS="--interactive"
4414 INTERACTIVE_FLAGS="--interactive"
4367 fi
4415 fi
4368
4416
4369 .env --file $ENV_FILE
4417 .env --file $ENV_FILE
4370
4418
4371 .env get_or_error DB_TYPE
4419 .env get_or_error DB_TYPE
4372 DB_TYPE=$REPLY
4420 DB_TYPE=$REPLY
4373
4421
4374 .env get_or_error DB_PASSWORD
4422 .env get_or_error DB_PASSWORD
4375 DB_PASSWORD=$REPLY
4423 DB_PASSWORD=$REPLY
4376
4424
4377 .env get_or_error DB_NAME
4425 .env get_or_error DB_NAME
4378 DB_NAME=$REPLY
4426 DB_NAME=$REPLY
4379
4427
4380 .env get_or_error DB_USER
4428 .env get_or_error DB_USER
4381 DB_USER=$REPLY
4429 DB_USER=$REPLY
4382
4430
4383 proj_name=rc_cluster_services
4431 proj_name=rc_cluster_services
4384
4432
4385 if [[ $DB_TYPE == "postgres" ]]; then
4433 if [[ $DB_TYPE == "postgres" ]]; then
4386 instance_type=database
4434 instance_type=database
4387 DB_CMD="PGPASSWORD=$DB_PASSWORD psql --username=$DB_USER --dbname=$DB_NAME"
4435 DB_CMD="PGPASSWORD=$DB_PASSWORD psql --username=$DB_USER --dbname=$DB_NAME"
4388 elif [[ $DB_TYPE == "mysql" ]]; then
4436 elif [[ $DB_TYPE == "mysql" ]]; then
4389 instance_type=database-mysql
4437 instance_type=database-mysql
4390 DB_CMD="mysql --user=$DB_USER --password=$DB_PASSWORD $DB_NAME"
4438 DB_CMD="mysql --user=$DB_USER --password=$DB_PASSWORD $DB_NAME"
4391
4439
4392 else
4440 else
4393 echo "$(red no database type selected via DB_TYPE var)"
4441 echo "$(red no database type selected via DB_TYPE var)"
4394 exit 1
4442 exit 1
4395 fi
4443 fi
4396
4444
4397 docker_id=$(docker ps --filter name=$proj_name-$instance_type -q | head -n1)
4445 docker_id=$(docker ps --filter name=$proj_name-$instance_type -q | head -n1)
4398 if [[ $docker_id == "" ]]; then
4446 if [[ $docker_id == "" ]]; then
4399 echo "$(yellow cannot find docker instance \($proj_name-$instance_type\) for command execution. Please make sure it is running.)"
4447 echo "$(yellow cannot find docker instance \($proj_name-$instance_type\) for command execution. Please make sure it is running.)"
4400 exit 1
4448 exit 1
4401 fi
4449 fi
4402
4450
4403 index_num=$(docker inspect "$docker_id" --format '{{ index .Config.Labels "com.docker.compose.container-number" }}')
4451 index_num=$(docker inspect "$docker_id" --format '{{ index .Config.Labels "com.docker.compose.container-number" }}')
4404 if [[ -z "$index_num" ]]
4452 if [[ -z "$index_num" ]]
4405 then
4453 then
4406 index_num="0"
4454 index_num="0"
4407 fi
4455 fi
4408
4456
4409 RC_STACK_PROFILES="--profile database --profile redis --profile elasticsearch --profile channelstream"
4457 RC_STACK_PROFILES="--profile database --profile redis --profile elasticsearch --profile channelstream"
4410
4458
4411 CMD_EXEC="\
4459 CMD_EXEC="\
4412 RC_ENV_FILE=$ENV_FILE docker compose \
4460 RC_ENV_FILE=$ENV_FILE docker compose \
4413 --env-file $ENV_FILE \
4461 --env-file $ENV_FILE \
4414 $ENV_EXPAND \
4462 $ENV_EXPAND \
4415 $RC_STACK_PROFILES \
4463 $RC_STACK_PROFILES \
4416 --project-name $proj_name \
4464 --project-name $proj_name \
4417 -f docker-compose-base.yaml \
4465 -f docker-compose-base.yaml \
4418 -f docker-compose-services.yaml \
4466 -f docker-compose-services.yaml \
4419 exec \
4467 exec \
4420 --user $EXEC_USER \
4468 --user $EXEC_USER \
4421 $INTERACTIVE_FLAGS \
4469 $INTERACTIVE_FLAGS \
4422 $instance_type \
4470 $instance_type \
4423 /bin/bash -c '$DB_CMD'"
4471 /bin/bash -c '$DB_CMD'"
4424
4472
4425 if [[ $DEBUG ]]; then
4473 if [[ $DEBUG ]]; then
4426 echo $CMD_EXEC
4474 echo $CMD_EXEC
4427 echo ${other_args[*]}
4475 echo ${other_args[*]}
4428 fi
4476 fi
4429
4477
4430 if [[ $DB_TYPE == "postgres" ]]; then
4478 if [[ $DB_TYPE == "postgres" ]]; then
4431 printf "*Volumes*:\n"
4479 printf "*Volumes*:\n"
4432 printf " attaching pg_data under: /var/lib/postgresql/data\n"
4480 printf " attaching pg_data under: /var/lib/postgresql/data\n"
4433 printf " attaching \$PWD/.custom/db_dump under: /var/rc-data-dump\n"
4481 printf " attaching \$PWD/.custom/db_dump under: /var/rc-data-dump\n"
4434 printf "\n"
4482 printf "\n"
4435 printf "*Restore dump*:\n"
4483 printf "*Restore dump*:\n"
4436 printf " \i /var/rc-data-dump/your_dump.sql\n"
4484 printf " \i /var/rc-data-dump/your_dump.sql\n"
4437 printf "\n"
4485 printf "\n"
4438 elif [[ $DB_TYPE == "mysql" ]]; then
4486 elif [[ $DB_TYPE == "mysql" ]]; then
4439 printf "*Volumes*:\n"
4487 printf "*Volumes*:\n"
4440 printf " attaching mysql_data under: /var/lib/mysql\n"
4488 printf " attaching mysql_data under: /var/lib/mysql\n"
4441 printf " attaching \$PWD/.custom/db_dump under: /var/rc-data-dump\n"
4489 printf " attaching \$PWD/.custom/db_dump under: /var/rc-data-dump\n"
4442 printf "\n"
4490 printf "\n"
4443 fi
4491 fi
4444
4492
4445 eval "${CMD_EXEC}"
4493 eval "${CMD_EXEC}"
4446
4494
4447 }
4495 }
4448
4496
4449 # :command.function
4497 # :command.function
4450 rcstack_cli_db_upgrade_command() {
4498 rcstack_cli_db_upgrade_command() {
4451 # src/cli_db_upgrade_command.sh
4499 # src/cli_db_upgrade_command.sh
4452 check_bootstrap
4500 check_bootstrap
4453
4501
4454 DEBUG=${args[--debug]}
4502 DEBUG=${args[--debug]}
4455
4503
4456 target_container=rc_cluster_services-database-*
4504 target_container=rc_cluster_services-database-*
4457 docker_id=$(docker ps --filter name=$target_container -q | head -n1)
4505 docker_id=$(docker ps --filter name=$target_container -q | head -n1)
4458
4506
4459 if [[ $DEBUG ]]; then
4507 if [[ $DEBUG ]]; then
4460 echo "container id: $docker_id, based on $target_container filter"
4508 echo "container id: $docker_id, based on $target_container filter"
4461 docker ps
4509 docker ps
4462 fi
4510 fi
4463
4511
4464 if [ "$docker_id" == "" ]; then
4512 if [ "$docker_id" == "" ]; then
4465 MSG="Cannot find container ID with name $target_container"
4513 MSG="Cannot find container ID with name $target_container"
4466 echo "$(red $MSG)"
4514 echo "$(red $MSG)"
4467 exit 1
4515 exit 1
4468 fi
4516 fi
4469
4517
4470 if [[ $DEBUG ]]; then
4518 if [[ $DEBUG ]]; then
4471 echo "./$RC_SCRIPT_NAME stack rhodecode exec rhodecode /usr/local/bin/rhodecode_bin/bin/rc-upgrade-db /etc/rhodecode/conf/rhodecode.ini --force-yes"
4519 echo "./$RC_SCRIPT_NAME stack rhodecode exec rhodecode /usr/local/bin/rhodecode_bin/bin/rc-upgrade-db /etc/rhodecode/conf/rhodecode.ini --force-yes"
4472 fi
4520 fi
4473
4521
4474 ./$RC_SCRIPT_NAME stack rhodecode exec rhodecode /usr/local/bin/rhodecode_bin/bin/rc-upgrade-db /etc/rhodecode/conf/rhodecode.ini --force-yes
4522 ./$RC_SCRIPT_NAME stack rhodecode exec rhodecode /usr/local/bin/rhodecode_bin/bin/rc-upgrade-db /etc/rhodecode/conf/rhodecode.ini --force-yes
4475 }
4523 }
4476
4524
4477 # :command.function
4525 # :command.function
4478 rcstack_cli_storage_command() {
4526 rcstack_cli_storage_command() {
4479 # src/cli_storage_command.sh
4527 # src/cli_storage_command.sh
4480 check_bootstrap
4528 check_bootstrap
4481
4529
4482 DEBUG=${args[--debug]}
4530 DEBUG=${args[--debug]}
4483 RUN_WITHOUT_TTY=${args[--no-tty]}
4531 RUN_WITHOUT_TTY=${args[--no-tty]}
4484 INTERACTIVE_FLAGS="--interactive --tty"
4532 INTERACTIVE_FLAGS="--interactive --tty"
4485 if [[ $RUN_WITHOUT_TTY ]]; then
4533 if [[ $RUN_WITHOUT_TTY ]]; then
4486 INTERACTIVE_FLAGS="--interactive"
4534 INTERACTIVE_FLAGS="--interactive"
4487 fi
4535 fi
4488
4536
4489 ENV_FILE=${args[--env-file-path]}
4537 ENV_FILE=${args[--env-file-path]}
4490 ATTACHED=${args[--attached]}
4538 ATTACHED=${args[--attached]}
4491
4539
4492 if [[ $DEBUG ]]; then
4540 if [[ $DEBUG ]]; then
4493 echo "rc_datavolume inspection..."
4541 echo "rc_datavolume inspection..."
4494 docker volume inspect rc_datavolume
4542 docker volume inspect rc_datavolume
4495
4543
4496 echo "rc_reposvolume inspection..."
4544 echo "rc_reposvolume inspection..."
4497 docker volume inspect rc_reposvolume
4545 docker volume inspect rc_reposvolume
4498 fi
4546 fi
4499
4547
4500 #
4548 #
4501 #if [[ $DEBUG ]]; then
4549 #if [[ $DEBUG ]]; then
4502 # echo "image id: $image_id, based on $target_container filter"
4550 # echo "image id: $image_id, based on $target_container filter"
4503 # docker image ls
4551 # docker image ls
4504 # echo "---"
4552 # echo "---"
4505 #fi
4553 #fi
4506 # rename a volume
4554 # rename a volume
4507 #docker volume create --name <new_volume>
4555 #docker volume create --name <new_volume>
4508 #docker run --rm -it -v <old_volume>:/from -v <new_volume>:/to alpine ash -c "cd /from ; cp -av . /to"
4556 #docker run --rm -it -v <old_volume>:/from -v <new_volume>:/to alpine ash -c "cd /from ; cp -av . /to"
4509 #docker volume rm <old_volume>
4557 #docker volume rm <old_volume>
4510
4558
4511 if [[ $ATTACHED ]]; then
4559 if [[ $ATTACHED ]]; then
4512 printf "Starting with attached mode to vcsserver !"
4560 printf "Starting with attached mode to vcsserver !"
4513 printf "present rc_datavolume \t\tunder: /var/opt/rhodecode_data\n"
4561 printf "present rc_datavolume \t\tunder: /var/opt/rhodecode_data\n"
4514 printf "present rc_reposvolume \t\tunder: /var/opt/rhodecode_repo_store\n"
4562 printf "present rc_reposvolume \t\tunder: /var/opt/rhodecode_repo_store\n"
4515 printf "present confvolume \t\tunder: /etc/rhodecode/conf\n"
4563 printf "present confvolume \t\tunder: /etc/rhodecode/conf\n"
4516
4564
4517 match_name=rc_cluster_apps-vcsserver
4565 match_name=rc_cluster_apps-vcsserver
4518
4566
4519 docker_id=$(docker ps --filter name=$match_name -q | head -n1)
4567 docker_id=$(docker ps --filter name=$match_name -q | head -n1)
4520 if [[ $docker_id == "" ]]; then
4568 if [[ $docker_id == "" ]]; then
4521 echo "$(yellow cannot find instance to attach by name *$match_name*)"
4569 echo "$(yellow cannot find instance to attach by name *$match_name*)"
4522 exit 1
4570 exit 1
4523 fi
4571 fi
4524
4572
4525 docker exec \
4573 docker exec \
4526 $INTERACTIVE_FLAGS \
4574 $INTERACTIVE_FLAGS \
4527 --workdir /var/opt $docker_id bash
4575 --workdir /var/opt $docker_id bash
4528
4576
4529 else
4577 else
4530 printf "attaching rc_datavolume \t\tunder: /vol/datavolume\n"
4578 printf "attaching rc_datavolume \t\tunder: /vol/datavolume\n"
4531 printf "attaching rc_reposvolume \t\tunder: /vol/repovolume\n"
4579 printf "attaching rc_reposvolume \t\tunder: /vol/repovolume\n"
4532 printf "attaching \$PWD/.custom/storage \t\tunder: /vol/backupvolume\n"
4580 printf "attaching \$PWD/.custom/storage \t\tunder: /vol/backupvolume\n"
4533
4581
4534 docker run --rm \
4582 docker run --rm \
4535 $INTERACTIVE_FLAGS \
4583 $INTERACTIVE_FLAGS \
4536 --volume $PWD/.custom/storage:/vol/backupvolume \
4584 --volume $PWD/.custom/storage:/vol/backupvolume \
4537 --volume rc_datavolume:/vol/datavolume \
4585 --volume rc_datavolume:/vol/datavolume \
4538 --volume rc_reposvolume:/vol/repovolume \
4586 --volume rc_reposvolume:/vol/repovolume \
4539 --workdir="/vol" \
4587 --workdir="/vol" \
4540 $BASE_OPS_IMAGE \
4588 $BASE_OPS_IMAGE \
4541 /bin/bash
4589 /bin/bash
4542 fi
4590 fi
4543
4591
4544 }
4592 }
4545
4593
4546 # :command.function
4594 # :command.function
4547 rcstack_cli_attach_command() {
4595 rcstack_cli_attach_command() {
4548 # src/cli_attach_command.sh
4596 # src/cli_attach_command.sh
4549 check_bootstrap
4597 check_bootstrap
4550 RUN_WITHOUT_TTY=${args[--no-tty]}
4598 RUN_WITHOUT_TTY=${args[--no-tty]}
4551 INTERACTIVE_FLAGS="--interactive --tty"
4599 INTERACTIVE_FLAGS="--interactive --tty"
4552 if [[ $RUN_WITHOUT_TTY ]]; then
4600 if [[ $RUN_WITHOUT_TTY ]]; then
4553 INTERACTIVE_FLAGS="--interactive"
4601 INTERACTIVE_FLAGS="--interactive"
4554 fi
4602 fi
4555
4603
4556 instance_type=${args[--instance-type]}
4604 instance_type=${args[--instance-type]}
4557
4605
4558 match_name=rc_cluster_apps-$instance_type
4606 match_name=rc_cluster_apps-$instance_type
4559
4607
4560 docker_id=$(docker ps --filter name=$match_name -q | head -n1)
4608 docker_id=$(docker ps --filter name=$match_name -q | head -n1)
4561 if [[ $docker_id == "" ]]; then
4609 if [[ $docker_id == "" ]]; then
4562 echo "$(yellow cannot find instance to attach by name *$match_name*)"
4610 echo "$(yellow cannot find instance to attach by name *$match_name*)"
4563 exit 1
4611 exit 1
4564 fi
4612 fi
4565
4613
4566 docker exec \
4614 docker exec \
4567 $INTERACTIVE_FLAGS \
4615 $INTERACTIVE_FLAGS \
4568 $docker_id bash
4616 $docker_id bash
4569
4617
4570 }
4618 }
4571
4619
4572 # :command.function
4620 # :command.function
4573 rcstack_cli_set_edition_command() {
4621 rcstack_cli_set_edition_command() {
4574 # src/cli_set_edition_command.sh
4622 # src/cli_set_edition_command.sh
4575 INI_TARGET=$PWD/config/_shared
4623 INI_TARGET=$PWD/config/_shared
4576 BOOTSTRAP_RUNTIME_ENV=$PWD/.custom/.runtime.env
4624 BOOTSTRAP_RUNTIME_ENV=$PWD/.custom/.runtime.env
4577
4625
4578 RC_EDITION=${args[edition_type]}
4626 RC_EDITION=${args[edition_type]}
4579 ini_path=$INI_TARGET/rhodecode.ini
4627 ini_path=$INI_TARGET/rhodecode.ini
4580 DEBUG=${args[--debug]}
4628 DEBUG=${args[--debug]}
4581
4629
4582 echo "set-edition: setting current installation as rhodecode-$RC_EDITION type"
4630 echo "set-edition: setting current installation as rhodecode-$RC_EDITION type"
4583
4631
4584 echo "set-edition: configure $ini_path"
4632 echo "set-edition: configure $ini_path"
4585 sed_replace '^use = egg:rhodecode-enterprise.*' "use = egg:rhodecode-enterprise-$RC_EDITION"
4633 sed_replace '^use = egg:rhodecode-enterprise.*' "use = egg:rhodecode-enterprise-$RC_EDITION"
4586 echo "set-edition: configure $BOOTSTRAP_RUNTIME_ENV"
4634 echo "set-edition: configure $BOOTSTRAP_RUNTIME_ENV"
4587 .env --file "$BOOTSTRAP_RUNTIME_ENV"
4635 .env --file "$BOOTSTRAP_RUNTIME_ENV"
4588 .env set RC_EDITION=$RC_EDITION
4636 .env set RC_EDITION=$RC_EDITION
4589
4637
4590 echo "set-edition: configuration done, run "
4638 echo "set-edition: configuration done, run "
4591 echo "./$RC_SCRIPT_NAME stack-upgrade rhodecode"
4639 echo "./$RC_SCRIPT_NAME stack-upgrade rhodecode"
4592
4640
4593 }
4641 }
4594
4642
4595 # :command.function
4643 # :command.function
4596 rcstack_cli_configure_vcsserver_command() {
4644 rcstack_cli_configure_vcsserver_command() {
4597 # src/cli_configure_vcsserver_command.sh
4645 # src/cli_configure_vcsserver_command.sh
4598 ini_path=${args[ini_path]}
4646 ini_path=${args[ini_path]}
4599 DEBUG=${args[--debug]}
4647 DEBUG=${args[--debug]}
4600
4648
4601 config_vcsserver_ini
4649 config_vcsserver_ini
4602
4650
4603 echo
4651 echo
4604 echo "reconfigure of $ini_path completed"
4652 echo "reconfigure of $ini_path completed"
4605
4653
4606 }
4654 }
4607
4655
4608 # :command.function
4656 # :command.function
4609 rcstack_cli_configure_rhodecode_command() {
4657 rcstack_cli_configure_rhodecode_command() {
4610 # src/cli_configure_rhodecode_command.sh
4658 # src/cli_configure_rhodecode_command.sh
4611 ini_path=${args[ini_path]}
4659 ini_path=${args[ini_path]}
4612 DEBUG=${args[--debug]}
4660 DEBUG=${args[--debug]}
4613
4661
4614 # read generated secrets etc from our .env file
4662 # read generated secrets etc from our .env file
4615 .env --file $RUNTIME_ENV
4663 .env --file $RUNTIME_ENV
4616
4664
4617 .env get RC_LICENSE_TOKEN
4665 .env get RC_LICENSE_TOKEN
4618 RC_LICENSE_TOKEN=$REPLY
4666 RC_LICENSE_TOKEN=$REPLY
4619
4667
4620 .env get RC_EDITION
4668 .env get RC_EDITION
4621 RC_EDITION=$REPLY
4669 RC_EDITION=$REPLY
4622
4670
4623 .env get RC_SHARED_KEY
4671 .env get RC_SHARED_KEY
4624 RC_SHARED_KEY=$REPLY
4672 RC_SHARED_KEY=$REPLY
4625
4673
4626 .env get RC_HOSTNAME
4674 .env get RC_HOSTNAME
4627 RC_HOSTNAME=$(sed_safe_path $REPLY)
4675 RC_HOSTNAME=$(sed_safe_path $REPLY)
4628
4676
4629 .env get RC_APP_BASE_URL
4677 .env get RC_APP_BASE_URL
4630 RC_APP_BASE_URL=$(sed_safe_path $REPLY)
4678 RC_APP_BASE_URL=$(sed_safe_path $REPLY)
4631
4679
4632 .env get RC_SQLALCHEMY_DB1_URL
4680 .env get RC_SQLALCHEMY_DB1_URL
4633 RC_SQLALCHEMY_DB1_URL=$(sed_safe_path $REPLY)
4681 RC_SQLALCHEMY_DB1_URL=$(sed_safe_path $REPLY)
4634
4682
4635 .env get RC_CHANNELSTREAM_WS_URL
4683 .env get RC_CHANNELSTREAM_WS_URL
4636 RC_CHANNELSTREAM_WS_URL=$(sed_safe_path $REPLY)
4684 RC_CHANNELSTREAM_WS_URL=$(sed_safe_path $REPLY)
4637
4685
4638 # $ini_path needs to be defined!
4686 # $ini_path needs to be defined!
4639 config_rhodecode_ini
4687 config_rhodecode_ini
4640
4688
4641 echo
4689 echo
4642 echo "reconfigure of $ini_path completed"
4690 echo "reconfigure of $ini_path completed"
4643 }
4691 }
4644
4692
4645 # :command.function
4693 # :command.function
4646 rcstack_backup_db_command() {
4694 rcstack_backup_db_command() {
4647 # src/backup_db_command.sh
4695 # src/backup_db_command.sh
4648 check_bootstrap
4696 check_bootstrap
4649
4697
4650 DEBUG=${args[--debug]}
4698 DEBUG=${args[--debug]}
4651 DESTINATION=${args[destination]}
4699 DESTINATION=${args[destination]}
4652
4700
4653 backup_date=$(date +%Y-%m-%d)
4701 backup_date=$(date +%Y-%m-%d)
4654 backup_name_prefix=rc_db_dump
4702 backup_name_prefix=rc_db_dump
4655
4703
4656 echo "$(green_bold Creating backup of rcstack database)"
4704 echo "$(green_bold Creating backup of rcstack database)"
4657
4705
4658 .env --file $RUNTIME_ENV
4706 .env --file $RUNTIME_ENV
4659
4707
4660 .env get_or_error DB_TYPE
4708 .env get_or_error DB_TYPE
4661 DB_TYPE=$REPLY
4709 DB_TYPE=$REPLY
4662
4710
4663 .env get_or_error DB_PASSWORD
4711 .env get_or_error DB_PASSWORD
4664 DB_PASSWORD=$REPLY
4712 DB_PASSWORD=$REPLY
4665
4713
4666 .env get_or_error DB_NAME
4714 .env get_or_error DB_NAME
4667 DB_NAME=$REPLY
4715 DB_NAME=$REPLY
4668
4716
4669 .env get_or_error DB_USER
4717 .env get_or_error DB_USER
4670 DB_USER=$REPLY
4718 DB_USER=$REPLY
4671
4719
4672 proj_name=rc_cluster_services
4720 proj_name=rc_cluster_services
4673
4721
4674 if [[ $DB_TYPE == "postgres" ]]; then
4722 if [[ $DB_TYPE == "postgres" ]]; then
4675 instance_type=database
4723 instance_type=database
4676 DB_CMD="PGPASSWORD=$DB_PASSWORD psql --username=$DB_USER --dbname=$DB_NAME"
4724 DB_CMD="PGPASSWORD=$DB_PASSWORD psql --username=$DB_USER --dbname=$DB_NAME"
4677 elif [[ $DB_TYPE == "mysql" ]]; then
4725 elif [[ $DB_TYPE == "mysql" ]]; then
4678 instance_type=database-mysql
4726 instance_type=database-mysql
4679 DB_CMD="mysql --user=$DB_USER --password=$DB_PASSWORD $DB_NAME"
4727 DB_CMD="mysql --user=$DB_USER --password=$DB_PASSWORD $DB_NAME"
4680
4728
4681 else
4729 else
4682 echo "$(red no database type selected via DB_TYPE var)"
4730 echo "$(red no database type selected via DB_TYPE var)"
4683 exit 1
4731 exit 1
4684 fi
4732 fi
4685
4733
4686 docker_id=$(docker ps --filter name=$proj_name-$instance_type-1 -q | head -n1)
4734 docker_id=$(docker ps --filter name=$proj_name-$instance_type-1 -q | head -n1)
4687 if [[ $docker_id == "" ]]; then
4735 if [[ $docker_id == "" ]]; then
4688 echo "$(yellow cannot find docker instance \($proj_name-$instance_type\) for command execution. Please make sure it is running.)"
4736 echo "$(yellow cannot find docker instance \($proj_name-$instance_type\) for command execution. Please make sure it is running.)"
4689 exit 1
4737 exit 1
4690 fi
4738 fi
4691
4739
4692 index_num=$(docker inspect "$docker_id" --format '{{ index .Config.Labels "com.docker.compose.container-number" }}')
4740 index_num=$(docker inspect "$docker_id" --format '{{ index .Config.Labels "com.docker.compose.container-number" }}')
4693 if [[ -z "$index_num" ]]
4741 if [[ -z "$index_num" ]]
4694 then
4742 then
4695 index_num="0"
4743 index_num="0"
4696 fi
4744 fi
4697
4745
4698 destination_dir=$DESTINATION
4746 destination_dir=$DESTINATION
4699 spacer="_"
4747 spacer="_"
4700 backup_name="$backup_name_prefix$spacer$backup_date.sql.gz"
4748 backup_name="$backup_name_prefix$spacer$backup_date.sql.gz"
4701
4749
4702 set -euo pipefail
4750 set -euo pipefail
4703
4751
4704 if [[ $DB_TYPE == "postgres" ]]; then
4752 if [[ $DB_TYPE == "postgres" ]]; then
4705 BACKUP_CMD="pg_dump --inserts -U $DB_USER -h 127.0.0.1 --dbname=$DB_NAME | gzip > /var/rc-data-dump/$backup_name"
4753 BACKUP_CMD="pg_dump --inserts -U $DB_USER -h 127.0.0.1 --dbname=$DB_NAME | gzip > /var/rc-data-dump/$backup_name"
4706
4754
4707 if [[ $DEBUG ]]; then
4755 if [[ $DEBUG ]]; then
4708 echo "docker-instance: $docker_id"
4756 echo "docker-instance: $docker_id"
4709 echo "docker exec -e $BACKUP_CMD"
4757 echo "docker exec -e $BACKUP_CMD"
4710 echo "dump placed in /var/rc-data-dump/$backup_name"
4758 echo "dump placed in /var/rc-data-dump/$backup_name"
4711 echo "run docker cp $docker_id:/var/rc-data-dump/$backup_name $PWD to copy the file into your host machine"
4759 echo "run docker cp $docker_id:/var/rc-data-dump/$backup_name $PWD to copy the file into your host machine"
4712 fi
4760 fi
4713 docker exec -e PGPASSWORD=$DB_PASSWORD $docker_id /bin/bash -c "$BACKUP_CMD"
4761 docker exec -e PGPASSWORD=$DB_PASSWORD $docker_id /bin/bash -c "$BACKUP_CMD"
4714
4762
4715 elif [[ $DB_TYPE == "mysql" ]]; then
4763 elif [[ $DB_TYPE == "mysql" ]]; then
4716 BACKUP_CMD="mysqldump --user=$DB_USER --password=$DB_PASSWORD --host=localhost $DB_NAME | gzip > /var/rc-data-dump/$backup_name"
4764 BACKUP_CMD="mysqldump --user=$DB_USER --password=$DB_PASSWORD --host=localhost $DB_NAME | gzip > /var/rc-data-dump/$backup_name"
4717
4765
4718 if [[ $DEBUG ]]; then
4766 if [[ $DEBUG ]]; then
4719 echo "docker-instance: $docker_id"
4767 echo "docker-instance: $docker_id"
4720 echo "docker exec -e $BACKUP_CMD"
4768 echo "docker exec -e $BACKUP_CMD"
4721 echo "dump placed in /var/rc-data-dump/$backup_name"
4769 echo "dump placed in /var/rc-data-dump/$backup_name"
4722 echo "run docker cp $docker_id:/var/rc-data-dump/$backup_name $PWD to copy the file into your host machine"
4770 echo "run docker cp $docker_id:/var/rc-data-dump/$backup_name $PWD to copy the file into your host machine"
4723 fi
4771 fi
4724
4772
4725 docker exec $docker_id /bin/bash -c "$BACKUP_CMD"
4773 docker exec $docker_id /bin/bash -c "$BACKUP_CMD"
4726 fi
4774 fi
4727
4775
4728 docker cp $docker_id:/var/rc-data-dump/$backup_name $destination_dir
4776 docker cp $docker_id:/var/rc-data-dump/$backup_name $destination_dir
4729
4777
4730 echo "$(green Backup created in: \'$destination_dir\')"
4778 echo "$(green Backup created in: \'$destination_dir\')"
4731 ls -la $destination_dir | grep $backup_name_prefix
4779 ls -la $destination_dir | grep $backup_name_prefix
4732
4780
4733 }
4781 }
4734
4782
4735 # :command.function
4783 # :command.function
4736 rcstack_backup_data_command() {
4784 rcstack_backup_data_command() {
4737 # src/backup_data_command.sh
4785 # src/backup_data_command.sh
4738 check_bootstrap
4786 check_bootstrap
4739
4787
4740 DEBUG=${args[--debug]}
4788 DEBUG=${args[--debug]}
4741 DESTINATION=${args[destination]}
4789 DESTINATION=${args[destination]}
4742
4790
4743 echo "$(green_bold Creating backup of rcstack volumes)"
4791 echo "$(green_bold Creating backup of rcstack volumes)"
4744
4792
4745 backup_date=$(date +%Y-%m-%d)
4793 backup_date=$(date +%Y-%m-%d)
4746 backup_name_prefix=rc_data_dump
4794 backup_name_prefix=rc_data_dump
4747
4795
4748 target_container=rc_cluster_apps-rhodecode-*
4796 target_container=rc_cluster_apps-rhodecode-*
4749
4797
4750 docker_id=$(docker ps --filter name=$target_container -q | head -n1)
4798 docker_id=$(docker ps --filter name=$target_container -q | head -n1)
4751
4799
4752 if [[ $DEBUG ]]; then
4800 if [[ $DEBUG ]]; then
4753 echo "container id: $docker_id, based on $target_container filter"
4801 echo "container id: $docker_id, based on $target_container filter"
4754 docker ps
4802 docker ps
4755 echo "---"
4803 echo "---"
4756 fi
4804 fi
4757
4805
4758 if [ "$docker_id" == "" ]; then
4806 if [ "$docker_id" == "" ]; then
4759 MSG="Cannot find container ID with name $target_container"
4807 MSG="Cannot find container ID with name $target_container"
4760 echo "$(red $MSG)"
4808 echo "$(red $MSG)"
4761 exit 1
4809 exit 1
4762 fi
4810 fi
4763
4811
4764 set -euo pipefail
4812 set -euo pipefail
4765
4813
4766 echo "$(green_bold Following volumes will be backed-up:)"
4814 echo "$(green_bold Following volumes will be backed-up:)"
4767
4815
4768 volumes=$(docker inspect --format "{{ range .Mounts }}{{ println .Destination }}{{ end }}" $docker_id)
4816 volumes=$(docker inspect --format "{{ range .Mounts }}{{ println .Destination }}{{ end }}" $docker_id)
4769 destination_dir=$DESTINATION
4817 destination_dir=$DESTINATION
4770
4818
4771 spacer="_"
4819 spacer="_"
4772 for vol in $volumes; do
4820 for vol in $volumes; do
4773 echo "Volume: $vol"
4821 echo "Volume: $vol"
4774 vol_name=$(slugify $vol)
4822 vol_name=$(slugify $vol)
4775 backup_slug="$backup_name_prefix$spacer$vol_name$spacer$backup_date"
4823 backup_slug="$backup_name_prefix$spacer$vol_name$spacer$backup_date"
4776
4824
4777 docker run --rm -v $destination_dir:/backup --volumes-from "$docker_id" $BASE_OPS_IMAGE tar -czvf /backup/$backup_slug.tar.gz "$vol"
4825 docker run --rm -v $destination_dir:/backup --volumes-from "$docker_id" $BASE_OPS_IMAGE tar -czvf /backup/$backup_slug.tar.gz "$vol"
4778 done
4826 done
4779
4827
4780 echo "$(green Backup created in: \'$destination_dir\')"
4828 echo "$(green Backup created in: \'$destination_dir\')"
4781 ls -la $destination_dir | grep $backup_name_prefix
4829 ls -la $destination_dir | grep $backup_name_prefix
4782
4830
4783 #docker-volume-restore-compressed() {
4831 #docker-volume-restore-compressed() {
4784 # destination_dir=$1
4832 # destination_dir=$1
4785 # container=$2
4833 # container=$2
4786 #
4834 #
4787 # docker run --rm -v $destination_dir:/backup --volumes-from "$container" debian:jessie tar -xzvf /backup/backup.tar.gz "${@:3}"
4835 # docker run --rm -v $destination_dir:/backup --volumes-from "$container" debian:jessie tar -xzvf /backup/backup.tar.gz "${@:3}"
4788 # echo "Double checking files..."
4836 # echo "Double checking files..."
4789 # docker run --rm -v $destination_dir:/backup --volumes-from "$container" debian:jessie ls -lh "${@:2}"
4837 # docker run --rm -v $destination_dir:/backup --volumes-from "$container" debian:jessie ls -lh "${@:2}"
4790 #}
4838 #}
4791 }
4839 }
4792
4840
4793 # :command.function
4841 # :command.function
4794 rcstack__completions_command() {
4842 rcstack__completions_command() {
4795 # src/_completions_command.sh
4843 # src/_completions_command.sh
4796 send_completions
4844 send_completions
4797 }
4845 }
4798
4846
4799 # :command.parse_requirements
4847 # :command.parse_requirements
4800 parse_requirements() {
4848 parse_requirements() {
4801 # :command.fixed_flags_filter
4849 # :command.fixed_flags_filter
4802 while [[ $# -gt 0 ]]; do
4850 while [[ $# -gt 0 ]]; do
4803 case "${1:-}" in
4851 case "${1:-}" in
4804 --version | -v)
4852 --version | -v)
4805 version_command
4853 version_command
4806 exit
4854 exit
4807 ;;
4855 ;;
4808
4856
4809 --help | -h)
4857 --help | -h)
4810 long_usage=yes
4858 long_usage=yes
4811 rcstack_usage
4859 rcstack_usage
4812 exit
4860 exit
4813 ;;
4861 ;;
4814
4862
4815 # :flag.case
4863 # :flag.case
4816 --debug)
4864 --debug)
4817
4865
4818 # :flag.case_no_arg
4866 # :flag.case_no_arg
4819 args['--debug']=1
4867 args['--debug']=1
4820 shift
4868 shift
4821 ;;
4869 ;;
4822
4870
4823 # :flag.case
4871 # :flag.case
4824 --no-init-check)
4872 --no-init-check)
4825
4873
4826 # :flag.case_no_arg
4874 # :flag.case_no_arg
4827 args['--no-init-check']=1
4875 args['--no-init-check']=1
4828 shift
4876 shift
4829 ;;
4877 ;;
4830
4878
4831 *)
4879 *)
4832 break
4880 break
4833 ;;
4881 ;;
4834
4882
4835 esac
4883 esac
4836 done
4884 done
4837
4885
4838 # :command.environment_variables_filter
4886 # :command.environment_variables_filter
4839 # :command.environment_variables_default
4887 # :command.environment_variables_default
4840 export RCC_CONFIG="${RCC_CONFIG:-.rcstack.ini}"
4888 export RCC_CONFIG="${RCC_CONFIG:-.rcstack.ini}"
4841 export RC_STACK_ROUTER_EXT="${RC_STACK_ROUTER_EXT:-.custom/docker-compose-router.override.yaml}"
4889 export RC_STACK_ROUTER_EXT="${RC_STACK_ROUTER_EXT:-.custom/docker-compose-router.override.yaml}"
4842 export RC_STACK_METRICS_EXT="${RC_STACK_METRICS_EXT:-.custom/docker-compose-metrics.override.yaml}"
4890 export RC_STACK_METRICS_EXT="${RC_STACK_METRICS_EXT:-.custom/docker-compose-metrics.override.yaml}"
4843 export RC_STACK_SERVICES_EXT="${RC_STACK_SERVICES_EXT:-.custom/docker-compose-services.override.yaml}"
4891 export RC_STACK_SERVICES_EXT="${RC_STACK_SERVICES_EXT:-.custom/docker-compose-services.override.yaml}"
4844 export RC_STACK_RHODECODE_EXT="${RC_STACK_RHODECODE_EXT:-.custom/docker-compose-apps.override.yaml}"
4892 export RC_STACK_RHODECODE_EXT="${RC_STACK_RHODECODE_EXT:-.custom/docker-compose-apps.override.yaml}"
4845
4893
4846 # :command.command_filter
4894 # :command.command_filter
4847 action=${1:-}
4895 action=${1:-}
4848
4896
4849 case $action in
4897 case $action in
4850 -*) ;;
4898 -*) ;;
4851
4899
4852 get-started)
4900 get-started)
4853 action="get-started"
4901 action="get-started"
4854 shift
4902 shift
4855 rcstack_get_started_parse_requirements "$@"
4903 rcstack_get_started_parse_requirements "$@"
4856 shift $#
4904 shift $#
4857 ;;
4905 ;;
4858
4906
4859 init)
4907 init)
4860 action="init"
4908 action="init"
4861 shift
4909 shift
4862 rcstack_init_parse_requirements "$@"
4910 rcstack_init_parse_requirements "$@"
4863 shift $#
4911 shift $#
4864 ;;
4912 ;;
4865
4913
4866 self-update)
4914 self-update)
4867 action="self-update"
4915 action="self-update"
4868 shift
4916 shift
4869 rcstack_self_update_parse_requirements "$@"
4917 rcstack_self_update_parse_requirements "$@"
4870 shift $#
4918 shift $#
4871 ;;
4919 ;;
4872
4920
4873 self-upgrade)
4921 self-upgrade)
4874 action="self-upgrade"
4922 action="self-upgrade"
4875 shift
4923 shift
4876 rcstack_self_upgrade_parse_requirements "$@"
4924 rcstack_self_upgrade_parse_requirements "$@"
4877 shift $#
4925 shift $#
4878 ;;
4926 ;;
4879
4927
4880 stack)
4928 stack)
4881 action="stack"
4929 action="stack"
4882 shift
4930 shift
4883 rcstack_stack_parse_requirements "$@"
4931 rcstack_stack_parse_requirements "$@"
4884 shift $#
4932 shift $#
4885 ;;
4933 ;;
4886
4934
4887 stack-status | status)
4935 stack-status | status)
4888 action="stack-status"
4936 action="stack-status"
4889 shift
4937 shift
4890 rcstack_stack_status_parse_requirements "$@"
4938 rcstack_stack_status_parse_requirements "$@"
4891 shift $#
4939 shift $#
4892 ;;
4940 ;;
4893
4941
4894 stack-upgrade)
4942 stack-upgrade)
4895 action="stack-upgrade"
4943 action="stack-upgrade"
4896 shift
4944 shift
4897 rcstack_stack_upgrade_parse_requirements "$@"
4945 rcstack_stack_upgrade_parse_requirements "$@"
4898 shift $#
4946 shift $#
4899 ;;
4947 ;;
4900
4948
4901 stack-monitor)
4949 stack-monitor)
4902 action="stack-monitor"
4950 action="stack-monitor"
4903 shift
4951 shift
4904 rcstack_stack_monitor_parse_requirements "$@"
4952 rcstack_stack_monitor_parse_requirements "$@"
4905 shift $#
4953 shift $#
4906 ;;
4954 ;;
4907
4955
4908 cli)
4956 cli)
4909 action="cli"
4957 action="cli"
4910 shift
4958 shift
4911 rcstack_cli_parse_requirements "$@"
4959 rcstack_cli_parse_requirements "$@"
4912 shift $#
4960 shift $#
4913 ;;
4961 ;;
4914
4962
4915 backup-db)
4963 backup-db)
4916 action="backup-db"
4964 action="backup-db"
4917 shift
4965 shift
4918 rcstack_backup_db_parse_requirements "$@"
4966 rcstack_backup_db_parse_requirements "$@"
4919 shift $#
4967 shift $#
4920 ;;
4968 ;;
4921
4969
4922 backup-data)
4970 backup-data)
4923 action="backup-data"
4971 action="backup-data"
4924 shift
4972 shift
4925 rcstack_backup_data_parse_requirements "$@"
4973 rcstack_backup_data_parse_requirements "$@"
4926 shift $#
4974 shift $#
4927 ;;
4975 ;;
4928
4976
4929 _completions)
4977 _completions)
4930 action="_completions"
4978 action="_completions"
4931 shift
4979 shift
4932 rcstack__completions_parse_requirements "$@"
4980 rcstack__completions_parse_requirements "$@"
4933 shift $#
4981 shift $#
4934 ;;
4982 ;;
4935
4983
4936 # :command.command_fallback
4984 # :command.command_fallback
4937 "")
4985 "")
4938 rcstack_usage >&2
4986 rcstack_usage >&2
4939 exit 1
4987 exit 1
4940 ;;
4988 ;;
4941
4989
4942 *)
4990 *)
4943 printf "invalid command: %s\n" "$action" >&2
4991 printf "invalid command: %s\n" "$action" >&2
4944 exit 1
4992 exit 1
4945 ;;
4993 ;;
4946
4994
4947 esac
4995 esac
4948
4996
4949 # :command.parse_requirements_while
4997 # :command.parse_requirements_while
4950 while [[ $# -gt 0 ]]; do
4998 while [[ $# -gt 0 ]]; do
4951 key="$1"
4999 key="$1"
4952 case "$key" in
5000 case "$key" in
4953
5001
4954 -?*)
5002 -?*)
4955 printf "invalid option: %s\n" "$key" >&2
5003 printf "invalid option: %s\n" "$key" >&2
4956 exit 1
5004 exit 1
4957 ;;
5005 ;;
4958
5006
4959 *)
5007 *)
4960 # :command.parse_requirements_case
5008 # :command.parse_requirements_case
4961 # :command.parse_requirements_case_simple
5009 # :command.parse_requirements_case_simple
4962 printf "invalid argument: %s\n" "$key" >&2
5010 printf "invalid argument: %s\n" "$key" >&2
4963 exit 1
5011 exit 1
4964
5012
4965 ;;
5013 ;;
4966
5014
4967 esac
5015 esac
4968 done
5016 done
4969
5017
4970 }
5018 }
4971
5019
4972 # :command.parse_requirements
5020 # :command.parse_requirements
4973 rcstack_get_started_parse_requirements() {
5021 rcstack_get_started_parse_requirements() {
4974 # :command.fixed_flags_filter
5022 # :command.fixed_flags_filter
4975 while [[ $# -gt 0 ]]; do
5023 while [[ $# -gt 0 ]]; do
4976 case "${1:-}" in
5024 case "${1:-}" in
4977 --help | -h)
5025 --help | -h)
4978 long_usage=yes
5026 long_usage=yes
4979 rcstack_get_started_usage
5027 rcstack_get_started_usage
4980 exit
5028 exit
4981 ;;
5029 ;;
4982
5030
4983 *)
5031 *)
4984 break
5032 break
4985 ;;
5033 ;;
4986
5034
4987 esac
5035 esac
4988 done
5036 done
4989
5037
4990 # :command.command_filter
5038 # :command.command_filter
4991 action="get-started"
5039 action="get-started"
4992
5040
4993 # :command.parse_requirements_while
5041 # :command.parse_requirements_while
4994 while [[ $# -gt 0 ]]; do
5042 while [[ $# -gt 0 ]]; do
4995 key="$1"
5043 key="$1"
4996 case "$key" in
5044 case "$key" in
4997
5045
4998 -?*)
5046 -?*)
4999 printf "invalid option: %s\n" "$key" >&2
5047 printf "invalid option: %s\n" "$key" >&2
5000 exit 1
5048 exit 1
5001 ;;
5049 ;;
5002
5050
5003 *)
5051 *)
5004 # :command.parse_requirements_case
5052 # :command.parse_requirements_case
5005 # :command.parse_requirements_case_simple
5053 # :command.parse_requirements_case_simple
5006 printf "invalid argument: %s\n" "$key" >&2
5054 printf "invalid argument: %s\n" "$key" >&2
5007 exit 1
5055 exit 1
5008
5056
5009 ;;
5057 ;;
5010
5058
5011 esac
5059 esac
5012 done
5060 done
5013
5061
5014 }
5062 }
5015
5063
5016 # :command.parse_requirements
5064 # :command.parse_requirements
5017 rcstack_init_parse_requirements() {
5065 rcstack_init_parse_requirements() {
5018 # :command.fixed_flags_filter
5066 # :command.fixed_flags_filter
5019 while [[ $# -gt 0 ]]; do
5067 while [[ $# -gt 0 ]]; do
5020 case "${1:-}" in
5068 case "${1:-}" in
5021 --help | -h)
5069 --help | -h)
5022 long_usage=yes
5070 long_usage=yes
5023 rcstack_init_usage
5071 rcstack_init_usage
5024 exit
5072 exit
5025 ;;
5073 ;;
5026
5074
5027 *)
5075 *)
5028 break
5076 break
5029 ;;
5077 ;;
5030
5078
5031 esac
5079 esac
5032 done
5080 done
5033
5081
5034 # :command.dependencies_filter
5082 # :command.dependencies_filter
5035 if command -v curl >/dev/null 2>&1; then
5083 if command -v curl >/dev/null 2>&1; then
5036 deps['curl']="$(command -v curl | head -n1)"
5084 deps['curl']="$(command -v curl | head -n1)"
5037 else
5085 else
5038 printf "missing dependency: curl\n" >&2
5086 printf "missing dependency: curl\n" >&2
5039 exit 1
5087 exit 1
5040 fi
5088 fi
5041
5089
5042 if command -v tar >/dev/null 2>&1; then
5090 if command -v tar >/dev/null 2>&1; then
5043 deps['tar']="$(command -v tar | head -n1)"
5091 deps['tar']="$(command -v tar | head -n1)"
5044 else
5092 else
5045 printf "missing dependency: tar\n" >&2
5093 printf "missing dependency: tar\n" >&2
5046 exit 1
5094 exit 1
5047 fi
5095 fi
5048
5096
5049 if command -v find >/dev/null 2>&1; then
5097 if command -v find >/dev/null 2>&1; then
5050 deps['find']="$(command -v find | head -n1)"
5098 deps['find']="$(command -v find | head -n1)"
5051 else
5099 else
5052 printf "missing dependency: find\n" >&2
5100 printf "missing dependency: find\n" >&2
5053 exit 1
5101 exit 1
5054 fi
5102 fi
5055
5103
5056 # :command.command_filter
5104 # :command.command_filter
5057 action="init"
5105 action="init"
5058
5106
5059 # :command.parse_requirements_while
5107 # :command.parse_requirements_while
5060 while [[ $# -gt 0 ]]; do
5108 while [[ $# -gt 0 ]]; do
5061 key="$1"
5109 key="$1"
5062 case "$key" in
5110 case "$key" in
5063 # :flag.case
5111 # :flag.case
5064 --arg-accept-eula)
5112 --arg-accept-eula)
5065
5113
5066 # :flag.case_no_arg
5114 # :flag.case_no_arg
5067 args['--arg-accept-eula']=1
5115 args['--arg-accept-eula']=1
5068 shift
5116 shift
5069 ;;
5117 ;;
5070
5118
5071 # :flag.case
5119 # :flag.case
5072 --arg-rc-edition)
5120 --arg-rc-edition)
5073
5121
5074 # :flag.case_arg
5122 # :flag.case_arg
5075 if [[ -n ${2+x} ]]; then
5123 if [[ -n ${2+x} ]]; then
5076
5124
5077 args['--arg-rc-edition']="$2"
5125 args['--arg-rc-edition']="$2"
5078 shift
5126 shift
5079 shift
5127 shift
5080 else
5128 else
5081 printf "%s\n" "--arg-rc-edition requires an argument: --arg-rc-edition ARG_RC_EDITION" >&2
5129 printf "%s\n" "--arg-rc-edition requires an argument: --arg-rc-edition ARG_RC_EDITION" >&2
5082 exit 1
5130 exit 1
5083 fi
5131 fi
5084 ;;
5132 ;;
5085
5133
5086 # :flag.case
5134 # :flag.case
5087 --arg-rc-version)
5135 --arg-rc-version)
5088
5136
5089 # :flag.case_arg
5137 # :flag.case_arg
5090 if [[ -n ${2+x} ]]; then
5138 if [[ -n ${2+x} ]]; then
5091
5139
5092 args['--arg-rc-version']="$2"
5140 args['--arg-rc-version']="$2"
5093 shift
5141 shift
5094 shift
5142 shift
5095 else
5143 else
5096 printf "%s\n" "--arg-rc-version requires an argument: --arg-rc-version ARG_RC_VERSION" >&2
5144 printf "%s\n" "--arg-rc-version requires an argument: --arg-rc-version ARG_RC_VERSION" >&2
5097 exit 1
5145 exit 1
5098 fi
5146 fi
5099 ;;
5147 ;;
5100
5148
5101 # :flag.case
5149 # :flag.case
5102 --arg-hostname)
5150 --arg-hostname)
5103
5151
5104 # :flag.case_arg
5152 # :flag.case_arg
5105 if [[ -n ${2+x} ]]; then
5153 if [[ -n ${2+x} ]]; then
5106
5154
5107 args['--arg-hostname']="$2"
5155 args['--arg-hostname']="$2"
5108 shift
5156 shift
5109 shift
5157 shift
5110 else
5158 else
5111 printf "%s\n" "--arg-hostname requires an argument: --arg-hostname ARG_HOSTNAME" >&2
5159 printf "%s\n" "--arg-hostname requires an argument: --arg-hostname ARG_HOSTNAME" >&2
5112 exit 1
5160 exit 1
5113 fi
5161 fi
5114 ;;
5162 ;;
5115
5163
5116 # :flag.case
5164 # :flag.case
5117 --arg-database-type)
5165 --arg-database-type)
5118
5166
5119 # :flag.case_arg
5167 # :flag.case_arg
5120 if [[ -n ${2+x} ]]; then
5168 if [[ -n ${2+x} ]]; then
5121
5169
5122 args['--arg-database-type']="$2"
5170 args['--arg-database-type']="$2"
5123 shift
5171 shift
5124 shift
5172 shift
5125 else
5173 else
5126 printf "%s\n" "--arg-database-type requires an argument: --arg-database-type ARG_DATABASE_TYPE" >&2
5174 printf "%s\n" "--arg-database-type requires an argument: --arg-database-type ARG_DATABASE_TYPE" >&2
5127 exit 1
5175 exit 1
5128 fi
5176 fi
5129 ;;
5177 ;;
5130
5178
5131 # :flag.case
5179 # :flag.case
5132 --arg-use-ssl)
5180 --arg-use-ssl)
5133
5181
5134 # :flag.case_arg
5182 # :flag.case_arg
5135 if [[ -n ${2+x} ]]; then
5183 if [[ -n ${2+x} ]]; then
5136
5184
5137 args['--arg-use-ssl']="$2"
5185 args['--arg-use-ssl']="$2"
5138 shift
5186 shift
5139 shift
5187 shift
5140 else
5188 else
5141 printf "%s\n" "--arg-use-ssl requires an argument: --arg-use-ssl ARG_USE_SSL" >&2
5189 printf "%s\n" "--arg-use-ssl requires an argument: --arg-use-ssl ARG_USE_SSL" >&2
5142 exit 1
5190 exit 1
5143 fi
5191 fi
5144 ;;
5192 ;;
5145
5193
5146 # :flag.case
5194 # :flag.case
5147 --arg-admin-email)
5195 --arg-admin-email)
5148
5196
5149 # :flag.case_arg
5197 # :flag.case_arg
5150 if [[ -n ${2+x} ]]; then
5198 if [[ -n ${2+x} ]]; then
5151
5199
5152 args['--arg-admin-email']="$2"
5200 args['--arg-admin-email']="$2"
5153 shift
5201 shift
5154 shift
5202 shift
5155 else
5203 else
5156 printf "%s\n" "--arg-admin-email requires an argument: --arg-admin-email ARG_ADMIN_EMAIL" >&2
5204 printf "%s\n" "--arg-admin-email requires an argument: --arg-admin-email ARG_ADMIN_EMAIL" >&2
5157 exit 1
5205 exit 1
5158 fi
5206 fi
5159 ;;
5207 ;;
5160
5208
5161 # :flag.case
5209 # :flag.case
5162 --arg-admin-user)
5210 --arg-admin-user)
5163
5211
5164 # :flag.case_arg
5212 # :flag.case_arg
5165 if [[ -n ${2+x} ]]; then
5213 if [[ -n ${2+x} ]]; then
5166
5214
5167 args['--arg-admin-user']="$2"
5215 args['--arg-admin-user']="$2"
5168 shift
5216 shift
5169 shift
5217 shift
5170 else
5218 else
5171 printf "%s\n" "--arg-admin-user requires an argument: --arg-admin-user ARG_ADMIN_USER" >&2
5219 printf "%s\n" "--arg-admin-user requires an argument: --arg-admin-user ARG_ADMIN_USER" >&2
5172 exit 1
5220 exit 1
5173 fi
5221 fi
5174 ;;
5222 ;;
5175
5223
5176 # :flag.case
5224 # :flag.case
5177 --arg-admin-pass)
5225 --arg-admin-pass)
5178
5226
5179 # :flag.case_arg
5227 # :flag.case_arg
5180 if [[ -n ${2+x} ]]; then
5228 if [[ -n ${2+x} ]]; then
5181
5229
5182 args['--arg-admin-pass']="$2"
5230 args['--arg-admin-pass']="$2"
5183 shift
5231 shift
5184 shift
5232 shift
5185 else
5233 else
5186 printf "%s\n" "--arg-admin-pass requires an argument: --arg-admin-pass ARG_ADMIN_PASS" >&2
5234 printf "%s\n" "--arg-admin-pass requires an argument: --arg-admin-pass ARG_ADMIN_PASS" >&2
5187 exit 1
5235 exit 1
5188 fi
5236 fi
5189 ;;
5237 ;;
5190
5238
5191 # :flag.case
5239 # :flag.case
5192 --arg-license-token)
5240 --arg-license-token)
5193
5241
5194 # :flag.case_arg
5242 # :flag.case_arg
5195 if [[ -n ${2+x} ]]; then
5243 if [[ -n ${2+x} ]]; then
5196
5244
5197 args['--arg-license-token']="$2"
5245 args['--arg-license-token']="$2"
5198 shift
5246 shift
5199 shift
5247 shift
5200 else
5248 else
5201 printf "%s\n" "--arg-license-token requires an argument: --arg-license-token ARG_ADMIN_TOKEN" >&2
5249 printf "%s\n" "--arg-license-token requires an argument: --arg-license-token ARG_ADMIN_TOKEN" >&2
5202 exit 1
5250 exit 1
5203 fi
5251 fi
5204 ;;
5252 ;;
5205
5253
5206 # :flag.case
5254 # :flag.case
5207 --no-prompt)
5255 --no-prompt)
5208
5256
5209 # :flag.case_no_arg
5257 # :flag.case_no_arg
5210 args['--no-prompt']=1
5258 args['--no-prompt']=1
5211 shift
5259 shift
5212 ;;
5260 ;;
5213
5261
5214 # :flag.case
5262 # :flag.case
5215 --force | -f)
5263 --force | -f)
5216
5264
5217 # :flag.case_no_arg
5265 # :flag.case_no_arg
5218 args['--force']=1
5266 args['--force']=1
5219 shift
5267 shift
5220 ;;
5268 ;;
5221
5269
5222 # :flag.case
5270 # :flag.case
5223 --stage)
5271 --stage)
5224
5272
5225 # :flag.case_arg
5273 # :flag.case_arg
5226 if [[ -n ${2+x} ]]; then
5274 if [[ -n ${2+x} ]]; then
5227
5275
5228 if [[ -z ${args['--stage']+x} ]]; then
5276 if [[ -z ${args['--stage']+x} ]]; then
5229 args['--stage']="\"$2\""
5277 args['--stage']="\"$2\""
5230 else
5278 else
5231 args['--stage']="${args[--stage]} \"$2\""
5279 args['--stage']="${args[--stage]} \"$2\""
5232 fi
5280 fi
5233 shift
5281 shift
5234 shift
5282 shift
5235 else
5283 else
5236 printf "%s\n" "--stage requires an argument: --stage STAGE" >&2
5284 printf "%s\n" "--stage requires an argument: --stage STAGE" >&2
5237 exit 1
5285 exit 1
5238 fi
5286 fi
5239 ;;
5287 ;;
5240
5288
5241 # :flag.case
5289 # :flag.case
5242 --docker-revision)
5290 --docker-revision)
5243
5291
5244 # :flag.case_arg
5292 # :flag.case_arg
5245 if [[ -n ${2+x} ]]; then
5293 if [[ -n ${2+x} ]]; then
5246
5294
5247 args['--docker-revision']="$2"
5295 args['--docker-revision']="$2"
5248 shift
5296 shift
5249 shift
5297 shift
5250 else
5298 else
5251 printf "%s\n" "--docker-revision requires an argument: --docker-revision DOCKER_REVISION" >&2
5299 printf "%s\n" "--docker-revision requires an argument: --docker-revision DOCKER_REVISION" >&2
5252 exit 1
5300 exit 1
5253 fi
5301 fi
5254 ;;
5302 ;;
5255
5303
5256 # :flag.case
5304 # :flag.case
5257 --install-docker)
5305 --install-docker)
5258
5306
5259 # :flag.case_arg
5307 # :flag.case_arg
5260 if [[ -n ${2+x} ]]; then
5308 if [[ -n ${2+x} ]]; then
5261
5309
5262 args['--install-docker']="$2"
5310 args['--install-docker']="$2"
5263 shift
5311 shift
5264 shift
5312 shift
5265 else
5313 else
5266 printf "%s\n" "--install-docker requires an argument: --install-docker INSTALL_DOCKER" >&2
5314 printf "%s\n" "--install-docker requires an argument: --install-docker INSTALL_DOCKER" >&2
5267 exit 1
5315 exit 1
5268 fi
5316 fi
5269 ;;
5317 ;;
5270
5318
5271 # :flag.case
5319 # :flag.case
5272 --server-url)
5320 --server-url)
5273
5321
5274 # :flag.case_arg
5322 # :flag.case_arg
5275 if [[ -n ${2+x} ]]; then
5323 if [[ -n ${2+x} ]]; then
5276
5324
5277 args['--server-url']="$2"
5325 args['--server-url']="$2"
5278 shift
5326 shift
5279 shift
5327 shift
5280 else
5328 else
5281 printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
5329 printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
5282 exit 1
5330 exit 1
5283 fi
5331 fi
5284 ;;
5332 ;;
5285
5333
5286 # :flag.case
5334 # :flag.case
5287 --auth-token)
5335 --auth-token)
5288
5336
5289 # :flag.case_arg
5337 # :flag.case_arg
5290 if [[ -n ${2+x} ]]; then
5338 if [[ -n ${2+x} ]]; then
5291
5339
5292 args['--auth-token']="$2"
5340 args['--auth-token']="$2"
5293 shift
5341 shift
5294 shift
5342 shift
5295 else
5343 else
5296 printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
5344 printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
5297 exit 1
5345 exit 1
5298 fi
5346 fi
5299 ;;
5347 ;;
5300
5348
5301 -?*)
5349 -?*)
5302 printf "invalid option: %s\n" "$key" >&2
5350 printf "invalid option: %s\n" "$key" >&2
5303 exit 1
5351 exit 1
5304 ;;
5352 ;;
5305
5353
5306 *)
5354 *)
5307 # :command.parse_requirements_case
5355 # :command.parse_requirements_case
5308 # :command.parse_requirements_case_simple
5356 # :command.parse_requirements_case_simple
5309 printf "invalid argument: %s\n" "$key" >&2
5357 printf "invalid argument: %s\n" "$key" >&2
5310 exit 1
5358 exit 1
5311
5359
5312 ;;
5360 ;;
5313
5361
5314 esac
5362 esac
5315 done
5363 done
5316
5364
5317 # :command.default_assignments
5365 # :command.default_assignments
5318 [[ -n ${args['--docker-revision']:-} ]] || args['--docker-revision']="stable"
5366 [[ -n ${args['--docker-revision']:-} ]] || args['--docker-revision']="stable"
5319 [[ -n ${args['--server-url']:-} ]] || args['--server-url']="https://dls.rhodecode.com/get_archive"
5367 [[ -n ${args['--server-url']:-} ]] || args['--server-url']="https://dls.rhodecode.com/get_archive"
5320
5368
5321 # :command.whitelist_filter
5369 # :command.whitelist_filter
5322 if [[ ${args['--arg-rc-edition']} ]] && [[ ! ${args['--arg-rc-edition']} =~ ^(ce|ee)$ ]]; then
5370 if [[ ${args['--arg-rc-edition']} ]] && [[ ! ${args['--arg-rc-edition']} =~ ^(ce|ee)$ ]]; then
5323 printf "%s\n" "--arg-rc-edition must be one of: ce, ee" >&2
5371 printf "%s\n" "--arg-rc-edition must be one of: ce, ee" >&2
5324 exit 1
5372 exit 1
5325 fi
5373 fi
5326 if [[ ${args['--arg-database-type']} ]] && [[ ! ${args['--arg-database-type']} =~ ^(postgres|mysql|none)$ ]]; then
5374 if [[ ${args['--arg-database-type']} ]] && [[ ! ${args['--arg-database-type']} =~ ^(postgres|mysql|none)$ ]]; then
5327 printf "%s\n" "--arg-database-type must be one of: postgres, mysql, none" >&2
5375 printf "%s\n" "--arg-database-type must be one of: postgres, mysql, none" >&2
5328 exit 1
5376 exit 1
5329 fi
5377 fi
5330 if [[ ${args['--arg-use-ssl']} ]] && [[ ! ${args['--arg-use-ssl']} =~ ^(y|n)$ ]]; then
5378 if [[ ${args['--arg-use-ssl']} ]] && [[ ! ${args['--arg-use-ssl']} =~ ^(y|n)$ ]]; then
5331 printf "%s\n" "--arg-use-ssl must be one of: y, n" >&2
5379 printf "%s\n" "--arg-use-ssl must be one of: y, n" >&2
5332 exit 1
5380 exit 1
5333 fi
5381 fi
5334
5382
5335 }
5383 }
5336
5384
5337 # :command.parse_requirements
5385 # :command.parse_requirements
5338 rcstack_self_update_parse_requirements() {
5386 rcstack_self_update_parse_requirements() {
5339 # :command.fixed_flags_filter
5387 # :command.fixed_flags_filter
5340 while [[ $# -gt 0 ]]; do
5388 while [[ $# -gt 0 ]]; do
5341 case "${1:-}" in
5389 case "${1:-}" in
5342 --help | -h)
5390 --help | -h)
5343 long_usage=yes
5391 long_usage=yes
5344 rcstack_self_update_usage
5392 rcstack_self_update_usage
5345 exit
5393 exit
5346 ;;
5394 ;;
5347
5395
5348 *)
5396 *)
5349 break
5397 break
5350 ;;
5398 ;;
5351
5399
5352 esac
5400 esac
5353 done
5401 done
5354
5402
5355 # :command.dependencies_filter
5403 # :command.dependencies_filter
5356 if command -v curl >/dev/null 2>&1; then
5404 if command -v curl >/dev/null 2>&1; then
5357 deps['curl']="$(command -v curl | head -n1)"
5405 deps['curl']="$(command -v curl | head -n1)"
5358 else
5406 else
5359 printf "missing dependency: curl\n" >&2
5407 printf "missing dependency: curl\n" >&2
5360 exit 1
5408 exit 1
5361 fi
5409 fi
5362
5410
5363 if command -v tar >/dev/null 2>&1; then
5411 if command -v tar >/dev/null 2>&1; then
5364 deps['tar']="$(command -v tar | head -n1)"
5412 deps['tar']="$(command -v tar | head -n1)"
5365 else
5413 else
5366 printf "missing dependency: tar\n" >&2
5414 printf "missing dependency: tar\n" >&2
5367 exit 1
5415 exit 1
5368 fi
5416 fi
5369
5417
5370 # :command.command_filter
5418 # :command.command_filter
5371 action="self-update"
5419 action="self-update"
5372
5420
5373 # :command.parse_requirements_while
5421 # :command.parse_requirements_while
5374 while [[ $# -gt 0 ]]; do
5422 while [[ $# -gt 0 ]]; do
5375 key="$1"
5423 key="$1"
5376 case "$key" in
5424 case "$key" in
5377 # :flag.case
5425 # :flag.case
5378 --force)
5426 --force)
5379
5427
5380 # :flag.case_no_arg
5428 # :flag.case_no_arg
5381 args['--force']=1
5429 args['--force']=1
5382 shift
5430 shift
5383 ;;
5431 ;;
5384
5432
5385 # :flag.case
5433 # :flag.case
5386 --update-docker-image)
5434 --update-docker-image)
5387
5435
5388 # :flag.case_arg
5436 # :flag.case_arg
5389 if [[ -n ${2+x} ]]; then
5437 if [[ -n ${2+x} ]]; then
5390
5438
5391 args['--update-docker-image']="$2"
5439 args['--update-docker-image']="$2"
5392 shift
5440 shift
5393 shift
5441 shift
5394 else
5442 else
5395 printf "%s\n" "--update-docker-image requires an argument: --update-docker-image UPDATE_DOCKER_IMAGE" >&2
5443 printf "%s\n" "--update-docker-image requires an argument: --update-docker-image UPDATE_DOCKER_IMAGE" >&2
5396 exit 1
5444 exit 1
5397 fi
5445 fi
5398 ;;
5446 ;;
5399
5447
5400 # :flag.case
5448 # :flag.case
5401 --cli-file)
5449 --cli-file)
5402 # :flag.conflicts
5450 # :flag.conflicts
5403 if [[ -n "${args['--cli-revision']:-}" ]]; then
5451 if [[ -n "${args['--cli-revision']:-}" ]]; then
5404 printf "conflicting options: %s cannot be used with %s\n" "$key" "--cli-revision" >&2
5452 printf "conflicting options: %s cannot be used with %s\n" "$key" "--cli-revision" >&2
5405 exit 1
5453 exit 1
5406 fi
5454 fi
5407
5455
5408 # :flag.case_arg
5456 # :flag.case_arg
5409 if [[ -n ${2+x} ]]; then
5457 if [[ -n ${2+x} ]]; then
5410
5458
5411 args['--cli-file']="$2"
5459 args['--cli-file']="$2"
5412 shift
5460 shift
5413 shift
5461 shift
5414 else
5462 else
5415 printf "%s\n" "--cli-file requires an argument: --cli-file CLI_FILE" >&2
5463 printf "%s\n" "--cli-file requires an argument: --cli-file CLI_FILE" >&2
5416 exit 1
5464 exit 1
5417 fi
5465 fi
5418 ;;
5466 ;;
5419
5467
5420 # :flag.case
5468 # :flag.case
5421 --cli-revision)
5469 --cli-revision)
5422 # :flag.conflicts
5470 # :flag.conflicts
5423 if [[ -n "${args['--cli-file']:-}" ]]; then
5471 if [[ -n "${args['--cli-file']:-}" ]]; then
5424 printf "conflicting options: %s cannot be used with %s\n" "$key" "--cli-file" >&2
5472 printf "conflicting options: %s cannot be used with %s\n" "$key" "--cli-file" >&2
5425 exit 1
5473 exit 1
5426 fi
5474 fi
5427
5475
5428 # :flag.case_arg
5476 # :flag.case_arg
5429 if [[ -n ${2+x} ]]; then
5477 if [[ -n ${2+x} ]]; then
5430
5478
5431 args['--cli-revision']="$2"
5479 args['--cli-revision']="$2"
5432 shift
5480 shift
5433 shift
5481 shift
5434 else
5482 else
5435 printf "%s\n" "--cli-revision requires an argument: --cli-revision CLI_REVISION" >&2
5483 printf "%s\n" "--cli-revision requires an argument: --cli-revision CLI_REVISION" >&2
5436 exit 1
5484 exit 1
5437 fi
5485 fi
5438 ;;
5486 ;;
5439
5487
5440 # :flag.case
5488 # :flag.case
5441 --docker-revision)
5489 --docker-revision)
5442
5490
5443 # :flag.case_arg
5491 # :flag.case_arg
5444 if [[ -n ${2+x} ]]; then
5492 if [[ -n ${2+x} ]]; then
5445
5493
5446 args['--docker-revision']="$2"
5494 args['--docker-revision']="$2"
5447 shift
5495 shift
5448 shift
5496 shift
5449 else
5497 else
5450 printf "%s\n" "--docker-revision requires an argument: --docker-revision DOCKER_REVISION" >&2
5498 printf "%s\n" "--docker-revision requires an argument: --docker-revision DOCKER_REVISION" >&2
5451 exit 1
5499 exit 1
5452 fi
5500 fi
5453 ;;
5501 ;;
5454
5502
5455 # :flag.case
5503 # :flag.case
5456 --server-url)
5504 --server-url)
5457
5505
5458 # :flag.case_arg
5506 # :flag.case_arg
5459 if [[ -n ${2+x} ]]; then
5507 if [[ -n ${2+x} ]]; then
5460
5508
5461 args['--server-url']="$2"
5509 args['--server-url']="$2"
5462 shift
5510 shift
5463 shift
5511 shift
5464 else
5512 else
5465 printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
5513 printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
5466 exit 1
5514 exit 1
5467 fi
5515 fi
5468 ;;
5516 ;;
5469
5517
5470 # :flag.case
5518 # :flag.case
5471 --auth-token)
5519 --auth-token)
5472
5520
5473 # :flag.case_arg
5521 # :flag.case_arg
5474 if [[ -n ${2+x} ]]; then
5522 if [[ -n ${2+x} ]]; then
5475
5523
5476 args['--auth-token']="$2"
5524 args['--auth-token']="$2"
5477 shift
5525 shift
5478 shift
5526 shift
5479 else
5527 else
5480 printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
5528 printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
5481 exit 1
5529 exit 1
5482 fi
5530 fi
5483 ;;
5531 ;;
5484
5532
5485 -?*)
5533 -?*)
5486 printf "invalid option: %s\n" "$key" >&2
5534 printf "invalid option: %s\n" "$key" >&2
5487 exit 1
5535 exit 1
5488 ;;
5536 ;;
5489
5537
5490 *)
5538 *)
5491 # :command.parse_requirements_case
5539 # :command.parse_requirements_case
5492 # :command.parse_requirements_case_simple
5540 # :command.parse_requirements_case_simple
5493 printf "invalid argument: %s\n" "$key" >&2
5541 printf "invalid argument: %s\n" "$key" >&2
5494 exit 1
5542 exit 1
5495
5543
5496 ;;
5544 ;;
5497
5545
5498 esac
5546 esac
5499 done
5547 done
5500
5548
5501 # :command.default_assignments
5549 # :command.default_assignments
5502 [[ -n ${args['--cli-revision']:-} ]] || args['--cli-revision']="stable"
5550 [[ -n ${args['--cli-revision']:-} ]] || args['--cli-revision']="stable"
5503 [[ -n ${args['--docker-revision']:-} ]] || args['--docker-revision']="stable"
5551 [[ -n ${args['--docker-revision']:-} ]] || args['--docker-revision']="stable"
5504 [[ -n ${args['--server-url']:-} ]] || args['--server-url']="https://dls.rhodecode.com/get_archive"
5552 [[ -n ${args['--server-url']:-} ]] || args['--server-url']="https://dls.rhodecode.com/get_archive"
5505
5553
5506 }
5554 }
5507
5555
5508 # :command.parse_requirements
5556 # :command.parse_requirements
5509 rcstack_self_upgrade_parse_requirements() {
5557 rcstack_self_upgrade_parse_requirements() {
5510 # :command.fixed_flags_filter
5558 # :command.fixed_flags_filter
5511 while [[ $# -gt 0 ]]; do
5559 while [[ $# -gt 0 ]]; do
5512 case "${1:-}" in
5560 case "${1:-}" in
5513 --help | -h)
5561 --help | -h)
5514 long_usage=yes
5562 long_usage=yes
5515 rcstack_self_upgrade_usage
5563 rcstack_self_upgrade_usage
5516 exit
5564 exit
5517 ;;
5565 ;;
5518
5566
5519 *)
5567 *)
5520 break
5568 break
5521 ;;
5569 ;;
5522
5570
5523 esac
5571 esac
5524 done
5572 done
5525
5573
5526 # :command.dependencies_filter
5574 # :command.dependencies_filter
5527 if command -v curl >/dev/null 2>&1; then
5575 if command -v curl >/dev/null 2>&1; then
5528 deps['curl']="$(command -v curl | head -n1)"
5576 deps['curl']="$(command -v curl | head -n1)"
5529 else
5577 else
5530 printf "missing dependency: curl\n" >&2
5578 printf "missing dependency: curl\n" >&2
5531 exit 1
5579 exit 1
5532 fi
5580 fi
5533
5581
5534 if command -v tar >/dev/null 2>&1; then
5582 if command -v tar >/dev/null 2>&1; then
5535 deps['tar']="$(command -v tar | head -n1)"
5583 deps['tar']="$(command -v tar | head -n1)"
5536 else
5584 else
5537 printf "missing dependency: tar\n" >&2
5585 printf "missing dependency: tar\n" >&2
5538 exit 1
5586 exit 1
5539 fi
5587 fi
5540
5588
5541 # :command.command_filter
5589 # :command.command_filter
5542 action="self-upgrade"
5590 action="self-upgrade"
5543
5591
5544 # :command.parse_requirements_while
5592 # :command.parse_requirements_while
5545 while [[ $# -gt 0 ]]; do
5593 while [[ $# -gt 0 ]]; do
5546 key="$1"
5594 key="$1"
5547 case "$key" in
5595 case "$key" in
5548 # :flag.case
5596 # :flag.case
5549 --from-ver)
5597 --from-ver)
5550
5598
5551 # :flag.case_arg
5599 # :flag.case_arg
5552 if [[ -n ${2+x} ]]; then
5600 if [[ -n ${2+x} ]]; then
5553
5601
5554 args['--from-ver']="$2"
5602 args['--from-ver']="$2"
5555 shift
5603 shift
5556 shift
5604 shift
5557 else
5605 else
5558 printf "%s\n" "--from-ver requires an argument: --from-ver FROM_VER" >&2
5606 printf "%s\n" "--from-ver requires an argument: --from-ver FROM_VER" >&2
5559 exit 1
5607 exit 1
5560 fi
5608 fi
5561 ;;
5609 ;;
5562
5610
5563 # :flag.case
5611 # :flag.case
5564 --to-ver)
5612 --to-ver)
5565
5613
5566 # :flag.case_arg
5614 # :flag.case_arg
5567 if [[ -n ${2+x} ]]; then
5615 if [[ -n ${2+x} ]]; then
5568
5616
5569 args['--to-ver']="$2"
5617 args['--to-ver']="$2"
5570 shift
5618 shift
5571 shift
5619 shift
5572 else
5620 else
5573 printf "%s\n" "--to-ver requires an argument: --to-ver TO_VER" >&2
5621 printf "%s\n" "--to-ver requires an argument: --to-ver TO_VER" >&2
5574 exit 1
5622 exit 1
5575 fi
5623 fi
5576 ;;
5624 ;;
5577
5625
5578 -?*)
5626 -?*)
5579 printf "invalid option: %s\n" "$key" >&2
5627 printf "invalid option: %s\n" "$key" >&2
5580 exit 1
5628 exit 1
5581 ;;
5629 ;;
5582
5630
5583 *)
5631 *)
5584 # :command.parse_requirements_case
5632 # :command.parse_requirements_case
5585 # :command.parse_requirements_case_simple
5633 # :command.parse_requirements_case_simple
5586 printf "invalid argument: %s\n" "$key" >&2
5634 printf "invalid argument: %s\n" "$key" >&2
5587 exit 1
5635 exit 1
5588
5636
5589 ;;
5637 ;;
5590
5638
5591 esac
5639 esac
5592 done
5640 done
5593
5641
5594 }
5642 }
5595
5643
5596 # :command.parse_requirements
5644 # :command.parse_requirements
5597 rcstack_stack_parse_requirements() {
5645 rcstack_stack_parse_requirements() {
5598 # :command.fixed_flags_filter
5646 # :command.fixed_flags_filter
5599 while [[ $# -gt 0 ]]; do
5647 while [[ $# -gt 0 ]]; do
5600 case "${1:-}" in
5648 case "${1:-}" in
5601 --help | -h)
5649 --help | -h)
5602 long_usage=yes
5650 long_usage=yes
5603 rcstack_stack_usage
5651 rcstack_stack_usage
5604 exit
5652 exit
5605 ;;
5653 ;;
5606
5654
5607 # :flag.case
5655 # :flag.case
5608 --env-file-path)
5656 --env-file-path)
5609
5657
5610 # :flag.case_arg
5658 # :flag.case_arg
5611 if [[ -n ${2+x} ]]; then
5659 if [[ -n ${2+x} ]]; then
5612 # :flag.validations
5660 # :flag.validations
5613 if [[ -n $(validate_file_exists "$2") ]]; then
5661 if [[ -n $(validate_file_exists "$2") ]]; then
5614 printf "validation error in %s:\n%s\n" "--env-file-path ENV_FILE_PATH" "$(validate_file_exists "$2")" >&2
5662 printf "validation error in %s:\n%s\n" "--env-file-path ENV_FILE_PATH" "$(validate_file_exists "$2")" >&2
5615 exit 1
5663 exit 1
5616 fi
5664 fi
5617
5665
5618 args['--env-file-path']="$2"
5666 args['--env-file-path']="$2"
5619 shift
5667 shift
5620 shift
5668 shift
5621 else
5669 else
5622 printf "%s\n" "--env-file-path requires an argument: --env-file-path ENV_FILE_PATH" >&2
5670 printf "%s\n" "--env-file-path requires an argument: --env-file-path ENV_FILE_PATH" >&2
5623 exit 1
5671 exit 1
5624 fi
5672 fi
5625 ;;
5673 ;;
5626
5674
5627 # :flag.case
5675 # :flag.case
5628 --stack-prefix)
5676 --stack-prefix)
5629
5677
5630 # :flag.case_arg
5678 # :flag.case_arg
5631 if [[ -n ${2+x} ]]; then
5679 if [[ -n ${2+x} ]]; then
5632
5680
5633 args['--stack-prefix']="$2"
5681 args['--stack-prefix']="$2"
5634 shift
5682 shift
5635 shift
5683 shift
5636 else
5684 else
5637 printf "%s\n" "--stack-prefix requires an argument: --stack-prefix STACK_PREFIX" >&2
5685 printf "%s\n" "--stack-prefix requires an argument: --stack-prefix STACK_PREFIX" >&2
5638 exit 1
5686 exit 1
5639 fi
5687 fi
5640 ;;
5688 ;;
5641
5689
5642 *)
5690 *)
5643 break
5691 break
5644 ;;
5692 ;;
5645
5693
5646 esac
5694 esac
5647 done
5695 done
5648
5696
5649 # :command.command_filter
5697 # :command.command_filter
5650 action=${1:-}
5698 action=${1:-}
5651
5699
5652 case $action in
5700 case $action in
5653 -*) ;;
5701 -*) ;;
5654
5702
5655 router)
5703 router)
5656 action="router"
5704 action="router"
5657 shift
5705 shift
5658 rcstack_stack_router_parse_requirements "$@"
5706 rcstack_stack_router_parse_requirements "$@"
5659 shift $#
5707 shift $#
5660 ;;
5708 ;;
5661
5709
5662 metrics)
5710 metrics)
5663 action="metrics"
5711 action="metrics"
5664 shift
5712 shift
5665 rcstack_stack_metrics_parse_requirements "$@"
5713 rcstack_stack_metrics_parse_requirements "$@"
5666 shift $#
5714 shift $#
5667 ;;
5715 ;;
5668
5716
5669 services)
5717 services)
5670 action="services"
5718 action="services"
5671 shift
5719 shift
5672 rcstack_stack_services_parse_requirements "$@"
5720 rcstack_stack_services_parse_requirements "$@"
5673 shift $#
5721 shift $#
5674 ;;
5722 ;;
5675
5723
5676 rhodecode)
5724 rhodecode)
5677 action="rhodecode"
5725 action="rhodecode"
5678 shift
5726 shift
5679 rcstack_stack_rhodecode_parse_requirements "$@"
5727 rcstack_stack_rhodecode_parse_requirements "$@"
5680 shift $#
5728 shift $#
5681 ;;
5729 ;;
5682
5730
5683 all)
5731 all)
5684 action="all"
5732 action="all"
5685 shift
5733 shift
5686 rcstack_stack_all_parse_requirements "$@"
5734 rcstack_stack_all_parse_requirements "$@"
5687 shift $#
5735 shift $#
5688 ;;
5736 ;;
5689
5737
5690 # :command.command_fallback
5738 # :command.command_fallback
5691 "")
5739 "")
5692 rcstack_stack_usage >&2
5740 rcstack_stack_usage >&2
5693 exit 1
5741 exit 1
5694 ;;
5742 ;;
5695
5743
5696 *)
5744 *)
5697 printf "invalid command: %s\n" "$action" >&2
5745 printf "invalid command: %s\n" "$action" >&2
5698 exit 1
5746 exit 1
5699 ;;
5747 ;;
5700
5748
5701 esac
5749 esac
5702
5750
5703 # :command.parse_requirements_while
5751 # :command.parse_requirements_while
5704 while [[ $# -gt 0 ]]; do
5752 while [[ $# -gt 0 ]]; do
5705 key="$1"
5753 key="$1"
5706 case "$key" in
5754 case "$key" in
5707
5755
5708 -?*)
5756 -?*)
5709 printf "invalid option: %s\n" "$key" >&2
5757 printf "invalid option: %s\n" "$key" >&2
5710 exit 1
5758 exit 1
5711 ;;
5759 ;;
5712
5760
5713 *)
5761 *)
5714 # :command.parse_requirements_case
5762 # :command.parse_requirements_case
5715 # :command.parse_requirements_case_simple
5763 # :command.parse_requirements_case_simple
5716 printf "invalid argument: %s\n" "$key" >&2
5764 printf "invalid argument: %s\n" "$key" >&2
5717 exit 1
5765 exit 1
5718
5766
5719 ;;
5767 ;;
5720
5768
5721 esac
5769 esac
5722 done
5770 done
5723
5771
5724 # :command.default_assignments
5772 # :command.default_assignments
5725 [[ -n ${args['--env-file-path']:-} ]] || args['--env-file-path']="$PWD/.custom/.runtime.env"
5773 [[ -n ${args['--env-file-path']:-} ]] || args['--env-file-path']="$PWD/.custom/.runtime.env"
5726
5774
5727 }
5775 }
5728
5776
5729 # :command.parse_requirements
5777 # :command.parse_requirements
5730 rcstack_stack_router_parse_requirements() {
5778 rcstack_stack_router_parse_requirements() {
5731 # :command.fixed_flags_filter
5779 # :command.fixed_flags_filter
5732 while [[ $# -gt 0 ]]; do
5780 while [[ $# -gt 0 ]]; do
5733 case "${1:-}" in
5781 case "${1:-}" in
5734 --help | -h)
5782 --help | -h)
5735 long_usage=yes
5783 long_usage=yes
5736 rcstack_stack_router_usage
5784 rcstack_stack_router_usage
5737 exit
5785 exit
5738 ;;
5786 ;;
5739
5787
5740 *)
5788 *)
5741 break
5789 break
5742 ;;
5790 ;;
5743
5791
5744 esac
5792 esac
5745 done
5793 done
5746
5794
5747 # :command.command_filter
5795 # :command.command_filter
5748 action="stack router"
5796 action="stack router"
5749
5797
5750 # :command.parse_requirements_while
5798 # :command.parse_requirements_while
5751 while [[ $# -gt 0 ]]; do
5799 while [[ $# -gt 0 ]]; do
5752 key="$1"
5800 key="$1"
5753 case "$key" in
5801 case "$key" in
5754
5802
5755 --)
5803 --)
5756 shift
5804 shift
5757 other_args+=("$@")
5805 other_args+=("$@")
5758 break
5806 break
5759 ;;
5807 ;;
5760
5808
5761 -?*)
5809 -?*)
5762 other_args+=("$1")
5810 other_args+=("$1")
5763 shift
5811 shift
5764 ;;
5812 ;;
5765
5813
5766 *)
5814 *)
5767 # :command.parse_requirements_case
5815 # :command.parse_requirements_case
5768 # :command.parse_requirements_case_catch_all
5816 # :command.parse_requirements_case_catch_all
5769 other_args+=("$1")
5817 other_args+=("$1")
5770 shift
5818 shift
5771
5819
5772 ;;
5820 ;;
5773
5821
5774 esac
5822 esac
5775 done
5823 done
5776
5824
5777 }
5825 }
5778
5826
5779 # :command.parse_requirements
5827 # :command.parse_requirements
5780 rcstack_stack_metrics_parse_requirements() {
5828 rcstack_stack_metrics_parse_requirements() {
5781 # :command.fixed_flags_filter
5829 # :command.fixed_flags_filter
5782 while [[ $# -gt 0 ]]; do
5830 while [[ $# -gt 0 ]]; do
5783 case "${1:-}" in
5831 case "${1:-}" in
5784 --help | -h)
5832 --help | -h)
5785 long_usage=yes
5833 long_usage=yes
5786 rcstack_stack_metrics_usage
5834 rcstack_stack_metrics_usage
5787 exit
5835 exit
5788 ;;
5836 ;;
5789
5837
5790 *)
5838 *)
5791 break
5839 break
5792 ;;
5840 ;;
5793
5841
5794 esac
5842 esac
5795 done
5843 done
5796
5844
5797 # :command.command_filter
5845 # :command.command_filter
5798 action="stack metrics"
5846 action="stack metrics"
5799
5847
5800 # :command.parse_requirements_while
5848 # :command.parse_requirements_while
5801 while [[ $# -gt 0 ]]; do
5849 while [[ $# -gt 0 ]]; do
5802 key="$1"
5850 key="$1"
5803 case "$key" in
5851 case "$key" in
5804
5852
5805 --)
5853 --)
5806 shift
5854 shift
5807 other_args+=("$@")
5855 other_args+=("$@")
5808 break
5856 break
5809 ;;
5857 ;;
5810
5858
5811 -?*)
5859 -?*)
5812 other_args+=("$1")
5860 other_args+=("$1")
5813 shift
5861 shift
5814 ;;
5862 ;;
5815
5863
5816 *)
5864 *)
5817 # :command.parse_requirements_case
5865 # :command.parse_requirements_case
5818 # :command.parse_requirements_case_catch_all
5866 # :command.parse_requirements_case_catch_all
5819 other_args+=("$1")
5867 other_args+=("$1")
5820 shift
5868 shift
5821
5869
5822 ;;
5870 ;;
5823
5871
5824 esac
5872 esac
5825 done
5873 done
5826
5874
5827 }
5875 }
5828
5876
5829 # :command.parse_requirements
5877 # :command.parse_requirements
5830 rcstack_stack_services_parse_requirements() {
5878 rcstack_stack_services_parse_requirements() {
5831 # :command.fixed_flags_filter
5879 # :command.fixed_flags_filter
5832 while [[ $# -gt 0 ]]; do
5880 while [[ $# -gt 0 ]]; do
5833 case "${1:-}" in
5881 case "${1:-}" in
5834 --help | -h)
5882 --help | -h)
5835 long_usage=yes
5883 long_usage=yes
5836 rcstack_stack_services_usage
5884 rcstack_stack_services_usage
5837 exit
5885 exit
5838 ;;
5886 ;;
5839
5887
5840 *)
5888 *)
5841 break
5889 break
5842 ;;
5890 ;;
5843
5891
5844 esac
5892 esac
5845 done
5893 done
5846
5894
5847 # :command.command_filter
5895 # :command.command_filter
5848 action="stack services"
5896 action="stack services"
5849
5897
5850 # :command.parse_requirements_while
5898 # :command.parse_requirements_while
5851 while [[ $# -gt 0 ]]; do
5899 while [[ $# -gt 0 ]]; do
5852 key="$1"
5900 key="$1"
5853 case "$key" in
5901 case "$key" in
5854
5902
5855 --)
5903 --)
5856 shift
5904 shift
5857 other_args+=("$@")
5905 other_args+=("$@")
5858 break
5906 break
5859 ;;
5907 ;;
5860
5908
5861 -?*)
5909 -?*)
5862 other_args+=("$1")
5910 other_args+=("$1")
5863 shift
5911 shift
5864 ;;
5912 ;;
5865
5913
5866 *)
5914 *)
5867 # :command.parse_requirements_case
5915 # :command.parse_requirements_case
5868 # :command.parse_requirements_case_catch_all
5916 # :command.parse_requirements_case_catch_all
5869 other_args+=("$1")
5917 other_args+=("$1")
5870 shift
5918 shift
5871
5919
5872 ;;
5920 ;;
5873
5921
5874 esac
5922 esac
5875 done
5923 done
5876
5924
5877 }
5925 }
5878
5926
5879 # :command.parse_requirements
5927 # :command.parse_requirements
5880 rcstack_stack_rhodecode_parse_requirements() {
5928 rcstack_stack_rhodecode_parse_requirements() {
5881 # :command.fixed_flags_filter
5929 # :command.fixed_flags_filter
5882 while [[ $# -gt 0 ]]; do
5930 while [[ $# -gt 0 ]]; do
5883 case "${1:-}" in
5931 case "${1:-}" in
5884 --help | -h)
5932 --help | -h)
5885 long_usage=yes
5933 long_usage=yes
5886 rcstack_stack_rhodecode_usage
5934 rcstack_stack_rhodecode_usage
5887 exit
5935 exit
5888 ;;
5936 ;;
5889
5937
5890 *)
5938 *)
5891 break
5939 break
5892 ;;
5940 ;;
5893
5941
5894 esac
5942 esac
5895 done
5943 done
5896
5944
5897 # :command.command_filter
5945 # :command.command_filter
5898 action="stack rhodecode"
5946 action="stack rhodecode"
5899
5947
5900 # :command.parse_requirements_while
5948 # :command.parse_requirements_while
5901 while [[ $# -gt 0 ]]; do
5949 while [[ $# -gt 0 ]]; do
5902 key="$1"
5950 key="$1"
5903 case "$key" in
5951 case "$key" in
5904
5952
5905 --)
5953 --)
5906 shift
5954 shift
5907 other_args+=("$@")
5955 other_args+=("$@")
5908 break
5956 break
5909 ;;
5957 ;;
5910
5958
5911 -?*)
5959 -?*)
5912 other_args+=("$1")
5960 other_args+=("$1")
5913 shift
5961 shift
5914 ;;
5962 ;;
5915
5963
5916 *)
5964 *)
5917 # :command.parse_requirements_case
5965 # :command.parse_requirements_case
5918 # :command.parse_requirements_case_catch_all
5966 # :command.parse_requirements_case_catch_all
5919 other_args+=("$1")
5967 other_args+=("$1")
5920 shift
5968 shift
5921
5969
5922 ;;
5970 ;;
5923
5971
5924 esac
5972 esac
5925 done
5973 done
5926
5974
5927 }
5975 }
5928
5976
5929 # :command.parse_requirements
5977 # :command.parse_requirements
5930 rcstack_stack_all_parse_requirements() {
5978 rcstack_stack_all_parse_requirements() {
5931 # :command.fixed_flags_filter
5979 # :command.fixed_flags_filter
5932 while [[ $# -gt 0 ]]; do
5980 while [[ $# -gt 0 ]]; do
5933 case "${1:-}" in
5981 case "${1:-}" in
5934 --help | -h)
5982 --help | -h)
5935 long_usage=yes
5983 long_usage=yes
5936 rcstack_stack_all_usage
5984 rcstack_stack_all_usage
5937 exit
5985 exit
5938 ;;
5986 ;;
5939
5987
5940 *)
5988 *)
5941 break
5989 break
5942 ;;
5990 ;;
5943
5991
5944 esac
5992 esac
5945 done
5993 done
5946
5994
5947 # :command.command_filter
5995 # :command.command_filter
5948 action="stack all"
5996 action="stack all"
5949
5997
5950 # :command.parse_requirements_while
5998 # :command.parse_requirements_while
5951 while [[ $# -gt 0 ]]; do
5999 while [[ $# -gt 0 ]]; do
5952 key="$1"
6000 key="$1"
5953 case "$key" in
6001 case "$key" in
5954
6002
5955 --)
6003 --)
5956 shift
6004 shift
5957 other_args+=("$@")
6005 other_args+=("$@")
5958 break
6006 break
5959 ;;
6007 ;;
5960
6008
5961 -?*)
6009 -?*)
5962 other_args+=("$1")
6010 other_args+=("$1")
5963 shift
6011 shift
5964 ;;
6012 ;;
5965
6013
5966 *)
6014 *)
5967 # :command.parse_requirements_case
6015 # :command.parse_requirements_case
5968 # :command.parse_requirements_case_catch_all
6016 # :command.parse_requirements_case_catch_all
5969 other_args+=("$1")
6017 other_args+=("$1")
5970 shift
6018 shift
5971
6019
5972 ;;
6020 ;;
5973
6021
5974 esac
6022 esac
5975 done
6023 done
5976
6024
5977 }
6025 }
5978
6026
5979 # :command.parse_requirements
6027 # :command.parse_requirements
5980 rcstack_stack_status_parse_requirements() {
6028 rcstack_stack_status_parse_requirements() {
5981 # :command.fixed_flags_filter
6029 # :command.fixed_flags_filter
5982 while [[ $# -gt 0 ]]; do
6030 while [[ $# -gt 0 ]]; do
5983 case "${1:-}" in
6031 case "${1:-}" in
5984 --help | -h)
6032 --help | -h)
5985 long_usage=yes
6033 long_usage=yes
5986 rcstack_stack_status_usage
6034 rcstack_stack_status_usage
5987 exit
6035 exit
5988 ;;
6036 ;;
5989
6037
5990 *)
6038 *)
5991 break
6039 break
5992 ;;
6040 ;;
5993
6041
5994 esac
6042 esac
5995 done
6043 done
5996
6044
5997 # :command.command_filter
6045 # :command.command_filter
5998 action="stack-status"
6046 action="stack-status"
5999
6047
6000 # :command.parse_requirements_while
6048 # :command.parse_requirements_while
6001 while [[ $# -gt 0 ]]; do
6049 while [[ $# -gt 0 ]]; do
6002 key="$1"
6050 key="$1"
6003 case "$key" in
6051 case "$key" in
6004 # :flag.case
6052 # :flag.case
6005 --detailed)
6053 --detailed)
6006
6054
6007 # :flag.case_no_arg
6055 # :flag.case_no_arg
6008 args['--detailed']=1
6056 args['--detailed']=1
6009 shift
6057 shift
6010 ;;
6058 ;;
6011
6059
6012 # :flag.case
6060 # :flag.case
6013 --configs | -c)
6061 --configs | -c)
6014
6062
6015 # :flag.case_no_arg
6063 # :flag.case_no_arg
6016 args['--configs']=1
6064 args['--configs']=1
6017 shift
6065 shift
6018 ;;
6066 ;;
6019
6067
6020 # :flag.case
6068 # :flag.case
6021 --verbose | -v)
6069 --verbose | -v)
6022
6070
6023 # :flag.case_no_arg
6071 # :flag.case_no_arg
6024 args['--verbose']=1
6072 args['--verbose']=1
6025 shift
6073 shift
6026 ;;
6074 ;;
6027
6075
6028 -?*)
6076 -?*)
6029 printf "invalid option: %s\n" "$key" >&2
6077 printf "invalid option: %s\n" "$key" >&2
6030 exit 1
6078 exit 1
6031 ;;
6079 ;;
6032
6080
6033 *)
6081 *)
6034 # :command.parse_requirements_case
6082 # :command.parse_requirements_case
6035 # :command.parse_requirements_case_simple
6083 # :command.parse_requirements_case_simple
6036 printf "invalid argument: %s\n" "$key" >&2
6084 printf "invalid argument: %s\n" "$key" >&2
6037 exit 1
6085 exit 1
6038
6086
6039 ;;
6087 ;;
6040
6088
6041 esac
6089 esac
6042 done
6090 done
6043
6091
6044 }
6092 }
6045
6093
6046 # :command.parse_requirements
6094 # :command.parse_requirements
6047 rcstack_stack_upgrade_parse_requirements() {
6095 rcstack_stack_upgrade_parse_requirements() {
6048 # :command.fixed_flags_filter
6096 # :command.fixed_flags_filter
6049 while [[ $# -gt 0 ]]; do
6097 while [[ $# -gt 0 ]]; do
6050 case "${1:-}" in
6098 case "${1:-}" in
6051 --help | -h)
6099 --help | -h)
6052 long_usage=yes
6100 long_usage=yes
6053 rcstack_stack_upgrade_usage
6101 rcstack_stack_upgrade_usage
6054 exit
6102 exit
6055 ;;
6103 ;;
6056
6104
6057 # :flag.case
6105 # :flag.case
6058 --stack-prefix)
6106 --stack-prefix)
6059
6107
6060 # :flag.case_arg
6108 # :flag.case_arg
6061 if [[ -n ${2+x} ]]; then
6109 if [[ -n ${2+x} ]]; then
6062
6110
6063 args['--stack-prefix']="$2"
6111 args['--stack-prefix']="$2"
6064 shift
6112 shift
6065 shift
6113 shift
6066 else
6114 else
6067 printf "%s\n" "--stack-prefix requires an argument: --stack-prefix STACK_PREFIX" >&2
6115 printf "%s\n" "--stack-prefix requires an argument: --stack-prefix STACK_PREFIX" >&2
6068 exit 1
6116 exit 1
6069 fi
6117 fi
6070 ;;
6118 ;;
6071
6119
6072 *)
6120 *)
6073 break
6121 break
6074 ;;
6122 ;;
6075
6123
6076 esac
6124 esac
6077 done
6125 done
6078
6126
6079 # :command.command_filter
6127 # :command.command_filter
6080 action=${1:-}
6128 action=${1:-}
6081
6129
6082 case $action in
6130 case $action in
6083 -*) ;;
6131 -*) ;;
6084
6132
6085 router)
6133 router)
6086 action="router"
6134 action="router"
6087 shift
6135 shift
6088 rcstack_stack_upgrade_router_parse_requirements "$@"
6136 rcstack_stack_upgrade_router_parse_requirements "$@"
6089 shift $#
6137 shift $#
6090 ;;
6138 ;;
6091
6139
6092 services)
6140 services)
6093 action="services"
6141 action="services"
6094 shift
6142 shift
6095 rcstack_stack_upgrade_services_parse_requirements "$@"
6143 rcstack_stack_upgrade_services_parse_requirements "$@"
6096 shift $#
6144 shift $#
6097 ;;
6145 ;;
6098
6146
6099 metrics)
6147 metrics)
6100 action="metrics"
6148 action="metrics"
6101 shift
6149 shift
6102 rcstack_stack_upgrade_metrics_parse_requirements "$@"
6150 rcstack_stack_upgrade_metrics_parse_requirements "$@"
6103 shift $#
6151 shift $#
6104 ;;
6152 ;;
6105
6153
6106 rhodecode)
6154 rhodecode)
6107 action="rhodecode"
6155 action="rhodecode"
6108 shift
6156 shift
6109 rcstack_stack_upgrade_rhodecode_parse_requirements "$@"
6157 rcstack_stack_upgrade_rhodecode_parse_requirements "$@"
6110 shift $#
6158 shift $#
6111 ;;
6159 ;;
6112
6160
6113 # :command.command_fallback
6161 # :command.command_fallback
6114 "")
6162 "")
6115 rcstack_stack_upgrade_usage >&2
6163 rcstack_stack_upgrade_usage >&2
6116 exit 1
6164 exit 1
6117 ;;
6165 ;;
6118
6166
6119 *)
6167 *)
6120 printf "invalid command: %s\n" "$action" >&2
6168 printf "invalid command: %s\n" "$action" >&2
6121 exit 1
6169 exit 1
6122 ;;
6170 ;;
6123
6171
6124 esac
6172 esac
6125
6173
6126 # :command.parse_requirements_while
6174 # :command.parse_requirements_while
6127 while [[ $# -gt 0 ]]; do
6175 while [[ $# -gt 0 ]]; do
6128 key="$1"
6176 key="$1"
6129 case "$key" in
6177 case "$key" in
6130
6178
6131 -?*)
6179 -?*)
6132 printf "invalid option: %s\n" "$key" >&2
6180 printf "invalid option: %s\n" "$key" >&2
6133 exit 1
6181 exit 1
6134 ;;
6182 ;;
6135
6183
6136 *)
6184 *)
6137 # :command.parse_requirements_case
6185 # :command.parse_requirements_case
6138 # :command.parse_requirements_case_simple
6186 # :command.parse_requirements_case_simple
6139 printf "invalid argument: %s\n" "$key" >&2
6187 printf "invalid argument: %s\n" "$key" >&2
6140 exit 1
6188 exit 1
6141
6189
6142 ;;
6190 ;;
6143
6191
6144 esac
6192 esac
6145 done
6193 done
6146
6194
6147 }
6195 }
6148
6196
6149 # :command.parse_requirements
6197 # :command.parse_requirements
6150 rcstack_stack_upgrade_router_parse_requirements() {
6198 rcstack_stack_upgrade_router_parse_requirements() {
6151 # :command.fixed_flags_filter
6199 # :command.fixed_flags_filter
6152 while [[ $# -gt 0 ]]; do
6200 while [[ $# -gt 0 ]]; do
6153 case "${1:-}" in
6201 case "${1:-}" in
6154 --help | -h)
6202 --help | -h)
6155 long_usage=yes
6203 long_usage=yes
6156 rcstack_stack_upgrade_router_usage
6204 rcstack_stack_upgrade_router_usage
6157 exit
6205 exit
6158 ;;
6206 ;;
6159
6207
6160 *)
6208 *)
6161 break
6209 break
6162 ;;
6210 ;;
6163
6211
6164 esac
6212 esac
6165 done
6213 done
6166
6214
6167 # :command.command_filter
6215 # :command.command_filter
6168 action="stack-upgrade router"
6216 action="stack-upgrade router"
6169
6217
6170 # :command.parse_requirements_while
6218 # :command.parse_requirements_while
6171 while [[ $# -gt 0 ]]; do
6219 while [[ $# -gt 0 ]]; do
6172 key="$1"
6220 key="$1"
6173 case "$key" in
6221 case "$key" in
6174
6222
6175 -?*)
6223 -?*)
6176 printf "invalid option: %s\n" "$key" >&2
6224 printf "invalid option: %s\n" "$key" >&2
6177 exit 1
6225 exit 1
6178 ;;
6226 ;;
6179
6227
6180 *)
6228 *)
6181 # :command.parse_requirements_case
6229 # :command.parse_requirements_case
6182 # :command.parse_requirements_case_simple
6230 # :command.parse_requirements_case_simple
6183 printf "invalid argument: %s\n" "$key" >&2
6231 printf "invalid argument: %s\n" "$key" >&2
6184 exit 1
6232 exit 1
6185
6233
6186 ;;
6234 ;;
6187
6235
6188 esac
6236 esac
6189 done
6237 done
6190
6238
6191 }
6239 }
6192
6240
6193 # :command.parse_requirements
6241 # :command.parse_requirements
6194 rcstack_stack_upgrade_services_parse_requirements() {
6242 rcstack_stack_upgrade_services_parse_requirements() {
6195 # :command.fixed_flags_filter
6243 # :command.fixed_flags_filter
6196 while [[ $# -gt 0 ]]; do
6244 while [[ $# -gt 0 ]]; do
6197 case "${1:-}" in
6245 case "${1:-}" in
6198 --help | -h)
6246 --help | -h)
6199 long_usage=yes
6247 long_usage=yes
6200 rcstack_stack_upgrade_services_usage
6248 rcstack_stack_upgrade_services_usage
6201 exit
6249 exit
6202 ;;
6250 ;;
6203
6251
6204 *)
6252 *)
6205 break
6253 break
6206 ;;
6254 ;;
6207
6255
6208 esac
6256 esac
6209 done
6257 done
6210
6258
6211 # :command.command_filter
6259 # :command.command_filter
6212 action="stack-upgrade services"
6260 action="stack-upgrade services"
6213
6261
6214 # :command.parse_requirements_while
6262 # :command.parse_requirements_while
6215 while [[ $# -gt 0 ]]; do
6263 while [[ $# -gt 0 ]]; do
6216 key="$1"
6264 key="$1"
6217 case "$key" in
6265 case "$key" in
6218
6266
6219 -?*)
6267 -?*)
6220 printf "invalid option: %s\n" "$key" >&2
6268 printf "invalid option: %s\n" "$key" >&2
6221 exit 1
6269 exit 1
6222 ;;
6270 ;;
6223
6271
6224 *)
6272 *)
6225 # :command.parse_requirements_case
6273 # :command.parse_requirements_case
6226 # :command.parse_requirements_case_simple
6274 # :command.parse_requirements_case_simple
6227 printf "invalid argument: %s\n" "$key" >&2
6275 printf "invalid argument: %s\n" "$key" >&2
6228 exit 1
6276 exit 1
6229
6277
6230 ;;
6278 ;;
6231
6279
6232 esac
6280 esac
6233 done
6281 done
6234
6282
6235 }
6283 }
6236
6284
6237 # :command.parse_requirements
6285 # :command.parse_requirements
6238 rcstack_stack_upgrade_metrics_parse_requirements() {
6286 rcstack_stack_upgrade_metrics_parse_requirements() {
6239 # :command.fixed_flags_filter
6287 # :command.fixed_flags_filter
6240 while [[ $# -gt 0 ]]; do
6288 while [[ $# -gt 0 ]]; do
6241 case "${1:-}" in
6289 case "${1:-}" in
6242 --help | -h)
6290 --help | -h)
6243 long_usage=yes
6291 long_usage=yes
6244 rcstack_stack_upgrade_metrics_usage
6292 rcstack_stack_upgrade_metrics_usage
6245 exit
6293 exit
6246 ;;
6294 ;;
6247
6295
6248 *)
6296 *)
6249 break
6297 break
6250 ;;
6298 ;;
6251
6299
6252 esac
6300 esac
6253 done
6301 done
6254
6302
6255 # :command.command_filter
6303 # :command.command_filter
6256 action="stack-upgrade metrics"
6304 action="stack-upgrade metrics"
6257
6305
6258 # :command.parse_requirements_while
6306 # :command.parse_requirements_while
6259 while [[ $# -gt 0 ]]; do
6307 while [[ $# -gt 0 ]]; do
6260 key="$1"
6308 key="$1"
6261 case "$key" in
6309 case "$key" in
6262
6310
6263 -?*)
6311 -?*)
6264 printf "invalid option: %s\n" "$key" >&2
6312 printf "invalid option: %s\n" "$key" >&2
6265 exit 1
6313 exit 1
6266 ;;
6314 ;;
6267
6315
6268 *)
6316 *)
6269 # :command.parse_requirements_case
6317 # :command.parse_requirements_case
6270 # :command.parse_requirements_case_simple
6318 # :command.parse_requirements_case_simple
6271 printf "invalid argument: %s\n" "$key" >&2
6319 printf "invalid argument: %s\n" "$key" >&2
6272 exit 1
6320 exit 1
6273
6321
6274 ;;
6322 ;;
6275
6323
6276 esac
6324 esac
6277 done
6325 done
6278
6326
6279 }
6327 }
6280
6328
6281 # :command.parse_requirements
6329 # :command.parse_requirements
6282 rcstack_stack_upgrade_rhodecode_parse_requirements() {
6330 rcstack_stack_upgrade_rhodecode_parse_requirements() {
6283 # :command.fixed_flags_filter
6331 # :command.fixed_flags_filter
6284 while [[ $# -gt 0 ]]; do
6332 while [[ $# -gt 0 ]]; do
6285 case "${1:-}" in
6333 case "${1:-}" in
6286 --help | -h)
6334 --help | -h)
6287 long_usage=yes
6335 long_usage=yes
6288 rcstack_stack_upgrade_rhodecode_usage
6336 rcstack_stack_upgrade_rhodecode_usage
6289 exit
6337 exit
6290 ;;
6338 ;;
6291
6339
6292 *)
6340 *)
6293 break
6341 break
6294 ;;
6342 ;;
6295
6343
6296 esac
6344 esac
6297 done
6345 done
6298
6346
6299 # :command.command_filter
6347 # :command.command_filter
6300 action="stack-upgrade rhodecode"
6348 action="stack-upgrade rhodecode"
6301
6349
6302 # :command.parse_requirements_while
6350 # :command.parse_requirements_while
6303 while [[ $# -gt 0 ]]; do
6351 while [[ $# -gt 0 ]]; do
6304 key="$1"
6352 key="$1"
6305 case "$key" in
6353 case "$key" in
6306 # :flag.case
6354 # :flag.case
6307 --stop-wait)
6355 --stop-wait)
6308
6356
6309 # :flag.case_arg
6357 # :flag.case_arg
6310 if [[ -n ${2+x} ]]; then
6358 if [[ -n ${2+x} ]]; then
6311
6359
6312 args['--stop-wait']="$2"
6360 args['--stop-wait']="$2"
6313 shift
6361 shift
6314 shift
6362 shift
6315 else
6363 else
6316 printf "%s\n" "--stop-wait requires an argument: --stop-wait STOP_WAIT" >&2
6364 printf "%s\n" "--stop-wait requires an argument: --stop-wait STOP_WAIT" >&2
6317 exit 1
6365 exit 1
6318 fi
6366 fi
6319 ;;
6367 ;;
6320
6368
6321 # :flag.case
6369 # :flag.case
6322 --docker-stop-wait)
6370 --docker-stop-wait)
6323
6371
6324 # :flag.case_arg
6372 # :flag.case_arg
6325 if [[ -n ${2+x} ]]; then
6373 if [[ -n ${2+x} ]]; then
6326
6374
6327 args['--docker-stop-wait']="$2"
6375 args['--docker-stop-wait']="$2"
6328 shift
6376 shift
6329 shift
6377 shift
6330 else
6378 else
6331 printf "%s\n" "--docker-stop-wait requires an argument: --docker-stop-wait DOCKER_STOP_WAIT" >&2
6379 printf "%s\n" "--docker-stop-wait requires an argument: --docker-stop-wait DOCKER_STOP_WAIT" >&2
6332 exit 1
6380 exit 1
6333 fi
6381 fi
6334 ;;
6382 ;;
6335
6383
6336 -?*)
6384 -?*)
6337 printf "invalid option: %s\n" "$key" >&2
6385 printf "invalid option: %s\n" "$key" >&2
6338 exit 1
6386 exit 1
6339 ;;
6387 ;;
6340
6388
6341 *)
6389 *)
6342 # :command.parse_requirements_case
6390 # :command.parse_requirements_case
6343 # :command.parse_requirements_case_simple
6391 # :command.parse_requirements_case_simple
6344 printf "invalid argument: %s\n" "$key" >&2
6392 printf "invalid argument: %s\n" "$key" >&2
6345 exit 1
6393 exit 1
6346
6394
6347 ;;
6395 ;;
6348
6396
6349 esac
6397 esac
6350 done
6398 done
6351
6399
6352 # :command.default_assignments
6400 # :command.default_assignments
6353 [[ -n ${args['--stop-wait']:-} ]] || args['--stop-wait']="120"
6401 [[ -n ${args['--stop-wait']:-} ]] || args['--stop-wait']="120"
6354 [[ -n ${args['--docker-stop-wait']:-} ]] || args['--docker-stop-wait']="3600"
6402 [[ -n ${args['--docker-stop-wait']:-} ]] || args['--docker-stop-wait']="3600"
6355
6403
6356 }
6404 }
6357
6405
6358 # :command.parse_requirements
6406 # :command.parse_requirements
6359 rcstack_stack_monitor_parse_requirements() {
6407 rcstack_stack_monitor_parse_requirements() {
6360 # :command.fixed_flags_filter
6408 # :command.fixed_flags_filter
6361 while [[ $# -gt 0 ]]; do
6409 while [[ $# -gt 0 ]]; do
6362 case "${1:-}" in
6410 case "${1:-}" in
6363 --help | -h)
6411 --help | -h)
6364 long_usage=yes
6412 long_usage=yes
6365 rcstack_stack_monitor_usage
6413 rcstack_stack_monitor_usage
6366 exit
6414 exit
6367 ;;
6415 ;;
6368
6416
6369 *)
6417 *)
6370 break
6418 break
6371 ;;
6419 ;;
6372
6420
6373 esac
6421 esac
6374 done
6422 done
6375
6423
6376 # :command.command_filter
6424 # :command.command_filter
6377 action=${1:-}
6425 action=${1:-}
6378
6426
6379 case $action in
6427 case $action in
6380 -*) ;;
6428 -*) ;;
6381
6429
6382 restart-unhealthy)
6430 restart-unhealthy)
6383 action="restart-unhealthy"
6431 action="restart-unhealthy"
6384 shift
6432 shift
6385 rcstack_stack_monitor_restart_unhealthy_parse_requirements "$@"
6433 rcstack_stack_monitor_restart_unhealthy_parse_requirements "$@"
6386 shift $#
6434 shift $#
6387 ;;
6435 ;;
6388
6436
6389 # :command.command_fallback
6437 # :command.command_fallback
6390 "")
6438 "")
6391 rcstack_stack_monitor_usage >&2
6439 rcstack_stack_monitor_usage >&2
6392 exit 1
6440 exit 1
6393 ;;
6441 ;;
6394
6442
6395 *)
6443 *)
6396 printf "invalid command: %s\n" "$action" >&2
6444 printf "invalid command: %s\n" "$action" >&2
6397 exit 1
6445 exit 1
6398 ;;
6446 ;;
6399
6447
6400 esac
6448 esac
6401
6449
6402 # :command.parse_requirements_while
6450 # :command.parse_requirements_while
6403 while [[ $# -gt 0 ]]; do
6451 while [[ $# -gt 0 ]]; do
6404 key="$1"
6452 key="$1"
6405 case "$key" in
6453 case "$key" in
6406
6454
6407 -?*)
6455 -?*)
6408 printf "invalid option: %s\n" "$key" >&2
6456 printf "invalid option: %s\n" "$key" >&2
6409 exit 1
6457 exit 1
6410 ;;
6458 ;;
6411
6459
6412 *)
6460 *)
6413 # :command.parse_requirements_case
6461 # :command.parse_requirements_case
6414 # :command.parse_requirements_case_simple
6462 # :command.parse_requirements_case_simple
6415 printf "invalid argument: %s\n" "$key" >&2
6463 printf "invalid argument: %s\n" "$key" >&2
6416 exit 1
6464 exit 1
6417
6465
6418 ;;
6466 ;;
6419
6467
6420 esac
6468 esac
6421 done
6469 done
6422
6470
6423 }
6471 }
6424
6472
6425 # :command.parse_requirements
6473 # :command.parse_requirements
6426 rcstack_stack_monitor_restart_unhealthy_parse_requirements() {
6474 rcstack_stack_monitor_restart_unhealthy_parse_requirements() {
6427 # :command.fixed_flags_filter
6475 # :command.fixed_flags_filter
6428 while [[ $# -gt 0 ]]; do
6476 while [[ $# -gt 0 ]]; do
6429 case "${1:-}" in
6477 case "${1:-}" in
6430 --help | -h)
6478 --help | -h)
6431 long_usage=yes
6479 long_usage=yes
6432 rcstack_stack_monitor_restart_unhealthy_usage
6480 rcstack_stack_monitor_restart_unhealthy_usage
6433 exit
6481 exit
6434 ;;
6482 ;;
6435
6483
6436 *)
6484 *)
6437 break
6485 break
6438 ;;
6486 ;;
6439
6487
6440 esac
6488 esac
6441 done
6489 done
6442
6490
6443 # :command.command_filter
6491 # :command.command_filter
6444 action="stack-monitor restart-unhealthy"
6492 action="stack-monitor restart-unhealthy"
6445
6493
6446 # :command.parse_requirements_while
6494 # :command.parse_requirements_while
6447 while [[ $# -gt 0 ]]; do
6495 while [[ $# -gt 0 ]]; do
6448 key="$1"
6496 key="$1"
6449 case "$key" in
6497 case "$key" in
6450 # :flag.case
6498 # :flag.case
6451 --loop)
6499 --loop)
6452
6500
6453 # :flag.case_arg
6501 # :flag.case_arg
6454 if [[ -n ${2+x} ]]; then
6502 if [[ -n ${2+x} ]]; then
6455 # :flag.validations
6503 # :flag.validations
6456 if [[ -n $(validate_integer "$2") ]]; then
6504 if [[ -n $(validate_integer "$2") ]]; then
6457 printf "validation error in %s:\n%s\n" "--loop LOOP" "$(validate_integer "$2")" >&2
6505 printf "validation error in %s:\n%s\n" "--loop LOOP" "$(validate_integer "$2")" >&2
6458 exit 1
6506 exit 1
6459 fi
6507 fi
6460
6508
6461 args['--loop']="$2"
6509 args['--loop']="$2"
6462 shift
6510 shift
6463 shift
6511 shift
6464 else
6512 else
6465 printf "%s\n" "--loop requires an argument: --loop LOOP" >&2
6513 printf "%s\n" "--loop requires an argument: --loop LOOP" >&2
6466 exit 1
6514 exit 1
6467 fi
6515 fi
6468 ;;
6516 ;;
6469
6517
6470 -?*)
6518 -?*)
6471 printf "invalid option: %s\n" "$key" >&2
6519 printf "invalid option: %s\n" "$key" >&2
6472 exit 1
6520 exit 1
6473 ;;
6521 ;;
6474
6522
6475 *)
6523 *)
6476 # :command.parse_requirements_case
6524 # :command.parse_requirements_case
6477 # :command.parse_requirements_case_simple
6525 # :command.parse_requirements_case_simple
6478 printf "invalid argument: %s\n" "$key" >&2
6526 printf "invalid argument: %s\n" "$key" >&2
6479 exit 1
6527 exit 1
6480
6528
6481 ;;
6529 ;;
6482
6530
6483 esac
6531 esac
6484 done
6532 done
6485
6533
6486 # :command.default_assignments
6534 # :command.default_assignments
6487 [[ -n ${args['--loop']:-} ]] || args['--loop']="0"
6535 [[ -n ${args['--loop']:-} ]] || args['--loop']="0"
6488
6536
6489 }
6537 }
6490
6538
6491 # :command.parse_requirements
6539 # :command.parse_requirements
6492 rcstack_cli_parse_requirements() {
6540 rcstack_cli_parse_requirements() {
6493 # :command.fixed_flags_filter
6541 # :command.fixed_flags_filter
6494 while [[ $# -gt 0 ]]; do
6542 while [[ $# -gt 0 ]]; do
6495 case "${1:-}" in
6543 case "${1:-}" in
6496 --help | -h)
6544 --help | -h)
6497 long_usage=yes
6545 long_usage=yes
6498 rcstack_cli_usage
6546 rcstack_cli_usage
6499 exit
6547 exit
6500 ;;
6548 ;;
6501
6549
6502 *)
6550 *)
6503 break
6551 break
6504 ;;
6552 ;;
6505
6553
6506 esac
6554 esac
6507 done
6555 done
6508
6556
6509 # :command.command_filter
6557 # :command.command_filter
6510 action=${1:-}
6558 action=${1:-}
6511
6559
6512 case $action in
6560 case $action in
6513 -*) ;;
6561 -*) ;;
6514
6562
6515 cmd)
6563 cmd)
6516 action="cmd"
6564 action="cmd"
6517 shift
6565 shift
6518 rcstack_cli_cmd_parse_requirements "$@"
6566 rcstack_cli_cmd_parse_requirements "$@"
6519 shift $#
6567 shift $#
6520 ;;
6568 ;;
6521
6569
6522 ishell)
6570 ishell)
6523 action="ishell"
6571 action="ishell"
6524 shift
6572 shift
6525 rcstack_cli_ishell_parse_requirements "$@"
6573 rcstack_cli_ishell_parse_requirements "$@"
6526 shift $#
6574 shift $#
6527 ;;
6575 ;;
6528
6576
6529 image-info)
6577 image-info)
6530 action="image-info"
6578 action="image-info"
6531 shift
6579 shift
6532 rcstack_cli_image_info_parse_requirements "$@"
6580 rcstack_cli_image_info_parse_requirements "$@"
6533 shift $#
6581 shift $#
6534 ;;
6582 ;;
6535
6583
6584 set-image)
6585 action="set-image"
6586 shift
6587 rcstack_cli_set_image_parse_requirements "$@"
6588 shift $#
6589 ;;
6590
6536 set-runtime-image)
6591 set-runtime-image)
6537 action="set-runtime-image"
6592 action="set-runtime-image"
6538 shift
6593 shift
6539 rcstack_cli_set_runtime_image_parse_requirements "$@"
6594 deprecated_cli_set_runtime_image_parse_requirements "$@"
6540 shift $#
6595 shift $#
6541 ;;
6596 ;;
6542
6597
6543 docker-info)
6598 docker-info)
6544 action="docker-info"
6599 action="docker-info"
6545 shift
6600 shift
6546 rcstack_cli_docker_info_parse_requirements "$@"
6601 rcstack_cli_docker_info_parse_requirements "$@"
6547 shift $#
6602 shift $#
6548 ;;
6603 ;;
6549
6604
6550 docker-upgrade)
6605 docker-upgrade)
6551 action="docker-upgrade"
6606 action="docker-upgrade"
6552 shift
6607 shift
6553 rcstack_cli_docker_upgrade_parse_requirements "$@"
6608 rcstack_cli_docker_upgrade_parse_requirements "$@"
6554 shift $#
6609 shift $#
6555 ;;
6610 ;;
6556
6611
6557 redis)
6612 redis)
6558 action="redis"
6613 action="redis"
6559 shift
6614 shift
6560 rcstack_cli_redis_parse_requirements "$@"
6615 rcstack_cli_redis_parse_requirements "$@"
6561 shift $#
6616 shift $#
6562 ;;
6617 ;;
6563
6618
6564 db)
6619 db)
6565 action="db"
6620 action="db"
6566 shift
6621 shift
6567 rcstack_cli_db_parse_requirements "$@"
6622 rcstack_cli_db_parse_requirements "$@"
6568 shift $#
6623 shift $#
6569 ;;
6624 ;;
6570
6625
6571 db-upgrade)
6626 db-upgrade)
6572 action="db-upgrade"
6627 action="db-upgrade"
6573 shift
6628 shift
6574 rcstack_cli_db_upgrade_parse_requirements "$@"
6629 rcstack_cli_db_upgrade_parse_requirements "$@"
6575 shift $#
6630 shift $#
6576 ;;
6631 ;;
6577
6632
6578 storage)
6633 storage)
6579 action="storage"
6634 action="storage"
6580 shift
6635 shift
6581 rcstack_cli_storage_parse_requirements "$@"
6636 rcstack_cli_storage_parse_requirements "$@"
6582 shift $#
6637 shift $#
6583 ;;
6638 ;;
6584
6639
6585 attach)
6640 attach)
6586 action="attach"
6641 action="attach"
6587 shift
6642 shift
6588 rcstack_cli_attach_parse_requirements "$@"
6643 rcstack_cli_attach_parse_requirements "$@"
6589 shift $#
6644 shift $#
6590 ;;
6645 ;;
6591
6646
6592 set-edition)
6647 set-edition)
6593 action="set-edition"
6648 action="set-edition"
6594 shift
6649 shift
6595 rcstack_cli_set_edition_parse_requirements "$@"
6650 rcstack_cli_set_edition_parse_requirements "$@"
6596 shift $#
6651 shift $#
6597 ;;
6652 ;;
6598
6653
6599 configure-vcsserver)
6654 configure-vcsserver)
6600 action="configure-vcsserver"
6655 action="configure-vcsserver"
6601 shift
6656 shift
6602 rcstack_cli_configure_vcsserver_parse_requirements "$@"
6657 rcstack_cli_configure_vcsserver_parse_requirements "$@"
6603 shift $#
6658 shift $#
6604 ;;
6659 ;;
6605
6660
6606 configure-rhodecode)
6661 configure-rhodecode)
6607 action="configure-rhodecode"
6662 action="configure-rhodecode"
6608 shift
6663 shift
6609 rcstack_cli_configure_rhodecode_parse_requirements "$@"
6664 rcstack_cli_configure_rhodecode_parse_requirements "$@"
6610 shift $#
6665 shift $#
6611 ;;
6666 ;;
6612
6667
6613 # :command.command_fallback
6668 # :command.command_fallback
6614 "")
6669 "")
6615 rcstack_cli_usage >&2
6670 rcstack_cli_usage >&2
6616 exit 1
6671 exit 1
6617 ;;
6672 ;;
6618
6673
6619 *)
6674 *)
6620 printf "invalid command: %s\n" "$action" >&2
6675 printf "invalid command: %s\n" "$action" >&2
6621 exit 1
6676 exit 1
6622 ;;
6677 ;;
6623
6678
6624 esac
6679 esac
6625
6680
6626 # :command.parse_requirements_while
6681 # :command.parse_requirements_while
6627 while [[ $# -gt 0 ]]; do
6682 while [[ $# -gt 0 ]]; do
6628 key="$1"
6683 key="$1"
6629 case "$key" in
6684 case "$key" in
6630
6685
6631 -?*)
6686 -?*)
6632 printf "invalid option: %s\n" "$key" >&2
6687 printf "invalid option: %s\n" "$key" >&2
6633 exit 1
6688 exit 1
6634 ;;
6689 ;;
6635
6690
6636 *)
6691 *)
6637 # :command.parse_requirements_case
6692 # :command.parse_requirements_case
6638 # :command.parse_requirements_case_simple
6693 # :command.parse_requirements_case_simple
6639 printf "invalid argument: %s\n" "$key" >&2
6694 printf "invalid argument: %s\n" "$key" >&2
6640 exit 1
6695 exit 1
6641
6696
6642 ;;
6697 ;;
6643
6698
6644 esac
6699 esac
6645 done
6700 done
6646
6701
6647 }
6702 }
6648
6703
6649 # :command.parse_requirements
6704 # :command.parse_requirements
6650 rcstack_cli_cmd_parse_requirements() {
6705 rcstack_cli_cmd_parse_requirements() {
6651 # :command.fixed_flags_filter
6706 # :command.fixed_flags_filter
6652 while [[ $# -gt 0 ]]; do
6707 while [[ $# -gt 0 ]]; do
6653 case "${1:-}" in
6708 case "${1:-}" in
6654 --help | -h)
6709 --help | -h)
6655 long_usage=yes
6710 long_usage=yes
6656 rcstack_cli_cmd_usage
6711 rcstack_cli_cmd_usage
6657 exit
6712 exit
6658 ;;
6713 ;;
6659
6714
6660 *)
6715 *)
6661 break
6716 break
6662 ;;
6717 ;;
6663
6718
6664 esac
6719 esac
6665 done
6720 done
6666
6721
6667 # :command.command_filter
6722 # :command.command_filter
6668 action="cli cmd"
6723 action="cli cmd"
6669
6724
6670 # :command.parse_requirements_while
6725 # :command.parse_requirements_while
6671 while [[ $# -gt 0 ]]; do
6726 while [[ $# -gt 0 ]]; do
6672 key="$1"
6727 key="$1"
6673 case "$key" in
6728 case "$key" in
6674 # :flag.case
6729 # :flag.case
6675 --no-tty)
6730 --no-tty)
6676
6731
6677 # :flag.case_no_arg
6732 # :flag.case_no_arg
6678 args['--no-tty']=1
6733 args['--no-tty']=1
6679 shift
6734 shift
6680 ;;
6735 ;;
6681
6736
6682 # :flag.case
6737 # :flag.case
6683 --user)
6738 --user)
6684
6739
6685 # :flag.case_no_arg
6740 # :flag.case_no_arg
6686 args['--user']=1
6741 args['--user']=1
6687 shift
6742 shift
6688 ;;
6743 ;;
6689
6744
6690 # :flag.case
6745 # :flag.case
6691 --env-file-path)
6746 --env-file-path)
6692
6747
6693 # :flag.case_arg
6748 # :flag.case_arg
6694 if [[ -n ${2+x} ]]; then
6749 if [[ -n ${2+x} ]]; then
6695 # :flag.validations
6750 # :flag.validations
6696 if [[ -n $(validate_file_exists "$2") ]]; then
6751 if [[ -n $(validate_file_exists "$2") ]]; then
6697 printf "validation error in %s:\n%s\n" "--env-file-path ENV_FILE_PATH" "$(validate_file_exists "$2")" >&2
6752 printf "validation error in %s:\n%s\n" "--env-file-path ENV_FILE_PATH" "$(validate_file_exists "$2")" >&2
6698 exit 1
6753 exit 1
6699 fi
6754 fi
6700
6755
6701 args['--env-file-path']="$2"
6756 args['--env-file-path']="$2"
6702 shift
6757 shift
6703 shift
6758 shift
6704 else
6759 else
6705 printf "%s\n" "--env-file-path requires an argument: --env-file-path ENV_FILE_PATH" >&2
6760 printf "%s\n" "--env-file-path requires an argument: --env-file-path ENV_FILE_PATH" >&2
6706 exit 1
6761 exit 1
6707 fi
6762 fi
6708 ;;
6763 ;;
6709
6764
6710 --)
6765 --)
6711 shift
6766 shift
6712 other_args+=("$@")
6767 other_args+=("$@")
6713 break
6768 break
6714 ;;
6769 ;;
6715
6770
6716 -?*)
6771 -?*)
6717 other_args+=("$1")
6772 other_args+=("$1")
6718 shift
6773 shift
6719 ;;
6774 ;;
6720
6775
6721 *)
6776 *)
6722 # :command.parse_requirements_case
6777 # :command.parse_requirements_case
6723 # :command.parse_requirements_case_catch_all
6778 # :command.parse_requirements_case_catch_all
6724 other_args+=("$1")
6779 other_args+=("$1")
6725 shift
6780 shift
6726
6781
6727 ;;
6782 ;;
6728
6783
6729 esac
6784 esac
6730 done
6785 done
6731
6786
6732 # :command.default_assignments
6787 # :command.default_assignments
6733 [[ -n ${args['--env-file-path']:-} ]] || args['--env-file-path']="$PWD/.custom/.runtime.env"
6788 [[ -n ${args['--env-file-path']:-} ]] || args['--env-file-path']="$PWD/.custom/.runtime.env"
6734
6789
6735 }
6790 }
6736
6791
6737 # :command.parse_requirements
6792 # :command.parse_requirements
6738 rcstack_cli_ishell_parse_requirements() {
6793 rcstack_cli_ishell_parse_requirements() {
6739 # :command.fixed_flags_filter
6794 # :command.fixed_flags_filter
6740 while [[ $# -gt 0 ]]; do
6795 while [[ $# -gt 0 ]]; do
6741 case "${1:-}" in
6796 case "${1:-}" in
6742 --help | -h)
6797 --help | -h)
6743 long_usage=yes
6798 long_usage=yes
6744 rcstack_cli_ishell_usage
6799 rcstack_cli_ishell_usage
6745 exit
6800 exit
6746 ;;
6801 ;;
6747
6802
6748 *)
6803 *)
6749 break
6804 break
6750 ;;
6805 ;;
6751
6806
6752 esac
6807 esac
6753 done
6808 done
6754
6809
6755 # :command.command_filter
6810 # :command.command_filter
6756 action="cli ishell"
6811 action="cli ishell"
6757
6812
6758 # :command.parse_requirements_while
6813 # :command.parse_requirements_while
6759 while [[ $# -gt 0 ]]; do
6814 while [[ $# -gt 0 ]]; do
6760 key="$1"
6815 key="$1"
6761 case "$key" in
6816 case "$key" in
6762 # :flag.case
6817 # :flag.case
6763 --no-tty)
6818 --no-tty)
6764
6819
6765 # :flag.case_no_arg
6820 # :flag.case_no_arg
6766 args['--no-tty']=1
6821 args['--no-tty']=1
6767 shift
6822 shift
6768 ;;
6823 ;;
6769
6824
6770 # :flag.case
6825 # :flag.case
6771 --user)
6826 --user)
6772
6827
6773 # :flag.case_no_arg
6828 # :flag.case_no_arg
6774 args['--user']=1
6829 args['--user']=1
6775 shift
6830 shift
6776 ;;
6831 ;;
6777
6832
6778 # :flag.case
6833 # :flag.case
6779 --env-file-path)
6834 --env-file-path)
6780
6835
6781 # :flag.case_arg
6836 # :flag.case_arg
6782 if [[ -n ${2+x} ]]; then
6837 if [[ -n ${2+x} ]]; then
6783 # :flag.validations
6838 # :flag.validations
6784 if [[ -n $(validate_file_exists "$2") ]]; then
6839 if [[ -n $(validate_file_exists "$2") ]]; then
6785 printf "validation error in %s:\n%s\n" "--env-file-path ENV_FILE_PATH" "$(validate_file_exists "$2")" >&2
6840 printf "validation error in %s:\n%s\n" "--env-file-path ENV_FILE_PATH" "$(validate_file_exists "$2")" >&2
6786 exit 1
6841 exit 1
6787 fi
6842 fi
6788
6843
6789 args['--env-file-path']="$2"
6844 args['--env-file-path']="$2"
6790 shift
6845 shift
6791 shift
6846 shift
6792 else
6847 else
6793 printf "%s\n" "--env-file-path requires an argument: --env-file-path ENV_FILE_PATH" >&2
6848 printf "%s\n" "--env-file-path requires an argument: --env-file-path ENV_FILE_PATH" >&2
6794 exit 1
6849 exit 1
6795 fi
6850 fi
6796 ;;
6851 ;;
6797
6852
6798 -?*)
6853 -?*)
6799 printf "invalid option: %s\n" "$key" >&2
6854 printf "invalid option: %s\n" "$key" >&2
6800 exit 1
6855 exit 1
6801 ;;
6856 ;;
6802
6857
6803 *)
6858 *)
6804 # :command.parse_requirements_case
6859 # :command.parse_requirements_case
6805 # :command.parse_requirements_case_simple
6860 # :command.parse_requirements_case_simple
6806 printf "invalid argument: %s\n" "$key" >&2
6861 printf "invalid argument: %s\n" "$key" >&2
6807 exit 1
6862 exit 1
6808
6863
6809 ;;
6864 ;;
6810
6865
6811 esac
6866 esac
6812 done
6867 done
6813
6868
6814 # :command.default_assignments
6869 # :command.default_assignments
6815 [[ -n ${args['--env-file-path']:-} ]] || args['--env-file-path']="$PWD/.custom/.runtime.env"
6870 [[ -n ${args['--env-file-path']:-} ]] || args['--env-file-path']="$PWD/.custom/.runtime.env"
6816
6871
6817 }
6872 }
6818
6873
6819 # :command.parse_requirements
6874 # :command.parse_requirements
6820 rcstack_cli_image_info_parse_requirements() {
6875 rcstack_cli_image_info_parse_requirements() {
6821 # :command.fixed_flags_filter
6876 # :command.fixed_flags_filter
6822 while [[ $# -gt 0 ]]; do
6877 while [[ $# -gt 0 ]]; do
6823 case "${1:-}" in
6878 case "${1:-}" in
6824 --help | -h)
6879 --help | -h)
6825 long_usage=yes
6880 long_usage=yes
6826 rcstack_cli_image_info_usage
6881 rcstack_cli_image_info_usage
6827 exit
6882 exit
6828 ;;
6883 ;;
6829
6884
6830 *)
6885 *)
6831 break
6886 break
6832 ;;
6887 ;;
6833
6888
6834 esac
6889 esac
6835 done
6890 done
6836
6891
6837 # :command.command_filter
6892 # :command.command_filter
6838 action="cli image-info"
6893 action="cli image-info"
6839
6894
6840 # :command.parse_requirements_while
6895 # :command.parse_requirements_while
6841 while [[ $# -gt 0 ]]; do
6896 while [[ $# -gt 0 ]]; do
6842 key="$1"
6897 key="$1"
6843 case "$key" in
6898 case "$key" in
6844 # :flag.case
6899 # :flag.case
6845 --verbose)
6900 --verbose)
6846
6901
6847 # :flag.case_no_arg
6902 # :flag.case_no_arg
6848 args['--verbose']=1
6903 args['--verbose']=1
6849 shift
6904 shift
6850 ;;
6905 ;;
6851
6906
6852 -?*)
6907 -?*)
6853 printf "invalid option: %s\n" "$key" >&2
6908 printf "invalid option: %s\n" "$key" >&2
6854 exit 1
6909 exit 1
6855 ;;
6910 ;;
6856
6911
6857 *)
6912 *)
6858 # :command.parse_requirements_case
6913 # :command.parse_requirements_case
6859 # :command.parse_requirements_case_simple
6914 # :command.parse_requirements_case_simple
6860 printf "invalid argument: %s\n" "$key" >&2
6915 printf "invalid argument: %s\n" "$key" >&2
6861 exit 1
6916 exit 1
6862
6917
6863 ;;
6918 ;;
6864
6919
6865 esac
6920 esac
6866 done
6921 done
6867
6922
6868 }
6923 }
6869
6924
6870 # :command.parse_requirements
6925 # :command.parse_requirements
6871 rcstack_cli_set_runtime_image_parse_requirements() {
6926 rcstack_cli_set_image_parse_requirements() {
6927 # :command.fixed_flags_filter
6928 while [[ $# -gt 0 ]]; do
6929 case "${1:-}" in
6930 --help | -h)
6931 long_usage=yes
6932 rcstack_cli_set_image_usage
6933 exit
6934 ;;
6935
6936 *)
6937 break
6938 ;;
6939
6940 esac
6941 done
6942
6943 # :command.command_filter
6944 action="cli set-image"
6945
6946 # :command.parse_requirements_while
6947 while [[ $# -gt 0 ]]; do
6948 key="$1"
6949 case "$key" in
6950
6951 -?*)
6952 printf "invalid option: %s\n" "$key" >&2
6953 exit 1
6954 ;;
6955
6956 *)
6957 # :command.parse_requirements_case
6958 # :command.parse_requirements_case_simple
6959 if [[ -z ${args['version']+x} ]]; then
6960
6961 args['version']=$1
6962 shift
6963 else
6964 printf "invalid argument: %s\n" "$key" >&2
6965 exit 1
6966 fi
6967
6968 ;;
6969
6970 esac
6971 done
6972
6973 # :command.required_args_filter
6974 if [[ -z ${args['version']+x} ]]; then
6975 printf "missing required argument: VERSION\nusage: rcstack cli set-image VERSION\n" >&2
6976 exit 1
6977 fi
6978
6979 }
6980
6981 # :command.parse_requirements
6982 deprecated_cli_set_runtime_image_parse_requirements() {
6872 # :command.fixed_flags_filter
6983 # :command.fixed_flags_filter
6873 while [[ $# -gt 0 ]]; do
6984 while [[ $# -gt 0 ]]; do
6874 case "${1:-}" in
6985 case "${1:-}" in
6875 --help | -h)
6986 --help | -h)
6876 long_usage=yes
6987 long_usage=yes
6877 rcstack_cli_set_runtime_image_usage
6988 deprecated_cli_set_runtime_image_usage
6878 exit
6989 exit
6879 ;;
6990 ;;
6880
6991
6881 *)
6992 *)
6882 break
6993 break
6883 ;;
6994 ;;
6884
6995
6885 esac
6996 esac
6886 done
6997 done
6887
6998
6888 # :command.command_filter
6999 # :command.command_filter
6889 action="cli set-runtime-image"
7000 action="cli set-runtime-image"
6890
7001
6891 # :command.parse_requirements_while
7002 # :command.parse_requirements_while
6892 while [[ $# -gt 0 ]]; do
7003 while [[ $# -gt 0 ]]; do
6893 key="$1"
7004 key="$1"
6894 case "$key" in
7005 case "$key" in
6895
7006
6896 -?*)
7007 -?*)
6897 printf "invalid option: %s\n" "$key" >&2
7008 printf "invalid option: %s\n" "$key" >&2
6898 exit 1
7009 exit 1
6899 ;;
7010 ;;
6900
7011
6901 *)
7012 *)
6902 # :command.parse_requirements_case
7013 # :command.parse_requirements_case
6903 # :command.parse_requirements_case_simple
7014 # :command.parse_requirements_case_simple
6904 if [[ -z ${args['version']+x} ]]; then
7015 if [[ -z ${args['version']+x} ]]; then
6905
7016
6906 args['version']=$1
7017 args['version']=$1
6907 shift
7018 shift
6908 else
7019 else
6909 printf "invalid argument: %s\n" "$key" >&2
7020 printf "invalid argument: %s\n" "$key" >&2
6910 exit 1
7021 exit 1
6911 fi
7022 fi
6912
7023
6913 ;;
7024 ;;
6914
7025
6915 esac
7026 esac
6916 done
7027 done
6917
7028
6918 # :command.required_args_filter
7029 # :command.required_args_filter
6919 if [[ -z ${args['version']+x} ]]; then
7030 if [[ -z ${args['version']+x} ]]; then
6920 printf "missing required argument: VERSION\nusage: rcstack cli set-runtime-image VERSION\n" >&2
7031 printf "missing required argument: VERSION\nusage: rcstack cli set-runtime-image VERSION\n" >&2
6921 exit 1
7032 exit 1
6922 fi
7033 fi
6923
7034
6924 }
7035 }
6925
7036
6926 # :command.parse_requirements
7037 # :command.parse_requirements
6927 rcstack_cli_docker_info_parse_requirements() {
7038 rcstack_cli_docker_info_parse_requirements() {
6928 # :command.fixed_flags_filter
7039 # :command.fixed_flags_filter
6929 while [[ $# -gt 0 ]]; do
7040 while [[ $# -gt 0 ]]; do
6930 case "${1:-}" in
7041 case "${1:-}" in
6931 --help | -h)
7042 --help | -h)
6932 long_usage=yes
7043 long_usage=yes
6933 rcstack_cli_docker_info_usage
7044 rcstack_cli_docker_info_usage
6934 exit
7045 exit
6935 ;;
7046 ;;
6936
7047
6937 *)
7048 *)
6938 break
7049 break
6939 ;;
7050 ;;
6940
7051
6941 esac
7052 esac
6942 done
7053 done
6943
7054
6944 # :command.command_filter
7055 # :command.command_filter
6945 action="cli docker-info"
7056 action="cli docker-info"
6946
7057
6947 # :command.parse_requirements_while
7058 # :command.parse_requirements_while
6948 while [[ $# -gt 0 ]]; do
7059 while [[ $# -gt 0 ]]; do
6949 key="$1"
7060 key="$1"
6950 case "$key" in
7061 case "$key" in
6951 # :flag.case
7062 # :flag.case
6952 --verbose)
7063 --verbose)
6953
7064
6954 # :flag.case_no_arg
7065 # :flag.case_no_arg
6955 args['--verbose']=1
7066 args['--verbose']=1
6956 shift
7067 shift
6957 ;;
7068 ;;
6958
7069
6959 -?*)
7070 -?*)
6960 printf "invalid option: %s\n" "$key" >&2
7071 printf "invalid option: %s\n" "$key" >&2
6961 exit 1
7072 exit 1
6962 ;;
7073 ;;
6963
7074
6964 *)
7075 *)
6965 # :command.parse_requirements_case
7076 # :command.parse_requirements_case
6966 # :command.parse_requirements_case_simple
7077 # :command.parse_requirements_case_simple
6967 printf "invalid argument: %s\n" "$key" >&2
7078 printf "invalid argument: %s\n" "$key" >&2
6968 exit 1
7079 exit 1
6969
7080
6970 ;;
7081 ;;
6971
7082
6972 esac
7083 esac
6973 done
7084 done
6974
7085
6975 }
7086 }
6976
7087
6977 # :command.parse_requirements
7088 # :command.parse_requirements
6978 rcstack_cli_docker_upgrade_parse_requirements() {
7089 rcstack_cli_docker_upgrade_parse_requirements() {
6979 # :command.fixed_flags_filter
7090 # :command.fixed_flags_filter
6980 while [[ $# -gt 0 ]]; do
7091 while [[ $# -gt 0 ]]; do
6981 case "${1:-}" in
7092 case "${1:-}" in
6982 --help | -h)
7093 --help | -h)
6983 long_usage=yes
7094 long_usage=yes
6984 rcstack_cli_docker_upgrade_usage
7095 rcstack_cli_docker_upgrade_usage
6985 exit
7096 exit
6986 ;;
7097 ;;
6987
7098
6988 *)
7099 *)
6989 break
7100 break
6990 ;;
7101 ;;
6991
7102
6992 esac
7103 esac
6993 done
7104 done
6994
7105
6995 # :command.command_filter
7106 # :command.command_filter
6996 action="cli docker-upgrade"
7107 action="cli docker-upgrade"
6997
7108
6998 # :command.parse_requirements_while
7109 # :command.parse_requirements_while
6999 while [[ $# -gt 0 ]]; do
7110 while [[ $# -gt 0 ]]; do
7000 key="$1"
7111 key="$1"
7001 case "$key" in
7112 case "$key" in
7002 # :flag.case
7113 # :flag.case
7003 --compose)
7114 --compose)
7004
7115
7005 # :flag.case_no_arg
7116 # :flag.case_no_arg
7006 args['--compose']=1
7117 args['--compose']=1
7007 shift
7118 shift
7008 ;;
7119 ;;
7009
7120
7010 -?*)
7121 -?*)
7011 printf "invalid option: %s\n" "$key" >&2
7122 printf "invalid option: %s\n" "$key" >&2
7012 exit 1
7123 exit 1
7013 ;;
7124 ;;
7014
7125
7015 *)
7126 *)
7016 # :command.parse_requirements_case
7127 # :command.parse_requirements_case
7017 # :command.parse_requirements_case_simple
7128 # :command.parse_requirements_case_simple
7018 printf "invalid argument: %s\n" "$key" >&2
7129 printf "invalid argument: %s\n" "$key" >&2
7019 exit 1
7130 exit 1
7020
7131
7021 ;;
7132 ;;
7022
7133
7023 esac
7134 esac
7024 done
7135 done
7025
7136
7026 }
7137 }
7027
7138
7028 # :command.parse_requirements
7139 # :command.parse_requirements
7029 rcstack_cli_redis_parse_requirements() {
7140 rcstack_cli_redis_parse_requirements() {
7030 # :command.fixed_flags_filter
7141 # :command.fixed_flags_filter
7031 while [[ $# -gt 0 ]]; do
7142 while [[ $# -gt 0 ]]; do
7032 case "${1:-}" in
7143 case "${1:-}" in
7033 --help | -h)
7144 --help | -h)
7034 long_usage=yes
7145 long_usage=yes
7035 rcstack_cli_redis_usage
7146 rcstack_cli_redis_usage
7036 exit
7147 exit
7037 ;;
7148 ;;
7038
7149
7039 *)
7150 *)
7040 break
7151 break
7041 ;;
7152 ;;
7042
7153
7043 esac
7154 esac
7044 done
7155 done
7045
7156
7046 # :command.command_filter
7157 # :command.command_filter
7047 action="cli redis"
7158 action="cli redis"
7048
7159
7049 # :command.parse_requirements_while
7160 # :command.parse_requirements_while
7050 while [[ $# -gt 0 ]]; do
7161 while [[ $# -gt 0 ]]; do
7051 key="$1"
7162 key="$1"
7052 case "$key" in
7163 case "$key" in
7053 # :flag.case
7164 # :flag.case
7054 --no-tty)
7165 --no-tty)
7055
7166
7056 # :flag.case_no_arg
7167 # :flag.case_no_arg
7057 args['--no-tty']=1
7168 args['--no-tty']=1
7058 shift
7169 shift
7059 ;;
7170 ;;
7060
7171
7061 # :flag.case
7172 # :flag.case
7062 --user)
7173 --user)
7063
7174
7064 # :flag.case_no_arg
7175 # :flag.case_no_arg
7065 args['--user']=1
7176 args['--user']=1
7066 shift
7177 shift
7067 ;;
7178 ;;
7068
7179
7069 # :flag.case
7180 # :flag.case
7070 --env-file-path)
7181 --env-file-path)
7071
7182
7072 # :flag.case_arg
7183 # :flag.case_arg
7073 if [[ -n ${2+x} ]]; then
7184 if [[ -n ${2+x} ]]; then
7074 # :flag.validations
7185 # :flag.validations
7075 if [[ -n $(validate_file_exists "$2") ]]; then
7186 if [[ -n $(validate_file_exists "$2") ]]; then
7076 printf "validation error in %s:\n%s\n" "--env-file-path ENV_FILE_PATH" "$(validate_file_exists "$2")" >&2
7187 printf "validation error in %s:\n%s\n" "--env-file-path ENV_FILE_PATH" "$(validate_file_exists "$2")" >&2
7077 exit 1
7188 exit 1
7078 fi
7189 fi
7079
7190
7080 args['--env-file-path']="$2"
7191 args['--env-file-path']="$2"
7081 shift
7192 shift
7082 shift
7193 shift
7083 else
7194 else
7084 printf "%s\n" "--env-file-path requires an argument: --env-file-path ENV_FILE_PATH" >&2
7195 printf "%s\n" "--env-file-path requires an argument: --env-file-path ENV_FILE_PATH" >&2
7085 exit 1
7196 exit 1
7086 fi
7197 fi
7087 ;;
7198 ;;
7088
7199
7089 # :flag.case
7200 # :flag.case
7090 --db)
7201 --db)
7091
7202
7092 # :flag.case_arg
7203 # :flag.case_arg
7093 if [[ -n ${2+x} ]]; then
7204 if [[ -n ${2+x} ]]; then
7094
7205
7095 args['--db']="$2"
7206 args['--db']="$2"
7096 shift
7207 shift
7097 shift
7208 shift
7098 else
7209 else
7099 printf "%s\n" "--db requires an argument: --db DB" >&2
7210 printf "%s\n" "--db requires an argument: --db DB" >&2
7100 exit 1
7211 exit 1
7101 fi
7212 fi
7102 ;;
7213 ;;
7103
7214
7104 -?*)
7215 -?*)
7105 printf "invalid option: %s\n" "$key" >&2
7216 printf "invalid option: %s\n" "$key" >&2
7106 exit 1
7217 exit 1
7107 ;;
7218 ;;
7108
7219
7109 *)
7220 *)
7110 # :command.parse_requirements_case
7221 # :command.parse_requirements_case
7111 # :command.parse_requirements_case_simple
7222 # :command.parse_requirements_case_simple
7112 printf "invalid argument: %s\n" "$key" >&2
7223 printf "invalid argument: %s\n" "$key" >&2
7113 exit 1
7224 exit 1
7114
7225
7115 ;;
7226 ;;
7116
7227
7117 esac
7228 esac
7118 done
7229 done
7119
7230
7120 # :command.default_assignments
7231 # :command.default_assignments
7121 [[ -n ${args['--env-file-path']:-} ]] || args['--env-file-path']="$PWD/.custom/.runtime.env"
7232 [[ -n ${args['--env-file-path']:-} ]] || args['--env-file-path']="$PWD/.custom/.runtime.env"
7122 [[ -n ${args['--db']:-} ]] || args['--db']="0"
7233 [[ -n ${args['--db']:-} ]] || args['--db']="0"
7123
7234
7124 }
7235 }
7125
7236
7126 # :command.parse_requirements
7237 # :command.parse_requirements
7127 rcstack_cli_db_parse_requirements() {
7238 rcstack_cli_db_parse_requirements() {
7128 # :command.fixed_flags_filter
7239 # :command.fixed_flags_filter
7129 while [[ $# -gt 0 ]]; do
7240 while [[ $# -gt 0 ]]; do
7130 case "${1:-}" in
7241 case "${1:-}" in
7131 --help | -h)
7242 --help | -h)
7132 long_usage=yes
7243 long_usage=yes
7133 rcstack_cli_db_usage
7244 rcstack_cli_db_usage
7134 exit
7245 exit
7135 ;;
7246 ;;
7136
7247
7137 *)
7248 *)
7138 break
7249 break
7139 ;;
7250 ;;
7140
7251
7141 esac
7252 esac
7142 done
7253 done
7143
7254
7144 # :command.command_filter
7255 # :command.command_filter
7145 action="cli db"
7256 action="cli db"
7146
7257
7147 # :command.parse_requirements_while
7258 # :command.parse_requirements_while
7148 while [[ $# -gt 0 ]]; do
7259 while [[ $# -gt 0 ]]; do
7149 key="$1"
7260 key="$1"
7150 case "$key" in
7261 case "$key" in
7151 # :flag.case
7262 # :flag.case
7152 --no-tty)
7263 --no-tty)
7153
7264
7154 # :flag.case_no_arg
7265 # :flag.case_no_arg
7155 args['--no-tty']=1
7266 args['--no-tty']=1
7156 shift
7267 shift
7157 ;;
7268 ;;
7158
7269
7159 # :flag.case
7270 # :flag.case
7160 --user)
7271 --user)
7161
7272
7162 # :flag.case_no_arg
7273 # :flag.case_no_arg
7163 args['--user']=1
7274 args['--user']=1
7164 shift
7275 shift
7165 ;;
7276 ;;
7166
7277
7167 # :flag.case
7278 # :flag.case
7168 --env-file-path)
7279 --env-file-path)
7169
7280
7170 # :flag.case_arg
7281 # :flag.case_arg
7171 if [[ -n ${2+x} ]]; then
7282 if [[ -n ${2+x} ]]; then
7172 # :flag.validations
7283 # :flag.validations
7173 if [[ -n $(validate_file_exists "$2") ]]; then
7284 if [[ -n $(validate_file_exists "$2") ]]; then
7174 printf "validation error in %s:\n%s\n" "--env-file-path ENV_FILE_PATH" "$(validate_file_exists "$2")" >&2
7285 printf "validation error in %s:\n%s\n" "--env-file-path ENV_FILE_PATH" "$(validate_file_exists "$2")" >&2
7175 exit 1
7286 exit 1
7176 fi
7287 fi
7177
7288
7178 args['--env-file-path']="$2"
7289 args['--env-file-path']="$2"
7179 shift
7290 shift
7180 shift
7291 shift
7181 else
7292 else
7182 printf "%s\n" "--env-file-path requires an argument: --env-file-path ENV_FILE_PATH" >&2
7293 printf "%s\n" "--env-file-path requires an argument: --env-file-path ENV_FILE_PATH" >&2
7183 exit 1
7294 exit 1
7184 fi
7295 fi
7185 ;;
7296 ;;
7186
7297
7187 -?*)
7298 -?*)
7188 printf "invalid option: %s\n" "$key" >&2
7299 printf "invalid option: %s\n" "$key" >&2
7189 exit 1
7300 exit 1
7190 ;;
7301 ;;
7191
7302
7192 *)
7303 *)
7193 # :command.parse_requirements_case
7304 # :command.parse_requirements_case
7194 # :command.parse_requirements_case_simple
7305 # :command.parse_requirements_case_simple
7195 printf "invalid argument: %s\n" "$key" >&2
7306 printf "invalid argument: %s\n" "$key" >&2
7196 exit 1
7307 exit 1
7197
7308
7198 ;;
7309 ;;
7199
7310
7200 esac
7311 esac
7201 done
7312 done
7202
7313
7203 # :command.default_assignments
7314 # :command.default_assignments
7204 [[ -n ${args['--env-file-path']:-} ]] || args['--env-file-path']="$PWD/.custom/.runtime.env"
7315 [[ -n ${args['--env-file-path']:-} ]] || args['--env-file-path']="$PWD/.custom/.runtime.env"
7205
7316
7206 }
7317 }
7207
7318
7208 # :command.parse_requirements
7319 # :command.parse_requirements
7209 rcstack_cli_db_upgrade_parse_requirements() {
7320 rcstack_cli_db_upgrade_parse_requirements() {
7210 # :command.fixed_flags_filter
7321 # :command.fixed_flags_filter
7211 while [[ $# -gt 0 ]]; do
7322 while [[ $# -gt 0 ]]; do
7212 case "${1:-}" in
7323 case "${1:-}" in
7213 --help | -h)
7324 --help | -h)
7214 long_usage=yes
7325 long_usage=yes
7215 rcstack_cli_db_upgrade_usage
7326 rcstack_cli_db_upgrade_usage
7216 exit
7327 exit
7217 ;;
7328 ;;
7218
7329
7219 *)
7330 *)
7220 break
7331 break
7221 ;;
7332 ;;
7222
7333
7223 esac
7334 esac
7224 done
7335 done
7225
7336
7226 # :command.command_filter
7337 # :command.command_filter
7227 action="cli db-upgrade"
7338 action="cli db-upgrade"
7228
7339
7229 # :command.parse_requirements_while
7340 # :command.parse_requirements_while
7230 while [[ $# -gt 0 ]]; do
7341 while [[ $# -gt 0 ]]; do
7231 key="$1"
7342 key="$1"
7232 case "$key" in
7343 case "$key" in
7233
7344
7234 -?*)
7345 -?*)
7235 printf "invalid option: %s\n" "$key" >&2
7346 printf "invalid option: %s\n" "$key" >&2
7236 exit 1
7347 exit 1
7237 ;;
7348 ;;
7238
7349
7239 *)
7350 *)
7240 # :command.parse_requirements_case
7351 # :command.parse_requirements_case
7241 # :command.parse_requirements_case_simple
7352 # :command.parse_requirements_case_simple
7242 printf "invalid argument: %s\n" "$key" >&2
7353 printf "invalid argument: %s\n" "$key" >&2
7243 exit 1
7354 exit 1
7244
7355
7245 ;;
7356 ;;
7246
7357
7247 esac
7358 esac
7248 done
7359 done
7249
7360
7250 }
7361 }
7251
7362
7252 # :command.parse_requirements
7363 # :command.parse_requirements
7253 rcstack_cli_storage_parse_requirements() {
7364 rcstack_cli_storage_parse_requirements() {
7254 # :command.fixed_flags_filter
7365 # :command.fixed_flags_filter
7255 while [[ $# -gt 0 ]]; do
7366 while [[ $# -gt 0 ]]; do
7256 case "${1:-}" in
7367 case "${1:-}" in
7257 --help | -h)
7368 --help | -h)
7258 long_usage=yes
7369 long_usage=yes
7259 rcstack_cli_storage_usage
7370 rcstack_cli_storage_usage
7260 exit
7371 exit
7261 ;;
7372 ;;
7262
7373
7263 *)
7374 *)
7264 break
7375 break
7265 ;;
7376 ;;
7266
7377
7267 esac
7378 esac
7268 done
7379 done
7269
7380
7270 # :command.command_filter
7381 # :command.command_filter
7271 action="cli storage"
7382 action="cli storage"
7272
7383
7273 # :command.parse_requirements_while
7384 # :command.parse_requirements_while
7274 while [[ $# -gt 0 ]]; do
7385 while [[ $# -gt 0 ]]; do
7275 key="$1"
7386 key="$1"
7276 case "$key" in
7387 case "$key" in
7277 # :flag.case
7388 # :flag.case
7278 --no-tty)
7389 --no-tty)
7279
7390
7280 # :flag.case_no_arg
7391 # :flag.case_no_arg
7281 args['--no-tty']=1
7392 args['--no-tty']=1
7282 shift
7393 shift
7283 ;;
7394 ;;
7284
7395
7285 # :flag.case
7396 # :flag.case
7286 --attached)
7397 --attached)
7287
7398
7288 # :flag.case_arg
7399 # :flag.case_arg
7289 if [[ -n ${2+x} ]]; then
7400 if [[ -n ${2+x} ]]; then
7290
7401
7291 args['--attached']="$2"
7402 args['--attached']="$2"
7292 shift
7403 shift
7293 shift
7404 shift
7294 else
7405 else
7295 printf "%s\n" "--attached requires an argument: --attached ATTACHED" >&2
7406 printf "%s\n" "--attached requires an argument: --attached ATTACHED" >&2
7296 exit 1
7407 exit 1
7297 fi
7408 fi
7298 ;;
7409 ;;
7299
7410
7300 -?*)
7411 -?*)
7301 printf "invalid option: %s\n" "$key" >&2
7412 printf "invalid option: %s\n" "$key" >&2
7302 exit 1
7413 exit 1
7303 ;;
7414 ;;
7304
7415
7305 *)
7416 *)
7306 # :command.parse_requirements_case
7417 # :command.parse_requirements_case
7307 # :command.parse_requirements_case_simple
7418 # :command.parse_requirements_case_simple
7308 printf "invalid argument: %s\n" "$key" >&2
7419 printf "invalid argument: %s\n" "$key" >&2
7309 exit 1
7420 exit 1
7310
7421
7311 ;;
7422 ;;
7312
7423
7313 esac
7424 esac
7314 done
7425 done
7315
7426
7316 }
7427 }
7317
7428
7318 # :command.parse_requirements
7429 # :command.parse_requirements
7319 rcstack_cli_attach_parse_requirements() {
7430 rcstack_cli_attach_parse_requirements() {
7320 # :command.fixed_flags_filter
7431 # :command.fixed_flags_filter
7321 while [[ $# -gt 0 ]]; do
7432 while [[ $# -gt 0 ]]; do
7322 case "${1:-}" in
7433 case "${1:-}" in
7323 --help | -h)
7434 --help | -h)
7324 long_usage=yes
7435 long_usage=yes
7325 rcstack_cli_attach_usage
7436 rcstack_cli_attach_usage
7326 exit
7437 exit
7327 ;;
7438 ;;
7328
7439
7329 *)
7440 *)
7330 break
7441 break
7331 ;;
7442 ;;
7332
7443
7333 esac
7444 esac
7334 done
7445 done
7335
7446
7336 # :command.command_filter
7447 # :command.command_filter
7337 action="cli attach"
7448 action="cli attach"
7338
7449
7339 # :command.parse_requirements_while
7450 # :command.parse_requirements_while
7340 while [[ $# -gt 0 ]]; do
7451 while [[ $# -gt 0 ]]; do
7341 key="$1"
7452 key="$1"
7342 case "$key" in
7453 case "$key" in
7343 # :flag.case
7454 # :flag.case
7344 --no-tty)
7455 --no-tty)
7345
7456
7346 # :flag.case_no_arg
7457 # :flag.case_no_arg
7347 args['--no-tty']=1
7458 args['--no-tty']=1
7348 shift
7459 shift
7349 ;;
7460 ;;
7350
7461
7351 # :flag.case
7462 # :flag.case
7352 --instance-type)
7463 --instance-type)
7353
7464
7354 # :flag.case_arg
7465 # :flag.case_arg
7355 if [[ -n ${2+x} ]]; then
7466 if [[ -n ${2+x} ]]; then
7356
7467
7357 args['--instance-type']="$2"
7468 args['--instance-type']="$2"
7358 shift
7469 shift
7359 shift
7470 shift
7360 else
7471 else
7361 printf "%s\n" "--instance-type requires an argument: --instance-type INSTANCE_TYPE" >&2
7472 printf "%s\n" "--instance-type requires an argument: --instance-type INSTANCE_TYPE" >&2
7362 exit 1
7473 exit 1
7363 fi
7474 fi
7364 ;;
7475 ;;
7365
7476
7366 -?*)
7477 -?*)
7367 printf "invalid option: %s\n" "$key" >&2
7478 printf "invalid option: %s\n" "$key" >&2
7368 exit 1
7479 exit 1
7369 ;;
7480 ;;
7370
7481
7371 *)
7482 *)
7372 # :command.parse_requirements_case
7483 # :command.parse_requirements_case
7373 # :command.parse_requirements_case_simple
7484 # :command.parse_requirements_case_simple
7374 printf "invalid argument: %s\n" "$key" >&2
7485 printf "invalid argument: %s\n" "$key" >&2
7375 exit 1
7486 exit 1
7376
7487
7377 ;;
7488 ;;
7378
7489
7379 esac
7490 esac
7380 done
7491 done
7381
7492
7382 # :command.default_assignments
7493 # :command.default_assignments
7383 [[ -n ${args['--instance-type']:-} ]] || args['--instance-type']="rhodecode"
7494 [[ -n ${args['--instance-type']:-} ]] || args['--instance-type']="rhodecode"
7384
7495
7385 }
7496 }
7386
7497
7387 # :command.parse_requirements
7498 # :command.parse_requirements
7388 rcstack_cli_set_edition_parse_requirements() {
7499 rcstack_cli_set_edition_parse_requirements() {
7389 # :command.fixed_flags_filter
7500 # :command.fixed_flags_filter
7390 while [[ $# -gt 0 ]]; do
7501 while [[ $# -gt 0 ]]; do
7391 case "${1:-}" in
7502 case "${1:-}" in
7392 --help | -h)
7503 --help | -h)
7393 long_usage=yes
7504 long_usage=yes
7394 rcstack_cli_set_edition_usage
7505 rcstack_cli_set_edition_usage
7395 exit
7506 exit
7396 ;;
7507 ;;
7397
7508
7398 *)
7509 *)
7399 break
7510 break
7400 ;;
7511 ;;
7401
7512
7402 esac
7513 esac
7403 done
7514 done
7404
7515
7405 # :command.command_filter
7516 # :command.command_filter
7406 action="cli set-edition"
7517 action="cli set-edition"
7407
7518
7408 # :command.parse_requirements_while
7519 # :command.parse_requirements_while
7409 while [[ $# -gt 0 ]]; do
7520 while [[ $# -gt 0 ]]; do
7410 key="$1"
7521 key="$1"
7411 case "$key" in
7522 case "$key" in
7412
7523
7413 -?*)
7524 -?*)
7414 printf "invalid option: %s\n" "$key" >&2
7525 printf "invalid option: %s\n" "$key" >&2
7415 exit 1
7526 exit 1
7416 ;;
7527 ;;
7417
7528
7418 *)
7529 *)
7419 # :command.parse_requirements_case
7530 # :command.parse_requirements_case
7420 # :command.parse_requirements_case_simple
7531 # :command.parse_requirements_case_simple
7421 if [[ -z ${args['edition_type']+x} ]]; then
7532 if [[ -z ${args['edition_type']+x} ]]; then
7422
7533
7423 args['edition_type']=$1
7534 args['edition_type']=$1
7424 shift
7535 shift
7425 else
7536 else
7426 printf "invalid argument: %s\n" "$key" >&2
7537 printf "invalid argument: %s\n" "$key" >&2
7427 exit 1
7538 exit 1
7428 fi
7539 fi
7429
7540
7430 ;;
7541 ;;
7431
7542
7432 esac
7543 esac
7433 done
7544 done
7434
7545
7435 # :command.required_args_filter
7546 # :command.required_args_filter
7436 if [[ -z ${args['edition_type']+x} ]]; then
7547 if [[ -z ${args['edition_type']+x} ]]; then
7437 printf "missing required argument: EDITION_TYPE\nusage: rcstack cli set-edition EDITION_TYPE\n" >&2
7548 printf "missing required argument: EDITION_TYPE\nusage: rcstack cli set-edition EDITION_TYPE\n" >&2
7438 exit 1
7549 exit 1
7439 fi
7550 fi
7440
7551
7441 # :command.whitelist_filter
7552 # :command.whitelist_filter
7442 if [[ -n ${args['edition_type']} ]] && [[ ! ${args['edition_type']} =~ ^(ce|ee)$ ]]; then
7553 if [[ -n ${args['edition_type']} ]] && [[ ! ${args['edition_type']} =~ ^(ce|ee)$ ]]; then
7443 printf "%s\n" "edition_type must be one of: ce, ee" >&2
7554 printf "%s\n" "edition_type must be one of: ce, ee" >&2
7444 exit 1
7555 exit 1
7445 fi
7556 fi
7446
7557
7447 }
7558 }
7448
7559
7449 # :command.parse_requirements
7560 # :command.parse_requirements
7450 rcstack_cli_configure_vcsserver_parse_requirements() {
7561 rcstack_cli_configure_vcsserver_parse_requirements() {
7451 # :command.fixed_flags_filter
7562 # :command.fixed_flags_filter
7452 while [[ $# -gt 0 ]]; do
7563 while [[ $# -gt 0 ]]; do
7453 case "${1:-}" in
7564 case "${1:-}" in
7454 --help | -h)
7565 --help | -h)
7455 long_usage=yes
7566 long_usage=yes
7456 rcstack_cli_configure_vcsserver_usage
7567 rcstack_cli_configure_vcsserver_usage
7457 exit
7568 exit
7458 ;;
7569 ;;
7459
7570
7460 *)
7571 *)
7461 break
7572 break
7462 ;;
7573 ;;
7463
7574
7464 esac
7575 esac
7465 done
7576 done
7466
7577
7467 # :command.command_filter
7578 # :command.command_filter
7468 action="cli configure-vcsserver"
7579 action="cli configure-vcsserver"
7469
7580
7470 # :command.parse_requirements_while
7581 # :command.parse_requirements_while
7471 while [[ $# -gt 0 ]]; do
7582 while [[ $# -gt 0 ]]; do
7472 key="$1"
7583 key="$1"
7473 case "$key" in
7584 case "$key" in
7474
7585
7475 -?*)
7586 -?*)
7476 printf "invalid option: %s\n" "$key" >&2
7587 printf "invalid option: %s\n" "$key" >&2
7477 exit 1
7588 exit 1
7478 ;;
7589 ;;
7479
7590
7480 *)
7591 *)
7481 # :command.parse_requirements_case
7592 # :command.parse_requirements_case
7482 # :command.parse_requirements_case_simple
7593 # :command.parse_requirements_case_simple
7483 if [[ -z ${args['ini_path']+x} ]]; then
7594 if [[ -z ${args['ini_path']+x} ]]; then
7484 # :argument.validations
7595 # :argument.validations
7485 if [[ -n $(validate_file_exists "$1") ]]; then
7596 if [[ -n $(validate_file_exists "$1") ]]; then
7486 printf "validation error in %s:\n%s\n" "INI_PATH" "$(validate_file_exists "$1")" >&2
7597 printf "validation error in %s:\n%s\n" "INI_PATH" "$(validate_file_exists "$1")" >&2
7487 exit 1
7598 exit 1
7488 fi
7599 fi
7489
7600
7490 args['ini_path']=$1
7601 args['ini_path']=$1
7491 shift
7602 shift
7492 else
7603 else
7493 printf "invalid argument: %s\n" "$key" >&2
7604 printf "invalid argument: %s\n" "$key" >&2
7494 exit 1
7605 exit 1
7495 fi
7606 fi
7496
7607
7497 ;;
7608 ;;
7498
7609
7499 esac
7610 esac
7500 done
7611 done
7501
7612
7502 # :command.required_args_filter
7613 # :command.required_args_filter
7503 if [[ -z ${args['ini_path']+x} ]]; then
7614 if [[ -z ${args['ini_path']+x} ]]; then
7504 printf "missing required argument: INI_PATH\nusage: rcstack cli configure-vcsserver INI_PATH\n" >&2
7615 printf "missing required argument: INI_PATH\nusage: rcstack cli configure-vcsserver INI_PATH\n" >&2
7505 exit 1
7616 exit 1
7506 fi
7617 fi
7507
7618
7508 }
7619 }
7509
7620
7510 # :command.parse_requirements
7621 # :command.parse_requirements
7511 rcstack_cli_configure_rhodecode_parse_requirements() {
7622 rcstack_cli_configure_rhodecode_parse_requirements() {
7512 # :command.fixed_flags_filter
7623 # :command.fixed_flags_filter
7513 while [[ $# -gt 0 ]]; do
7624 while [[ $# -gt 0 ]]; do
7514 case "${1:-}" in
7625 case "${1:-}" in
7515 --help | -h)
7626 --help | -h)
7516 long_usage=yes
7627 long_usage=yes
7517 rcstack_cli_configure_rhodecode_usage
7628 rcstack_cli_configure_rhodecode_usage
7518 exit
7629 exit
7519 ;;
7630 ;;
7520
7631
7521 *)
7632 *)
7522 break
7633 break
7523 ;;
7634 ;;
7524
7635
7525 esac
7636 esac
7526 done
7637 done
7527
7638
7528 # :command.command_filter
7639 # :command.command_filter
7529 action="cli configure-rhodecode"
7640 action="cli configure-rhodecode"
7530
7641
7531 # :command.parse_requirements_while
7642 # :command.parse_requirements_while
7532 while [[ $# -gt 0 ]]; do
7643 while [[ $# -gt 0 ]]; do
7533 key="$1"
7644 key="$1"
7534 case "$key" in
7645 case "$key" in
7535
7646
7536 -?*)
7647 -?*)
7537 printf "invalid option: %s\n" "$key" >&2
7648 printf "invalid option: %s\n" "$key" >&2
7538 exit 1
7649 exit 1
7539 ;;
7650 ;;
7540
7651
7541 *)
7652 *)
7542 # :command.parse_requirements_case
7653 # :command.parse_requirements_case
7543 # :command.parse_requirements_case_simple
7654 # :command.parse_requirements_case_simple
7544 if [[ -z ${args['ini_path']+x} ]]; then
7655 if [[ -z ${args['ini_path']+x} ]]; then
7545 # :argument.validations
7656 # :argument.validations
7546 if [[ -n $(validate_file_exists "$1") ]]; then
7657 if [[ -n $(validate_file_exists "$1") ]]; then
7547 printf "validation error in %s:\n%s\n" "INI_PATH" "$(validate_file_exists "$1")" >&2
7658 printf "validation error in %s:\n%s\n" "INI_PATH" "$(validate_file_exists "$1")" >&2
7548 exit 1
7659 exit 1
7549 fi
7660 fi
7550
7661
7551 args['ini_path']=$1
7662 args['ini_path']=$1
7552 shift
7663 shift
7553 else
7664 else
7554 printf "invalid argument: %s\n" "$key" >&2
7665 printf "invalid argument: %s\n" "$key" >&2
7555 exit 1
7666 exit 1
7556 fi
7667 fi
7557
7668
7558 ;;
7669 ;;
7559
7670
7560 esac
7671 esac
7561 done
7672 done
7562
7673
7563 # :command.required_args_filter
7674 # :command.required_args_filter
7564 if [[ -z ${args['ini_path']+x} ]]; then
7675 if [[ -z ${args['ini_path']+x} ]]; then
7565 printf "missing required argument: INI_PATH\nusage: rcstack cli configure-rhodecode INI_PATH\n" >&2
7676 printf "missing required argument: INI_PATH\nusage: rcstack cli configure-rhodecode INI_PATH\n" >&2
7566 exit 1
7677 exit 1
7567 fi
7678 fi
7568
7679
7569 }
7680 }
7570
7681
7571 # :command.parse_requirements
7682 # :command.parse_requirements
7572 rcstack_backup_db_parse_requirements() {
7683 rcstack_backup_db_parse_requirements() {
7573 # :command.fixed_flags_filter
7684 # :command.fixed_flags_filter
7574 while [[ $# -gt 0 ]]; do
7685 while [[ $# -gt 0 ]]; do
7575 case "${1:-}" in
7686 case "${1:-}" in
7576 --help | -h)
7687 --help | -h)
7577 long_usage=yes
7688 long_usage=yes
7578 rcstack_backup_db_usage
7689 rcstack_backup_db_usage
7579 exit
7690 exit
7580 ;;
7691 ;;
7581
7692
7582 *)
7693 *)
7583 break
7694 break
7584 ;;
7695 ;;
7585
7696
7586 esac
7697 esac
7587 done
7698 done
7588
7699
7589 # :command.dependencies_filter
7700 # :command.dependencies_filter
7590 if command -v tar >/dev/null 2>&1; then
7701 if command -v tar >/dev/null 2>&1; then
7591 deps['tar']="$(command -v tar | head -n1)"
7702 deps['tar']="$(command -v tar | head -n1)"
7592 else
7703 else
7593 printf "missing dependency: tar\n" >&2
7704 printf "missing dependency: tar\n" >&2
7594 exit 1
7705 exit 1
7595 fi
7706 fi
7596
7707
7597 if command -v gzip >/dev/null 2>&1; then
7708 if command -v gzip >/dev/null 2>&1; then
7598 deps['gzip']="$(command -v gzip | head -n1)"
7709 deps['gzip']="$(command -v gzip | head -n1)"
7599 else
7710 else
7600 printf "missing dependency: gzip\n" >&2
7711 printf "missing dependency: gzip\n" >&2
7601 exit 1
7712 exit 1
7602 fi
7713 fi
7603
7714
7604 # :command.command_filter
7715 # :command.command_filter
7605 action="backup-db"
7716 action="backup-db"
7606
7717
7607 # :command.parse_requirements_while
7718 # :command.parse_requirements_while
7608 while [[ $# -gt 0 ]]; do
7719 while [[ $# -gt 0 ]]; do
7609 key="$1"
7720 key="$1"
7610 case "$key" in
7721 case "$key" in
7611
7722
7612 -?*)
7723 -?*)
7613 printf "invalid option: %s\n" "$key" >&2
7724 printf "invalid option: %s\n" "$key" >&2
7614 exit 1
7725 exit 1
7615 ;;
7726 ;;
7616
7727
7617 *)
7728 *)
7618 # :command.parse_requirements_case
7729 # :command.parse_requirements_case
7619 # :command.parse_requirements_case_simple
7730 # :command.parse_requirements_case_simple
7620 if [[ -z ${args['destination']+x} ]]; then
7731 if [[ -z ${args['destination']+x} ]]; then
7621 # :argument.validations
7732 # :argument.validations
7622 if [[ -n $(validate_dir_exists "$1") ]]; then
7733 if [[ -n $(validate_dir_exists "$1") ]]; then
7623 printf "validation error in %s:\n%s\n" "DESTINATION" "$(validate_dir_exists "$1")" >&2
7734 printf "validation error in %s:\n%s\n" "DESTINATION" "$(validate_dir_exists "$1")" >&2
7624 exit 1
7735 exit 1
7625 fi
7736 fi
7626
7737
7627 args['destination']=$1
7738 args['destination']=$1
7628 shift
7739 shift
7629 else
7740 else
7630 printf "invalid argument: %s\n" "$key" >&2
7741 printf "invalid argument: %s\n" "$key" >&2
7631 exit 1
7742 exit 1
7632 fi
7743 fi
7633
7744
7634 ;;
7745 ;;
7635
7746
7636 esac
7747 esac
7637 done
7748 done
7638
7749
7639 # :command.required_args_filter
7750 # :command.required_args_filter
7640 if [[ -z ${args['destination']+x} ]]; then
7751 if [[ -z ${args['destination']+x} ]]; then
7641 printf "missing required argument: DESTINATION\nusage: rcstack backup-db DESTINATION\n" >&2
7752 printf "missing required argument: DESTINATION\nusage: rcstack backup-db DESTINATION\n" >&2
7642 exit 1
7753 exit 1
7643 fi
7754 fi
7644
7755
7645 }
7756 }
7646
7757
7647 # :command.parse_requirements
7758 # :command.parse_requirements
7648 rcstack_backup_data_parse_requirements() {
7759 rcstack_backup_data_parse_requirements() {
7649 # :command.fixed_flags_filter
7760 # :command.fixed_flags_filter
7650 while [[ $# -gt 0 ]]; do
7761 while [[ $# -gt 0 ]]; do
7651 case "${1:-}" in
7762 case "${1:-}" in
7652 --help | -h)
7763 --help | -h)
7653 long_usage=yes
7764 long_usage=yes
7654 rcstack_backup_data_usage
7765 rcstack_backup_data_usage
7655 exit
7766 exit
7656 ;;
7767 ;;
7657
7768
7658 *)
7769 *)
7659 break
7770 break
7660 ;;
7771 ;;
7661
7772
7662 esac
7773 esac
7663 done
7774 done
7664
7775
7665 # :command.dependencies_filter
7776 # :command.dependencies_filter
7666 if command -v tar >/dev/null 2>&1; then
7777 if command -v tar >/dev/null 2>&1; then
7667 deps['tar']="$(command -v tar | head -n1)"
7778 deps['tar']="$(command -v tar | head -n1)"
7668 else
7779 else
7669 printf "missing dependency: tar\n" >&2
7780 printf "missing dependency: tar\n" >&2
7670 exit 1
7781 exit 1
7671 fi
7782 fi
7672
7783
7673 if command -v gzip >/dev/null 2>&1; then
7784 if command -v gzip >/dev/null 2>&1; then
7674 deps['gzip']="$(command -v gzip | head -n1)"
7785 deps['gzip']="$(command -v gzip | head -n1)"
7675 else
7786 else
7676 printf "missing dependency: gzip\n" >&2
7787 printf "missing dependency: gzip\n" >&2
7677 exit 1
7788 exit 1
7678 fi
7789 fi
7679
7790
7680 # :command.command_filter
7791 # :command.command_filter
7681 action="backup-data"
7792 action="backup-data"
7682
7793
7683 # :command.parse_requirements_while
7794 # :command.parse_requirements_while
7684 while [[ $# -gt 0 ]]; do
7795 while [[ $# -gt 0 ]]; do
7685 key="$1"
7796 key="$1"
7686 case "$key" in
7797 case "$key" in
7687
7798
7688 -?*)
7799 -?*)
7689 printf "invalid option: %s\n" "$key" >&2
7800 printf "invalid option: %s\n" "$key" >&2
7690 exit 1
7801 exit 1
7691 ;;
7802 ;;
7692
7803
7693 *)
7804 *)
7694 # :command.parse_requirements_case
7805 # :command.parse_requirements_case
7695 # :command.parse_requirements_case_simple
7806 # :command.parse_requirements_case_simple
7696 if [[ -z ${args['destination']+x} ]]; then
7807 if [[ -z ${args['destination']+x} ]]; then
7697 # :argument.validations
7808 # :argument.validations
7698 if [[ -n $(validate_dir_exists "$1") ]]; then
7809 if [[ -n $(validate_dir_exists "$1") ]]; then
7699 printf "validation error in %s:\n%s\n" "DESTINATION" "$(validate_dir_exists "$1")" >&2
7810 printf "validation error in %s:\n%s\n" "DESTINATION" "$(validate_dir_exists "$1")" >&2
7700 exit 1
7811 exit 1
7701 fi
7812 fi
7702
7813
7703 args['destination']=$1
7814 args['destination']=$1
7704 shift
7815 shift
7705 else
7816 else
7706 printf "invalid argument: %s\n" "$key" >&2
7817 printf "invalid argument: %s\n" "$key" >&2
7707 exit 1
7818 exit 1
7708 fi
7819 fi
7709
7820
7710 ;;
7821 ;;
7711
7822
7712 esac
7823 esac
7713 done
7824 done
7714
7825
7715 # :command.required_args_filter
7826 # :command.required_args_filter
7716 if [[ -z ${args['destination']+x} ]]; then
7827 if [[ -z ${args['destination']+x} ]]; then
7717 printf "missing required argument: DESTINATION\nusage: rcstack backup-data DESTINATION\n" >&2
7828 printf "missing required argument: DESTINATION\nusage: rcstack backup-data DESTINATION\n" >&2
7718 exit 1
7829 exit 1
7719 fi
7830 fi
7720
7831
7721 }
7832 }
7722
7833
7723 # :command.parse_requirements
7834 # :command.parse_requirements
7724 rcstack__completions_parse_requirements() {
7835 rcstack__completions_parse_requirements() {
7725 # :command.fixed_flags_filter
7836 # :command.fixed_flags_filter
7726 while [[ $# -gt 0 ]]; do
7837 while [[ $# -gt 0 ]]; do
7727 case "${1:-}" in
7838 case "${1:-}" in
7728 --help | -h)
7839 --help | -h)
7729 long_usage=yes
7840 long_usage=yes
7730 rcstack__completions_usage
7841 rcstack__completions_usage
7731 exit
7842 exit
7732 ;;
7843 ;;
7733
7844
7734 *)
7845 *)
7735 break
7846 break
7736 ;;
7847 ;;
7737
7848
7738 esac
7849 esac
7739 done
7850 done
7740
7851
7741 # :command.command_filter
7852 # :command.command_filter
7742 action="_completions"
7853 action="_completions"
7743
7854
7744 # :command.parse_requirements_while
7855 # :command.parse_requirements_while
7745 while [[ $# -gt 0 ]]; do
7856 while [[ $# -gt 0 ]]; do
7746 key="$1"
7857 key="$1"
7747 case "$key" in
7858 case "$key" in
7748
7859
7749 -?*)
7860 -?*)
7750 printf "invalid option: %s\n" "$key" >&2
7861 printf "invalid option: %s\n" "$key" >&2
7751 exit 1
7862 exit 1
7752 ;;
7863 ;;
7753
7864
7754 *)
7865 *)
7755 # :command.parse_requirements_case
7866 # :command.parse_requirements_case
7756 # :command.parse_requirements_case_simple
7867 # :command.parse_requirements_case_simple
7757 printf "invalid argument: %s\n" "$key" >&2
7868 printf "invalid argument: %s\n" "$key" >&2
7758 exit 1
7869 exit 1
7759
7870
7760 ;;
7871 ;;
7761
7872
7762 esac
7873 esac
7763 done
7874 done
7764
7875
7765 }
7876 }
7766
7877
7767 # :command.initialize
7878 # :command.initialize
7768 initialize() {
7879 initialize() {
7769 version="5.12.0"
7880 version="5.13.0"
7770 long_usage=''
7881 long_usage=''
7771 set -e
7882 set -e
7772
7883
7773 # :command.environment_variables_default
7884 # :command.environment_variables_default
7774 export RCC_CONFIG="${RCC_CONFIG:-.rcstack.ini}"
7885 export RCC_CONFIG="${RCC_CONFIG:-.rcstack.ini}"
7775 export RC_STACK_ROUTER_EXT="${RC_STACK_ROUTER_EXT:-.custom/docker-compose-router.override.yaml}"
7886 export RC_STACK_ROUTER_EXT="${RC_STACK_ROUTER_EXT:-.custom/docker-compose-router.override.yaml}"
7776 export RC_STACK_METRICS_EXT="${RC_STACK_METRICS_EXT:-.custom/docker-compose-metrics.override.yaml}"
7887 export RC_STACK_METRICS_EXT="${RC_STACK_METRICS_EXT:-.custom/docker-compose-metrics.override.yaml}"
7777 export RC_STACK_SERVICES_EXT="${RC_STACK_SERVICES_EXT:-.custom/docker-compose-services.override.yaml}"
7888 export RC_STACK_SERVICES_EXT="${RC_STACK_SERVICES_EXT:-.custom/docker-compose-services.override.yaml}"
7778 export RC_STACK_RHODECODE_EXT="${RC_STACK_RHODECODE_EXT:-.custom/docker-compose-apps.override.yaml}"
7889 export RC_STACK_RHODECODE_EXT="${RC_STACK_RHODECODE_EXT:-.custom/docker-compose-apps.override.yaml}"
7779
7890
7780 # src/initialize.sh
7891 # src/initialize.sh
7781
7892
7782 rc_image_ver=5.0.2
7893 rc_image_ver=5.0.3
7783
7894
7784 rhodecode_default_config_path=config/_shared/rhodecode.ini
7895 rhodecode_default_config_path=config/_shared/rhodecode.ini
7785 vcsserver_default_config_path=config/_shared/vcsserver.ini
7896 vcsserver_default_config_path=config/_shared/vcsserver.ini
7786
7897
7787 RC_STACK_ROUTER_VER=1.0.0
7898 RC_STACK_ROUTER_VER=1.0.0
7788 RC_STACK_SERVICES_VER=1.0.0
7899 RC_STACK_SERVICES_VER=1.0.0
7789 RC_STACK_RHODECODE_VER=1.0.0
7900 RC_STACK_RHODECODE_VER=1.0.0
7790 RC_STACK_METRICS_VER=1.0.0
7901 RC_STACK_METRICS_VER=1.0.0
7791
7902
7792 RC_SCRIPT_NAME=rcstack
7903 RC_SCRIPT_NAME=rcstack
7793 # bootstrap file is a config file at the same time
7904 # bootstrap file is a config file at the same time
7794 CONFIG_FILE=${RCC_CONFIG:=.rcstack.ini}
7905 CONFIG_FILE=${RCC_CONFIG:=.rcstack.ini}
7795
7906
7796 # runtime env file
7907 # runtime env file
7797 RUNTIME_ENV=$PWD/.custom/.runtime.env
7908 RUNTIME_ENV=$PWD/.custom/.runtime.env
7798
7909
7799 # STACK_LIST
7910 # STACK_LIST
7800 VALID_SERVICES="router metrics services rhodecode"
7911 VALID_SERVICES="router metrics services rhodecode"
7801 DOCKER_DEFS_WORK_DIR="docker_defs"
7912 DOCKER_DEFS_WORK_DIR="docker_defs"
7802
7913
7803 # stage key, saved in .rcstack.ini : stage func to execute
7914 # stage key, saved in .rcstack.ini : stage func to execute
7804 BOOTSTRAP_STAGES="\
7915 BOOTSTRAP_STAGES="\
7805 bootstrap_v1_docker_install \
7916 bootstrap_v1_docker_install \
7806 bootstrap_v1_docker_commons \
7917 bootstrap_v1_docker_commons \
7807 bootstrap_v1_definitions \
7918 bootstrap_v1_definitions \
7808 bootstrap_v1_config \
7919 bootstrap_v1_config \
7809 bootstrap_v1_overrides \
7920 bootstrap_v1_overrides \
7810 "
7921 "
7811
7922
7812 YAML_TEMPLATES="\
7923 YAML_TEMPLATES="\
7813 docker-compose-apps.override.yaml
7924 docker-compose-apps.override.yaml
7814 docker-compose-metrics.override.yaml
7925 docker-compose-metrics.override.yaml
7815 docker-compose-router.override.yaml
7926 docker-compose-router.override.yaml
7816 docker-compose-services.override.yaml
7927 docker-compose-services.override.yaml
7817 runtime.env.tmpl
7928 runtime.env.tmpl
7818 "
7929 "
7819
7930
7820 BASE_OPS_IMAGE="ubuntu:22.04"
7931 BASE_OPS_IMAGE="ubuntu:22.04"
7821
7932
7822 get_stage_function() {
7933 get_stage_function() {
7823 stage_name=$1
7934 stage_name=$1
7824
7935
7825 case $stage_name in
7936 case $stage_name in
7826 bootstrap_v1_docker_install)
7937 bootstrap_v1_docker_install)
7827 stage_func=bootstrap_docker_install
7938 stage_func=bootstrap_docker_install
7828 ;;
7939 ;;
7829 bootstrap_v1_docker_commons)
7940 bootstrap_v1_docker_commons)
7830 stage_func=bootstrap_docker_commons
7941 stage_func=bootstrap_docker_commons
7831 ;;
7942 ;;
7832 bootstrap_v1_definitions)
7943 bootstrap_v1_definitions)
7833 stage_func=bootstrap_definitions
7944 stage_func=bootstrap_definitions
7834 ;;
7945 ;;
7835 bootstrap_v1_config)
7946 bootstrap_v1_config)
7836 stage_func=bootstrap_config
7947 stage_func=bootstrap_config
7837 ;;
7948 ;;
7838 bootstrap_v1_overrides)
7949 bootstrap_v1_overrides)
7839 stage_func=bootstrap_overrides
7950 stage_func=bootstrap_overrides
7840 ;;
7951 ;;
7841 *)
7952 *)
7842 echo "can't find function for stage $stage_name"
7953 echo "can't find function for stage $stage_name"
7843 exit 1
7954 exit 1
7844 esac
7955 esac
7845
7956
7846 echo $stage_func
7957 echo $stage_func
7847 }
7958 }
7848
7959
7849 #echo "1 ----"
7960 #echo "1 ----"
7850 #echo $RC_STACK_SERVICES_EXT
7961 #echo $RC_STACK_SERVICES_EXT
7851 #echo $RC_STACK_METRICS_EXT
7962 #echo $RC_STACK_METRICS_EXT
7852 #echo "1 -----"
7963 #echo "1 -----"
7853
7964
7854 #echo '2 ----'
7965 #echo '2 ----'
7855 #grep -v -e '^#' "$ENV_FILE" | xargs -I {} echo \'{}\'
7966 #grep -v -e '^#' "$ENV_FILE" | xargs -I {} echo \'{}\'
7856 #echo '2 ----'
7967 #echo '2 ----'
7857
7968
7858 #expose env vars from ./rcstack config
7969 #expose env vars from ./rcstack config
7859 #if [[ -f $ENV_FILE ]]; then
7970 #if [[ -f $ENV_FILE ]]; then
7860 # eval $(grep -v -e '^#' "$ENV_FILE" | xargs -I {} echo export \'{}\')
7971 # eval $(grep -v -e '^#' "$ENV_FILE" | xargs -I {} echo export \'{}\')
7861 #fi
7972 #fi
7862
7973
7863 #ENV_EXPAND=""
7974 #ENV_EXPAND=""
7864 #for k in $(config_keys); do
7975 #for k in $(config_keys); do
7865 # k_upper=${k^^}
7976 # k_upper=${k^^}
7866 # env_entry="-e $k_upper='$(config_get "$k")' "
7977 # env_entry="-e $k_upper='$(config_get "$k")' "
7867 # ENV_EXPAND+=$env_entry;
7978 # ENV_EXPAND+=$env_entry;
7868 # #echo $env_expand
7979 # #echo $env_expand
7869 #done
7980 #done
7870
7981
7871 #
7982 #
7872 #echo "3 ----"
7983 #echo "3 ----"
7873 #echo $RC_STACK_SERVICES_EXT
7984 #echo $RC_STACK_SERVICES_EXT
7874 #echo $RC_STACK_METRICS_EXT
7985 #echo $RC_STACK_METRICS_EXT
7875 #echo $RC_STACK_RHODECODE_EXT
7986 #echo $RC_STACK_RHODECODE_EXT
7876 #echo "3 -----"
7987 #echo "3 -----"
7877
7988
7878 #env | grep RC_
7989 #env | grep RC_
7879
7990
7880 docker_ping_host() {
7991 docker_ping_host() {
7881 PING_HOST="$1"
7992 PING_HOST="$1"
7882 docker run --network rhodecode_network --rm alpine ping "$PING_HOST"
7993 docker run --network rhodecode_network --rm alpine ping "$PING_HOST"
7883 }
7994 }
7884
7995
7885 get_started() {
7996 get_started() {
7886 echo ""
7997 echo ""
7887 echo "To start using RhodeCode run the following stacks using './$RC_SCRIPT_NAME stack [STACK_NAME]'"
7998 echo "To start using RhodeCode run the following stacks using './$RC_SCRIPT_NAME stack [STACK_NAME]'"
7888 echo "Check './$RC_SCRIPT_NAME stack --help' for more examples and options"
7999 echo "Check './$RC_SCRIPT_NAME stack --help' for more examples and options"
7889 echo "$(green_bold IMPORTANT): init command generates some secrets/config inside $RUNTIME_ENV file."
8000 echo "$(green_bold IMPORTANT): init command generates some secrets/config inside $RUNTIME_ENV file."
7890 echo "Check and adjust those settings if needed."
8001 echo "Check and adjust those settings if needed."
7891 echo ""
8002 echo ""
7892 echo "$(bold Run the stacks in following order):"
8003 echo "$(bold Run the stacks in following order):"
7893 echo "$(bold [NOTE]): Instead of running stacks independent, one can use shorthand to run all stacks in order (detached with -d)"
8004 echo "$(bold [NOTE]): Instead of running stacks independent, one can use shorthand to run all stacks in order (detached with -d)"
7894 echo "./$RC_SCRIPT_NAME stack all up -d"
8005 echo "./$RC_SCRIPT_NAME stack all up -d"
7895 echo ""
8006 echo ""
7896 echo "$(green_bold 1\) router [Mandatory]): run the edge router to control stack traffic / domain access and optionally SSL termination"
8007 echo "$(green_bold 1\) router [Mandatory]): run the edge router to control stack traffic / domain access and optionally SSL termination"
7897 echo "IMPORTANT: router binds to some common ports 80, 443, SSH (9022), Loki (3100) if those are not available, please adjust them"
8008 echo "IMPORTANT: router binds to some common ports 80, 443, SSH (9022), Loki (3100) if those are not available, please adjust them"
7898 echo "To configure this stack before running check: $RC_STACK_ROUTER_EXT"
8009 echo "To configure this stack before running check: $RC_STACK_ROUTER_EXT"
7899 echo ""
8010 echo ""
7900 echo "./$RC_SCRIPT_NAME stack router up --detach"
8011 echo "./$RC_SCRIPT_NAME stack router up --detach"
7901 echo ""
8012 echo ""
7902 echo "$(green_bold 2\) services [Mandatory]): run the services, like database, redis, channelstream etc..."
8013 echo "$(green_bold 2\) services [Mandatory]): run the services, like database, redis, channelstream etc..."
7903 echo "IMPORTANT: if you like to run your own database, or redis please adjust before running"
8014 echo "IMPORTANT: if you like to run your own database, or redis please adjust before running"
7904 echo "To configure this stack before running check: $RC_STACK_SERVICES_EXT"
8015 echo "To configure this stack before running check: $RC_STACK_SERVICES_EXT"
7905 echo ""
8016 echo ""
7906 echo "./$RC_SCRIPT_NAME stack services up --detach"
8017 echo "./$RC_SCRIPT_NAME stack services up --detach"
7907 echo ""
8018 echo ""
7908 echo "$(green_bold 3\) rhodecode [Mandatory]): run the rhodecode app stack"
8019 echo "$(green_bold 3\) rhodecode [Mandatory]): run the rhodecode app stack"
7909 echo "To configure this stack before running check: $RC_STACK_RHODECODE_EXT"
8020 echo "To configure this stack before running check: $RC_STACK_RHODECODE_EXT"
7910 echo ""
8021 echo ""
7911 echo "./$RC_SCRIPT_NAME stack rhodecode up --detach"
8022 echo "./$RC_SCRIPT_NAME stack rhodecode up --detach"
7912 echo ""
8023 echo ""
7913 echo "$(yellow_bold 4\) metrics [Optional]): run the monitoring stack, this includes grafana/prometheus logging/metrics system"
8024 echo "$(yellow_bold 4\) metrics [Optional]): run the monitoring stack, this includes grafana/prometheus logging/metrics system"
7914 echo "To configure this stack before running check: $RC_STACK_METRICS_EXT"
8025 echo "To configure this stack before running check: $RC_STACK_METRICS_EXT"
7915 echo ""
8026 echo ""
7916 echo "./$RC_SCRIPT_NAME stack metrics up --detach"
8027 echo "./$RC_SCRIPT_NAME stack metrics up --detach"
7917 echo ""
8028 echo ""
7918 echo "$(bold [Status]): check services run status, ports etc.."
8029 echo "$(bold [Status]): check services run status, ports etc.."
7919 echo "./$RC_SCRIPT_NAME status -v --configs"
8030 echo "./$RC_SCRIPT_NAME status -v --configs"
7920 echo ""
8031 echo ""
7921 echo "$(bold [Logs]): check service logs"
8032 echo "$(bold [Logs]): check service logs"
7922 echo "./$RC_SCRIPT_NAME stack [STACK_NAME] logs"
8033 echo "./$RC_SCRIPT_NAME stack [STACK_NAME] logs"
7923 }
8034 }
7924
8035
7925 get_started_full() {
8036 get_started_full() {
7926 echo "$(blue_bold [~~~~ GET STARTED ~~~~~])"
8037 echo "$(blue_bold [~~~~ GET STARTED ~~~~~])"
7927 echo "$(green_bold Having problems / need help? Reach out to us here:) https://community.rhodecode.com"
8038 echo "$(green_bold Having problems / need help? Reach out to us here:) https://community.rhodecode.com"
7928 echo ""
8039 echo ""
7929 echo "./$RC_SCRIPT_NAME is a CLI based installer/manager for RhodeCode Cluster Stack"
8040 echo "./$RC_SCRIPT_NAME is a CLI based installer/manager for RhodeCode Cluster Stack"
7930 echo "./$RC_SCRIPT_NAME -h is your friend, in case of doubt, check examples and usage options with -h / --help flag"
8041 echo "./$RC_SCRIPT_NAME -h is your friend, in case of doubt, check examples and usage options with -h / --help flag"
7931 echo ""
8042 echo ""
7932 echo "$(yellow_bold [First time run])"
8043 echo "$(yellow_bold [First time run])"
7933 echo "run './$RC_SCRIPT_NAME init' to setup docker and download required installer files."
8044 echo "run './$RC_SCRIPT_NAME init' to setup docker and download required installer files."
7934 echo "./$RC_SCRIPT_NAME can install Docker for you, or install it manually before running init command"
8045 echo "./$RC_SCRIPT_NAME can install Docker for you, or install it manually before running init command"
7935
8046
7936 get_started
8047 get_started
7937 }
8048 }
7938
8049
7939 }
8050 }
7940
8051
7941 # :command.run
8052 # :command.run
7942 run() {
8053 run() {
7943 declare -A args=()
8054 declare -A args=()
7944 declare -A deps=()
8055 declare -A deps=()
7945 declare -a other_args=()
8056 declare -a other_args=()
7946 declare -a input=()
8057 declare -a input=()
7947 normalize_input "$@"
8058 normalize_input "$@"
7948 parse_requirements "${input[@]}"
8059 parse_requirements "${input[@]}"
7949
8060
7950 case "$action" in
8061 case "$action" in
7951 "get-started") rcstack_get_started_command ;;
8062 "get-started") rcstack_get_started_command ;;
7952 "init") rcstack_init_command ;;
8063 "init") rcstack_init_command ;;
7953 "self-update") rcstack_self_update_command ;;
8064 "self-update") rcstack_self_update_command ;;
7954 "self-upgrade") rcstack_self_upgrade_command ;;
8065 "self-upgrade") rcstack_self_upgrade_command ;;
7955 "stack") rcstack_stack_command ;;
8066 "stack") rcstack_stack_command ;;
7956 "stack router") rcstack_stack_router_command ;;
8067 "stack router") rcstack_stack_router_command ;;
7957 "stack metrics") rcstack_stack_metrics_command ;;
8068 "stack metrics") rcstack_stack_metrics_command ;;
7958 "stack services") rcstack_stack_services_command ;;
8069 "stack services") rcstack_stack_services_command ;;
7959 "stack rhodecode") rcstack_stack_rhodecode_command ;;
8070 "stack rhodecode") rcstack_stack_rhodecode_command ;;
7960 "stack all") rcstack_stack_all_command ;;
8071 "stack all") rcstack_stack_all_command ;;
7961 "stack-status") rcstack_stack_status_command ;;
8072 "stack-status") rcstack_stack_status_command ;;
7962 "stack-upgrade") rcstack_stack_upgrade_command ;;
8073 "stack-upgrade") rcstack_stack_upgrade_command ;;
7963 "stack-upgrade router") rcstack_stack_upgrade_router_command ;;
8074 "stack-upgrade router") rcstack_stack_upgrade_router_command ;;
7964 "stack-upgrade services") rcstack_stack_upgrade_services_command ;;
8075 "stack-upgrade services") rcstack_stack_upgrade_services_command ;;
7965 "stack-upgrade metrics") rcstack_stack_upgrade_metrics_command ;;
8076 "stack-upgrade metrics") rcstack_stack_upgrade_metrics_command ;;
7966 "stack-upgrade rhodecode") rcstack_stack_upgrade_rhodecode_command ;;
8077 "stack-upgrade rhodecode") rcstack_stack_upgrade_rhodecode_command ;;
7967 "stack-monitor") rcstack_stack_monitor_command ;;
8078 "stack-monitor") rcstack_stack_monitor_command ;;
7968 "stack-monitor restart-unhealthy") rcstack_stack_monitor_restart_unhealthy_command ;;
8079 "stack-monitor restart-unhealthy") rcstack_stack_monitor_restart_unhealthy_command ;;
7969 "cli") rcstack_cli_command ;;
8080 "cli") rcstack_cli_command ;;
7970 "cli cmd") rcstack_cli_cmd_command ;;
8081 "cli cmd") rcstack_cli_cmd_command ;;
7971 "cli ishell") rcstack_cli_ishell_command ;;
8082 "cli ishell") rcstack_cli_ishell_command ;;
7972 "cli image-info") rcstack_cli_image_info_command ;;
8083 "cli image-info") rcstack_cli_image_info_command ;;
7973 "cli set-runtime-image") rcstack_cli_set_runtime_image_command ;;
8084 "cli set-image") rcstack_cli_set_image_command ;;
8085 "cli set-runtime-image") deprecated_cli_set_runtime_image_command ;;
7974 "cli docker-info") rcstack_cli_docker_info_command ;;
8086 "cli docker-info") rcstack_cli_docker_info_command ;;
7975 "cli docker-upgrade") rcstack_cli_docker_upgrade_command ;;
8087 "cli docker-upgrade") rcstack_cli_docker_upgrade_command ;;
7976 "cli redis") rcstack_cli_redis_command ;;
8088 "cli redis") rcstack_cli_redis_command ;;
7977 "cli db") rcstack_cli_db_command ;;
8089 "cli db") rcstack_cli_db_command ;;
7978 "cli db-upgrade") rcstack_cli_db_upgrade_command ;;
8090 "cli db-upgrade") rcstack_cli_db_upgrade_command ;;
7979 "cli storage") rcstack_cli_storage_command ;;
8091 "cli storage") rcstack_cli_storage_command ;;
7980 "cli attach") rcstack_cli_attach_command ;;
8092 "cli attach") rcstack_cli_attach_command ;;
7981 "cli set-edition") rcstack_cli_set_edition_command ;;
8093 "cli set-edition") rcstack_cli_set_edition_command ;;
7982 "cli configure-vcsserver") rcstack_cli_configure_vcsserver_command ;;
8094 "cli configure-vcsserver") rcstack_cli_configure_vcsserver_command ;;
7983 "cli configure-rhodecode") rcstack_cli_configure_rhodecode_command ;;
8095 "cli configure-rhodecode") rcstack_cli_configure_rhodecode_command ;;
7984 "backup-db") rcstack_backup_db_command ;;
8096 "backup-db") rcstack_backup_db_command ;;
7985 "backup-data") rcstack_backup_data_command ;;
8097 "backup-data") rcstack_backup_data_command ;;
7986 "_completions") rcstack__completions_command ;;
8098 "_completions") rcstack__completions_command ;;
7987 esac
8099 esac
7988 }
8100 }
7989
8101
7990 initialize
8102 initialize
7991 run "$@"
8103 run "$@"
@@ -1,54 +1,54 b''
1 ## BUILD/RUN ARGS ##
1 ## BUILD/RUN ARGS ##
2 ####################
2 ####################
3
3
4 TZ="UTC"
4 TZ="UTC"
5
5
6 # Version of docker image to deploy and run
6 # Version of docker image to deploy and run
7 # to set a custom version run ./rcstack cli set-runtime-image VER (e.g 5.0.0)
7 # to set a custom version run ./rcstack cli set-image VER (e.g 5.0.0)
8 RC_VERSION=stable
8 RC_VERSION=stable
9
9
10 # Select RhodeCode edition ce (free community), or ee (paid/enterprise)
10 # Select RhodeCode edition ce (free community), or ee (paid/enterprise)
11 RC_EDITION=ee
11 RC_EDITION=ee
12
12
13 # GENERATED ARGS #
13 # GENERATED ARGS #
14 ##################
14 ##################
15
15
16 # set limit of redis in-memory cache before keys get evicted using LRU cache
16 # set limit of redis in-memory cache before keys get evicted using LRU cache
17 RC_REDIS_MAXMEMORY=1024mb
17 RC_REDIS_MAXMEMORY=1024mb
18
18
19 # set the size of ramdisk used for locking files
19 # set the size of ramdisk used for locking files
20 RC_DATA_RAMDISK_SIZE=512M
20 RC_DATA_RAMDISK_SIZE=512M
21
21
22 # Database bootstrap/access credentials
22 # Database bootstrap/access credentials
23 # Bootstrap container with specific password
23 # Bootstrap container with specific password
24 # This password will be used to generate new account and password for the database
24 # This password will be used to generate new account and password for the database
25 # Please don't change those unless you use your own database
25 # Please don't change those unless you use your own database
26 DB_NAME=rhodecode
26 DB_NAME=rhodecode
27 DB_USER=rhodecode
27 DB_USER=rhodecode
28 DB_PASSWORD=GENERATED_AT_BOOTSTRAP
28 DB_PASSWORD=GENERATED_AT_BOOTSTRAP
29
29
30 # Database type used, can be postgres, mysql, none
30 # Database type used, can be postgres, mysql, none
31 DB_TYPE=postgres
31 DB_TYPE=postgres
32
32
33 # user/password for first admin user created for access
33 # user/password for first admin user created for access
34 # this is a bootstrap super-admin account to access the web interface
34 # this is a bootstrap super-admin account to access the web interface
35 RHODECODE_USER_EMAIL=admin@server-com
35 RHODECODE_USER_EMAIL=admin@server-com
36 RHODECODE_USER_NAME=admin
36 RHODECODE_USER_NAME=admin
37 RHODECODE_USER_PASS=secret4
37 RHODECODE_USER_PASS=secret4
38
38
39 # prependend to loki url prefix, this will be generated
39 # prependend to loki url prefix, this will be generated
40 # format is username:plaintext_password@
40 # format is username:plaintext_password@
41 RC_LOKI_AUTH=loki-auth:password@
41 RC_LOKI_AUTH=loki-auth:password@
42
42
43 # base url for running app, this is used for traefik hasname matching, so accessing this host will redirect
43 # base url for running app, this is used for traefik hasname matching, so accessing this host will redirect
44 # traffic to the running instance. This needs to be the same as RC_APP_BASE_URL
44 # traffic to the running instance. This needs to be the same as RC_APP_BASE_URL
45 # replace this with your name of host. e.g yourdomain.com or rc.company.local
45 # replace this with your name of host. e.g yourdomain.com or rc.company.local
46 RC_HOSTNAME=base-url
46 RC_HOSTNAME=base-url
47
47
48 # application base url, at which location including a scheme (http/https) this app will be
48 # application base url, at which location including a scheme (http/https) this app will be
49 # running, this needs to be a valid resolvable domain for rhodecode links to work properly
49 # running, this needs to be a valid resolvable domain for rhodecode links to work properly
50 RC_APP_BASE_URL=http://base-url
50 RC_APP_BASE_URL=http://base-url
51
51
52 # use celery workers/scheduler
52 # use celery workers/scheduler
53 RC_USE_CELERY=true
53 RC_USE_CELERY=true
54 RC_CELERY_BROKER_URL=redis://redis:6379/8
54 RC_CELERY_BROKER_URL=redis://redis:6379/8
General Comments 0
You need to be logged in to leave comments. Login now