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