##// END OF EJS Templates
rcstack: 5.0.5 EULA added
marcink -
Show More
This diff has been collapsed as it changes many lines, (661 lines changed) Show them Hide them
@@ -0,0 +1,661 b''
1 GNU AFFERO GENERAL PUBLIC LICENSE
2 Version 3, 19 November 2007
3
4 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5 Everyone is permitted to copy and distribute verbatim copies
6 of this license document, but changing it is not allowed.
7
8 Preamble
9
10 The GNU Affero General Public License is a free, copyleft license for
11 software and other kinds of works, specifically designed to ensure
12 cooperation with the community in the case of network server software.
13
14 The licenses for most software and other practical works are designed
15 to take away your freedom to share and change the works. By contrast,
16 our General Public Licenses are intended to guarantee your freedom to
17 share and change all versions of a program--to make sure it remains free
18 software for all its users.
19
20 When we speak of free software, we are referring to freedom, not
21 price. Our General Public Licenses are designed to make sure that you
22 have the freedom to distribute copies of free software (and charge for
23 them if you wish), that you receive source code or can get it if you
24 want it, that you can change the software or use pieces of it in new
25 free programs, and that you know you can do these things.
26
27 Developers that use our General Public Licenses protect your rights
28 with two steps: (1) assert copyright on the software, and (2) offer
29 you this License which gives you legal permission to copy, distribute
30 and/or modify the software.
31
32 A secondary benefit of defending all users' freedom is that
33 improvements made in alternate versions of the program, if they
34 receive widespread use, become available for other developers to
35 incorporate. Many developers of free software are heartened and
36 encouraged by the resulting cooperation. However, in the case of
37 software used on network servers, this result may fail to come about.
38 The GNU General Public License permits making a modified version and
39 letting the public access it on a server without ever releasing its
40 source code to the public.
41
42 The GNU Affero General Public License is designed specifically to
43 ensure that, in such cases, the modified source code becomes available
44 to the community. It requires the operator of a network server to
45 provide the source code of the modified version running there to the
46 users of that server. Therefore, public use of a modified version, on
47 a publicly accessible server, gives the public access to the source
48 code of the modified version.
49
50 An older license, called the Affero General Public License and
51 published by Affero, was designed to accomplish similar goals. This is
52 a different license, not a version of the Affero GPL, but Affero has
53 released a new version of the Affero GPL which permits relicensing under
54 this license.
55
56 The precise terms and conditions for copying, distribution and
57 modification follow.
58
59 TERMS AND CONDITIONS
60
61 0. Definitions.
62
63 "This License" refers to version 3 of the GNU Affero General Public License.
64
65 "Copyright" also means copyright-like laws that apply to other kinds of
66 works, such as semiconductor masks.
67
68 "The Program" refers to any copyrightable work licensed under this
69 License. Each licensee is addressed as "you". "Licensees" and
70 "recipients" may be individuals or organizations.
71
72 To "modify" a work means to copy from or adapt all or part of the work
73 in a fashion requiring copyright permission, other than the making of an
74 exact copy. The resulting work is called a "modified version" of the
75 earlier work or a work "based on" the earlier work.
76
77 A "covered work" means either the unmodified Program or a work based
78 on the Program.
79
80 To "propagate" a work means to do anything with it that, without
81 permission, would make you directly or secondarily liable for
82 infringement under applicable copyright law, except executing it on a
83 computer or modifying a private copy. Propagation includes copying,
84 distribution (with or without modification), making available to the
85 public, and in some countries other activities as well.
86
87 To "convey" a work means any kind of propagation that enables other
88 parties to make or receive copies. Mere interaction with a user through
89 a computer network, with no transfer of a copy, is not conveying.
90
91 An interactive user interface displays "Appropriate Legal Notices"
92 to the extent that it includes a convenient and prominently visible
93 feature that (1) displays an appropriate copyright notice, and (2)
94 tells the user that there is no warranty for the work (except to the
95 extent that warranties are provided), that licensees may convey the
96 work under this License, and how to view a copy of this License. If
97 the interface presents a list of user commands or options, such as a
98 menu, a prominent item in the list meets this criterion.
99
100 1. Source Code.
101
102 The "source code" for a work means the preferred form of the work
103 for making modifications to it. "Object code" means any non-source
104 form of a work.
105
106 A "Standard Interface" means an interface that either is an official
107 standard defined by a recognized standards body, or, in the case of
108 interfaces specified for a particular programming language, one that
109 is widely used among developers working in that language.
110
111 The "System Libraries" of an executable work include anything, other
112 than the work as a whole, that (a) is included in the normal form of
113 packaging a Major Component, but which is not part of that Major
114 Component, and (b) serves only to enable use of the work with that
115 Major Component, or to implement a Standard Interface for which an
116 implementation is available to the public in source code form. A
117 "Major Component", in this context, means a major essential component
118 (kernel, window system, and so on) of the specific operating system
119 (if any) on which the executable work runs, or a compiler used to
120 produce the work, or an object code interpreter used to run it.
121
122 The "Corresponding Source" for a work in object code form means all
123 the source code needed to generate, install, and (for an executable
124 work) run the object code and to modify the work, including scripts to
125 control those activities. However, it does not include the work's
126 System Libraries, or general-purpose tools or generally available free
127 programs which are used unmodified in performing those activities but
128 which are not part of the work. For example, Corresponding Source
129 includes interface definition files associated with source files for
130 the work, and the source code for shared libraries and dynamically
131 linked subprograms that the work is specifically designed to require,
132 such as by intimate data communication or control flow between those
133 subprograms and other parts of the work.
134
135 The Corresponding Source need not include anything that users
136 can regenerate automatically from other parts of the Corresponding
137 Source.
138
139 The Corresponding Source for a work in source code form is that
140 same work.
141
142 2. Basic Permissions.
143
144 All rights granted under this License are granted for the term of
145 copyright on the Program, and are irrevocable provided the stated
146 conditions are met. This License explicitly affirms your unlimited
147 permission to run the unmodified Program. The output from running a
148 covered work is covered by this License only if the output, given its
149 content, constitutes a covered work. This License acknowledges your
150 rights of fair use or other equivalent, as provided by copyright law.
151
152 You may make, run and propagate covered works that you do not
153 convey, without conditions so long as your license otherwise remains
154 in force. You may convey covered works to others for the sole purpose
155 of having them make modifications exclusively for you, or provide you
156 with facilities for running those works, provided that you comply with
157 the terms of this License in conveying all material for which you do
158 not control copyright. Those thus making or running the covered works
159 for you must do so exclusively on your behalf, under your direction
160 and control, on terms that prohibit them from making any copies of
161 your copyrighted material outside their relationship with you.
162
163 Conveying under any other circumstances is permitted solely under
164 the conditions stated below. Sublicensing is not allowed; section 10
165 makes it unnecessary.
166
167 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168
169 No covered work shall be deemed part of an effective technological
170 measure under any applicable law fulfilling obligations under article
171 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172 similar laws prohibiting or restricting circumvention of such
173 measures.
174
175 When you convey a covered work, you waive any legal power to forbid
176 circumvention of technological measures to the extent such circumvention
177 is effected by exercising rights under this License with respect to
178 the covered work, and you disclaim any intention to limit operation or
179 modification of the work as a means of enforcing, against the work's
180 users, your or third parties' legal rights to forbid circumvention of
181 technological measures.
182
183 4. Conveying Verbatim Copies.
184
185 You may convey verbatim copies of the Program's source code as you
186 receive it, in any medium, provided that you conspicuously and
187 appropriately publish on each copy an appropriate copyright notice;
188 keep intact all notices stating that this License and any
189 non-permissive terms added in accord with section 7 apply to the code;
190 keep intact all notices of the absence of any warranty; and give all
191 recipients a copy of this License along with the Program.
192
193 You may charge any price or no price for each copy that you convey,
194 and you may offer support or warranty protection for a fee.
195
196 5. Conveying Modified Source Versions.
197
198 You may convey a work based on the Program, or the modifications to
199 produce it from the Program, in the form of source code under the
200 terms of section 4, provided that you also meet all of these conditions:
201
202 a) The work must carry prominent notices stating that you modified
203 it, and giving a relevant date.
204
205 b) The work must carry prominent notices stating that it is
206 released under this License and any conditions added under section
207 7. This requirement modifies the requirement in section 4 to
208 "keep intact all notices".
209
210 c) You must license the entire work, as a whole, under this
211 License to anyone who comes into possession of a copy. This
212 License will therefore apply, along with any applicable section 7
213 additional terms, to the whole of the work, and all its parts,
214 regardless of how they are packaged. This License gives no
215 permission to license the work in any other way, but it does not
216 invalidate such permission if you have separately received it.
217
218 d) If the work has interactive user interfaces, each must display
219 Appropriate Legal Notices; however, if the Program has interactive
220 interfaces that do not display Appropriate Legal Notices, your
221 work need not make them do so.
222
223 A compilation of a covered work with other separate and independent
224 works, which are not by their nature extensions of the covered work,
225 and which are not combined with it such as to form a larger program,
226 in or on a volume of a storage or distribution medium, is called an
227 "aggregate" if the compilation and its resulting copyright are not
228 used to limit the access or legal rights of the compilation's users
229 beyond what the individual works permit. Inclusion of a covered work
230 in an aggregate does not cause this License to apply to the other
231 parts of the aggregate.
232
233 6. Conveying Non-Source Forms.
234
235 You may convey a covered work in object code form under the terms
236 of sections 4 and 5, provided that you also convey the
237 machine-readable Corresponding Source under the terms of this License,
238 in one of these ways:
239
240 a) Convey the object code in, or embodied in, a physical product
241 (including a physical distribution medium), accompanied by the
242 Corresponding Source fixed on a durable physical medium
243 customarily used for software interchange.
244
245 b) Convey the object code in, or embodied in, a physical product
246 (including a physical distribution medium), accompanied by a
247 written offer, valid for at least three years and valid for as
248 long as you offer spare parts or customer support for that product
249 model, to give anyone who possesses the object code either (1) a
250 copy of the Corresponding Source for all the software in the
251 product that is covered by this License, on a durable physical
252 medium customarily used for software interchange, for a price no
253 more than your reasonable cost of physically performing this
254 conveying of source, or (2) access to copy the
255 Corresponding Source from a network server at no charge.
256
257 c) Convey individual copies of the object code with a copy of the
258 written offer to provide the Corresponding Source. This
259 alternative is allowed only occasionally and noncommercially, and
260 only if you received the object code with such an offer, in accord
261 with subsection 6b.
262
263 d) Convey the object code by offering access from a designated
264 place (gratis or for a charge), and offer equivalent access to the
265 Corresponding Source in the same way through the same place at no
266 further charge. You need not require recipients to copy the
267 Corresponding Source along with the object code. If the place to
268 copy the object code is a network server, the Corresponding Source
269 may be on a different server (operated by you or a third party)
270 that supports equivalent copying facilities, provided you maintain
271 clear directions next to the object code saying where to find the
272 Corresponding Source. Regardless of what server hosts the
273 Corresponding Source, you remain obligated to ensure that it is
274 available for as long as needed to satisfy these requirements.
275
276 e) Convey the object code using peer-to-peer transmission, provided
277 you inform other peers where the object code and Corresponding
278 Source of the work are being offered to the general public at no
279 charge under subsection 6d.
280
281 A separable portion of the object code, whose source code is excluded
282 from the Corresponding Source as a System Library, need not be
283 included in conveying the object code work.
284
285 A "User Product" is either (1) a "consumer product", which means any
286 tangible personal property which is normally used for personal, family,
287 or household purposes, or (2) anything designed or sold for incorporation
288 into a dwelling. In determining whether a product is a consumer product,
289 doubtful cases shall be resolved in favor of coverage. For a particular
290 product received by a particular user, "normally used" refers to a
291 typical or common use of that class of product, regardless of the status
292 of the particular user or of the way in which the particular user
293 actually uses, or expects or is expected to use, the product. A product
294 is a consumer product regardless of whether the product has substantial
295 commercial, industrial or non-consumer uses, unless such uses represent
296 the only significant mode of use of the product.
297
298 "Installation Information" for a User Product means any methods,
299 procedures, authorization keys, or other information required to install
300 and execute modified versions of a covered work in that User Product from
301 a modified version of its Corresponding Source. The information must
302 suffice to ensure that the continued functioning of the modified object
303 code is in no case prevented or interfered with solely because
304 modification has been made.
305
306 If you convey an object code work under this section in, or with, or
307 specifically for use in, a User Product, and the conveying occurs as
308 part of a transaction in which the right of possession and use of the
309 User Product is transferred to the recipient in perpetuity or for a
310 fixed term (regardless of how the transaction is characterized), the
311 Corresponding Source conveyed under this section must be accompanied
312 by the Installation Information. But this requirement does not apply
313 if neither you nor any third party retains the ability to install
314 modified object code on the User Product (for example, the work has
315 been installed in ROM).
316
317 The requirement to provide Installation Information does not include a
318 requirement to continue to provide support service, warranty, or updates
319 for a work that has been modified or installed by the recipient, or for
320 the User Product in which it has been modified or installed. Access to a
321 network may be denied when the modification itself materially and
322 adversely affects the operation of the network or violates the rules and
323 protocols for communication across the network.
324
325 Corresponding Source conveyed, and Installation Information provided,
326 in accord with this section must be in a format that is publicly
327 documented (and with an implementation available to the public in
328 source code form), and must require no special password or key for
329 unpacking, reading or copying.
330
331 7. Additional Terms.
332
333 "Additional permissions" are terms that supplement the terms of this
334 License by making exceptions from one or more of its conditions.
335 Additional permissions that are applicable to the entire Program shall
336 be treated as though they were included in this License, to the extent
337 that they are valid under applicable law. If additional permissions
338 apply only to part of the Program, that part may be used separately
339 under those permissions, but the entire Program remains governed by
340 this License without regard to the additional permissions.
341
342 When you convey a copy of a covered work, you may at your option
343 remove any additional permissions from that copy, or from any part of
344 it. (Additional permissions may be written to require their own
345 removal in certain cases when you modify the work.) You may place
346 additional permissions on material, added by you to a covered work,
347 for which you have or can give appropriate copyright permission.
348
349 Notwithstanding any other provision of this License, for material you
350 add to a covered work, you may (if authorized by the copyright holders of
351 that material) supplement the terms of this License with terms:
352
353 a) Disclaiming warranty or limiting liability differently from the
354 terms of sections 15 and 16 of this License; or
355
356 b) Requiring preservation of specified reasonable legal notices or
357 author attributions in that material or in the Appropriate Legal
358 Notices displayed by works containing it; or
359
360 c) Prohibiting misrepresentation of the origin of that material, or
361 requiring that modified versions of such material be marked in
362 reasonable ways as different from the original version; or
363
364 d) Limiting the use for publicity purposes of names of licensors or
365 authors of the material; or
366
367 e) Declining to grant rights under trademark law for use of some
368 trade names, trademarks, or service marks; or
369
370 f) Requiring indemnification of licensors and authors of that
371 material by anyone who conveys the material (or modified versions of
372 it) with contractual assumptions of liability to the recipient, for
373 any liability that these contractual assumptions directly impose on
374 those licensors and authors.
375
376 All other non-permissive additional terms are considered "further
377 restrictions" within the meaning of section 10. If the Program as you
378 received it, or any part of it, contains a notice stating that it is
379 governed by this License along with a term that is a further
380 restriction, you may remove that term. If a license document contains
381 a further restriction but permits relicensing or conveying under this
382 License, you may add to a covered work material governed by the terms
383 of that license document, provided that the further restriction does
384 not survive such relicensing or conveying.
385
386 If you add terms to a covered work in accord with this section, you
387 must place, in the relevant source files, a statement of the
388 additional terms that apply to those files, or a notice indicating
389 where to find the applicable terms.
390
391 Additional terms, permissive or non-permissive, may be stated in the
392 form of a separately written license, or stated as exceptions;
393 the above requirements apply either way.
394
395 8. Termination.
396
397 You may not propagate or modify a covered work except as expressly
398 provided under this License. Any attempt otherwise to propagate or
399 modify it is void, and will automatically terminate your rights under
400 this License (including any patent licenses granted under the third
401 paragraph of section 11).
402
403 However, if you cease all violation of this License, then your
404 license from a particular copyright holder is reinstated (a)
405 provisionally, unless and until the copyright holder explicitly and
406 finally terminates your license, and (b) permanently, if the copyright
407 holder fails to notify you of the violation by some reasonable means
408 prior to 60 days after the cessation.
409
410 Moreover, your license from a particular copyright holder is
411 reinstated permanently if the copyright holder notifies you of the
412 violation by some reasonable means, this is the first time you have
413 received notice of violation of this License (for any work) from that
414 copyright holder, and you cure the violation prior to 30 days after
415 your receipt of the notice.
416
417 Termination of your rights under this section does not terminate the
418 licenses of parties who have received copies or rights from you under
419 this License. If your rights have been terminated and not permanently
420 reinstated, you do not qualify to receive new licenses for the same
421 material under section 10.
422
423 9. Acceptance Not Required for Having Copies.
424
425 You are not required to accept this License in order to receive or
426 run a copy of the Program. Ancillary propagation of a covered work
427 occurring solely as a consequence of using peer-to-peer transmission
428 to receive a copy likewise does not require acceptance. However,
429 nothing other than this License grants you permission to propagate or
430 modify any covered work. These actions infringe copyright if you do
431 not accept this License. Therefore, by modifying or propagating a
432 covered work, you indicate your acceptance of this License to do so.
433
434 10. Automatic Licensing of Downstream Recipients.
435
436 Each time you convey a covered work, the recipient automatically
437 receives a license from the original licensors, to run, modify and
438 propagate that work, subject to this License. You are not responsible
439 for enforcing compliance by third parties with this License.
440
441 An "entity transaction" is a transaction transferring control of an
442 organization, or substantially all assets of one, or subdividing an
443 organization, or merging organizations. If propagation of a covered
444 work results from an entity transaction, each party to that
445 transaction who receives a copy of the work also receives whatever
446 licenses to the work the party's predecessor in interest had or could
447 give under the previous paragraph, plus a right to possession of the
448 Corresponding Source of the work from the predecessor in interest, if
449 the predecessor has it or can get it with reasonable efforts.
450
451 You may not impose any further restrictions on the exercise of the
452 rights granted or affirmed under this License. For example, you may
453 not impose a license fee, royalty, or other charge for exercise of
454 rights granted under this License, and you may not initiate litigation
455 (including a cross-claim or counterclaim in a lawsuit) alleging that
456 any patent claim is infringed by making, using, selling, offering for
457 sale, or importing the Program or any portion of it.
458
459 11. Patents.
460
461 A "contributor" is a copyright holder who authorizes use under this
462 License of the Program or a work on which the Program is based. The
463 work thus licensed is called the contributor's "contributor version".
464
465 A contributor's "essential patent claims" are all patent claims
466 owned or controlled by the contributor, whether already acquired or
467 hereafter acquired, that would be infringed by some manner, permitted
468 by this License, of making, using, or selling its contributor version,
469 but do not include claims that would be infringed only as a
470 consequence of further modification of the contributor version. For
471 purposes of this definition, "control" includes the right to grant
472 patent sublicenses in a manner consistent with the requirements of
473 this License.
474
475 Each contributor grants you a non-exclusive, worldwide, royalty-free
476 patent license under the contributor's essential patent claims, to
477 make, use, sell, offer for sale, import and otherwise run, modify and
478 propagate the contents of its contributor version.
479
480 In the following three paragraphs, a "patent license" is any express
481 agreement or commitment, however denominated, not to enforce a patent
482 (such as an express permission to practice a patent or covenant not to
483 sue for patent infringement). To "grant" such a patent license to a
484 party means to make such an agreement or commitment not to enforce a
485 patent against the party.
486
487 If you convey a covered work, knowingly relying on a patent license,
488 and the Corresponding Source of the work is not available for anyone
489 to copy, free of charge and under the terms of this License, through a
490 publicly available network server or other readily accessible means,
491 then you must either (1) cause the Corresponding Source to be so
492 available, or (2) arrange to deprive yourself of the benefit of the
493 patent license for this particular work, or (3) arrange, in a manner
494 consistent with the requirements of this License, to extend the patent
495 license to downstream recipients. "Knowingly relying" means you have
496 actual knowledge that, but for the patent license, your conveying the
497 covered work in a country, or your recipient's use of the covered work
498 in a country, would infringe one or more identifiable patents in that
499 country that you have reason to believe are valid.
500
501 If, pursuant to or in connection with a single transaction or
502 arrangement, you convey, or propagate by procuring conveyance of, a
503 covered work, and grant a patent license to some of the parties
504 receiving the covered work authorizing them to use, propagate, modify
505 or convey a specific copy of the covered work, then the patent license
506 you grant is automatically extended to all recipients of the covered
507 work and works based on it.
508
509 A patent license is "discriminatory" if it does not include within
510 the scope of its coverage, prohibits the exercise of, or is
511 conditioned on the non-exercise of one or more of the rights that are
512 specifically granted under this License. You may not convey a covered
513 work if you are a party to an arrangement with a third party that is
514 in the business of distributing software, under which you make payment
515 to the third party based on the extent of your activity of conveying
516 the work, and under which the third party grants, to any of the
517 parties who would receive the covered work from you, a discriminatory
518 patent license (a) in connection with copies of the covered work
519 conveyed by you (or copies made from those copies), or (b) primarily
520 for and in connection with specific products or compilations that
521 contain the covered work, unless you entered into that arrangement,
522 or that patent license was granted, prior to 28 March 2007.
523
524 Nothing in this License shall be construed as excluding or limiting
525 any implied license or other defenses to infringement that may
526 otherwise be available to you under applicable patent law.
527
528 12. No Surrender of Others' Freedom.
529
530 If conditions are imposed on you (whether by court order, agreement or
531 otherwise) that contradict the conditions of this License, they do not
532 excuse you from the conditions of this License. If you cannot convey a
533 covered work so as to satisfy simultaneously your obligations under this
534 License and any other pertinent obligations, then as a consequence you may
535 not convey it at all. For example, if you agree to terms that obligate you
536 to collect a royalty for further conveying from those to whom you convey
537 the Program, the only way you could satisfy both those terms and this
538 License would be to refrain entirely from conveying the Program.
539
540 13. Remote Network Interaction; Use with the GNU General Public License.
541
542 Notwithstanding any other provision of this License, if you modify the
543 Program, your modified version must prominently offer all users
544 interacting with it remotely through a computer network (if your version
545 supports such interaction) an opportunity to receive the Corresponding
546 Source of your version by providing access to the Corresponding Source
547 from a network server at no charge, through some standard or customary
548 means of facilitating copying of software. This Corresponding Source
549 shall include the Corresponding Source for any work covered by version 3
550 of the GNU General Public License that is incorporated pursuant to the
551 following paragraph.
552
553 Notwithstanding any other provision of this License, you have
554 permission to link or combine any covered work with a work licensed
555 under version 3 of the GNU General Public License into a single
556 combined work, and to convey the resulting work. The terms of this
557 License will continue to apply to the part which is the covered work,
558 but the work with which it is combined will remain governed by version
559 3 of the GNU General Public License.
560
561 14. Revised Versions of this License.
562
563 The Free Software Foundation may publish revised and/or new versions of
564 the GNU Affero General Public License from time to time. Such new versions
565 will be similar in spirit to the present version, but may differ in detail to
566 address new problems or concerns.
567
568 Each version is given a distinguishing version number. If the
569 Program specifies that a certain numbered version of the GNU Affero General
570 Public License "or any later version" applies to it, you have the
571 option of following the terms and conditions either of that numbered
572 version or of any later version published by the Free Software
573 Foundation. If the Program does not specify a version number of the
574 GNU Affero General Public License, you may choose any version ever published
575 by the Free Software Foundation.
576
577 If the Program specifies that a proxy can decide which future
578 versions of the GNU Affero General Public License can be used, that proxy's
579 public statement of acceptance of a version permanently authorizes you
580 to choose that version for the Program.
581
582 Later license versions may give you additional or different
583 permissions. However, no additional obligations are imposed on any
584 author or copyright holder as a result of your choosing to follow a
585 later version.
586
587 15. Disclaimer of Warranty.
588
589 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590 APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591 HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592 OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595 IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596 ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597
598 16. Limitation of Liability.
599
600 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602 THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603 GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604 USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605 DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606 PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607 EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608 SUCH DAMAGES.
609
610 17. Interpretation of Sections 15 and 16.
611
612 If the disclaimer of warranty and limitation of liability provided
613 above cannot be given local legal effect according to their terms,
614 reviewing courts shall apply local law that most closely approximates
615 an absolute waiver of all civil liability in connection with the
616 Program, unless a warranty or assumption of liability accompanies a
617 copy of the Program in return for a fee.
618
619 END OF TERMS AND CONDITIONS
620
621 How to Apply These Terms to Your New Programs
622
623 If you develop a new program, and you want it to be of the greatest
624 possible use to the public, the best way to achieve this is to make it
625 free software which everyone can redistribute and change under these terms.
626
627 To do so, attach the following notices to the program. It is safest
628 to attach them to the start of each source file to most effectively
629 state the exclusion of warranty; and each file should have at least
630 the "copyright" line and a pointer to where the full notice is found.
631
632 <one line to give the program's name and a brief idea of what it does.>
633 Copyright (C) <year> <name of author>
634
635 This program is free software: you can redistribute it and/or modify
636 it under the terms of the GNU Affero General Public License as published by
637 the Free Software Foundation, either version 3 of the License, or
638 (at your option) any later version.
639
640 This program is distributed in the hope that it will be useful,
641 but WITHOUT ANY WARRANTY; without even the implied warranty of
642 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643 GNU Affero General Public License for more details.
644
645 You should have received a copy of the GNU Affero General Public License
646 along with this program. If not, see <http://www.gnu.org/licenses/>.
647
648 Also add information on how to contact you by electronic and paper mail.
649
650 If your software can interact with users remotely through a computer
651 network, you should also make sure that it provides a way for users to
652 get its source. For example, if your program is a web application, its
653 interface could display a "Source" link that leads users to an archive
654 of the code. There are many ways you could offer source, and different
655 solutions will be better for different programs; see section 13 for the
656 specific requirements.
657
658 You should also get your employer (if you work as a programmer) or school,
659 if any, to sign a "copyright disclaimer" for the program, if necessary.
660 For more information on this, and how to apply and follow the GNU AGPL, see
661 <http://www.gnu.org/licenses/>.
@@ -0,0 +1,48 b''
1 SOFTWARE LICENSE TERMS
2
3 1. Grant of License and Restrictions. Subject to the terms hereof, payment of all fees, and any applicable user/use limitations, either RhodeCode, Inc. or RhodeCode, GmbH (as specified in the Order Form) ("RhodeCode") grants Licensee a personal, nonsublicensable, nonexclusive, right to use the licensed product in object code form only ("Product") only in accordance with RhodeCode's applicable user documentation and price list. RhodeCode retains ownership of all copies and Licensee will maintain the copyright notice and any other notices that appear on the Product on any copies and any media. Licensee will not (and will not allow any third party to) (i) reverse engineer or attempt to discover any source code or underlying ideas or algorithms of any Product (except to the extent that applicable law prohibits reverse engineering restrictions), (ii) provide, lease, lend, disclose, use for timesharing or service bureau purposes, or otherwise use or allow others to use for the benefit of any third party, any Product (except as expressly and specifically authorized by RhodeCode), (iii) possess or use any Product, or allow the transfer, transmission, export, or re-export of any Product or portion thereof in violation of any export control laws or regulations administered by the U.S. Commerce Department, U.S. Treasury Department's Office of Foreign Assets Control, or any other government agency, or (v) modify any Product. Prior to disposing of any media or apparatus containing any part of the Product, Licensee shall completely destroy any Product contained therein. All the limitations and restrictions on Products in this Agreement also apply to documentation. LICENSEE ACKNOWLEDGES THAT THE PRODUCT MAY INCLUDE FEATURES TO PREVENT USE AFTER THE APPLICABLE LICENSE PERIOD AND/OR USE INCONSISTENT HEREWITH. Licensee acknowledges that Product may be distributed alongside or contain or use certain third party software including software components provided under an open source license ("Third Party Software"). THIRD PARTY SOFTWARE IS SUBJECT TO AND GOVERNED BY (AND LICENSEE AGREES TO, AND WILL INDEMNIFY RHODECODE FOR NONCOMPLIANCE WITH) THE RESPECTIVE LICENSES FOR THE THIRD PARTY SOFTWARE AVAILABLE AT APPENDIX.
4
5 2. Support and Maintenance. During the license period, RhodeCode will use reasonable commercial efforts to provide the support and maintenance services for that Product as and to the extent described in RhodeCode's then applicable standard Support and Maintenance Terms (the current version of which can be found on RhodeCode's web site ("Support Services").
6
7 3. Fees and Payment. Within thirty days after first receipt of the Product or the date(s) otherwise expressly agreed by RhodeCode, Licensee shall pay RhodeCode's then current applicable license/subscription fees for any authorized copies or uses of the Product or such other fees as have been expressly agreed to by RhodeCode ("License Fees"). License Fees for renewal terms for annual subscriptions will also be paid annually in advance. At the same time as payment of the initial License Fees, and annually in advance thereafter (and except to the extent included in License Fees for annual subscriptions), Licensee shall also pay any applicable fees for Support Services or such other support and maintenance fees as have been expressly agreed to by RhodeCode at RhodeCode's then current rates for such services ("Annual Support Services Fees"). In addition, without limiting RhodeCode's remedies, if Licensee makes or uses copies, or has users/uses, that are not authorized hereunder, it will so report to RhodeCode and will pay additional license and maintenance and support fees equal to RhodeCode's then current standard fees for the license and maintenance and support of such extra copies and users/uses (from time to time upon request, RhodeCode will be entitled to audit or have audited all systems and records relevant to assure compliance with the foregoing; any audit showing noncompliance will be at Licensee's expense). All payments shall be made in U.S. dollars if Licensee licenses the Product from RhodeCode, Inc. or Euros if Licensee licenses the Product from RhodeCode, GmbH. Any payments more than thirty (30) days overdue will bear a late payment fee of 1.5% per month, or, if lower, the maximum rate allowed by law. In addition, Licensee will pay all taxes, shipping, duties, withholdings, backup withholding and the like; when RhodeCode has the legal obligation to pay or collect such taxes, the appropriate amount shall paid by Licensee directly to RhodeCode.
8
9 4. Termination; Breach. All licenses will terminate thirty days (ten in the case of non-payment and immediately in the case of a breach of Section 1) after notice of any breach by Licensee remaining uncured at the end of such notice period. A license will also terminate upon the expiration of any applicable license period specified for the applicable Product on the RhodeCode price list or such other license period as have been expressly agreed to by RhodeCode, subject to annual renewal (upon mutual written agreement each year) in the case of an annual subscription license. In the event that the Product is subject to a court-approved claim that it infringes a third party's patent rights, RhodeCode may, in its sole discretion, terminate the Agreement and refund to Licensee a pro rata portion of the License Fees and Annual Support Services Fees already paid to RhodeCode. Upon any termination, Licensee shall immediately cease all use of all affected Products and return or destroy all copies of all affected Products and all portions thereof and so certify to RhodeCode. Except as otherwise expressly provided herein, the terms hereof shall survive any termination. Termination is not an exclusive remedy and all other remedies will be available whether or not termination occurs. THE PRODUCT MAY CONTAIN DISABLING CODE THAT WILL MAKE THE PRODUCT (AND RELATED DATA) UNUSABLE UPON TERMINATION OF THE LICENSE.
10
11 5. Indemnification. RhodeCode shall hold Licensee harmless from liability to third parties resulting from infringement by a Product of any patent validly issued in the United States and/or any European Union country and issued sixty (60) days or more before delivery of such Product or any copyright or misappropriation of any trade secret, provided RhodeCode is promptly notified of any and all threats, claims and proceedings related thereto and given reasonable assistance and the opportunity to assume sole control over defense and settlement; RhodeCode will not be responsible for any settlement it does not approve. The foregoing obligations do not apply with respect to a Product or portions or components thereof (i) not created by RhodeCode, (ii) that are modified after delivery by RhodeCode, (iii) combined with other products, processes or materials where the alleged infringement relates to such combination, (iv) where Licensee continues allegedly infringing activity after being notified thereof or after being informed of modifications that would have avoided the alleged infringement, or (v) where Licensee's use of such Product is not strictly in accordance herewith.
12
13 6. Limited Warranty and Disclaimer. RhodeCode warrants for a period of thirty (30) days from delivery of a Product that such Product will materially conform to RhodeCode's then current user documentation for such Product. This warranty covers only problems reported to RhodeCode during the warranty period. ANY LIABILITY OF RHODECODE WITH RESPECT TO A PRODUCT OR THE PERFORMANCE THEREOF UNDER ANY WARRANTY, NEGLIGENCE, STRICT LIABILITY OR OTHER THEORY WILL BE LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR, IF REPLACEMENT IS INADEQUATE AS A REMEDY OR, IN RHODECODE'S OPINION, IMPRACTICAL, TO REFUND OF AN APPROPRIATE PORTION THE REMAINING UNAMORTIZED LICENSE FEE PAID BY LICENSEE. EXCEPT FOR THE FOREGOING WARRANTY BY RHODECODE, ALL PRODUCTS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND FROM ANYONE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. FURTHER, RHODECODE DOES NOT WARRANT RESULTS OF USE OR THAT THE PRODUCTS ARE BUG FREE OR THAT THE PRODUCT'S USE WILL BE UNINTERRUPTED.
14
15 7. Limitation of Liability. NOTWITHSTANDING ANYTHING ELSE HEREIN OR OTHERWISE, AND EXCEPT FOR BODILY INJURY, NEITHER RHODECODE NOR ANY LICENSOR SHALL BE LIABLE OR OBLIGATED WITH RESPECT TO THE SUBJECT MATTER HEREOF OR UNDER ANY CONTRACT, NEGLIGENCE, STRICT LIABILITY OR OTHER LEGAL OR EQUITABLE THEORY (I) FOR ANY AMOUNTS IN EXCESS IN THE AGGREGATE OF THE GREATER OF (A) $100 OR (B) THE FEES PAID TO IT HEREUNDER WITH RESPECT TO THE APPLICABLE PRODUCT DURING THE TWELVE MONTH PERIOD PRIOR TO THE CAUSE OF ACTION; (II) FOR ANY COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES OR RIGHTS; (III) FOR ANY INCIDENTAL OR CONSEQUENTIAL DAMAGES; (IV) FOR INTERRUPTION OF USE OR LOSS OR CORRUPTION OF DATA; OR (V)FOR ANY MATTER BEYOND ITS REASONABLE CONTROL. THE PRODUCT IS NOT DESIGNED, MANUFACTURED, OR INTENDED FOR USE IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE PERFORMANCE WHERE THE FAILURE OF THE PRODUCT COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SIGNIFICANT PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES"). USE OF THE PRODUCT IN HIGH RISK ACTIVITIES IS NOT AUTHORIZED. THE PARTIES AGREE THAT THIS SECTION 7 REPRESENTS A REASONABLE ALLOCATION OF RISK AND THAT LICENSOR WOULD NOT PROCEED IN THE ABSENCE OF SUCH ALLOCATION.
16
17 8. Embedded Reporting / Compliance Routine; Data Access and Use. Licensee acknowledges that Products may contain reporting routines that will identify and analyze certain aspects of use and performance of Products and/or the systems on which they are installed, as well as the operator and operating environment (including problems and issues that arise in connection therewith). RhodeCode may request Licensee to send such reports and information to RhodeCode for diagnostic or billing purposes. Provided it does not identify Licensee, RhodeCode will be free to use for development, diagnostic and corrective purposes any data and information it so collects relating to diagnosis, problems, systems, performance, use or functionality, and may allow others to do so.
18
19 9. Professional Services. RhodeCode may provide consulting, training or other professional services for Licensee, as agreed upon in a separate order form. Upon payment of any applicable professional services fees and related expenses, specified in the applicable order form, RhodeCode agrees to use reasonable commercial efforts to provide agreed upon professional services. If RhodeCode cannot complete the professional services within the estimated hours, or if the RhodeCode provides additional professional services, Licensee will pay RhodeCode at its then-current hourly rates for consultation. RhodeCode retains ownership of all results of professional services.
20
21 10. Miscellaneous. Neither this arrangement nor the licenses granted hereunder are assignable or transferable (and any attempt to do so shall be void); provided that either party may assign and transfer the foregoing to a successor to substantially all of RhodeCode's Product business or assets or Licensee's business for which Products are licensed (but if the authorized copies or users are not limited, the assignee is not licensed to expand use beyond Licensee's bona fide pre-assignment use plus reasonably expected growth assuming the assignment and related transactions had not occurred). The provisions hereof are for the benefit of the parties only and not for any other person or entity. Any notice, report, approval, authorization, agreement or consent required or permitted hereunder shall be in writing; notices shall be sent to the address the applicable party has or may provide by written notice or, if there is no such address, the most recent address the party giving notice can locate using reasonable efforts. No failure or delay in exercising any right hereunder will operate as a waiver thereof, nor will any partial exercise of any right or power hereunder preclude further exercise. If any provision shall be adjudged by any court of competent jurisdiction to be unenforceable or invalid, that provision shall be limited or eliminated to the minimum extent necessary so that this arrangement shall otherwise remain in full force and effect and enforceable. This Agreement shall be deemed to have been made in, and shall be construed pursuant to the laws of the State of California and the United States without regard to conflicts of laws provisions thereof, and without regard to the United Nations Convention on the International Sale of Goods or the Uniform Computer Information Transactions Act. This is the complete and exclusive statement of the mutual understanding of the parties and supersedes and cancels all previous written and oral agreements and communications relating to the subject matter hereof and any waivers or amendments shall be effective only if made in writing; however, if a separate written license agreement with respect to this product exists between Licensee and RhodeCode, the terms of that written license agreement (excluding the pre-printed terms of any purchase order, confirmation or similar document, which, even if signed by the parties after the effectiveness hereof, will have no effect and will not be considered agreed to by RhodeCode) shall take precedence over this Agreement. The substantially prevailing party in any action to enforce this Agreement will be entitled to recover its attorney's fees and costs in connection with such action. As defined in FAR section 2.101, DFAR section 252.227-7014(a)(1) and DFAR section 252.227-7014(a)(5) or otherwise, all Products and accompanying documentation provided by RhodeCode are "commercial items," "commercial computer software" and/or "commercial computer software documentation." Consistent with DFAR section 227.7202 and FAR section 12.212, any use, modification, reproduction, release, performance, display, disclosure or distribution thereof by or for the U.S. Government shall be governed solely by these terms and shall be prohibited except to the extent expressly permitted by these terms.
22
23 11. Privacy Policy. By accepting this License agreement you acknowledge that you agree to the general data Privacy Policy Terms.
24 The current version of which can be found on RhodeCode's web site ("Privacy Policy").
25
26
27 APPENDIX
28
29 Licenses of Third Party Packages
30
31 * APSL-2.0 http://spdx.org/licenses/APSL-2.0
32 * Apache-2.0 http://spdx.org/licenses/Apache-2.0
33 * BSD-2-Clause http://spdx.org/licenses/BSD-2-Clause
34 * BSD-3-Clause http://spdx.org/licenses/BSD-3-Clause
35 * BSD-4-Clause http://spdx.org/licenses/BSD-4-Clause
36 * LGPL-3.0 http://spdx.org/licenses/LGPL-3.0
37 * LGPL-3.0+ http://spdx.org/licenses/LGPL-3.0+
38 * Libpng http://spdx.org/licenses/Libpng
39 * MIT http://spdx.org/licenses/MIT
40 * OLDAP-2.8 http://spdx.org/licenses/OLDAP-2.8
41 * OpenSSL http://spdx.org/licenses/OpenSSL
42 * Python-2.0 http://spdx.org/licenses/Python-2.0
43 * Unlicense http://spdx.org/licenses/Unlicense
44 * ZPL-2.1 http://spdx.org/licenses/ZPL-2.1
45 * Zlib http://spdx.org/licenses/Zlib
46 * cyrus http://cyrusimap.web.cmu.edu/mediawiki/index.php/Downloads#Licensing
47 * expat http://directory.fsf.org/wiki/License:Expat
48 * repoze http://repoze.org/license.html
@@ -1,24 +1,30 b''
1 1 .. :changelog:
2 2
3 3 Release History
4 4 ---------------
5 5
6 6
7 5.0.6 (2023-10-12)
8 ++++++++++++++++++
9
10 * rcstack asks for EULA for CE/EE versions
11
12
7 13 5.0.5 (2023-10-10)
8 14 ++++++++++++++++++
9 15
10 16 * expose DOMAIN/_pages to expose "pages" like drop-folder to serve static pages
11 17 * change documention to RST
12 18
13 19
14 20 5.0.4 (2023-09-29)
15 21 ++++++++++++++++++
16 22
17 23 * rcstack: remove dependency for md5sum, this allows to run on macOS
18 24 * nginx: cleanup configuration files to single conf file
19 25
20 26
21 27 5.0.0 (2023-09-21)
22 28 ++++++++++++++++++
23 29
24 30 * initial release for new python3 RhodeCode installer
@@ -1,35 +1,36 b''
1 1 # Configuration file for the Sphinx documentation builder.
2 2 #
3 3 # For the full list of built-in configuration values, see the documentation:
4 4 # https://www.sphinx-doc.org/en/master/usage/configuration.html
5 5
6 6 # -- Project information -----------------------------------------------------
7 7 # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8 8 import datetime
9 9
10 10 now = datetime.datetime.today()
11 11
12 12 project = 'RhodeCode rcstack'
13 13 copyright = f'2010-{now.year}, RhodeCode Inc.'
14 14 author = 'RhodeCode Inc.'
15 15
16 16 # -- General configuration ---------------------------------------------------
17 17 # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
18 18
19 19 extensions = [
20 20 'sphinx_rtd_theme'
21 21 ]
22 22
23 23 templates_path = ['_templates']
24 24 exclude_patterns = []
25 25
26 26 # The name of the Pygments (syntax highlighting) style to use.
27 27 pygments_style = 'sphinx'
28 28
29 29 # -- Options for HTML output -------------------------------------------------
30 30 # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
31 31
32 32 html_theme = 'furo'
33 33 html_static_path = ['_static']
34 34 html_last_updated_fmt = ' %H:%m %b %d, %Y'
35 35 html_show_sphinx = False
36 html_extra_path = ['extra']
@@ -1,122 +1,122 b''
1 Welcome to RhodeCode Cluster (rcstack) documentation!
2 =====================================================
1 Welcome to RhodeCode rcstack documentation!
2 ===========================================
3 3
4 4
5 ===========================
6 RhodeCode Cluster (rcstack)
7 ===========================
5 =================
6 RhodeCode rcstack
7 =================
8 8
9 RhodeCode Cluster is a multi-node highly-scalable setup to run RhodeCode services.
9 RhodeCode rcstack is a multi-node highly-scalable setup to run RhodeCode services.
10 10 It consists of all RhodeCode services required with additionally
11 11 Edge Router(Traefik with optional SSL) and Metrics Stack (Prometheus, Loki, Grafana) in single environment using Docker.
12 12
13 13 Using a docker-compose this setup creates following services for RhodeCode:
14 14
15 15
16 16
17 17 **Router (mandatory to run):**
18 18
19 19
20 20 .. code-block:: bash
21 21
22 22 ./rcstack router --help
23 23
24 24
25 25 `Traefik <https://doc.traefik.io/traefik/>`_ aka Edge Router is responsible for handling all outgoing and incoming traffic to whole stack.
26 26 It can do SSL termination, and handle SSL traffic with certificate management.
27 27
28 28 Traefik listens to few defaults ports and
29 29 handles all incoming/outgoing traffic to the stack
30 30
31 31 - 80 (HTTP)
32 32 - 443 (HTTPS)
33 33 - 9443 (SSH for RhodeCode traffic)
34 34 - 3100 (Loki log aggregation)
35 35
36 36
37 37 **Services (mandatory to run):**
38 38
39 39 .. code-block:: bash
40 40
41 41 ./rcstack services --help
42 42
43 43
44 44 - Database (defaults to PostgreSQL) Optionally can be replaced by MySQL, or own external database if needed.
45 45 - Redis, acts as cache and queue exchange
46 46 - ChannelStream - live websocket communications
47 47 - Elasticsearch (full text search backend)
48 48 - Nginx (static file service) proxy serving RhodeCode static files
49 49
50 50
51 51 **RhodeCode (mandatory to run):**
52 52
53 53 .. code-block:: bash
54 54
55 55 ./rcstack rhodecode --help
56 56
57 57
58 58 - RhodeCode CE/EE web app
59 59 - VCSServer for GIT/SVN/HG support
60 60 - SSH server for cloning over SSH
61 61 - SVN webserver for SVN protocol support
62 62 - Celery workers for asynchronous tasks
63 63 - Celery beat for scheduler and automation tasks
64 64
65 65
66 66 **Metrics (Optional)**
67 67
68 68 .. code-block:: bash
69 69
70 70 ./rcstack metrics --help
71 71
72 72 - Loki, logs aggregation
73 73 - Grafana, metrics Dashboard
74 74 - Prometheus, metrics time-series
75 75 - Statsd-exporter - statsd to Prometheus bridge
76 76 - Node-exporter - machine stats and usage
77 77 - Promtail - log scraping
78 78
79 79
80 80 .. toctree::
81 81 :maxdepth: 1
82 82 :hidden:
83 83 :caption: Installation
84 84
85 85 install/installation.rst
86 86 install/upgrade.rst
87 87
88 88
89 89 .. toctree::
90 90 :maxdepth: 1
91 91 :hidden:
92 92 :caption: Configuration
93 93
94 94 configuration/configuration-overview.rst
95 95 configuration/scaling-rhodecode.rst
96 96 configuration/enable-ssl-on-traefik.rst
97 97 configuration/data-volumes.rst
98 98 configuration/set-license-file.rst
99 99
100 100
101 101 .. toctree::
102 102 :maxdepth: 1
103 103 :hidden:
104 104 :caption: Migration
105 105
106 106 migration/migration-to-docker.rst
107 107
108 108
109 109 .. toctree::
110 110 :maxdepth: 1
111 111 :hidden:
112 112 :caption: Builds & Images
113 113
114 114 builds/build-new-image.rst
115 115 builds/building-images.rst
116 116
117 117 .. toctree::
118 118 :maxdepth: 1
119 119 :hidden:
120 120 :caption: Changelog
121 121
122 122 changes.rst No newline at end of file
@@ -1,7017 +1,7047 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 rcstack_usage() {
22 22 if [[ -n $long_usage ]]; then
23 23 printf "rcstack\n"
24 24 echo
25 25
26 26 printf " CLI for installing and managing RhodeCode Cluster Stack \nSupport:\n https://community.rhodecode.com\nDocs: https://docs.rhodecode.com/rcstack\n"
27 27 echo
28 28
29 29 else
30 30 printf "rcstack - CLI for installing and managing RhodeCode Cluster Stack \nSupport: https://community.rhodecode.com\nDocs: https://docs.rhodecode.com/rcstack\n"
31 31 echo
32 32
33 33 fi
34 34
35 35 printf "%s\n" "Usage:"
36 36 printf " rcstack [OPTIONS] COMMAND\n"
37 37 printf " rcstack [COMMAND] --help | -h\n"
38 38 printf " rcstack --version | -v\n"
39 39 echo
40 40 # :command.usage_commands
41 41 printf "%s\n" "Commands:"
42 42 printf " %s Print instructions to get started with rhodecode docker stack\n" "get-started "
43 43 printf " %s Bootstrap this machine, check docker version and install rhodecode-network\n" "init "
44 44 printf " %s Update rcstack and it's docker definitions\n" "self-update "
45 45 echo
46 46 printf "%s\n" "Stack Commands:"
47 47 printf " %s Run one of available cluster stacks, run stack -h for more details\n" "stack "
48 48 printf " %s Show stack status\n" "stack-status "
49 49 printf " %s Upgrade a stack, run stack-upgrade -h for more details\n" "stack-upgrade "
50 50 printf " %s run monitoring on stack items\n" "stack-monitor "
51 51 echo
52 52 printf "%s\n" "CLI Commands:"
53 53 printf " %s Various CLI tools, run cli -h for more details\n" "cli "
54 54 echo
55 55 printf "%s\n" "Backup Commands:"
56 56 printf " %s Backup Database\n" "backup-db "
57 57 printf " %s Backup RhodeCode storage\n" "backup-data "
58 58 echo
59 59 printf "%s\n" "Build Commands:"
60 60 printf " %s Fetch Artifacts to run installer based build\n" "get-build-artifacts"
61 61 printf " %s Build RhodeCode image from installer, ./rcstack get-build-artifacts initially\n" "build-installer "
62 62 printf " %s Fetch RhodeCode sources, store in .source dir to run a source-based builds\n" "get-build-source "
63 63 printf " %s Build RhodeCode image from source, requires ./rcstack get-build-source initially\n" "build-source "
64 64 echo
65 65
66 66 # :command.long_usage
67 67 if [[ -n $long_usage ]]; then
68 68 printf "%s\n" "Options:"
69 69
70 70 # :command.usage_flags
71 71 # :flag.usage
72 72 printf " %s\n" "--debug"
73 73 printf " Enable debug and detailed output,\n"
74 74 echo
75 75
76 76 # :flag.usage
77 77 printf " %s\n" "--no-init-check"
78 78 printf " Skip check for ./rcstack init call\n"
79 79 echo
80 80
81 81 # :command.usage_fixed_flags
82 82 printf " %s\n" "--help, -h"
83 83 printf " Show this help\n"
84 84 echo
85 85 printf " %s\n" "--version, -v"
86 86 printf " Show version number\n"
87 87 echo
88 88
89 89 # :command.usage_environment_variables
90 90 printf "%s\n" "Environment Variables:"
91 91
92 92 # :environment_variable.usage
93 93 printf " %s\n" "RCC_CONFIG"
94 94 printf " default config file for rcstack\n"
95 95 printf " Default: .rcstack.ini\n"
96 96 echo
97 97
98 98 # :environment_variable.usage
99 99 printf " %s\n" "AUTH_TOKEN"
100 100 printf " Set your RhodeCode AUTH Token\n"
101 101 echo
102 102
103 103 # :environment_variable.usage
104 104 printf " %s\n" "RC_STACK_ROUTER_EXT"
105 105 printf "\n"
106 106 printf " Default: .custom/docker-compose-router.override.yaml\n"
107 107 echo
108 108
109 109 # :environment_variable.usage
110 110 printf " %s\n" "RC_STACK_METRICS_EXT"
111 111 printf "\n"
112 112 printf " Default: .custom/docker-compose-metrics.override.yaml\n"
113 113 echo
114 114
115 115 # :environment_variable.usage
116 116 printf " %s\n" "RC_STACK_SERVICES_EXT"
117 117 printf "\n"
118 118 printf " Default: .custom/docker-compose-services.override.yaml\n"
119 119 echo
120 120
121 121 # :environment_variable.usage
122 122 printf " %s\n" "RC_STACK_RHODECODE_EXT"
123 123 printf "\n"
124 124 printf " Default: .custom/docker-compose-apps.override.yaml\n"
125 125 echo
126 126
127 127 # :command.footer
128 128 printf "RhodeCode Inc 2023\n\n"
129 129 echo
130 130
131 131 fi
132 132 }
133 133
134 134 # :command.usage
135 135 rcstack_get_started_usage() {
136 136 if [[ -n $long_usage ]]; then
137 137 printf "rcstack get-started - Print instructions to get started with rhodecode docker stack\n"
138 138 echo
139 139
140 140 else
141 141 printf "rcstack get-started - Print instructions to get started with rhodecode docker stack\n"
142 142 echo
143 143
144 144 fi
145 145
146 146 printf "%s\n" "Usage:"
147 147 printf " rcstack get-started\n"
148 148 printf " rcstack get-started --help | -h\n"
149 149 echo
150 150
151 151 # :command.long_usage
152 152 if [[ -n $long_usage ]]; then
153 153 printf "%s\n" "Options:"
154 154
155 155 # :command.usage_fixed_flags
156 156 printf " %s\n" "--help, -h"
157 157 printf " Show this help\n"
158 158 echo
159 159
160 160 fi
161 161 }
162 162
163 163 # :command.usage
164 164 rcstack_init_usage() {
165 165 if [[ -n $long_usage ]]; then
166 166 printf "rcstack init - Bootstrap this machine, check docker version and install rhodecode-network\n"
167 167 echo
168 168
169 169 else
170 170 printf "rcstack init - Bootstrap this machine, check docker version and install rhodecode-network\n"
171 171 echo
172 172
173 173 fi
174 174
175 175 printf "%s\n" "Usage:"
176 176 printf " rcstack init [OPTIONS]\n"
177 177 printf " rcstack init --help | -h\n"
178 178 echo
179 179
180 180 # :command.long_usage
181 181 if [[ -n $long_usage ]]; then
182 182 printf "%s\n" "Options:"
183 183
184 184 # :command.usage_flags
185 185 # :flag.usage
186 186 printf " %s\n" "--arg-rc-edition ARG_RC_EDITION"
187 187 printf " specify rc_edition [ee|ce] for setup\n"
188 188 echo
189 189
190 190 # :flag.usage
191 191 printf " %s\n" "--arg-hostname ARG_HOSTNAME"
192 192 printf " specify hostname [hostname.example.com] for setup\n"
193 193 echo
194 194
195 195 # :flag.usage
196 196 printf " %s\n" "--arg-use-ssl ARG_USE_SSL"
197 197 printf " specify use_ssl [y|n] for setup\n"
198 198 echo
199 199
200 200 # :flag.usage
201 201 printf " %s\n" "--arg-admin-email ARG_ADMIN_EMAIL"
202 202 printf " specify admin_email [foo@example.com] for setup\n"
203 203 echo
204 204
205 205 # :flag.usage
206 206 printf " %s\n" "--arg-admin-user ARG_ADMIN_USER"
207 207 printf " specify admin_user [admin] for setup\n"
208 208 echo
209 209
210 210 # :flag.usage
211 211 printf " %s\n" "--arg-admin-pass ARG_ADMIN_PASS"
212 212 printf " specify admin_pass [secretpassword] for setup\n"
213 213 echo
214 214
215 215 # :flag.usage
216 216 printf " %s\n" "--arg-license-token ARG_ADMIN_TOKEN"
217 217 printf " specify license_token [abcd-abcd-abcd-abcd] for setup\n"
218 218 echo
219 219
220 220 # :flag.usage
221 221 printf " %s\n" "--no-prompt"
222 222 printf " Don't use interactive prompt to ask setup questions. Use defaults instead\n"
223 223 echo
224 224
225 225 # :flag.usage
226 226 printf " %s\n" "--force, -f"
227 227 printf " Overwrite existing files\n"
228 228 echo
229 229
230 230 # :flag.usage
231 231 printf " %s\n" "--stage STAGE (repeatable)"
232 232 printf " specify one or more stages to run\n"
233 233 echo
234 234
235 235 # :flag.usage
236 236 printf " %s\n" "--auth-token AUTH_TOKEN"
237 237 printf " Optionally specify AUTH TOKEN to obtain sources\n"
238 238 echo
239 239
240 240 # :flag.usage
241 241 printf " %s\n" "--server-url SERVER_URL"
242 242 printf " Specify RhodeCode server location where projects should be downloaded\n"
243 243 printf " Default: https://code.rhodecode.com\n"
244 244 echo
245 245
246 246 # :flag.usage
247 247 printf " %s\n" "--docker-revision DOCKER_REVISION"
248 248 printf " revision to fetch new docker definitions.\n"
249 249 printf " Default: master\n"
250 250 echo
251 251
252 252 # :flag.usage
253 253 printf " %s\n" "--install-docker INSTALL_DOCKER"
254 254 printf " answer [y]es or [n]o to question to install docker\n"
255 255 echo
256 256
257 257 # :command.usage_fixed_flags
258 258 printf " %s\n" "--help, -h"
259 259 printf " Show this help\n"
260 260 echo
261 261
262 262 # :command.usage_examples
263 263 printf "%s\n" "Examples:"
264 264 printf " - ./rcstack init\n - ./rcstack init --force\n # non-interactive mode to say yes to install docker question [n] always does\n not install docker\n - ./rcstack init --install-docker=y\n # non-interactive mode to answer setup questions use --help to check all\n --arg-NAME options\n - ./rcstack init --install-docker=y --arg-hostname=docker-dev --arg-use-ssl=n\n --arg-rc-edition=ee\n"
265 265 echo
266 266
267 267 fi
268 268 }
269 269
270 270 # :command.usage
271 271 rcstack_self_update_usage() {
272 272 if [[ -n $long_usage ]]; then
273 273 printf "rcstack self-update - Update rcstack and it's docker definitions\n"
274 274 echo
275 275
276 276 else
277 277 printf "rcstack self-update - Update rcstack and it's docker definitions\n"
278 278 echo
279 279
280 280 fi
281 281
282 282 printf "%s\n" "Usage:"
283 283 printf " rcstack self-update [OPTIONS]\n"
284 284 printf " rcstack self-update --help | -h\n"
285 285 echo
286 286
287 287 # :command.long_usage
288 288 if [[ -n $long_usage ]]; then
289 289 printf "%s\n" "Options:"
290 290
291 291 # :command.usage_flags
292 292 # :flag.usage
293 293 printf " %s\n" "--force"
294 294 printf " Ignore same-version skip check. Runs same logic as there would be new\n version available\n"
295 295 echo
296 296
297 297 # :flag.usage
298 298 printf " %s\n" "--cli-revision CLI_REVISION"
299 299 printf " revision to fetch new rcstack cli tool.\n"
300 300 printf " Default: master\n"
301 301 echo
302 302
303 303 # :flag.usage
304 304 printf " %s\n" "--docker-revision DOCKER_REVISION"
305 305 printf " revision to fetch new docker definitions.\n"
306 306 printf " Default: master\n"
307 307 echo
308 308
309 309 # :flag.usage
310 310 printf " %s\n" "--auth-token AUTH_TOKEN"
311 311 printf " Optionally specify AUTH TOKEN to obtain sources\n"
312 312 echo
313 313
314 314 # :flag.usage
315 315 printf " %s\n" "--server-url SERVER_URL"
316 316 printf " Specify RhodeCode server location where projects should be downloaded\n"
317 317 printf " Default: https://code.rhodecode.com\n"
318 318 echo
319 319
320 320 # :command.usage_fixed_flags
321 321 printf " %s\n" "--help, -h"
322 322 printf " Show this help\n"
323 323 echo
324 324
325 325 # :command.usage_examples
326 326 printf "%s\n" "Examples:"
327 327 printf " - ./rccstack self-update simply to update it to a new version\n \n # to fetch dev branch and install it\n - ./rccstack self-update --cli-revision=dev --docker-revision=dev\n \n # In case rcstack breaks, you can re-download the stack script using curl\n curl -L -s -o rcstack https://dls.rhodecode.com/get/master && chmod +x rcstack\n"
328 328 echo
329 329
330 330 fi
331 331 }
332 332
333 333 # :command.usage
334 334 rcstack_stack_usage() {
335 335 if [[ -n $long_usage ]]; then
336 336 printf "rcstack stack - Run one of available cluster stacks, run stack -h for more details\n"
337 337 echo
338 338
339 339 else
340 340 printf "rcstack stack - Run one of available cluster stacks, run stack -h for more details\n"
341 341 echo
342 342
343 343 fi
344 344
345 345 printf "%s\n" "Usage:"
346 346 printf " rcstack stack [OPTIONS] COMMAND\n"
347 347 printf " rcstack stack [COMMAND] --help | -h\n"
348 348 echo
349 349 # :command.usage_commands
350 350 printf "%s\n" "Commands:"
351 351 printf " %s execute commands for the router stack\n" "router "
352 352 printf " %s execute commands for the router stack\n" "metrics "
353 353 printf " %s execute commands for the router stack\n" "services "
354 354 printf " %s execute commands for the router stack\n" "rhodecode"
355 355 printf " %s execute commands for all stacks in order\n" "all "
356 356 echo
357 357
358 358 # :command.long_usage
359 359 if [[ -n $long_usage ]]; then
360 360 printf "%s\n" "Options:"
361 361
362 362 # :command.usage_flags
363 363 # :flag.usage
364 364 printf " %s\n" "--env-file-path ENV_FILE_PATH"
365 365 printf " Set custom env file\n"
366 366 printf " Default: $PWD/.custom/.runtime.env\n"
367 367 echo
368 368
369 369 # :flag.usage
370 370 printf " %s\n" "--stack-prefix STACK_PREFIX"
371 371 printf " Set custom stack prefix, e.g rc_cluster_apps_ci\n"
372 372 echo
373 373
374 374 # :command.usage_fixed_flags
375 375 printf " %s\n" "--help, -h"
376 376 printf " Show this help\n"
377 377 echo
378 378
379 379 # :command.usage_examples
380 380 printf "%s\n" "Examples:"
381 381 printf " # running stack\n - ./rcstack stack router up # run router stack with output to stdout\n - ./rcstack stack router up --detach # run router stack detached\n - ./rcstack stack router down # stop whole router stack\n - ./rcstack stack router ps # check status of router stack\n \n # logs, use logs -f to follow/tail --until 1h to limit for last time\n - ./rcstack stack services logs -f database\n \n # scale a single stack service[s] to more replicas (horizontally), use\n overrides files to permanently set scale\n - ./rcstack stack rhodecode up --detach --no-recreate --scale rhodecode=2\n --scale vcsserver=2\n \n # run router stack with your overrides compose file\n - ./rcstack stack router -f docker-overrides.yaml up -d\n \n # run command in the stack image\n - ./rcstack stack rhodecode run rhodecode bash\n"
382 382 echo
383 383
384 384 fi
385 385 }
386 386
387 387 # :command.usage
388 388 rcstack_stack_router_usage() {
389 389 if [[ -n $long_usage ]]; then
390 390 printf "rcstack stack router - execute commands for the router stack\n"
391 391 echo
392 392
393 393 else
394 394 printf "rcstack stack router - execute commands for the router stack\n"
395 395 echo
396 396
397 397 fi
398 398
399 399 printf "%s\n" "Usage:"
400 400 printf " rcstack stack router [SERVICES PARAMS...]\n"
401 401 printf " rcstack stack router --help | -h\n"
402 402 echo
403 403
404 404 # :command.long_usage
405 405 if [[ -n $long_usage ]]; then
406 406 printf "%s\n" "Options:"
407 407
408 408 # :command.usage_fixed_flags
409 409 printf " %s\n" "--help, -h"
410 410 printf " Show this help\n"
411 411 echo
412 412
413 413 # :command.usage_args
414 414 printf "%s\n" "Arguments:"
415 415
416 416 echo " SERVICES PARAMS..."
417 417 printf " Additional arguments or flags for services command\n"
418 418 echo
419 419
420 420 fi
421 421 }
422 422
423 423 # :command.usage
424 424 rcstack_stack_metrics_usage() {
425 425 if [[ -n $long_usage ]]; then
426 426 printf "rcstack stack metrics - execute commands for the router stack\n"
427 427 echo
428 428
429 429 else
430 430 printf "rcstack stack metrics - execute commands for the router stack\n"
431 431 echo
432 432
433 433 fi
434 434
435 435 printf "%s\n" "Usage:"
436 436 printf " rcstack stack metrics [SERVICES PARAMS...]\n"
437 437 printf " rcstack stack metrics --help | -h\n"
438 438 echo
439 439
440 440 # :command.long_usage
441 441 if [[ -n $long_usage ]]; then
442 442 printf "%s\n" "Options:"
443 443
444 444 # :command.usage_fixed_flags
445 445 printf " %s\n" "--help, -h"
446 446 printf " Show this help\n"
447 447 echo
448 448
449 449 # :command.usage_args
450 450 printf "%s\n" "Arguments:"
451 451
452 452 echo " SERVICES PARAMS..."
453 453 printf " Additional arguments or flags for services command\n"
454 454 echo
455 455
456 456 fi
457 457 }
458 458
459 459 # :command.usage
460 460 rcstack_stack_services_usage() {
461 461 if [[ -n $long_usage ]]; then
462 462 printf "rcstack stack services - execute commands for the router stack\n"
463 463 echo
464 464
465 465 else
466 466 printf "rcstack stack services - execute commands for the router stack\n"
467 467 echo
468 468
469 469 fi
470 470
471 471 printf "%s\n" "Usage:"
472 472 printf " rcstack stack services [SERVICES PARAMS...]\n"
473 473 printf " rcstack stack services --help | -h\n"
474 474 echo
475 475
476 476 # :command.long_usage
477 477 if [[ -n $long_usage ]]; then
478 478 printf "%s\n" "Options:"
479 479
480 480 # :command.usage_fixed_flags
481 481 printf " %s\n" "--help, -h"
482 482 printf " Show this help\n"
483 483 echo
484 484
485 485 # :command.usage_args
486 486 printf "%s\n" "Arguments:"
487 487
488 488 echo " SERVICES PARAMS..."
489 489 printf " Additional arguments or flags for services command\n"
490 490 echo
491 491
492 492 fi
493 493 }
494 494
495 495 # :command.usage
496 496 rcstack_stack_rhodecode_usage() {
497 497 if [[ -n $long_usage ]]; then
498 498 printf "rcstack stack rhodecode - execute commands for the router stack\n"
499 499 echo
500 500
501 501 else
502 502 printf "rcstack stack rhodecode - execute commands for the router stack\n"
503 503 echo
504 504
505 505 fi
506 506
507 507 printf "%s\n" "Usage:"
508 508 printf " rcstack stack rhodecode [SERVICES PARAMS...]\n"
509 509 printf " rcstack stack rhodecode --help | -h\n"
510 510 echo
511 511
512 512 # :command.long_usage
513 513 if [[ -n $long_usage ]]; then
514 514 printf "%s\n" "Options:"
515 515
516 516 # :command.usage_fixed_flags
517 517 printf " %s\n" "--help, -h"
518 518 printf " Show this help\n"
519 519 echo
520 520
521 521 # :command.usage_args
522 522 printf "%s\n" "Arguments:"
523 523
524 524 echo " SERVICES PARAMS..."
525 525 printf " Additional arguments or flags for services command\n"
526 526 echo
527 527
528 528 fi
529 529 }
530 530
531 531 # :command.usage
532 532 rcstack_stack_all_usage() {
533 533 if [[ -n $long_usage ]]; then
534 534 printf "rcstack stack all - execute commands for all stacks in order\n"
535 535 echo
536 536
537 537 else
538 538 printf "rcstack stack all - execute commands for all stacks in order\n"
539 539 echo
540 540
541 541 fi
542 542
543 543 printf "%s\n" "Usage:"
544 544 printf " rcstack stack all [SERVICES PARAMS...]\n"
545 545 printf " rcstack stack all --help | -h\n"
546 546 echo
547 547
548 548 # :command.long_usage
549 549 if [[ -n $long_usage ]]; then
550 550 printf "%s\n" "Options:"
551 551
552 552 # :command.usage_fixed_flags
553 553 printf " %s\n" "--help, -h"
554 554 printf " Show this help\n"
555 555 echo
556 556
557 557 # :command.usage_args
558 558 printf "%s\n" "Arguments:"
559 559
560 560 echo " SERVICES PARAMS..."
561 561 printf " Additional arguments or flags for services command\n"
562 562 echo
563 563
564 564 fi
565 565 }
566 566
567 567 # :command.usage
568 568 rcstack_stack_status_usage() {
569 569 if [[ -n $long_usage ]]; then
570 570 printf "rcstack stack-status - Show stack status\n"
571 571 echo
572 572
573 573 else
574 574 printf "rcstack stack-status - Show stack status\n"
575 575 echo
576 576
577 577 fi
578 578
579 579 printf "Alias: status\n"
580 580 echo
581 581
582 582 printf "%s\n" "Usage:"
583 583 printf " rcstack stack-status [OPTIONS]\n"
584 584 printf " rcstack stack-status --help | -h\n"
585 585 echo
586 586
587 587 # :command.long_usage
588 588 if [[ -n $long_usage ]]; then
589 589 printf "%s\n" "Options:"
590 590
591 591 # :command.usage_flags
592 592 # :flag.usage
593 593 printf " %s\n" "--detailed"
594 594 printf " Display a detailed format\n"
595 595 echo
596 596
597 597 # :flag.usage
598 598 printf " %s\n" "--configs"
599 599 printf " Display a detailed info about configuration files\n"
600 600 echo
601 601
602 602 # :command.usage_fixed_flags
603 603 printf " %s\n" "--help, -h"
604 604 printf " Show this help\n"
605 605 echo
606 606
607 607 fi
608 608 }
609 609
610 610 # :command.usage
611 611 rcstack_stack_upgrade_usage() {
612 612 if [[ -n $long_usage ]]; then
613 613 printf "rcstack stack-upgrade - Upgrade a stack, run stack-upgrade -h for more details\n"
614 614 echo
615 615
616 616 else
617 617 printf "rcstack stack-upgrade - Upgrade a stack, run stack-upgrade -h for more details\n"
618 618 echo
619 619
620 620 fi
621 621
622 622 printf "%s\n" "Usage:"
623 623 printf " rcstack stack-upgrade [OPTIONS] COMMAND\n"
624 624 printf " rcstack stack-upgrade [COMMAND] --help | -h\n"
625 625 echo
626 626 # :command.usage_commands
627 627 printf "%s\n" "Commands:"
628 628 printf " %s upgrade the router stack\n" "router "
629 629 printf " %s run the router stack\n" "metrics "
630 630 printf " %s run the router stack\n" "services "
631 631 printf " %s run the router stack\n" "rhodecode"
632 632 echo
633 633
634 634 # :command.long_usage
635 635 if [[ -n $long_usage ]]; then
636 636 printf "%s\n" "Options:"
637 637
638 638 # :command.usage_flags
639 639 # :flag.usage
640 640 printf " %s\n" "--stack-prefix STACK_PREFIX"
641 641 printf " Set custom stack prefix, e.g rc_cluster_apps_ci\n"
642 642 echo
643 643
644 644 # :command.usage_fixed_flags
645 645 printf " %s\n" "--help, -h"
646 646 printf " Show this help\n"
647 647 echo
648 648
649 649 # :command.usage_examples
650 650 printf "%s\n" "Examples:"
651 651 printf " # Upgrading stack\n - ./rcstack stack-upgrade router\n \n # RhodeCode stack upgrades with 0 downtime using container rotation\n - ./rcstack stack-upgrade rhodecode\n"
652 652 echo
653 653
654 654 fi
655 655 }
656 656
657 657 # :command.usage
658 658 rcstack_stack_upgrade_router_usage() {
659 659 if [[ -n $long_usage ]]; then
660 660 printf "rcstack stack-upgrade router - upgrade the router stack\n"
661 661 echo
662 662
663 663 else
664 664 printf "rcstack stack-upgrade router - upgrade the router stack\n"
665 665 echo
666 666
667 667 fi
668 668
669 669 printf "%s\n" "Usage:"
670 670 printf " rcstack stack-upgrade router\n"
671 671 printf " rcstack stack-upgrade router --help | -h\n"
672 672 echo
673 673
674 674 # :command.long_usage
675 675 if [[ -n $long_usage ]]; then
676 676 printf "%s\n" "Options:"
677 677
678 678 # :command.usage_fixed_flags
679 679 printf " %s\n" "--help, -h"
680 680 printf " Show this help\n"
681 681 echo
682 682
683 683 fi
684 684 }
685 685
686 686 # :command.usage
687 687 rcstack_stack_upgrade_metrics_usage() {
688 688 if [[ -n $long_usage ]]; then
689 689 printf "rcstack stack-upgrade metrics - run the router stack\n"
690 690 echo
691 691
692 692 else
693 693 printf "rcstack stack-upgrade metrics - run the router stack\n"
694 694 echo
695 695
696 696 fi
697 697
698 698 printf "%s\n" "Usage:"
699 699 printf " rcstack stack-upgrade metrics\n"
700 700 printf " rcstack stack-upgrade metrics --help | -h\n"
701 701 echo
702 702
703 703 # :command.long_usage
704 704 if [[ -n $long_usage ]]; then
705 705 printf "%s\n" "Options:"
706 706
707 707 # :command.usage_fixed_flags
708 708 printf " %s\n" "--help, -h"
709 709 printf " Show this help\n"
710 710 echo
711 711
712 712 fi
713 713 }
714 714
715 715 # :command.usage
716 716 rcstack_stack_upgrade_services_usage() {
717 717 if [[ -n $long_usage ]]; then
718 718 printf "rcstack stack-upgrade services - run the router stack\n"
719 719 echo
720 720
721 721 else
722 722 printf "rcstack stack-upgrade services - run the router stack\n"
723 723 echo
724 724
725 725 fi
726 726
727 727 printf "%s\n" "Usage:"
728 728 printf " rcstack stack-upgrade services\n"
729 729 printf " rcstack stack-upgrade services --help | -h\n"
730 730 echo
731 731
732 732 # :command.long_usage
733 733 if [[ -n $long_usage ]]; then
734 734 printf "%s\n" "Options:"
735 735
736 736 # :command.usage_fixed_flags
737 737 printf " %s\n" "--help, -h"
738 738 printf " Show this help\n"
739 739 echo
740 740
741 741 fi
742 742 }
743 743
744 744 # :command.usage
745 745 rcstack_stack_upgrade_rhodecode_usage() {
746 746 if [[ -n $long_usage ]]; then
747 747 printf "rcstack stack-upgrade rhodecode - run the router stack\n"
748 748 echo
749 749
750 750 else
751 751 printf "rcstack stack-upgrade rhodecode - run the router stack\n"
752 752 echo
753 753
754 754 fi
755 755
756 756 printf "%s\n" "Usage:"
757 757 printf " rcstack stack-upgrade rhodecode [OPTIONS]\n"
758 758 printf " rcstack stack-upgrade rhodecode --help | -h\n"
759 759 echo
760 760
761 761 # :command.long_usage
762 762 if [[ -n $long_usage ]]; then
763 763 printf "%s\n" "Options:"
764 764
765 765 # :command.usage_flags
766 766 # :flag.usage
767 767 printf " %s\n" "--stop-wait STOP_WAIT"
768 768 printf " Number of seconds to wait for stopping old containers, use low value to\n quickly restart and recycle containers\n"
769 769 printf " Default: 120\n"
770 770 echo
771 771
772 772 # :flag.usage
773 773 printf " %s\n" "--docker-stop-wait DOCKER_STOP_WAIT"
774 774 printf " Number of seconds to pass to docker stop command that will wait for\n container to gracefull stop\n"
775 775 printf " Default: 3600\n"
776 776 echo
777 777
778 778 # :command.usage_fixed_flags
779 779 printf " %s\n" "--help, -h"
780 780 printf " Show this help\n"
781 781 echo
782 782
783 783 fi
784 784 }
785 785
786 786 # :command.usage
787 787 rcstack_stack_monitor_usage() {
788 788 if [[ -n $long_usage ]]; then
789 789 printf "rcstack stack-monitor - run monitoring on stack items\n"
790 790 echo
791 791
792 792 else
793 793 printf "rcstack stack-monitor - run monitoring on stack items\n"
794 794 echo
795 795
796 796 fi
797 797
798 798 printf "%s\n" "Usage:"
799 799 printf " rcstack stack-monitor COMMAND\n"
800 800 printf " rcstack stack-monitor [COMMAND] --help | -h\n"
801 801 echo
802 802 # :command.usage_commands
803 803 printf "%s\n" "Stack Commands:"
804 804 printf " %s monitor stack containers that are unhealthy and restart them\n" "restart-unhealthy"
805 805 echo
806 806
807 807 # :command.long_usage
808 808 if [[ -n $long_usage ]]; then
809 809 printf "%s\n" "Options:"
810 810
811 811 # :command.usage_fixed_flags
812 812 printf " %s\n" "--help, -h"
813 813 printf " Show this help\n"
814 814 echo
815 815
816 816 fi
817 817 }
818 818
819 819 # :command.usage
820 820 rcstack_stack_monitor_restart_unhealthy_usage() {
821 821 if [[ -n $long_usage ]]; then
822 822 printf "rcstack stack-monitor restart-unhealthy - monitor stack containers that are unhealthy and restart them\n"
823 823 echo
824 824
825 825 else
826 826 printf "rcstack stack-monitor restart-unhealthy - monitor stack containers that are unhealthy and restart them\n"
827 827 echo
828 828
829 829 fi
830 830
831 831 printf "%s\n" "Usage:"
832 832 printf " rcstack stack-monitor restart-unhealthy [OPTIONS]\n"
833 833 printf " rcstack stack-monitor restart-unhealthy --help | -h\n"
834 834 echo
835 835
836 836 # :command.long_usage
837 837 if [[ -n $long_usage ]]; then
838 838 printf "%s\n" "Options:"
839 839
840 840 # :command.usage_flags
841 841 # :flag.usage
842 842 printf " %s\n" "--loop LOOP"
843 843 printf " run in a loop to monitor continously every N seconds\n"
844 844 printf " Default: 0\n"
845 845 echo
846 846
847 847 # :command.usage_fixed_flags
848 848 printf " %s\n" "--help, -h"
849 849 printf " Show this help\n"
850 850 echo
851 851
852 852 # :command.usage_examples
853 853 printf "%s\n" "Examples:"
854 854 printf " # check and restart for unhealthy containers\n ./rcstack restart-unhealthy\n \n # check and restart for unhealthy containers, and continue in a loop every 5\n minutes (300s)\n ./rcstack restart-unhealthy --loop=300\n \n # run this script in background with logs\n nohup ./rcstack restart-unhealthy --loop=300 > unhealthy-checks.log &\n"
855 855 echo
856 856
857 857 fi
858 858 }
859 859
860 860 # :command.usage
861 861 rcstack_cli_usage() {
862 862 if [[ -n $long_usage ]]; then
863 863 printf "rcstack cli - Various CLI tools, run cli -h for more details\n"
864 864 echo
865 865
866 866 else
867 867 printf "rcstack cli - Various CLI tools, run cli -h for more details\n"
868 868 echo
869 869
870 870 fi
871 871
872 872 printf "%s\n" "Usage:"
873 873 printf " rcstack cli COMMAND\n"
874 874 printf " rcstack cli [COMMAND] --help | -h\n"
875 875 echo
876 876 # :command.usage_commands
877 877 printf "%s\n" "Commands:"
878 878 printf " %s print out stored docker image version\n" "image-info "
879 879 printf " %s set version to .runtime.env file\n" "set-runtime-image "
880 880 printf " %s Ishell attached to running RhodeCode instance\n" "ishell "
881 881 printf " %s CLI for Redis\n" "redis "
882 882 printf " %s CLI with Database connection\n" "db "
883 883 printf " %s CLI to run db upgrade\n" "db-upgrade "
884 884 printf " %s CLI for repository storage. Exposes a basic image with mounted data and repositories volumes or attach to currently running containers storage\n" "storage "
885 885 printf " %s attach to running instance of RhodeCode, by default it attaches to rhodecode main web app\n" "attach "
886 886 printf " %s set current setup to either CE (Community) or EE (Enterprise) type\n" "set-edition "
887 887 printf " %s reconfigure the vcsserver.ini file\n" "configure-vcsserver"
888 888 printf " %s reconfigure the rhodecode.ini file\n" "configure-rhodecode"
889 889 echo
890 890
891 891 # :command.long_usage
892 892 if [[ -n $long_usage ]]; then
893 893 printf "%s\n" "Options:"
894 894
895 895 # :command.usage_fixed_flags
896 896 printf " %s\n" "--help, -h"
897 897 printf " Show this help\n"
898 898 echo
899 899
900 900 fi
901 901 }
902 902
903 903 # :command.usage
904 904 rcstack_cli_image_info_usage() {
905 905 if [[ -n $long_usage ]]; then
906 906 printf "rcstack cli image-info - print out stored docker image version\n"
907 907 echo
908 908
909 909 else
910 910 printf "rcstack cli image-info - print out stored docker image version\n"
911 911 echo
912 912
913 913 fi
914 914
915 915 printf "%s\n" "Usage:"
916 916 printf " rcstack cli image-info [OPTIONS]\n"
917 917 printf " rcstack cli image-info --help | -h\n"
918 918 echo
919 919
920 920 # :command.long_usage
921 921 if [[ -n $long_usage ]]; then
922 922 printf "%s\n" "Options:"
923 923
924 924 # :command.usage_flags
925 925 # :flag.usage
926 926 printf " %s\n" "--verbose"
927 927 printf " rich output about image\n"
928 928 echo
929 929
930 930 # :command.usage_fixed_flags
931 931 printf " %s\n" "--help, -h"
932 932 printf " Show this help\n"
933 933 echo
934 934
935 935 fi
936 936 }
937 937
938 938 # :command.usage
939 939 rcstack_cli_set_runtime_image_usage() {
940 940 if [[ -n $long_usage ]]; then
941 941 printf "rcstack cli set-runtime-image - set version to .runtime.env file\n"
942 942 echo
943 943
944 944 else
945 945 printf "rcstack cli set-runtime-image - set version to .runtime.env file\n"
946 946 echo
947 947
948 948 fi
949 949
950 950 printf "%s\n" "Usage:"
951 951 printf " rcstack cli set-runtime-image VERSION\n"
952 952 printf " rcstack cli set-runtime-image --help | -h\n"
953 953 echo
954 954
955 955 # :command.long_usage
956 956 if [[ -n $long_usage ]]; then
957 957 printf "%s\n" "Options:"
958 958
959 959 # :command.usage_fixed_flags
960 960 printf " %s\n" "--help, -h"
961 961 printf " Show this help\n"
962 962 echo
963 963
964 964 # :command.usage_args
965 965 printf "%s\n" "Arguments:"
966 966
967 967 # :argument.usage
968 968 printf " %s\n" "VERSION"
969 969 printf " Version of docker image to set e.g '5.0.0'\n"
970 970 echo
971 971
972 972 fi
973 973 }
974 974
975 975 # :command.usage
976 976 rcstack_cli_ishell_usage() {
977 977 if [[ -n $long_usage ]]; then
978 978 printf "rcstack cli ishell - Ishell attached to running RhodeCode instance\n"
979 979 echo
980 980
981 981 else
982 982 printf "rcstack cli ishell - Ishell attached to running RhodeCode instance\n"
983 983 echo
984 984
985 985 fi
986 986
987 987 printf "%s\n" "Usage:"
988 988 printf " rcstack cli ishell\n"
989 989 printf " rcstack cli ishell --help | -h\n"
990 990 echo
991 991
992 992 # :command.long_usage
993 993 if [[ -n $long_usage ]]; then
994 994 printf "%s\n" "Options:"
995 995
996 996 # :command.usage_fixed_flags
997 997 printf " %s\n" "--help, -h"
998 998 printf " Show this help\n"
999 999 echo
1000 1000
1001 1001 fi
1002 1002 }
1003 1003
1004 1004 # :command.usage
1005 1005 rcstack_cli_redis_usage() {
1006 1006 if [[ -n $long_usage ]]; then
1007 1007 printf "rcstack cli redis - CLI for Redis\n"
1008 1008 echo
1009 1009
1010 1010 else
1011 1011 printf "rcstack cli redis - CLI for Redis\n"
1012 1012 echo
1013 1013
1014 1014 fi
1015 1015
1016 1016 printf "%s\n" "Usage:"
1017 1017 printf " rcstack cli redis\n"
1018 1018 printf " rcstack cli redis --help | -h\n"
1019 1019 echo
1020 1020
1021 1021 # :command.long_usage
1022 1022 if [[ -n $long_usage ]]; then
1023 1023 printf "%s\n" "Options:"
1024 1024
1025 1025 # :command.usage_fixed_flags
1026 1026 printf " %s\n" "--help, -h"
1027 1027 printf " Show this help\n"
1028 1028 echo
1029 1029
1030 1030 fi
1031 1031 }
1032 1032
1033 1033 # :command.usage
1034 1034 rcstack_cli_db_usage() {
1035 1035 if [[ -n $long_usage ]]; then
1036 1036 printf "rcstack cli db - CLI with Database connection\n"
1037 1037 echo
1038 1038
1039 1039 else
1040 1040 printf "rcstack cli db - CLI with Database connection\n"
1041 1041 echo
1042 1042
1043 1043 fi
1044 1044
1045 1045 printf "%s\n" "Usage:"
1046 1046 printf " rcstack cli db\n"
1047 1047 printf " rcstack cli db --help | -h\n"
1048 1048 echo
1049 1049
1050 1050 # :command.long_usage
1051 1051 if [[ -n $long_usage ]]; then
1052 1052 printf "%s\n" "Options:"
1053 1053
1054 1054 # :command.usage_fixed_flags
1055 1055 printf " %s\n" "--help, -h"
1056 1056 printf " Show this help\n"
1057 1057 echo
1058 1058
1059 1059 # :command.usage_examples
1060 1060 printf "%s\n" "Examples:"
1061 1061 printf " # restore backup\n - \i /var/rc-data-dump/your_dump.sql\n"
1062 1062 echo
1063 1063
1064 1064 fi
1065 1065 }
1066 1066
1067 1067 # :command.usage
1068 1068 rcstack_cli_db_upgrade_usage() {
1069 1069 if [[ -n $long_usage ]]; then
1070 1070 printf "rcstack cli db-upgrade - CLI to run db upgrade\n"
1071 1071 echo
1072 1072
1073 1073 else
1074 1074 printf "rcstack cli db-upgrade - CLI to run db upgrade\n"
1075 1075 echo
1076 1076
1077 1077 fi
1078 1078
1079 1079 printf "%s\n" "Usage:"
1080 1080 printf " rcstack cli db-upgrade\n"
1081 1081 printf " rcstack cli db-upgrade --help | -h\n"
1082 1082 echo
1083 1083
1084 1084 # :command.long_usage
1085 1085 if [[ -n $long_usage ]]; then
1086 1086 printf "%s\n" "Options:"
1087 1087
1088 1088 # :command.usage_fixed_flags
1089 1089 printf " %s\n" "--help, -h"
1090 1090 printf " Show this help\n"
1091 1091 echo
1092 1092
1093 1093 fi
1094 1094 }
1095 1095
1096 1096 # :command.usage
1097 1097 rcstack_cli_storage_usage() {
1098 1098 if [[ -n $long_usage ]]; then
1099 1099 printf "rcstack cli storage - CLI for repository storage. Exposes a basic image with mounted data and repositories volumes or attach to currently running containers storage\n"
1100 1100 echo
1101 1101
1102 1102 else
1103 1103 printf "rcstack cli storage - CLI for repository storage. Exposes a basic image with mounted data and repositories volumes or attach to currently running containers storage\n"
1104 1104 echo
1105 1105
1106 1106 fi
1107 1107
1108 1108 printf "%s\n" "Usage:"
1109 1109 printf " rcstack cli storage [OPTIONS]\n"
1110 1110 printf " rcstack cli storage --help | -h\n"
1111 1111 echo
1112 1112
1113 1113 # :command.long_usage
1114 1114 if [[ -n $long_usage ]]; then
1115 1115 printf "%s\n" "Options:"
1116 1116
1117 1117 # :command.usage_flags
1118 1118 # :flag.usage
1119 1119 printf " %s\n" "--attached ATTACHED"
1120 1120 printf " attach to storage of already running vcsserver container instead\n"
1121 1121 echo
1122 1122
1123 1123 # :command.usage_fixed_flags
1124 1124 printf " %s\n" "--help, -h"
1125 1125 printf " Show this help\n"
1126 1126 echo
1127 1127
1128 1128 fi
1129 1129 }
1130 1130
1131 1131 # :command.usage
1132 1132 rcstack_cli_attach_usage() {
1133 1133 if [[ -n $long_usage ]]; then
1134 1134 printf "rcstack cli attach - attach to running instance of RhodeCode, by default it attaches to rhodecode main web app\n"
1135 1135 echo
1136 1136
1137 1137 else
1138 1138 printf "rcstack cli attach - attach to running instance of RhodeCode, by default it attaches to rhodecode main web app\n"
1139 1139 echo
1140 1140
1141 1141 fi
1142 1142
1143 1143 printf "%s\n" "Usage:"
1144 1144 printf " rcstack cli attach [OPTIONS]\n"
1145 1145 printf " rcstack cli attach --help | -h\n"
1146 1146 echo
1147 1147
1148 1148 # :command.long_usage
1149 1149 if [[ -n $long_usage ]]; then
1150 1150 printf "%s\n" "Options:"
1151 1151
1152 1152 # :command.usage_flags
1153 1153 # :flag.usage
1154 1154 printf " %s\n" "--instance-type INSTANCE_TYPE"
1155 1155 printf " type of instance to attach to\n"
1156 1156 printf " Default: rhodecode\n"
1157 1157 echo
1158 1158
1159 1159 # :command.usage_fixed_flags
1160 1160 printf " %s\n" "--help, -h"
1161 1161 printf " Show this help\n"
1162 1162 echo
1163 1163
1164 1164 # :command.usage_examples
1165 1165 printf "%s\n" "Examples:"
1166 1166 printf " ./rcstack cli attach --instance-type sshd\n ./rcstack cli attach --instance-type vcsserver\n ./rcstack cli attach --instance-type celery\n ./rcstack cli attach --instance-type celery-beat\n"
1167 1167 echo
1168 1168
1169 1169 fi
1170 1170 }
1171 1171
1172 1172 # :command.usage
1173 1173 rcstack_cli_set_edition_usage() {
1174 1174 if [[ -n $long_usage ]]; then
1175 1175 printf "rcstack cli set-edition - set current setup to either CE (Community) or EE (Enterprise) type\n"
1176 1176 echo
1177 1177
1178 1178 else
1179 1179 printf "rcstack cli set-edition - set current setup to either CE (Community) or EE (Enterprise) type\n"
1180 1180 echo
1181 1181
1182 1182 fi
1183 1183
1184 1184 printf "%s\n" "Usage:"
1185 1185 printf " rcstack cli set-edition EDITION_TYPE\n"
1186 1186 printf " rcstack cli set-edition --help | -h\n"
1187 1187 echo
1188 1188
1189 1189 # :command.long_usage
1190 1190 if [[ -n $long_usage ]]; then
1191 1191 printf "%s\n" "Options:"
1192 1192
1193 1193 # :command.usage_fixed_flags
1194 1194 printf " %s\n" "--help, -h"
1195 1195 printf " Show this help\n"
1196 1196 echo
1197 1197
1198 1198 # :command.usage_args
1199 1199 printf "%s\n" "Arguments:"
1200 1200
1201 1201 # :argument.usage
1202 1202 printf " %s\n" "EDITION_TYPE"
1203 1203 printf " pick type CE or EE\n"
1204 1204 printf " Allowed: ce, ee\n"
1205 1205 echo
1206 1206
1207 1207 # :command.usage_examples
1208 1208 printf "%s\n" "Examples:"
1209 1209 printf " ./rcstack set-edition ce\n"
1210 1210 printf " ./rcstack set-edition ee\n"
1211 1211 echo
1212 1212
1213 1213 fi
1214 1214 }
1215 1215
1216 1216 # :command.usage
1217 1217 rcstack_cli_configure_vcsserver_usage() {
1218 1218 if [[ -n $long_usage ]]; then
1219 1219 printf "rcstack cli configure-vcsserver - reconfigure the vcsserver.ini file\n"
1220 1220 echo
1221 1221
1222 1222 else
1223 1223 printf "rcstack cli configure-vcsserver - reconfigure the vcsserver.ini file\n"
1224 1224 echo
1225 1225
1226 1226 fi
1227 1227
1228 1228 printf "%s\n" "Usage:"
1229 1229 printf " rcstack cli configure-vcsserver INI_PATH\n"
1230 1230 printf " rcstack cli configure-vcsserver --help | -h\n"
1231 1231 echo
1232 1232
1233 1233 # :command.long_usage
1234 1234 if [[ -n $long_usage ]]; then
1235 1235 printf "%s\n" "Options:"
1236 1236
1237 1237 # :command.usage_fixed_flags
1238 1238 printf " %s\n" "--help, -h"
1239 1239 printf " Show this help\n"
1240 1240 echo
1241 1241
1242 1242 # :command.usage_args
1243 1243 printf "%s\n" "Arguments:"
1244 1244
1245 1245 # :argument.usage
1246 1246 printf " %s\n" "INI_PATH"
1247 1247 printf " Path to vcsserver.ini to reconfigure\n"
1248 1248 echo
1249 1249
1250 1250 # :command.usage_examples
1251 1251 printf "%s\n" "Examples:"
1252 1252 printf " ./rcstack cli configure-vcs config/_shared/vcsserver.ini\n"
1253 1253 echo
1254 1254
1255 1255 fi
1256 1256 }
1257 1257
1258 1258 # :command.usage
1259 1259 rcstack_cli_configure_rhodecode_usage() {
1260 1260 if [[ -n $long_usage ]]; then
1261 1261 printf "rcstack cli configure-rhodecode - reconfigure the rhodecode.ini file\n"
1262 1262 echo
1263 1263
1264 1264 else
1265 1265 printf "rcstack cli configure-rhodecode - reconfigure the rhodecode.ini file\n"
1266 1266 echo
1267 1267
1268 1268 fi
1269 1269
1270 1270 printf "%s\n" "Usage:"
1271 1271 printf " rcstack cli configure-rhodecode INI_PATH\n"
1272 1272 printf " rcstack cli configure-rhodecode --help | -h\n"
1273 1273 echo
1274 1274
1275 1275 # :command.long_usage
1276 1276 if [[ -n $long_usage ]]; then
1277 1277 printf "%s\n" "Options:"
1278 1278
1279 1279 # :command.usage_fixed_flags
1280 1280 printf " %s\n" "--help, -h"
1281 1281 printf " Show this help\n"
1282 1282 echo
1283 1283
1284 1284 # :command.usage_args
1285 1285 printf "%s\n" "Arguments:"
1286 1286
1287 1287 # :argument.usage
1288 1288 printf " %s\n" "INI_PATH"
1289 1289 printf " Path to rhodecode.ini to reconfigure\n"
1290 1290 echo
1291 1291
1292 1292 # :command.usage_examples
1293 1293 printf "%s\n" "Examples:"
1294 1294 printf " ./rcstack cli configure-rhodecode config/_shared/rhodecode.ini\n"
1295 1295 echo
1296 1296
1297 1297 fi
1298 1298 }
1299 1299
1300 1300 # :command.usage
1301 1301 rcstack_backup_db_usage() {
1302 1302 if [[ -n $long_usage ]]; then
1303 1303 printf "rcstack backup-db - Backup Database\n"
1304 1304 echo
1305 1305
1306 1306 else
1307 1307 printf "rcstack backup-db - Backup Database\n"
1308 1308 echo
1309 1309
1310 1310 fi
1311 1311
1312 1312 printf "%s\n" "Usage:"
1313 1313 printf " rcstack backup-db\n"
1314 1314 printf " rcstack backup-db --help | -h\n"
1315 1315 echo
1316 1316
1317 1317 # :command.long_usage
1318 1318 if [[ -n $long_usage ]]; then
1319 1319 printf "%s\n" "Options:"
1320 1320
1321 1321 # :command.usage_fixed_flags
1322 1322 printf " %s\n" "--help, -h"
1323 1323 printf " Show this help\n"
1324 1324 echo
1325 1325
1326 1326 # :command.usage_examples
1327 1327 printf "%s\n" "Examples:"
1328 1328 printf " # make backup gz compressed from container DB\n - ./rcstack backup-db\n \n # restore backup\n - gunzip your_dump.sql.gz\n - ./rcstack cli db\n - \i /var/rc-data-dump/your_dump.sql\n"
1329 1329 echo
1330 1330
1331 1331 fi
1332 1332 }
1333 1333
1334 1334 # :command.usage
1335 1335 rcstack_backup_data_usage() {
1336 1336 if [[ -n $long_usage ]]; then
1337 1337 printf "rcstack backup-data - Backup RhodeCode storage\n"
1338 1338 echo
1339 1339
1340 1340 else
1341 1341 printf "rcstack backup-data - Backup RhodeCode storage\n"
1342 1342 echo
1343 1343
1344 1344 fi
1345 1345
1346 1346 printf "%s\n" "Usage:"
1347 1347 printf " rcstack backup-data\n"
1348 1348 printf " rcstack backup-data --help | -h\n"
1349 1349 echo
1350 1350
1351 1351 # :command.long_usage
1352 1352 if [[ -n $long_usage ]]; then
1353 1353 printf "%s\n" "Options:"
1354 1354
1355 1355 # :command.usage_fixed_flags
1356 1356 printf " %s\n" "--help, -h"
1357 1357 printf " Show this help\n"
1358 1358 echo
1359 1359
1360 1360 # :command.usage_examples
1361 1361 printf "%s\n" "Examples:"
1362 1362 printf " # make backup gz compressed for rhodecode containers, and all volumes\n - ./rcstack backup-data\n"
1363 1363 echo
1364 1364
1365 1365 fi
1366 1366 }
1367 1367
1368 1368 # :command.usage
1369 1369 rcstack_get_build_artifacts_usage() {
1370 1370 if [[ -n $long_usage ]]; then
1371 1371 printf "rcstack get-build-artifacts - Fetch Artifacts to run installer based build\n"
1372 1372 echo
1373 1373
1374 1374 else
1375 1375 printf "rcstack get-build-artifacts - Fetch Artifacts to run installer based build\n"
1376 1376 echo
1377 1377
1378 1378 fi
1379 1379
1380 1380 printf "%s\n" "Usage:"
1381 1381 printf " rcstack get-build-artifacts [OPTIONS]\n"
1382 1382 printf " rcstack get-build-artifacts --help | -h\n"
1383 1383 echo
1384 1384
1385 1385 # :command.long_usage
1386 1386 if [[ -n $long_usage ]]; then
1387 1387 printf "%s\n" "Options:"
1388 1388
1389 1389 # :command.usage_flags
1390 1390 # :flag.usage
1391 1391 printf " %s\n" "--auth AUTH"
1392 1392 printf " Specify custom auth for curl e.g -u admin:secret\n"
1393 1393 printf " Default: \n"
1394 1394 echo
1395 1395
1396 1396 # :flag.usage
1397 1397 printf " %s\n" "--installer-url INSTALLER_URL"
1398 1398 printf " Installer Download URL\n"
1399 1399 printf " Default: https://dls.rhodecode.com/dls/N2E2ZTY1NzA3NjYxNDA2NTc1NjI3MTcyNzA2MjcxNzIyZTcwNjI3YQ==/rhodecode-control/latest-linux-ee\n"
1400 1400 echo
1401 1401
1402 1402 # :flag.usage
1403 1403 printf " %s\n" "--manifest-url MANIFEST_URL"
1404 1404 printf " Manifest file url\n"
1405 1405 printf " Default: https://dls.rhodecode.com/linux/MANIFEST\n"
1406 1406 echo
1407 1407
1408 1408 # :flag.usage
1409 1409 printf " %s\n" "--version-name VERSION_NAME"
1410 1410 printf " Specify custom build ver e.g 4.27.0\n"
1411 1411 printf " Default: $RC_CLI_VERSION_NAME\n"
1412 1412 echo
1413 1413
1414 1414 # :command.usage_fixed_flags
1415 1415 printf " %s\n" "--help, -h"
1416 1416 printf " Show this help\n"
1417 1417 echo
1418 1418
1419 1419 fi
1420 1420 }
1421 1421
1422 1422 # :command.usage
1423 1423 rcstack_build_installer_usage() {
1424 1424 if [[ -n $long_usage ]]; then
1425 1425 printf "rcstack build-installer - Build RhodeCode image from installer, ./rcstack get-build-artifacts initially\n"
1426 1426 echo
1427 1427
1428 1428 else
1429 1429 printf "rcstack build-installer - Build RhodeCode image from installer, ./rcstack get-build-artifacts initially\n"
1430 1430 echo
1431 1431
1432 1432 fi
1433 1433
1434 1434 printf "%s\n" "Usage:"
1435 1435 printf " rcstack build-installer [OPTIONS]\n"
1436 1436 printf " rcstack build-installer --help | -h\n"
1437 1437 echo
1438 1438
1439 1439 # :command.long_usage
1440 1440 if [[ -n $long_usage ]]; then
1441 1441 printf "%s\n" "Options:"
1442 1442
1443 1443 # :command.usage_flags
1444 1444 # :flag.usage
1445 1445 printf " %s\n" "--version-name VERSION_NAME"
1446 1446 printf " Specify custom build ver e.g 4.27.0\n"
1447 1447 printf " Default: $RC_CLI_VERSION_NAME\n"
1448 1448 echo
1449 1449
1450 1450 # :command.usage_fixed_flags
1451 1451 printf " %s\n" "--help, -h"
1452 1452 printf " Show this help\n"
1453 1453 echo
1454 1454
1455 1455 fi
1456 1456 }
1457 1457
1458 1458 # :command.usage
1459 1459 rcstack_get_build_source_usage() {
1460 1460 if [[ -n $long_usage ]]; then
1461 1461 printf "rcstack get-build-source - Fetch RhodeCode sources, store in .source dir to run a source-based builds\n"
1462 1462 echo
1463 1463
1464 1464 else
1465 1465 printf "rcstack get-build-source - Fetch RhodeCode sources, store in .source dir to run a source-based builds\n"
1466 1466 echo
1467 1467
1468 1468 fi
1469 1469
1470 1470 printf "%s\n" "Usage:"
1471 1471 printf " rcstack get-build-source [OPTIONS]\n"
1472 1472 printf " rcstack get-build-source --help | -h\n"
1473 1473 echo
1474 1474
1475 1475 # :command.long_usage
1476 1476 if [[ -n $long_usage ]]; then
1477 1477 printf "%s\n" "Options:"
1478 1478
1479 1479 # :command.usage_flags
1480 1480 # :flag.usage
1481 1481 printf " %s\n" "--revision REVISION"
1482 1482 printf " revision to download\n"
1483 1483 printf " Default: default\n"
1484 1484 echo
1485 1485
1486 1486 # :flag.usage
1487 1487 printf " %s\n" "--auth-token AUTH_TOKEN"
1488 1488 printf " Specify AUTH TOKEN to obtain sources\n"
1489 1489 echo
1490 1490
1491 1491 # :flag.usage
1492 1492 printf " %s\n" "--server-url SERVER_URL"
1493 1493 printf " Specify RhodeCode server location where projects should be downloaded\n"
1494 1494 printf " Default: https://code.rhodecode.com\n"
1495 1495 echo
1496 1496
1497 1497 # :command.usage_fixed_flags
1498 1498 printf " %s\n" "--help, -h"
1499 1499 printf " Show this help\n"
1500 1500 echo
1501 1501
1502 1502 # :command.usage_examples
1503 1503 printf "%s\n" "Examples:"
1504 1504 printf " ./rcstack get-sources $RC_CLI_VERSION_NAME\n"
1505 1505 printf " ./rcstack get-sources default --auth-token xyxyxyx --server-url\n https://secret.repo/\n"
1506 1506 echo
1507 1507
1508 1508 fi
1509 1509 }
1510 1510
1511 1511 # :command.usage
1512 1512 rcstack_build_source_usage() {
1513 1513 if [[ -n $long_usage ]]; then
1514 1514 printf "rcstack build-source - Build RhodeCode image from source, requires ./rcstack get-build-source initially\n"
1515 1515 echo
1516 1516
1517 1517 else
1518 1518 printf "rcstack build-source - Build RhodeCode image from source, requires ./rcstack get-build-source initially\n"
1519 1519 echo
1520 1520
1521 1521 fi
1522 1522
1523 1523 printf "%s\n" "Usage:"
1524 1524 printf " rcstack build-source [OPTIONS]\n"
1525 1525 printf " rcstack build-source --help | -h\n"
1526 1526 echo
1527 1527
1528 1528 # :command.long_usage
1529 1529 if [[ -n $long_usage ]]; then
1530 1530 printf "%s\n" "Options:"
1531 1531
1532 1532 # :command.usage_flags
1533 1533 # :flag.usage
1534 1534 printf " %s\n" "--version-name VERSION_NAME"
1535 1535 printf " Specify custom build ver e.g 4.27.0\n"
1536 1536 printf " Default: $RC_CLI_VERSION_NAME\n"
1537 1537 echo
1538 1538
1539 1539 # :flag.usage
1540 1540 printf " %s\n" "--source-build-yaml BUILD_SOURCE_YAML"
1541 1541 printf " yaml file to build source against\n"
1542 1542 printf " Default: docker-compose-apps.source.yaml\n"
1543 1543 echo
1544 1544
1545 1545 # :flag.usage
1546 1546 printf " %s\n" "--tag TAG (repeatable)"
1547 1547 printf " tag build image\n"
1548 1548 echo
1549 1549
1550 1550 # :command.usage_fixed_flags
1551 1551 printf " %s\n" "--help, -h"
1552 1552 printf " Show this help\n"
1553 1553 echo
1554 1554
1555 1555 # :command.usage_examples
1556 1556 printf "%s\n" "Examples:"
1557 1557 printf " ./rcstack build-source --version-name 4.28.0.REL.2023.02.02.1\n"
1558 1558 printf " ./rcstack build-source --source-build-yaml docker-compose-apps.venv.yaml\n --version-name 4.28.0.REL.2023.02.02.1\n"
1559 1559 echo
1560 1560
1561 1561 fi
1562 1562 }
1563 1563
1564 1564 # :command.usage
1565 1565 rcstack__completions_usage() {
1566 1566 if [[ -n $long_usage ]]; then
1567 1567 printf "rcstack _completions - Generate completions\n"
1568 1568 echo
1569 1569
1570 1570 else
1571 1571 printf "rcstack _completions - Generate completions\n"
1572 1572 echo
1573 1573
1574 1574 fi
1575 1575
1576 1576 printf "%s\n" "Usage:"
1577 1577 printf " rcstack _completions\n"
1578 1578 printf " rcstack _completions --help | -h\n"
1579 1579 echo
1580 1580
1581 1581 # :command.long_usage
1582 1582 if [[ -n $long_usage ]]; then
1583 1583 printf "%s\n" "Options:"
1584 1584
1585 1585 # :command.usage_fixed_flags
1586 1586 printf " %s\n" "--help, -h"
1587 1587 printf " Show this help\n"
1588 1588 echo
1589 1589
1590 1590 fi
1591 1591 }
1592 1592
1593 1593 # :command.normalize_input
1594 1594 normalize_input() {
1595 1595 local arg flags
1596 1596
1597 1597 while [[ $# -gt 0 ]]; do
1598 1598 arg="$1"
1599 1599 if [[ $arg =~ ^(--[a-zA-Z0-9_\-]+)=(.+)$ ]]; then
1600 1600 input+=("${BASH_REMATCH[1]}")
1601 1601 input+=("${BASH_REMATCH[2]}")
1602 1602 elif [[ $arg =~ ^(-[a-zA-Z0-9])=(.+)$ ]]; then
1603 1603 input+=("${BASH_REMATCH[1]}")
1604 1604 input+=("${BASH_REMATCH[2]}")
1605 1605 elif [[ $arg =~ ^-([a-zA-Z0-9][a-zA-Z0-9]+)$ ]]; then
1606 1606 flags="${BASH_REMATCH[1]}"
1607 1607 for ((i = 0; i < ${#flags}; i++)); do
1608 1608 input+=("-${flags:i:1}")
1609 1609 done
1610 1610 else
1611 1611 input+=("$arg")
1612 1612 fi
1613 1613
1614 1614 shift
1615 1615 done
1616 1616 }
1617 1617 # :command.inspect_args
1618 1618 inspect_args() {
1619 1619 if ((${#args[@]})); then
1620 1620 readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
1621 1621 echo args:
1622 1622 for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done
1623 1623 else
1624 1624 echo args: none
1625 1625 fi
1626 1626
1627 1627 if ((${#other_args[@]})); then
1628 1628 echo
1629 1629 echo other_args:
1630 1630 echo "- \${other_args[*]} = ${other_args[*]}"
1631 1631 for i in "${!other_args[@]}"; do
1632 1632 echo "- \${other_args[$i]} = ${other_args[$i]}"
1633 1633 done
1634 1634 fi
1635 1635
1636 1636 if ((${#deps[@]})); then
1637 1637 readarray -t sorted_keys < <(printf '%s\n' "${!deps[@]}" | sort)
1638 1638 echo
1639 1639 echo deps:
1640 1640 for k in "${sorted_keys[@]}"; do echo "- \${deps[$k]} = ${deps[$k]}"; done
1641 1641 fi
1642 1642
1643 1643 }
1644 1644
1645 1645 # :command.user_lib
1646 1646 # src/lib/check_bootstrap.sh
1647 1647
1648 1648 check_bootstrap() {
1649 1649 # Avoid destroying bootstrapping by simple start/stop
1650 1650 for stage_name in $BOOTSTRAP_STAGES; do
1651 1651 if ! config_has_key $stage_name ; then
1652 1652 echo "$(yellow WARNING:) Bootstrap key $stage_name not found in config file $CONFIG_FILE!"
1653 1653 echo "$(yellow NOTICE:) Run this first: ./$RC_SCRIPT_NAME init"
1654 1654 exit
1655 1655 fi
1656 1656 done
1657 1657
1658 1658 }
1659 1659
1660 1660 # src/lib/colors.sh
1661 1661 print_in_color() {
1662 1662 local color="$1"
1663 1663 shift
1664 1664 if [[ -z ${NO_COLOR+x} ]]; then
1665 1665 printf "$color%b\e[0m\n" "$*"
1666 1666 else
1667 1667 printf "%b\n" "$*"
1668 1668 fi
1669 1669 }
1670 1670
1671 1671 red() { print_in_color "\e[31m" "$*"; }
1672 1672 green() { print_in_color "\e[32m" "$*"; }
1673 1673 yellow() { print_in_color "\e[33m" "$*"; }
1674 1674 blue() { print_in_color "\e[34m" "$*"; }
1675 1675 magenta() { print_in_color "\e[35m" "$*"; }
1676 1676 cyan() { print_in_color "\e[36m" "$*"; }
1677 1677 bold() { print_in_color "\e[1m" "$*"; }
1678 1678 underlined() { print_in_color "\e[4m" "$*"; }
1679 1679 red_bold() { print_in_color "\e[1;31m" "$*"; }
1680 1680 green_bold() { print_in_color "\e[1;32m" "$*"; }
1681 1681 yellow_bold() { print_in_color "\e[1;33m" "$*"; }
1682 1682 blue_bold() { print_in_color "\e[1;34m" "$*"; }
1683 1683 magenta_bold() { print_in_color "\e[1;35m" "$*"; }
1684 1684 cyan_bold() { print_in_color "\e[1;36m" "$*"; }
1685 1685 red_underlined() { print_in_color "\e[4;31m" "$*"; }
1686 1686 green_underlined() { print_in_color "\e[4;32m" "$*"; }
1687 1687 yellow_underlined() { print_in_color "\e[4;33m" "$*"; }
1688 1688 blue_underlined() { print_in_color "\e[4;34m" "$*"; }
1689 1689 magenta_underlined() { print_in_color "\e[4;35m" "$*"; }
1690 1690 cyan_underlined() { print_in_color "\e[4;36m" "$*"; }
1691 1691
1692 1692 # src/lib/config.sh
1693 1693
1694 1694 config_show() {
1695 1695 config_load
1696 1696 ini_show
1697 1697 }
1698 1698
1699 1699 config_get() {
1700 1700 local key="$1"
1701 1701 local default_value="$2"
1702 1702
1703 1703 config_load
1704 1704 echo "${ini["$key"]:-$default_value}"
1705 1705 }
1706 1706
1707 1707 config_set() {
1708 1708 local key="$1"
1709 1709 shift
1710 1710 local value="$*"
1711 1711
1712 1712 config_load
1713 1713 ini["$key"]="$value"
1714 1714 config_save
1715 1715 }
1716 1716
1717 1717 config_del() {
1718 1718 local key="$1"
1719 1719
1720 1720 config_load
1721 1721 unset "ini[$key]"
1722 1722 config_save
1723 1723 }
1724 1724
1725 1725 config_keys() {
1726 1726 config_load
1727 1727 ini_keys
1728 1728 }
1729 1729
1730 1730 config_has_key() {
1731 1731 [[ $(config_get "$1") ]]
1732 1732 }
1733 1733
1734 1734 config_reload() {
1735 1735 declare -g config_loaded=false
1736 1736 config_load
1737 1737 }
1738 1738
1739 1739 config_load() {
1740 1740 [[ "$config_loaded" == "true" ]] && return
1741 1741
1742 1742 declare -g CONFIG_FILE=${CONFIG_FILE:=config.ini}
1743 1743 declare -g config_loaded=true
1744 1744 [[ -f "$CONFIG_FILE" ]] || touch "$CONFIG_FILE"
1745 1745 ini_load "$CONFIG_FILE"
1746 1746 }
1747 1747
1748 1748 config_save() {
1749 1749 ini_save "$CONFIG_FILE"
1750 1750 }
1751 1751
1752 1752 # src/lib/dotenv.sh
1753 1753
1754 1754 __dotenv=
1755 1755 __dotenv_file=
1756 1756 __dotenv_cmd=.env
1757 1757
1758 1758 .env() {
1759 1759 REPLY=()
1760 1760 [[ $__dotenv_file || ${1-} == -* ]] || .env.--file .env || return
1761 1761 if declare -F -- ".env.${1-}" >/dev/null; then .env."$@"; return ; fi
1762 1762 .env --help >&2; return 64
1763 1763 }
1764 1764
1765 1765 .env.-f() { .env.--file "$@"; }
1766 1766
1767 1767 .env.get() {
1768 1768 .env::arg "get requires a key" "$@" &&
1769 1769 [[ "$__dotenv" =~ ^(.*(^|$'\n'))([ ]*)"$1="(.*)$ ]] &&
1770 1770 REPLY=${BASH_REMATCH[4]%%$'\n'*} && REPLY=${REPLY%"${REPLY##*[![:space:]]}"}
1771 1771 }
1772 1772
1773 1773 .env.parse() {
1774 1774 local line key
1775 1775 while IFS= read -r line; do
1776 1776 line=${line#"${line%%[![:space:]]*}"} # trim leading whitespace
1777 1777 line=${line%"${line##*[![:space:]]}"} # trim trailing whitespace
1778 1778 if [[ ! "$line" || "$line" == '#'* ]]; then continue ; fi
1779 1779 if (($#)); then
1780 1780 for key; do
1781 1781 if [[ $key == "${line%%=*}" ]]; then REPLY+=("$line"); break;
1782 1782 fi
1783 1783 done
1784 1784 else
1785 1785 REPLY+=("$line")
1786 1786 fi
1787 1787 done <<<"$__dotenv"
1788 1788 ((${#REPLY[@]}))
1789 1789 }
1790 1790
1791 1791 .env.export() { ! .env.parse "$@" || export "${REPLY[@]}"; }
1792 1792
1793 1793 .env.set() {
1794 1794 .env::file load || return ; local key saved=$__dotenv
1795 1795 while (($#)); do
1796 1796 key=${1#+}; key=${key%%=*}
1797 1797 if .env.get "$key"; then
1798 1798 REPLY=()
1799 1799 if [[ $1 == +* ]]; then shift; continue # skip if already found
1800 1800 elif [[ $1 == *=* ]]; then
1801 1801 __dotenv=${BASH_REMATCH[1]}${BASH_REMATCH[3]}$1$'\n'${BASH_REMATCH[4]#*$'\n'}
1802 1802 else
1803 1803 __dotenv=${BASH_REMATCH[1]}${BASH_REMATCH[4]#*$'\n'}
1804 1804 continue # delete all occurrences
1805 1805 fi
1806 1806 elif [[ $1 == *=* ]]; then
1807 1807 __dotenv+="${1#+}"$'\n'
1808 1808 fi
1809 1809 shift
1810 1810 done
1811 1811 [[ $__dotenv == "$saved" ]] || .env::file save
1812 1812 }
1813 1813
1814 1814 .env.puts() { echo "${1-}">>"$__dotenv_file" && __dotenv+="$1"$'\n'; }
1815 1815
1816 1816 .env.generate() {
1817 1817 .env::arg "key required for generate" "$@" || return
1818 1818 .env.get "$1" && return || REPLY=$("${@:2}") || return
1819 1819 .env::one "generate: ouptut of '${*:2}' has more than one line" "$REPLY" || return
1820 1820 .env.puts "$1=$REPLY"
1821 1821 }
1822 1822
1823 1823 .env.--file() {
1824 1824 .env::arg "filename required for --file" "$@" || return
1825 1825 __dotenv_file=$1; .env::file load || return
1826 1826 (($#<2)) || .env "${@:2}"
1827 1827 }
1828 1828
1829 1829 .env::arg() { [[ "${2-}" ]] || { echo "$__dotenv_cmd: $1" >&2; return 64; }; }
1830 1830
1831 1831 .env::one() { [[ "$2" != *$'\n'* ]] || .env::arg "$1"; }
1832 1832
1833 1833 .env::file() {
1834 1834 local REPLY=$__dotenv_file
1835 1835 case "$1" in
1836 1836 load)
1837 1837 __dotenv=; ! [[ -f "$REPLY" ]] || __dotenv="$(<"$REPLY")"$'\n' || return ;;
1838 1838 save)
1839 1839 if [[ -L "$REPLY" ]] && declare -F -- realpath.resolved >/dev/null; then
1840 1840 realpath.resolved "$REPLY"
1841 1841 fi
1842 1842 { [[ ! -f "$REPLY" ]] || cp -p "$REPLY" "$REPLY.bak"; } &&
1843 1843 printf %s "$__dotenv" >"$REPLY.bak" && mv "$REPLY.bak" "$REPLY"
1844 1844 esac
1845 1845 }
1846 1846 #
1847 1847 #__dotenv() {
1848 1848 # set -eu
1849 1849 # __dotenv_cmd=${0##*/}
1850 1850 # .env.export() { .env.parse "$@" || return 0; printf 'export %q\n' "${REPLY[@]}"; REPLY=(); }
1851 1851 # .env "$@" || return $?
1852 1852 # ${REPLY[@]+printf '%s\n' "${REPLY[@]}"}
1853 1853 #}
1854 1854 #if [[ $0 == "${BASH_SOURCE-}" ]]; then __dotenv "$@"; exit; fi
1855 1855
1856 1856 # src/lib/get_docker_definitions.sh
1857 1857
1858 1858 get_docker_definitions() {
1859 1859 SOURCE_DIR=$PWD
1860 1860 RHODECODE_DOCKER_HASH=$1
1861 1861 FULL_MODE=$2
1862 1862 DEBUG=$3
1863 1863
1864 1864 # download sources
1865 1865 echo "bootstrap_definitions: download rhodecode docker definitions from $SERVER_URL"
1866 1866 echo ""
1867 1867 extracted_arcive_dir="rhodecode-enterprise-docker-id-bacb-sub-0-archive-all"
1868 1868
1869 1869 if [ $DEBUG ]; then
1870 1870 echo "bootstrap_definitions: downloading: $SERVER_URL/rhodecode-enterprise-docker/archive/$RHODECODE_DOCKER_HASH.tgz?with_hash=0"
1871 1871 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
1872 1872
1873 1873 echo "extracted archive to $SOURCE_DIR"
1874 1874 echo "bootstrap_definitions: running CP $SOURCE_DIR/$extracted_arcive_dir/* $SOURCE_DIR"
1875 1875 cp_backup_verbose $SOURCE_DIR/*rhodecode-enterprise-docker-plain/* $SOURCE_DIR
1876 1876
1877 1877 echo "bootstrap_definitions: removing $SOURCE_DIR/$extracted_arcive_dir"
1878 1878 rm -r $SOURCE_DIR/$extracted_arcive_dir
1879 1879 else
1880 1880 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
1881 1881
1882 1882 cp_backup $SOURCE_DIR/$extracted_arcive_dir/* $SOURCE_DIR
1883 1883
1884 1884 rm -r $SOURCE_DIR/$extracted_arcive_dir
1885 1885 fi
1886 1886
1887 1887 echo "$(green bootstrap_definitions: docker definitions extracted to $SOURCE_DIR)"
1888 1888
1889 1889 # cleanup of backup files, just good to have, ignore any warnings
1890 1890 # NOTE: Disabled for backward compat
1891 1891 #find "$SOURCE_DIR" -nowarn -ignore_readdir_race -iname "*.~*~" -delete 2> /dev/null
1892 1892
1893 1893 # some cleanup of things we don't need in cli
1894 1894 if [[ ! $FULL_MODE ]]; then
1895 1895 rm dev-tools
1896 1896 rm -r scripts/dev-tools
1897 1897 rm -r entrypoints.d
1898 1898 fi
1899 1899 }
1900 1900
1901 1901 # src/lib/ini.sh
1902 1902
1903 1903 ini_load() {
1904 1904 declare -gA ini
1905 1905
1906 1906 local ini_file="$1"
1907 1907
1908 1908 local section=""
1909 1909 local key=""
1910 1910 local value=""
1911 1911 local section_regex="^\[(.+)\]"
1912 1912 local key_regex="^([^ =]+) *= *(.*) *$"
1913 1913 local comment_regex="^;"
1914 1914
1915 1915 while IFS= read -r line; do
1916 1916 if [[ $line =~ $comment_regex ]]; then
1917 1917 continue
1918 1918 elif [[ $line =~ $section_regex ]]; then
1919 1919 section="${BASH_REMATCH[1]}."
1920 1920 elif [[ $line =~ $key_regex ]]; then
1921 1921 key="${BASH_REMATCH[1]}"
1922 1922 value="${BASH_REMATCH[2]}"
1923 1923 ini["${section}${key}"]="$value"
1924 1924 fi
1925 1925 done <"$ini_file"
1926 1926 }
1927 1927
1928 1928 ini_save() {
1929 1929 declare -gA ini
1930 1930
1931 1931 local ini_file="$1"
1932 1932
1933 1933 local current_section=""
1934 1934 local has_free_keys=false
1935 1935
1936 1936 rm -f "$ini_file"
1937 1937
1938 1938 for key in $(ini_keys); do
1939 1939 [[ $key == *.* ]] && continue
1940 1940 has_free_keys=true
1941 1941 value="${ini[$key]}"
1942 1942 echo "$key = $value" >>"$ini_file"
1943 1943 done
1944 1944
1945 1945 [[ "${has_free_keys}" == "true" ]] && echo >>"$ini_file"
1946 1946
1947 1947 for key in $(ini_keys); do
1948 1948 [[ $key == *.* ]] || continue
1949 1949 value="${ini[$key]}"
1950 1950 IFS="." read -r section_name key_name <<<"$key"
1951 1951
1952 1952 if [[ "$current_section" != "$section_name" ]]; then
1953 1953 [[ $current_section ]] && echo >>"$ini_file"
1954 1954 echo "[$section_name]" >>"$ini_file"
1955 1955 current_section="$section_name"
1956 1956 fi
1957 1957
1958 1958 echo "$key_name = $value" >>"$ini_file"
1959 1959 done
1960 1960 }
1961 1961
1962 1962 ini_show() {
1963 1963 declare -gA ini
1964 1964
1965 1965 for key in $(ini_keys); do
1966 1966 echo "$key = ${ini[$key]}"
1967 1967 done
1968 1968 }
1969 1969
1970 1970 ini_keys() {
1971 1971 declare -gA ini
1972 1972
1973 1973 local keys=("${!ini[@]}")
1974 1974 for a in "${keys[@]}"; do echo "$a"; done | sort
1975 1975 }
1976 1976
1977 1977 # src/lib/reconfigure_ini.sh
1978 1978 sed_replace() {
1979 1979 if [[ $ini_path == "" ]]; then
1980 1980 echo "ERROR: missing 'ini_path' variable"
1981 1981 fi
1982 1982
1983 1983 if [[ $DEBUG ]]; then
1984 1984 echo
1985 1985 echo "sed --in-place=.replaced -E \"s/$1/$2/\" $ini_path"
1986 1986 echo "pat1: $1"
1987 1987 echo "pat2: $2"
1988 1988 fi
1989 1989
1990 1990 sed --in-place=.replaced -E "s/$1/$2/" $ini_path
1991 1991
1992 1992 }
1993 1993
1994 1994 sed_safe_path() {
1995 1995 echo $((echo $1|sed -r 's/([\$\.\*\/\[\\^])/\\\1/g'|sed 's/[]]/\[]]/g')>&1)
1996 1996 }
1997 1997
1998 1998 config_vcsserver_ini() {
1999 1999
2000 2000 #host/port
2001 2001 sed_replace '^#?host = .*' 'host = 0\.0\.0\.0'
2002 2002 sed_replace '^#?port = .*' 'port = 10010'
2003 2003
2004 2004 # workers adjustment
2005 2005 sed_replace '^#?workers = .*' 'workers = 1'
2006 2006 sed_replace '^#?memory_max_usage = .*' 'memory_max_usage = 2147483648'
2007 2007 sed_replace '^#?core\.binary_dir = .*' 'core.binary_dir = \/usr\/local\/bin\/rhodecode_bin\/vcs_bin'
2008 2008
2009 2009 sed_replace '^#?rc_cache\.repo_object\.expiration_time = .*' '#rc_cache.repo_object.expiration_time = 2592000'
2010 2010 sed_replace '^#?rc_cache\.repo_object\.backend = dogpile\.cache\.rc\.redis_msgpack' 'rc_cache.repo_object.backend = dogpile.cache.rc.redis_msgpack'
2011 2011
2012 2012 sed_replace '^#?rc_cache\.repo_object\.arguments\.socket_timeout = .*' 'rc_cache.repo_object.arguments.socket_timeout = 30'
2013 2013 sed_replace '^#?rc_cache\.repo_object\.arguments\.db = .*' 'rc_cache.repo_object.arguments.db = 5'
2014 2014 sed_replace '^#?rc_cache\.repo_object\.arguments\.port = .*' 'rc_cache.repo_object.arguments.port = 6379'
2015 2015 sed_replace '^#?rc_cache\.repo_object\.arguments\.host = .*' 'rc_cache.repo_object.arguments.host = redis'
2016 2016 sed_replace '^#?rc_cache\.repo_object\.arguments\.redis_expiration_time = .*' 'rc_cache.repo_object.arguments.redis_expiration_time = 3592000'
2017 2017
2018 2018 sed_replace '^#?cache_dir = .*' 'cache_dir = \/var\/opt\/rhodecode_data'
2019 2019 sed_replace '^#?formatter = .*' 'formatter = json'
2020 2020
2021 2021 #statsd enable
2022 2022 sed_replace '^#?statsd.enabled = .*' 'statsd.enabled = true'
2023 2023 sed_replace '^#?statsd.statsd_host = .*' 'statsd.statsd_host = statsd-exporter'
2024 2024 sed_replace '^#?statsd.statsd_port = .*' 'statsd.statsd_port = 9125'
2025 2025
2026 2026 }
2027 2027
2028 2028 config_rhodecode_ini() {
2029 2029 #host/port
2030 2030 sed_replace '^#?host = .*' 'host = 0\.0\.0\.0'
2031 2031 sed_replace '^#?port = .*' 'port = 10020'
2032 2032
2033 2033 # workers adjustment
2034 2034 sed_replace '^#?workers = .*' 'workers = 1'
2035 2035 sed_replace '^#?memory_max_usage = .*' 'memory_max_usage = 2147483648'
2036 2036
2037 2037 # email
2038 2038 sed_replace '^#?email_prefix = .*' 'email_prefix = [RhodeCode]'
2039 2039 sed_replace '^#?app_email_from = .*' "app_email_from = rhodecode-noreply@$RC_HOSTNAME"
2040 2040 sed_replace '^#?smtp_server = .*' 'smtp_server = localhost'
2041 2041
2042 2042 # app-instance-uuid
2043 2043 sed_replace '^app_instance_uuid = .*' "app_instance_uuid = $RC_APP_INSTANCE_UUID"
2044 2044
2045 2045 # app base
2046 2046 sed_replace '^app\.base_url = .*' "app\.base_url = $RC_APP_BASE_URL"
2047 2047
2048 2048 # set license_token
2049 2049 sed_replace '^#?license_token =.*' "license_token = $RC_LICENSE_TOKEN"
2050 2050 # set Edition
2051 2051 sed_replace '^use = egg:rhodecode-enterprise.*' "use = egg:rhodecode-enterprise-$RC_EDITION"
2052 2052
2053 2053 # enable celery
2054 2054 sed_replace '^#?use_celery = .*' 'use_celery = true'
2055 2055
2056 2056 # DB
2057 2057 sed_replace '^sqlalchemy\.db1\.url =.*' "sqlalchemy\.db1\.url = $RC_SQLALCHEMY_DB1_URL"
2058 2058
2059 2059 #CHANNELSTREAM WS_URL
2060 2060 sed_replace '^#?channelstream\.ws_url =.*' "channelstream\.ws_url = $RC_CHANNELSTREAM_WS_URL"
2061 2061
2062 2062 # set cache dir
2063 2063 sed_replace '^#?cache_dir = .*' 'cache_dir = \/var\/opt\/rhodecode_data'
2064 2064
2065 2065 # set archive cache dir
2066 2066 sed_replace '^#?archive_cache_dir = .*' 'archive_cache_dir = \/var\/opt\/rhodecode_data\/tarballcache'
2067 2067
2068 2068 # set file_store path
2069 2069 sed_replace '^#?file_store\.storage_path = .*' 'file_store.storage_path = \/var\/opt\/rhodecode_data\/file_store'
2070 2070
2071 2071 # cleanup rabbitmq example entry
2072 2072 sed_replace '^#celery\.broker_url = amqp.*' ''
2073 2073 sed_replace '^#?celery\.broker_url = .*' 'celery\.broker_url = redis:\/\/redis:6379\/8'
2074 2074
2075 2075 # switch beaker sessions to Redis based
2076 2076 sed_replace '^#?beaker.session.type = file.*' '#beaker.session.type = file'
2077 2077 sed_replace '^#?beaker.session.data_dir = .*' '#beaker.session.data_dir = \/tmp\/data\/sessions'
2078 2078
2079 2079 # enable redis db2
2080 2080 sed_replace '^#?beaker\.session\.type = ext:redis' 'beaker.session.type = ext:redis'
2081 2081 sed_replace '^#?beaker\.session\.url = redis:\/\/127.0.0.1:6379\/2' 'beaker.session.url = redis:\/\/redis:6379\/2'
2082 2082
2083 2083 # sed_replace '^#?beaker.session.type = ext:database.*' 'beaker.session.type = ext:database'
2084 2084 # sed_replace '^#?beaker.session.sa.url = postgresql.*' 'beaker.session.sa.url = postgresql://{{rhodecode_db_username}}:{{rhodecode_db_password}}@localhost/{{rhodecode_db_name}}'
2085 2085
2086 2086 # hooks reconfigure for auto-bind to host
2087 2087 sed_replace '^#?vcs.hooks.host = .*' 'vcs.hooks.host = \*'
2088 2088 sed_replace '^#?vcs.server = .*' 'vcs.server = vcsserver:10010'
2089 2089
2090 2090 # enable SVN
2091 2091 sed_replace '^#?svn.proxy.generate_config = .*' 'svn.proxy.generate_config = true'
2092 2092
2093 2093 # enable SSH
2094 2094 sed_replace '^#?ssh.generate_authorized_keyfile = .*' 'ssh.generate_authorized_keyfile = true'
2095 2095
2096 2096 #statsd enable
2097 2097 sed_replace '^#?statsd.enabled = .*' 'statsd.enabled = true'
2098 2098 sed_replace '^#?statsd.statsd_host = .*' 'statsd.statsd_host = statsd-exporter'
2099 2099 sed_replace '^#?statsd.statsd_port = .*' 'statsd.statsd_port = 9125'
2100 2100
2101 2101 # the wrapper_cmd
2102 2102 sed_replace '^#?ssh.wrapper_cmd = .*' 'ssh.wrapper_cmd = \/usr\/local\/bin\/rhodecode_bin\/bin\/rc-ssh-wrapper'
2103 2103
2104 2104 sed_replace '^#?api_access_controllers_whitelist = .*' 'api_access_controllers_whitelist = RepoFilesView:repo_archivefile, RepoFilesView:repo_file_raw'
2105 2105
2106 2106 # # set search to elasticsearch
2107 2107 # # enabled modules for Whoosh we remove, we have duplicates there..
2108 2108 # '^search.module = .*' ''
2109 2109 # '^search.location = .*' ''
2110 2110 #
2111 2111 # '^#?search.module = .*' 'search.module = rc_elasticsearch'
2112 2112 # '^#?search.location = .*' 'search.location = http://localhost:9200'
2113 2113 # '^#?search.es_version = .*' 'search.es_version = 6'
2114 2114
2115 2115 # enable Chat
2116 2116 sed_replace '^#?chat.enabled = .*' 'chat.enabled = true'
2117 2117
2118 2118 # logging
2119 2119 sed_replace '^#?formatter = .*' 'formatter = json'
2120 2120
2121 2121 }
2122 2122
2123 2123 # src/lib/send_completions.sh
2124 2124
2125 2125 # src/lib/utils.sh
2126 2126
2127 2127 generate_md5() {
2128 2128 local input_string="$1"
2129 2129
2130 2130 if command -v md5 &> /dev/null; then
2131 2131 echo -n "$input_string" | md5
2132 2132 elif command -v md5sum &> /dev/null; then
2133 2133 echo -n "$input_string" | md5sum | awk '{print $1}'
2134 2134 else
2135 2135 echo "Error: Neither md5 nor md5sum command is available. Please make sure this is installed in your system"
2136 2136 return 1
2137 2137 fi
2138 2138 }
2139 2139
2140 2140 random_str() {
2141 2141 len=$1
2142 2142 random_generate=$(generate_md5 $RANDOM | head -c $len)
2143 2143 echo "$random_generate"
2144 2144 }
2145 2145
2146 2146 # function to copy files with --backup=numbered option
2147 2147 detect_cp_backup () {
2148 2148 cp -r -f --update --backup=numbered "$@" 2>/dev/null
2149 2149 if [ $? -eq 0 ]; then
2150 2150 # if exit status is 0, --backup=numbered worked and return true
2151 2151 return 0
2152 2152 else
2153 2153 # if exit status is not 0, --backup=numbered didn't work and return false
2154 2154 return 1
2155 2155 fi
2156 2156 }
2157 2157
2158 2158 # function that acts like cp
2159 2159 cp_backup () {
2160 2160 cp -r -f "$@"
2161 2161 }
2162 2162
2163 2163 cp_backup_verbose () {
2164 2164 cp -r -f -v "$@"
2165 2165 }
2166 2166
2167 2167 # version_gte checks if the version specified in $VERSION is at least the given
2168 2168 # SemVer (Maj.Minor[.Patch]), or CalVer (YY.MM) version.It returns 0 (success)
2169 2169 # if $VERSION is either unset (=latest) or newer or equal than the specified
2170 2170 # version, or returns 1 (fail) otherwise.
2171 2171 #
2172 2172 # examples:
2173 2173 #
2174 2174 # VERSION=23.0
2175 2175 # version_gte 23.0 // 0 (success)
2176 2176 # version_gte 20.10 // 0 (success)
2177 2177 # version_gte 19.03 // 0 (success)
2178 2178 # version_gte 21.10 // 1 (fail)
2179 2179 version_gte() {
2180 2180 if [ -z "$VERSION" ]; then
2181 2181 return 0
2182 2182 fi
2183 2183 eval version_compare "$VERSION" "$1"
2184 2184 }
2185 2185
2186 2186 # version_compare compares two version strings (either SemVer (Major.Minor.Path),
2187 2187 # or CalVer (YY.MM) version strings. It returns 0 (success) if version A is newer
2188 2188 # or equal than version B, or 1 (fail) otherwise. Patch releases and pre-release
2189 2189 # (-alpha/-beta) are not taken into account
2190 2190 #
2191 2191 # examples:
2192 2192 #
2193 2193 # version_compare 23.0.0 20.10 // 0 (success)
2194 2194 # version_compare 23.0 20.10 // 0 (success)
2195 2195 # version_compare 20.10 19.03 // 0 (success)
2196 2196 # version_compare 20.10 20.10 // 0 (success)
2197 2197 # version_compare 19.03 20.10 // 1 (fail)
2198 2198 version_compare() (
2199 2199 set +x
2200 2200
2201 2201 yy_a="$(echo "$1" | cut -d'.' -f1)"
2202 2202 yy_b="$(echo "$2" | cut -d'.' -f1)"
2203 2203 if [ "$yy_a" -lt "$yy_b" ]; then
2204 2204 return 1
2205 2205 fi
2206 2206 if [ "$yy_a" -gt "$yy_b" ]; then
2207 2207 return 0
2208 2208 fi
2209 2209 mm_a="$(echo "$1" | cut -d'.' -f2)"
2210 2210 mm_b="$(echo "$2" | cut -d'.' -f2)"
2211 2211
2212 2212 # trim leading zeros to accommodate CalVer
2213 2213 mm_a="${mm_a#0}"
2214 2214 mm_b="${mm_b#0}"
2215 2215
2216 2216 if [ "${mm_a:-0}" -lt "${mm_b:-0}" ]; then
2217 2217 return 1
2218 2218 fi
2219 2219
2220 2220 return 0
2221 2221 )
2222 2222
2223 2223 # src/lib/validate_stack_exists.sh
2224 2224
2225 2225 validate_stack_exists() {
2226 2226 err=""
2227 2227 invalid="1"
2228 2228
2229 2229 for item in $VALID_SERVICES
2230 2230 do
2231 2231 if [ "$1" == "$item" ]; then
2232 2232 invalid=""
2233 2233 break
2234 2234 fi
2235 2235 done
2236 2236
2237 2237 if [[ -n $invalid ]]; then
2238 2238 err="command '$1' not in list of $VALID_SERVICES"
2239 2239 fi
2240 2240
2241 2241 echo $err
2242 2242 }
2243 2243
2244 2244 # src/lib/validations/validate_dir_exists.sh
2245 2245 validate_dir_exists() {
2246 2246 [[ -d "$1" ]] || echo "must be an existing directory"
2247 2247 }
2248 2248
2249 2249 # src/lib/validations/validate_file_exists.sh
2250 2250 validate_file_exists() {
2251 2251 [[ -f "$1" ]] || echo "must be an existing file"
2252 2252 }
2253 2253
2254 2254 # src/lib/validations/validate_integer.sh
2255 2255 validate_integer() {
2256 2256 [[ "$1" =~ ^[0-9]+$ ]] || echo "must be an integer"
2257 2257 }
2258 2258
2259 2259 # src/lib/validations/validate_not_empty.sh
2260 2260 validate_not_empty() {
2261 2261 [[ -z "$1" ]] && echo "must not be empty"
2262 2262 }
2263 2263
2264 2264 # :command.command_functions
2265 2265 # :command.function
2266 2266 rcstack_get_started_command() {
2267 2267 # src/get_started_command.sh
2268 2268 get_started_full
2269 2269 }
2270 2270
2271 2271 # :command.function
2272 2272 rcstack_init_command() {
2273 2273 # src/init_command.sh
2274 2274 DEBUG=${args[--debug]}
2275 2275 force=${args[--force]}
2276 2276 docker_revision=${args[--docker-revision]}
2277 2277 install_docker=${args[--install-docker]}
2278 2278 no_prompt=${args[--no-prompt]}
2279 2279
2280 2280 eval "stages_from_cli=(${args[--stage]})"
2281 2281
2282 2282 # CLI passed args / defaults
2283 2283
2284 2284 if [[ -z ${args['--arg-rc-edition']} ]]; then
2285 2285 # set default
2286 2286 args['--arg-rc-edition']="ee"
2287 2287 else
2288 2288 # mark we used flag and don't ask in prompts
2289 2289 args['__arg_rc_edition']=1
2290 2290 fi
2291 2291
2292 if [[ -z ${args['--arg-accept-eula']} ]]; then
2293 # set default
2294 args['--arg-accept-eula']="yes"
2295 else
2296 # mark we used flag and don't ask in prompts
2297 args['__arg_accept_eula']=1
2298 fi
2299
2292 2300 if [[ -z ${args['--arg-hostname']} ]]; then
2293 2301 # set default
2294 2302 args['--arg-hostname']="rhodecode.local"
2295 2303 else
2296 2304 # mark we used flag and don't ask in prompts
2297 2305 args['__arg_hostname']=1
2298 2306 fi
2299 2307
2300 2308 if [[ -z ${args['--arg-use-ssl']} ]]; then
2301 2309 # set default
2302 2310 args['--arg-use-ssl']="n"
2303 2311 else
2304 2312 # mark we used flag and don't ask in prompts
2305 2313 args['__arg_use_ssl']=1
2306 2314 fi
2307 2315
2308 2316 if [[ -z ${args['--arg-admin-email']} ]]; then
2309 2317 # set default
2310 2318 args['--arg-admin-email']="admin@${args['--arg-hostname']}"
2311 2319 else
2312 2320 # mark we used flag and don't ask in prompts
2313 2321 args['__arg_admin_email']=1
2314 2322 fi
2315 2323
2316 2324 if [[ -z ${args['--arg-admin-user']} ]]; then
2317 2325 # set default
2318 2326 args['--arg-admin-user']="admin"
2319 2327 else
2320 2328 # mark we used flag and don't ask in prompts
2321 2329 args['__arg_admin_user']=1
2322 2330 fi
2323 2331
2324 2332 if [[ -z ${args['--arg-admin-pass']} ]]; then
2325 2333 # set default
2326 2334 args['--arg-admin-pass']="secret4"
2327 2335 else
2328 2336 # mark we used flag and don't ask in prompts
2329 2337 args['__arg_admin_pass']=1
2330 2338 fi
2331 2339
2332 2340 if [[ -z ${args['--arg-license-token']} ]]; then
2333 2341 # set default
2334 2342 args['--arg-license-token']="$(random_str 4)"-"$(random_str 4)"-"$(random_str 4)"-"$(random_str 4)"
2335 2343 else
2336 2344 # mark we used flag and don't ask in prompts
2337 2345 args['__arg_license_token']=1
2338 2346 fi
2339 2347
2340 2348 if [[ -z ${args['--arg-log-formatter']} ]]; then
2341 2349 # set default
2342 2350 args['--arg-log-formatter']="json"
2343 2351 else
2344 2352 # mark we used flag and don't ask in prompts
2345 2353 args['__arg_log_formatter']=1
2346 2354 fi
2347 2355
2348 2356 arg_rc_edition=${args[--arg-rc-edition]}
2357 arg_accept_eula=${args[--arg-accept-eula]}
2349 2358 arg_hostname=${args[--arg-hostname]}
2350 2359 arg_use_ssl=${args[--arg-use-ssl]}
2351 2360 arg_admin_email=${args[--arg-admin-email]}
2352 2361 arg_admin_user=${args[--arg-admin-user]}
2353 2362 arg_admin_pass=${args[--arg-admin-pass]}
2354 2363 arg_license_token=${args[--arg-license-token]}
2355 2364 arg_log_formatter=${args[--arg-log-formatter]}
2356 2365
2357 2366 ask_user_for_config() {
2358 2367 local config_done="n"
2359 2368
2360 2369 echo "Starting interactive setup..."
2361 2370 echo ""
2362 2371
2363 2372 while [[ "$config_done" == "n" ]]
2364 2373 # config loop start
2365 2374 do
2366 2375 # edition to install
2367 2376 if [ ! -z "$arg_rc_edition" ] && [ -z ${args['__arg_rc_edition']} ]
2368 2377 then
2369 2378 read -p "Select 'ee' to use Enterprise edition or type 'ce' to use Community free edition: rhodecode-[$arg_rc_edition]: " new_value
2370 2379 if [ ! -z "$new_value" ]
2371 2380 then
2372 2381 arg_rc_edition="$new_value"
2373 2382 fi
2374 2383 fi
2375 2384
2385 if [ ! -z "$arg_accept_eula" ] && [ -z ${args['__arg_accept_eula']} ]
2386 then
2387 if [[ $arg_rc_edition == "ee" ]]; then
2388 #EE EULA
2389 read -p "Do you accept RhodeCode EULA (see: https://docs.rhodecode.com/rcstack/eula/ee.txt) accept: 'yes' deny: 'no' ? [$arg_accept_eula]: " new_value
2390 else
2391 #CE EULA
2392 read -p "Do you accept RhodeCode EULA (see: https://docs.rhodecode.com/rcstack/eula/ce.txt) accept: 'yes' deny: 'no' ? [$arg_accept_eula]: " new_value
2393 fi
2394
2395 if [ ! -z "$new_value" ]
2396 then
2397 arg_accept_eula="$new_value"
2398 fi
2399
2400 if [[ $arg_accept_eula != "yes" ]]; then
2401 echo "$(red please accept EULA by typing yes, no installation is possible without accepted EULA)"
2402 exit
2403 fi
2404 fi
2405
2376 2406 # ask for license-token IF edition is ee
2377 2407 if [[ $arg_rc_edition == "ee" ]]; then
2378 2408 if [ ! -z "$arg_license_token" ] && [ -z ${args['__arg_license_token']} ]
2379 2409 then
2380 2410 read -p "enter a valid license-token or use pre-generated one [$arg_license_token]: " new_value
2381 2411 if [ ! -z "$new_value" ]
2382 2412 then
2383 2413 arg_license_token="$new_value"
2384 2414 fi
2385 2415 fi
2386 2416 fi
2387 2417
2388 2418 # hostname
2389 2419 if [ ! -z "$arg_hostname" ] && [ -z ${args['__arg_hostname']} ]
2390 2420 then
2391 2421 read -p "Enter a valid hostname for RhodeCode Stack? [$arg_hostname]: " new_value
2392 2422 if [ ! -z "$new_value" ]
2393 2423 then
2394 2424 arg_hostname="$new_value"
2395 2425 fi
2396 2426 if [[ $arg_hostname =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]
2397 2427 then
2398 2428 echo
2399 2429 echo "$(red IP addresses are unsupported and will not work. Please provide a DNS hostname)"
2400 2430 echo
2401 2431 arg_hostname="rc-docker.local"
2402 2432 fi
2403 2433 fi
2404 2434
2405 2435 # use SSL
2406 2436 if [ ! -z "$arg_use_ssl" ] && [ -z ${args['__arg_use_ssl']} ]
2407 2437 then
2408 2438 read -p "Do you want to enable SSL/HTTPS now (can be changed later) 'y' for yes 'n' for no? [$arg_use_ssl]: " new_value
2409 2439 if [ ! -z "$new_value" ]
2410 2440 then
2411 2441 arg_use_ssl="$new_value"
2412 2442 fi
2413 2443 fi
2414 2444
2415 2445 # admin email
2416 2446 if [ ! -z "$arg_admin_email" ] && [ -z ${args['__arg_admin_email']} ]
2417 2447 then
2418 2448 read -p "Enter first super-admin email? [$arg_admin_email]: " new_value
2419 2449 if [ ! -z "$new_value" ]
2420 2450 then
2421 2451 arg_admin_email="$new_value"
2422 2452 fi
2423 2453 fi
2424 2454
2425 2455 # admin user
2426 2456 if [ ! -z "$arg_admin_user" ] && [ -z ${args['__arg_admin_user']} ]
2427 2457 then
2428 2458 read -p "Enter first super-admin account name? [$arg_admin_user]: " new_value
2429 2459 if [ ! -z "$new_value" ]
2430 2460 then
2431 2461 arg_admin_user="$new_value"
2432 2462 fi
2433 2463 fi
2434 2464
2435 2465 # admin password
2436 2466 if [ ! -z "$arg_admin_pass" ] && [ -z ${args['__arg_admin_pass']} ]
2437 2467 then
2438 2468 read -p "Enter first super-admin account password? [$arg_admin_pass]: " new_value
2439 2469 if [ ! -z "$new_value" ]
2440 2470 then
2441 2471 arg_admin_pass="$new_value"
2442 2472 fi
2443 2473 fi
2444 2474
2445 2475 echo -e "\nDoes this look right?\n"
2446 2476 echo "RhodeCode Edition : rhodecode-$arg_rc_edition"
2447 2477 echo "License Token : $arg_license_token"
2448 2478 echo "Hostname : $arg_hostname"
2449 2479 echo "Use SSL : $arg_use_ssl"
2450 2480 echo "Email : $arg_admin_email"
2451 2481 echo "Admin user : $arg_admin_user"
2452 2482 echo "Admin password : $arg_admin_pass"
2453 2483 echo ""
2454 2484 read -p "ENTER to continue, 'n' to try again, Ctrl+C to exit: " config_done
2455 2485
2456 2486 # config loop end
2457 2487 done
2458 2488
2459 2489 }
2460 2490
2461 2491 check_docker() {
2462 2492 (which docker || which docker.io) &>/dev/null
2463 2493 }
2464 2494
2465 2495 bootstrap_docker_install() {
2466 2496 # systemctl enable docker on debian
2467 2497 echo "bootstrap_docker_install: trying to check and configure docker"
2468 2498 failMsg="Failed to find docker on your PATH"
2469 2499
2470 2500 if ! check_docker; then
2471 2501
2472 2502 if [[ $install_docker == "n" ]]; then
2473 2503 echo "$(red $failMsg, exiting without docker install)"
2474 2504 fi
2475 2505
2476 2506 echo "$(yellow $failMsg, trying docker install)"
2477 2507
2478 2508 if [[ $install_docker == "y" ]]; then
2479 2509 echo "continuing with automated docker installation from https://get.docker.com/ "
2480 2510 else
2481 2511 read -p "Enter to install Docker directly from https://get.docker.com/ or Ctrl+C to exit and install it manually"
2482 2512 fi
2483 2513
2484 2514 curl -fsSL https://get.docker.com -o install-docker.sh
2485 2515 sh install-docker.sh
2486 2516 rm install-docker.sh
2487 2517
2488 2518 if ! check_docker; then
2489 2519 echo "$failMsg"
2490 2520 echo "Docker install failed. Quitting."
2491 2521 exit 1
2492 2522 fi
2493 2523
2494 2524 docker --version
2495 2525
2496 2526 fi
2497 2527 }
2498 2528
2499 2529 bootstrap_docker_commons() {
2500 2530
2501 2531 echo 'bootstrap_docker_commons: running docker commands.'
2502 2532
2503 2533 echo "bootstrap_docker_commons: creating volume 'rc_datavolume'"
2504 2534 docker volume create --label keep=1 --name=rc_datavolume
2505 2535 echo "bootstrap_docker_commons (rc_datavolume): done"
2506 2536 echo ""
2507 2537
2508 2538 echo "bootstrap_docker_commons: creating volume 'rc_reposvolume'"
2509 2539 docker volume create --label keep=1 --name=rc_reposvolume
2510 2540 echo "bootstrap_docker_commons (rc_reposvolume): done"
2511 2541 echo ""
2512 2542
2513 2543 echo "bootstrap_docker_commons: creating network 'rhodecode_network'"
2514 2544 docker network inspect rhodecode_network >/dev/null 2>&1 || docker network create rhodecode_network
2515 2545 echo "bootstrap_docker_commons (rhodecode_network): done"
2516 2546 echo ""
2517 2547
2518 2548 echo "bootstrap_docker_commons: creating loki logging"
2519 2549 loki_driver=$(docker plugin ls --format {{.Name}} --filter enabled=true | grep loki || echo "")
2520 2550 if [[ $loki_driver == "" ]]; then
2521 2551 docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
2522 2552 else
2523 2553 echo "bootstrap_docker_commons: loki driver already exists"
2524 2554 fi
2525 2555 }
2526 2556
2527 2557 config_init() {
2528 2558 loc_config_file=${CONFIG_FILE:=config.ini}
2529 2559 [[ -f "$loc_config_file" ]] || touch "$loc_config_file"
2530 2560 }
2531 2561
2532 2562 bootstrap_config() {
2533 2563 shared_key=$(random_str 32)
2534 2564 shared_key_md5=$(generate_md5 $shared_key | head -c 32)
2535 2565 db_key=$(random_str 32)
2536 2566
2537 2567 if [[ ! $no_prompt ]]; then
2538 2568 ask_user_for_config
2539 2569 fi
2540 2570
2541 2571 # setup args
2542 2572 license_token=$arg_license_token
2543 2573 log_formatter=$arg_log_formatter
2544 2574 base_domain=$arg_hostname
2545 2575 rc_edition=$arg_rc_edition
2546 2576
2547 2577 is_https=0
2548 2578 if [[ $arg_use_ssl == "y" ]]; then is_https=1; fi
2549 2579
2550 2580 DB_USER='rhodecode'
2551 2581 DB_NAME='rhodecode'
2552 2582
2553 2583 if [[ ! -f "$CONFIG_FILE" ]]; then
2554 2584 echo "init new config at: $CONFIG_FILE"
2555 2585 config_init
2556 2586 else
2557 2587 echo "re-using existing config at: $CONFIG_FILE"
2558 2588 fi
2559 2589
2560 2590 CUSTOM_DIR_PATH=$PWD/.custom
2561 2591 mkdir -p "$CUSTOM_DIR_PATH"
2562 2592 BOOTSTRAP_TMPL=$PWD/templates/runtime.env.tmpl
2563 2593 BOOTSTRAP_RUNTIME_ENV=$PWD/.custom/.runtime.env
2564 2594
2565 2595 # TODO: Pick version
2566 2596 ver=0_edge
2567 2597 INI_TARGET=$PWD/config/_shared
2568 2598 RHODECODE_INI_TMPL=$PWD/templates/ini/$ver/rhodecode.ini
2569 2599 VCSSERVER_INI_TMPL=$PWD/templates/ini/$ver/vcsserver.ini
2570 2600
2571 2601 if [[ ! -f "$BOOTSTRAP_RUNTIME_ENV" ]]; then
2572 2602 echo "bootstrap_config: init runtime env config at: $BOOTSTRAP_RUNTIME_ENV"
2573 2603
2574 2604 # Make runtime file
2575 2605 echo "## BOOTSTRAP GENERATED $(date) ##" >> $BOOTSTRAP_RUNTIME_ENV
2576 2606 echo "" >> $BOOTSTRAP_RUNTIME_ENV
2577 2607
2578 2608 cat $BOOTSTRAP_TMPL >> $BOOTSTRAP_RUNTIME_ENV
2579 2609
2580 2610 # Make .ini files
2581 2611 cp -v $RHODECODE_INI_TMPL $INI_TARGET
2582 2612 cp -v $VCSSERVER_INI_TMPL $INI_TARGET
2583 2613
2584 2614 # init env generator with env file
2585 2615 .env --file "$BOOTSTRAP_RUNTIME_ENV"
2586 2616
2587 2617 .env set RC_EDITION=$rc_edition
2588 2618 .env set DB_PASSWORD=$db_key
2589 2619
2590 2620 .env set RHODECODE_USER_EMAIL=$arg_admin_email
2591 2621 .env set RHODECODE_USER_NAME=$arg_admin_user
2592 2622 .env set RHODECODE_USER_PASS=$arg_admin_pass
2593 2623
2594 2624 .env set RC_ENCRYPTED_SECRET=$shared_key
2595 2625
2596 2626 rc_db1="postgresql://$DB_USER:$db_key@database/$DB_NAME"
2597 2627 .env set RC_DB_URL="$rc_db1"
2598 2628 .env set RC_SQLALCHEMY_DB1_URL="$rc_db1"
2599 2629
2600 2630 .env set RC_LICENSE_TOKEN=$license_token
2601 2631 .env set RC_HOSTNAME=$base_domain
2602 2632
2603 2633 if [[ $is_https == 1 ]]; then
2604 2634 app_base_url=https://$base_domain
2605 2635 else
2606 2636 app_base_url=http://$base_domain
2607 2637 fi
2608 2638
2609 2639 .env set RC_APP_BASE_URL=$app_base_url
2610 2640
2611 2641 .env set RC_LOKI_AUTH=loki-auth:$shared_key@
2612 2642
2613 2643 .env puts '# Log formatter option'
2614 2644 .env set RC_LOGGING_FORMATTER=$log_formatter
2615 2645 .env set RC_USE_CELERY=true
2616 2646
2617 2647 .env puts '# Channelstream config'
2618 2648 .env set RC_CHANNELSTREAM_SERVER=channelstream:8000
2619 2649
2620 2650 if [[ $is_https == 1 ]]; then
2621 2651 rc_channelstream_url="wss://$base_domain/_channelstream"
2622 2652 else
2623 2653 rc_channelstream_url="ws://$base_domain/_channelstream"
2624 2654 fi
2625 2655
2626 2656 .env set RC_CHANNELSTREAM_WS_URL=$rc_channelstream_url
2627 2657
2628 2658 .env set CHANNELSTREAM_ALLOW_POSTING_FROM=0.0.0.0
2629 2659
2630 2660 .env puts '# Channelstream secrets'
2631 2661 .env set CHANNELSTREAM_SECRET=$shared_key
2632 2662 .env set RC_CHANNELSTREAM_SECRET=$shared_key
2633 2663
2634 2664 .env puts '# Channelstream admin'
2635 2665 .env set CHANNELSTREAM_ADMIN_SECRET=$shared_key
2636 2666 .env set RC_CHANNELSTREAM_ADMIN_SECRET=$shared_key
2637 2667
2638 2668 ini_path=$INI_TARGET/vcsserver.ini
2639 2669 config_vcsserver_ini
2640 2670
2641 2671 ini_path=$INI_TARGET/rhodecode.ini
2642 2672 RC_EDITION=$rc_edition
2643 2673 RC_LICENSE_TOKEN=$license_token
2644 2674 RC_HOSTNAME=$(sed_safe_path $base_domain)
2645 2675 RC_APP_BASE_URL=$(sed_safe_path $app_base_url)
2646 2676 RC_SQLALCHEMY_DB1_URL=$(sed_safe_path $rc_db1)
2647 2677 RC_CHANNELSTREAM_WS_URL=$(sed_safe_path $rc_channelstream_url)
2648 2678
2649 2679 config_rhodecode_ini
2650 2680
2651 2681 touch $BOOTSTRAP_RUNTIME_ENV
2652 2682 else
2653 2683 echo "bootstrap_config: $BOOTSTRAP_RUNTIME_ENV file exists, not adding any configuration..."
2654 2684 fi
2655 2685 }
2656 2686
2657 2687 bootstrap_definitions() {
2658 2688
2659 2689 AUTH_TOKEN=${args[--auth-token]}
2660 2690 SERVER_URL=${args[--server-url]}
2661 2691
2662 2692 DEFINITIONS_EXIST=""
2663 2693 CHECK_FILES="\
2664 2694 docker-compose-services.yaml \
2665 2695 docker-compose-apps.yaml \
2666 2696 docker-compose-metrics.yaml \
2667 2697 docker-compose-router.yaml \
2668 2698 "
2669 2699 for check_file in $CHECK_FILES; do
2670 2700 if [[ -f "$check_file" ]]; then
2671 2701 DEFINITIONS_EXIST="1"
2672 2702 fi
2673 2703 done
2674 2704
2675 2705 if [[ -n $DEFINITIONS_EXIST && ! $force ]]; then
2676 2706 echo "$(yellow bootstrap_definitions: skipping docker defs creation, existing files found. Use --force to create them anyway)"
2677 2707 return
2678 2708 fi
2679 2709
2680 2710 if [[ -n $DEFINITIONS_EXIST ]]; then
2681 2711 echo "$(yellow docker definitions exists, are you sure to force re-create them?)"
2682 2712 while true; do
2683 2713 read -p "Would you like to continue with overriding file? [yn] " yn
2684 2714 case $yn in
2685 2715 [Yy]*) break ;;
2686 2716 [Nn]*) exit ;;
2687 2717 *) echo "Please answer y or n." ;;
2688 2718 esac
2689 2719 done
2690 2720 fi
2691 2721 FULL_MODE=1
2692 2722 get_docker_definitions $docker_revision $FULL_MODE $DEBUG
2693 2723
2694 2724 }
2695 2725
2696 2726 bootstrap_overrides() {
2697 2727 templates=$YAML_TEMPLATES
2698 2728
2699 2729 target_dir=$PWD/.custom
2700 2730
2701 2731 for o_file in $templates; do
2702 2732 target_file=$target_dir/$o_file
2703 2733 if [[ ! -f "$target_file" ]]; then
2704 2734 echo "copy override file $o_file"
2705 2735 cp -v $PWD/templates/$o_file $target_file
2706 2736 else
2707 2737 echo "file $target_file existing, skipping..."
2708 2738 fi
2709 2739 done
2710 2740 mkdir -p $target_dir/traefik_custom
2711 2741 cp -r $PWD/config/traefik/* $target_dir/traefik_custom/
2712 2742
2713 2743 echo "$(green bootstrap_overrides: overrides extracted to $target_dir)"
2714 2744
2715 2745 # save our loki auth using md5 encryption so the auth works OOTB
2716 2746 echo "loki-auth:$shared_key_md5" >> $target_dir/traefik_custom/dynamic/.htpasswd
2717 2747
2718 2748 # change our templates and adjust using enable SSH
2719 2749 if [[ $arg_use_ssl == "y" ]]; then
2720 2750 echo "enabling SSL on .override.yaml templates"
2721 2751
2722 2752 metrics_replace() {
2723 2753 metrics_tmpl=$target_dir/docker-compose-metrics.override.yaml
2724 2754 sed --in-place=.replaced -E "s/$1/$2/" $metrics_tmpl
2725 2755 }
2726 2756
2727 2757 metrics_replace '# # Enable http\+https' ' # Enable http\+https'
2728 2758 metrics_replace '# - "traefik.http.routers.grafana.entrypoints=http,https"' ' - "traefik.http.routers.grafana.entrypoints=http,https"'
2729 2759
2730 2760 apps_replace() {
2731 2761 apps_tmpl=$target_dir/docker-compose-apps.override.yaml
2732 2762 sed --in-place=.replaced -E "s/$1/$2/" $apps_tmpl
2733 2763 }
2734 2764
2735 2765 apps_replace '# # Enable http\+https' ' # Enable http\+https'
2736 2766 apps_replace '# - "traefik.http.routers.rhodecode.entrypoints=http,https"' ' - "traefik.http.routers.rhodecode.entrypoints=http,https"'
2737 2767
2738 2768 fi
2739 2769 }
2740 2770
2741 2771 cur_date=$(date '+%Y-%m-%d %H:%M:%S')
2742 2772
2743 2773 # Init the config !
2744 2774 if [[ ! -f "$CONFIG_FILE" ]]; then
2745 2775 echo "config: init new config at: $CONFIG_FILE"
2746 2776 config_init
2747 2777 else
2748 2778 echo "config: re-using present config at: $CONFIG_FILE"
2749 2779 fi
2750 2780
2751 2781 run_stages=$BOOTSTRAP_STAGES
2752 2782
2753 2783 if [ ! ${#stages_from_cli[@]} -eq 0 ]; then
2754 2784 echo "Using custom stages to run init command..."
2755 2785 run_stages=${stages_from_cli[@]}
2756 2786 fi
2757 2787
2758 2788 for stage_name in $run_stages; do
2759 2789
2760 2790 stage_func=$(get_stage_function $stage_name)
2761 2791
2762 2792 if ! config_has_key $stage_name ; then
2763 2793 echo "$(green \* bootstrap: \'$stage_name\' stage not found\; running now... )"
2764 2794 $stage_func
2765 2795 config_set "$stage_name" $cur_date
2766 2796 else
2767 2797 if [ $force ]; then
2768 2798 echo "$(green \* bootstrap: \'$stage_name\' is present!\; FORCE running now... )"
2769 2799 $stage_func $force
2770 2800 config_set "$stage_name" $cur_date
2771 2801 else
2772 2802 echo "$(yellow \* bootstrap: \'$stage_name\' stage already present, use --force to run it again)"
2773 2803 fi
2774 2804 fi
2775 2805
2776 2806 done
2777 2807
2778 2808 echo ""
2779 2809 echo "~~~~ $(green Bootstrap completed) ~~~~"
2780 2810
2781 2811 get_started
2782 2812
2783 2813 }
2784 2814
2785 2815 # :command.function
2786 2816 rcstack_self_update_command() {
2787 2817 # src/self_update_command.sh
2788 2818 check_bootstrap
2789 2819
2790 2820 DEBUG=${args[--debug]}
2791 2821 AUTH_TOKEN=${args[--auth-token]}
2792 2822 SERVER_URL=${args[--server-url]}
2793 2823 FORCE=${args[--force]}
2794 2824
2795 2825 cli_revision=${args[--cli-revision]}
2796 2826 docker_revision=${args[--docker-revision]}
2797 2827
2798 2828 FETCH_FROM=$SERVER_URL/rhodecode-enterprise-docker/raw/$cli_revision/scripts/rcstack/rcstack
2799 2829
2800 2830 FINAL_TARGET=$PWD/scripts/rcstack/rcstack
2801 2831
2802 2832 DL_TARGET=$PWD/scripts/rcstack/rcstack.tmp
2803 2833
2804 2834 #ensure we have this dir !
2805 2835 mkdir -p $PWD/scripts/rcstack
2806 2836
2807 2837 .env --file $RUNTIME_ENV
2808 2838 .env get RC_VERSION
2809 2839
2810 2840 ENV_VER=$REPLY
2811 2841
2812 2842 echo "self-update: downloading new $RC_SCRIPT_NAME script from $FETCH_FROM"
2813 2843
2814 2844 if [[ $FORCE ]]; then
2815 2845 echo "$(yellow self-update: --force used, doing forced update)"
2816 2846 fi
2817 2847
2818 2848 if [[ $DEBUG ]]; then
2819 2849 echo "running: curl -ss --fail --header \"X-Rc-Auth-Token: $AUTH_TOKEN\" -o $DL_TARGET -L $FETCH_FROM"
2820 2850 fi
2821 2851
2822 2852 curl -L -ss --fail --header "X-Rc-Auth-Token: $AUTH_TOKEN" -o $DL_TARGET $FETCH_FROM
2823 2853
2824 2854 chmod +x $DL_TARGET
2825 2855
2826 2856 version_old=0
2827 2857 rc_version_old=0
2828 2858
2829 2859 # check if we have OLD file, in case we don't just set versions to 0
2830 2860 if [[ -f "$FINAL_TARGET" ]]; then
2831 2861 version_old=$($FINAL_TARGET --version)
2832 2862 rc_version_old=$($FINAL_TARGET cli image-info)
2833 2863 fi
2834 2864
2835 2865 version_dl=$($DL_TARGET --version)
2836 2866 rc_version_dl=$($DL_TARGET cli image-info)
2837 2867
2838 2868 echo "self-update: $RC_SCRIPT_NAME version downloaded: $version_dl"
2839 2869
2840 2870 if [[ $DEBUG ]]; then
2841 2871 echo "DEBUG: old-script ver: $version_old"
2842 2872 echo "DEBUG: new-script ver: $version_dl"
2843 2873 echo "DEBUG: "
2844 2874 echo "DEBUG: .runtime.env set version $ENV_VER"
2845 2875 echo "DEBUG: "
2846 2876 echo "DEBUG: old-script: RC VERSION: $rc_version_old"
2847 2877 echo "DEBUG: new-script: RC VERSION: $rc_version_dl"
2848 2878 fi
2849 2879
2850 2880 if [[ $version_old == "$version_dl" ]]; then
2851 2881
2852 2882 if [[ $FORCE ]]; then
2853 2883 echo "$(yellow self-update: downloaded version is the same as current version $version_dl, continue with --force...)"
2854 2884 else
2855 2885 echo "self-update: downloaded version is the same as current version $version_dl, exiting..."
2856 2886 exit
2857 2887 fi
2858 2888
2859 2889 fi
2860 2890
2861 2891 docker_image_update() {
2862 2892
2863 2893 echo "$(green self-update: saving new RC_VERSION=$rc_version_dl to runtime.env file)"
2864 2894
2865 2895 echo "currently .runtime.env file uses image: $ENV_VER"
2866 2896 while true; do
2867 2897 read -p "self-update: Would you like to continue with setting RC_VERSION=$rc_version_dl into .runtime.env file? [yn] " yn
2868 2898 case $yn in
2869 2899 [Yy]*)
2870 2900 .env set RC_VERSION=$rc_version_dl
2871 2901 echo "self-update: new version set into config"
2872 2902 break ;;
2873 2903 [Nn]*)
2874 2904 break ;;
2875 2905 *) echo "Please answer y or n." ;;
2876 2906 esac
2877 2907 done
2878 2908 }
2879 2909
2880 2910 if [[ $rc_version_old == "$rc_version_dl" ]]; then
2881 2911 echo "self-update: docker image defined by RC_VERSION=$rc_version_dl seems to be up-to date"
2882 2912
2883 2913 if [[ $FORCE ]]; then
2884 2914 echo "$(yellow self-update: continue with --force...)"
2885 2915 docker_image_update
2886 2916 fi
2887 2917
2888 2918 else
2889 2919 docker_image_update
2890 2920 fi
2891 2921
2892 2922 echo "self-update: updating cli $RC_SCRIPT_NAME script to new version: $version_dl"
2893 2923
2894 2924 if [[ -f "$FINAL_TARGET" ]]; then
2895 2925 rm $FINAL_TARGET && mv -v $DL_TARGET $FINAL_TARGET
2896 2926 else
2897 2927 mv -v $DL_TARGET $FINAL_TARGET
2898 2928 fi
2899 2929
2900 2930 echo "$(green self-update: updating docker definitions to $docker_revision)"
2901 2931
2902 2932 FULL_MODE=1
2903 2933 get_docker_definitions $docker_revision $FULL_MODE $DEBUG
2904 2934
2905 2935 echo "$(green self-update: successfully update to $version_dl)"
2906 2936 exit
2907 2937 }
2908 2938
2909 2939 # :command.function
2910 2940 rcstack_stack_router_command() {
2911 2941 # src/stack_router_command.sh
2912 2942 check_bootstrap
2913 2943
2914 2944 DEBUG=${args[--debug]}
2915 2945 ENV_FILE=${args[--env-file-path]}
2916 2946
2917 2947 if [[ ! -f $RC_STACK_ROUTER_EXT ]]; then
2918 2948 RC_STACK_ROUTER_EXT=""
2919 2949 else
2920 2950 RC_STACK_ROUTER_EXT="-f $RC_STACK_ROUTER_EXT"
2921 2951 fi
2922 2952
2923 2953 CMD_ROUTER="\
2924 2954 RC_ENV_FILE=$ENV_FILE docker compose \
2925 2955 --env-file $ENV_FILE \
2926 2956 $ENV_EXPAND \
2927 2957 -p rc_cluster_router \
2928 2958 -f docker-compose-base.yaml \
2929 2959 -f docker-compose-router.yaml $RC_STACK_ROUTER_EXT"
2930 2960
2931 2961 if [[ $DEBUG ]]; then
2932 2962 echo "---"
2933 2963 echo "stacks docker: $RC_STACK_ROUTER_EXT_LCL"
2934 2964 echo "running command: ${CMD_ROUTER}"
2935 2965 echo "ARGS: ${other_args[*]}"
2936 2966 echo "---"
2937 2967 fi
2938 2968 eval "${CMD_ROUTER} ${other_args[*]}"
2939 2969
2940 2970 }
2941 2971
2942 2972 # :command.function
2943 2973 rcstack_stack_metrics_command() {
2944 2974 # src/stack_metrics_command.sh
2945 2975 check_bootstrap
2946 2976
2947 2977 DEBUG=${args[--debug]}
2948 2978 ENV_FILE=${args[--env-file-path]}
2949 2979
2950 2980 if [[ ! -f $RC_STACK_METRICS_EXT ]]; then
2951 2981 RC_STACK_METRICS_EXT_LCL=""
2952 2982 else
2953 2983 RC_STACK_METRICS_EXT_LCL="-f $RC_STACK_METRICS_EXT"
2954 2984 fi
2955 2985
2956 2986 CMD_METRICS="\
2957 2987 RC_ENV_FILE=$ENV_FILE docker compose \
2958 2988 --env-file $ENV_FILE \
2959 2989 $ENV_EXPAND \
2960 2990 -p rc_cluster_metrics \
2961 2991 -f docker-compose-base.yaml \
2962 2992 -f docker-compose-metrics.yaml $RC_STACK_METRICS_EXT_LCL"
2963 2993
2964 2994 if [[ $DEBUG ]]; then
2965 2995 echo "---"
2966 2996 echo "stacks docker: $RC_STACK_METRICS_EXT_LCL"
2967 2997 echo "running command: ${CMD_METRICS}"
2968 2998 echo "ARGS: ${other_args[*]}"
2969 2999 echo "---"
2970 3000 fi
2971 3001 eval "${CMD_METRICS} ${other_args[*]}"
2972 3002 }
2973 3003
2974 3004 # :command.function
2975 3005 rcstack_stack_services_command() {
2976 3006 # src/stack_services_command.sh
2977 3007 check_bootstrap
2978 3008
2979 3009 DEBUG=${args[--debug]}
2980 3010 ENV_FILE=${args[--env-file-path]}
2981 3011
2982 3012 if [[ ! -f $RC_STACK_SERVICES_EXT ]]; then
2983 3013 RC_STACK_SERVICES_EXT_LCL=""
2984 3014 else
2985 3015 RC_STACK_SERVICES_EXT_LCL="-f $RC_STACK_SERVICES_EXT"
2986 3016 fi
2987 3017
2988 3018 RC_STACK_PROFILES="--profile database --profile redis --profile elasticsearch --profile channelstream"
2989 3019
2990 3020 CMD_SERVICES="\
2991 3021 RC_ENV_FILE=$ENV_FILE docker compose \
2992 3022 --env-file $ENV_FILE \
2993 3023 $ENV_EXPAND \
2994 3024 $RC_STACK_PROFILES \
2995 3025 -p rc_cluster_services \
2996 3026 -f docker-compose-base.yaml \
2997 3027 -f docker-compose-services.yaml $RC_STACK_SERVICES_EXT_LCL"
2998 3028
2999 3029 if [[ $DEBUG ]]; then
3000 3030 echo "---"
3001 3031 echo "stacks docker: $RC_STACK_SERVICES_EXT_LCL"
3002 3032 echo "running command: ${CMD_SERVICES}"
3003 3033 echo "ARGS: ${other_args[*]}"
3004 3034 echo "---"
3005 3035 fi
3006 3036
3007 3037 eval "${CMD_SERVICES} ${other_args[*]}"
3008 3038 }
3009 3039
3010 3040 # :command.function
3011 3041 rcstack_stack_rhodecode_command() {
3012 3042 # src/stack_rhodecode_command.sh
3013 3043 check_bootstrap
3014 3044
3015 3045 DEBUG=${args[--debug]}
3016 3046 ENV_FILE=${args[--env-file-path]}
3017 3047
3018 3048 stack_prefix=${args[--stack-prefix]}
3019 3049 if [[ $stack_prefix == "" ]]; then
3020 3050 stack_prefix="rc_cluster_apps"
3021 3051 fi
3022 3052
3023 3053 if [[ ! -f $RC_STACK_RHODECODE_EXT ]]; then
3024 3054 RC_STACK_RHODECODE_EXT_LCL=""
3025 3055 else
3026 3056 RC_STACK_RHODECODE_EXT_LCL="-f $RC_STACK_RHODECODE_EXT"
3027 3057 fi
3028 3058
3029 3059 CMD_RHODECODE="\
3030 3060 RC_ENV_FILE=$ENV_FILE docker compose \
3031 3061 --env-file $ENV_FILE \
3032 3062 $ENV_EXPAND \
3033 3063 -p $stack_prefix \
3034 3064 -f docker-compose-base.yaml \
3035 3065 -f docker-compose-apps.yaml $RC_STACK_RHODECODE_EXT_LCL"
3036 3066
3037 3067 CMD_RHODECODE_SOURCE="\
3038 3068 RC_ENV_FILE=$ENV_FILE docker compose \
3039 3069 --env-file $ENV_FILE \
3040 3070 $ENV_EXPAND \
3041 3071 -p $stack_prefix \
3042 3072 -f docker-compose-base.yaml \
3043 3073 -f docker-compose-apps.yaml \
3044 3074 -f docker-compose-apps.source.yaml $RC_STACK_RHODECODE_EXT_LCL"
3045 3075
3046 3076 sub_cmd=${other_args[0]}
3047 3077
3048 3078 if [[ $sub_cmd == "up" ]]; then
3049 3079 declare -a final_args=( "$sub_cmd" "--no-color" "--no-build" "${other_args[@]:1}" )
3050 3080 else
3051 3081 declare -a final_args=( "$sub_cmd" "${other_args[@]:1}" )
3052 3082 fi
3053 3083
3054 3084 if [[ $DEBUG ]]; then
3055 3085 echo "---"
3056 3086 echo "stacks docker: $RC_STACK_RHODECODE_EXT_LCL"
3057 3087 echo "running command: ${CMD_RHODECODE}"
3058 3088 echo "ARGS: ${final_args[*]}"
3059 3089 echo "---"
3060 3090 fi
3061 3091 eval "${CMD_RHODECODE} ${final_args[*]}"
3062 3092
3063 3093 }
3064 3094
3065 3095 # :command.function
3066 3096 rcstack_stack_all_command() {
3067 3097 # src/stack_all_command.sh
3068 3098 check_bootstrap
3069 3099
3070 3100 DEBUG=${args[--debug]}
3071 3101
3072 3102 stack_lst=$VALID_SERVICES
3073 3103
3074 3104 for stack in $stack_lst; do
3075 3105 ./$RC_SCRIPT_NAME stack $stack ${other_args[*]}
3076 3106 done
3077 3107
3078 3108 }
3079 3109
3080 3110 # :command.function
3081 3111 rcstack_stack_status_command() {
3082 3112 # src/stack_status_command.sh
3083 3113 check_bootstrap
3084 3114 DEBUG=${args[--debug]}
3085 3115 DETAILED=${args[--detailed]}
3086 3116 CONFIGS=${args[--configs]}
3087 3117
3088 3118 .env --file $RUNTIME_ENV
3089 3119 .env get RC_APP_BASE_URL
3090 3120 RC_APP_BASE_URL=$REPLY
3091 3121
3092 3122 if [[ $DEBUG ]]; then
3093 3123 echo "---"
3094 3124 ps_cmd=$(docker ps --filter=name=rc_cluster --format="{{.ID}}")
3095 3125
3096 3126 for service in $ps_cmd; do
3097 3127
3098 3128 servicename=`docker inspect --format '{{ .Name }}' $service`
3099 3129 servicename=${servicename:1}
3100 3130 echo $servicename
3101 3131 docker inspect $service --format='{{.State.Status}}: {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'
3102 3132 echo ""
3103 3133
3104 3134 done
3105 3135 echo "---"
3106 3136 fi
3107 3137
3108 3138 echo "Running hostname: $RC_APP_BASE_URL"
3109 3139
3110 3140 if [[ $CONFIGS ]]; then
3111 3141 printf "RhodeCode:\n"
3112 3142 printf " ini (in-host): $rhodecode_default_config_path\n"
3113 3143 printf " volumes (in-container):\n"
3114 3144 printf " repo-store: /var/opt/rhodecode_repo_store\n"
3115 3145 printf " data-store: /var/opt/rhodecode_data\n"
3116 3146
3117 3147 printf "VCSServer:\n"
3118 3148 printf " ini (in-host): $vcsserver_default_config_path\n"
3119 3149 printf " volumes (in-container):\n"
3120 3150 printf " repo-store: /var/opt/rhodecode_repo_store\n"
3121 3151 printf " data-store: /var/opt/rhodecode_data\n"
3122 3152
3123 3153 printf "Traefik (router):\n"
3124 3154 printf " ssl-certs definitions: .custom/traefik_custom/dynamic/traefik_dynamic_custom.yaml\n"
3125 3155 printf " ssl-certs dir: .custom/traefik_custom/dynamic/certs/\n"
3126 3156
3127 3157 fi
3128 3158
3129 3159 if [[ $DETAILED ]]; then
3130 3160 ps_cmd=$(docker ps --filter=name=rc_cluster --format="{{.ID}}")
3131 3161
3132 3162 for service in $ps_cmd; do
3133 3163 servicename=`docker inspect --format '{{ .Name }}' $service`
3134 3164 servicename=${servicename:1}
3135 3165 printf "CONTAINER:\\t$servicename\n"
3136 3166 printf "LOGS:\\t\\tdocker logs --tail=100 $service\n"
3137 3167 docker ps --filter=name=$servicename --format="ID:\\t\\t{{.ID}}\nIMAGE:\\t\\t{{.Image}}\nSTATUS:\\t\\t{{.Status}}\nPORTS:\\t\\t{{.Ports}}\n"
3138 3168 echo ""
3139 3169 done
3140 3170 else
3141 3171 docker ps --filter=name=rc_cluster --format "table {{.ID}}\t{{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}" | (read -r; printf "%s\n" "$REPLY"; sort -k 2 )
3142 3172 fi
3143 3173
3144 3174 }
3145 3175
3146 3176 # :command.function
3147 3177 rcstack_stack_upgrade_router_command() {
3148 3178 # src/stack_upgrade_router_command.sh
3149 3179 echo "Upgrading this stack with:"
3150 3180 echo "./$RC_SCRIPT_NAME stack router up --force-recreate --detach"
3151 3181 echo ""
3152 3182 echo "NOTE: To reclaim space occupied by old images, run:"
3153 3183 echo "docker image prune -f"
3154 3184
3155 3185 ./$RC_SCRIPT_NAME stack router up --force-recreate --detach
3156 3186
3157 3187 }
3158 3188
3159 3189 # :command.function
3160 3190 rcstack_stack_upgrade_metrics_command() {
3161 3191 # src/stack_upgrade_metrics_command.sh
3162 3192 echo "To upgrading this stack with:"
3163 3193 echo "./$RC_SCRIPT_NAME stack metrics up --force-recreate --detach"
3164 3194 echo ""
3165 3195 echo "NOTE: To reclaim space occupied by old images, run:"
3166 3196 echo "docker image prune -f"
3167 3197
3168 3198 ./$RC_SCRIPT_NAME stack metrics up --force-recreate --detach
3169 3199
3170 3200 }
3171 3201
3172 3202 # :command.function
3173 3203 rcstack_stack_upgrade_services_command() {
3174 3204 # src/stack_upgrade_services_command.sh
3175 3205 echo "Upgrading this stack with:"
3176 3206 echo "./$RC_SCRIPT_NAME stack services up --force-recreate --detach"
3177 3207 echo ""
3178 3208 echo "NOTE: To reclaim space occupied by old images, run:"
3179 3209 echo "docker image prune -f"
3180 3210
3181 3211 ./$RC_SCRIPT_NAME stack services up --force-recreate --detach
3182 3212
3183 3213 }
3184 3214
3185 3215 # :command.function
3186 3216 rcstack_stack_upgrade_rhodecode_command() {
3187 3217 # src/stack_upgrade_rhodecode_command.sh
3188 3218 check_bootstrap
3189 3219
3190 3220 stop_wait=${args[--stop-wait]}
3191 3221 docker_stop_wait=${args[--docker-stop-wait]}
3192 3222
3193 3223 stack_prefix=${args[--stack-prefix]}
3194 3224 if [[ $stack_prefix == "" ]]; then
3195 3225 stack_prefix="rc_cluster_apps"
3196 3226 fi
3197 3227
3198 3228 # search docker IDs for current service
3199 3229 .env --file $RUNTIME_ENV
3200 3230
3201 3231 .env get RC_VERSION
3202 3232 RC_VERSION=$REPLY
3203 3233
3204 3234 .env get RC_EDITION
3205 3235 RC_EDITION=$REPLY
3206 3236
3207 3237 echo "Pulling new image: rhodecode/rhodecode-${RC_EDITION}:${RC_VERSION}"
3208 3238 echo "WARNING: about to start downloading the RhodeCode base image"
3209 3239 echo "This process may take anywhere between a few minutes to an hour, depending on your network speed"
3210 3240 echo "running: docker pull -q rhodecode/rhodecode-${RC_EDITION}:${RC_VERSION}"
3211 3241
3212 3242 eval "docker pull -q rhodecode/rhodecode-${RC_EDITION}:${RC_VERSION}"
3213 3243
3214 3244 have_tty=1
3215 3245 # Set a dummy terminal type if none set
3216 3246 [[ -z "$TERM" ]] && export have_tty=0
3217 3247 [[ ! -t 1 ]] && export have_tty=0
3218 3248
3219 3249 set_cursor() {
3220 3250 if [[ $have_tty == 1 ]]; then
3221 3251 tput $1
3222 3252 fi
3223 3253 }
3224 3254
3225 3255 stop_containers() {
3226 3256 target_container=$1
3227 3257 docker_stop_wait=$2
3228 3258 stop_wait=$3
3229 3259 target_containers_pat="$stack_prefix-$target_container-*"
3230 3260
3231 3261 # array with OLD containers
3232 3262 local -a old_docker_ids
3233 3263 readarray -t old_docker_ids < <(docker ps --filter name="$target_containers_pat" -q)
3234 3264
3235 3265 scale=${#old_docker_ids[@]}
3236 3266 scale_2=$(( scale * 2 ))
3237 3267
3238 3268 echo ""
3239 3269 echo "Found $scale services for $target_container"
3240 3270 echo "existing docker-ids:" "${old_docker_ids[@]}"
3241 3271 echo ""
3242 3272
3243 3273 echo "Scaling to 2x ($scale_2 total) containers for $target_container"
3244 3274 ./$RC_SCRIPT_NAME stack rhodecode up $target_container --no-recreate --detach --scale $target_container=$scale_2
3245 3275
3246 3276 # array with ALL new containers
3247 3277 local -a scaled_docker_ids
3248 3278 readarray -t scaled_docker_ids < <(docker ps --filter name="$target_containers_pat" -q)
3249 3279
3250 3280 echo "Scaling completed, running $scale_2 services for upgrade purpose..."
3251 3281 echo "new docker-ids:" "${scaled_docker_ids[@]}"
3252 3282
3253 3283 # calculate just NEW containers
3254 3284 declare -A new_container_check
3255 3285
3256 3286 # Mark elements of the first initial docker
3257 3287 for docker_id in "${old_docker_ids[@]}"; do
3258 3288 new_container_check[$docker_id]=1
3259 3289 done
3260 3290
3261 3291 local new_docker_ids_str
3262 3292 new_docker_ids_str=""
3263 3293
3264 3294 # Check if elements of the second array are not in the first
3265 3295 for n_docker_id in "${scaled_docker_ids[@]}"; do
3266 3296 # if $docker_id in new services is empty in the last array we ADD it :)
3267 3297 if [[ -z ${new_container_check[$n_docker_id]} ]]; then
3268 3298 new_docker_ids_str+=" $n_docker_id "
3269 3299 fi
3270 3300 done
3271 3301
3272 3302 echo "Stopping $scale old $target_container containers "
3273 3303 echo "killing docker-ids:" "${old_docker_ids[@]}"
3274 3304
3275 3305 spin='⠾⠽⠻⠟⠯⠷'
3276 3306 charwidth=1
3277 3307
3278 3308 # wait the required stop-wait time
3279 3309 #HC: docker inspect --format='{{.Name}}: {{json .ContainerId .State.Health.Status}}' <container-id>
3280 3310 local i
3281 3311 i=$(($stop_wait * 10))
3282 3312
3283 3313 local status
3284 3314 status=''
3285 3315
3286 3316 # cursor invisible
3287 3317 set_cursor civis
3288 3318 while true
3289 3319 s=$((i / 10))
3290 3320 do
3291 3321 i=$(($i-1))
3292 3322 if [[ $i -lt 1 ]]; then
3293 3323 break
3294 3324 fi
3295 3325
3296 3326 if [[ "$(($i % 10))" == 0 ]];
3297 3327 then
3298 3328 is_at_sec=1
3299 3329 else
3300 3330 is_at_sec=0
3301 3331 fi
3302 3332
3303 3333 local new_docker_ids_status_cnt
3304 3334
3305 3335 if [[ $is_at_sec == 1 ]]; then
3306 3336
3307 3337 new_docker_ids_status_cnt=$(docker inspect --format='{{.State.Health.Status}}' $new_docker_ids_str | grep -c "healthy" || echo "")
3308 3338
3309 3339 if [[ $new_docker_ids_status_cnt -eq $scale ]]; then
3310 3340 echo "All $target_container are in HEALTHY state; stopping old ones now"
3311 3341 echo ""
3312 3342 break
3313 3343 fi
3314 3344
3315 3345 fi
3316 3346
3317 3347 k=$(((k + $charwidth) % ${#spin}))
3318 3348
3319 3349 if [[ $have_tty == 1 ]]; then
3320 3350 printf "%s stopping $scale old containers once they are in HEALTHY state, or in $s s..." "${spin:$k:$charwidth}"
3321 3351 printf "\r"
3322 3352 else
3323 3353 if [[ $is_at_sec == 1 ]]; then
3324 3354 echo "stopping $scale old containers once they are in HEALTHY state, or in $s s..."
3325 3355 fi
3326 3356 fi
3327 3357
3328 3358 sleep .1
3329 3359 done
3330 3360 set_cursor cnorm
3331 3361
3332 3362 for container in "${old_docker_ids[@]}"
3333 3363 do
3334 3364 echo "now running container $container stop with --time $docker_stop_wait"
3335 3365 docker stop --time "$docker_stop_wait" "$container" > /dev/null
3336 3366 docker rm "$container" > /dev/null
3337 3367 echo "Stopped $container"
3338 3368 done
3339 3369
3340 3370 }
3341 3371
3342 3372 # VCSSERVER Containers
3343 3373 stop_containers "vcsserver" $docker_stop_wait $stop_wait
3344 3374
3345 3375 # RHODECODE Containers
3346 3376 stop_containers "rhodecode" $docker_stop_wait $stop_wait
3347 3377
3348 3378 # SVN Containers
3349 3379 stop_containers "svn" $docker_stop_wait $stop_wait
3350 3380
3351 3381 # SSHD Containers
3352 3382 stop_containers "sshd" $docker_stop_wait $stop_wait
3353 3383
3354 3384 ./$RC_SCRIPT_NAME stack rhodecode up celery --force-recreate --detach
3355 3385 ./$RC_SCRIPT_NAME stack rhodecode up celery-beat --force-recreate --detach
3356 3386
3357 3387 echo "Upgrade to rhodecode/rhodecode-${RC_EDITION}:${RC_VERSION} completed"
3358 3388 exit
3359 3389
3360 3390 }
3361 3391
3362 3392 # :command.function
3363 3393 rcstack_stack_monitor_restart_unhealthy_command() {
3364 3394 # src/stack_monitor_restart_unhealthy_command.sh
3365 3395 check_bootstrap
3366 3396
3367 3397 DEBUG=${args[--debug]}
3368 3398 loop=${args[--loop]}
3369 3399
3370 3400 get_unhealthy() {
3371 3401 unhealthy=$(docker ps --filter health=unhealthy --filter label=autoheal=true --format "{{.ID}}")
3372 3402
3373 3403 if [[ $unhealthy == "" ]]; then
3374 3404 echo "$(green stack-monitor: no unhealthy containers found)"
3375 3405 else
3376 3406 echo "$(yellow stack-monitor: found unhealthy containers $unhealthy)"
3377 3407 fi
3378 3408
3379 3409 for container in $unhealthy
3380 3410 do
3381 3411 docker stats --no-stream --format '{{.ID}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}\t{{.BlockIO}}' $container
3382 3412 echo "stack-monitor: restart $container"
3383 3413 docker restart --time=10 $container
3384 3414 done
3385 3415
3386 3416 }
3387 3417
3388 3418 if [[ ! $loop == "0" ]]; then
3389 3419
3390 3420 while true
3391 3421 do
3392 3422 date_formatted=$(date)
3393 3423 echo "stack-monitor: loop-run every $loop seconds..., $date_formatted"
3394 3424 # loop run
3395 3425 NO_COLOR=1 get_unhealthy
3396 3426 echo "Next execution in $loop s..." && \
3397 3427 sleep $loop
3398 3428 echo ""
3399 3429 done
3400 3430
3401 3431 else
3402 3432
3403 3433 # one time run
3404 3434 get_unhealthy
3405 3435 fi
3406 3436
3407 3437 exit
3408 3438
3409 3439 }
3410 3440
3411 3441 # :command.function
3412 3442 rcstack_cli_image_info_command() {
3413 3443 # src/cli_image_info_command.sh
3414 3444
3415 3445 verbose=${args[--verbose]}
3416 3446
3417 3447 if [[ $verbose ]]; then
3418 3448
3419 3449 ver="unknown"
3420 3450 if [[ -f $ENV_FILE ]]; then
3421 3451 .env --file $RUNTIME_ENV
3422 3452 .env get RC_VERSION
3423 3453 ver=$REPLY
3424 3454 fi
3425 3455
3426 3456 echo "Image stored version: $rc_image_ver"
3427 3457 echo "Image from runtime: $ver"
3428 3458 echo "runtime-file=$RUNTIME_ENV"
3429 3459 echo "RC_VERSION=$ver"
3430 3460 else
3431 3461 echo $rc_image_ver
3432 3462 fi
3433 3463
3434 3464 }
3435 3465
3436 3466 # :command.function
3437 3467 rcstack_cli_set_runtime_image_command() {
3438 3468 # src/cli_set_runtime_image_command.sh
3439 3469 set_ver=${args[version]}
3440 3470
3441 3471 .env --file $RUNTIME_ENV
3442 3472 echo "setting runtime version to $set_ver into $RUNTIME_ENV"
3443 3473
3444 3474 .env set RC_VERSION=$set_ver
3445 3475
3446 3476 echo "New version set to $set_ver"
3447 3477
3448 3478 }
3449 3479
3450 3480 # :command.function
3451 3481 rcstack_cli_ishell_command() {
3452 3482 # src/cli_ishell_command.sh
3453 3483 instance_type=rhodecode
3454 3484
3455 3485 match_name=rc_cluster_apps-
3456 3486 docker_id=$(docker ps --filter name=$match_name -q | head -n1)
3457 3487
3458 3488 if [[ $docker_id == "" ]]; then
3459 3489 echo "$(yellow cannot find instance to attach by name *$match_name*)"
3460 3490 exit 1
3461 3491 fi
3462 3492
3463 3493 docker exec -it --tty $docker_id /usr/local/bin/rhodecode_bin/bin/rc-ishell /etc/rhodecode/conf/rhodecode.ini
3464 3494
3465 3495 }
3466 3496
3467 3497 # :command.function
3468 3498 rcstack_cli_redis_command() {
3469 3499 # src/cli_redis_command.sh
3470 3500 check_bootstrap
3471 3501
3472 3502 DEBUG=${args[--debug]}
3473 3503
3474 3504 target_container=rc_cluster_services-redis-1
3475 3505 docker_id=$(docker ps --filter name=$target_container -q)
3476 3506
3477 3507 if [[ $DEBUG ]]; then
3478 3508 echo "container id: $docker_id, based on $target_container filter"
3479 3509 docker ps
3480 3510 fi
3481 3511
3482 3512 if [ "$docker_id" == "" ]; then
3483 3513 MSG="Cannot find container ID with name $target_container"
3484 3514 echo "$(red $MSG)"
3485 3515 exit 1
3486 3516 fi
3487 3517
3488 3518 if [[ $DEBUG ]]; then
3489 3519 echo "Running |docker exec --interactive --tty $docker_id $CMD|"
3490 3520 echo "docker exec --interactive --tty $docker_id /bin/bash -c 'redis-cli'"
3491 3521 fi
3492 3522
3493 3523 eval "docker exec --interactive --tty $docker_id /bin/bash -c 'redis-cli'"
3494 3524
3495 3525 }
3496 3526
3497 3527 # :command.function
3498 3528 rcstack_cli_db_command() {
3499 3529 # src/cli_db_command.sh
3500 3530 check_bootstrap
3501 3531
3502 3532 DEBUG=${args[--debug]}
3503 3533
3504 3534 target_container=rc_cluster_services-database-*
3505 3535 docker_id=$(docker ps --filter name=$target_container -q | head -n1)
3506 3536
3507 3537 if [[ $DEBUG ]]; then
3508 3538 echo "container id: $docker_id, based on $target_container filter"
3509 3539 docker ps
3510 3540 fi
3511 3541
3512 3542 if [ "$docker_id" == "" ]; then
3513 3543 MSG="Cannot find container ID with name $target_container"
3514 3544 echo "$(red $MSG)"
3515 3545 exit 1
3516 3546 fi
3517 3547
3518 3548 .env --file $RUNTIME_ENV
3519 3549
3520 3550 .env get DB_PASSWORD
3521 3551 DB_PASSWORD=$REPLY
3522 3552
3523 3553 .env get DB_NAME
3524 3554 DB_NAME=$REPLY
3525 3555
3526 3556 .env get DB_USER
3527 3557 DB_USER=$REPLY
3528 3558
3529 3559 if [[ $DEBUG ]]; then
3530 3560 echo "Running |docker exec --env-file $RUNTIME_ENV --interactive --tty $docker_id $CMD|"
3531 3561 echo "docker exec --interactive --tty $docker_id /bin/bash -c 'PGPASSWORD=$DB_PASSWORD psql --username=$DB_USER --dbname=$DB_NAME'"
3532 3562 fi
3533 3563
3534 3564 printf "attaching pg_data \t\t\tunder: /var/lib/postgresql/data\n"
3535 3565 printf "attaching \$PWD/.custom/db_dump \t\tunder: /var/rc-data-dump\n"
3536 3566 printf "restore dump:\n\i /var/rc-data-dump/your_dump.sql\n\n"
3537 3567
3538 3568 eval "docker exec --env-file $RUNTIME_ENV --interactive --tty $docker_id /bin/bash -c 'PGPASSWORD=$DB_PASSWORD psql --username=$DB_USER --dbname=$DB_NAME'"
3539 3569
3540 3570 }
3541 3571
3542 3572 # :command.function
3543 3573 rcstack_cli_db_upgrade_command() {
3544 3574 # src/cli_db_upgrade_command.sh
3545 3575 check_bootstrap
3546 3576
3547 3577 DEBUG=${args[--debug]}
3548 3578
3549 3579 target_container=rc_cluster_services-database-*
3550 3580 docker_id=$(docker ps --filter name=$target_container -q | head -n1)
3551 3581
3552 3582 if [[ $DEBUG ]]; then
3553 3583 echo "container id: $docker_id, based on $target_container filter"
3554 3584 docker ps
3555 3585 fi
3556 3586
3557 3587 if [ "$docker_id" == "" ]; then
3558 3588 MSG="Cannot find container ID with name $target_container"
3559 3589 echo "$(red $MSG)"
3560 3590 exit 1
3561 3591 fi
3562 3592
3563 3593 if [[ $DEBUG ]]; then
3564 3594 echo "./$RC_SCRIPT_NAME stack rhodecode exec rhodecode /usr/local/bin/rhodecode_bin/bin/rc-upgrade-db /etc/rhodecode/conf/rhodecode.ini --force-yes"
3565 3595 fi
3566 3596
3567 3597 ./$RC_SCRIPT_NAME stack rhodecode exec rhodecode /usr/local/bin/rhodecode_bin/bin/rc-upgrade-db /etc/rhodecode/conf/rhodecode.ini --force-yes
3568 3598 }
3569 3599
3570 3600 # :command.function
3571 3601 rcstack_cli_storage_command() {
3572 3602 # src/cli_storage_command.sh
3573 3603 check_bootstrap
3574 3604
3575 3605 DEBUG=${args[--debug]}
3576 3606 ENV_FILE=${args[--env-file-path]}
3577 3607 ATTACHED=${args[--attached]}
3578 3608
3579 3609 if [[ $DEBUG ]]; then
3580 3610 echo "rc_datavolume inspection..."
3581 3611 docker volume inspect rc_datavolume
3582 3612
3583 3613 echo "rc_reposvolume inspection..."
3584 3614 docker volume inspect rc_reposvolume
3585 3615 fi
3586 3616
3587 3617 #
3588 3618 #if [[ $DEBUG ]]; then
3589 3619 # echo "image id: $image_id, based on $target_container filter"
3590 3620 # docker image ls
3591 3621 # echo "---"
3592 3622 #fi
3593 3623 # rename a volume
3594 3624 #docker volume create --name <new_volume>
3595 3625 #docker run --rm -it -v <old_volume>:/from -v <new_volume>:/to alpine ash -c "cd /from ; cp -av . /to"
3596 3626 #docker volume rm <old_volume>
3597 3627 if [[ $ATTACHED ]]; then
3598 3628 printf "Starting with attached mode to vcsserver !"
3599 3629 printf "present rc_datavolume \t\tunder: /var/opt/rhodecode_data\n"
3600 3630 printf "present rc_reposvolume \t\tunder: /var/opt/rhodecode_repo_store\n"
3601 3631 printf "present confvolume \t\tunder: /etc/rhodecode/conf\n"
3602 3632
3603 3633 match_name=rc_cluster_apps-vcsserver
3604 3634 docker_id=$(docker ps --filter name=$match_name -q | head -n1)
3605 3635
3606 3636 if [[ $docker_id == "" ]]; then
3607 3637 echo "$(yellow cannot find instance to attach by name *$match_name*)"
3608 3638 exit 1
3609 3639 fi
3610 3640
3611 3641 docker exec -it --tty --workdir /var/opt $docker_id bash
3612 3642
3613 3643 else
3614 3644 printf "attaching rc_datavolume \t\tunder: /vol/datavolume\n"
3615 3645 printf "attaching rc_reposvolume \t\tunder: /vol/repovolume\n"
3616 3646 printf "attaching \$PWD/.custom/storage \t\tunder: /vol/backupvolume\n"
3617 3647
3618 3648 docker run --rm \
3619 3649 -it \
3620 3650 --volume $PWD/.custom/storage:/vol/backupvolume \
3621 3651 --volume rc_datavolume:/vol/datavolume \
3622 3652 --volume rc_reposvolume:/vol/repovolume \
3623 3653 --workdir="/vol" \
3624 3654 ubuntu:22.04 \
3625 3655 /bin/bash
3626 3656 fi
3627 3657
3628 3658 }
3629 3659
3630 3660 # :command.function
3631 3661 rcstack_cli_attach_command() {
3632 3662 # src/cli_attach_command.sh
3633 3663 instance_type=${args[--instance-type]}
3634 3664
3635 3665 match_name=rc_cluster_apps-$instance_type
3636 3666 docker_id=$(docker ps --filter name=$match_name -q | head -n1)
3637 3667
3638 3668 if [[ $docker_id == "" ]]; then
3639 3669 echo "$(yellow cannot find instance to attach by name *$match_name*)"
3640 3670 exit 1
3641 3671 fi
3642 3672
3643 3673 docker exec -it --tty $docker_id bash
3644 3674
3645 3675 }
3646 3676
3647 3677 # :command.function
3648 3678 rcstack_cli_set_edition_command() {
3649 3679 # src/cli_set_edition_command.sh
3650 3680 INI_TARGET=$PWD/config/_shared
3651 3681 BOOTSTRAP_RUNTIME_ENV=$PWD/.custom/.runtime.env
3652 3682
3653 3683 RC_EDITION=${args[edition_type]}
3654 3684 ini_path=$INI_TARGET/rhodecode.ini
3655 3685
3656 3686 echo "Setting current installation as rhodecode-$RC_EDITION type"
3657 3687
3658 3688 echo "configure $ini_path"
3659 3689 sed_replace '^use = egg:rhodecode-enterprise.*' "use = egg:rhodecode-enterprise-$RC_EDITION"
3660 3690
3661 3691 echo ""
3662 3692 echo "configure $BOOTSTRAP_RUNTIME_ENV"
3663 3693 .env --file "$BOOTSTRAP_RUNTIME_ENV"
3664 3694 .env set RC_EDITION=$RC_EDITION
3665 3695
3666 3696 echo "Configuration done, run "
3667 3697 echo "./$RC_SCRIPT_NAME stack-upgrade rhodecode"
3668 3698
3669 3699 }
3670 3700
3671 3701 # :command.function
3672 3702 rcstack_cli_configure_vcsserver_command() {
3673 3703 # src/cli_configure_vcsserver_command.sh
3674 3704 ini_path=${args[ini_path]}
3675 3705 DEBUG=${args[--debug]}
3676 3706
3677 3707 config_vcsserver_ini
3678 3708
3679 3709 echo
3680 3710 echo "reconfigure of $ini_path completed"
3681 3711
3682 3712 }
3683 3713
3684 3714 # :command.function
3685 3715 rcstack_cli_configure_rhodecode_command() {
3686 3716 # src/cli_configure_rhodecode_command.sh
3687 3717 ini_path=${args[ini_path]}
3688 3718 DEBUG=${args[--debug]}
3689 3719
3690 3720 # read generated secrets etc from our .env file
3691 3721 .env --file $RUNTIME_ENV
3692 3722
3693 3723 .env get RC_LICENSE_TOKEN
3694 3724 RC_LICENSE_TOKEN=$REPLY
3695 3725
3696 3726 .env get RC_EDITION
3697 3727 RC_EDITION=$REPLY
3698 3728
3699 3729 .env get RC_HOSTNAME
3700 3730 RC_HOSTNAME=$(sed_safe_path $REPLY)
3701 3731
3702 3732 .env get RC_APP_BASE_URL
3703 3733 RC_APP_BASE_URL=$(sed_safe_path $REPLY)
3704 3734
3705 3735 .env get RC_SQLALCHEMY_DB1_URL
3706 3736 RC_SQLALCHEMY_DB1_URL=$(sed_safe_path $REPLY)
3707 3737
3708 3738 .env get RC_CHANNELSTREAM_WS_URL
3709 3739 RC_CHANNELSTREAM_WS_URL=$(sed_safe_path $REPLY)
3710 3740
3711 3741 # $ini_path needs to be defined!
3712 3742 config_rhodecode_ini
3713 3743
3714 3744 echo
3715 3745 echo "reconfigure of $ini_path completed"
3716 3746 }
3717 3747
3718 3748 # :command.function
3719 3749 rcstack_backup_db_command() {
3720 3750 # src/backup_db_command.sh
3721 3751 check_bootstrap
3722 3752
3723 3753 DEBUG=${args[--debug]}
3724 3754 DESTINATION=${args[destination]}
3725 3755
3726 3756 backup_name=rc_db_dump-$(date +%Y-%m-%d).sql.gz
3727 3757 echo "creating backup: $backup_name"
3728 3758
3729 3759 target_container=rc_cluster_services-database-*
3730 3760 docker_id=$(docker ps --filter name=$target_container -q | head -n1)
3731 3761
3732 3762 if [[ $DEBUG ]]; then
3733 3763 echo "container id: $docker_id, based on $target_container filter"
3734 3764 docker ps
3735 3765 echo "---"
3736 3766 fi
3737 3767
3738 3768 if [ "$docker_id" == "" ]; then
3739 3769 MSG="Cannot find container ID with name $target_container"
3740 3770 echo "$(red $MSG)"
3741 3771 exit 1
3742 3772 fi
3743 3773
3744 3774 .env --file $RUNTIME_ENV
3745 3775
3746 3776 .env get DB_PASSWORD
3747 3777 DB_PASSWORD=$REPLY
3748 3778
3749 3779 .env get DB_NAME
3750 3780 DB_NAME=$REPLY
3751 3781
3752 3782 .env get DB_USER
3753 3783 DB_USER=$REPLY
3754 3784
3755 3785 if [[ $DEBUG ]]; then
3756 3786 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'"
3757 3787 echo "dump placed in /var/rc-data-dump/$backup_name"
3758 3788 echo "run docker cp $docker_id:/var/rc-data-dump/$backup_name $PWD to copy the file into your host machine"
3759 3789 fi
3760 3790
3761 3791 set -euo pipefail
3762 3792
3763 3793 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"
3764 3794
3765 3795 echo "$(green Backup created in container volume under: /var/rc-data-dump/$backup_name !)"
3766 3796 echo "to copy this file into your host machine run:"
3767 3797 echo "docker cp $docker_id:/var/rc-data-dump/$backup_name $PWD"
3768 3798
3769 3799 }
3770 3800
3771 3801 # :command.function
3772 3802 rcstack_backup_data_command() {
3773 3803 # src/backup_data_command.sh
3774 3804 check_bootstrap
3775 3805
3776 3806 DEBUG=${args[--debug]}
3777 3807 DESTINATION=${args[destination]}
3778 3808
3779 3809 backup_name=rc_data_dump-$(date +%Y-%m-%d).tar.gz
3780 3810 echo "creating backup: $backup_name"
3781 3811
3782 3812 target_container=rc_cluster_apps-rhodecode-*
3783 3813 target_container=rc_cluster_apps-celery-*
3784 3814 docker_id=$(docker ps --filter name=$target_container -q | head -n1)
3785 3815
3786 3816 if [[ $DEBUG ]]; then
3787 3817 echo "container id: $docker_id, based on $target_container filter"
3788 3818 docker ps
3789 3819 echo "---"
3790 3820 fi
3791 3821
3792 3822 if [ "$docker_id" == "" ]; then
3793 3823 MSG="Cannot find container ID with name $target_container"
3794 3824 echo "$(red $MSG)"
3795 3825 exit 1
3796 3826 fi
3797 3827
3798 3828 set -euo pipefail
3799 3829
3800 3830 echo "Following volumes will be backed-up:"
3801 3831
3802 3832 volumes=$(docker inspect --format "{{ range .Mounts }}{{ println .Destination }}{{ end }}" $docker_id)
3803 3833 destination_dir=/tmp
3804 3834 for vol in $volumes; do
3805 3835 echo "backup: $vol"
3806 3836 docker run --rm -v $destination_dir:/backup --volumes-from "$docker_id" debian:jessie tar -czvf /backup/$backup_name.tar.gz "$vol"
3807 3837 done
3808 3838
3809 3839 echo "$(green Backup created in $destination_dir: $backup_name !)"
3810 3840
3811 3841 #docker-volume-restore-compressed() {
3812 3842 # destination_dir=$1
3813 3843 # container=$2
3814 3844 #
3815 3845 # docker run --rm -v $destination_dir:/backup --volumes-from "$container" debian:jessie tar -xzvf /backup/backup.tar.gz "${@:3}"
3816 3846 # echo "Double checking files..."
3817 3847 # docker run --rm -v $destination_dir:/backup --volumes-from "$container" debian:jessie ls -lh "${@:2}"
3818 3848 #}
3819 3849 }
3820 3850
3821 3851 # :command.function
3822 3852 rcstack_get_build_artifacts_command() {
3823 3853 # src/get_build_artifacts_command.sh
3824 3854 check_bootstrap
3825 3855
3826 3856 DEBUG=${args[--debug]}
3827 3857 AUTH=${args[--auth]}
3828 3858 INSTALLER_URL=${args[--installer-url]}
3829 3859 MANIFEST_URL=${args[--manifest-url]}
3830 3860 RC_VERSION=${args[--version-name]}
3831 3861 VER=$RC_VERSION
3832 3862
3833 3863 CACHE_DIR=$PWD/.cache
3834 3864 VER_REGEX="$VER+x86_64"
3835 3865
3836 3866 if [[ $VER == "" ]]; then
3837 3867 msg="Version is empty, please set --version-name correctly"
3838 3868 echo "$(red $msg)"
3839 3869 exit 1
3840 3870 fi
3841 3871
3842 3872 echo "Downloading Artifacts for version: $VER"
3843 3873 mkdir -p $CACHE_DIR
3844 3874
3845 3875 echo "1/4 Checking available downloads from MANIFEST file"
3846 3876
3847 3877 ARTS=$(curl -s $AUTH $MANIFEST_URL | grep --ignore-case "$VER_REGEX" | cut -d ' ' -f 2)
3848 3878
3849 3879 if [[ $DEBUG ]]; then
3850 3880 echo "DEBUG START"
3851 3881 curl -s $AUTH $MANIFEST_URL | grep --ignore-case "$VER_REGEX" || echo "no regex match"
3852 3882 curl -s $AUTH $MANIFEST_URL | grep --ignore-case "$VER_REGEX" | cut -d ' ' -f 2
3853 3883 echo "Found following artifacts:"
3854 3884 echo $ARTS
3855 3885 echo "DEBUG END"
3856 3886 fi
3857 3887
3858 3888 if [[ $ARTS == "" ]]; then
3859 3889 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"
3860 3890 echo "$(red $MSG)"
3861 3891 exit 1
3862 3892 fi
3863 3893
3864 3894 echo "2/4 Downloading locale-archive"
3865 3895 curl -L https://dls.rhodecode.com/assets/locale-archive -J -O
3866 3896 mv -v locale-archive "$CACHE_DIR"
3867 3897
3868 3898 # vcsserver/ce/ee
3869 3899 echo "3/4 Downloading installer artifacts"
3870 3900 for url in $ARTS; do
3871 3901 echo "Downloading $url with $AUTH"
3872 3902 curl $AUTH --fail-early -L ${url} -J -O
3873 3903 done
3874 3904
3875 3905 #for url in $(curl -s $MANIFEST_URL | grep --ignore-case -E 'control.+\+x86_64' | cut -d ' ' -f 2); do
3876 3906 # echo "Downloading $url"
3877 3907 # curl -L ${url} -J -O
3878 3908 #done
3879 3909
3880 3910 echo "4/4 Downloading installer from $INSTALLER_URL"
3881 3911 curl $AUTH -L $INSTALLER_URL -J -O
3882 3912
3883 3913 INSTALLER=$(ls -Art RhodeCode-installer-* | tail -n 1)
3884 3914 if [[ -n $INSTALLER ]]; then
3885 3915 chmod +x "${INSTALLER}"
3886 3916 fi
3887 3917
3888 3918 echo "Copying artifacts into $CACHE_DIR"
3889 3919
3890 3920 mv -v "${INSTALLER}" $CACHE_DIR
3891 3921 mv -v *.bz2 $CACHE_DIR
3892 3922 ls -lh $CACHE_DIR
3893 3923
3894 3924 }
3895 3925
3896 3926 # :command.function
3897 3927 rcstack_build_installer_command() {
3898 3928 # src/build_installer_command.sh
3899 3929 check_bootstrap
3900 3930
3901 3931 rc_version=${args[--version-name]}
3902 3932 export RC_VERSION=$rc_version
3903 3933 eval "echo INSTALLER BASED BUILDING${RC_VERSION}"
3904 3934
3905 3935 RC_VERSION=$rc_version ./$RC_SCRIPT_NAME stack rhodecode build --progress plain rhodecode
3906 3936
3907 3937 }
3908 3938
3909 3939 # :command.function
3910 3940 rcstack_get_build_source_command() {
3911 3941 # src/get_build_source_command.sh
3912 3942
3913 3943 NO_INIT=${args[--no-init-check]}
3914 3944
3915 3945 if [[ ! $NO_INIT ]]; then
3916 3946 check_bootstrap
3917 3947 fi
3918 3948
3919 3949 DEBUG=${args[--debug]}
3920 3950 AUTH_TOKEN=${args[--auth-token]}
3921 3951 SERVER_URL=${args[--server-url]}
3922 3952 revision=${args[--revision]}
3923 3953
3924 3954 SOURCE_DIR=$PWD/.source
3925 3955
3926 3956 RHODECODE_VCS_HASH=$revision
3927 3957 RHODECODE_CE_HASH=$revision
3928 3958 RHODECODE_EE_HASH=$revision
3929 3959
3930 3960 # download sources
3931 3961 echo "** download rhodecode source for build from $SERVER_URL using '$revision' hash **"
3932 3962 mkdir -p $SOURCE_DIR
3933 3963
3934 3964 echo "getting $SERVER_URL/rhodecode-vcsserver/archive/$RHODECODE_VCS_HASH.tgz"
3935 3965 curl --fail --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
3936 3966
3937 3967 echo "getting $SERVER_URL/rhodecode-enterprise-ce/archive/$RHODECODE_CE_HASH.tgz"
3938 3968 curl --fail --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
3939 3969
3940 3970 echo "getting $SERVER_URL/rhodecode-enterprise-ee/archive/$RHODECODE_EE_HASH.tgz"
3941 3971 curl --fail --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
3942 3972
3943 3973 rm -rf $SOURCE_DIR/rhodecode-vcsserver && \
3944 3974 mv $SOURCE_DIR/*rhodecode-vcsserver-plain $SOURCE_DIR/rhodecode-vcsserver
3945 3975 rm -rf $SOURCE_DIR/rhodecode-vcsserver/.hg
3946 3976
3947 3977 rm -rf $SOURCE_DIR/rhodecode-enterprise-ce && \
3948 3978 mv $SOURCE_DIR/*rhodecode-enterprise-ce-plain $SOURCE_DIR/rhodecode-enterprise-ce
3949 3979 rm -rf $SOURCE_DIR/rhodecode-enterprise-ce/.hg
3950 3980
3951 3981 rm -rf $SOURCE_DIR/rhodecode-enterprise-ee && \
3952 3982 mv $SOURCE_DIR/*rhodecode-enterprise-ee-plain $SOURCE_DIR/rhodecode-enterprise-ee
3953 3983 rm -rf $SOURCE_DIR/rhodecode-enterprise-ee/.hg
3954 3984
3955 3985 echo "downloading sources done to $SOURCE_DIR, directory now consists:"
3956 3986 ls -l $SOURCE_DIR
3957 3987
3958 3988 echo ""
3959 3989 date_formatted=$(date +%Y.%m.%d.1)
3960 3990 echo "to create source based build run:"
3961 3991 echo " ./$RC_SCRIPT_NAME build-source --version-name 4.28.0.REL.$date_formatted --tag edge"
3962 3992
3963 3993 }
3964 3994
3965 3995 # :command.function
3966 3996 rcstack_build_source_command() {
3967 3997 # src/build_source_command.sh
3968 3998 check_bootstrap
3969 3999
3970 4000 rc_version=${args[--version-name]}
3971 4001 source_build_yaml=${args[--source-build-yaml]}
3972 4002
3973 4003 eval "tags_data=(${args[--tag]})"
3974 4004
3975 4005 export RC_VERSION=$rc_version
3976 4006 export RC_EDITION=ee
3977 4007 echo "build_source: SOURCE BASED BUILDING: $rc_version"
3978 4008 echo ""
3979 4009
3980 4010 DOCKER_SCAN_SUGGEST=false RC_VERSION=$rc_version ./$RC_SCRIPT_NAME stack rhodecode -f $source_build_yaml build --progress plain rhodecode
3981 4011
3982 4012 # now tag the ee to ce
3983 4013 docker tag rhodecode/rhodecode-ee:$rc_version rhodecode/rhodecode-ce:$rc_version
3984 4014
3985 4015 # apply the tags
3986 4016 for tag in "${tags_data[@]}"; do
3987 4017 echo "build_source: creating tag:$tag"
3988 4018 docker tag rhodecode/rhodecode-ee:$rc_version rhodecode/rhodecode-ee:$tag
3989 4019 docker tag rhodecode/rhodecode-ee:$rc_version rhodecode/rhodecode-ce:$tag
3990 4020 done
3991 4021
3992 4022 echo "build_source: consider setting release version using"
3993 4023 echo " ./$RC_SCRIPT_NAME cli set-runtime-image $rc_version"
3994 4024
3995 4025 echo "build_source: push this image using"
3996 4026 echo " docker push rhodecode/rhodecode-ee:$rc_version"
3997 4027 echo " docker push rhodecode/rhodecode-ce:$rc_version"
3998 4028
3999 4029 for tag in "${tags_data[@]}"; do
4000 4030 echo " docker push rhodecode/rhodecode-ee:$tag"
4001 4031 echo " docker push rhodecode/rhodecode-ce:$tag"
4002 4032 done
4003 4033 }
4004 4034
4005 4035 # :command.function
4006 4036 rcstack__completions_command() {
4007 4037 # src/_completions_command.sh
4008 4038 send_completions
4009 4039 }
4010 4040
4011 4041 # :command.parse_requirements
4012 4042 parse_requirements() {
4013 4043 # :command.fixed_flags_filter
4014 4044 while [[ $# -gt 0 ]]; do
4015 4045 case "${1:-}" in
4016 4046 --version | -v)
4017 4047 version_command
4018 4048 exit
4019 4049 ;;
4020 4050
4021 4051 --help | -h)
4022 4052 long_usage=yes
4023 4053 rcstack_usage
4024 4054 exit
4025 4055 ;;
4026 4056
4027 4057 # :flag.case
4028 4058 --debug)
4029 4059
4030 4060 # :flag.case_no_arg
4031 4061 args['--debug']=1
4032 4062 shift
4033 4063 ;;
4034 4064
4035 4065 # :flag.case
4036 4066 --no-init-check)
4037 4067
4038 4068 # :flag.case_no_arg
4039 4069 args['--no-init-check']=1
4040 4070 shift
4041 4071 ;;
4042 4072
4043 4073 *)
4044 4074 break
4045 4075 ;;
4046 4076
4047 4077 esac
4048 4078 done
4049 4079
4050 4080 # :command.environment_variables_filter
4051 4081 # :command.environment_variables_default
4052 4082 export RCC_CONFIG="${RCC_CONFIG:-.rcstack.ini}"
4053 4083 export RC_STACK_ROUTER_EXT="${RC_STACK_ROUTER_EXT:-.custom/docker-compose-router.override.yaml}"
4054 4084 export RC_STACK_METRICS_EXT="${RC_STACK_METRICS_EXT:-.custom/docker-compose-metrics.override.yaml}"
4055 4085 export RC_STACK_SERVICES_EXT="${RC_STACK_SERVICES_EXT:-.custom/docker-compose-services.override.yaml}"
4056 4086 export RC_STACK_RHODECODE_EXT="${RC_STACK_RHODECODE_EXT:-.custom/docker-compose-apps.override.yaml}"
4057 4087
4058 4088 # :command.command_filter
4059 4089 action=${1:-}
4060 4090
4061 4091 case $action in
4062 4092 -*) ;;
4063 4093
4064 4094 get-started)
4065 4095 action="get-started"
4066 4096 shift
4067 4097 rcstack_get_started_parse_requirements "$@"
4068 4098 shift $#
4069 4099 ;;
4070 4100
4071 4101 init)
4072 4102 action="init"
4073 4103 shift
4074 4104 rcstack_init_parse_requirements "$@"
4075 4105 shift $#
4076 4106 ;;
4077 4107
4078 4108 self-update)
4079 4109 action="self-update"
4080 4110 shift
4081 4111 rcstack_self_update_parse_requirements "$@"
4082 4112 shift $#
4083 4113 ;;
4084 4114
4085 4115 stack)
4086 4116 action="stack"
4087 4117 shift
4088 4118 rcstack_stack_parse_requirements "$@"
4089 4119 shift $#
4090 4120 ;;
4091 4121
4092 4122 stack-status | status)
4093 4123 action="stack-status"
4094 4124 shift
4095 4125 rcstack_stack_status_parse_requirements "$@"
4096 4126 shift $#
4097 4127 ;;
4098 4128
4099 4129 stack-upgrade)
4100 4130 action="stack-upgrade"
4101 4131 shift
4102 4132 rcstack_stack_upgrade_parse_requirements "$@"
4103 4133 shift $#
4104 4134 ;;
4105 4135
4106 4136 stack-monitor)
4107 4137 action="stack-monitor"
4108 4138 shift
4109 4139 rcstack_stack_monitor_parse_requirements "$@"
4110 4140 shift $#
4111 4141 ;;
4112 4142
4113 4143 cli)
4114 4144 action="cli"
4115 4145 shift
4116 4146 rcstack_cli_parse_requirements "$@"
4117 4147 shift $#
4118 4148 ;;
4119 4149
4120 4150 backup-db)
4121 4151 action="backup-db"
4122 4152 shift
4123 4153 rcstack_backup_db_parse_requirements "$@"
4124 4154 shift $#
4125 4155 ;;
4126 4156
4127 4157 backup-data)
4128 4158 action="backup-data"
4129 4159 shift
4130 4160 rcstack_backup_data_parse_requirements "$@"
4131 4161 shift $#
4132 4162 ;;
4133 4163
4134 4164 get-build-artifacts)
4135 4165 action="get-build-artifacts"
4136 4166 shift
4137 4167 rcstack_get_build_artifacts_parse_requirements "$@"
4138 4168 shift $#
4139 4169 ;;
4140 4170
4141 4171 build-installer)
4142 4172 action="build-installer"
4143 4173 shift
4144 4174 rcstack_build_installer_parse_requirements "$@"
4145 4175 shift $#
4146 4176 ;;
4147 4177
4148 4178 get-build-source)
4149 4179 action="get-build-source"
4150 4180 shift
4151 4181 rcstack_get_build_source_parse_requirements "$@"
4152 4182 shift $#
4153 4183 ;;
4154 4184
4155 4185 build-source)
4156 4186 action="build-source"
4157 4187 shift
4158 4188 rcstack_build_source_parse_requirements "$@"
4159 4189 shift $#
4160 4190 ;;
4161 4191
4162 4192 _completions)
4163 4193 action="_completions"
4164 4194 shift
4165 4195 rcstack__completions_parse_requirements "$@"
4166 4196 shift $#
4167 4197 ;;
4168 4198
4169 4199 # :command.command_fallback
4170 4200 "")
4171 4201 rcstack_usage >&2
4172 4202 exit 1
4173 4203 ;;
4174 4204
4175 4205 *)
4176 4206 printf "invalid command: %s\n" "$action" >&2
4177 4207 exit 1
4178 4208 ;;
4179 4209
4180 4210 esac
4181 4211
4182 4212 # :command.parse_requirements_while
4183 4213 while [[ $# -gt 0 ]]; do
4184 4214 key="$1"
4185 4215 case "$key" in
4186 4216
4187 4217 -?*)
4188 4218 printf "invalid option: %s\n" "$key" >&2
4189 4219 exit 1
4190 4220 ;;
4191 4221
4192 4222 *)
4193 4223 # :command.parse_requirements_case
4194 4224 # :command.parse_requirements_case_simple
4195 4225 printf "invalid argument: %s\n" "$key" >&2
4196 4226 exit 1
4197 4227
4198 4228 ;;
4199 4229
4200 4230 esac
4201 4231 done
4202 4232
4203 4233 }
4204 4234
4205 4235 # :command.parse_requirements
4206 4236 rcstack_get_started_parse_requirements() {
4207 4237 # :command.fixed_flags_filter
4208 4238 while [[ $# -gt 0 ]]; do
4209 4239 case "${1:-}" in
4210 4240 --help | -h)
4211 4241 long_usage=yes
4212 4242 rcstack_get_started_usage
4213 4243 exit
4214 4244 ;;
4215 4245
4216 4246 *)
4217 4247 break
4218 4248 ;;
4219 4249
4220 4250 esac
4221 4251 done
4222 4252
4223 4253 # :command.command_filter
4224 4254 action="get-started"
4225 4255
4226 4256 # :command.parse_requirements_while
4227 4257 while [[ $# -gt 0 ]]; do
4228 4258 key="$1"
4229 4259 case "$key" in
4230 4260
4231 4261 -?*)
4232 4262 printf "invalid option: %s\n" "$key" >&2
4233 4263 exit 1
4234 4264 ;;
4235 4265
4236 4266 *)
4237 4267 # :command.parse_requirements_case
4238 4268 # :command.parse_requirements_case_simple
4239 4269 printf "invalid argument: %s\n" "$key" >&2
4240 4270 exit 1
4241 4271
4242 4272 ;;
4243 4273
4244 4274 esac
4245 4275 done
4246 4276
4247 4277 }
4248 4278
4249 4279 # :command.parse_requirements
4250 4280 rcstack_init_parse_requirements() {
4251 4281 # :command.fixed_flags_filter
4252 4282 while [[ $# -gt 0 ]]; do
4253 4283 case "${1:-}" in
4254 4284 --help | -h)
4255 4285 long_usage=yes
4256 4286 rcstack_init_usage
4257 4287 exit
4258 4288 ;;
4259 4289
4260 4290 *)
4261 4291 break
4262 4292 ;;
4263 4293
4264 4294 esac
4265 4295 done
4266 4296
4267 4297 # :command.dependencies_filter
4268 4298 if command -v curl >/dev/null 2>&1; then
4269 4299 deps['curl']="$(command -v curl | head -n1)"
4270 4300 else
4271 4301 printf "missing dependency: curl\n" >&2
4272 4302 exit 1
4273 4303 fi
4274 4304
4275 4305 if command -v tar >/dev/null 2>&1; then
4276 4306 deps['tar']="$(command -v tar | head -n1)"
4277 4307 else
4278 4308 printf "missing dependency: tar\n" >&2
4279 4309 exit 1
4280 4310 fi
4281 4311
4282 4312 if command -v find >/dev/null 2>&1; then
4283 4313 deps['find']="$(command -v find | head -n1)"
4284 4314 else
4285 4315 printf "missing dependency: find\n" >&2
4286 4316 exit 1
4287 4317 fi
4288 4318
4289 4319 # :command.command_filter
4290 4320 action="init"
4291 4321
4292 4322 # :command.parse_requirements_while
4293 4323 while [[ $# -gt 0 ]]; do
4294 4324 key="$1"
4295 4325 case "$key" in
4296 4326 # :flag.case
4297 4327 --arg-rc-edition)
4298 4328
4299 4329 # :flag.case_arg
4300 4330 if [[ -n ${2+x} ]]; then
4301 4331
4302 4332 args['--arg-rc-edition']="$2"
4303 4333 shift
4304 4334 shift
4305 4335 else
4306 4336 printf "%s\n" "--arg-rc-edition requires an argument: --arg-rc-edition ARG_RC_EDITION" >&2
4307 4337 exit 1
4308 4338 fi
4309 4339 ;;
4310 4340
4311 4341 # :flag.case
4312 4342 --arg-hostname)
4313 4343
4314 4344 # :flag.case_arg
4315 4345 if [[ -n ${2+x} ]]; then
4316 4346
4317 4347 args['--arg-hostname']="$2"
4318 4348 shift
4319 4349 shift
4320 4350 else
4321 4351 printf "%s\n" "--arg-hostname requires an argument: --arg-hostname ARG_HOSTNAME" >&2
4322 4352 exit 1
4323 4353 fi
4324 4354 ;;
4325 4355
4326 4356 # :flag.case
4327 4357 --arg-use-ssl)
4328 4358
4329 4359 # :flag.case_arg
4330 4360 if [[ -n ${2+x} ]]; then
4331 4361
4332 4362 args['--arg-use-ssl']="$2"
4333 4363 shift
4334 4364 shift
4335 4365 else
4336 4366 printf "%s\n" "--arg-use-ssl requires an argument: --arg-use-ssl ARG_USE_SSL" >&2
4337 4367 exit 1
4338 4368 fi
4339 4369 ;;
4340 4370
4341 4371 # :flag.case
4342 4372 --arg-admin-email)
4343 4373
4344 4374 # :flag.case_arg
4345 4375 if [[ -n ${2+x} ]]; then
4346 4376
4347 4377 args['--arg-admin-email']="$2"
4348 4378 shift
4349 4379 shift
4350 4380 else
4351 4381 printf "%s\n" "--arg-admin-email requires an argument: --arg-admin-email ARG_ADMIN_EMAIL" >&2
4352 4382 exit 1
4353 4383 fi
4354 4384 ;;
4355 4385
4356 4386 # :flag.case
4357 4387 --arg-admin-user)
4358 4388
4359 4389 # :flag.case_arg
4360 4390 if [[ -n ${2+x} ]]; then
4361 4391
4362 4392 args['--arg-admin-user']="$2"
4363 4393 shift
4364 4394 shift
4365 4395 else
4366 4396 printf "%s\n" "--arg-admin-user requires an argument: --arg-admin-user ARG_ADMIN_USER" >&2
4367 4397 exit 1
4368 4398 fi
4369 4399 ;;
4370 4400
4371 4401 # :flag.case
4372 4402 --arg-admin-pass)
4373 4403
4374 4404 # :flag.case_arg
4375 4405 if [[ -n ${2+x} ]]; then
4376 4406
4377 4407 args['--arg-admin-pass']="$2"
4378 4408 shift
4379 4409 shift
4380 4410 else
4381 4411 printf "%s\n" "--arg-admin-pass requires an argument: --arg-admin-pass ARG_ADMIN_PASS" >&2
4382 4412 exit 1
4383 4413 fi
4384 4414 ;;
4385 4415
4386 4416 # :flag.case
4387 4417 --arg-license-token)
4388 4418
4389 4419 # :flag.case_arg
4390 4420 if [[ -n ${2+x} ]]; then
4391 4421
4392 4422 args['--arg-license-token']="$2"
4393 4423 shift
4394 4424 shift
4395 4425 else
4396 4426 printf "%s\n" "--arg-license-token requires an argument: --arg-license-token ARG_ADMIN_TOKEN" >&2
4397 4427 exit 1
4398 4428 fi
4399 4429 ;;
4400 4430
4401 4431 # :flag.case
4402 4432 --no-prompt)
4403 4433
4404 4434 # :flag.case_no_arg
4405 4435 args['--no-prompt']=1
4406 4436 shift
4407 4437 ;;
4408 4438
4409 4439 # :flag.case
4410 4440 --force | -f)
4411 4441
4412 4442 # :flag.case_no_arg
4413 4443 args['--force']=1
4414 4444 shift
4415 4445 ;;
4416 4446
4417 4447 # :flag.case
4418 4448 --stage)
4419 4449
4420 4450 # :flag.case_arg
4421 4451 if [[ -n ${2+x} ]]; then
4422 4452
4423 4453 if [[ -z ${args['--stage']+x} ]]; then
4424 4454 args['--stage']="\"$2\""
4425 4455 else
4426 4456 args['--stage']="${args[--stage]} \"$2\""
4427 4457 fi
4428 4458 shift
4429 4459 shift
4430 4460 else
4431 4461 printf "%s\n" "--stage requires an argument: --stage STAGE" >&2
4432 4462 exit 1
4433 4463 fi
4434 4464 ;;
4435 4465
4436 4466 # :flag.case
4437 4467 --auth-token)
4438 4468
4439 4469 # :flag.case_arg
4440 4470 if [[ -n ${2+x} ]]; then
4441 4471
4442 4472 args['--auth-token']="$2"
4443 4473 shift
4444 4474 shift
4445 4475 else
4446 4476 printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
4447 4477 exit 1
4448 4478 fi
4449 4479 ;;
4450 4480
4451 4481 # :flag.case
4452 4482 --server-url)
4453 4483
4454 4484 # :flag.case_arg
4455 4485 if [[ -n ${2+x} ]]; then
4456 4486
4457 4487 args['--server-url']="$2"
4458 4488 shift
4459 4489 shift
4460 4490 else
4461 4491 printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
4462 4492 exit 1
4463 4493 fi
4464 4494 ;;
4465 4495
4466 4496 # :flag.case
4467 4497 --docker-revision)
4468 4498
4469 4499 # :flag.case_arg
4470 4500 if [[ -n ${2+x} ]]; then
4471 4501
4472 4502 args['--docker-revision']="$2"
4473 4503 shift
4474 4504 shift
4475 4505 else
4476 4506 printf "%s\n" "--docker-revision requires an argument: --docker-revision DOCKER_REVISION" >&2
4477 4507 exit 1
4478 4508 fi
4479 4509 ;;
4480 4510
4481 4511 # :flag.case
4482 4512 --install-docker)
4483 4513
4484 4514 # :flag.case_arg
4485 4515 if [[ -n ${2+x} ]]; then
4486 4516
4487 4517 args['--install-docker']="$2"
4488 4518 shift
4489 4519 shift
4490 4520 else
4491 4521 printf "%s\n" "--install-docker requires an argument: --install-docker INSTALL_DOCKER" >&2
4492 4522 exit 1
4493 4523 fi
4494 4524 ;;
4495 4525
4496 4526 -?*)
4497 4527 printf "invalid option: %s\n" "$key" >&2
4498 4528 exit 1
4499 4529 ;;
4500 4530
4501 4531 *)
4502 4532 # :command.parse_requirements_case
4503 4533 # :command.parse_requirements_case_simple
4504 4534 printf "invalid argument: %s\n" "$key" >&2
4505 4535 exit 1
4506 4536
4507 4537 ;;
4508 4538
4509 4539 esac
4510 4540 done
4511 4541
4512 4542 # :command.default_assignments
4513 4543 [[ -n ${args['--server-url']:-} ]] || args['--server-url']="https://code.rhodecode.com"
4514 4544 [[ -n ${args['--docker-revision']:-} ]] || args['--docker-revision']="master"
4515 4545
4516 4546 }
4517 4547
4518 4548 # :command.parse_requirements
4519 4549 rcstack_self_update_parse_requirements() {
4520 4550 # :command.fixed_flags_filter
4521 4551 while [[ $# -gt 0 ]]; do
4522 4552 case "${1:-}" in
4523 4553 --help | -h)
4524 4554 long_usage=yes
4525 4555 rcstack_self_update_usage
4526 4556 exit
4527 4557 ;;
4528 4558
4529 4559 *)
4530 4560 break
4531 4561 ;;
4532 4562
4533 4563 esac
4534 4564 done
4535 4565
4536 4566 # :command.dependencies_filter
4537 4567 if command -v curl >/dev/null 2>&1; then
4538 4568 deps['curl']="$(command -v curl | head -n1)"
4539 4569 else
4540 4570 printf "missing dependency: curl\n" >&2
4541 4571 exit 1
4542 4572 fi
4543 4573
4544 4574 if command -v tar >/dev/null 2>&1; then
4545 4575 deps['tar']="$(command -v tar | head -n1)"
4546 4576 else
4547 4577 printf "missing dependency: tar\n" >&2
4548 4578 exit 1
4549 4579 fi
4550 4580
4551 4581 # :command.command_filter
4552 4582 action="self-update"
4553 4583
4554 4584 # :command.parse_requirements_while
4555 4585 while [[ $# -gt 0 ]]; do
4556 4586 key="$1"
4557 4587 case "$key" in
4558 4588 # :flag.case
4559 4589 --force)
4560 4590
4561 4591 # :flag.case_no_arg
4562 4592 args['--force']=1
4563 4593 shift
4564 4594 ;;
4565 4595
4566 4596 # :flag.case
4567 4597 --cli-revision)
4568 4598
4569 4599 # :flag.case_arg
4570 4600 if [[ -n ${2+x} ]]; then
4571 4601
4572 4602 args['--cli-revision']="$2"
4573 4603 shift
4574 4604 shift
4575 4605 else
4576 4606 printf "%s\n" "--cli-revision requires an argument: --cli-revision CLI_REVISION" >&2
4577 4607 exit 1
4578 4608 fi
4579 4609 ;;
4580 4610
4581 4611 # :flag.case
4582 4612 --docker-revision)
4583 4613
4584 4614 # :flag.case_arg
4585 4615 if [[ -n ${2+x} ]]; then
4586 4616
4587 4617 args['--docker-revision']="$2"
4588 4618 shift
4589 4619 shift
4590 4620 else
4591 4621 printf "%s\n" "--docker-revision requires an argument: --docker-revision DOCKER_REVISION" >&2
4592 4622 exit 1
4593 4623 fi
4594 4624 ;;
4595 4625
4596 4626 # :flag.case
4597 4627 --auth-token)
4598 4628
4599 4629 # :flag.case_arg
4600 4630 if [[ -n ${2+x} ]]; then
4601 4631
4602 4632 args['--auth-token']="$2"
4603 4633 shift
4604 4634 shift
4605 4635 else
4606 4636 printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
4607 4637 exit 1
4608 4638 fi
4609 4639 ;;
4610 4640
4611 4641 # :flag.case
4612 4642 --server-url)
4613 4643
4614 4644 # :flag.case_arg
4615 4645 if [[ -n ${2+x} ]]; then
4616 4646
4617 4647 args['--server-url']="$2"
4618 4648 shift
4619 4649 shift
4620 4650 else
4621 4651 printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
4622 4652 exit 1
4623 4653 fi
4624 4654 ;;
4625 4655
4626 4656 -?*)
4627 4657 printf "invalid option: %s\n" "$key" >&2
4628 4658 exit 1
4629 4659 ;;
4630 4660
4631 4661 *)
4632 4662 # :command.parse_requirements_case
4633 4663 # :command.parse_requirements_case_simple
4634 4664 printf "invalid argument: %s\n" "$key" >&2
4635 4665 exit 1
4636 4666
4637 4667 ;;
4638 4668
4639 4669 esac
4640 4670 done
4641 4671
4642 4672 # :command.default_assignments
4643 4673 [[ -n ${args['--cli-revision']:-} ]] || args['--cli-revision']="master"
4644 4674 [[ -n ${args['--docker-revision']:-} ]] || args['--docker-revision']="master"
4645 4675 [[ -n ${args['--server-url']:-} ]] || args['--server-url']="https://code.rhodecode.com"
4646 4676
4647 4677 }
4648 4678
4649 4679 # :command.parse_requirements
4650 4680 rcstack_stack_parse_requirements() {
4651 4681 # :command.fixed_flags_filter
4652 4682 while [[ $# -gt 0 ]]; do
4653 4683 case "${1:-}" in
4654 4684 --help | -h)
4655 4685 long_usage=yes
4656 4686 rcstack_stack_usage
4657 4687 exit
4658 4688 ;;
4659 4689
4660 4690 # :flag.case
4661 4691 --env-file-path)
4662 4692
4663 4693 # :flag.case_arg
4664 4694 if [[ -n ${2+x} ]]; then
4665 4695 # :flag.validations
4666 4696 if [[ -n $(validate_file_exists "$2") ]]; then
4667 4697 printf "validation error in %s:\n%s\n" "--env-file-path ENV_FILE_PATH" "$(validate_file_exists "$2")" >&2
4668 4698 exit 1
4669 4699 fi
4670 4700
4671 4701 args['--env-file-path']="$2"
4672 4702 shift
4673 4703 shift
4674 4704 else
4675 4705 printf "%s\n" "--env-file-path requires an argument: --env-file-path ENV_FILE_PATH" >&2
4676 4706 exit 1
4677 4707 fi
4678 4708 ;;
4679 4709
4680 4710 # :flag.case
4681 4711 --stack-prefix)
4682 4712
4683 4713 # :flag.case_arg
4684 4714 if [[ -n ${2+x} ]]; then
4685 4715
4686 4716 args['--stack-prefix']="$2"
4687 4717 shift
4688 4718 shift
4689 4719 else
4690 4720 printf "%s\n" "--stack-prefix requires an argument: --stack-prefix STACK_PREFIX" >&2
4691 4721 exit 1
4692 4722 fi
4693 4723 ;;
4694 4724
4695 4725 *)
4696 4726 break
4697 4727 ;;
4698 4728
4699 4729 esac
4700 4730 done
4701 4731
4702 4732 # :command.command_filter
4703 4733 action=${1:-}
4704 4734
4705 4735 case $action in
4706 4736 -*) ;;
4707 4737
4708 4738 router)
4709 4739 action="router"
4710 4740 shift
4711 4741 rcstack_stack_router_parse_requirements "$@"
4712 4742 shift $#
4713 4743 ;;
4714 4744
4715 4745 metrics)
4716 4746 action="metrics"
4717 4747 shift
4718 4748 rcstack_stack_metrics_parse_requirements "$@"
4719 4749 shift $#
4720 4750 ;;
4721 4751
4722 4752 services)
4723 4753 action="services"
4724 4754 shift
4725 4755 rcstack_stack_services_parse_requirements "$@"
4726 4756 shift $#
4727 4757 ;;
4728 4758
4729 4759 rhodecode)
4730 4760 action="rhodecode"
4731 4761 shift
4732 4762 rcstack_stack_rhodecode_parse_requirements "$@"
4733 4763 shift $#
4734 4764 ;;
4735 4765
4736 4766 all)
4737 4767 action="all"
4738 4768 shift
4739 4769 rcstack_stack_all_parse_requirements "$@"
4740 4770 shift $#
4741 4771 ;;
4742 4772
4743 4773 # :command.command_fallback
4744 4774 "")
4745 4775 rcstack_stack_usage >&2
4746 4776 exit 1
4747 4777 ;;
4748 4778
4749 4779 *)
4750 4780 printf "invalid command: %s\n" "$action" >&2
4751 4781 exit 1
4752 4782 ;;
4753 4783
4754 4784 esac
4755 4785
4756 4786 # :command.parse_requirements_while
4757 4787 while [[ $# -gt 0 ]]; do
4758 4788 key="$1"
4759 4789 case "$key" in
4760 4790
4761 4791 -?*)
4762 4792 printf "invalid option: %s\n" "$key" >&2
4763 4793 exit 1
4764 4794 ;;
4765 4795
4766 4796 *)
4767 4797 # :command.parse_requirements_case
4768 4798 # :command.parse_requirements_case_simple
4769 4799 printf "invalid argument: %s\n" "$key" >&2
4770 4800 exit 1
4771 4801
4772 4802 ;;
4773 4803
4774 4804 esac
4775 4805 done
4776 4806
4777 4807 # :command.default_assignments
4778 4808 [[ -n ${args['--env-file-path']:-} ]] || args['--env-file-path']="$PWD/.custom/.runtime.env"
4779 4809
4780 4810 }
4781 4811
4782 4812 # :command.parse_requirements
4783 4813 rcstack_stack_router_parse_requirements() {
4784 4814 # :command.fixed_flags_filter
4785 4815 while [[ $# -gt 0 ]]; do
4786 4816 case "${1:-}" in
4787 4817 --help | -h)
4788 4818 long_usage=yes
4789 4819 rcstack_stack_router_usage
4790 4820 exit
4791 4821 ;;
4792 4822
4793 4823 *)
4794 4824 break
4795 4825 ;;
4796 4826
4797 4827 esac
4798 4828 done
4799 4829
4800 4830 # :command.command_filter
4801 4831 action="stack router"
4802 4832
4803 4833 # :command.parse_requirements_while
4804 4834 while [[ $# -gt 0 ]]; do
4805 4835 key="$1"
4806 4836 case "$key" in
4807 4837
4808 4838 --)
4809 4839 shift
4810 4840 other_args+=("$@")
4811 4841 break
4812 4842 ;;
4813 4843
4814 4844 -?*)
4815 4845 other_args+=("$1")
4816 4846 shift
4817 4847 ;;
4818 4848
4819 4849 *)
4820 4850 # :command.parse_requirements_case
4821 4851 # :command.parse_requirements_case_catch_all
4822 4852 other_args+=("$1")
4823 4853 shift
4824 4854
4825 4855 ;;
4826 4856
4827 4857 esac
4828 4858 done
4829 4859
4830 4860 }
4831 4861
4832 4862 # :command.parse_requirements
4833 4863 rcstack_stack_metrics_parse_requirements() {
4834 4864 # :command.fixed_flags_filter
4835 4865 while [[ $# -gt 0 ]]; do
4836 4866 case "${1:-}" in
4837 4867 --help | -h)
4838 4868 long_usage=yes
4839 4869 rcstack_stack_metrics_usage
4840 4870 exit
4841 4871 ;;
4842 4872
4843 4873 *)
4844 4874 break
4845 4875 ;;
4846 4876
4847 4877 esac
4848 4878 done
4849 4879
4850 4880 # :command.command_filter
4851 4881 action="stack metrics"
4852 4882
4853 4883 # :command.parse_requirements_while
4854 4884 while [[ $# -gt 0 ]]; do
4855 4885 key="$1"
4856 4886 case "$key" in
4857 4887
4858 4888 --)
4859 4889 shift
4860 4890 other_args+=("$@")
4861 4891 break
4862 4892 ;;
4863 4893
4864 4894 -?*)
4865 4895 other_args+=("$1")
4866 4896 shift
4867 4897 ;;
4868 4898
4869 4899 *)
4870 4900 # :command.parse_requirements_case
4871 4901 # :command.parse_requirements_case_catch_all
4872 4902 other_args+=("$1")
4873 4903 shift
4874 4904
4875 4905 ;;
4876 4906
4877 4907 esac
4878 4908 done
4879 4909
4880 4910 }
4881 4911
4882 4912 # :command.parse_requirements
4883 4913 rcstack_stack_services_parse_requirements() {
4884 4914 # :command.fixed_flags_filter
4885 4915 while [[ $# -gt 0 ]]; do
4886 4916 case "${1:-}" in
4887 4917 --help | -h)
4888 4918 long_usage=yes
4889 4919 rcstack_stack_services_usage
4890 4920 exit
4891 4921 ;;
4892 4922
4893 4923 *)
4894 4924 break
4895 4925 ;;
4896 4926
4897 4927 esac
4898 4928 done
4899 4929
4900 4930 # :command.command_filter
4901 4931 action="stack services"
4902 4932
4903 4933 # :command.parse_requirements_while
4904 4934 while [[ $# -gt 0 ]]; do
4905 4935 key="$1"
4906 4936 case "$key" in
4907 4937
4908 4938 --)
4909 4939 shift
4910 4940 other_args+=("$@")
4911 4941 break
4912 4942 ;;
4913 4943
4914 4944 -?*)
4915 4945 other_args+=("$1")
4916 4946 shift
4917 4947 ;;
4918 4948
4919 4949 *)
4920 4950 # :command.parse_requirements_case
4921 4951 # :command.parse_requirements_case_catch_all
4922 4952 other_args+=("$1")
4923 4953 shift
4924 4954
4925 4955 ;;
4926 4956
4927 4957 esac
4928 4958 done
4929 4959
4930 4960 }
4931 4961
4932 4962 # :command.parse_requirements
4933 4963 rcstack_stack_rhodecode_parse_requirements() {
4934 4964 # :command.fixed_flags_filter
4935 4965 while [[ $# -gt 0 ]]; do
4936 4966 case "${1:-}" in
4937 4967 --help | -h)
4938 4968 long_usage=yes
4939 4969 rcstack_stack_rhodecode_usage
4940 4970 exit
4941 4971 ;;
4942 4972
4943 4973 *)
4944 4974 break
4945 4975 ;;
4946 4976
4947 4977 esac
4948 4978 done
4949 4979
4950 4980 # :command.command_filter
4951 4981 action="stack rhodecode"
4952 4982
4953 4983 # :command.parse_requirements_while
4954 4984 while [[ $# -gt 0 ]]; do
4955 4985 key="$1"
4956 4986 case "$key" in
4957 4987
4958 4988 --)
4959 4989 shift
4960 4990 other_args+=("$@")
4961 4991 break
4962 4992 ;;
4963 4993
4964 4994 -?*)
4965 4995 other_args+=("$1")
4966 4996 shift
4967 4997 ;;
4968 4998
4969 4999 *)
4970 5000 # :command.parse_requirements_case
4971 5001 # :command.parse_requirements_case_catch_all
4972 5002 other_args+=("$1")
4973 5003 shift
4974 5004
4975 5005 ;;
4976 5006
4977 5007 esac
4978 5008 done
4979 5009
4980 5010 }
4981 5011
4982 5012 # :command.parse_requirements
4983 5013 rcstack_stack_all_parse_requirements() {
4984 5014 # :command.fixed_flags_filter
4985 5015 while [[ $# -gt 0 ]]; do
4986 5016 case "${1:-}" in
4987 5017 --help | -h)
4988 5018 long_usage=yes
4989 5019 rcstack_stack_all_usage
4990 5020 exit
4991 5021 ;;
4992 5022
4993 5023 *)
4994 5024 break
4995 5025 ;;
4996 5026
4997 5027 esac
4998 5028 done
4999 5029
5000 5030 # :command.command_filter
5001 5031 action="stack all"
5002 5032
5003 5033 # :command.parse_requirements_while
5004 5034 while [[ $# -gt 0 ]]; do
5005 5035 key="$1"
5006 5036 case "$key" in
5007 5037
5008 5038 --)
5009 5039 shift
5010 5040 other_args+=("$@")
5011 5041 break
5012 5042 ;;
5013 5043
5014 5044 -?*)
5015 5045 other_args+=("$1")
5016 5046 shift
5017 5047 ;;
5018 5048
5019 5049 *)
5020 5050 # :command.parse_requirements_case
5021 5051 # :command.parse_requirements_case_catch_all
5022 5052 other_args+=("$1")
5023 5053 shift
5024 5054
5025 5055 ;;
5026 5056
5027 5057 esac
5028 5058 done
5029 5059
5030 5060 }
5031 5061
5032 5062 # :command.parse_requirements
5033 5063 rcstack_stack_status_parse_requirements() {
5034 5064 # :command.fixed_flags_filter
5035 5065 while [[ $# -gt 0 ]]; do
5036 5066 case "${1:-}" in
5037 5067 --help | -h)
5038 5068 long_usage=yes
5039 5069 rcstack_stack_status_usage
5040 5070 exit
5041 5071 ;;
5042 5072
5043 5073 *)
5044 5074 break
5045 5075 ;;
5046 5076
5047 5077 esac
5048 5078 done
5049 5079
5050 5080 # :command.command_filter
5051 5081 action="stack-status"
5052 5082
5053 5083 # :command.parse_requirements_while
5054 5084 while [[ $# -gt 0 ]]; do
5055 5085 key="$1"
5056 5086 case "$key" in
5057 5087 # :flag.case
5058 5088 --detailed)
5059 5089
5060 5090 # :flag.case_no_arg
5061 5091 args['--detailed']=1
5062 5092 shift
5063 5093 ;;
5064 5094
5065 5095 # :flag.case
5066 5096 --configs)
5067 5097
5068 5098 # :flag.case_no_arg
5069 5099 args['--configs']=1
5070 5100 shift
5071 5101 ;;
5072 5102
5073 5103 -?*)
5074 5104 printf "invalid option: %s\n" "$key" >&2
5075 5105 exit 1
5076 5106 ;;
5077 5107
5078 5108 *)
5079 5109 # :command.parse_requirements_case
5080 5110 # :command.parse_requirements_case_simple
5081 5111 printf "invalid argument: %s\n" "$key" >&2
5082 5112 exit 1
5083 5113
5084 5114 ;;
5085 5115
5086 5116 esac
5087 5117 done
5088 5118
5089 5119 }
5090 5120
5091 5121 # :command.parse_requirements
5092 5122 rcstack_stack_upgrade_parse_requirements() {
5093 5123 # :command.fixed_flags_filter
5094 5124 while [[ $# -gt 0 ]]; do
5095 5125 case "${1:-}" in
5096 5126 --help | -h)
5097 5127 long_usage=yes
5098 5128 rcstack_stack_upgrade_usage
5099 5129 exit
5100 5130 ;;
5101 5131
5102 5132 # :flag.case
5103 5133 --stack-prefix)
5104 5134
5105 5135 # :flag.case_arg
5106 5136 if [[ -n ${2+x} ]]; then
5107 5137
5108 5138 args['--stack-prefix']="$2"
5109 5139 shift
5110 5140 shift
5111 5141 else
5112 5142 printf "%s\n" "--stack-prefix requires an argument: --stack-prefix STACK_PREFIX" >&2
5113 5143 exit 1
5114 5144 fi
5115 5145 ;;
5116 5146
5117 5147 *)
5118 5148 break
5119 5149 ;;
5120 5150
5121 5151 esac
5122 5152 done
5123 5153
5124 5154 # :command.command_filter
5125 5155 action=${1:-}
5126 5156
5127 5157 case $action in
5128 5158 -*) ;;
5129 5159
5130 5160 router)
5131 5161 action="router"
5132 5162 shift
5133 5163 rcstack_stack_upgrade_router_parse_requirements "$@"
5134 5164 shift $#
5135 5165 ;;
5136 5166
5137 5167 metrics)
5138 5168 action="metrics"
5139 5169 shift
5140 5170 rcstack_stack_upgrade_metrics_parse_requirements "$@"
5141 5171 shift $#
5142 5172 ;;
5143 5173
5144 5174 services)
5145 5175 action="services"
5146 5176 shift
5147 5177 rcstack_stack_upgrade_services_parse_requirements "$@"
5148 5178 shift $#
5149 5179 ;;
5150 5180
5151 5181 rhodecode)
5152 5182 action="rhodecode"
5153 5183 shift
5154 5184 rcstack_stack_upgrade_rhodecode_parse_requirements "$@"
5155 5185 shift $#
5156 5186 ;;
5157 5187
5158 5188 # :command.command_fallback
5159 5189 "")
5160 5190 rcstack_stack_upgrade_usage >&2
5161 5191 exit 1
5162 5192 ;;
5163 5193
5164 5194 *)
5165 5195 printf "invalid command: %s\n" "$action" >&2
5166 5196 exit 1
5167 5197 ;;
5168 5198
5169 5199 esac
5170 5200
5171 5201 # :command.parse_requirements_while
5172 5202 while [[ $# -gt 0 ]]; do
5173 5203 key="$1"
5174 5204 case "$key" in
5175 5205
5176 5206 -?*)
5177 5207 printf "invalid option: %s\n" "$key" >&2
5178 5208 exit 1
5179 5209 ;;
5180 5210
5181 5211 *)
5182 5212 # :command.parse_requirements_case
5183 5213 # :command.parse_requirements_case_simple
5184 5214 printf "invalid argument: %s\n" "$key" >&2
5185 5215 exit 1
5186 5216
5187 5217 ;;
5188 5218
5189 5219 esac
5190 5220 done
5191 5221
5192 5222 }
5193 5223
5194 5224 # :command.parse_requirements
5195 5225 rcstack_stack_upgrade_router_parse_requirements() {
5196 5226 # :command.fixed_flags_filter
5197 5227 while [[ $# -gt 0 ]]; do
5198 5228 case "${1:-}" in
5199 5229 --help | -h)
5200 5230 long_usage=yes
5201 5231 rcstack_stack_upgrade_router_usage
5202 5232 exit
5203 5233 ;;
5204 5234
5205 5235 *)
5206 5236 break
5207 5237 ;;
5208 5238
5209 5239 esac
5210 5240 done
5211 5241
5212 5242 # :command.command_filter
5213 5243 action="stack-upgrade router"
5214 5244
5215 5245 # :command.parse_requirements_while
5216 5246 while [[ $# -gt 0 ]]; do
5217 5247 key="$1"
5218 5248 case "$key" in
5219 5249
5220 5250 -?*)
5221 5251 printf "invalid option: %s\n" "$key" >&2
5222 5252 exit 1
5223 5253 ;;
5224 5254
5225 5255 *)
5226 5256 # :command.parse_requirements_case
5227 5257 # :command.parse_requirements_case_simple
5228 5258 printf "invalid argument: %s\n" "$key" >&2
5229 5259 exit 1
5230 5260
5231 5261 ;;
5232 5262
5233 5263 esac
5234 5264 done
5235 5265
5236 5266 }
5237 5267
5238 5268 # :command.parse_requirements
5239 5269 rcstack_stack_upgrade_metrics_parse_requirements() {
5240 5270 # :command.fixed_flags_filter
5241 5271 while [[ $# -gt 0 ]]; do
5242 5272 case "${1:-}" in
5243 5273 --help | -h)
5244 5274 long_usage=yes
5245 5275 rcstack_stack_upgrade_metrics_usage
5246 5276 exit
5247 5277 ;;
5248 5278
5249 5279 *)
5250 5280 break
5251 5281 ;;
5252 5282
5253 5283 esac
5254 5284 done
5255 5285
5256 5286 # :command.command_filter
5257 5287 action="stack-upgrade metrics"
5258 5288
5259 5289 # :command.parse_requirements_while
5260 5290 while [[ $# -gt 0 ]]; do
5261 5291 key="$1"
5262 5292 case "$key" in
5263 5293
5264 5294 -?*)
5265 5295 printf "invalid option: %s\n" "$key" >&2
5266 5296 exit 1
5267 5297 ;;
5268 5298
5269 5299 *)
5270 5300 # :command.parse_requirements_case
5271 5301 # :command.parse_requirements_case_simple
5272 5302 printf "invalid argument: %s\n" "$key" >&2
5273 5303 exit 1
5274 5304
5275 5305 ;;
5276 5306
5277 5307 esac
5278 5308 done
5279 5309
5280 5310 }
5281 5311
5282 5312 # :command.parse_requirements
5283 5313 rcstack_stack_upgrade_services_parse_requirements() {
5284 5314 # :command.fixed_flags_filter
5285 5315 while [[ $# -gt 0 ]]; do
5286 5316 case "${1:-}" in
5287 5317 --help | -h)
5288 5318 long_usage=yes
5289 5319 rcstack_stack_upgrade_services_usage
5290 5320 exit
5291 5321 ;;
5292 5322
5293 5323 *)
5294 5324 break
5295 5325 ;;
5296 5326
5297 5327 esac
5298 5328 done
5299 5329
5300 5330 # :command.command_filter
5301 5331 action="stack-upgrade services"
5302 5332
5303 5333 # :command.parse_requirements_while
5304 5334 while [[ $# -gt 0 ]]; do
5305 5335 key="$1"
5306 5336 case "$key" in
5307 5337
5308 5338 -?*)
5309 5339 printf "invalid option: %s\n" "$key" >&2
5310 5340 exit 1
5311 5341 ;;
5312 5342
5313 5343 *)
5314 5344 # :command.parse_requirements_case
5315 5345 # :command.parse_requirements_case_simple
5316 5346 printf "invalid argument: %s\n" "$key" >&2
5317 5347 exit 1
5318 5348
5319 5349 ;;
5320 5350
5321 5351 esac
5322 5352 done
5323 5353
5324 5354 }
5325 5355
5326 5356 # :command.parse_requirements
5327 5357 rcstack_stack_upgrade_rhodecode_parse_requirements() {
5328 5358 # :command.fixed_flags_filter
5329 5359 while [[ $# -gt 0 ]]; do
5330 5360 case "${1:-}" in
5331 5361 --help | -h)
5332 5362 long_usage=yes
5333 5363 rcstack_stack_upgrade_rhodecode_usage
5334 5364 exit
5335 5365 ;;
5336 5366
5337 5367 *)
5338 5368 break
5339 5369 ;;
5340 5370
5341 5371 esac
5342 5372 done
5343 5373
5344 5374 # :command.command_filter
5345 5375 action="stack-upgrade rhodecode"
5346 5376
5347 5377 # :command.parse_requirements_while
5348 5378 while [[ $# -gt 0 ]]; do
5349 5379 key="$1"
5350 5380 case "$key" in
5351 5381 # :flag.case
5352 5382 --stop-wait)
5353 5383
5354 5384 # :flag.case_arg
5355 5385 if [[ -n ${2+x} ]]; then
5356 5386
5357 5387 args['--stop-wait']="$2"
5358 5388 shift
5359 5389 shift
5360 5390 else
5361 5391 printf "%s\n" "--stop-wait requires an argument: --stop-wait STOP_WAIT" >&2
5362 5392 exit 1
5363 5393 fi
5364 5394 ;;
5365 5395
5366 5396 # :flag.case
5367 5397 --docker-stop-wait)
5368 5398
5369 5399 # :flag.case_arg
5370 5400 if [[ -n ${2+x} ]]; then
5371 5401
5372 5402 args['--docker-stop-wait']="$2"
5373 5403 shift
5374 5404 shift
5375 5405 else
5376 5406 printf "%s\n" "--docker-stop-wait requires an argument: --docker-stop-wait DOCKER_STOP_WAIT" >&2
5377 5407 exit 1
5378 5408 fi
5379 5409 ;;
5380 5410
5381 5411 -?*)
5382 5412 printf "invalid option: %s\n" "$key" >&2
5383 5413 exit 1
5384 5414 ;;
5385 5415
5386 5416 *)
5387 5417 # :command.parse_requirements_case
5388 5418 # :command.parse_requirements_case_simple
5389 5419 printf "invalid argument: %s\n" "$key" >&2
5390 5420 exit 1
5391 5421
5392 5422 ;;
5393 5423
5394 5424 esac
5395 5425 done
5396 5426
5397 5427 # :command.default_assignments
5398 5428 [[ -n ${args['--stop-wait']:-} ]] || args['--stop-wait']="120"
5399 5429 [[ -n ${args['--docker-stop-wait']:-} ]] || args['--docker-stop-wait']="3600"
5400 5430
5401 5431 }
5402 5432
5403 5433 # :command.parse_requirements
5404 5434 rcstack_stack_monitor_parse_requirements() {
5405 5435 # :command.fixed_flags_filter
5406 5436 while [[ $# -gt 0 ]]; do
5407 5437 case "${1:-}" in
5408 5438 --help | -h)
5409 5439 long_usage=yes
5410 5440 rcstack_stack_monitor_usage
5411 5441 exit
5412 5442 ;;
5413 5443
5414 5444 *)
5415 5445 break
5416 5446 ;;
5417 5447
5418 5448 esac
5419 5449 done
5420 5450
5421 5451 # :command.command_filter
5422 5452 action=${1:-}
5423 5453
5424 5454 case $action in
5425 5455 -*) ;;
5426 5456
5427 5457 restart-unhealthy)
5428 5458 action="restart-unhealthy"
5429 5459 shift
5430 5460 rcstack_stack_monitor_restart_unhealthy_parse_requirements "$@"
5431 5461 shift $#
5432 5462 ;;
5433 5463
5434 5464 # :command.command_fallback
5435 5465 "")
5436 5466 rcstack_stack_monitor_usage >&2
5437 5467 exit 1
5438 5468 ;;
5439 5469
5440 5470 *)
5441 5471 printf "invalid command: %s\n" "$action" >&2
5442 5472 exit 1
5443 5473 ;;
5444 5474
5445 5475 esac
5446 5476
5447 5477 # :command.parse_requirements_while
5448 5478 while [[ $# -gt 0 ]]; do
5449 5479 key="$1"
5450 5480 case "$key" in
5451 5481
5452 5482 -?*)
5453 5483 printf "invalid option: %s\n" "$key" >&2
5454 5484 exit 1
5455 5485 ;;
5456 5486
5457 5487 *)
5458 5488 # :command.parse_requirements_case
5459 5489 # :command.parse_requirements_case_simple
5460 5490 printf "invalid argument: %s\n" "$key" >&2
5461 5491 exit 1
5462 5492
5463 5493 ;;
5464 5494
5465 5495 esac
5466 5496 done
5467 5497
5468 5498 }
5469 5499
5470 5500 # :command.parse_requirements
5471 5501 rcstack_stack_monitor_restart_unhealthy_parse_requirements() {
5472 5502 # :command.fixed_flags_filter
5473 5503 while [[ $# -gt 0 ]]; do
5474 5504 case "${1:-}" in
5475 5505 --help | -h)
5476 5506 long_usage=yes
5477 5507 rcstack_stack_monitor_restart_unhealthy_usage
5478 5508 exit
5479 5509 ;;
5480 5510
5481 5511 *)
5482 5512 break
5483 5513 ;;
5484 5514
5485 5515 esac
5486 5516 done
5487 5517
5488 5518 # :command.command_filter
5489 5519 action="stack-monitor restart-unhealthy"
5490 5520
5491 5521 # :command.parse_requirements_while
5492 5522 while [[ $# -gt 0 ]]; do
5493 5523 key="$1"
5494 5524 case "$key" in
5495 5525 # :flag.case
5496 5526 --loop)
5497 5527
5498 5528 # :flag.case_arg
5499 5529 if [[ -n ${2+x} ]]; then
5500 5530 # :flag.validations
5501 5531 if [[ -n $(validate_integer "$2") ]]; then
5502 5532 printf "validation error in %s:\n%s\n" "--loop LOOP" "$(validate_integer "$2")" >&2
5503 5533 exit 1
5504 5534 fi
5505 5535
5506 5536 args['--loop']="$2"
5507 5537 shift
5508 5538 shift
5509 5539 else
5510 5540 printf "%s\n" "--loop requires an argument: --loop LOOP" >&2
5511 5541 exit 1
5512 5542 fi
5513 5543 ;;
5514 5544
5515 5545 -?*)
5516 5546 printf "invalid option: %s\n" "$key" >&2
5517 5547 exit 1
5518 5548 ;;
5519 5549
5520 5550 *)
5521 5551 # :command.parse_requirements_case
5522 5552 # :command.parse_requirements_case_simple
5523 5553 printf "invalid argument: %s\n" "$key" >&2
5524 5554 exit 1
5525 5555
5526 5556 ;;
5527 5557
5528 5558 esac
5529 5559 done
5530 5560
5531 5561 # :command.default_assignments
5532 5562 [[ -n ${args['--loop']:-} ]] || args['--loop']="0"
5533 5563
5534 5564 }
5535 5565
5536 5566 # :command.parse_requirements
5537 5567 rcstack_cli_parse_requirements() {
5538 5568 # :command.fixed_flags_filter
5539 5569 while [[ $# -gt 0 ]]; do
5540 5570 case "${1:-}" in
5541 5571 --help | -h)
5542 5572 long_usage=yes
5543 5573 rcstack_cli_usage
5544 5574 exit
5545 5575 ;;
5546 5576
5547 5577 *)
5548 5578 break
5549 5579 ;;
5550 5580
5551 5581 esac
5552 5582 done
5553 5583
5554 5584 # :command.command_filter
5555 5585 action=${1:-}
5556 5586
5557 5587 case $action in
5558 5588 -*) ;;
5559 5589
5560 5590 image-info)
5561 5591 action="image-info"
5562 5592 shift
5563 5593 rcstack_cli_image_info_parse_requirements "$@"
5564 5594 shift $#
5565 5595 ;;
5566 5596
5567 5597 set-runtime-image)
5568 5598 action="set-runtime-image"
5569 5599 shift
5570 5600 rcstack_cli_set_runtime_image_parse_requirements "$@"
5571 5601 shift $#
5572 5602 ;;
5573 5603
5574 5604 ishell)
5575 5605 action="ishell"
5576 5606 shift
5577 5607 rcstack_cli_ishell_parse_requirements "$@"
5578 5608 shift $#
5579 5609 ;;
5580 5610
5581 5611 redis)
5582 5612 action="redis"
5583 5613 shift
5584 5614 rcstack_cli_redis_parse_requirements "$@"
5585 5615 shift $#
5586 5616 ;;
5587 5617
5588 5618 db)
5589 5619 action="db"
5590 5620 shift
5591 5621 rcstack_cli_db_parse_requirements "$@"
5592 5622 shift $#
5593 5623 ;;
5594 5624
5595 5625 db-upgrade)
5596 5626 action="db-upgrade"
5597 5627 shift
5598 5628 rcstack_cli_db_upgrade_parse_requirements "$@"
5599 5629 shift $#
5600 5630 ;;
5601 5631
5602 5632 storage)
5603 5633 action="storage"
5604 5634 shift
5605 5635 rcstack_cli_storage_parse_requirements "$@"
5606 5636 shift $#
5607 5637 ;;
5608 5638
5609 5639 attach)
5610 5640 action="attach"
5611 5641 shift
5612 5642 rcstack_cli_attach_parse_requirements "$@"
5613 5643 shift $#
5614 5644 ;;
5615 5645
5616 5646 set-edition)
5617 5647 action="set-edition"
5618 5648 shift
5619 5649 rcstack_cli_set_edition_parse_requirements "$@"
5620 5650 shift $#
5621 5651 ;;
5622 5652
5623 5653 configure-vcsserver)
5624 5654 action="configure-vcsserver"
5625 5655 shift
5626 5656 rcstack_cli_configure_vcsserver_parse_requirements "$@"
5627 5657 shift $#
5628 5658 ;;
5629 5659
5630 5660 configure-rhodecode)
5631 5661 action="configure-rhodecode"
5632 5662 shift
5633 5663 rcstack_cli_configure_rhodecode_parse_requirements "$@"
5634 5664 shift $#
5635 5665 ;;
5636 5666
5637 5667 # :command.command_fallback
5638 5668 "")
5639 5669 rcstack_cli_usage >&2
5640 5670 exit 1
5641 5671 ;;
5642 5672
5643 5673 *)
5644 5674 printf "invalid command: %s\n" "$action" >&2
5645 5675 exit 1
5646 5676 ;;
5647 5677
5648 5678 esac
5649 5679
5650 5680 # :command.parse_requirements_while
5651 5681 while [[ $# -gt 0 ]]; do
5652 5682 key="$1"
5653 5683 case "$key" in
5654 5684
5655 5685 -?*)
5656 5686 printf "invalid option: %s\n" "$key" >&2
5657 5687 exit 1
5658 5688 ;;
5659 5689
5660 5690 *)
5661 5691 # :command.parse_requirements_case
5662 5692 # :command.parse_requirements_case_simple
5663 5693 printf "invalid argument: %s\n" "$key" >&2
5664 5694 exit 1
5665 5695
5666 5696 ;;
5667 5697
5668 5698 esac
5669 5699 done
5670 5700
5671 5701 }
5672 5702
5673 5703 # :command.parse_requirements
5674 5704 rcstack_cli_image_info_parse_requirements() {
5675 5705 # :command.fixed_flags_filter
5676 5706 while [[ $# -gt 0 ]]; do
5677 5707 case "${1:-}" in
5678 5708 --help | -h)
5679 5709 long_usage=yes
5680 5710 rcstack_cli_image_info_usage
5681 5711 exit
5682 5712 ;;
5683 5713
5684 5714 *)
5685 5715 break
5686 5716 ;;
5687 5717
5688 5718 esac
5689 5719 done
5690 5720
5691 5721 # :command.command_filter
5692 5722 action="cli image-info"
5693 5723
5694 5724 # :command.parse_requirements_while
5695 5725 while [[ $# -gt 0 ]]; do
5696 5726 key="$1"
5697 5727 case "$key" in
5698 5728 # :flag.case
5699 5729 --verbose)
5700 5730
5701 5731 # :flag.case_no_arg
5702 5732 args['--verbose']=1
5703 5733 shift
5704 5734 ;;
5705 5735
5706 5736 -?*)
5707 5737 printf "invalid option: %s\n" "$key" >&2
5708 5738 exit 1
5709 5739 ;;
5710 5740
5711 5741 *)
5712 5742 # :command.parse_requirements_case
5713 5743 # :command.parse_requirements_case_simple
5714 5744 printf "invalid argument: %s\n" "$key" >&2
5715 5745 exit 1
5716 5746
5717 5747 ;;
5718 5748
5719 5749 esac
5720 5750 done
5721 5751
5722 5752 }
5723 5753
5724 5754 # :command.parse_requirements
5725 5755 rcstack_cli_set_runtime_image_parse_requirements() {
5726 5756 # :command.fixed_flags_filter
5727 5757 while [[ $# -gt 0 ]]; do
5728 5758 case "${1:-}" in
5729 5759 --help | -h)
5730 5760 long_usage=yes
5731 5761 rcstack_cli_set_runtime_image_usage
5732 5762 exit
5733 5763 ;;
5734 5764
5735 5765 *)
5736 5766 break
5737 5767 ;;
5738 5768
5739 5769 esac
5740 5770 done
5741 5771
5742 5772 # :command.command_filter
5743 5773 action="cli set-runtime-image"
5744 5774
5745 5775 # :command.parse_requirements_while
5746 5776 while [[ $# -gt 0 ]]; do
5747 5777 key="$1"
5748 5778 case "$key" in
5749 5779
5750 5780 -?*)
5751 5781 printf "invalid option: %s\n" "$key" >&2
5752 5782 exit 1
5753 5783 ;;
5754 5784
5755 5785 *)
5756 5786 # :command.parse_requirements_case
5757 5787 # :command.parse_requirements_case_simple
5758 5788 if [[ -z ${args['version']+x} ]]; then
5759 5789
5760 5790 args['version']=$1
5761 5791 shift
5762 5792 else
5763 5793 printf "invalid argument: %s\n" "$key" >&2
5764 5794 exit 1
5765 5795 fi
5766 5796
5767 5797 ;;
5768 5798
5769 5799 esac
5770 5800 done
5771 5801
5772 5802 # :command.required_args_filter
5773 5803 if [[ -z ${args['version']+x} ]]; then
5774 5804 printf "missing required argument: VERSION\nusage: rcstack cli set-runtime-image VERSION\n" >&2
5775 5805 exit 1
5776 5806 fi
5777 5807
5778 5808 }
5779 5809
5780 5810 # :command.parse_requirements
5781 5811 rcstack_cli_ishell_parse_requirements() {
5782 5812 # :command.fixed_flags_filter
5783 5813 while [[ $# -gt 0 ]]; do
5784 5814 case "${1:-}" in
5785 5815 --help | -h)
5786 5816 long_usage=yes
5787 5817 rcstack_cli_ishell_usage
5788 5818 exit
5789 5819 ;;
5790 5820
5791 5821 *)
5792 5822 break
5793 5823 ;;
5794 5824
5795 5825 esac
5796 5826 done
5797 5827
5798 5828 # :command.command_filter
5799 5829 action="cli ishell"
5800 5830
5801 5831 # :command.parse_requirements_while
5802 5832 while [[ $# -gt 0 ]]; do
5803 5833 key="$1"
5804 5834 case "$key" in
5805 5835
5806 5836 -?*)
5807 5837 printf "invalid option: %s\n" "$key" >&2
5808 5838 exit 1
5809 5839 ;;
5810 5840
5811 5841 *)
5812 5842 # :command.parse_requirements_case
5813 5843 # :command.parse_requirements_case_simple
5814 5844 printf "invalid argument: %s\n" "$key" >&2
5815 5845 exit 1
5816 5846
5817 5847 ;;
5818 5848
5819 5849 esac
5820 5850 done
5821 5851
5822 5852 }
5823 5853
5824 5854 # :command.parse_requirements
5825 5855 rcstack_cli_redis_parse_requirements() {
5826 5856 # :command.fixed_flags_filter
5827 5857 while [[ $# -gt 0 ]]; do
5828 5858 case "${1:-}" in
5829 5859 --help | -h)
5830 5860 long_usage=yes
5831 5861 rcstack_cli_redis_usage
5832 5862 exit
5833 5863 ;;
5834 5864
5835 5865 *)
5836 5866 break
5837 5867 ;;
5838 5868
5839 5869 esac
5840 5870 done
5841 5871
5842 5872 # :command.command_filter
5843 5873 action="cli redis"
5844 5874
5845 5875 # :command.parse_requirements_while
5846 5876 while [[ $# -gt 0 ]]; do
5847 5877 key="$1"
5848 5878 case "$key" in
5849 5879
5850 5880 -?*)
5851 5881 printf "invalid option: %s\n" "$key" >&2
5852 5882 exit 1
5853 5883 ;;
5854 5884
5855 5885 *)
5856 5886 # :command.parse_requirements_case
5857 5887 # :command.parse_requirements_case_simple
5858 5888 printf "invalid argument: %s\n" "$key" >&2
5859 5889 exit 1
5860 5890
5861 5891 ;;
5862 5892
5863 5893 esac
5864 5894 done
5865 5895
5866 5896 }
5867 5897
5868 5898 # :command.parse_requirements
5869 5899 rcstack_cli_db_parse_requirements() {
5870 5900 # :command.fixed_flags_filter
5871 5901 while [[ $# -gt 0 ]]; do
5872 5902 case "${1:-}" in
5873 5903 --help | -h)
5874 5904 long_usage=yes
5875 5905 rcstack_cli_db_usage
5876 5906 exit
5877 5907 ;;
5878 5908
5879 5909 *)
5880 5910 break
5881 5911 ;;
5882 5912
5883 5913 esac
5884 5914 done
5885 5915
5886 5916 # :command.command_filter
5887 5917 action="cli db"
5888 5918
5889 5919 # :command.parse_requirements_while
5890 5920 while [[ $# -gt 0 ]]; do
5891 5921 key="$1"
5892 5922 case "$key" in
5893 5923
5894 5924 -?*)
5895 5925 printf "invalid option: %s\n" "$key" >&2
5896 5926 exit 1
5897 5927 ;;
5898 5928
5899 5929 *)
5900 5930 # :command.parse_requirements_case
5901 5931 # :command.parse_requirements_case_simple
5902 5932 printf "invalid argument: %s\n" "$key" >&2
5903 5933 exit 1
5904 5934
5905 5935 ;;
5906 5936
5907 5937 esac
5908 5938 done
5909 5939
5910 5940 }
5911 5941
5912 5942 # :command.parse_requirements
5913 5943 rcstack_cli_db_upgrade_parse_requirements() {
5914 5944 # :command.fixed_flags_filter
5915 5945 while [[ $# -gt 0 ]]; do
5916 5946 case "${1:-}" in
5917 5947 --help | -h)
5918 5948 long_usage=yes
5919 5949 rcstack_cli_db_upgrade_usage
5920 5950 exit
5921 5951 ;;
5922 5952
5923 5953 *)
5924 5954 break
5925 5955 ;;
5926 5956
5927 5957 esac
5928 5958 done
5929 5959
5930 5960 # :command.command_filter
5931 5961 action="cli db-upgrade"
5932 5962
5933 5963 # :command.parse_requirements_while
5934 5964 while [[ $# -gt 0 ]]; do
5935 5965 key="$1"
5936 5966 case "$key" in
5937 5967
5938 5968 -?*)
5939 5969 printf "invalid option: %s\n" "$key" >&2
5940 5970 exit 1
5941 5971 ;;
5942 5972
5943 5973 *)
5944 5974 # :command.parse_requirements_case
5945 5975 # :command.parse_requirements_case_simple
5946 5976 printf "invalid argument: %s\n" "$key" >&2
5947 5977 exit 1
5948 5978
5949 5979 ;;
5950 5980
5951 5981 esac
5952 5982 done
5953 5983
5954 5984 }
5955 5985
5956 5986 # :command.parse_requirements
5957 5987 rcstack_cli_storage_parse_requirements() {
5958 5988 # :command.fixed_flags_filter
5959 5989 while [[ $# -gt 0 ]]; do
5960 5990 case "${1:-}" in
5961 5991 --help | -h)
5962 5992 long_usage=yes
5963 5993 rcstack_cli_storage_usage
5964 5994 exit
5965 5995 ;;
5966 5996
5967 5997 *)
5968 5998 break
5969 5999 ;;
5970 6000
5971 6001 esac
5972 6002 done
5973 6003
5974 6004 # :command.command_filter
5975 6005 action="cli storage"
5976 6006
5977 6007 # :command.parse_requirements_while
5978 6008 while [[ $# -gt 0 ]]; do
5979 6009 key="$1"
5980 6010 case "$key" in
5981 6011 # :flag.case
5982 6012 --attached)
5983 6013
5984 6014 # :flag.case_arg
5985 6015 if [[ -n ${2+x} ]]; then
5986 6016
5987 6017 args['--attached']="$2"
5988 6018 shift
5989 6019 shift
5990 6020 else
5991 6021 printf "%s\n" "--attached requires an argument: --attached ATTACHED" >&2
5992 6022 exit 1
5993 6023 fi
5994 6024 ;;
5995 6025
5996 6026 -?*)
5997 6027 printf "invalid option: %s\n" "$key" >&2
5998 6028 exit 1
5999 6029 ;;
6000 6030
6001 6031 *)
6002 6032 # :command.parse_requirements_case
6003 6033 # :command.parse_requirements_case_simple
6004 6034 printf "invalid argument: %s\n" "$key" >&2
6005 6035 exit 1
6006 6036
6007 6037 ;;
6008 6038
6009 6039 esac
6010 6040 done
6011 6041
6012 6042 }
6013 6043
6014 6044 # :command.parse_requirements
6015 6045 rcstack_cli_attach_parse_requirements() {
6016 6046 # :command.fixed_flags_filter
6017 6047 while [[ $# -gt 0 ]]; do
6018 6048 case "${1:-}" in
6019 6049 --help | -h)
6020 6050 long_usage=yes
6021 6051 rcstack_cli_attach_usage
6022 6052 exit
6023 6053 ;;
6024 6054
6025 6055 *)
6026 6056 break
6027 6057 ;;
6028 6058
6029 6059 esac
6030 6060 done
6031 6061
6032 6062 # :command.command_filter
6033 6063 action="cli attach"
6034 6064
6035 6065 # :command.parse_requirements_while
6036 6066 while [[ $# -gt 0 ]]; do
6037 6067 key="$1"
6038 6068 case "$key" in
6039 6069 # :flag.case
6040 6070 --instance-type)
6041 6071
6042 6072 # :flag.case_arg
6043 6073 if [[ -n ${2+x} ]]; then
6044 6074
6045 6075 args['--instance-type']="$2"
6046 6076 shift
6047 6077 shift
6048 6078 else
6049 6079 printf "%s\n" "--instance-type requires an argument: --instance-type INSTANCE_TYPE" >&2
6050 6080 exit 1
6051 6081 fi
6052 6082 ;;
6053 6083
6054 6084 -?*)
6055 6085 printf "invalid option: %s\n" "$key" >&2
6056 6086 exit 1
6057 6087 ;;
6058 6088
6059 6089 *)
6060 6090 # :command.parse_requirements_case
6061 6091 # :command.parse_requirements_case_simple
6062 6092 printf "invalid argument: %s\n" "$key" >&2
6063 6093 exit 1
6064 6094
6065 6095 ;;
6066 6096
6067 6097 esac
6068 6098 done
6069 6099
6070 6100 # :command.default_assignments
6071 6101 [[ -n ${args['--instance-type']:-} ]] || args['--instance-type']="rhodecode"
6072 6102
6073 6103 }
6074 6104
6075 6105 # :command.parse_requirements
6076 6106 rcstack_cli_set_edition_parse_requirements() {
6077 6107 # :command.fixed_flags_filter
6078 6108 while [[ $# -gt 0 ]]; do
6079 6109 case "${1:-}" in
6080 6110 --help | -h)
6081 6111 long_usage=yes
6082 6112 rcstack_cli_set_edition_usage
6083 6113 exit
6084 6114 ;;
6085 6115
6086 6116 *)
6087 6117 break
6088 6118 ;;
6089 6119
6090 6120 esac
6091 6121 done
6092 6122
6093 6123 # :command.command_filter
6094 6124 action="cli set-edition"
6095 6125
6096 6126 # :command.parse_requirements_while
6097 6127 while [[ $# -gt 0 ]]; do
6098 6128 key="$1"
6099 6129 case "$key" in
6100 6130
6101 6131 -?*)
6102 6132 printf "invalid option: %s\n" "$key" >&2
6103 6133 exit 1
6104 6134 ;;
6105 6135
6106 6136 *)
6107 6137 # :command.parse_requirements_case
6108 6138 # :command.parse_requirements_case_simple
6109 6139 if [[ -z ${args['edition_type']+x} ]]; then
6110 6140
6111 6141 args['edition_type']=$1
6112 6142 shift
6113 6143 else
6114 6144 printf "invalid argument: %s\n" "$key" >&2
6115 6145 exit 1
6116 6146 fi
6117 6147
6118 6148 ;;
6119 6149
6120 6150 esac
6121 6151 done
6122 6152
6123 6153 # :command.required_args_filter
6124 6154 if [[ -z ${args['edition_type']+x} ]]; then
6125 6155 printf "missing required argument: EDITION_TYPE\nusage: rcstack cli set-edition EDITION_TYPE\n" >&2
6126 6156 exit 1
6127 6157 fi
6128 6158
6129 6159 # :command.whitelist_filter
6130 6160 if [[ -n ${args['edition_type']} ]] && [[ ! ${args['edition_type']} =~ ^(ce|ee)$ ]]; then
6131 6161 printf "%s\n" "edition_type must be one of: ce, ee" >&2
6132 6162 exit 1
6133 6163 fi
6134 6164
6135 6165 }
6136 6166
6137 6167 # :command.parse_requirements
6138 6168 rcstack_cli_configure_vcsserver_parse_requirements() {
6139 6169 # :command.fixed_flags_filter
6140 6170 while [[ $# -gt 0 ]]; do
6141 6171 case "${1:-}" in
6142 6172 --help | -h)
6143 6173 long_usage=yes
6144 6174 rcstack_cli_configure_vcsserver_usage
6145 6175 exit
6146 6176 ;;
6147 6177
6148 6178 *)
6149 6179 break
6150 6180 ;;
6151 6181
6152 6182 esac
6153 6183 done
6154 6184
6155 6185 # :command.command_filter
6156 6186 action="cli configure-vcsserver"
6157 6187
6158 6188 # :command.parse_requirements_while
6159 6189 while [[ $# -gt 0 ]]; do
6160 6190 key="$1"
6161 6191 case "$key" in
6162 6192
6163 6193 -?*)
6164 6194 printf "invalid option: %s\n" "$key" >&2
6165 6195 exit 1
6166 6196 ;;
6167 6197
6168 6198 *)
6169 6199 # :command.parse_requirements_case
6170 6200 # :command.parse_requirements_case_simple
6171 6201 if [[ -z ${args['ini_path']+x} ]]; then
6172 6202 # :argument.validations
6173 6203 if [[ -n $(validate_file_exists "$1") ]]; then
6174 6204 printf "validation error in %s:\n%s\n" "INI_PATH" "$(validate_file_exists "$1")" >&2
6175 6205 exit 1
6176 6206 fi
6177 6207
6178 6208 args['ini_path']=$1
6179 6209 shift
6180 6210 else
6181 6211 printf "invalid argument: %s\n" "$key" >&2
6182 6212 exit 1
6183 6213 fi
6184 6214
6185 6215 ;;
6186 6216
6187 6217 esac
6188 6218 done
6189 6219
6190 6220 # :command.required_args_filter
6191 6221 if [[ -z ${args['ini_path']+x} ]]; then
6192 6222 printf "missing required argument: INI_PATH\nusage: rcstack cli configure-vcsserver INI_PATH\n" >&2
6193 6223 exit 1
6194 6224 fi
6195 6225
6196 6226 }
6197 6227
6198 6228 # :command.parse_requirements
6199 6229 rcstack_cli_configure_rhodecode_parse_requirements() {
6200 6230 # :command.fixed_flags_filter
6201 6231 while [[ $# -gt 0 ]]; do
6202 6232 case "${1:-}" in
6203 6233 --help | -h)
6204 6234 long_usage=yes
6205 6235 rcstack_cli_configure_rhodecode_usage
6206 6236 exit
6207 6237 ;;
6208 6238
6209 6239 *)
6210 6240 break
6211 6241 ;;
6212 6242
6213 6243 esac
6214 6244 done
6215 6245
6216 6246 # :command.command_filter
6217 6247 action="cli configure-rhodecode"
6218 6248
6219 6249 # :command.parse_requirements_while
6220 6250 while [[ $# -gt 0 ]]; do
6221 6251 key="$1"
6222 6252 case "$key" in
6223 6253
6224 6254 -?*)
6225 6255 printf "invalid option: %s\n" "$key" >&2
6226 6256 exit 1
6227 6257 ;;
6228 6258
6229 6259 *)
6230 6260 # :command.parse_requirements_case
6231 6261 # :command.parse_requirements_case_simple
6232 6262 if [[ -z ${args['ini_path']+x} ]]; then
6233 6263 # :argument.validations
6234 6264 if [[ -n $(validate_file_exists "$1") ]]; then
6235 6265 printf "validation error in %s:\n%s\n" "INI_PATH" "$(validate_file_exists "$1")" >&2
6236 6266 exit 1
6237 6267 fi
6238 6268
6239 6269 args['ini_path']=$1
6240 6270 shift
6241 6271 else
6242 6272 printf "invalid argument: %s\n" "$key" >&2
6243 6273 exit 1
6244 6274 fi
6245 6275
6246 6276 ;;
6247 6277
6248 6278 esac
6249 6279 done
6250 6280
6251 6281 # :command.required_args_filter
6252 6282 if [[ -z ${args['ini_path']+x} ]]; then
6253 6283 printf "missing required argument: INI_PATH\nusage: rcstack cli configure-rhodecode INI_PATH\n" >&2
6254 6284 exit 1
6255 6285 fi
6256 6286
6257 6287 }
6258 6288
6259 6289 # :command.parse_requirements
6260 6290 rcstack_backup_db_parse_requirements() {
6261 6291 # :command.fixed_flags_filter
6262 6292 while [[ $# -gt 0 ]]; do
6263 6293 case "${1:-}" in
6264 6294 --help | -h)
6265 6295 long_usage=yes
6266 6296 rcstack_backup_db_usage
6267 6297 exit
6268 6298 ;;
6269 6299
6270 6300 *)
6271 6301 break
6272 6302 ;;
6273 6303
6274 6304 esac
6275 6305 done
6276 6306
6277 6307 # :command.dependencies_filter
6278 6308 if command -v tar >/dev/null 2>&1; then
6279 6309 deps['tar']="$(command -v tar | head -n1)"
6280 6310 else
6281 6311 printf "missing dependency: tar\n" >&2
6282 6312 exit 1
6283 6313 fi
6284 6314
6285 6315 if command -v gzip >/dev/null 2>&1; then
6286 6316 deps['gzip']="$(command -v gzip | head -n1)"
6287 6317 else
6288 6318 printf "missing dependency: gzip\n" >&2
6289 6319 exit 1
6290 6320 fi
6291 6321
6292 6322 # :command.command_filter
6293 6323 action="backup-db"
6294 6324
6295 6325 # :command.parse_requirements_while
6296 6326 while [[ $# -gt 0 ]]; do
6297 6327 key="$1"
6298 6328 case "$key" in
6299 6329
6300 6330 -?*)
6301 6331 printf "invalid option: %s\n" "$key" >&2
6302 6332 exit 1
6303 6333 ;;
6304 6334
6305 6335 *)
6306 6336 # :command.parse_requirements_case
6307 6337 # :command.parse_requirements_case_simple
6308 6338 printf "invalid argument: %s\n" "$key" >&2
6309 6339 exit 1
6310 6340
6311 6341 ;;
6312 6342
6313 6343 esac
6314 6344 done
6315 6345
6316 6346 }
6317 6347
6318 6348 # :command.parse_requirements
6319 6349 rcstack_backup_data_parse_requirements() {
6320 6350 # :command.fixed_flags_filter
6321 6351 while [[ $# -gt 0 ]]; do
6322 6352 case "${1:-}" in
6323 6353 --help | -h)
6324 6354 long_usage=yes
6325 6355 rcstack_backup_data_usage
6326 6356 exit
6327 6357 ;;
6328 6358
6329 6359 *)
6330 6360 break
6331 6361 ;;
6332 6362
6333 6363 esac
6334 6364 done
6335 6365
6336 6366 # :command.dependencies_filter
6337 6367 if command -v tar >/dev/null 2>&1; then
6338 6368 deps['tar']="$(command -v tar | head -n1)"
6339 6369 else
6340 6370 printf "missing dependency: tar\n" >&2
6341 6371 exit 1
6342 6372 fi
6343 6373
6344 6374 if command -v gzip >/dev/null 2>&1; then
6345 6375 deps['gzip']="$(command -v gzip | head -n1)"
6346 6376 else
6347 6377 printf "missing dependency: gzip\n" >&2
6348 6378 exit 1
6349 6379 fi
6350 6380
6351 6381 # :command.command_filter
6352 6382 action="backup-data"
6353 6383
6354 6384 # :command.parse_requirements_while
6355 6385 while [[ $# -gt 0 ]]; do
6356 6386 key="$1"
6357 6387 case "$key" in
6358 6388
6359 6389 -?*)
6360 6390 printf "invalid option: %s\n" "$key" >&2
6361 6391 exit 1
6362 6392 ;;
6363 6393
6364 6394 *)
6365 6395 # :command.parse_requirements_case
6366 6396 # :command.parse_requirements_case_simple
6367 6397 printf "invalid argument: %s\n" "$key" >&2
6368 6398 exit 1
6369 6399
6370 6400 ;;
6371 6401
6372 6402 esac
6373 6403 done
6374 6404
6375 6405 }
6376 6406
6377 6407 # :command.parse_requirements
6378 6408 rcstack_get_build_artifacts_parse_requirements() {
6379 6409 # :command.fixed_flags_filter
6380 6410 while [[ $# -gt 0 ]]; do
6381 6411 case "${1:-}" in
6382 6412 --help | -h)
6383 6413 long_usage=yes
6384 6414 rcstack_get_build_artifacts_usage
6385 6415 exit
6386 6416 ;;
6387 6417
6388 6418 *)
6389 6419 break
6390 6420 ;;
6391 6421
6392 6422 esac
6393 6423 done
6394 6424
6395 6425 # :command.command_filter
6396 6426 action="get-build-artifacts"
6397 6427
6398 6428 # :command.parse_requirements_while
6399 6429 while [[ $# -gt 0 ]]; do
6400 6430 key="$1"
6401 6431 case "$key" in
6402 6432 # :flag.case
6403 6433 --auth)
6404 6434
6405 6435 # :flag.case_arg
6406 6436 if [[ -n ${2+x} ]]; then
6407 6437
6408 6438 args['--auth']="$2"
6409 6439 shift
6410 6440 shift
6411 6441 else
6412 6442 printf "%s\n" "--auth requires an argument: --auth AUTH" >&2
6413 6443 exit 1
6414 6444 fi
6415 6445 ;;
6416 6446
6417 6447 # :flag.case
6418 6448 --installer-url)
6419 6449
6420 6450 # :flag.case_arg
6421 6451 if [[ -n ${2+x} ]]; then
6422 6452
6423 6453 args['--installer-url']="$2"
6424 6454 shift
6425 6455 shift
6426 6456 else
6427 6457 printf "%s\n" "--installer-url requires an argument: --installer-url INSTALLER_URL" >&2
6428 6458 exit 1
6429 6459 fi
6430 6460 ;;
6431 6461
6432 6462 # :flag.case
6433 6463 --manifest-url)
6434 6464
6435 6465 # :flag.case_arg
6436 6466 if [[ -n ${2+x} ]]; then
6437 6467
6438 6468 args['--manifest-url']="$2"
6439 6469 shift
6440 6470 shift
6441 6471 else
6442 6472 printf "%s\n" "--manifest-url requires an argument: --manifest-url MANIFEST_URL" >&2
6443 6473 exit 1
6444 6474 fi
6445 6475 ;;
6446 6476
6447 6477 # :flag.case
6448 6478 --version-name)
6449 6479
6450 6480 # :flag.case_arg
6451 6481 if [[ -n ${2+x} ]]; then
6452 6482
6453 6483 args['--version-name']="$2"
6454 6484 shift
6455 6485 shift
6456 6486 else
6457 6487 printf "%s\n" "--version-name requires an argument: --version-name VERSION_NAME" >&2
6458 6488 exit 1
6459 6489 fi
6460 6490 ;;
6461 6491
6462 6492 -?*)
6463 6493 printf "invalid option: %s\n" "$key" >&2
6464 6494 exit 1
6465 6495 ;;
6466 6496
6467 6497 *)
6468 6498 # :command.parse_requirements_case
6469 6499 # :command.parse_requirements_case_simple
6470 6500 printf "invalid argument: %s\n" "$key" >&2
6471 6501 exit 1
6472 6502
6473 6503 ;;
6474 6504
6475 6505 esac
6476 6506 done
6477 6507
6478 6508 # :command.default_assignments
6479 6509 [[ -n ${args['--auth']:-} ]] || args['--auth']=""
6480 6510 [[ -n ${args['--installer-url']:-} ]] || args['--installer-url']="https://dls.rhodecode.com/dls/N2E2ZTY1NzA3NjYxNDA2NTc1NjI3MTcyNzA2MjcxNzIyZTcwNjI3YQ==/rhodecode-control/latest-linux-ee"
6481 6511 [[ -n ${args['--manifest-url']:-} ]] || args['--manifest-url']="https://dls.rhodecode.com/linux/MANIFEST"
6482 6512 [[ -n ${args['--version-name']:-} ]] || args['--version-name']="$RC_CLI_VERSION_NAME"
6483 6513
6484 6514 }
6485 6515
6486 6516 # :command.parse_requirements
6487 6517 rcstack_build_installer_parse_requirements() {
6488 6518 # :command.fixed_flags_filter
6489 6519 while [[ $# -gt 0 ]]; do
6490 6520 case "${1:-}" in
6491 6521 --help | -h)
6492 6522 long_usage=yes
6493 6523 rcstack_build_installer_usage
6494 6524 exit
6495 6525 ;;
6496 6526
6497 6527 *)
6498 6528 break
6499 6529 ;;
6500 6530
6501 6531 esac
6502 6532 done
6503 6533
6504 6534 # :command.command_filter
6505 6535 action="build-installer"
6506 6536
6507 6537 # :command.parse_requirements_while
6508 6538 while [[ $# -gt 0 ]]; do
6509 6539 key="$1"
6510 6540 case "$key" in
6511 6541 # :flag.case
6512 6542 --version-name)
6513 6543
6514 6544 # :flag.case_arg
6515 6545 if [[ -n ${2+x} ]]; then
6516 6546
6517 6547 args['--version-name']="$2"
6518 6548 shift
6519 6549 shift
6520 6550 else
6521 6551 printf "%s\n" "--version-name requires an argument: --version-name VERSION_NAME" >&2
6522 6552 exit 1
6523 6553 fi
6524 6554 ;;
6525 6555
6526 6556 -?*)
6527 6557 printf "invalid option: %s\n" "$key" >&2
6528 6558 exit 1
6529 6559 ;;
6530 6560
6531 6561 *)
6532 6562 # :command.parse_requirements_case
6533 6563 # :command.parse_requirements_case_simple
6534 6564 printf "invalid argument: %s\n" "$key" >&2
6535 6565 exit 1
6536 6566
6537 6567 ;;
6538 6568
6539 6569 esac
6540 6570 done
6541 6571
6542 6572 # :command.default_assignments
6543 6573 [[ -n ${args['--version-name']:-} ]] || args['--version-name']="$RC_CLI_VERSION_NAME"
6544 6574
6545 6575 }
6546 6576
6547 6577 # :command.parse_requirements
6548 6578 rcstack_get_build_source_parse_requirements() {
6549 6579 # :command.fixed_flags_filter
6550 6580 while [[ $# -gt 0 ]]; do
6551 6581 case "${1:-}" in
6552 6582 --help | -h)
6553 6583 long_usage=yes
6554 6584 rcstack_get_build_source_usage
6555 6585 exit
6556 6586 ;;
6557 6587
6558 6588 *)
6559 6589 break
6560 6590 ;;
6561 6591
6562 6592 esac
6563 6593 done
6564 6594
6565 6595 # :command.dependencies_filter
6566 6596 if command -v curl >/dev/null 2>&1; then
6567 6597 deps['curl']="$(command -v curl | head -n1)"
6568 6598 else
6569 6599 printf "missing dependency: curl\n" >&2
6570 6600 exit 1
6571 6601 fi
6572 6602
6573 6603 if command -v tar >/dev/null 2>&1; then
6574 6604 deps['tar']="$(command -v tar | head -n1)"
6575 6605 else
6576 6606 printf "missing dependency: tar\n" >&2
6577 6607 exit 1
6578 6608 fi
6579 6609
6580 6610 # :command.command_filter
6581 6611 action="get-build-source"
6582 6612
6583 6613 # :command.parse_requirements_while
6584 6614 while [[ $# -gt 0 ]]; do
6585 6615 key="$1"
6586 6616 case "$key" in
6587 6617 # :flag.case
6588 6618 --revision)
6589 6619
6590 6620 # :flag.case_arg
6591 6621 if [[ -n ${2+x} ]]; then
6592 6622
6593 6623 args['--revision']="$2"
6594 6624 shift
6595 6625 shift
6596 6626 else
6597 6627 printf "%s\n" "--revision requires an argument: --revision REVISION" >&2
6598 6628 exit 1
6599 6629 fi
6600 6630 ;;
6601 6631
6602 6632 # :flag.case
6603 6633 --auth-token)
6604 6634
6605 6635 # :flag.case_arg
6606 6636 if [[ -n ${2+x} ]]; then
6607 6637
6608 6638 args['--auth-token']="$2"
6609 6639 shift
6610 6640 shift
6611 6641 else
6612 6642 printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
6613 6643 exit 1
6614 6644 fi
6615 6645 ;;
6616 6646
6617 6647 # :flag.case
6618 6648 --server-url)
6619 6649
6620 6650 # :flag.case_arg
6621 6651 if [[ -n ${2+x} ]]; then
6622 6652
6623 6653 args['--server-url']="$2"
6624 6654 shift
6625 6655 shift
6626 6656 else
6627 6657 printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
6628 6658 exit 1
6629 6659 fi
6630 6660 ;;
6631 6661
6632 6662 -?*)
6633 6663 printf "invalid option: %s\n" "$key" >&2
6634 6664 exit 1
6635 6665 ;;
6636 6666
6637 6667 *)
6638 6668 # :command.parse_requirements_case
6639 6669 # :command.parse_requirements_case_simple
6640 6670 printf "invalid argument: %s\n" "$key" >&2
6641 6671 exit 1
6642 6672
6643 6673 ;;
6644 6674
6645 6675 esac
6646 6676 done
6647 6677
6648 6678 # :command.default_assignments
6649 6679 [[ -n ${args['--revision']:-} ]] || args['--revision']="default"
6650 6680 [[ -n ${args['--server-url']:-} ]] || args['--server-url']="https://code.rhodecode.com"
6651 6681
6652 6682 }
6653 6683
6654 6684 # :command.parse_requirements
6655 6685 rcstack_build_source_parse_requirements() {
6656 6686 # :command.fixed_flags_filter
6657 6687 while [[ $# -gt 0 ]]; do
6658 6688 case "${1:-}" in
6659 6689 --help | -h)
6660 6690 long_usage=yes
6661 6691 rcstack_build_source_usage
6662 6692 exit
6663 6693 ;;
6664 6694
6665 6695 *)
6666 6696 break
6667 6697 ;;
6668 6698
6669 6699 esac
6670 6700 done
6671 6701
6672 6702 # :command.command_filter
6673 6703 action="build-source"
6674 6704
6675 6705 # :command.parse_requirements_while
6676 6706 while [[ $# -gt 0 ]]; do
6677 6707 key="$1"
6678 6708 case "$key" in
6679 6709 # :flag.case
6680 6710 --version-name)
6681 6711
6682 6712 # :flag.case_arg
6683 6713 if [[ -n ${2+x} ]]; then
6684 6714
6685 6715 args['--version-name']="$2"
6686 6716 shift
6687 6717 shift
6688 6718 else
6689 6719 printf "%s\n" "--version-name requires an argument: --version-name VERSION_NAME" >&2
6690 6720 exit 1
6691 6721 fi
6692 6722 ;;
6693 6723
6694 6724 # :flag.case
6695 6725 --source-build-yaml)
6696 6726
6697 6727 # :flag.case_arg
6698 6728 if [[ -n ${2+x} ]]; then
6699 6729
6700 6730 args['--source-build-yaml']="$2"
6701 6731 shift
6702 6732 shift
6703 6733 else
6704 6734 printf "%s\n" "--source-build-yaml requires an argument: --source-build-yaml BUILD_SOURCE_YAML" >&2
6705 6735 exit 1
6706 6736 fi
6707 6737 ;;
6708 6738
6709 6739 # :flag.case
6710 6740 --tag)
6711 6741
6712 6742 # :flag.case_arg
6713 6743 if [[ -n ${2+x} ]]; then
6714 6744
6715 6745 if [[ -z ${args['--tag']+x} ]]; then
6716 6746 args['--tag']="\"$2\""
6717 6747 else
6718 6748 args['--tag']="${args[--tag]} \"$2\""
6719 6749 fi
6720 6750 shift
6721 6751 shift
6722 6752 else
6723 6753 printf "%s\n" "--tag requires an argument: --tag TAG" >&2
6724 6754 exit 1
6725 6755 fi
6726 6756 ;;
6727 6757
6728 6758 -?*)
6729 6759 printf "invalid option: %s\n" "$key" >&2
6730 6760 exit 1
6731 6761 ;;
6732 6762
6733 6763 *)
6734 6764 # :command.parse_requirements_case
6735 6765 # :command.parse_requirements_case_simple
6736 6766 printf "invalid argument: %s\n" "$key" >&2
6737 6767 exit 1
6738 6768
6739 6769 ;;
6740 6770
6741 6771 esac
6742 6772 done
6743 6773
6744 6774 # :command.default_assignments
6745 6775 [[ -n ${args['--version-name']:-} ]] || args['--version-name']="$RC_CLI_VERSION_NAME"
6746 6776 [[ -n ${args['--source-build-yaml']:-} ]] || args['--source-build-yaml']="docker-compose-apps.source.yaml"
6747 6777
6748 6778 }
6749 6779
6750 6780 # :command.parse_requirements
6751 6781 rcstack__completions_parse_requirements() {
6752 6782 # :command.fixed_flags_filter
6753 6783 while [[ $# -gt 0 ]]; do
6754 6784 case "${1:-}" in
6755 6785 --help | -h)
6756 6786 long_usage=yes
6757 6787 rcstack__completions_usage
6758 6788 exit
6759 6789 ;;
6760 6790
6761 6791 *)
6762 6792 break
6763 6793 ;;
6764 6794
6765 6795 esac
6766 6796 done
6767 6797
6768 6798 # :command.command_filter
6769 6799 action="_completions"
6770 6800
6771 6801 # :command.parse_requirements_while
6772 6802 while [[ $# -gt 0 ]]; do
6773 6803 key="$1"
6774 6804 case "$key" in
6775 6805
6776 6806 -?*)
6777 6807 printf "invalid option: %s\n" "$key" >&2
6778 6808 exit 1
6779 6809 ;;
6780 6810
6781 6811 *)
6782 6812 # :command.parse_requirements_case
6783 6813 # :command.parse_requirements_case_simple
6784 6814 printf "invalid argument: %s\n" "$key" >&2
6785 6815 exit 1
6786 6816
6787 6817 ;;
6788 6818
6789 6819 esac
6790 6820 done
6791 6821
6792 6822 }
6793 6823
6794 6824 # :command.initialize
6795 6825 initialize() {
6796 version="5.0.4"
6826 version="5.0.6"
6797 6827 long_usage=''
6798 6828 set -e
6799 6829
6800 6830 # :command.environment_variables_default
6801 6831 export RCC_CONFIG="${RCC_CONFIG:-.rcstack.ini}"
6802 6832 export RC_STACK_ROUTER_EXT="${RC_STACK_ROUTER_EXT:-.custom/docker-compose-router.override.yaml}"
6803 6833 export RC_STACK_METRICS_EXT="${RC_STACK_METRICS_EXT:-.custom/docker-compose-metrics.override.yaml}"
6804 6834 export RC_STACK_SERVICES_EXT="${RC_STACK_SERVICES_EXT:-.custom/docker-compose-services.override.yaml}"
6805 6835 export RC_STACK_RHODECODE_EXT="${RC_STACK_RHODECODE_EXT:-.custom/docker-compose-apps.override.yaml}"
6806 6836
6807 6837 # src/initialize.sh
6808 6838
6809 6839 rc_image_ver=4.28.0
6810 6840
6811 6841 rhodecode_default_config_path=config/_shared/rhodecode.ini
6812 6842 vcsserver_default_config_path=config/_shared/vcsserver.ini
6813 6843
6814 6844 RC_STACK_ROUTER_VER=v1.0.0
6815 6845 RC_STACK_SERVICES_VER=v1.0.0
6816 6846 RC_STACK_RHODECODE_VER=v1.0.0
6817 6847 RC_STACK_METRICS_VER=v1.0.0
6818 6848
6819 6849 RC_SCRIPT_NAME=rcstack
6820 6850 # bootstrap file is a config file at the same time
6821 6851 CONFIG_FILE=${RCC_CONFIG:=.rcstack.ini}
6822 6852
6823 6853 # runtime env file
6824 6854 RUNTIME_ENV=$PWD/.custom/.runtime.env
6825 6855
6826 6856 # STACK_LIST
6827 6857 VALID_SERVICES="router metrics services rhodecode"
6828 6858 DOCKER_DEFS_WORK_DIR="docker_defs"
6829 6859
6830 6860 # stage key, saved in .rcstack.ini : stage func to execute
6831 6861 BOOTSTRAP_STAGES="\
6832 6862 bootstrap_v1_docker_install \
6833 6863 bootstrap_v1_docker_commons \
6834 6864 bootstrap_v1_definitions \
6835 6865 bootstrap_v1_config \
6836 6866 bootstrap_v1_overrides \
6837 6867 "
6838 6868
6839 6869 YAML_TEMPLATES="\
6840 6870 docker-compose-apps.override.yaml
6841 6871 docker-compose-metrics.override.yaml
6842 6872 docker-compose-router.override.yaml
6843 6873 docker-compose-services.override.yaml
6844 6874 runtime.env.tmpl
6845 6875 "
6846 6876
6847 6877 get_stage_function() {
6848 6878 stage_name=$1
6849 6879
6850 6880 case $stage_name in
6851 6881 bootstrap_v1_docker_install)
6852 6882 stage_func=bootstrap_docker_install
6853 6883 ;;
6854 6884 bootstrap_v1_docker_commons)
6855 6885 stage_func=bootstrap_docker_commons
6856 6886 ;;
6857 6887 bootstrap_v1_definitions)
6858 6888 stage_func=bootstrap_definitions
6859 6889 ;;
6860 6890 bootstrap_v1_config)
6861 6891 stage_func=bootstrap_config
6862 6892 ;;
6863 6893 bootstrap_v1_overrides)
6864 6894 stage_func=bootstrap_overrides
6865 6895 ;;
6866 6896 *)
6867 6897 echo "can't find function for stage $stage_name"
6868 6898 exit 1
6869 6899 esac
6870 6900
6871 6901 echo $stage_func
6872 6902 }
6873 6903
6874 6904 #echo "1 ----"
6875 6905 #echo $RC_STACK_SERVICES_EXT
6876 6906 #echo $RC_STACK_METRICS_EXT
6877 6907 #echo "1 -----"
6878 6908
6879 6909 #echo '2 ----'
6880 6910 #grep -v -e '^#' "$ENV_FILE" | xargs -I {} echo \'{}\'
6881 6911 #echo '2 ----'
6882 6912
6883 6913 #expose env vars from ./rcstack config
6884 6914 #if [[ -f $ENV_FILE ]]; then
6885 6915 # eval $(grep -v -e '^#' "$ENV_FILE" | xargs -I {} echo export \'{}\')
6886 6916 #fi
6887 6917
6888 6918 #ENV_EXPAND=""
6889 6919 #for k in $(config_keys); do
6890 6920 # k_upper=${k^^}
6891 6921 # env_entry="-e $k_upper='$(config_get "$k")' "
6892 6922 # ENV_EXPAND+=$env_entry;
6893 6923 # #echo $env_expand
6894 6924 #done
6895 6925
6896 6926 #
6897 6927 #echo "3 ----"
6898 6928 #echo $RC_STACK_SERVICES_EXT
6899 6929 #echo $RC_STACK_METRICS_EXT
6900 6930 #echo $RC_STACK_RHODECODE_EXT
6901 6931 #echo "3 -----"
6902 6932
6903 6933 #env | grep RC_
6904 6934
6905 6935 docker_ping_host() {
6906 6936 PING_HOST="$1"
6907 6937 docker run --network rhodecode_network --rm alpine ping "$PING_HOST"
6908 6938 }
6909 6939
6910 6940 get_started() {
6911 6941 echo ""
6912 6942 echo "To start using RhodeCode run the following stacks using './$RC_SCRIPT_NAME stack [STACK_NAME]'"
6913 6943 echo "Check './$RC_SCRIPT_NAME stack --help' for more examples and options"
6914 6944 echo "$(green_bold IMPORTANT): init command generates some secrets/config inside $RUNTIME_ENV file."
6915 6945 echo "Check and adjust those settings if needed."
6916 6946 echo ""
6917 6947 echo "$(bold Run the stacks in following order):"
6918 6948 echo ""
6919 6949 echo "$(green_bold 1\) router [Mandatory]): run the edge router to control stack traffic / domain access and optionally SSL termination"
6920 6950 echo "IMPORTANT: router binds to some common ports 80, 443, SSH (9022), Loki (3100) if those are not available, please adjust them"
6921 6951 echo "To configure this stack before running check: $RC_STACK_ROUTER_EXT"
6922 6952 echo ""
6923 6953 echo "./$RC_SCRIPT_NAME stack router up --detach"
6924 6954 echo ""
6925 6955 echo "$(green_bold 2\) services [Mandatory]): run the services, like database, redis, channelstream etc..."
6926 6956 echo "IMPORTANT: if you like to run your own database, or redis please adjust before running"
6927 6957 echo "To configure this stack before running check: $RC_STACK_SERVICES_EXT"
6928 6958 echo ""
6929 6959 echo "./$RC_SCRIPT_NAME stack services up --detach"
6930 6960 echo ""
6931 6961 echo "$(green_bold 3\) rhodecode [Mandatory]): run the rhodecode app stack"
6932 6962 echo "To configure this stack before running check: $RC_STACK_RHODECODE_EXT"
6933 6963 echo ""
6934 6964 echo "./$RC_SCRIPT_NAME stack rhodecode up --detach"
6935 6965 echo ""
6936 6966 echo "$(yellow_bold 4\) metrics [Optional]): run the monitoring stack, this includes grafana/prometheus logging/metrics system"
6937 6967 echo "To configure this stack before running check: $RC_STACK_METRICS_EXT"
6938 6968 echo ""
6939 6969 echo "./$RC_SCRIPT_NAME stack metrics up --detach"
6940 6970 echo ""
6941 6971 echo "$(bold [Status]): check services run status, ports etc.."
6942 6972 echo "./$RC_SCRIPT_NAME status"
6943 6973 echo ""
6944 6974 echo "$(bold [All]): shorthand to run all stacks (detached with -d)"
6945 6975 echo "./$RC_SCRIPT_NAME stack all up -d"
6946 6976 echo ""
6947 6977 echo "$(bold [Logs]): check service logs"
6948 6978 echo "./$RC_SCRIPT_NAME stack [STACK_NAME] logs"
6949 6979 }
6950 6980
6951 6981 get_started_full() {
6952 6982 echo "$(blue_bold [~~~~ GET STARTED ~~~~~])"
6953 6983 echo "$(green_bold Having problems / need help? Reach out to us here:) https://community.rhodecode.com"
6954 6984 echo ""
6955 6985 echo "./$RC_SCRIPT_NAME is a CLI based installer/manager for RhodeCode Cluster Stack"
6956 6986 echo "./$RC_SCRIPT_NAME -h is your friend, in case of doubt, check examples and usage options with -h / --help flag"
6957 6987 echo ""
6958 6988 echo "$(yellow_bold [First time run])"
6959 6989 echo "run './$RC_SCRIPT_NAME init' to setup docker and download required installer files."
6960 6990 echo "./$RC_SCRIPT_NAME can install Docker for you, or install it manually before running init command"
6961 6991
6962 6992 get_started
6963 6993 }
6964 6994
6965 6995 }
6966 6996
6967 6997 # :command.run
6968 6998 run() {
6969 6999 declare -A args=()
6970 7000 declare -A deps=()
6971 7001 declare -a other_args=()
6972 7002 declare -a input=()
6973 7003 normalize_input "$@"
6974 7004 parse_requirements "${input[@]}"
6975 7005
6976 7006 case "$action" in
6977 7007 "get-started") rcstack_get_started_command ;;
6978 7008 "init") rcstack_init_command ;;
6979 7009 "self-update") rcstack_self_update_command ;;
6980 7010 "stack") rcstack_stack_command ;;
6981 7011 "stack router") rcstack_stack_router_command ;;
6982 7012 "stack metrics") rcstack_stack_metrics_command ;;
6983 7013 "stack services") rcstack_stack_services_command ;;
6984 7014 "stack rhodecode") rcstack_stack_rhodecode_command ;;
6985 7015 "stack all") rcstack_stack_all_command ;;
6986 7016 "stack-status") rcstack_stack_status_command ;;
6987 7017 "stack-upgrade") rcstack_stack_upgrade_command ;;
6988 7018 "stack-upgrade router") rcstack_stack_upgrade_router_command ;;
6989 7019 "stack-upgrade metrics") rcstack_stack_upgrade_metrics_command ;;
6990 7020 "stack-upgrade services") rcstack_stack_upgrade_services_command ;;
6991 7021 "stack-upgrade rhodecode") rcstack_stack_upgrade_rhodecode_command ;;
6992 7022 "stack-monitor") rcstack_stack_monitor_command ;;
6993 7023 "stack-monitor restart-unhealthy") rcstack_stack_monitor_restart_unhealthy_command ;;
6994 7024 "cli") rcstack_cli_command ;;
6995 7025 "cli image-info") rcstack_cli_image_info_command ;;
6996 7026 "cli set-runtime-image") rcstack_cli_set_runtime_image_command ;;
6997 7027 "cli ishell") rcstack_cli_ishell_command ;;
6998 7028 "cli redis") rcstack_cli_redis_command ;;
6999 7029 "cli db") rcstack_cli_db_command ;;
7000 7030 "cli db-upgrade") rcstack_cli_db_upgrade_command ;;
7001 7031 "cli storage") rcstack_cli_storage_command ;;
7002 7032 "cli attach") rcstack_cli_attach_command ;;
7003 7033 "cli set-edition") rcstack_cli_set_edition_command ;;
7004 7034 "cli configure-vcsserver") rcstack_cli_configure_vcsserver_command ;;
7005 7035 "cli configure-rhodecode") rcstack_cli_configure_rhodecode_command ;;
7006 7036 "backup-db") rcstack_backup_db_command ;;
7007 7037 "backup-data") rcstack_backup_data_command ;;
7008 7038 "get-build-artifacts") rcstack_get_build_artifacts_command ;;
7009 7039 "build-installer") rcstack_build_installer_command ;;
7010 7040 "get-build-source") rcstack_get_build_source_command ;;
7011 7041 "build-source") rcstack_build_source_command ;;
7012 7042 "_completions") rcstack__completions_command ;;
7013 7043 esac
7014 7044 }
7015 7045
7016 7046 initialize
7017 7047 run "$@"
General Comments 0
You need to be logged in to leave comments. Login now