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