From d3b583e812cf85ffad5a19cb924876fdb7ad0c6d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 21 Apr 2022 21:18:27 +0000 Subject: [PATCH 001/823] Initial commit --- LICENSE | 674 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 2 + 2 files changed, 676 insertions(+) create mode 100644 LICENSE create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..f288702d --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 00000000..88d070e1 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# heavy_script +Script that can: Update Truenas SCALE applications, Mount and unmount PVC storage, Prune Docker images. From 29d59890f4601ca6a971eb70ee2ec9c3f4629e12 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 21 Apr 2022 21:19:53 +0000 Subject: [PATCH 002/823] initial --- heavy_script.sh | 161 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 heavy_script.sh diff --git a/heavy_script.sh b/heavy_script.sh new file mode 100644 index 00000000..8746fa2f --- /dev/null +++ b/heavy_script.sh @@ -0,0 +1,161 @@ +#!/bin/bash + +#If no argument is passed, kill the script. +[[ -z "$@" ]] && echo "This script requires an arguent, use -h for help" && exit + +while getopts ":hsi:mt:uUp" opt +do + case $opt in + h) + echo "These arguments NEED to be ran in a specific order, you can go from TOP to BOTTOM, see example below" + echo "-m | Initiates mounting feature, choose between unmounting and mounting PVC data" + echo "-i | Add application to ignore list, one by one, see example below." + echo "-t | Default: 300 -- Set a custom timeout: This is the ammount of time the script will wait for an application to go from DEPLOYING to ACTIVE" + echo "-s | sync catalog" + echo "-U | Update all applications, ignores versions" + echo "-u | Update all applications, does not update Major releases" + echo "-p | Prune unused/old docker images" + echo "EX |./update.sh -I portainer -I arch -I sonarr -I radarr -t 600 -sUp" + exit;; + \?) + echo "Invalid Option -$OPTARG, type -h for help" + exit;; + m) + echo -e "1 Mount\n2 Unmount All" && read -p "Please type a number: " selection + + if [[ $selection == "1" ]]; then + list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + echo "$list" && read -p "Please type a number : " selection + app=$(echo -e "$list" | grep ^$selection | awk '{print $2}' | cut -c 4-) + pvc=$(echo -e "$list" | grep ^$selection || echo -e "\nInvalid selection") + status=$(cli -m csv -c 'app chart_release query name,status' | grep $app | awk -F ',' '{print $2}'| tr -d " \t\n\r") && SECONDS=0 && timeout=200 + [[ "$status" != "STOPPED" ]] && echo -e "\nScaling down $app" && midclt call chart.release.scale $app '{"replica_count": 0}' &> /dev/null + while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] + do + status=$(cli -m csv -c 'app chart_release query name,status' | grep $app | awk -F ',' '{print $2}'|tr -d " \t\n\r") + echo -e "Waiting $(($timeout-$SECONDS)) more seconds for $app to be STOPPED" && sleep 10 + done + data_name=$(echo $pvc | awk '{print $3}') + mount=$(echo $pvc | awk '{print $4}') + path=$(find /*/*/ix-applications/releases/$app/volumes/ -maxdepth 0 | cut -c 6-) + echo -e "\nMounting\n"$path""$mount"\nTo\n/mnt/temporary/$data_name" && zfs set mountpoint=/temporary/$data_name "$path""$mount" && echo -e "Mounted\n\nUnmount with the following command\nzfs set mountpoint=legacy "$path""$mount"\nOr use the Unmount All option" + break + elif [[ $selection == "2" ]]; then + unmount_array=($(basename -a /mnt/temporary/* | sed "s/*//")) + [[ -z $unmount_array ]] && echo "Theres nothing to unmount" && exit + for i in ${unmount_array[@]} + do + main=$(k3s kubectl get pvc -A | grep $i | awk '{print $1, $2, $4}') + app=$(echo $main | awk '{print $1}' | cut -c 4-) + pvc=$(echo $main | awk '{print $3}') + path=$(find /*/*/ix-applications/releases/$app/volumes/ -maxdepth 0 | cut -c 6-) + zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/temporary/$i || echo "failed to unmount $i" + done + else + echo "Invalid selection, type -h for help" + break + fi + exit;; + :) + echo "Option: -$OPTARG requires an argument" >&2 + exit;; + s) + echo -e "Syncing all catalogs, please wait.." && cli -c 'app catalog sync_all' &> /dev/null && echo -e "Catalog sync complete" + ;; + i) + ignore+="$OPTARG" + ;; + t) + timeout=$OPTARG + re='^[0-9]+$' + ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n$timeout is not an interger" >&2 + ;; + U) + array=($(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ,true,)) + [[ -z $array ]] && echo -e "\nThere are no updates available" && continue || echo -e "\n${#array[@]} update(s) available" + [[ -z $timeout ]] && echo -e "\nSetting Default Timeout to 300\nChange timeout with -t" && timeout=300 || echo -e "\nTimeout was set to $timeout" + for i in ${array[@]} + do + n=$(echo $i | awk -F ',' '{print $1}') #print out first catagory, name. + ov=$(echo $i | awk -F ',' '{print $4}') #Old version + nv=$(echo $i | awk -F ',' '{print $5}') #New Version + status=$(echo $i | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE + if [[ "${ignore[*]}" =~ "${n}" ]]; then + echo -e "\n$n\nIgnored, skipping" + continue + elif [[ "$status" == "STOPPED" ]]; then + echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'$n'"' &> /dev/null && echo -e "Updated\n$ov\n$nv\nWas Stopped, Beginning Stop Loop" && SECONDS=0 || { echo "FAILED"; continue; } + while [[ "$status" != "ACTIVE" ]] + do + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep $n | awk -F ',' '{print $2}') + if [[ "$status" == "STOPPED" ]]; then + echo -e "Stopped" + break + elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then + echo -e "Error: Run Time($SECONDS) has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher time with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nNot shutting down application for safety reasons, continuing to next applicaion" + break + elif [[ "$status" == "DEPLOYING" ]]; then + echo -e "Waiting $(($timeout-$SECONDS)) more seconds for $n to be ACTIVE" && sleep 15 + continue + else + echo -e "Returing to STOPPED state.." && midclt call chart.release.scale $n '{"replica_count": 0}' &> /dev/null && echo -e "Stopped"|| echo "FAILED" + break + fi + done + else + echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'$n'"' &> /dev/null && echo -e "Updated\n$ov\n$nv" || echo -e "FAILED" + continue + fi + done + ;; + u) + array=($(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ,true,)) + [[ -z $array ]] && echo -e "\nThere are no updates available" && continue || echo -e "\n${#array[@]} update(s) available" + [[ -z $timeout ]] && echo -e "\nSetting Default Timeout to 300\nChange timeout with -t" && timeout=300 || echo -e "\nTimeout was set to $timeout" + for i in ${array[@]} + do + n=$(echo $i | awk -F ',' '{print $1}') #print out first catagory, name. + ottv=$(echo $i | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous Truecharts version + nttv=$(echo $i | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous version) #New Truecharts Version + oav=$(echo $i | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') #previous version) #New App Version + nav=$(echo $i | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') #previous version) #New App Version + status=$(echo $i | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE + tt=$(diff <(echo "$ottv") <(echo "$nttv")) #caluclating difference in major Truecharts versions + av=$(diff <(echo "$oav") <(echo "$nav")) #caluclating difference in major app versions + ov=$(echo $i | awk -F ',' '{print $4}') #Upgraded From + nv=$(echo $i | awk -F ',' '{print $5}') #Upraded To + if [[ "${ignore[*]}" =~ "${n}" ]]; then + echo -e "\n$n\nIgnored, skipping" + continue + elif [[ "$tt" == "$av" && "$status" == "ACTIVE" || "$status" == "DEPLOYING" ]]; then + echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'$n'"' &> /dev/null && echo -e "Updated\n$ov\n$nv" || echo "FAILED" + continue + elif [[ "$tt" == "$av" && "$status" == "STOPPED" ]]; then + echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'$n'"' &> /dev/null && echo -e "Updated\n$ov\n$nv\nWas Stopped, Beginning Stop Loop" && SECONDS=0 || { echo "FAILED"; continue; } + while [[ "$status" != "ACTIVE" ]] + do + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep $n | awk -F ',' '{print $2}') + if [[ "$status" == "STOPPED" ]]; then + echo -e "Stopped" + break + elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then + echo -e "Error: Run Time($SECONDS) has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher time with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nNot shutting down application for safety reasons, continuing to next applicaion" + break + elif [[ "$status" == "DEPLOYING" ]]; then + echo -e "Waiting $(($timeout-$SECONDS)) more seconds for $n to be ACTIVE" && sleep 15 + continue + else + echo "Returing to STOPPED state.." && midclt call chart.release.scale $n '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo -e "FAILED" + break + fi + done + else + echo -e "\n$n\nMajor Release, update manually" + continue + fi + done + ;; + p) + echo -e "\nPruning Docker Images" && docker image prune -af | grep Total || echo "Failed to Prune Docker Images" + esac +done From 427076d8c4baa0506fb79db6da715a6eaac54291 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 21 Apr 2022 21:22:55 +0000 Subject: [PATCH 003/823] Update README.md --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 88d070e1..07be40de 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,13 @@ # heavy_script Script that can: Update Truenas SCALE applications, Mount and unmount PVC storage, Prune Docker images. + + +These arguments NEED to be ran in a specific order, you can go from TOP to BOTTOM, see example below +| -m | Initiates mounting feature, choose between unmounting and mounting PVC data +| -i | Add application to ignore list, one by one, see example below. +| -t | Default: 300 -- Set a custom timeout: This is the ammount of time the script will wait for an application to go from DEPLOYING to ACTIVE +| -s |sync catalog +| -U | Update all applications, ignores versions +| -u | Update all applications, does not update Major releases +| -p | Prune unused/old docker images +| EX |./update.sh -i portainer -i arch -i sonarr -i radarr -t 600 -sUp From 8ba973521236835fb71a158270f883ef90089417 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 21 Apr 2022 21:25:52 +0000 Subject: [PATCH 004/823] Update README.md --- README.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/README.md b/README.md index 07be40de..88d070e1 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,2 @@ # heavy_script Script that can: Update Truenas SCALE applications, Mount and unmount PVC storage, Prune Docker images. - - -These arguments NEED to be ran in a specific order, you can go from TOP to BOTTOM, see example below -| -m | Initiates mounting feature, choose between unmounting and mounting PVC data -| -i | Add application to ignore list, one by one, see example below. -| -t | Default: 300 -- Set a custom timeout: This is the ammount of time the script will wait for an application to go from DEPLOYING to ACTIVE -| -s |sync catalog -| -U | Update all applications, ignores versions -| -u | Update all applications, does not update Major releases -| -p | Prune unused/old docker images -| EX |./update.sh -i portainer -i arch -i sonarr -i radarr -t 600 -sUp From bdf6641fac760250ce03b16c5bd219470b695109 Mon Sep 17 00:00:00 2001 From: kyler Date: Thu, 21 Apr 2022 21:46:50 -0600 Subject: [PATCH 005/823] fixing issue with multiple applications have similar name. --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 8746fa2f..d45b4a85 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -28,8 +28,8 @@ do echo "$list" && read -p "Please type a number : " selection app=$(echo -e "$list" | grep ^$selection | awk '{print $2}' | cut -c 4-) pvc=$(echo -e "$list" | grep ^$selection || echo -e "\nInvalid selection") - status=$(cli -m csv -c 'app chart_release query name,status' | grep $app | awk -F ',' '{print $2}'| tr -d " \t\n\r") && SECONDS=0 && timeout=200 - [[ "$status" != "STOPPED" ]] && echo -e "\nScaling down $app" && midclt call chart.release.scale $app '{"replica_count": 0}' &> /dev/null + status=$(cli -m csv -c 'app chart_release query name,status' | grep -w $app | awk -F ',' '{print $2}'| tr -d " \t\n\r") && SECONDS=0 && timeout=200 + [[ "$status" != "STOPPED" ]] && echo -e "\nScaling down -w $app" && midclt call chart.release.scale $app '{"replica_count": 0}' &> /dev/null while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] do status=$(cli -m csv -c 'app chart_release query name,status' | grep $app | awk -F ',' '{print $2}'|tr -d " \t\n\r") From 3ea7d03bb7e7fd93dbca3fb680bc8bf6257974ad Mon Sep 17 00:00:00 2001 From: kyler Date: Fri, 22 Apr 2022 15:37:02 -0600 Subject: [PATCH 006/823] general syntax improvements + echo mistakes fixed --- heavy_script.sh | 88 ++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index d45b4a85..6894bacb 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,7 +1,7 @@ #!/bin/bash #If no argument is passed, kill the script. -[[ -z "$@" ]] && echo "This script requires an arguent, use -h for help" && exit +[[ -z "$*" ]] && echo "This script requires an arguent, use -h for help" && exit while getopts ":hsi:mt:uUp" opt do @@ -26,30 +26,30 @@ do if [[ $selection == "1" ]]; then list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") echo "$list" && read -p "Please type a number : " selection - app=$(echo -e "$list" | grep ^$selection | awk '{print $2}' | cut -c 4-) - pvc=$(echo -e "$list" | grep ^$selection || echo -e "\nInvalid selection") - status=$(cli -m csv -c 'app chart_release query name,status' | grep -w $app | awk -F ',' '{print $2}'| tr -d " \t\n\r") && SECONDS=0 && timeout=200 - [[ "$status" != "STOPPED" ]] && echo -e "\nScaling down -w $app" && midclt call chart.release.scale $app '{"replica_count": 0}' &> /dev/null + app=$(echo -e "$list" | grep ^"$selection" | awk '{print $2}' | cut -c 4-) + pvc=$(echo -e "$list" | grep ^"$selection" || echo -e "\nInvalid selection") + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") && SECONDS=0 && timeout=200 + [[ "$status" != "STOPPED" ]] && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] do - status=$(cli -m csv -c 'app chart_release query name,status' | grep $app | awk -F ',' '{print $2}'|tr -d " \t\n\r") - echo -e "Waiting $(($timeout-$SECONDS)) more seconds for $app to be STOPPED" && sleep 10 + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 10 done - data_name=$(echo $pvc | awk '{print $3}') - mount=$(echo $pvc | awk '{print $4}') - path=$(find /*/*/ix-applications/releases/$app/volumes/ -maxdepth 0 | cut -c 6-) - echo -e "\nMounting\n"$path""$mount"\nTo\n/mnt/temporary/$data_name" && zfs set mountpoint=/temporary/$data_name "$path""$mount" && echo -e "Mounted\n\nUnmount with the following command\nzfs set mountpoint=legacy "$path""$mount"\nOr use the Unmount All option" + data_name=$(echo "$pvc" | awk '{print $3}') + mount=$(echo "$pvc" | awk '{print $4}') + path=$(find /*/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + echo -e "\nMounting\n""$path""""$mount""\nTo\n/mnt/temporary/$data_name" && zfs set mountpoint=/temporary/"$data_name" "$path""$mount" && echo -e "Mounted\n\nUnmount with the following command\nzfs set mountpoint=legacy ""$path"""$mount"\nOr use the Unmount All option" break elif [[ $selection == "2" ]]; then - unmount_array=($(basename -a /mnt/temporary/* | sed "s/*//")) + mapfile -t unmount_array < <(basename -a /mnt/temporary/* | sed "s/*//") [[ -z $unmount_array ]] && echo "Theres nothing to unmount" && exit - for i in ${unmount_array[@]} + for i in "${unmount_array[@]}" do - main=$(k3s kubectl get pvc -A | grep $i | awk '{print $1, $2, $4}') - app=$(echo $main | awk '{print $1}' | cut -c 4-) - pvc=$(echo $main | awk '{print $3}') - path=$(find /*/*/ix-applications/releases/$app/volumes/ -maxdepth 0 | cut -c 6-) - zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/temporary/$i || echo "failed to unmount $i" + main=$(k3s kubectl get pvc -A | grep "$i" | awk '{print $1, $2, $4}') + app=$(echo "$main" | awk '{print $1}' | cut -c 4-) + pvc=$(echo "$main" | awk '{print $3}') + path=$(find /*/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/temporary/"$i" || echo "failed to unmount $i" done else echo "Invalid selection, type -h for help" @@ -71,20 +71,20 @@ do ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n$timeout is not an interger" >&2 ;; U) - array=($(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ,true,)) + mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ,true,) [[ -z $array ]] && echo -e "\nThere are no updates available" && continue || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nSetting Default Timeout to 300\nChange timeout with -t" && timeout=300 || echo -e "\nTimeout was set to $timeout" - for i in ${array[@]} + for i in "${array[@]}" do - n=$(echo $i | awk -F ',' '{print $1}') #print out first catagory, name. - ov=$(echo $i | awk -F ',' '{print $4}') #Old version - nv=$(echo $i | awk -F ',' '{print $5}') #New Version - status=$(echo $i | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE - if [[ "${ignore[*]}" =~ "${n}" ]]; then + n=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. + ov=$(echo "$i" | awk -F ',' '{print $4}') #Old version + nv=$(echo "$i" | awk -F ',' '{print $5}') #New Version + status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE + if [[ "${ignore[*]}" == *"${n}"* ]]; then echo -e "\n$n\nIgnored, skipping" continue elif [[ "$status" == "STOPPED" ]]; then - echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'$n'"' &> /dev/null && echo -e "Updated\n$ov\n$nv\nWas Stopped, Beginning Stop Loop" && SECONDS=0 || { echo "FAILED"; continue; } + echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'"$n"'"' &> /dev/null && echo -e "Updated\n$ov\n$nv\nWas Stopped, Beginning Stop Loop" && SECONDS=0 || { echo "FAILED"; continue; } while [[ "$status" != "ACTIVE" ]] do status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep $n | awk -F ',' '{print $2}') @@ -95,46 +95,46 @@ do echo -e "Error: Run Time($SECONDS) has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher time with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nNot shutting down application for safety reasons, continuing to next applicaion" break elif [[ "$status" == "DEPLOYING" ]]; then - echo -e "Waiting $(($timeout-$SECONDS)) more seconds for $n to be ACTIVE" && sleep 15 + echo -e "Waiting $((timeout-SECONDS)) more seconds for $n to be ACTIVE" && sleep 15 continue else - echo -e "Returing to STOPPED state.." && midclt call chart.release.scale $n '{"replica_count": 0}' &> /dev/null && echo -e "Stopped"|| echo "FAILED" + echo -e "Returing to STOPPED state.." && midclt call chart.release.scale "$n" '{"replica_count": 0}' &> /dev/null && echo -e "Stopped"|| echo "FAILED" break fi done else - echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'$n'"' &> /dev/null && echo -e "Updated\n$ov\n$nv" || echo -e "FAILED" + echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'"$n"'"' &> /dev/null && echo -e "Updated\n$ov\n$nv" || echo -e "FAILED" continue fi done ;; u) - array=($(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ,true,)) + mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ,true,) [[ -z $array ]] && echo -e "\nThere are no updates available" && continue || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nSetting Default Timeout to 300\nChange timeout with -t" && timeout=300 || echo -e "\nTimeout was set to $timeout" - for i in ${array[@]} + for i in "${array[@]}" do - n=$(echo $i | awk -F ',' '{print $1}') #print out first catagory, name. - ottv=$(echo $i | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous Truecharts version - nttv=$(echo $i | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous version) #New Truecharts Version - oav=$(echo $i | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') #previous version) #New App Version - nav=$(echo $i | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') #previous version) #New App Version - status=$(echo $i | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE + n=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. + ottv=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous Truecharts version + nttv=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous version) #New Truecharts Version + oav=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') #previous version) #New App Version + nav=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') #previous version) #New App Version + status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE tt=$(diff <(echo "$ottv") <(echo "$nttv")) #caluclating difference in major Truecharts versions av=$(diff <(echo "$oav") <(echo "$nav")) #caluclating difference in major app versions - ov=$(echo $i | awk -F ',' '{print $4}') #Upgraded From - nv=$(echo $i | awk -F ',' '{print $5}') #Upraded To - if [[ "${ignore[*]}" =~ "${n}" ]]; then + ov=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From + nv=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To + if [[ "${ignore[*]}" == *"${n}"* ]]; then echo -e "\n$n\nIgnored, skipping" continue elif [[ "$tt" == "$av" && "$status" == "ACTIVE" || "$status" == "DEPLOYING" ]]; then - echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'$n'"' &> /dev/null && echo -e "Updated\n$ov\n$nv" || echo "FAILED" + echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'"$n"'"' &> /dev/null && echo -e "Updated\n$ov\n$nv" || echo "FAILED" continue elif [[ "$tt" == "$av" && "$status" == "STOPPED" ]]; then echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'$n'"' &> /dev/null && echo -e "Updated\n$ov\n$nv\nWas Stopped, Beginning Stop Loop" && SECONDS=0 || { echo "FAILED"; continue; } while [[ "$status" != "ACTIVE" ]] do - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep $n | awk -F ',' '{print $2}') + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "$n" | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then echo -e "Stopped" break @@ -142,10 +142,10 @@ do echo -e "Error: Run Time($SECONDS) has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher time with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nNot shutting down application for safety reasons, continuing to next applicaion" break elif [[ "$status" == "DEPLOYING" ]]; then - echo -e "Waiting $(($timeout-$SECONDS)) more seconds for $n to be ACTIVE" && sleep 15 + echo -e "Waiting $((timeout-SECONDS)) more seconds for $n to be ACTIVE" && sleep 15 continue else - echo "Returing to STOPPED state.." && midclt call chart.release.scale $n '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo -e "FAILED" + echo "Returing to STOPPED state.." && midclt call chart.release.scale "$n" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo -e "FAILED" break fi done From 3fafbfeb64ae5cc5275b7bf8bf4a40725151b1dd Mon Sep 17 00:00:00 2001 From: kyler Date: Fri, 22 Apr 2022 16:00:48 -0600 Subject: [PATCH 007/823] give mounting feature ability to use timeout --- heavy_script.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 6894bacb..1a26642d 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -20,6 +20,17 @@ do \?) echo "Invalid Option -$OPTARG, type -h for help" exit;; + :) + echo "Option: -$OPTARG requires an argument" >&2 + exit;; + i) + ignore+="$OPTARG" + ;; + t) + timeout=$OPTARG + re='^[0-9]+$' + ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n$timeout is not an interger" >&2 + ;; m) echo -e "1 Mount\n2 Unmount All" && read -p "Please type a number: " selection @@ -28,8 +39,8 @@ do echo "$list" && read -p "Please type a number : " selection app=$(echo -e "$list" | grep ^"$selection" | awk '{print $2}' | cut -c 4-) pvc=$(echo -e "$list" | grep ^"$selection" || echo -e "\nInvalid selection") - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") && SECONDS=0 && timeout=200 - [[ "$status" != "STOPPED" ]] && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") && SECONDS=0 + [[ "$status" != "STOPPED" ]] && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null && [[ -z $timeout ]] && echo -e "\nSetting Default Timeout to 300\nChange timeout with -t" && timeout=300 || echo -e "\nTimeout was set to $timeout" while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] do status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") @@ -56,20 +67,9 @@ do break fi exit;; - :) - echo "Option: -$OPTARG requires an argument" >&2 - exit;; s) echo -e "Syncing all catalogs, please wait.." && cli -c 'app catalog sync_all' &> /dev/null && echo -e "Catalog sync complete" ;; - i) - ignore+="$OPTARG" - ;; - t) - timeout=$OPTARG - re='^[0-9]+$' - ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n$timeout is not an interger" >&2 - ;; U) mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ,true,) [[ -z $array ]] && echo -e "\nThere are no updates available" && continue || echo -e "\n${#array[@]} update(s) available" From c97fabd643f450a9ed95796446cde68f9e02950a Mon Sep 17 00:00:00 2001 From: kyler Date: Sat, 23 Apr 2022 13:50:58 -0600 Subject: [PATCH 008/823] Help argument update --- heavy_script.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 1a26642d..4c9dfb2c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -10,12 +10,14 @@ do echo "These arguments NEED to be ran in a specific order, you can go from TOP to BOTTOM, see example below" echo "-m | Initiates mounting feature, choose between unmounting and mounting PVC data" echo "-i | Add application to ignore list, one by one, see example below." - echo "-t | Default: 300 -- Set a custom timeout: This is the ammount of time the script will wait for an application to go from DEPLOYING to ACTIVE" + echo "-t | Set a custom timeout in seconds for -u or -U: This is the ammount of time the script will wait for an application to go from DEPLOYING to ACTIVE" + echo "-t | Set a custom timeout in seconds for -m: Amount of time script will wait for applications to stop, before timing out" echo "-s | sync catalog" echo "-U | Update all applications, ignores versions" echo "-u | Update all applications, does not update Major releases" echo "-p | Prune unused/old docker images" - echo "EX |./update.sh -I portainer -I arch -I sonarr -I radarr -t 600 -sUp" + echo "EX |./heavy_script.sh -i portainer -i arch -i sonarr -i radarr -t 600 -sUp" + echo "EX | bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m" exit;; \?) echo "Invalid Option -$OPTARG, type -h for help" From 16e922e59ea046ce16ccccd2272b9e7d1d9f8efa Mon Sep 17 00:00:00 2001 From: kyler Date: Sat, 23 Apr 2022 15:13:57 -0600 Subject: [PATCH 009/823] video push --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 4c9dfb2c..81bd964c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -16,7 +16,7 @@ do echo "-U | Update all applications, ignores versions" echo "-u | Update all applications, does not update Major releases" echo "-p | Prune unused/old docker images" - echo "EX |./heavy_script.sh -i portainer -i arch -i sonarr -i radarr -t 600 -sUp" + echo "EX | bash heavy_script.sh -i portainer -i arch -i sonarr -i radarr -t 600 -sUp" echo "EX | bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m" exit;; \?) From e15cefa952c67ca6f6219d3aeb199df886e35674 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Apr 2022 08:04:01 -0600 Subject: [PATCH 010/823] -u/-U can now update container images (custom-app) --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 81bd964c..940b9b53 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -73,7 +73,7 @@ do echo -e "Syncing all catalogs, please wait.." && cli -c 'app catalog sync_all' &> /dev/null && echo -e "Catalog sync complete" ;; U) - mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ,true,) + mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep ",true") [[ -z $array ]] && echo -e "\nThere are no updates available" && continue || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nSetting Default Timeout to 300\nChange timeout with -t" && timeout=300 || echo -e "\nTimeout was set to $timeout" for i in "${array[@]}" @@ -111,7 +111,7 @@ do done ;; u) - mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ,true,) + mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true") [[ -z $array ]] && echo -e "\nThere are no updates available" && continue || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nSetting Default Timeout to 300\nChange timeout with -t" && timeout=300 || echo -e "\nTimeout was set to $timeout" for i in "${array[@]}" From 25c59c008caef7efc4f3d639f407594185f39544 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Apr 2022 00:37:36 +0000 Subject: [PATCH 011/823] Add Backup and Restore functions Adds the ability to backup, and restore the ix-applications dataset. Tested to be working. --- heavy_script.sh | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 940b9b53..52656900 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,12 +3,14 @@ #If no argument is passed, kill the script. [[ -z "$*" ]] && echo "This script requires an arguent, use -h for help" && exit -while getopts ":hsi:mt:uUp" opt +while getopts ":hsi:mrb:t:uUp" opt do case $opt in h) echo "These arguments NEED to be ran in a specific order, you can go from TOP to BOTTOM, see example below" echo "-m | Initiates mounting feature, choose between unmounting and mounting PVC data" + echo "-r | Opens a menu to restore a HeavyScript backup that was taken on you ix-applications pool" + echo "-b | Back-up your ix-applications dataset, specify a number after -b" echo "-i | Add application to ignore list, one by one, see example below." echo "-t | Set a custom timeout in seconds for -u or -U: This is the ammount of time the script will wait for an application to go from DEPLOYING to ACTIVE" echo "-t | Set a custom timeout in seconds for -m: Amount of time script will wait for applications to stop, before timing out" @@ -16,7 +18,7 @@ do echo "-U | Update all applications, ignores versions" echo "-u | Update all applications, does not update Major releases" echo "-p | Prune unused/old docker images" - echo "EX | bash heavy_script.sh -i portainer -i arch -i sonarr -i radarr -t 600 -sUp" + echo "EX | bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -sUp" echo "EX | bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m" exit;; \?) @@ -25,6 +27,36 @@ do :) echo "Option: -$OPTARG requires an argument" >&2 exit;; + b) + number_of_backups=$OPTARG + echo "Number of backups was set to $number_of_backups" + re='^[0-9]+$' + ! [[ $number_of_backups =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n$number_of_backups is not an interger" >&2 && exit + + date=$(date '+%Y_%m_%d_%H_%M_%S') + cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' + + mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -nr | awk -F '|' '{print $2}'| tr -d " \t\r") + overflow=$(expr ${#list_backups[@]} - $number_of_backups) + + if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then + echo && mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -nr | awk -F '|' '{print $2}'| tr -d " \t\r" | tail -n "$overflow") + for i in "${list_overflow[@]}" + do + cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null && echo -e "Deleting your oldest backup $i\nThis is to remain in the $number_of_backups backups range you set. " || echo "Failed to delete $i" + done + fi + ;; + r) + list_backups=$(cli -c 'app kubernetes list_backups' | sort -nr | tr -d " \t\r" | awk -F '|' '/HeavyScript_/{print NR-1, $2}') && echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection" | awk '{print $2}') && echo -e "\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible.\n\nYou have chosen to restore $restore_point\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } + if [[ $yesno == "1" ]]; then + echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" + elif [[ $yesno == "2" ]]; then + echo "You've chosen NO, killing script. Good luck." + else + echo "Invalid Selection" + fi + ;; i) ignore+="$OPTARG" ;; @@ -89,7 +121,7 @@ do echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'"$n"'"' &> /dev/null && echo -e "Updated\n$ov\n$nv\nWas Stopped, Beginning Stop Loop" && SECONDS=0 || { echo "FAILED"; continue; } while [[ "$status" != "ACTIVE" ]] do - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep $n | awk -F ',' '{print $2}') + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "$n" | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then echo -e "Stopped" break @@ -133,7 +165,7 @@ do echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'"$n"'"' &> /dev/null && echo -e "Updated\n$ov\n$nv" || echo "FAILED" continue elif [[ "$tt" == "$av" && "$status" == "STOPPED" ]]; then - echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'$n'"' &> /dev/null && echo -e "Updated\n$ov\n$nv\nWas Stopped, Beginning Stop Loop" && SECONDS=0 || { echo "FAILED"; continue; } + echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'"$n"'"' &> /dev/null && echo -e "Updated\n$ov\n$nv\nWas Stopped, Beginning Stop Loop" && SECONDS=0 || { echo "FAILED"; continue; } while [[ "$status" != "ACTIVE" ]] do status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "$n" | awk -F ',' '{print $2}') From f171428f647ceac16e6117502da5799218f3ab71 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Apr 2022 01:02:11 +0000 Subject: [PATCH 012/823] Fix restore numbering Tried just using awk, rather than grepping into awk, but it didnt work out --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 52656900..891897a3 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -48,7 +48,7 @@ do fi ;; r) - list_backups=$(cli -c 'app kubernetes list_backups' | sort -nr | tr -d " \t\r" | awk -F '|' '/HeavyScript_/{print NR-1, $2}') && echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection" | awk '{print $2}') && echo -e "\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible.\n\nYou have chosen to restore $restore_point\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } + list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | tr -d " \t\r" | awk -F '|' '{print NR-1, $2}' | column -t) && echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection" | awk '{print $2}') && echo -e "\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible.\n\nYou have chosen to restore $restore_point\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } if [[ $yesno == "1" ]]; then echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" elif [[ $yesno == "2" ]]; then From d76c5f927a1c5c038f86ee1e2e1eb5d26d3f7550 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Apr 2022 01:09:42 +0000 Subject: [PATCH 013/823] re-added sort --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 891897a3..313f6b2d 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -48,7 +48,7 @@ do fi ;; r) - list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | tr -d " \t\r" | awk -F '|' '{print NR-1, $2}' | column -t) && echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection" | awk '{print $2}') && echo -e "\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible.\n\nYou have chosen to restore $restore_point\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } + list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -rn | tr -d " \t\r" | awk -F '|' '{print NR-1, $2}' | column -t) && echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection" | awk '{print $2}') && echo -e "\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible.\n\nYou have chosen to restore $restore_point\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } if [[ $yesno == "1" ]]; then echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" elif [[ $yesno == "2" ]]; then From 8c066d9a29b59ea4803580710fcc9b3072576560 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Apr 2022 01:19:13 +0000 Subject: [PATCH 014/823] actually place information in the readme --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 88d070e1..452a4cc2 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,21 @@ # heavy_script Script that can: Update Truenas SCALE applications, Mount and unmount PVC storage, Prune Docker images. + + +## These arguments NEED to be ran in a specific order, you can go from TOP to BOTTOM, see example below +- -m | Initiates mounting feature, choose between unmounting and mounting PVC data" +- -r | Opens a menu to restore a HeavyScript backup that was taken on you ix-applications pool" +- -b | Back-up your ix-applications dataset, specify a number after -b" +- -i | Add application to ignore list, one by one, see example below." +- -t | Set a custom timeout in seconds for -u or -U: This is the ammount of time the script will wait for an application to go from DEPLOYING to ACTIVE" +- -t | Set a custom timeout in seconds for -m: Amount of time script will wait for applications to stop, before timing out" +- -s | sync catalog" +- -U | Update all applications, ignores versions" +- -u | Update all applications, does not update Major releases" +- -p | Prune unused/old docker images" + + + +### Examples +- bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -sUp" +- bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m" From cd212882dc38b61cccaa13db57bc521d4062f392 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Apr 2022 01:30:18 +0000 Subject: [PATCH 015/823] rough update for readme --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 452a4cc2..717cdda1 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,15 @@ Script that can: Update Truenas SCALE applications, Mount and unmount PVC storag - -p | Prune unused/old docker images" - ### Examples -- bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -sUp" -- bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m" +#### bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -sup +- This is your typical cron job implementation. +- -b is set to 14. Up to 14 snapshots of your ix-applications dataset will be saved +- -i is set to ignore portainer, arch, sonarr, and radarr. These applications will be ignored when it comes to updates. +- -t I set it to 600 seconds, this means the script will wait 600 seconds for the application to become ACTIVE before timing out and continuing to a different application. +- -s will just sync the repositories, ensuring you are downloading the latest updates +- -u update applications as long as the major version has absolutely no change, if it does have a change it will ask the user to update manually. +- -p Prune docker images. + +- bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m +- bash /mnt/tank/scripts/heavy_script/heavy_script.sh -r From cdd3fb8c6a9084226e85ebfb9ee1d9dbc580a087 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Apr 2022 01:39:44 +0000 Subject: [PATCH 016/823] Add personal Cron Job --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 717cdda1..af57c590 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,7 @@ Script that can: Update Truenas SCALE applications, Mount and unmount PVC storag - bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m - bash /mnt/tank/scripts/heavy_script/heavy_script.sh -r + + +### My personal Cron Job +- ```git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -sup``` From ea90a42c744d16600a036cf5be637f38d2071d30 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Apr 2022 01:40:54 +0000 Subject: [PATCH 017/823] formatting --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 313f6b2d..01aaef1e 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -102,7 +102,7 @@ do fi exit;; s) - echo -e "Syncing all catalogs, please wait.." && cli -c 'app catalog sync_all' &> /dev/null && echo -e "Catalog sync complete" + echo -e "\nSyncing all catalogs, please wait.." && cli -c 'app catalog sync_all' &> /dev/null && echo -e "Catalog sync complete" ;; U) mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep ",true") From e280bad4d2e5e34ed7fec6068a6899fec5c31f9c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Apr 2022 01:43:20 +0000 Subject: [PATCH 018/823] formatting last change i swear. Ive just been trying to get things nicely formatted and working. --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 01aaef1e..7988b08e 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -29,7 +29,7 @@ do exit;; b) number_of_backups=$OPTARG - echo "Number of backups was set to $number_of_backups" + echo -e "\nNumber of backups was set to $number_of_backups" re='^[0-9]+$' ! [[ $number_of_backups =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n$number_of_backups is not an interger" >&2 && exit From 9e066803636a385681be6998ba1e10c7acb863f8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Apr 2022 02:10:33 +0000 Subject: [PATCH 019/823] Place overflow within if statement doing unnecessary math when it might not be required. This will probably save 12 nanoseconds. --- heavy_script.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 7988b08e..18d5eb2f 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -35,11 +35,9 @@ do date=$(date '+%Y_%m_%d_%H_%M_%S') cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' - mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -nr | awk -F '|' '{print $2}'| tr -d " \t\r") - overflow=$(expr ${#list_backups[@]} - $number_of_backups) - if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then + overflow=$(expr ${#list_backups[@]} - $number_of_backups) echo && mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -nr | awk -F '|' '{print $2}'| tr -d " \t\r" | tail -n "$overflow") for i in "${list_overflow[@]}" do From fdf19626fac5beb7125fd6e50b23fab3758e4e5e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 3 May 2022 21:38:10 -0600 Subject: [PATCH 020/823] better method of finding PVC_path --- heavy_script.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 18d5eb2f..74ea770a 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -80,8 +80,9 @@ do done data_name=$(echo "$pvc" | awk '{print $3}') mount=$(echo "$pvc" | awk '{print $4}') - path=$(find /*/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - echo -e "\nMounting\n""$path""""$mount""\nTo\n/mnt/temporary/$data_name" && zfs set mountpoint=/temporary/"$data_name" "$path""$mount" && echo -e "Mounted\n\nUnmount with the following command\nzfs set mountpoint=legacy ""$path"""$mount"\nOr use the Unmount All option" + volume_name=$(echo "$pvc" | awk '{print $4}') + full_path=$(zfs list | grep $volume_name | awk '{print $1}') + echo -e "\nMounting\n"$full_path"\nTo\n/mnt/temporary/$data_name" && zfs set mountpoint=/temporary/"$data_name" "$full_path" && echo -e "Mounted\n\nUnmount with the following command\nzfs set mountpoint=legacy "$full_path" && rmdir /mnt/temporary/"$data_name"\nOr use the Unmount All option" break elif [[ $selection == "2" ]]; then mapfile -t unmount_array < <(basename -a /mnt/temporary/* | sed "s/*//") From 07ca4b940115696721e9d530f2c0f44a9589feb3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 4 May 2022 23:38:58 +0000 Subject: [PATCH 021/823] Sort Update output alphabetically --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 74ea770a..1b7ef5c8 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -104,7 +104,7 @@ do echo -e "\nSyncing all catalogs, please wait.." && cli -c 'app catalog sync_all' &> /dev/null && echo -e "Catalog sync complete" ;; U) - mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep ",true") + mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep ",true" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" && continue || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nSetting Default Timeout to 300\nChange timeout with -t" && timeout=300 || echo -e "\nTimeout was set to $timeout" for i in "${array[@]}" @@ -142,7 +142,7 @@ do done ;; u) - mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true") + mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep ",true" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" && continue || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nSetting Default Timeout to 300\nChange timeout with -t" && timeout=300 || echo -e "\nTimeout was set to $timeout" for i in "${array[@]}" From b8765964d223bc5991cfe5c22ce1619c11d79be0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 4 May 2022 22:07:55 -0600 Subject: [PATCH 022/823] Mounting feature improvement --- heavy_script.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 74ea770a..a670ad8b 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -71,8 +71,13 @@ do echo "$list" && read -p "Please type a number : " selection app=$(echo -e "$list" | grep ^"$selection" | awk '{print $2}' | cut -c 4-) pvc=$(echo -e "$list" | grep ^"$selection" || echo -e "\nInvalid selection") - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") && SECONDS=0 - [[ "$status" != "STOPPED" ]] && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null && [[ -z $timeout ]] && echo -e "\nSetting Default Timeout to 300\nChange timeout with -t" && timeout=300 || echo -e "\nTimeout was set to $timeout" + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + if [[ "$status" != "STOPPED" ]]; then + [[ -z $timeout ]] && echo -e "\nSetting Default Timeout to 300\nChange timeout with -t" && timeout=300 || echo -e "\nTimeout was set to $timeout" + SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null + else + echo -e "\n$app is already stopped" + fi while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] do status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") @@ -82,7 +87,7 @@ do mount=$(echo "$pvc" | awk '{print $4}') volume_name=$(echo "$pvc" | awk '{print $4}') full_path=$(zfs list | grep $volume_name | awk '{print $1}') - echo -e "\nMounting\n"$full_path"\nTo\n/mnt/temporary/$data_name" && zfs set mountpoint=/temporary/"$data_name" "$full_path" && echo -e "Mounted\n\nUnmount with the following command\nzfs set mountpoint=legacy "$full_path" && rmdir /mnt/temporary/"$data_name"\nOr use the Unmount All option" + echo -e "\nMounting\n"$full_path"\nTo\n/mnt/temporary/$data_name" && zfs set mountpoint=/temporary/"$data_name" "$full_path" && echo -e "Mounted\n\nUnmount with the following command\nzfs set mountpoint=legacy "$full_path" && rmdir /mnt/temporary/"$data_name"\nOr use the Unmount All option\n" break elif [[ $selection == "2" ]]; then mapfile -t unmount_array < <(basename -a /mnt/temporary/* | sed "s/*//") From 48023d7f8196cb552733ca3ead34cec647dbcdcf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 5 May 2022 12:29:01 +0000 Subject: [PATCH 023/823] proper Restore indentation --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 70e9daa9..7070e6f7 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -48,7 +48,7 @@ do r) list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -rn | tr -d " \t\r" | awk -F '|' '{print NR-1, $2}' | column -t) && echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection" | awk '{print $2}') && echo -e "\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible.\n\nYou have chosen to restore $restore_point\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } if [[ $yesno == "1" ]]; then - echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" + echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" elif [[ $yesno == "2" ]]; then echo "You've chosen NO, killing script. Good luck." else From b4e5b45045dd03bc99ab585a2ccd5dbef08d7655 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 10 May 2022 03:54:31 +0000 Subject: [PATCH 024/823] Backport Truescript Changes 1. Arguments can be used in any order now (Thanks Ornias) 2. Rollback applications feature (Ornias' Idea, again thank you) - When using -R The script will monitor the status of the application after updating it, make sure it deploys, if the app does not deploy within the timeout, roll the application back 3. Ability to stop applications prior to updating with -S (another idea by ornias) 4. Option for verbose output with -v I made this change after adding the new features, it makes the output ugly, but figured id give the users the choice to see more information. 5. Better variable names 6. A ton of other various little fixes and testing You can view the current work, and who exactly did what, and when with this link: https://github.com/truecharts/truescript/commits/optimise My current un-pulled Pull Request: https://github.com/truecharts/truescript/pull/5 --- heavy_script.sh | 476 ++++++++++++++++++++++++++++-------------------- 1 file changed, 283 insertions(+), 193 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 7070e6f7..1d5bd7ba 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,199 +1,289 @@ #!/bin/bash - #If no argument is passed, kill the script. [[ -z "$*" ]] && echo "This script requires an arguent, use -h for help" && exit -while getopts ":hsi:mrb:t:uUp" opt +while getopts ":hsi:mrb:t:uUpSRv" opt do - case $opt in - h) - echo "These arguments NEED to be ran in a specific order, you can go from TOP to BOTTOM, see example below" - echo "-m | Initiates mounting feature, choose between unmounting and mounting PVC data" - echo "-r | Opens a menu to restore a HeavyScript backup that was taken on you ix-applications pool" - echo "-b | Back-up your ix-applications dataset, specify a number after -b" - echo "-i | Add application to ignore list, one by one, see example below." - echo "-t | Set a custom timeout in seconds for -u or -U: This is the ammount of time the script will wait for an application to go from DEPLOYING to ACTIVE" - echo "-t | Set a custom timeout in seconds for -m: Amount of time script will wait for applications to stop, before timing out" - echo "-s | sync catalog" - echo "-U | Update all applications, ignores versions" - echo "-u | Update all applications, does not update Major releases" - echo "-p | Prune unused/old docker images" - echo "EX | bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -sUp" - echo "EX | bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m" - exit;; - \?) - echo "Invalid Option -$OPTARG, type -h for help" - exit;; - :) - echo "Option: -$OPTARG requires an argument" >&2 - exit;; - b) - number_of_backups=$OPTARG - echo -e "\nNumber of backups was set to $number_of_backups" - re='^[0-9]+$' - ! [[ $number_of_backups =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n$number_of_backups is not an interger" >&2 && exit - - date=$(date '+%Y_%m_%d_%H_%M_%S') - cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' - mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -nr | awk -F '|' '{print $2}'| tr -d " \t\r") - if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then - overflow=$(expr ${#list_backups[@]} - $number_of_backups) - echo && mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -nr | awk -F '|' '{print $2}'| tr -d " \t\r" | tail -n "$overflow") - for i in "${list_overflow[@]}" - do - cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null && echo -e "Deleting your oldest backup $i\nThis is to remain in the $number_of_backups backups range you set. " || echo "Failed to delete $i" - done - fi - ;; - r) - list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -rn | tr -d " \t\r" | awk -F '|' '{print NR-1, $2}' | column -t) && echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection" | awk '{print $2}') && echo -e "\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible.\n\nYou have chosen to restore $restore_point\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } - if [[ $yesno == "1" ]]; then - echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" - elif [[ $yesno == "2" ]]; then - echo "You've chosen NO, killing script. Good luck." - else - echo "Invalid Selection" - fi - ;; - i) - ignore+="$OPTARG" - ;; - t) - timeout=$OPTARG - re='^[0-9]+$' - ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n$timeout is not an interger" >&2 - ;; - m) - echo -e "1 Mount\n2 Unmount All" && read -p "Please type a number: " selection - - if [[ $selection == "1" ]]; then - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") - echo "$list" && read -p "Please type a number : " selection - app=$(echo -e "$list" | grep ^"$selection" | awk '{print $2}' | cut -c 4-) - pvc=$(echo -e "$list" | grep ^"$selection" || echo -e "\nInvalid selection") - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - if [[ "$status" != "STOPPED" ]]; then - [[ -z $timeout ]] && echo -e "\nSetting Default Timeout to 300\nChange timeout with -t" && timeout=300 || echo -e "\nTimeout was set to $timeout" - SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null - else - echo -e "\n$app is already stopped" - fi - while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] - do - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 10 - done - data_name=$(echo "$pvc" | awk '{print $3}') - mount=$(echo "$pvc" | awk '{print $4}') - volume_name=$(echo "$pvc" | awk '{print $4}') - full_path=$(zfs list | grep $volume_name | awk '{print $1}') - echo -e "\nMounting\n"$full_path"\nTo\n/mnt/temporary/$data_name" && zfs set mountpoint=/temporary/"$data_name" "$full_path" && echo -e "Mounted\n\nUnmount with the following command\nzfs set mountpoint=legacy "$full_path" && rmdir /mnt/temporary/"$data_name"\nOr use the Unmount All option\n" - break - elif [[ $selection == "2" ]]; then - mapfile -t unmount_array < <(basename -a /mnt/temporary/* | sed "s/*//") - [[ -z $unmount_array ]] && echo "Theres nothing to unmount" && exit - for i in "${unmount_array[@]}" - do - main=$(k3s kubectl get pvc -A | grep "$i" | awk '{print $1, $2, $4}') - app=$(echo "$main" | awk '{print $1}' | cut -c 4-) - pvc=$(echo "$main" | awk '{print $3}') - path=$(find /*/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/temporary/"$i" || echo "failed to unmount $i" - done - else - echo "Invalid selection, type -h for help" - break - fi - exit;; - s) - echo -e "\nSyncing all catalogs, please wait.." && cli -c 'app catalog sync_all' &> /dev/null && echo -e "Catalog sync complete" - ;; - U) - mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep ",true" | sort) - [[ -z $array ]] && echo -e "\nThere are no updates available" && continue || echo -e "\n${#array[@]} update(s) available" - [[ -z $timeout ]] && echo -e "\nSetting Default Timeout to 300\nChange timeout with -t" && timeout=300 || echo -e "\nTimeout was set to $timeout" - for i in "${array[@]}" - do - n=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. - ov=$(echo "$i" | awk -F ',' '{print $4}') #Old version - nv=$(echo "$i" | awk -F ',' '{print $5}') #New Version - status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE - if [[ "${ignore[*]}" == *"${n}"* ]]; then - echo -e "\n$n\nIgnored, skipping" - continue - elif [[ "$status" == "STOPPED" ]]; then - echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'"$n"'"' &> /dev/null && echo -e "Updated\n$ov\n$nv\nWas Stopped, Beginning Stop Loop" && SECONDS=0 || { echo "FAILED"; continue; } - while [[ "$status" != "ACTIVE" ]] - do - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "$n" | awk -F ',' '{print $2}') - if [[ "$status" == "STOPPED" ]]; then - echo -e "Stopped" - break - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then - echo -e "Error: Run Time($SECONDS) has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher time with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nNot shutting down application for safety reasons, continuing to next applicaion" - break - elif [[ "$status" == "DEPLOYING" ]]; then - echo -e "Waiting $((timeout-SECONDS)) more seconds for $n to be ACTIVE" && sleep 15 - continue - else - echo -e "Returing to STOPPED state.." && midclt call chart.release.scale "$n" '{"replica_count": 0}' &> /dev/null && echo -e "Stopped"|| echo "FAILED" - break - fi - done - else - echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'"$n"'"' &> /dev/null && echo -e "Updated\n$ov\n$nv" || echo -e "FAILED" - continue - fi - done - ;; - u) - mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep ",true" | sort) - [[ -z $array ]] && echo -e "\nThere are no updates available" && continue || echo -e "\n${#array[@]} update(s) available" - [[ -z $timeout ]] && echo -e "\nSetting Default Timeout to 300\nChange timeout with -t" && timeout=300 || echo -e "\nTimeout was set to $timeout" - for i in "${array[@]}" - do - n=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. - ottv=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous Truecharts version - nttv=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous version) #New Truecharts Version - oav=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') #previous version) #New App Version - nav=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') #previous version) #New App Version - status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE - tt=$(diff <(echo "$ottv") <(echo "$nttv")) #caluclating difference in major Truecharts versions - av=$(diff <(echo "$oav") <(echo "$nav")) #caluclating difference in major app versions - ov=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From - nv=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To - if [[ "${ignore[*]}" == *"${n}"* ]]; then - echo -e "\n$n\nIgnored, skipping" - continue - elif [[ "$tt" == "$av" && "$status" == "ACTIVE" || "$status" == "DEPLOYING" ]]; then - echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'"$n"'"' &> /dev/null && echo -e "Updated\n$ov\n$nv" || echo "FAILED" - continue - elif [[ "$tt" == "$av" && "$status" == "STOPPED" ]]; then - echo -e "\n$n\nUpdating" && cli -c 'app chart_release upgrade release_name=''"'"$n"'"' &> /dev/null && echo -e "Updated\n$ov\n$nv\nWas Stopped, Beginning Stop Loop" && SECONDS=0 || { echo "FAILED"; continue; } - while [[ "$status" != "ACTIVE" ]] - do - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "$n" | awk -F ',' '{print $2}') - if [[ "$status" == "STOPPED" ]]; then - echo -e "Stopped" - break - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then - echo -e "Error: Run Time($SECONDS) has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher time with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nNot shutting down application for safety reasons, continuing to next applicaion" - break - elif [[ "$status" == "DEPLOYING" ]]; then - echo -e "Waiting $((timeout-SECONDS)) more seconds for $n to be ACTIVE" && sleep 15 - continue - else - echo "Returing to STOPPED state.." && midclt call chart.release.scale "$n" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo -e "FAILED" - break - fi - done - else - echo -e "\n$n\nMajor Release, update manually" - continue - fi - done - ;; - p) - echo -e "\nPruning Docker Images" && docker image prune -af | grep Total || echo "Failed to Prune Docker Images" - esac + case $opt in + h) + echo "-m | Initiates mounting feature, choose between unmounting and mounting PVC data" + echo "-r | Opens a menu to restore a heavy_script backup that was taken on you ix-applications pool" + echo "-b | Back-up your ix-applications dataset, specify a number after -b" + echo "-i | Add application to ignore list, one by one, see example below." + echo "-R | Roll-back applications if they fail to update" + echo "-S | Shutdown applications prior to updating" + echo "-v | verbose output" + echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo "-s | sync catalog" + echo "-S | Stops App before update with -u or -U and restarts afterwards" + echo "-U | Update all applications, ignores versions" + echo "-u | Update all applications, does not update Major releases" + echo "-p | Prune unused/old docker images" + echo "-s | Stop App before attempting update" + echo "EX | bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vRsUp" + echo "EX | bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m" + exit + ;; + \?) + echo "Invalid Option -$OPTARG, type -h for help" + exit + ;; + :) + echo "Option: -$OPTARG requires an argument" >&2 + exit + ;; + b) + re='^[0-9]+$' + ! [[ $OPTARG =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n$number_of_backups is not an interger" >&2 && exit + number_of_backups=$OPTARG + echo -e "\nNumber of backups was set to $number_of_backups" + ;; + r) + restore="true" + ;; + i) + ignore+=("$OPTARG") + ;; + t) + re='^[0-9]+$' + timeout=$OPTARG + ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n$timeout is not an interger" >&2 && exit + ;; + m) + mount="true" + ;; + s) + sync="true" + ;; + U) + update_all_apps="true" + ;; + u) + update_apps="true" + ;; + S) + stop_before_update="true" + ;; + p) + prune="true" + ;; + R) + rollback="true" + ;; + v) + verbose="true" + ;; + esac done + +backup(){ +date=$(date '+%Y_%m_%d_%H_%M_%S') +[[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' +[[ -z "$verbose" ]] && echo -e "\nNew Backup Name:" && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 +mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") +if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then + echo -e "\nDeleting the oldest backup(s) for exceeding limit:" + overflow=$(expr ${#list_backups[@]} - $number_of_backups) + mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | tail -n "$overflow") + for i in "${list_overflow[@]}" + do + cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo "Failed to delete $i" + echo "$i" + done +fi +} +export -f backup + +restore(){ +list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -rV | tr -d " \t\r" | awk -F '|' '{print NR-1, $2}' | column -t) && echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection" | awk '{print $2}') && echo -e "\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible.\n\nYou have chosen to restore $restore_point\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } +if [[ $yesno == "1" ]]; then + echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" +elif [[ $yesno == "2" ]]; then + echo "You've chosen NO, killing script. Good luck." +else + echo "Invalid Selection" +fi +} +export -f restore + +mount(){ +echo -e "1 Mount\n2 Unmount All" && read -p "Please type a number: " selection + +if [[ $selection == "1" ]]; then + list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + echo "$list" && read -p "Please type a number : " selection + app=$(echo -e "$list" | grep ^"$selection" | awk '{print $2}' | cut -c 4-) + pvc=$(echo -e "$list" | grep ^"$selection" || echo -e "\nInvalid selection") + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + if [[ "$status" != "STOPPED" ]]; then + [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nTimeout was set to $timeout" + SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null + else + echo -e "\n$app is already stopped" + fi + while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] + do + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 10 + done + data_name=$(echo "$pvc" | awk '{print $3}') + mount=$(echo "$pvc" | awk '{print $4}') + volume_name=$(echo "$pvc" | awk '{print $4}') + full_path=$(zfs list | grep $volume_name | awk '{print $1}') + echo -e "\nMounting\n"$full_path"\nTo\n/mnt/temporary/$data_name" && zfs set mountpoint=/temporary/"$data_name" "$full_path" && echo -e "Mounted\n\nUnmount with the following command\nzfs set mountpoint=legacy "$full_path" && rmdir /mnt/temporary/"$data_name"\nOr use the Unmount All option\n" + exit +elif [[ $selection == "2" ]]; then + mapfile -t unmount_array < <(basename -a /mnt/temporary/* | sed "s/*//") + [[ -z $unmount_array ]] && echo "Theres nothing to unmount" && exit + for i in "${unmount_array[@]}" + do + main=$(k3s kubectl get pvc -A | grep "$i" | awk '{print $1, $2, $4}') + app=$(echo "$main" | awk '{print $1}' | cut -c 4-) + pvc=$(echo "$main" | awk '{print $3}') + path=$(find /*/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/temporary/"$i" || echo "failed to unmount $i" + done +else + echo "Invalid selection, type -h for help" + break +fi +} +export -f mount + +sync(){ +echo -e "\nSyncing all catalogs, please wait.." && cli -c 'app catalog sync_all' &> /dev/null && echo -e "Catalog sync complete" +} +export -f sync + +prune(){ +echo -e "\nPruning Docker Images" && docker image prune -af | grep Total || echo "Failed to Prune Docker Images" +} +export -f prune + +update_apps(){ + mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep ",true" | sort) + [[ -z $array ]] && echo -e "\nThere are no updates available" || echo -e "\n${#array[@]} update(s) available" + [[ -z $timeout ]] && echo -e "\nSetting Default Timeout to 500\nChange timeout with -t" && timeout=500 || echo -e "\nTimeout was set to $timeout" + for i in "${array[@]}" + do + app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. + old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version + new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version + old_chart_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version + new_chart_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version + status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE + diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions + diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions + old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From + new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To + rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') + [[ "${ignore[*]}" == *"${app_name}"* ]] && echo -e "\n$app_name\nIgnored, skipping" && continue + if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update + startstatus=$status + if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not + if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop + echo -e "\n$app_name" + [[ "$verbose" == "true" ]] && echo "Updating..." + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" + continue + else # if status was not STOPPED, stop the app prior to updating + echo -e "\n"$app_name"" + [[ "$verbose" == "true" ]] && echo "Stopping prior to update..." + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" + while [[ "$status" != "STOPPED" ]] + do + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ""$app_name"," | awk -F ',' '{print $2}') + if [[ "$status" == "STOPPED" ]]; then + echo "Stopped" + [[ "$verbose" == "true" ]] && echo "Updating..." + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "Failed to update" + break + elif [[ "$SECONDS" -ge "$timeout" ]]; then + echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" + break + elif [[ "$status" != "STOPPED" ]]; then + [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED" + sleep 10 + continue + fi + done + fi + else #user must not be using -S, just update + echo -e "\n$app_name" + [[ "$verbose" == "true" ]] && echo "Updating..." + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || { echo "FAILED"; continue; } + fi + else + echo -e "\n$app_name\nMajor Release, update manually" + continue + fi + done +} +export -f update_apps + +after_update_actions(){ +SECONDS=0 +count=0 +if [[ $rollback == "true" ]]; then + while [[ "0" != "1" ]] + do + (( count++ )) + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ""$app_name"," | awk -F ',' '{print $2}') + if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then + [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" + break + elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" != "true" ]]; then + echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update..." + midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null + [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update + break + elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" == "true" ]]; then + echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning" + break + elif [[ "$status" == "STOPPED" ]]; then + [[ "$count" -le 1 ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -ge 2 ]] && echo "Error: Application appears to be stuck in stopped state" && break #if reports stopped any time after the first loop, assume its broken. + elif [[ "$status" == "ACTIVE" ]]; then + [[ "$count" -le 1 ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -ge 2 ]] && echo "Active" && break #if reports active any time after the first loop, assume actually active. + else + [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" + sleep 15 + continue + fi + done +else + if [[ "$startstatus" == "STOPPED" ]]; then + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ""$app_name"," | awk -F ',' '{print $2}') + while [[ "$status" != "STOPPED" ]] + do + (( count++ )) + [[ "$count" -ge 2 ]] && status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ""$app_name"," | awk -F ',' '{print $2}') #Skip first status check, due to the one directly above it. + if [[ "$status" == "STOPPED" ]]; then + echo "Stopped" + break + elif [[ "$status" == "ACTIVE" ]]; then + [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" + break + elif [[ "$SECONDS" -ge "$timeout" ]]; then + echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" + break + elif [[ "$status" != "STOPPED" ]]; then + [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" + sleep 10 + continue + fi + done + fi +fi +} +export -f prune + +[[ $restore == "true" ]] && restore && exit +[[ $number_of_backups -gt 0 ]] && backup +[[ $mount == "true" ]] && mount && exit +[[ $sync == "true" ]] && sync +[[ $update_all_apps == "true" || $update_apps == "true" ]] && update_apps +[[ $prune == "true" ]] && prune From 9d2f21d31f8ba1be80dd32029a47ffecc1d8c57a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 10 May 2022 04:53:19 +0000 Subject: [PATCH 025/823] update readme will update with a longer, proper readme later. --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index af57c590..21bb9ed0 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,13 @@ Script that can: Update Truenas SCALE applications, Mount and unmount PVC storage, Prune Docker images. -## These arguments NEED to be ran in a specific order, you can go from TOP to BOTTOM, see example below - -m | Initiates mounting feature, choose between unmounting and mounting PVC data" - -r | Opens a menu to restore a HeavyScript backup that was taken on you ix-applications pool" - -b | Back-up your ix-applications dataset, specify a number after -b" - -i | Add application to ignore list, one by one, see example below." +- -R | Roll-back applications if they fail to update +- -S | Shutdown applications prior to updating +- -v | verbose output - -t | Set a custom timeout in seconds for -u or -U: This is the ammount of time the script will wait for an application to go from DEPLOYING to ACTIVE" - -t | Set a custom timeout in seconds for -m: Amount of time script will wait for applications to stop, before timing out" - -s | sync catalog" From b4272324b26a9483602a8984632a4cffdd8d93af Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 9 May 2022 22:55:26 -0600 Subject: [PATCH 026/823] Personal Cron job --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 21bb9ed0..4f3fa0b4 100644 --- a/README.md +++ b/README.md @@ -32,4 +32,4 @@ Script that can: Update Truenas SCALE applications, Mount and unmount PVC storag ### My personal Cron Job -- ```git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -sup``` +- ```git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -Rsup``` From a8b9deac6a2c725f9c24293b1f579a3a984ddc39 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 10 May 2022 12:48:35 -0600 Subject: [PATCH 027/823] cleaner timemout message --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 1d5bd7ba..b80ca5b8 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -116,7 +116,7 @@ if [[ $selection == "1" ]]; then pvc=$(echo -e "$list" | grep ^"$selection" || echo -e "\nInvalid selection") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then - [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nTimeout was set to $timeout" + [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null else echo -e "\n$app is already stopped" @@ -163,7 +163,7 @@ export -f prune update_apps(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep ",true" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" || echo -e "\n${#array[@]} update(s) available" - [[ -z $timeout ]] && echo -e "\nSetting Default Timeout to 500\nChange timeout with -t" && timeout=500 || echo -e "\nTimeout was set to $timeout" + [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" for i in "${array[@]}" do app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. From 174450ec3d342f9f6d9f3a5907dc169a302db487 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 10 May 2022 19:20:01 +0000 Subject: [PATCH 028/823] Update Readme --- README.md | 60 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 4f3fa0b4..aac04cd5 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,51 @@ # heavy_script -Script that can: Update Truenas SCALE applications, Mount and unmount PVC storage, Prune Docker images. +Update | Backup | Restore | Mount PVC | Rollback Applications | Sync Catalog | Prune Docker Images -- -m | Initiates mounting feature, choose between unmounting and mounting PVC data" -- -r | Opens a menu to restore a HeavyScript backup that was taken on you ix-applications pool" -- -b | Back-up your ix-applications dataset, specify a number after -b" -- -i | Add application to ignore list, one by one, see example below." -- -R | Roll-back applications if they fail to update -- -S | Shutdown applications prior to updating -- -v | verbose output -- -t | Set a custom timeout in seconds for -u or -U: This is the ammount of time the script will wait for an application to go from DEPLOYING to ACTIVE" -- -t | Set a custom timeout in seconds for -m: Amount of time script will wait for applications to stop, before timing out" -- -s | sync catalog" -- -U | Update all applications, ignores versions" -- -u | Update all applications, does not update Major releases" -- -p | Prune unused/old docker images" - +| Flag | Example | Parameter | Description | +|------ |------------------------ |----------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| -r | -r | None | Restore HeavyScript specific 'ix-applications dataset' snapshot | +| -m | -m | None | Initiates mounting feature
Choose between unmounting and mounting PVC data | +| -b | -b 14 | int | Backup 'ix-appliactions' dataset
Creates backups up to the number you've chosen | +| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating | +| -R | -R | None | Monitors applications after they update
If the app does not become "ACTIVE" after either:
The custom Timeout, or Default Timeout,
rollback the application. | +| -v | -v | None | Verbose output | +| -S | -S | None | Shutdown applications prior to updating | +| -t | -t 150 | int | Set a custom timeout to be used with either:
-m
- Time the script will wait for application to be "STOPPED"
or
-u/U
- Time the script will wait for application to be either "STOPPED" or "ACTIVE" | +| -s | -s | None | Sync Catalog before updating | +| -U | -U | None | Update applications, ignoring major version changes | +| -u | -u | None | Update applications, do NOT update if there was a major version change | +| -p | -p | None | Prune old/unused docker images | +
+
### Examples -#### bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -sup -- This is your typical cron job implementation. +#### Typical Cron Job +``` +bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -Rsup +``` + - -b is set to 14. Up to 14 snapshots of your ix-applications dataset will be saved - -i is set to ignore portainer, arch, sonarr, and radarr. These applications will be ignored when it comes to updates. - -t I set it to 600 seconds, this means the script will wait 600 seconds for the application to become ACTIVE before timing out and continuing to a different application. -- -s will just sync the repositories, ensuring you are downloading the latest updates +- -R Will rollback applications if they fail to deploy after updating. +- -s will just sync the repositories, ensuring you are downloading the latest updates. - -u update applications as long as the major version has absolutely no change, if it does have a change it will ask the user to update manually. - -p Prune docker images. -- bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m -- bash /mnt/tank/scripts/heavy_script/heavy_script.sh -r +#### Mounting PVC Data +``` +bash /mnt/tank/scripts/heavy_script.sh -t 300 -m +``` -### My personal Cron Job -- ```git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -Rsup``` +#### Restoring ix-applications dataset + +``` +bash /mnt/tank/scripts/heavy_script/heavy_script.sh -r +``` + +#### My personal Cron Job +``` +git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -Rsup +``` From 1bb08e7d860d8561b3df2bd75c9410f822ce1075 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 10 May 2022 14:46:47 -0600 Subject: [PATCH 029/823] better ignore list search --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index b80ca5b8..9f3d36ee 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -177,7 +177,7 @@ update_apps(){ old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') - [[ "${ignore[*]}" == *"${app_name}"* ]] && echo -e "\n$app_name\nIgnored, skipping" && continue + printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && continue #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update startstatus=$status if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not From e91fd6d2d20031df2e1ea6f9d41179cc3f837dbc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 10 May 2022 16:42:05 -0600 Subject: [PATCH 030/823] thwart wrong reporting --- heavy_script.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 9f3d36ee..b339bef2 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -256,21 +256,23 @@ if [[ $rollback == "true" ]]; then else if [[ "$startstatus" == "STOPPED" ]]; then status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ""$app_name"," | awk -F ',' '{print $2}') - while [[ "$status" != "STOPPED" ]] + while [[ "0" != "1" ]] do (( count++ )) [[ "$count" -ge 2 ]] && status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ""$app_name"," | awk -F ',' '{print $2}') #Skip first status check, due to the one directly above it. if [[ "$status" == "STOPPED" ]]; then - echo "Stopped" + [[ "$count" -le 1 ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -ge 2 ]] && echo "Stopped" && break #assume actually stopped anytime AFTER the first loop break elif [[ "$status" == "ACTIVE" ]]; then + [[ "$count" -le 1 ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" break elif [[ "$SECONDS" -ge "$timeout" ]]; then echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" break - elif [[ "$status" != "STOPPED" ]]; then + else [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" sleep 10 continue From 39e66836a2e3817ec02a36607f402d0bb2bb647e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 10 May 2022 17:37:20 -0600 Subject: [PATCH 031/823] after_update_actions optimizations --- heavy_script.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index b339bef2..64a5ad0a 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -243,10 +243,10 @@ if [[ $rollback == "true" ]]; then break elif [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -ge 2 ]] && echo "Error: Application appears to be stuck in stopped state" && break #if reports stopped any time after the first loop, assume its broken. + echo "Error: Application appears to be stuck in stopped state" && break #if reports stopped any time after the first loop, assume its broken. elif [[ "$status" == "ACTIVE" ]]; then [[ "$count" -le 1 ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -ge 2 ]] && echo "Active" && break #if reports active any time after the first loop, assume actually active. + echo "Active" && break #if reports active any time after the first loop, assume actually active. else [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" sleep 15 @@ -255,14 +255,13 @@ if [[ $rollback == "true" ]]; then done else if [[ "$startstatus" == "STOPPED" ]]; then - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ""$app_name"," | awk -F ',' '{print $2}') while [[ "0" != "1" ]] do (( count++ )) - [[ "$count" -ge 2 ]] && status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ""$app_name"," | awk -F ',' '{print $2}') #Skip first status check, due to the one directly above it. + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ""$app_name"," | awk -F ',' '{print $2}') #Skip first status check, due to the one directly above it. if [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -ge 2 ]] && echo "Stopped" && break #assume actually stopped anytime AFTER the first loop + echo "Stopped" && break #assume actually stopped anytime AFTER the first loop break elif [[ "$status" == "ACTIVE" ]]; then [[ "$count" -le 1 ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check From aca0c15ecd56ace98650abeb8ff5a1f4da720de5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 10 May 2022 17:56:23 -0600 Subject: [PATCH 032/823] Kill script if invalid selection --- heavy_script.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 64a5ad0a..990a6c20 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -95,7 +95,10 @@ fi export -f backup restore(){ -list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -rV | tr -d " \t\r" | awk -F '|' '{print NR-1, $2}' | column -t) && echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection" | awk '{print $2}') && echo -e "\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible.\n\nYou have chosen to restore $restore_point\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } +list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -rV | tr -d " \t\r" | awk -F '|' '{print NR-1, $2}' | column -t) +echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection" | awk '{print $2}') +[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script +echo -e "\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible.\n\nYou have chosen to restore $restore_point\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } if [[ $yesno == "1" ]]; then echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" elif [[ $yesno == "2" ]]; then @@ -112,8 +115,9 @@ echo -e "1 Mount\n2 Unmount All" && read -p "Please type a number: " selection if [[ $selection == "1" ]]; then list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") echo "$list" && read -p "Please type a number : " selection - app=$(echo -e "$list" | grep ^"$selection" | awk '{print $2}' | cut -c 4-) - pvc=$(echo -e "$list" | grep ^"$selection" || echo -e "\nInvalid selection") + app=$(echo -e "$list" | grep ^"$selection" | awk '{print $2}' | cut -c 4- ) + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script + pvc=$(echo -e "$list" | grep ^"$selection") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" @@ -145,7 +149,6 @@ elif [[ $selection == "2" ]]; then done else echo "Invalid selection, type -h for help" - break fi } export -f mount From 9111b7b490240d645f29aa337d7dbbd9d0f84db4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 10 May 2022 19:35:46 -0600 Subject: [PATCH 033/823] remove warning for ext services chart --- heavy_script.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 990a6c20..9513cb24 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -186,19 +186,19 @@ update_apps(){ if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Updating..." + [[ "$verbose" == "true" ]] && echo "Updating.." cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" continue else # if status was not STOPPED, stop the app prior to updating echo -e "\n"$app_name"" - [[ "$verbose" == "true" ]] && echo "Stopping prior to update..." + [[ "$verbose" == "true" ]] && echo "Stopping prior to update.." midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" while [[ "$status" != "STOPPED" ]] do status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ""$app_name"," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then echo "Stopped" - [[ "$verbose" == "true" ]] && echo "Updating..." + [[ "$verbose" == "true" ]] && echo "Updating.." cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "Failed to update" break elif [[ "$SECONDS" -ge "$timeout" ]]; then @@ -213,7 +213,7 @@ update_apps(){ fi else #user must not be using -S, just update echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Updating..." + [[ "$verbose" == "true" ]] && echo "Updating.." cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || { echo "FAILED"; continue; } fi else @@ -237,7 +237,7 @@ if [[ $rollback == "true" ]]; then midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" break elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" != "true" ]]; then - echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update..." + echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update.." midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update break @@ -245,10 +245,12 @@ if [[ $rollback == "true" ]]; then echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning" break elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - echo "Error: Application appears to be stuck in stopped state" && break #if reports stopped any time after the first loop, assume its broken. + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + echo "Stopped" && break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$status" == "ACTIVE" ]]; then - [[ "$count" -le 1 ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check echo "Active" && break #if reports active any time after the first loop, assume actually active. else [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" @@ -263,11 +265,13 @@ else (( count++ )) status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ""$app_name"," | awk -F ',' '{print $2}') #Skip first status check, due to the one directly above it. if [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check echo "Stopped" && break #assume actually stopped anytime AFTER the first loop break elif [[ "$status" == "ACTIVE" ]]; then - [[ "$count" -le 1 ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" break From e6250239c405e805d4ff481f076459d1dc245218 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 10 May 2022 20:10:26 -0600 Subject: [PATCH 034/823] start # line from 1 in Restore Function --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 9513cb24..45cacf27 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -95,7 +95,7 @@ fi export -f backup restore(){ -list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -rV | tr -d " \t\r" | awk -F '|' '{print NR-1, $2}' | column -t) +list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -rV | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection" | awk '{print $2}') [[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script echo -e "\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible.\n\nYou have chosen to restore $restore_point\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } From 9c6312c3e92544ee00a9463adfe2dd627fdb4727 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 10 May 2022 20:53:01 -0600 Subject: [PATCH 035/823] restore + mount cleanup --- heavy_script.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 45cacf27..6fc316f3 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -95,10 +95,13 @@ fi export -f backup restore(){ +clear -x list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -rV | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection" | awk '{print $2}') +[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script [[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script -echo -e "\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible.\n\nYou have chosen to restore $restore_point\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } +echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" || { echo "FAILED"; exit; } +echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } if [[ $yesno == "1" ]]; then echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" elif [[ $yesno == "2" ]]; then @@ -110,11 +113,13 @@ fi export -f restore mount(){ +clear -x echo -e "1 Mount\n2 Unmount All" && read -p "Please type a number: " selection - +[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script if [[ $selection == "1" ]]; then list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") echo "$list" && read -p "Please type a number : " selection + [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script app=$(echo -e "$list" | grep ^"$selection" | awk '{print $2}' | cut -c 4- ) [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script pvc=$(echo -e "$list" | grep ^"$selection") @@ -144,7 +149,7 @@ elif [[ $selection == "2" ]]; then main=$(k3s kubectl get pvc -A | grep "$i" | awk '{print $1, $2, $4}') app=$(echo "$main" | awk '{print $1}' | cut -c 4-) pvc=$(echo "$main" | awk '{print $3}') - path=$(find /*/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + path=$(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/temporary/"$i" || echo "failed to unmount $i" done else From 93e155c0f0ea4d5993bc5a70170cf3ba24dfd555 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 12 May 2022 01:15:28 +0000 Subject: [PATCH 036/823] Verbose information README --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index aac04cd5..1866db89 100644 --- a/README.md +++ b/README.md @@ -49,3 +49,19 @@ bash /mnt/tank/scripts/heavy_script/heavy_script.sh -r ``` git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -Rsup ``` + +
+
+ +### Additional Informaton + +#### Verbose vs Non-Verbose +- Verbose used `bash heavy_test.sh -b 5 -SRupv` +- Non-Verbose used `bash heavy_test.sh -b 5 -SRup` + +| Verbose | Non-Verbose | +|--------- |------------- | +| ![image](https://user-images.githubusercontent.com/20793231/167971188-07f71d02-8da3-4e0c-b9a0-cd26e7f63613.png) | ![image](https://user-images.githubusercontent.com/20793231/167972033-dc8d4ab4-4fb2-4c8a-b7dc-b9311ae55cf8.png) | + + + From 1edff4f384c496f19ec3ba53c0b92355a374732c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 12 May 2022 01:28:36 +0000 Subject: [PATCH 037/823] Re-arrange function calls --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 6fc316f3..d828eb59 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -295,8 +295,8 @@ fi export -f prune [[ $restore == "true" ]] && restore && exit -[[ $number_of_backups -gt 0 ]] && backup [[ $mount == "true" ]] && mount && exit +[[ $number_of_backups -gt 0 ]] && backup [[ $sync == "true" ]] && sync [[ $update_all_apps == "true" || $update_apps == "true" ]] && update_apps [[ $prune == "true" ]] && prune From 683e8b4d622c6a396a86a54d4d09289ac7cfd67e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 12 May 2022 04:28:27 +0000 Subject: [PATCH 038/823] Safety Checks 1. Ensure number of backups is AT LEAST 1. Im assuming a value of 0 would be user error.. so we want to ensure we have at least one backup 2. Make restore function use the same sorting method. Which ignores all words, only uses the values. 3. Changed mountpoint from `/temporary` to `/heavyscript` Hopefully to avoid any issues of users using /temporary for ANY other reason.. 4. Add a safety check within the unmount feature.. Before, there was a possibility users could have two applications, on separate pools, the script would try to mount to both of them. Obviously this is an issue. So we added a newline count, if the find command finds more than one entry for an application, use the slower, but more reliable method of checking the users current application pool, attempt to mount the application instance that exists on that pool. 5. If user tries using '-r' and '-m' at the same time, report an error and exit. Those two functions cannot be used at the same time.. --- heavy_script.sh | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index d828eb59..827a2f50 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -34,9 +34,9 @@ do ;; b) re='^[0-9]+$' - ! [[ $OPTARG =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n$number_of_backups is not an interger" >&2 && exit number_of_backups=$OPTARG - echo -e "\nNumber of backups was set to $number_of_backups" + ! [[ $OPTARG =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n"$number_of_backups" is not an interger" >&2 && exit + [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit ;; r) restore="true" @@ -47,7 +47,8 @@ do t) re='^[0-9]+$' timeout=$OPTARG - ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n$timeout is not an interger" >&2 && exit + ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n"$timeout" is not an interger" >&2 && exit + [[ "$timeout" -le 50 ]] && echo "Warning: Your timeout is set very low and may lead to premature rollbacks or skips" ;; m) mount="true" @@ -77,6 +78,7 @@ do done backup(){ +echo -e "\nNumber of backups was set to $number_of_backups" date=$(date '+%Y_%m_%d_%H_%M_%S') [[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' [[ -z "$verbose" ]] && echo -e "\nNew Backup Name:" && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 @@ -96,7 +98,7 @@ export -f backup restore(){ clear -x -list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -rV | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) +list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection" | awk '{print $2}') [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script [[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script @@ -139,10 +141,10 @@ if [[ $selection == "1" ]]; then mount=$(echo "$pvc" | awk '{print $4}') volume_name=$(echo "$pvc" | awk '{print $4}') full_path=$(zfs list | grep $volume_name | awk '{print $1}') - echo -e "\nMounting\n"$full_path"\nTo\n/mnt/temporary/$data_name" && zfs set mountpoint=/temporary/"$data_name" "$full_path" && echo -e "Mounted\n\nUnmount with the following command\nzfs set mountpoint=legacy "$full_path" && rmdir /mnt/temporary/"$data_name"\nOr use the Unmount All option\n" + echo -e "\nMounting\n"$full_path"\nTo\n/mnt/heavyscript/$data_name" && zfs set mountpoint=/heavyscript/"$data_name" "$full_path" && echo -e "Mounted\n\nUnmount with the following command\nzfs set mountpoint=legacy "$full_path" && rmdir /mnt/heavyscript/"$data_name"\nOr use the Unmount All option\n" exit elif [[ $selection == "2" ]]; then - mapfile -t unmount_array < <(basename -a /mnt/temporary/* | sed "s/*//") + mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") [[ -z $unmount_array ]] && echo "Theres nothing to unmount" && exit for i in "${unmount_array[@]}" do @@ -150,8 +152,16 @@ elif [[ $selection == "2" ]]; then app=$(echo "$main" | awk '{print $1}' | cut -c 4-) pvc=$(echo "$main" | awk '{print $3}') path=$(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/temporary/"$i" || echo "failed to unmount $i" + safety_check=$(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6- | wc -l) #if theres more than one new lines, that means theres more than one application with the same name on another pool. + if [[ "$safety_check" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused. + echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep dataset | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" && continue || echo "failed to unmount $i" + fi + zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" done + rmdir /mnt/heavyscript else echo "Invalid selection, type -h for help" fi @@ -268,7 +278,7 @@ else while [[ "0" != "1" ]] do (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ""$app_name"," | awk -F ',' '{print $2}') #Skip first status check, due to the one directly above it. + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ""$app_name"," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check @@ -294,9 +304,10 @@ fi } export -f prune -[[ $restore == "true" ]] && restore && exit -[[ $mount == "true" ]] && mount && exit -[[ $number_of_backups -gt 0 ]] && backup -[[ $sync == "true" ]] && sync -[[ $update_all_apps == "true" || $update_apps == "true" ]] && update_apps -[[ $prune == "true" ]] && prune +[[ "$restore" == "true" && "$mount" == "true" ]] && echo -e "The Restore Function(-r)\nand\nMount Function(-m)\nCannot both be called at the same time." && exit +[[ "$restore" == "true" ]] && restore && exit +[[ "$mount" == "true" ]] && mount && exit +[[ "$number_of_backups" -ge 1 ]] && backup +[[ "$sync" == "true" ]] && sync +[[ "$update_all_apps" == "true" || $update_apps == "true" ]] && update_apps +[[ "$prune" == "true" ]] && prune From 62f1e0a9c279d1df3ffc9426b5751b36a5b81724 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 12 May 2022 08:41:18 -0600 Subject: [PATCH 039/823] fix out of order deletion --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 827a2f50..082f5a44 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -86,7 +86,7 @@ mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavySc if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then echo -e "\nDeleting the oldest backup(s) for exceeding limit:" overflow=$(expr ${#list_backups[@]} - $number_of_backups) - mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | tail -n "$overflow") + mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | tail -n "$overflow" | sort -t '_' -V -k2,7) for i in "${list_overflow[@]}" do cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo "Failed to delete $i" From fb7b63169315bc1ff1c742dbdcb94a6a44cfb13c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 12 May 2022 08:54:48 -0600 Subject: [PATCH 040/823] remove need to rev sort --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 082f5a44..e312afff 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -86,7 +86,7 @@ mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavySc if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then echo -e "\nDeleting the oldest backup(s) for exceeding limit:" overflow=$(expr ${#list_backups[@]} - $number_of_backups) - mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | tail -n "$overflow" | sort -t '_' -V -k2,7) + mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") for i in "${list_overflow[@]}" do cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo "Failed to delete $i" From 22c454c326885f80936821f4601e465cf46ad84e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 13 May 2022 16:46:15 +0000 Subject: [PATCH 041/823] close update functino if no updates --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index e312afff..94e2de5b 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -180,7 +180,7 @@ export -f prune update_apps(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep ",true" | sort) - [[ -z $array ]] && echo -e "\nThere are no updates available" || echo -e "\n${#array[@]} update(s) available" + [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" for i in "${array[@]}" do From 0176e2c319c1fcd6fd28c020d6b5e6f84965405c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 13 May 2022 17:40:15 -0600 Subject: [PATCH 042/823] fix various issues --- heavy_script.sh | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 94e2de5b..b2f30c0a 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,5 +1,6 @@ #!/bin/bash #If no argument is passed, kill the script. + [[ -z "$*" ]] && echo "This script requires an arguent, use -h for help" && exit while getopts ":hsi:mrb:t:uUpSRv" opt @@ -35,7 +36,7 @@ do b) re='^[0-9]+$' number_of_backups=$OPTARG - ! [[ $OPTARG =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n"$number_of_backups" is not an interger" >&2 && exit + ! [[ $OPTARG =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit ;; r) @@ -47,8 +48,7 @@ do t) re='^[0-9]+$' timeout=$OPTARG - ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n"$timeout" is not an interger" >&2 && exit - [[ "$timeout" -le 50 ]] && echo "Warning: Your timeout is set very low and may lead to premature rollbacks or skips" + ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n\"""$timeout""\" is not an interger" >&2 && exit ;; m) mount="true" @@ -85,7 +85,7 @@ date=$(date '+%Y_%m_%d_%H_%M_%S') mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then echo -e "\nDeleting the oldest backup(s) for exceeding limit:" - overflow=$(expr ${#list_backups[@]} - $number_of_backups) + overflow=$(( ${#list_backups[@]} - "$number_of_backups" )) mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") for i in "${list_overflow[@]}" do @@ -97,9 +97,11 @@ fi export -f backup restore(){ -clear -x +clear -x && echo "pulling restore points.." list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) -echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection" | awk '{print $2}') +clear -x +[[ -z "$list_backups" ]] && echo "No HeavyScript restore points available" && exit || { title; echo "Choose a restore point" ; } +echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^""$selection" " | awk '{print $2}') [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script [[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" || { echo "FAILED"; exit; } @@ -116,6 +118,7 @@ export -f restore mount(){ clear -x +title echo -e "1 Mount\n2 Unmount All" && read -p "Please type a number: " selection [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script if [[ $selection == "1" ]]; then @@ -140,8 +143,8 @@ if [[ $selection == "1" ]]; then data_name=$(echo "$pvc" | awk '{print $3}') mount=$(echo "$pvc" | awk '{print $4}') volume_name=$(echo "$pvc" | awk '{print $4}') - full_path=$(zfs list | grep $volume_name | awk '{print $1}') - echo -e "\nMounting\n"$full_path"\nTo\n/mnt/heavyscript/$data_name" && zfs set mountpoint=/heavyscript/"$data_name" "$full_path" && echo -e "Mounted\n\nUnmount with the following command\nzfs set mountpoint=legacy "$full_path" && rmdir /mnt/heavyscript/"$data_name"\nOr use the Unmount All option\n" + full_path=$(zfs list | grep "$volume_name" | awk '{print $1}') + echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" && zfs set mountpoint=/heavyscript/"$data_name" "$full_path" && echo -e "Mounted\n\nUnmount with the following command\nzfs set mountpoint=legacy "$full_path" && rmdir /mnt/heavyscript/"$data_name"\nOr use the Unmount All option\n" exit elif [[ $selection == "2" ]]; then mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") @@ -182,6 +185,7 @@ update_apps(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep ",true" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" + [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" for i in "${array[@]}" do app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. @@ -205,7 +209,7 @@ update_apps(){ cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" continue else # if status was not STOPPED, stop the app prior to updating - echo -e "\n"$app_name"" + echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Stopping prior to update.." midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" while [[ "$status" != "STOPPED" ]] @@ -246,7 +250,7 @@ if [[ $rollback == "true" ]]; then while [[ "0" != "1" ]] do (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ""$app_name"," | awk -F ',' '{print $2}') + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep """$app_name""," | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" @@ -278,7 +282,7 @@ else while [[ "0" != "1" ]] do (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ""$app_name"," | awk -F ',' '{print $2}') + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep """$app_name""," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check @@ -304,10 +308,24 @@ fi } export -f prune +title(){ +echo ' _ _ _____ _ _ ' +echo '| | | | / ___| (_) | | ' +echo '| |_| | ___ __ ___ ___ _\ `--. ___ _ __ _ _ __ | |_' +echo "| _ |/ _ \/ _\` \ \ / / | | |\`--. \/ __| '__| | '_ \| __|" +echo '| | | | __/ (_| |\ V /| |_| /\__/ / (__| | | | |_) | |_ ' +echo '\_| |_/\___|\__,_| \_/ \__, \____/ \___|_| |_| .__/ \__|' +echo ' __/ | | | ' +echo ' |___/ |_| ' +echo +} +export -f title + [[ "$restore" == "true" && "$mount" == "true" ]] && echo -e "The Restore Function(-r)\nand\nMount Function(-m)\nCannot both be called at the same time." && exit [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit +[[ "$number_of_backups" -ge 1 && "$sync" == "true" ]] && [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && title [[ "$number_of_backups" -ge 1 ]] && backup [[ "$sync" == "true" ]] && sync -[[ "$update_all_apps" == "true" || $update_apps == "true" ]] && update_apps +[[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && update_apps [[ "$prune" == "true" ]] && prune From 71a2a49cc03c1a9911d171efbc2094e43b7f266b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 14 May 2022 00:09:35 +0000 Subject: [PATCH 043/823] remove ascii from updates. Looked awful in email :( --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index b2f30c0a..36c63bc5 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -324,7 +324,6 @@ export -f title [[ "$restore" == "true" && "$mount" == "true" ]] && echo -e "The Restore Function(-r)\nand\nMount Function(-m)\nCannot both be called at the same time." && exit [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit -[[ "$number_of_backups" -ge 1 && "$sync" == "true" ]] && [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && title [[ "$number_of_backups" -ge 1 ]] && backup [[ "$sync" == "true" ]] && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && update_apps From dc10af179884dbdb605cc8f7ebd12dd4d82abafa Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 14 May 2022 12:25:00 -0600 Subject: [PATCH 044/823] minor bugfixes --- heavy_script.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index b2f30c0a..cd472230 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -20,7 +20,7 @@ do echo "-U | Update all applications, ignores versions" echo "-u | Update all applications, does not update Major releases" echo "-p | Prune unused/old docker images" - echo "-s | Stop App before attempting update" + echo "-S | Stop App before attempting update" echo "EX | bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vRsUp" echo "EX | bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m" exit @@ -320,8 +320,10 @@ echo ' |___/ |_| ' echo } export -f title - +#exit if incompatable functions are called [[ "$restore" == "true" && "$mount" == "true" ]] && echo -e "The Restore Function(-r)\nand\nMount Function(-m)\nCannot both be called at the same time." && exit +[[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit +#Continue to call functions in specific order [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]] && [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && title From b4a53bcddba81523dcf650612ca3814f65aaca99 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 16 May 2022 17:49:48 -0600 Subject: [PATCH 045/823] misc changes --- heavy_script.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index cd472230..973ca5ee 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,7 +1,7 @@ #!/bin/bash -#If no argument is passed, kill the script. -[[ -z "$*" ]] && echo "This script requires an arguent, use -h for help" && exit +#If no argument is passed, kill the script. +[[ -z "$*" ]] && echo "This script requires an argument, use -h for help" && exit while getopts ":hsi:mrb:t:uUpSRv" opt do @@ -12,7 +12,7 @@ do echo "-b | Back-up your ix-applications dataset, specify a number after -b" echo "-i | Add application to ignore list, one by one, see example below." echo "-R | Roll-back applications if they fail to update" - echo "-S | Shutdown applications prior to updating" + echo "-S | Shutdown application prior to updating" echo "-v | verbose output" echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" echo "-s | sync catalog" @@ -20,7 +20,6 @@ do echo "-U | Update all applications, ignores versions" echo "-u | Update all applications, does not update Major releases" echo "-p | Prune unused/old docker images" - echo "-S | Stop App before attempting update" echo "EX | bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vRsUp" echo "EX | bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m" exit @@ -101,7 +100,7 @@ clear -x && echo "pulling restore points.." list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) clear -x [[ -z "$list_backups" ]] && echo "No HeavyScript restore points available" && exit || { title; echo "Choose a restore point" ; } -echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^""$selection" " | awk '{print $2}') +echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script [[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" || { echo "FAILED"; exit; } @@ -214,7 +213,7 @@ update_apps(){ midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" while [[ "$status" != "STOPPED" ]] do - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep ""$app_name"," | awk -F ',' '{print $2}') + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then echo "Stopped" [[ "$verbose" == "true" ]] && echo "Updating.." @@ -250,7 +249,7 @@ if [[ $rollback == "true" ]]; then while [[ "0" != "1" ]] do (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep """$app_name""," | awk -F ',' '{print $2}') + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" @@ -279,10 +278,10 @@ if [[ $rollback == "true" ]]; then done else if [[ "$startstatus" == "STOPPED" ]]; then - while [[ "0" != "1" ]] + while [[ "0" != "1" ]] #using a constant while loop, then breaking out of the loop with break commands below. do (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep """$app_name""," | awk -F ',' '{print $2}') + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check From 920ec3c6313da90bfe5902d83b402af8c1595f5b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 17 May 2022 21:31:55 -0600 Subject: [PATCH 046/823] various fixes/optimizations --- heavy_script.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 973ca5ee..9e3903f4 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,6 +1,6 @@ #!/bin/bash - #If no argument is passed, kill the script. + [[ -z "$*" ]] && echo "This script requires an argument, use -h for help" && exit while getopts ":hsi:mrb:t:uUpSRv" opt @@ -12,7 +12,7 @@ do echo "-b | Back-up your ix-applications dataset, specify a number after -b" echo "-i | Add application to ignore list, one by one, see example below." echo "-R | Roll-back applications if they fail to update" - echo "-S | Shutdown application prior to updating" + echo "-S | Shutdown applications prior to updating" echo "-v | verbose output" echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" echo "-s | sync catalog" @@ -20,6 +20,7 @@ do echo "-U | Update all applications, ignores versions" echo "-u | Update all applications, does not update Major releases" echo "-p | Prune unused/old docker images" + echo "-S | Stop App before attempting update" echo "EX | bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vRsUp" echo "EX | bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m" exit @@ -124,9 +125,9 @@ if [[ $selection == "1" ]]; then list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") echo "$list" && read -p "Please type a number : " selection [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script - app=$(echo -e "$list" | grep ^"$selection" | awk '{print $2}' | cut -c 4- ) + app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script - pvc=$(echo -e "$list" | grep ^"$selection") + pvc=$(echo -e "$list" | grep ^"$selection ") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" @@ -137,7 +138,7 @@ if [[ $selection == "1" ]]; then while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] do status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 10 + echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 done data_name=$(echo "$pvc" | awk '{print $3}') mount=$(echo "$pvc" | awk '{print $4}') @@ -278,7 +279,7 @@ if [[ $rollback == "true" ]]; then done else if [[ "$startstatus" == "STOPPED" ]]; then - while [[ "0" != "1" ]] #using a constant while loop, then breaking out of the loop with break commands below. + while [[ "0" != "1" ]] #using a constant while loop, then breaking out of the loop with break commands below. do (( count++ )) status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "$app_name," | awk -F ',' '{print $2}') From 334a22ea1d902edd958bce4073996e1bdb619bbb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 18 May 2022 03:43:24 +0000 Subject: [PATCH 047/823] Remove redundant lines in -h --- heavy_script.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 66e83dcf..7a8bdbce 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -16,11 +16,9 @@ do echo "-v | verbose output" echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" echo "-s | sync catalog" - echo "-S | Stops App before update with -u or -U and restarts afterwards" echo "-U | Update all applications, ignores versions" echo "-u | Update all applications, does not update Major releases" echo "-p | Prune unused/old docker images" - echo "-S | Stop App before attempting update" echo "EX | bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vRsUp" echo "EX | bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m" exit From b013b09204ef73afccf55453769a8bddac63fc06 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 5 Jun 2022 21:50:10 +0000 Subject: [PATCH 048/823] Update Readme --- README.md | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/README.md b/README.md index 1866db89..f98afd30 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,94 @@ git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_scr

+ +## How to Install + +### Create a Scripts Dataset + +I created a `scripts` dataset on my Truenas SCALE system, this is where all my scripts will remain. + +### Open a Terminal + +**Change Directory to your scripts folder** +``` +cd /mnt/speed/scripts +``` + +**Git Clone Heavy_Script** +``` +git clone https://github.com/Heavybullets8/heavy_script.git +``` + +**Change Directory to Heavy_Script folder** +``` +cd heavy_script +``` + +From here, you can just run Heavy_Script with `bash heavy_script.sh -ARGUMENTS` + +> Note: `chmod +x` is NOT required. Doing this will break the `git pull` function. Just run the script with `bash heavy_script.sh` + +
+ +## How to Update + +### Manually + +#### Open a Terminal + +**Change Directory to your heavy_script folder** +``` +cd /mnt/speed/scripts/heavy_script +``` + +**git pull** +``` +git pull +``` +
+ +### Update with your Cron Job + +Here, we will update the script prior to running it, incase there is a bugfix, or any new additions to the script + +**Cron Job Command** +``` +git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -Rsup +``` +> The important command here is the `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull` + +> This command will allow you to preform a `git pull` on a remote directory, which will ensure your script is udated prior to running it + +> `&&` Is used to run a command AFTER the previous command completed successfully +>> So once the `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull` command completes, THEN it will run the `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh -b 14 -Rsup` command + +
+
+ +## Creating a Cron Job + +1. Truenas SCALE GUI +2. System Settings +3. Advanced +4. Cron Jobs + 1. Click Add + +| Name | Value | Reason | +|------------------------ |------------------------------------------------------------------------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `Description` | HeavyScript git pull and Update apps | This is up to you, put whatever you think is a good description in here | +| `Command` | `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull && bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh -b 14 -Rsup` | This is the command you will be running on your schedule I personally use: `git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -Rsup` | +| `Run As User` | `root` | Running the script as `root` is REQUIRED. You cannot access all of the kubernetes functions without this user. | +| `Schedule` | Up to you, I run mine everyday at `0400` | Again up to you | +| `Hide Standard Output` | `False` or Unticked | I like to receive an email report of how the script ran, what apps updated etc. | +| `Hide Standard Error` | `False` or Unticked | I want to see any errors that occur | +| `Enabled` | `True` or Ticked | This will Enable the script to run on your schedule | + + + +
+
+ ### Additional Informaton #### Verbose vs Non-Verbose From dbfe7f2bb89ec586f96cb4c026125a8b0bcdeab2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 6 Jun 2022 18:10:39 -0600 Subject: [PATCH 049/823] regex improvements --- heavy_script.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 7a8bdbce..c852fa6b 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -126,7 +126,7 @@ if [[ $selection == "1" ]]; then app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script pvc=$(echo -e "$list" | grep ^"$selection ") - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null @@ -135,14 +135,14 @@ if [[ $selection == "1" ]]; then fi while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] do - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "(,|^)$app(,|$)" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 done data_name=$(echo "$pvc" | awk '{print $3}') mount=$(echo "$pvc" | awk '{print $4}') volume_name=$(echo "$pvc" | awk '{print $4}') full_path=$(zfs list | grep "$volume_name" | awk '{print $1}') - echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" && zfs set mountpoint=/heavyscript/"$data_name" "$full_path" && echo -e "Mounted\n\nUnmount with the following command\nzfs set mountpoint=legacy "$full_path" && rmdir /mnt/heavyscript/"$data_name"\nOr use the Unmount All option\n" + echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" && zfs set mountpoint=/heavyscript/"$data_name" "$full_path" && echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy "$full_path" && rmdir /mnt/heavyscript/"$data_name"\n\nOr use the Unmount All option\n" exit elif [[ $selection == "2" ]]; then mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") @@ -152,15 +152,15 @@ elif [[ $selection == "2" ]]; then main=$(k3s kubectl get pvc -A | grep "$i" | awk '{print $1, $2, $4}') app=$(echo "$main" | awk '{print $1}' | cut -c 4-) pvc=$(echo "$main" | awk '{print $3}') - path=$(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - safety_check=$(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6- | wc -l) #if theres more than one new lines, that means theres more than one application with the same name on another pool. - if [[ "$safety_check" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused. + mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused. echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" pool=$(cli -c 'app kubernetes config' | grep dataset | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" && continue || echo "failed to unmount $i" + else + zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" fi - zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" done rmdir /mnt/heavyscript else @@ -212,7 +212,7 @@ update_apps(){ midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" while [[ "$status" != "STOPPED" ]] do - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "$app_name," | awk -F ',' '{print $2}') + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then echo "Stopped" [[ "$verbose" == "true" ]] && echo "Updating.." From addef531db16f10c892471cccd8b88ef20cb78d1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 7 Jun 2022 00:17:58 +0000 Subject: [PATCH 050/823] cleanup remove "continue" in unmount feature. Was no longer needed after previous commit. --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index c852fa6b..86e02e96 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -157,7 +157,7 @@ elif [[ $selection == "2" ]]; then echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" pool=$(cli -c 'app kubernetes config' | grep dataset | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" && continue || echo "failed to unmount $i" + zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" else zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" fi From 3317a1fb332a47f6c863a70ee3a864138371e7da Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 9 Jun 2022 13:56:28 -0600 Subject: [PATCH 051/823] fix mounting regex --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 86e02e96..0ff1f3bf 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -149,7 +149,7 @@ elif [[ $selection == "2" ]]; then [[ -z $unmount_array ]] && echo "Theres nothing to unmount" && exit for i in "${unmount_array[@]}" do - main=$(k3s kubectl get pvc -A | grep "$i" | awk '{print $1, $2, $4}') + main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') app=$(echo "$main" | awk '{print $1}' | cut -c 4-) pvc=$(echo "$main" | awk '{print $3}') mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) From 5d872c952f7945696b2fdd2c1dd9962e0a20c3e7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 10 Jun 2022 13:36:13 -0600 Subject: [PATCH 052/823] commit to beta --- heavy_script.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 0ff1f3bf..70e327cf 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -155,7 +155,7 @@ elif [[ $selection == "2" ]]; then mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused. echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep dataset | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" else @@ -175,12 +175,12 @@ echo -e "\nSyncing all catalogs, please wait.." && cli -c 'app catalog sync_all' export -f sync prune(){ -echo -e "\nPruning Docker Images" && docker image prune -af | grep Total || echo "Failed to Prune Docker Images" +echo -e "\nPruning Docker Images" && docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" } export -f prune update_apps(){ - mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep ",true" | sort) + mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|$)" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" @@ -192,6 +192,7 @@ update_apps(){ old_chart_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version new_chart_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE + startstatus=$status diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From @@ -199,7 +200,6 @@ update_apps(){ rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && continue #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update - startstatus=$status if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo -e "\n$app_name" @@ -248,7 +248,7 @@ if [[ $rollback == "true" ]]; then while [[ "0" != "1" ]] do (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "$app_name," | awk -F ',' '{print $2}') + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" @@ -280,7 +280,7 @@ else while [[ "0" != "1" ]] #using a constant while loop, then breaking out of the loop with break commands below. do (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "$app_name," | awk -F ',' '{print $2}') + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check From 6d1a9fc77bbadbd678fad8f7c2a3282de5ea74a9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 10 Jun 2022 13:40:35 -0600 Subject: [PATCH 053/823] longopts + dns + refactor --- heavy_script.sh | 92 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 68 insertions(+), 24 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 70e327cf..0bed593e 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,30 +1,49 @@ #!/bin/bash + #If no argument is passed, kill the script. +[[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -[[ -z "$*" ]] && echo "This script requires an argument, use -h for help" && exit -while getopts ":hsi:mrb:t:uUpSRv" opt +while getopts ":si:rb:t:uUpSRv-:" opt do case $opt in - h) - echo "-m | Initiates mounting feature, choose between unmounting and mounting PVC data" - echo "-r | Opens a menu to restore a heavy_script backup that was taken on you ix-applications pool" - echo "-b | Back-up your ix-applications dataset, specify a number after -b" - echo "-i | Add application to ignore list, one by one, see example below." - echo "-R | Roll-back applications if they fail to update" - echo "-S | Shutdown applications prior to updating" - echo "-v | verbose output" - echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" - echo "-s | sync catalog" - echo "-U | Update all applications, ignores versions" - echo "-u | Update all applications, does not update Major releases" - echo "-p | Prune unused/old docker images" - echo "EX | bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vRsUp" - echo "EX | bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m" - exit - ;; + -) + case "${OPTARG}" in + dns) + dns="true" + ;; + restore) + restore="true" + ;; + mount) + mount="true" + ;; + help) + echo "-m | Initiates mounting feature, choose between unmounting and mounting PVC data" + echo "-r | Opens a menu to restore a heavy_script backup that was taken on you ix-applications pool" + echo "-b | Back-up your ix-applications dataset, specify a number after -b" + echo "-i | Add application to ignore list, one by one, see example below." + echo "-R | Roll-back applications if they fail to update" + echo "-S | Shutdown applications prior to updating" + echo "-v | verbose output" + echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo "-s | sync catalog" + echo "-U | Update all applications, ignores versions" + echo "-u | Update all applications, does not update Major releases" + echo "-p | Prune unused/old docker images" + echo "EX | bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vRsUp" + echo "EX | bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m" + exit + ;; + + *) + echo "Invalid Option -$OPTARG, type --help for help" + exit + ;; + esac + ;; \?) - echo "Invalid Option -$OPTARG, type -h for help" + echo "Invalid Option -$OPTARG, type --help for help" exit ;; :) @@ -38,7 +57,7 @@ do [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit ;; r) - restore="true" + rollback="true" ;; i) ignore+=("$OPTARG") @@ -48,9 +67,6 @@ do timeout=$OPTARG ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n\"""$timeout""\" is not an interger" >&2 && exit ;; - m) - mount="true" - ;; s) sync="true" ;; @@ -318,10 +334,38 @@ echo ' |___/ |_| ' echo } export -f title + +dns(){ +clear -x +echo "Generating DNS Names.." +#ignored dependency pods, No change required +ignore="cron|kube-system|nvidia|svclb|NAME|memcached" + +# Pulling pod names + +mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$ignore" | sort) + +# Pulling all ports +all_ports=$(k3s kubectl get service -A) + +clear -x +count=0 +for i in "${main[@]}" +do + [[ count -le 0 ]] && echo -e "\n" && ((count++)) + appName=$(echo "$i" | awk '{print $2}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//') + ixName=$(echo "$i" | awk '{print $1}') + port=$(echo "$all_ports" | grep -E "\s$appName\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}") + echo -e "$appName.$ixName.svc.cluster.local $port" +done | uniq | nl -b t | sed 's/\s\s\s$/- -------- ----/' | column -t -R 1 -N "#,DNS_Name,Port" -L +} +export -f dns + #exit if incompatable functions are called [[ "$restore" == "true" && "$mount" == "true" ]] && echo -e "The Restore Function(-r)\nand\nMount Function(-m)\nCannot both be called at the same time." && exit [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit #Continue to call functions in specific order +[[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit [[ "$number_of_backups" -ge 1 ]] && backup From 8a2ec69b75b907c27e6951680d5fac95811520b6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 10 Jun 2022 14:32:39 -0600 Subject: [PATCH 054/823] update readme + script --- README.md | 53 ++++++++++++++++++++++++++----------------------- heavy_script.sh | 46 +++++++++++++++++++++++++----------------- 2 files changed, 56 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index f98afd30..e199193f 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,37 @@ # heavy_script -Update | Backup | Restore | Mount PVC | Rollback Applications | Sync Catalog | Prune Docker Images -| Flag | Example | Parameter | Description | -|------ |------------------------ |----------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| -r | -r | None | Restore HeavyScript specific 'ix-applications dataset' snapshot | -| -m | -m | None | Initiates mounting feature
Choose between unmounting and mounting PVC data | -| -b | -b 14 | int | Backup 'ix-appliactions' dataset
Creates backups up to the number you've chosen | -| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating | -| -R | -R | None | Monitors applications after they update
If the app does not become "ACTIVE" after either:
The custom Timeout, or Default Timeout,
rollback the application. | -| -v | -v | None | Verbose output | -| -S | -S | None | Shutdown applications prior to updating | -| -t | -t 150 | int | Set a custom timeout to be used with either:
-m
- Time the script will wait for application to be "STOPPED"
or
-u/U
- Time the script will wait for application to be either "STOPPED" or "ACTIVE" | -| -s | -s | None | Sync Catalog before updating | -| -U | -U | None | Update applications, ignoring major version changes | -| -u | -u | None | Update applications, do NOT update if there was a major version change | -| -p | -p | None | Prune old/unused docker images | +## Arguments + +| Flag | Example | Parameter | Description | +|----------- |------------------------ |----------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot | +| --mount | --mount | None | Initiates mounting feature Choose between unmounting and mounting PVC data | +| --dns | --dns | None | list all of your applications DNS names and their web ports | +| -U | -U | None | Update applications, ignoring major version changes | +| -u | -u | None | Update applications, do NOT update if there was a major version change | +| -b | -b 14 | Integer | Backup `ix-appliactions` dataset Creates backups up to the number you've chosen | +| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating List one application after another as shown in the example | +| (-R\|-r) | -r | None | Monitors applications after they update If the app does not become "ACTIVE" after either: The custom Timeout, or Default Timeout, rollback the application. Warning: deprecating `-R` please begin using `-r` instead | +| -v | -v | None | Verbose Output Look at the bottom of this page for an example | +| -S | -S | None | Shutdown the application prior to updating it | +| -t | -t 150 | Integer | Set a custom timeout to be used with either: `-m` - Time the script will wait for application to be "STOPPED" or `-(u\|U)` - Time the script will wait for application to be either "STOPPED" or "ACTIVE" | +| -s | -s | None | Sync Catalogs prior to updating | +| -p | -p | None | Prune old/unused docker images | +

### Examples #### Typical Cron Job ``` -bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -Rsup +bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsup ``` - -b is set to 14. Up to 14 snapshots of your ix-applications dataset will be saved - -i is set to ignore portainer, arch, sonarr, and radarr. These applications will be ignored when it comes to updates. - -t I set it to 600 seconds, this means the script will wait 600 seconds for the application to become ACTIVE before timing out and continuing to a different application. -- -R Will rollback applications if they fail to deploy after updating. +- -r Will rollback applications if they fail to deploy after updating. - -s will just sync the repositories, ensuring you are downloading the latest updates. - -u update applications as long as the major version has absolutely no change, if it does have a change it will ask the user to update manually. - -p Prune docker images. @@ -36,18 +39,18 @@ bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -Rsup #### Mounting PVC Data ``` -bash /mnt/tank/scripts/heavy_script.sh -t 300 -m +bash /mnt/tank/scripts/heavy_script.sh -t 300 --mount ``` #### Restoring ix-applications dataset ``` -bash /mnt/tank/scripts/heavy_script/heavy_script.sh -r +bash /mnt/tank/scripts/heavy_script/heavy_script.sh --restore ``` #### My personal Cron Job ``` -git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -Rsup +git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -rsup ```
@@ -106,14 +109,14 @@ Here, we will update the script prior to running it, incase there is a bugfix, o **Cron Job Command** ``` -git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -Rsup +git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -rsup ``` > The important command here is the `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull` > This command will allow you to preform a `git pull` on a remote directory, which will ensure your script is udated prior to running it > `&&` Is used to run a command AFTER the previous command completed successfully ->> So once the `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull` command completes, THEN it will run the `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh -b 14 -Rsup` command +>> So once the `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull` command completes, THEN it will run the `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh -b 14 -rsup` command

@@ -129,7 +132,7 @@ git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_scr | Name | Value | Reason | |------------------------ |------------------------------------------------------------------------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `Description` | HeavyScript git pull and Update apps | This is up to you, put whatever you think is a good description in here | -| `Command` | `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull && bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh -b 14 -Rsup` | This is the command you will be running on your schedule I personally use: `git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -Rsup` | +| `Command` | `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull && bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh -b 14 -rsup` | This is the command you will be running on your schedule I personally use: `git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -rsup` | | `Run As User` | `root` | Running the script as `root` is REQUIRED. You cannot access all of the kubernetes functions without this user. | | `Schedule` | Up to you, I run mine everyday at `0400` | Again up to you | | `Hide Standard Output` | `False` or Unticked | I like to receive an email report of how the script ran, what apps updated etc. | @@ -144,8 +147,8 @@ git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_scr ### Additional Informaton #### Verbose vs Non-Verbose -- Verbose used `bash heavy_test.sh -b 5 -SRupv` -- Non-Verbose used `bash heavy_test.sh -b 5 -SRup` +- Verbose used `bash heavy_script.sh -b 5 -Srupv` +- Non-Verbose used `bash heavy_script.sh -b 5 -Srup` | Verbose | Non-Verbose | |--------- |------------- | diff --git a/heavy_script.sh b/heavy_script.sh index 0bed593e..899130d4 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -9,6 +9,32 @@ do case $opt in -) case "${OPTARG}" in + help) + clear -x + echo "Basic Utilities" + echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" + echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset" + echo "--dns | list all of your applications DNS names and their web ports" + echo + echo "Update Options" + echo "-U | Update all applications, ignores versions" + echo "-u | Update all applications, does not update Major releases" + echo "-b | Back-up your ix-applications dataset, specify a number after -b" + echo "-i | Add application to ignore list, one by one, see example below." + echo "-R | THIS OPTION WILL DEPRICATE SOON, USE \"-r\" instead. Roll-back applications if they fail to update" + echo "-r | Roll-back applications if they fail to update" + echo "-S | Shutdown applications prior to updating" + echo "-v | verbose output" + echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo "-s | sync catalog" + echo "-p | Prune unused/old docker images" + echo + echo "Examples" + echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" + echo "bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m" + echo "bash /mnt/tank/scripts/heavy_script.sh --mount" + exit + ;; dns) dns="true" ;; @@ -18,23 +44,6 @@ do mount) mount="true" ;; - help) - echo "-m | Initiates mounting feature, choose between unmounting and mounting PVC data" - echo "-r | Opens a menu to restore a heavy_script backup that was taken on you ix-applications pool" - echo "-b | Back-up your ix-applications dataset, specify a number after -b" - echo "-i | Add application to ignore list, one by one, see example below." - echo "-R | Roll-back applications if they fail to update" - echo "-S | Shutdown applications prior to updating" - echo "-v | verbose output" - echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" - echo "-s | sync catalog" - echo "-U | Update all applications, ignores versions" - echo "-u | Update all applications, does not update Major releases" - echo "-p | Prune unused/old docker images" - echo "EX | bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vRsUp" - echo "EX | bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m" - exit - ;; *) echo "Invalid Option -$OPTARG, type --help for help" @@ -84,6 +93,7 @@ do ;; R) rollback="true" + echo "WARNING: -R is being transisitioned to -r, this is due to a refactor in the script. Please Make the change ASAP!" ;; v) verbose="true" @@ -342,7 +352,6 @@ echo "Generating DNS Names.." ignore="cron|kube-system|nvidia|svclb|NAME|memcached" # Pulling pod names - mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$ignore" | sort) # Pulling all ports @@ -364,6 +373,7 @@ export -f dns #exit if incompatable functions are called [[ "$restore" == "true" && "$mount" == "true" ]] && echo -e "The Restore Function(-r)\nand\nMount Function(-m)\nCannot both be called at the same time." && exit [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit + #Continue to call functions in specific order [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit From 37be0a61c1aef9e0d573bb2706c2a02ce9abb567 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 10 Jun 2022 15:25:16 -0600 Subject: [PATCH 055/823] table of contents --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e199193f..ebe23d1a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,14 @@ # heavy_script +## Table of contents: +* [Arguments](#arguments) +* [Examples](#examples) +* [How to Install](#how-to-install) +* [How to Update](#how-to-update) +* [Creating a Cron Job](#creating-a-cron-job) +* [Additional Information](#additional-information) + +
## Arguments @@ -7,7 +16,7 @@ |----------- |------------------------ |----------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot | | --mount | --mount | None | Initiates mounting feature Choose between unmounting and mounting PVC data | -| --dns | --dns | None | list all of your applications DNS names and their web ports | +| --dns | --dns | None | list all of your applications DNS names and their web port | | -U | -U | None | Update applications, ignoring major version changes | | -u | -u | None | Update applications, do NOT update if there was a major version change | | -b | -b 14 | Integer | Backup `ix-appliactions` dataset Creates backups up to the number you've chosen | @@ -123,7 +132,7 @@ git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_scr ## Creating a Cron Job -1. Truenas SCALE GUI +1. TrueNAS SCALE GUI 2. System Settings 3. Advanced 4. Cron Jobs @@ -144,7 +153,7 @@ git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_scr

-### Additional Informaton +### Additional Information #### Verbose vs Non-Verbose - Verbose used `bash heavy_script.sh -b 5 -Srupv` From ab0fdc24acb0c3fd88e513a4df47da2e695a236e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 10 Jun 2022 15:37:20 -0600 Subject: [PATCH 056/823] readme + help cleanup --- README.md | 20 +++++++++++++------- heavy_script.sh | 5 +++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ebe23d1a..09454c44 100644 --- a/README.md +++ b/README.md @@ -37,13 +37,13 @@ bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsup ``` -- -b is set to 14. Up to 14 snapshots of your ix-applications dataset will be saved -- -i is set to ignore portainer, arch, sonarr, and radarr. These applications will be ignored when it comes to updates. -- -t I set it to 600 seconds, this means the script will wait 600 seconds for the application to become ACTIVE before timing out and continuing to a different application. -- -r Will rollback applications if they fail to deploy after updating. -- -s will just sync the repositories, ensuring you are downloading the latest updates. -- -u update applications as long as the major version has absolutely no change, if it does have a change it will ask the user to update manually. -- -p Prune docker images. +> `-b` is set to 14. Up to 14 snapshots of your ix-applications dataset will be saved +> `-i` is set to ignore portainer, arch, sonarr, and radarr. These applications will be ignored when it comes to updates. +> `-t` I set it to 600 seconds, this means the script will wait 600 seconds for the application to become ACTIVE before timing out and continuing to a different application. +> `-r` Will rollback applications if they fail to deploy after updating. +> `-s` will just sync the repositories, ensuring you are downloading the latest updates. +> `-u` update applications as long as the major version has absolutely no change, if it does have a change it will ask the user to update manually. +> `-p` Prune docker images. #### Mounting PVC Data @@ -57,6 +57,12 @@ bash /mnt/tank/scripts/heavy_script.sh -t 300 --mount bash /mnt/tank/scripts/heavy_script/heavy_script.sh --restore ``` +#### List All DNS Names + +``` +bash /mnt/tank/scripts/heavy_script/heavy_script.sh --dns +``` + #### My personal Cron Job ``` git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -rsup diff --git a/heavy_script.sh b/heavy_script.sh index 899130d4..2a770c8c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -31,8 +31,9 @@ do echo echo "Examples" echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" - echo "bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m" - echo "bash /mnt/tank/scripts/heavy_script.sh --mount" + echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" + echo "bash /mnt/tank/scripts/heavy_script.sh --dns" + echo "bash /mnt/tank/scripts/heavy_script.sh --restore" exit ;; dns) From d2beb15cfefa9cd4a8df0692ddc651efee17504d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 10 Jun 2022 15:37:59 -0600 Subject: [PATCH 057/823] spacing? --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 09454c44..6a043d2c 100644 --- a/README.md +++ b/README.md @@ -38,11 +38,17 @@ bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsup ``` > `-b` is set to 14. Up to 14 snapshots of your ix-applications dataset will be saved + > `-i` is set to ignore portainer, arch, sonarr, and radarr. These applications will be ignored when it comes to updates. + > `-t` I set it to 600 seconds, this means the script will wait 600 seconds for the application to become ACTIVE before timing out and continuing to a different application. + > `-r` Will rollback applications if they fail to deploy after updating. + > `-s` will just sync the repositories, ensuring you are downloading the latest updates. + > `-u` update applications as long as the major version has absolutely no change, if it does have a change it will ask the user to update manually. + > `-p` Prune docker images. #### Mounting PVC Data From 23858a2a8130ab2ad1c9ea4d9e2e695c907f1d19 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 10 Jun 2022 19:48:34 -0600 Subject: [PATCH 058/823] delete restore point option --- heavy_script.sh | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 2a770c8c..e5085a50 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -33,7 +33,8 @@ do echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" - echo "bash /mnt/tank/scripts/heavy_script.sh --restore" + echo "bash /mnt/tank/scripts/heavy_script.sh --restore" + echo exit ;; dns) @@ -45,9 +46,11 @@ do mount) mount="true" ;; - + delete-backup) + deleteBackup="true" + ;; *) - echo "Invalid Option -$OPTARG, type --help for help" + echo "Invalid Option --$OPTARG, type --help for help" exit ;; esac @@ -148,7 +151,7 @@ echo -e "1 Mount\n2 Unmount All" && read -p "Please type a number: " selection [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script if [[ $selection == "1" ]]; then list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") - echo "$list" && read -p "Please type a number : " selection + echo "$list" && read -p "Please type a number: " selection [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script @@ -333,6 +336,28 @@ fi } export -f prune + +deleteBackup(){ +clear -x && echo "pulling restore points.." +list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) +clear -x +[[ -z "$list_backups" ]] && echo "No HeavyScript restore points available" && exit || { title; echo "Choose a restore point" ; } +echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') +[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script +[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script +echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" || { echo "FAILED"; exit; } +echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } +if [[ $yesno == "1" ]]; then + echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo "Sucessfully deleted $restore_point" || echo "Deletion Failed" +elif [[ $yesno == "2" ]]; then + echo "You've chosen NO, killing script." +else + echo "Invalid Selection" +fi +} + + + title(){ echo ' _ _ _____ _ _ ' echo '| | | | / ___| (_) | | ' @@ -350,10 +375,10 @@ dns(){ clear -x echo "Generating DNS Names.." #ignored dependency pods, No change required -ignore="cron|kube-system|nvidia|svclb|NAME|memcached" +dep_ignore="cron|kube-system|nvidia|svclb|NAME|memcached" # Pulling pod names -mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$ignore" | sort) +mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$dep_ignore" | sort) # Pulling all ports all_ports=$(k3s kubectl get service -A) @@ -376,6 +401,7 @@ export -f dns [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit #Continue to call functions in specific order +[[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit From 3c42621a955bb00db6f2192f78c9580feeaef208 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 10 Jun 2022 20:04:52 -0600 Subject: [PATCH 059/823] delete backup readme --- README.md | 37 ++++++++++------- heavy_script.sh | 104 +++++++++++++++++++++++++----------------------- 2 files changed, 76 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index 6a043d2c..8a8cd395 100644 --- a/README.md +++ b/README.md @@ -12,21 +12,22 @@ ## Arguments -| Flag | Example | Parameter | Description | -|----------- |------------------------ |----------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot | -| --mount | --mount | None | Initiates mounting feature Choose between unmounting and mounting PVC data | -| --dns | --dns | None | list all of your applications DNS names and their web port | -| -U | -U | None | Update applications, ignoring major version changes | -| -u | -u | None | Update applications, do NOT update if there was a major version change | -| -b | -b 14 | Integer | Backup `ix-appliactions` dataset Creates backups up to the number you've chosen | -| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating List one application after another as shown in the example | -| (-R\|-r) | -r | None | Monitors applications after they update If the app does not become "ACTIVE" after either: The custom Timeout, or Default Timeout, rollback the application. Warning: deprecating `-R` please begin using `-r` instead | -| -v | -v | None | Verbose Output Look at the bottom of this page for an example | -| -S | -S | None | Shutdown the application prior to updating it | -| -t | -t 150 | Integer | Set a custom timeout to be used with either: `-m` - Time the script will wait for application to be "STOPPED" or `-(u\|U)` - Time the script will wait for application to be either "STOPPED" or "ACTIVE" | -| -s | -s | None | Sync Catalogs prior to updating | -| -p | -p | None | Prune old/unused docker images | +| Flag | Example | Parameter | Description | +|----------------- |------------------------ |----------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| --delete-backup | --delete-backup | None | Opens a menu to delete backups >Useful if you need to delete old system backups or backups from other scripts | +| --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot | +| --mount | --mount | None | Initiates mounting feature Choose between unmounting and mounting PVC data | +| --dns | --dns | None | list all of your applications DNS names and their web ports | +| -U | -U | None | Update applications, ignoring major version changes | +| -u | -u | None | Update applications, do NOT update if there was a major version change | +| -b | -b 14 | Integer | Backup `ix-appliactions` dataset Creates backups up to the number you've chosen | +| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating List one application after another as shown in the example | +| (-R\|-r) | -r | None | Monitors applications after they update If the app does not become "ACTIVE" after either: The custom Timeout, or Default Timeout, rollback the application. >Warning: deprecating `-R` please begin using `-r` instead | +| -v | -v | None | Verbose Output Look at the bottom of this page for an example | +| -S | -S | None | Shutdown the application prior to updating it | +| -t | -t 150 | Integer | Set a custom timeout to be used with either: `-m` - Time the script will wait for application to be "STOPPED" or `-(u\|U)` - Time the script will wait for application to be either "STOPPED" or "ACTIVE" | +| -s | -s | None | Sync Catalogs prior to updating | +| -p | -p | None | Prune old/unused docker images |

@@ -63,6 +64,12 @@ bash /mnt/tank/scripts/heavy_script.sh -t 300 --mount bash /mnt/tank/scripts/heavy_script/heavy_script.sh --restore ``` +#### Deleting Backups + +``` +bash /mnt/tank/scripts/heavy_script/heavy_script.sh --backup-delete +``` + #### List All DNS Names ``` diff --git a/heavy_script.sh b/heavy_script.sh index e5085a50..54af2d26 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -105,6 +105,27 @@ do esac done + +deleteBackup(){ +clear -x && echo "pulling all restore points.." +list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) +clear -x +[[ -z "$list_backups" ]] && echo "No restore points available" && exit || { title; echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" ; } +echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') +[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script +[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script +echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" || { echo "FAILED"; exit; } +echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } +if [[ $yesno == "1" ]]; then + echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo "Sucessfully deleted" || echo "Deletion Failed" +elif [[ $yesno == "2" ]]; then + echo "You've chosen NO, killing script." +else + echo "Invalid Selection" +fi +} + + backup(){ echo -e "\nNumber of backups was set to $number_of_backups" date=$(date '+%Y_%m_%d_%H_%M_%S') @@ -124,6 +145,7 @@ fi } export -f backup + restore(){ clear -x && echo "pulling restore points.." list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) @@ -144,6 +166,33 @@ fi } export -f restore + +dns(){ +clear -x +echo "Generating DNS Names.." +#ignored dependency pods, No change required +dep_ignore="cron|kube-system|nvidia|svclb|NAME|memcached" + +# Pulling pod names +mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$dep_ignore" | sort) + +# Pulling all ports +all_ports=$(k3s kubectl get service -A) + +clear -x +count=0 +for i in "${main[@]}" +do + [[ count -le 0 ]] && echo -e "\n" && ((count++)) + appName=$(echo "$i" | awk '{print $2}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//') + ixName=$(echo "$i" | awk '{print $1}') + port=$(echo "$all_ports" | grep -E "\s$appName\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}") + echo -e "$appName.$ixName.svc.cluster.local $port" +done | uniq | nl -b t | sed 's/\s\s\s$/- -------- ----/' | column -t -R 1 -N "#,DNS_Name,Port" -L +} +export -f dns + + mount(){ clear -x title @@ -199,15 +248,12 @@ fi } export -f mount + sync(){ echo -e "\nSyncing all catalogs, please wait.." && cli -c 'app catalog sync_all' &> /dev/null && echo -e "Catalog sync complete" } export -f sync -prune(){ -echo -e "\nPruning Docker Images" && docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" -} -export -f prune update_apps(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|$)" | sort) @@ -334,29 +380,12 @@ else fi fi } -export -f prune +export -f after_update_actions - -deleteBackup(){ -clear -x && echo "pulling restore points.." -list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) -clear -x -[[ -z "$list_backups" ]] && echo "No HeavyScript restore points available" && exit || { title; echo "Choose a restore point" ; } -echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') -[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script -echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" || { echo "FAILED"; exit; } -echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } -if [[ $yesno == "1" ]]; then - echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo "Sucessfully deleted $restore_point" || echo "Deletion Failed" -elif [[ $yesno == "2" ]]; then - echo "You've chosen NO, killing script." -else - echo "Invalid Selection" -fi +prune(){ +echo -e "\nPruning Docker Images" && docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" } - - +export -f prune title(){ echo ' _ _ _____ _ _ ' @@ -371,31 +400,6 @@ echo } export -f title -dns(){ -clear -x -echo "Generating DNS Names.." -#ignored dependency pods, No change required -dep_ignore="cron|kube-system|nvidia|svclb|NAME|memcached" - -# Pulling pod names -mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$dep_ignore" | sort) - -# Pulling all ports -all_ports=$(k3s kubectl get service -A) - -clear -x -count=0 -for i in "${main[@]}" -do - [[ count -le 0 ]] && echo -e "\n" && ((count++)) - appName=$(echo "$i" | awk '{print $2}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//') - ixName=$(echo "$i" | awk '{print $1}') - port=$(echo "$all_ports" | grep -E "\s$appName\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}") - echo -e "$appName.$ixName.svc.cluster.local $port" -done | uniq | nl -b t | sed 's/\s\s\s$/- -------- ----/' | column -t -R 1 -N "#,DNS_Name,Port" -L -} -export -f dns - #exit if incompatable functions are called [[ "$restore" == "true" && "$mount" == "true" ]] && echo -e "The Restore Function(-r)\nand\nMount Function(-m)\nCannot both be called at the same time." && exit [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit From b21c2703f329b882cd770b6d071687fbadce0851 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 10 Jun 2022 20:10:27 -0600 Subject: [PATCH 060/823] fix readme again --- README.md | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 8a8cd395..d72edfa2 100644 --- a/README.md +++ b/README.md @@ -12,22 +12,23 @@ ## Arguments -| Flag | Example | Parameter | Description | -|----------------- |------------------------ |----------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| --delete-backup | --delete-backup | None | Opens a menu to delete backups >Useful if you need to delete old system backups or backups from other scripts | -| --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot | -| --mount | --mount | None | Initiates mounting feature Choose between unmounting and mounting PVC data | -| --dns | --dns | None | list all of your applications DNS names and their web ports | -| -U | -U | None | Update applications, ignoring major version changes | -| -u | -u | None | Update applications, do NOT update if there was a major version change | -| -b | -b 14 | Integer | Backup `ix-appliactions` dataset Creates backups up to the number you've chosen | -| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating List one application after another as shown in the example | -| (-R\|-r) | -r | None | Monitors applications after they update If the app does not become "ACTIVE" after either: The custom Timeout, or Default Timeout, rollback the application. >Warning: deprecating `-R` please begin using `-r` instead | -| -v | -v | None | Verbose Output Look at the bottom of this page for an example | -| -S | -S | None | Shutdown the application prior to updating it | -| -t | -t 150 | Integer | Set a custom timeout to be used with either: `-m` - Time the script will wait for application to be "STOPPED" or `-(u\|U)` - Time the script will wait for application to be either "STOPPED" or "ACTIVE" | -| -s | -s | None | Sync Catalogs prior to updating | -| -p | -p | None | Prune old/unused docker images | +| Flag | Example | Parameter | Description | +|----------------- |------------------------ |----------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| --delete-backup | --delete-backup | None | Opens a menu to delete backups
_Useful if you need to delete old system backups or backups from other scripts_ | +| --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot | +| --mount | --mount | None | Initiates mounting feature
Choose between unmounting and mounting PVC data | +| --dns | --dns | None | list all of your applications DNS names and their web ports | +| -U | -U | None | Update applications, ignoring major version changes | +| -u | -u | None | Update applications, do NOT update if there was a major version change | +| -b | -b 14 | Integer | Backup `ix-appliactions` dataset
_Creates backups up to the number you've chosen_ | +| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating
_List one application after another as shown in the example_ | +| (-R\|-r) | -r | None | Monitors applications after they update
If the app does not become "ACTIVE" after either:
The custom Timeout, or Default Timeout,
rollback the application.
__Warning: deprecating `-R` please begin using `-r` instead__ | +| -v | -v | None | Verbose Output
_Look at the bottom of this page for an example_ | +| -S | -S | None | Shutdown the application prior to updating it | +| -t | -t 150 | Integer | Set a custom timeout to be used with either:
`-m`
_Time the script will wait for application to be "STOPPED"_
or
`-(u\|U)`
_Time the script will wait for application to be either "STOPPED" or "ACTIVE"_ | +| -s | -s | None | Sync Catalogs prior to updating | +| -p | -p | None | Prune old/unused docker images | +

From 6469dab7c460e8a43d1de24ddc8b626ec475e516 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 10 Jun 2022 22:38:50 -0600 Subject: [PATCH 061/823] fix help & add read prompt timer --- heavy_script.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 54af2d26..9e635e55 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -12,9 +12,10 @@ do help) clear -x echo "Basic Utilities" - echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" - echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset" - echo "--dns | list all of your applications DNS names and their web ports" + echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" + echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset" + echo "--delete backup | Opens a menu to delete backups on your system" + echo "--dns | list all of your applications DNS names and their web ports" echo echo "Update Options" echo "-U | Update all applications, ignores versions" @@ -34,7 +35,8 @@ do echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" echo "bash /mnt/tank/scripts/heavy_script.sh --restore" - echo + echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" + echo exit ;; dns) @@ -111,11 +113,11 @@ clear -x && echo "pulling all restore points.." list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) clear -x [[ -z "$list_backups" ]] && echo "No restore points available" && exit || { title; echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" ; } -echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') +echo "$list_backups" && read -t 600 -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script [[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" || { echo "FAILED"; exit; } -echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } +echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -t 120 -p "Please type a number: " yesno || { echo "FAILED"; exit; } if [[ $yesno == "1" ]]; then echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo "Sucessfully deleted" || echo "Deletion Failed" elif [[ $yesno == "2" ]]; then @@ -151,11 +153,11 @@ clear -x && echo "pulling restore points.." list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) clear -x [[ -z "$list_backups" ]] && echo "No HeavyScript restore points available" && exit || { title; echo "Choose a restore point" ; } -echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') +echo "$list_backups" && read -t 600 -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script [[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" || { echo "FAILED"; exit; } -echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; } +echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -t 120 -p "Please type a number: " yesno || { echo "FAILED"; exit; } if [[ $yesno == "1" ]]; then echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" elif [[ $yesno == "2" ]]; then @@ -196,11 +198,11 @@ export -f dns mount(){ clear -x title -echo -e "1 Mount\n2 Unmount All" && read -p "Please type a number: " selection +echo -e "1 Mount\n2 Unmount All" && read -t 600 -p "Please type a number: " selection [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script if [[ $selection == "1" ]]; then list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") - echo "$list" && read -p "Please type a number: " selection + echo "$list" && read -t 120 -p "Please type a number: " selection [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script From 9e429e2a5be2fe70fed33c2048961139178d58b1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 10 Jun 2022 22:41:55 -0600 Subject: [PATCH 062/823] remove arg check & readme --- README.md | 2 +- heavy_script.sh | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index d72edfa2..f7717f6e 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ bash /mnt/tank/scripts/heavy_script/heavy_script.sh --restore #### Deleting Backups ``` -bash /mnt/tank/scripts/heavy_script/heavy_script.sh --backup-delete +bash /mnt/tank/scripts/heavy_script/heavy_script.sh --delete-backup ``` #### List All DNS Names diff --git a/heavy_script.sh b/heavy_script.sh index 9e635e55..9033eef2 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -403,7 +403,6 @@ echo export -f title #exit if incompatable functions are called -[[ "$restore" == "true" && "$mount" == "true" ]] && echo -e "The Restore Function(-r)\nand\nMount Function(-m)\nCannot both be called at the same time." && exit [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit #Continue to call functions in specific order From 45127be73ad6c4b9a1bce9cf66166a7c818a7669 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 11 Jun 2022 00:13:09 -0600 Subject: [PATCH 063/823] code cleanup --- heavy_script.sh | 395 +++++++++++++++++++++++++----------------------- 1 file changed, 206 insertions(+), 189 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 9033eef2..a26ab23f 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,108 +4,37 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -while getopts ":si:rb:t:uUpSRv-:" opt -do - case $opt in - -) - case "${OPTARG}" in - help) - clear -x - echo "Basic Utilities" - echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" - echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset" - echo "--delete backup | Opens a menu to delete backups on your system" - echo "--dns | list all of your applications DNS names and their web ports" - echo - echo "Update Options" - echo "-U | Update all applications, ignores versions" - echo "-u | Update all applications, does not update Major releases" - echo "-b | Back-up your ix-applications dataset, specify a number after -b" - echo "-i | Add application to ignore list, one by one, see example below." - echo "-R | THIS OPTION WILL DEPRICATE SOON, USE \"-r\" instead. Roll-back applications if they fail to update" - echo "-r | Roll-back applications if they fail to update" - echo "-S | Shutdown applications prior to updating" - echo "-v | verbose output" - echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" - echo "-s | sync catalog" - echo "-p | Prune unused/old docker images" - echo - echo "Examples" - echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" - echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" - echo "bash /mnt/tank/scripts/heavy_script.sh --dns" - echo "bash /mnt/tank/scripts/heavy_script.sh --restore" - echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" - echo - exit - ;; - dns) - dns="true" - ;; - restore) - restore="true" - ;; - mount) - mount="true" - ;; - delete-backup) - deleteBackup="true" - ;; - *) - echo "Invalid Option --$OPTARG, type --help for help" - exit - ;; - esac - ;; - \?) - echo "Invalid Option -$OPTARG, type --help for help" - exit - ;; - :) - echo "Option: -$OPTARG requires an argument" >&2 - exit - ;; - b) - re='^[0-9]+$' - number_of_backups=$OPTARG - ! [[ $OPTARG =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit - [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit - ;; - r) - rollback="true" - ;; - i) - ignore+=("$OPTARG") - ;; - t) - re='^[0-9]+$' - timeout=$OPTARG - ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n\"""$timeout""\" is not an interger" >&2 && exit - ;; - s) - sync="true" - ;; - U) - update_all_apps="true" - ;; - u) - update_apps="true" - ;; - S) - stop_before_update="true" - ;; - p) - prune="true" - ;; - R) - rollback="true" - echo "WARNING: -R is being transisitioned to -r, this is due to a refactor in the script. Please Make the change ASAP!" - ;; - v) - verbose="true" - ;; - esac -done +help(){ +[[ $help == "true" ]] && clear -x +echo "Basic Utilities" +echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" +echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset" +echo "--delete backup | Opens a menu to delete backups on your system" +echo "--dns | list all of your applications DNS names and their web ports" +echo +echo "Update Options" +echo "-U | Update all applications, ignores versions" +echo "-u | Update all applications, does not update Major releases" +echo "-b | Back-up your ix-applications dataset, specify a number after -b" +echo "-i | Add application to ignore list, one by one, see example below." +echo "-R | THIS OPTION WILL DEPRICATE SOON, USE \"-r\" instead. Roll-back applications if they fail to update" +echo "-r | Roll-back applications if they fail to update" +echo "-S | Shutdown applications prior to updating" +echo "-v | verbose output" +echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" +echo "-s | sync catalog" +echo "-p | Prune unused/old docker images" +echo +echo "Examples" +echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" +echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" +echo "bash /mnt/tank/scripts/heavy_script.sh --dns" +echo "bash /mnt/tank/scripts/heavy_script.sh --restore" +echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" +echo +exit +} +export -f help deleteBackup(){ @@ -119,13 +48,14 @@ echo "$list_backups" && read -t 600 -p "Please type a number: " selection && res echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" || { echo "FAILED"; exit; } echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -t 120 -p "Please type a number: " yesno || { echo "FAILED"; exit; } if [[ $yesno == "1" ]]; then - echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo "Sucessfully deleted" || echo "Deletion Failed" + echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo "Sucessfully deleted" || echo "Deletion Failed" elif [[ $yesno == "2" ]]; then - echo "You've chosen NO, killing script." + echo "You've chosen NO, killing script." else - echo "Invalid Selection" + echo "Invalid Selection" fi } +export -f deleteBackup backup(){ @@ -135,14 +65,14 @@ date=$(date '+%Y_%m_%d_%H_%M_%S') [[ -z "$verbose" ]] && echo -e "\nNew Backup Name:" && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then - echo -e "\nDeleting the oldest backup(s) for exceeding limit:" - overflow=$(( ${#list_backups[@]} - "$number_of_backups" )) - mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") - for i in "${list_overflow[@]}" - do - cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo "Failed to delete $i" - echo "$i" - done + echo -e "\nDeleting the oldest backup(s) for exceeding limit:" + overflow=$(( ${#list_backups[@]} - "$number_of_backups" )) + mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") + for i in "${list_overflow[@]}" + do + cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo "Failed to delete $i" + echo "$i" + done fi } export -f backup @@ -159,11 +89,11 @@ echo "$list_backups" && read -t 600 -p "Please type a number: " selection && res echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" || { echo "FAILED"; exit; } echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -t 120 -p "Please type a number: " yesno || { echo "FAILED"; exit; } if [[ $yesno == "1" ]]; then - echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" + echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" elif [[ $yesno == "2" ]]; then - echo "You've chosen NO, killing script. Good luck." + echo "You've chosen NO, killing script. Good luck." else - echo "Invalid Selection" + echo "Invalid Selection" fi } export -f restore @@ -201,51 +131,51 @@ title echo -e "1 Mount\n2 Unmount All" && read -t 600 -p "Please type a number: " selection [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script if [[ $selection == "1" ]]; then - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") - echo "$list" && read -t 120 -p "Please type a number: " selection - [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script - app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script - pvc=$(echo -e "$list" | grep ^"$selection ") - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - if [[ "$status" != "STOPPED" ]]; then - [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" - SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null - else - echo -e "\n$app is already stopped" - fi - while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] + list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + echo "$list" && read -t 120 -p "Please type a number: " selection + [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script + app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script + pvc=$(echo -e "$list" | grep ^"$selection ") + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + if [[ "$status" != "STOPPED" ]]; then + [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" + SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null + else + echo -e "\n$app is already stopped" + fi + while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] do - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 done - data_name=$(echo "$pvc" | awk '{print $3}') - mount=$(echo "$pvc" | awk '{print $4}') - volume_name=$(echo "$pvc" | awk '{print $4}') - full_path=$(zfs list | grep "$volume_name" | awk '{print $1}') - echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" && zfs set mountpoint=/heavyscript/"$data_name" "$full_path" && echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy "$full_path" && rmdir /mnt/heavyscript/"$data_name"\n\nOr use the Unmount All option\n" - exit + data_name=$(echo "$pvc" | awk '{print $3}') + mount=$(echo "$pvc" | awk '{print $4}') + volume_name=$(echo "$pvc" | awk '{print $4}') + full_path=$(zfs list | grep "$volume_name" | awk '{print $1}') + echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" && zfs set mountpoint=/heavyscript/"$data_name" "$full_path" && echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy "$full_path" && rmdir /mnt/heavyscript/"$data_name"\n\nOr use the Unmount All option\n" + exit elif [[ $selection == "2" ]]; then - mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") - [[ -z $unmount_array ]] && echo "Theres nothing to unmount" && exit - for i in "${unmount_array[@]}" + mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") + [[ -z $unmount_array ]] && echo "Theres nothing to unmount" && exit + for i in "${unmount_array[@]}" do - main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') - app=$(echo "$main" | awk '{print $1}' | cut -c 4-) - pvc=$(echo "$main" | awk '{print $3}') - mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused. - echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" - else - zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" - fi + main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') + app=$(echo "$main" | awk '{print $1}' | cut -c 4-) + pvc=$(echo "$main" | awk '{print $3}') + mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused. + echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + else + zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + fi done - rmdir /mnt/heavyscript + rmdir /mnt/heavyscript else - echo "Invalid selection, type -h for help" + echo "Invalid selection, \"$selection\" was not an option" fi } export -f mount @@ -258,33 +188,33 @@ export -f sync update_apps(){ - mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|$)" | sort) - [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" - [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" - [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" - for i in "${array[@]}" - do - app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. - old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version - new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version - old_chart_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version - new_chart_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version - status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE - startstatus=$status - diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions - diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions - old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From - new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To - rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') - printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && continue #If application is on ignore list, skip - if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update - if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not - if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop +mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|$)" | sort) +[[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" +[[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" +[[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" + for i in "${array[@]}" + do + app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. + old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version + new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version + old_chart_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version + new_chart_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version + status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE + startstatus=$status + diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions + diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions + old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From + new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To + rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') + printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && continue #If application is on ignore list, skip + if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update + if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not + if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Updating.." cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" continue - else # if status was not STOPPED, stop the app prior to updating + else # if status was not STOPPED, stop the app prior to updating echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Stopping prior to update.." midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" @@ -305,20 +235,21 @@ update_apps(){ continue fi done - fi - else #user must not be using -S, just update - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || { echo "FAILED"; continue; } - fi - else - echo -e "\n$app_name\nMajor Release, update manually" - continue - fi - done + fi + else #user must not be using -S, just update + echo -e "\n$app_name" + [[ "$verbose" == "true" ]] && echo "Updating.." + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || { echo "FAILED"; continue; } + fi + else + echo -e "\n$app_name\nMajor Release, update manually" + continue + fi + done } export -f update_apps + after_update_actions(){ SECONDS=0 count=0 @@ -384,11 +315,13 @@ fi } export -f after_update_actions + prune(){ echo -e "\nPruning Docker Images" && docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" } export -f prune + title(){ echo ' _ _ _____ _ _ ' echo '| | | | / ___| (_) | | ' @@ -402,10 +335,94 @@ echo } export -f title + +# Parse script options +while getopts ":si:rb:t:uUpSRv-:" opt +do + case $opt in + -) + case "${OPTARG}" in + help) + help="true" + ;; + dns) + dns="true" + ;; + restore) + restore="true" + ;; + mount) + mount="true" + ;; + delete-backup) + deleteBackup="true" + ;; + *) + echo -e "Invalid Option \"--$OPTARG\"\n" && help + exit + ;; + esac + ;; + \?) + echo -e "Invalid Option \"-$OPTARG\"\n" && help + exit + ;; + :) + echo -e "Option: \"-$OPTARG\" requires an argument\n" && help + exit + ;; + b) + re='^[0-9]+$' + number_of_backups=$OPTARG + ! [[ $OPTARG =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit + [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit + ;; + r) + rollback="true" + ;; + i) + ignore+=("$OPTARG") + ;; + t) + re='^[0-9]+$' + timeout=$OPTARG + ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n\"""$timeout""\" is not an interger" >&2 && exit + ;; + s) + sync="true" + ;; + U) + update_all_apps="true" + ;; + u) + update_apps="true" + ;; + S) + stop_before_update="true" + ;; + p) + prune="true" + ;; + R) + rollback="true" + echo "WARNING: -R is being transisitioned to -r, this is due to a refactor in the script. Please Make the change ASAP!" + ;; + v) + verbose="true" + ;; + *) + echo -e "Invalid Option \"--$OPTARG\"\n" && help + exit + ;; + esac +done + + #exit if incompatable functions are called [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit #Continue to call functions in specific order +[[ "$help" == "true" ]] && help [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit From c89b217943016027d1b12c03a4e68aa560343356 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 11 Jun 2022 01:39:44 -0600 Subject: [PATCH 064/823] remove un-needed indentation --- heavy_script.sh | 100 ++++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index a26ab23f..0f08a004 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -192,60 +192,60 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" - for i in "${array[@]}" - do - app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. - old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version - new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version - old_chart_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version - new_chart_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version - status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE - startstatus=$status - diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions - diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions - old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From - new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To - rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') - printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && continue #If application is on ignore list, skip - if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update - if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not - if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" - continue - else # if status was not STOPPED, stop the app prior to updating - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Stopping prior to update.." - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" - while [[ "$status" != "STOPPED" ]] - do - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') - if [[ "$status" == "STOPPED" ]]; then - echo "Stopped" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "Failed to update" - break - elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" - break - elif [[ "$status" != "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED" - sleep 10 - continue - fi - done - fi - else #user must not be using -S, just update +for i in "${array[@]}" +do + app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. + old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version + new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version + old_chart_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version + new_chart_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version + status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE + startstatus=$status + diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions + diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions + old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From + new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To + rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') + printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && continue #If application is on ignore list, skip + if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update + if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not + if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || { echo "FAILED"; continue; } + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" + continue + else # if status was not STOPPED, stop the app prior to updating + echo -e "\n$app_name" + [[ "$verbose" == "true" ]] && echo "Stopping prior to update.." + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" + while [[ "$status" != "STOPPED" ]] + do + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + if [[ "$status" == "STOPPED" ]]; then + echo "Stopped" + [[ "$verbose" == "true" ]] && echo "Updating.." + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "Failed to update" + break + elif [[ "$SECONDS" -ge "$timeout" ]]; then + echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" + break + elif [[ "$status" != "STOPPED" ]]; then + [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED" + sleep 10 + continue + fi + done fi - else - echo -e "\n$app_name\nMajor Release, update manually" - continue + else #user must not be using -S, just update + echo -e "\n$app_name" + [[ "$verbose" == "true" ]] && echo "Updating.." + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || { echo "FAILED"; continue; } fi - done + else + echo -e "\n$app_name\nMajor Release, update manually" + continue + fi +done } export -f update_apps From 9f741e4742df4c99dca3fc99468ea65ace1bf2e6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 11 Jun 2022 02:02:07 -0600 Subject: [PATCH 065/823] more indentation --- heavy_script.sh | 68 ++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 0f08a004..1c28a7b8 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -207,44 +207,44 @@ do new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && continue #If application is on ignore list, skip - if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update - if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not - if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" - continue - else # if status was not STOPPED, stop the app prior to updating - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Stopping prior to update.." - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" - while [[ "$status" != "STOPPED" ]] - do - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') - if [[ "$status" == "STOPPED" ]]; then - echo "Stopped" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "Failed to update" - break - elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" - break - elif [[ "$status" != "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED" - sleep 10 - continue - fi - done - fi - else #user must not be using -S, just update + if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update + if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not + if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || { echo "FAILED"; continue; } + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" + continue + else # if status was not STOPPED, stop the app prior to updating + echo -e "\n$app_name" + [[ "$verbose" == "true" ]] && echo "Stopping prior to update.." + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" + while [[ "$status" != "STOPPED" ]] + do + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + if [[ "$status" == "STOPPED" ]]; then + echo "Stopped" + [[ "$verbose" == "true" ]] && echo "Updating.." + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "Failed to update" + break + elif [[ "$SECONDS" -ge "$timeout" ]]; then + echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" + break + elif [[ "$status" != "STOPPED" ]]; then + [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED" + sleep 10 + continue + fi + done fi - else - echo -e "\n$app_name\nMajor Release, update manually" - continue + else #user must not be using -S, just update + echo -e "\n$app_name" + [[ "$verbose" == "true" ]] && echo "Updating.." + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || { echo "FAILED"; continue; } fi + else + echo -e "\n$app_name\nMajor Release, update manually" + continue + fi done } export -f update_apps From 8e8f46f4a3443e39d76ad5877d907a04370f6988 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 12 Jun 2022 19:35:10 +0000 Subject: [PATCH 066/823] typo in --help --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 1c28a7b8..7bd059de 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -9,7 +9,7 @@ help(){ echo "Basic Utilities" echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset" -echo "--delete backup | Opens a menu to delete backups on your system" +echo "--delete-backup | Opens a menu to delete backups on your system" echo "--dns | list all of your applications DNS names and their web ports" echo echo "Update Options" From e325ab0a3a9997ec6df9d149d5645a8467496676 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 04:48:10 +0000 Subject: [PATCH 067/823] fix DNS regex Exclude dependency pods unless they were launched with custom-app. --- heavy_script.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 7bd059de..8eb2b15b 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -24,14 +24,14 @@ echo "-v | verbose output" echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" echo "-s | sync catalog" echo "-p | Prune unused/old docker images" -echo +echo echo "Examples" echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" -echo "bash /mnt/tank/scripts/heavy_script.sh --restore" +echo "bash /mnt/tank/scripts/heavy_script.sh --restore" echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" -echo +echo exit } export -f help @@ -102,8 +102,8 @@ export -f restore dns(){ clear -x echo "Generating DNS Names.." -#ignored dependency pods, No change required -dep_ignore="cron|kube-system|nvidia|svclb|NAME|memcached" +#ignored dependency pods, may need to add more in the future. +dep_ignore="\-cronjob\-|^kube-system|\ssvclb|NAME|\-memcached\-.[^custom\-app]|\-postgresql\-.[^custom\-app]|\-redis\-.[^custom\-app]|\-mariadb\-.[^custom\-app]|\-promtail\-.[^custom\-app]" # Pulling pod names mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$dep_ignore" | sort) From 382b8296be0416fc164cefccd569ca9d363960d9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 13:30:23 -0600 Subject: [PATCH 068/823] testing self update --- heavy_script.sh | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 1c28a7b8..d1a10de2 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,12 +4,38 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit +self_update() { +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") +SCRIPTNAME="$0" +ARGS="$@" +BRANCH="beta" + +cd $SCRIPTPATH +git fetch + +[[ -n $(git diff --name-only origin/$BRANCH | grep $SCRIPTNAME) ]] && { + echo "Found a new version of me, updating myself..." + git pull --force + git checkout $BRANCH + git pull --force + echo "Running the new version..." + exec "$SCRIPTNAME" "$@" + + # Now exit this old instance + exit 1 + } + echo "Already the latest version." +} + +self_update + help(){ [[ $help == "true" ]] && clear -x echo "Basic Utilities" echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset" -echo "--delete backup | Opens a menu to delete backups on your system" +echo "--delete-backup | Opens a menu to delete backups on your system" echo "--dns | list all of your applications DNS names and their web ports" echo echo "Update Options" @@ -24,14 +50,14 @@ echo "-v | verbose output" echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" echo "-s | sync catalog" echo "-p | Prune unused/old docker images" -echo +echo echo "Examples" echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" -echo "bash /mnt/tank/scripts/heavy_script.sh --restore" +echo "bash /mnt/tank/scripts/heavy_script.sh --restore" echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" -echo +echo exit } export -f help @@ -102,8 +128,8 @@ export -f restore dns(){ clear -x echo "Generating DNS Names.." -#ignored dependency pods, No change required -dep_ignore="cron|kube-system|nvidia|svclb|NAME|memcached" +#ignored dependency pods, may need to add more in the future. +dep_ignore="\-cronjob\-|^kube-system|\ssvclb|NAME|\-memcached\-.[^custom\-app]|\-postgresql\-.[^custom\-app]|\-redis\-.[^custom\-app]|\-mariadb\-.[^custom\-app]|\-promtail\-.[^custom\-app]" # Pulling pod names mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$dep_ignore" | sort) @@ -430,4 +456,4 @@ done [[ "$number_of_backups" -ge 1 ]] && backup [[ "$sync" == "true" ]] && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && update_apps -[[ "$prune" == "true" ]] && prune +[[ "$prune" == "true" ]] && prune \ No newline at end of file From bbb6428466ff74dfbcfde3b68756d615e71434ec Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 13:55:49 -0600 Subject: [PATCH 069/823] testing self update --- heavy_script.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index d1a10de2..a9240fd1 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,14 +3,14 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - -self_update() { +ARGS="echo $* | sed s/--self-update//" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" -ARGS="$@" BRANCH="beta" +self_update() { + cd $SCRIPTPATH git fetch @@ -20,7 +20,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec "$SCRIPTNAME" "$@" + exec "$SCRIPTNAME" "$ARGS" # Now exit this old instance exit 1 @@ -28,7 +28,7 @@ git fetch echo "Already the latest version." } -self_update + help(){ [[ $help == "true" ]] && clear -x @@ -371,6 +371,9 @@ do help) help="true" ;; + self-update) + self_update="true" + ;; dns) dns="true" ;; @@ -448,6 +451,7 @@ done [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit #Continue to call functions in specific order +[[ "$self_update" == "true" ]] && self_update [[ "$help" == "true" ]] && help [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit From e4dd02a78429e33af50044c5baf00781e49b480c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 13:56:26 -0600 Subject: [PATCH 070/823] bash scriptname --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index a9240fd1..813f2910 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -20,7 +20,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec "$SCRIPTNAME" "$ARGS" + exec bash "$SCRIPTNAME" "$ARGS" # Now exit this old instance exit 1 From f92adc4c0c31e32c128b9bc49f8aee54bae1a9cd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 13:59:31 -0600 Subject: [PATCH 071/823] testing --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 813f2910..1168be69 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -28,7 +28,7 @@ git fetch echo "Already the latest version." } - +echo help(){ [[ $help == "true" ]] && clear -x From cc1d9883a5308299f477675665c81211fa1d943a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:05:27 -0600 Subject: [PATCH 072/823] replace string --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 1168be69..ee47c0d3 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,7 +3,7 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="echo $* | sed s/--self-update//" +ARGS="$*" ; echo "${ARGS}//--self-update/" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From a1dc4fd99ae90b9c772458dd3fb496211de5cc19 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:06:03 -0600 Subject: [PATCH 073/823] pushing just to push --- heavy_script.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heavy_script.sh b/heavy_script.sh index ee47c0d3..986fdafc 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -9,6 +9,8 @@ SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" BRANCH="beta" + + self_update() { cd $SCRIPTPATH From cad43d63ef13d381d64cec510bdcc47e3e2b06cf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:07:23 -0600 Subject: [PATCH 074/823] another push --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 986fdafc..3f3cfd98 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,7 +3,7 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$*" ; echo "${ARGS}//--self-update/" +ARGS="$*" ; echo "${ARGS//--self-update/}" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" @@ -30,7 +30,7 @@ git fetch echo "Already the latest version." } -echo + help(){ [[ $help == "true" ]] && clear -x From 169c5fe8a3c1603181017df0842d1be8e757cb21 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:07:47 -0600 Subject: [PATCH 075/823] another --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 3f3cfd98..8d029bfa 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -10,7 +10,6 @@ SCRIPTNAME="$0" BRANCH="beta" - self_update() { cd $SCRIPTPATH From eceba192fb2bea328bfc7eaab08a23336310ee2f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:08:45 -0600 Subject: [PATCH 076/823] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 8d029bfa..6ee5472f 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,7 +3,7 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$*" ; echo "${ARGS//--self-update/}" +ARGS="$*" ; echo "${ARGS//--self-update}" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From 94036179d4695e773f11573a3299bd5ef76a45a3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:09:12 -0600 Subject: [PATCH 077/823] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 6ee5472f..cef2b6cd 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -9,7 +9,6 @@ SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" BRANCH="beta" - self_update() { cd $SCRIPTPATH From 06e7ad4b27676e0b0f61b032d64ee614af7101c5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:10:28 -0600 Subject: [PATCH 078/823] escape hyphens? --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index cef2b6cd..b4398a15 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,7 +3,7 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$*" ; echo "${ARGS//--self-update}" +ARGS="$*" ; echo "${ARGS//\-\-self\-update}" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From bb4edf6bf1fe0ecb59b4f55794ca3f5f34e810d3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:10:54 -0600 Subject: [PATCH 079/823] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index b4398a15..610f0392 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -9,6 +9,7 @@ SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" BRANCH="beta" + self_update() { cd $SCRIPTPATH From 151b37947bed1aa98e0dc4c952955476d5ddecf5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:11:51 -0600 Subject: [PATCH 080/823] remove self update form args --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 610f0392..054e7ebc 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,7 +3,7 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$*" ; echo "${ARGS//\-\-self\-update}" +ARGS="$*" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" @@ -21,7 +21,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "$ARGS" + exec bash "$SCRIPTNAME" "${ARGS//\-\-self\-update}" # Now exit this old instance exit 1 From 69393bab6b08a644da74052d25b42864f907d2ce Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:12:18 -0600 Subject: [PATCH 081/823] only real way to test this unf --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 054e7ebc..300b9a18 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,6 +3,7 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS="$*" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From d2d5f6f7aebb0d71e57b5801108314df228a1fc0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:13:17 -0600 Subject: [PATCH 082/823] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 300b9a18..ed41f382 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -22,7 +22,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS//\-\-self\-update}" + bash "$SCRIPTNAME" "${ARGS//\ \-\-self\-update}" # Now exit this old instance exit 1 From ab68827f8ffd975d3eeb01b0b37e555b06c1090e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:13:35 -0600 Subject: [PATCH 083/823] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index ed41f382..7456f664 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -10,7 +10,6 @@ SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" BRANCH="beta" - self_update() { cd $SCRIPTPATH From 362974975c299aa28fbb6d53cc4ac31e0608d567 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:14:25 -0600 Subject: [PATCH 084/823] once again --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 7456f664..ed41f382 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -10,6 +10,7 @@ SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" BRANCH="beta" + self_update() { cd $SCRIPTPATH From 7f44d500b89619c93e1044489d5b449de1885ee4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:16:12 -0600 Subject: [PATCH 085/823] more testing --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index ed41f382..7456f664 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -10,7 +10,6 @@ SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" BRANCH="beta" - self_update() { cd $SCRIPTPATH From e880da61ed8128b6acb6f2ad0b878c64f7418794 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:17:23 -0600 Subject: [PATCH 086/823] more testing --- heavy_script.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 7456f664..f2724dbb 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -21,7 +21,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - bash "$SCRIPTNAME" "${ARGS//\ \-\-self\-update}" + bash "$SCRIPTNAME" "${ARGS//\ \-\-self\-update\ }" # Now exit this old instance exit 1 @@ -30,7 +30,6 @@ git fetch } - help(){ [[ $help == "true" ]] && clear -x echo "Basic Utilities" From 5f2df0a69e50c836b876c6cc3367ef1a97edd6eb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:25:37 -0600 Subject: [PATCH 087/823] test --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index f2724dbb..c5d1603d 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$*" +ARGS="$@" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" @@ -21,7 +21,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - bash "$SCRIPTNAME" "${ARGS//\ \-\-self\-update\ }" + exec bash "$SCRIPTNAME" "${ARGS//\ \-\-self\-update\ }" # Now exit this old instance exit 1 From 7e82f95bf24295f893fa10d8316c4291f6439a84 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:26:15 -0600 Subject: [PATCH 088/823] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index c5d1603d..0fa18fe7 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS="$@" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From b50f475743aa009adc80046b3d22b1667834c948 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:26:54 -0600 Subject: [PATCH 089/823] string --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 0fa18fe7..093b3cd3 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,7 +5,7 @@ -ARGS="$@" +ARGS="$*" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From 3fab72b9d9b6ce265c3001f470e7a7c0266be2b4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:27:19 -0600 Subject: [PATCH 090/823] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 093b3cd3..26f70132 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS="$*" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 9da93da982e2981176ffefeb9e6bcac36ae401a1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:28:41 -0600 Subject: [PATCH 091/823] test --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 26f70132..779fda63 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$*" +ARGS="$@" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" @@ -21,7 +21,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS//\ \-\-self\-update\ }" + exec bash "$SCRIPTNAME" "${ARGS//\-\-self\-update}" # Now exit this old instance exit 1 From 8dc864cae74fcdf9dc380a391a16fbee3df8791e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:29:00 -0600 Subject: [PATCH 092/823] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 779fda63..c19eb5d2 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS="$@" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From f11ef25a43fe773cac26e60ffccb615edbfda158 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:35:45 -0600 Subject: [PATCH 093/823] test --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index c19eb5d2..77c56652 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,7 +5,7 @@ -ARGS="$@" +ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" @@ -22,7 +22,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS//\-\-self\-update}" + exec bash "$SCRIPTNAME" "${ARGS[@]//\-\-self\-update}" # Now exit this old instance exit 1 From 29665ca8cf396ec1dca0e641fbdd6a00e572c4c6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:37:02 -0600 Subject: [PATCH 094/823] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 77c56652..e57950ff 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 6c1e4a762fefd327d957dc40699093808f0b97fa Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:38:14 -0600 Subject: [PATCH 095/823] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index e57950ff..77c56652 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 0a01f4b0c2e8513bb80514261b67b38874f127cf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:41:15 -0600 Subject: [PATCH 096/823] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 77c56652..689bffba 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -22,7 +22,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]//\-\-self\-update}" + exec bash "$SCRIPTNAME" "${ARGS[@]/\-\-self\-update}" # Now exit this old instance exit 1 From 5f40b315f2be192f48159a46fc90277e000afb1d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:41:32 -0600 Subject: [PATCH 097/823] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 689bffba..c62a17fe 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 70f5388b7de8bb2176a5ca1e303839bb991ddb74 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:43:16 -0600 Subject: [PATCH 098/823] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index c62a17fe..72cda34c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -21,7 +21,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]/\-\-self\-update}" + exec bash "$SCRIPTNAME" "${ARGS[@]/\ \-\-self\-update\ }" # Now exit this old instance exit 1 From 1713d195288a437549b80b83b67a7b6c5237a68f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:43:42 -0600 Subject: [PATCH 099/823] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 72cda34c..d107139e 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From c7f594b63b3aa444c4526a635157d54f811bc66b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:45:11 -0600 Subject: [PATCH 100/823] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index d107139e..eede1ab9 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -22,7 +22,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]/\ \-\-self\-update\ }" + exec bash "$SCRIPTNAME" "${ARGS[@]/[\ ]\-\-self\-update[\ ]}" # Now exit this old instance exit 1 From b6b7f18f14298cb472aa59e82af3fff50194fd33 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:45:29 -0600 Subject: [PATCH 101/823] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index eede1ab9..3d8f2766 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From a17d0a0faad9e25894e0e757005263b94f7c2257 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:46:32 -0600 Subject: [PATCH 102/823] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 3d8f2766..b31616c8 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -21,7 +21,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]/[\ ]\-\-self\-update[\ ]}" + exec bash "$SCRIPTNAME" "${ARGS[@]/(\ )\-\-self\-update(\ )}" # Now exit this old instance exit 1 From 8e2d77323ebcb0db9e328dd32561088fa9ee0c9a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:46:45 -0600 Subject: [PATCH 103/823] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index b31616c8..069d89d6 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 8c0cb93fe0b6631f1dfc3d63a42ae55bca7557fb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:51:40 -0600 Subject: [PATCH 104/823] test --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 069d89d6..800c1747 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,7 +5,7 @@ -ARGS=( "$@" ) +ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" @@ -22,7 +22,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]/(\ )\-\-self\-update(\ )}" + exec bash "$SCRIPTNAME" "${ARGS[@]/\s?\-\-self\-update\s?}" # Now exit this old instance exit 1 From d39634b39f9e2033491bcf93b5691d1b65d94fdd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:52:03 -0600 Subject: [PATCH 105/823] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 800c1747..be75bac5 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 4c9ee5de13de19e30f2c7dcee0390fb0f31ce73f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:53:01 -0600 Subject: [PATCH 106/823] sed --- heavy_script.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index be75bac5..d7abe91e 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,8 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS=( "$@" ) + +ARGS="$@" ; echo "$ARGS" | sed -e 's/\s?\-\-self\-update\s?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" @@ -21,7 +22,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]/\s?\-\-self\-update\s?}" + exec bash "$SCRIPTNAME" "${ARGS[@]}" # Now exit this old instance exit 1 From 8c1db858b8a8bdfa5c0ae8967eeede676b191319 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:53:20 -0600 Subject: [PATCH 107/823] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index d7abe91e..62db01d7 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS="$@" ; echo "$ARGS" | sed -e 's/\s?\-\-self\-update\s?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 8ac7b496d9d53d7789e68df0aa55c60f97569f9d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:59:37 -0600 Subject: [PATCH 108/823] regex --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 62db01d7..d7ce4cce 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$@" ; echo "$ARGS" | sed -e 's/\s?\-\-self\-update\s?//' +ARGS="$@" ; echo "$ARGS" | sed -e 's/[:space:]\?\-\-self\-update[:space:]\?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" @@ -21,7 +21,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]}" + exec bash "$SCRIPTNAME" ${ARGS[@]} # Now exit this old instance exit 1 From 1845d3c9c028f06dd971e6ed483b50cfdd271cd7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:00:09 -0600 Subject: [PATCH 109/823] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index d7ce4cce..3daae58d 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS="$@" ; echo "$ARGS" | sed -e 's/[:space:]\?\-\-self\-update[:space:]\?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 48d71ffc2e4d3ab17b33d4be10c83100178c8adc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:00:51 -0600 Subject: [PATCH 110/823] fix space --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 3daae58d..b148a01d 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,7 +5,7 @@ -ARGS="$@" ; echo "$ARGS" | sed -e 's/[:space:]\?\-\-self\-update[:space:]\?//' +ARGS="$@" ; echo "$ARGS" | sed -e 's/[[:space:]]\?\-\-self\-update[[:space:]]\?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From af6d65d0d50da00e4f53e9b64261ee08668191bc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:01:51 -0600 Subject: [PATCH 111/823] reg --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index b148a01d..a5a708ef 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,7 +5,7 @@ -ARGS="$@" ; echo "$ARGS" | sed -e 's/[[:space:]]\?\-\-self\-update[[:space:]]\?//' +ARGS="$@" ; echo "$ARGS" | sed -e 's/[[:space:]]\?--self-update[[:space:]]\?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From a17ba00666285229245500b1c838b5ac7315b7bb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:02:25 -0600 Subject: [PATCH 112/823] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index a5a708ef..a440bec7 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS="$@" ; echo "$ARGS" | sed -e 's/[[:space:]]\?--self-update[[:space:]]\?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From d111b214139bcd821c3d7cee60ea030957f99935 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:03:10 -0600 Subject: [PATCH 113/823] reg --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index a440bec7..28931d09 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$@" ; echo "$ARGS" | sed -e 's/[[:space:]]\?--self-update[[:space:]]\?//' +ARGS="$@" ; echo "$ARGS" | sed -e 's/[[:space:]]?--self-update[[:space:]]?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From 05906fee686cf2244fc533d6b700c12b9aff9e1c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:03:28 -0600 Subject: [PATCH 114/823] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 28931d09..2f3623fa 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS="$@" ; echo "$ARGS" | sed -e 's/[[:space:]]?--self-update[[:space:]]?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From a0f83bc66a9129417f427b216f5d388295df552f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:05:31 -0600 Subject: [PATCH 115/823] :L --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 2f3623fa..3431c131 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,7 +5,7 @@ -ARGS="$@" ; echo "$ARGS" | sed -e 's/[[:space:]]?--self-update[[:space:]]?//' +ARGS="$@" ; echo "$ARGS" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From fec89db940a98d0576128d80c8d4cdd500673b67 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:05:59 -0600 Subject: [PATCH 116/823] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 3431c131..e0211266 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS="$@" ; echo "$ARGS" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From f289cdf76b3d51f0e4da3b6911cc3f8a21f9d7ee Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:07:28 -0600 Subject: [PATCH 117/823] test --- heavy_script.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index e0211266..62d8373b 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,8 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$@" ; echo "$ARGS" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g' +ARGS=( echo "$@" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g') + SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From 8030dbf2b5de0f3404fc9fa4686271982f24778d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:08:30 -0600 Subject: [PATCH 118/823] fix --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 62d8373b..6eb77eb7 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS=( echo "$@" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g') +ARGS=$(echo "$@" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g') SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 3bd1013b3d03166d2bebb5f965d29a50bb6ed087 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:10:05 -0600 Subject: [PATCH 119/823] non array --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 6eb77eb7..edbca1b6 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS=$(echo "$@" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g') +ARGS=$(echo "$*" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g') SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") @@ -22,7 +22,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" ${ARGS[@]} + exec bash "$SCRIPTNAME" "$ARGS" # Now exit this old instance exit 1 From 83b1e286e800ff82212e5dd0cd2ba7f7eb7f4925 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:10:24 -0600 Subject: [PATCH 120/823] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index edbca1b6..8825fcca 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS=$(echo "$*" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g') SCRIPT=$(readlink -f "$0") From 4c8cc6bb2c1070c9f5e74a1f853a99d42624a60f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:10:57 -0600 Subject: [PATCH 121/823] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 8825fcca..edbca1b6 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS=$(echo "$*" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g') SCRIPT=$(readlink -f "$0") From 2ad456b905169bf57291868481f167042b9ff00e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:13:46 -0600 Subject: [PATCH 122/823] test --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index edbca1b6..89022099 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS=$(echo "$*" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g') +ARGS=$( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") @@ -22,7 +22,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "$ARGS" + exec bash "$SCRIPTNAME" "${ARGS[@]/[[:space:]]?--self-update[[:space:]]?}" # Now exit this old instance exit 1 From 41f49eb4ff587633c64178e74fdd9345f06e7752 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:14:05 -0600 Subject: [PATCH 123/823] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 89022099..221eb93d 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS=$( "$@" ) SCRIPT=$(readlink -f "$0") From 113fc93d913e671668bd35f5dd338c8a1d5d16d9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:16:40 -0600 Subject: [PATCH 124/823] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 221eb93d..afa51e61 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -23,7 +23,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]/[[:space:]]?--self-update[[:space:]]?}" + exec bash "$SCRIPTNAME" "${ARGS[@]//[[:space:]]?--self-update[[:space:]]?}" # Now exit this old instance exit 1 From e4c54be187a64b0b70f1176f09a7e3d68706e242 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:16:56 -0600 Subject: [PATCH 125/823] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index afa51e61..f5792fc7 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS=$( "$@" ) SCRIPT=$(readlink -f "$0") From 7b07ea3a33278ede33498a1b4aa363761ddb3a45 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:22:53 -0600 Subject: [PATCH 126/823] for --- heavy_script.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index f5792fc7..774b0ce7 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -22,7 +22,13 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]//[[:space:]]?--self-update[[:space:]]?}" + count=0 + for i in ${ARGS[@]} + do + [[ "$i" == "//[[:space:]]?--self-update[[:space:]]?" ]] && unset "${ARGS[$count]}" + ((count++)) + done + exec bash "$SCRIPTNAME" "${ARGS[@]}" # Now exit this old instance exit 1 From de661f0ef0c7d9d54af28fc756ebaac647d2eb11 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:23:11 -0600 Subject: [PATCH 127/823] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 774b0ce7..c43390ca 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS=$( "$@" ) SCRIPT=$(readlink -f "$0") From 1a46cb1ffd8d88ef58543f4250f091c827764507 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:28:47 -0600 Subject: [PATCH 128/823] test --- heavy_script.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index c43390ca..ab9b8eb6 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,7 +5,8 @@ -ARGS=$( "$@" ) +ARGS=("$@") + SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 2e8a4dbdaa14166187b6a34456a0334ec75a30a0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:29:16 -0600 Subject: [PATCH 129/823] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index ab9b8eb6..ca77e300 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -8,6 +8,7 @@ ARGS=("$@") + SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From 338499585bf730f8c0b359db9cf457d043f2b639 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:30:19 -0600 Subject: [PATCH 130/823] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index ca77e300..02799f99 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -28,7 +28,7 @@ git fetch count=0 for i in ${ARGS[@]} do - [[ "$i" == "//[[:space:]]?--self-update[[:space:]]?" ]] && unset "${ARGS[$count]}" + [[ "$i" == "--self-update" ]] && unset "${ARGS[$count]}" ((count++)) done exec bash "$SCRIPTNAME" "${ARGS[@]}" From 64d3371c21148cff4882aace0aea35a0cb975ff9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:30:39 -0600 Subject: [PATCH 131/823] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 02799f99..409f2dbf 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -8,7 +8,6 @@ ARGS=("$@") - SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From 2309076a709d25b35b71da1f04a168521312f264 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:34:07 -0600 Subject: [PATCH 132/823] syntax --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 409f2dbf..5de1f109 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -27,7 +27,7 @@ git fetch count=0 for i in ${ARGS[@]} do - [[ "$i" == "--self-update" ]] && unset "${ARGS[$count]}" + [[ "$i" == "--self-update" ]] && unset "ARGS[$count]" ((count++)) done exec bash "$SCRIPTNAME" "${ARGS[@]}" From 54a96475fc6428020670f0c6003306bcf5684b74 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:34:33 -0600 Subject: [PATCH 133/823] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 5de1f109..82590268 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -8,6 +8,7 @@ ARGS=("$@") + SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From 749c033a68d3222fa2d82ff902584d77feb614a1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:35:50 -0600 Subject: [PATCH 134/823] ooooo --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 82590268..ef62901a 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -28,7 +28,7 @@ git fetch count=0 for i in ${ARGS[@]} do - [[ "$i" == "--self-update" ]] && unset "ARGS[$count]" + [[ "$i" == "--self-update" ]] && unset "ARGS[$count]" && break ((count++)) done exec bash "$SCRIPTNAME" "${ARGS[@]}" From b99cb44b7ab420e32ba7d6ee2bf05233231b4796 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:40:09 -0600 Subject: [PATCH 135/823] lowercase --- heavy_script.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index ef62901a..dcff7967 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,17 +5,13 @@ -ARGS=("$@") - - +args=("$@") +self_update() { SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" BRANCH="beta" - -self_update() { - cd $SCRIPTPATH git fetch @@ -26,12 +22,12 @@ git fetch git pull --force echo "Running the new version..." count=0 - for i in ${ARGS[@]} + for i in "${args[@]}" do - [[ "$i" == "--self-update" ]] && unset "ARGS[$count]" && break + [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done - exec bash "$SCRIPTNAME" "${ARGS[@]}" + exec bash "$SCRIPTNAME" "${args[@]}" # Now exit this old instance exit 1 From 5f028225ccba2a5408ad87dbb33f148f1160e58d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:41:16 -0600 Subject: [PATCH 136/823] almost done --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index dcff7967..54361cdb 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - args=("$@") self_update() { From 01fc4f6c9101a210eac4432baf32740d46f92f1f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:42:24 -0600 Subject: [PATCH 137/823] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 54361cdb..dcff7967 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + args=("$@") self_update() { From 6658586651e514929dc9de67d5bea0cd699bd4a4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:45:22 -0600 Subject: [PATCH 138/823] delete branch --- heavy_script.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index dcff7967..3ebd69e2 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -11,15 +11,12 @@ self_update() { SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" -BRANCH="beta" cd $SCRIPTPATH git fetch [[ -n $(git diff --name-only origin/$BRANCH | grep $SCRIPTNAME) ]] && { echo "Found a new version of me, updating myself..." git pull --force - git checkout $BRANCH - git pull --force echo "Running the new version..." count=0 for i in "${args[@]}" From bf5f1a0dc212cf42529d9d4c60192dca080af36d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:50:20 -0600 Subject: [PATCH 139/823] test --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 3ebd69e2..575bc6c3 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -14,9 +14,9 @@ SCRIPTNAME="$0" cd $SCRIPTPATH git fetch -[[ -n $(git diff --name-only origin/$BRANCH | grep $SCRIPTNAME) ]] && { +[[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]] && { echo "Found a new version of me, updating myself..." - git pull --force + git pull --force &> /dev/null echo "Running the new version..." count=0 for i in "${args[@]}" From 546cb6892f42199b52ebc2963e7defe1cb99027b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:52:22 -0600 Subject: [PATCH 140/823] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 575bc6c3..7c2ed973 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -12,7 +12,7 @@ SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" cd $SCRIPTPATH -git fetch +git fetch &> /dev/null [[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]] && { echo "Found a new version of me, updating myself..." From 083269cdffe933fb38809c56ecf143e5e406ee2e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:55:14 -0600 Subject: [PATCH 141/823] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 7c2ed973..90d45d44 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - args=("$@") self_update() { From 7f99e9e46e1779ccd3bcf0cc9de35fbb20025cef Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:56:01 -0600 Subject: [PATCH 142/823] formatting --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 90d45d44..d1e26776 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -16,7 +16,7 @@ git fetch &> /dev/null [[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]] && { echo "Found a new version of me, updating myself..." git pull --force &> /dev/null - echo "Running the new version..." + echo -e "Running the new version...\n" count=0 for i in "${args[@]}" do @@ -28,7 +28,7 @@ git fetch &> /dev/null # Now exit this old instance exit 1 } - echo "Already the latest version." + echo -e "Already the latest version.\n" } From 799629013b7bc90ce859e4c39541638b1838cc82 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:56:50 -0600 Subject: [PATCH 143/823] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index d1e26776..8efd5417 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -23,7 +23,7 @@ git fetch &> /dev/null [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done - exec bash "$SCRIPTNAME" "${args[@]}" + bash "$SCRIPTNAME" "${args[@]}" # Now exit this old instance exit 1 From 455ab485393d2f937c44af120b6936b8210083bc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:57:13 -0600 Subject: [PATCH 144/823] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 8efd5417..5b0dd8b6 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + args=("$@") self_update() { From 2c7cf84674bc78600af59a9780fbc61c4d235649 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:57:42 -0600 Subject: [PATCH 145/823] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 5b0dd8b6..22bf5103 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,7 +3,7 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - +echo "yep" args=("$@") From 97b0236def42b41be9ca1ce915d213b877cdb251 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:58:32 -0600 Subject: [PATCH 146/823] test --- heavy_script.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 22bf5103..2462458d 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,7 +3,6 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -echo "yep" args=("$@") @@ -15,7 +14,7 @@ cd $SCRIPTPATH git fetch &> /dev/null [[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]] && { - echo "Found a new version of me, updating myself..." + echo "Found a new version of HeavyScript, updating myself..." git pull --force &> /dev/null echo -e "Running the new version...\n" count=0 From 27516ff497c6b78dc8912f221b3b46ae1a66a22a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:59:08 -0600 Subject: [PATCH 147/823] sleep --- heavy_script.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 2462458d..9b1c290e 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -23,7 +23,8 @@ git fetch &> /dev/null [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done - bash "$SCRIPTNAME" "${args[@]}" + sleep 5 + exec bash "$SCRIPTNAME" "${args[@]}" # Now exit this old instance exit 1 From 993475135b9394b2fb104a551e4198b768240c73 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:59:42 -0600 Subject: [PATCH 148/823] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 9b1c290e..176a0582 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,6 +3,7 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit +echo "yep" args=("$@") From 893004fe5838a5c86748f60d128105e96a928a52 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 16:20:35 -0600 Subject: [PATCH 149/823] add self update option --- README.md | 24 ++++++++++-------------- heavy_script.sh | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index f7717f6e..d41f2613 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ | Flag | Example | Parameter | Description | |----------------- |------------------------ |----------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| --self-update | --self-update | None | Updates HeavyScript prior to running it
_You no longer need to git pull_ | | --delete-backup | --delete-backup | None | Opens a menu to delete backups
_Useful if you need to delete old system backups or backups from other scripts_ | | --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot | | --mount | --mount | None | Initiates mounting feature
Choose between unmounting and mounting PVC data | @@ -36,7 +37,7 @@ ### Examples #### Typical Cron Job ``` -bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsup +bash heavy_script.sh --self-update -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsup ``` > `-b` is set to 14. Up to 14 snapshots of your ix-applications dataset will be saved @@ -53,6 +54,8 @@ bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsup > `-p` Prune docker images. +> `--self-update` Will update the script prior to running anything else. + #### Mounting PVC Data ``` @@ -79,7 +82,7 @@ bash /mnt/tank/scripts/heavy_script/heavy_script.sh --dns #### My personal Cron Job ``` -git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -rsup +bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 14 -rsup ```
@@ -111,7 +114,7 @@ cd heavy_script From here, you can just run Heavy_Script with `bash heavy_script.sh -ARGUMENTS` -> Note: `chmod +x` is NOT required. Doing this will break the `git pull` function. Just run the script with `bash heavy_script.sh` +> Note: `chmod +x` is NOT required. Doing this will break the `git pull` (or self update) function. Just run the script with `bash heavy_script.sh`
@@ -132,20 +135,13 @@ git pull ```
-### Update with your Cron Job +### Update with the scripts built-in option -Here, we will update the script prior to running it, incase there is a bugfix, or any new additions to the script - -**Cron Job Command** ``` -git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -rsup +bash heavyscript --self-update -b 14 -supr ``` -> The important command here is the `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull` +> The important argument here is the `--self-update`, you can still use all of your same arguments with this option. -> This command will allow you to preform a `git pull` on a remote directory, which will ensure your script is udated prior to running it - -> `&&` Is used to run a command AFTER the previous command completed successfully ->> So once the `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull` command completes, THEN it will run the `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh -b 14 -rsup` command

@@ -161,7 +157,7 @@ git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_scr | Name | Value | Reason | |------------------------ |------------------------------------------------------------------------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `Description` | HeavyScript git pull and Update apps | This is up to you, put whatever you think is a good description in here | -| `Command` | `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull && bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh -b 14 -rsup` | This is the command you will be running on your schedule I personally use: `git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -rsup` | +| `Command` | `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh --self-update -b 14 -rsup` | This is the command you will be running on your schedule I personally use: `bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 14 -rsup` | | `Run As User` | `root` | Running the script as `root` is REQUIRED. You cannot access all of the kubernetes functions without this user. | | `Schedule` | Up to you, I run mine everyday at `0400` | Again up to you | | `Hide Standard Output` | `False` or Unticked | I like to receive an email report of how the script ran, what apps updated etc. | diff --git a/heavy_script.sh b/heavy_script.sh index 8eb2b15b..4ba89019 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,6 +3,35 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit +args=("$@") + +self_update() { +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") +SCRIPTNAME="$0" +cd $SCRIPTPATH +git fetch &> /dev/null + +[[ -n $(git diff --name-only origin/main | grep $SCRIPTNAME) ]] && { + echo "Found a new version of HeavyScript, updating myself..." + git pull --force &> /dev/null + echo -e "Running the new version...\n" + count=0 + for i in "${args[@]}" + do + [[ "$i" == "--self-update" ]] && unset "args[$count]" && break + ((count++)) + done + sleep 5 + exec bash "$SCRIPTNAME" "${args[@]}" + + # Now exit this old instance + exit + } + echo -e "HeavyScript is already the latest version.\n" +} + + help(){ [[ $help == "true" ]] && clear -x @@ -342,9 +371,12 @@ do case $opt in -) case "${OPTARG}" in - help) + help) help="true" ;; + self-update) + self_update="true" + ;; dns) dns="true" ;; @@ -423,6 +455,7 @@ done #Continue to call functions in specific order [[ "$help" == "true" ]] && help +[[ "$self_update" == "true" ]] && self_update [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit From b984d2873e88c4e2b73ea6ff1df992ac4f2c6991 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 22:22:29 +0000 Subject: [PATCH 150/823] typo in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d41f2613..c1529c08 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ git pull ### Update with the scripts built-in option ``` -bash heavyscript --self-update -b 14 -supr +bash heavyscript.sh --self-update -b 14 -supr ``` > The important argument here is the `--self-update`, you can still use all of your same arguments with this option. From 4d34c42f38a75b0928ec6e625a3c98a16738f531 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 22:23:34 +0000 Subject: [PATCH 151/823] remove whitespace --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 4ba89019..f8d87e8c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -32,7 +32,6 @@ git fetch &> /dev/null } - help(){ [[ $help == "true" ]] && clear -x echo "Basic Utilities" From ca455cd9a5f916731f85fea9c5200d0a6e9fb440 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 14 Jun 2022 23:28:13 +0000 Subject: [PATCH 152/823] cleanup add git reset in the event a user chmod +x the script. remove continue from if statement.. it didn't do anything --- heavy_script.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index f8d87e8c..e0ae0adb 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -14,13 +14,14 @@ git fetch &> /dev/null [[ -n $(git diff --name-only origin/main | grep $SCRIPTNAME) ]] && { echo "Found a new version of HeavyScript, updating myself..." - git pull --force &> /dev/null + git reset --hard -q + git pull --force -q echo -e "Running the new version...\n" count=0 for i in "${args[@]}" do - [[ "$i" == "--self-update" ]] && unset "args[$count]" && break - ((count++)) + [[ "$i" == "--self-update" ]] && unset "args[$count]" && break + ((count++)) done sleep 5 exec bash "$SCRIPTNAME" "${args[@]}" @@ -57,7 +58,7 @@ echo "Examples" echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" -echo "bash /mnt/tank/scripts/heavy_script.sh --restore" +echo "bash --restore" echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" echo exit @@ -267,7 +268,7 @@ do else #user must not be using -S, just update echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || { echo "FAILED"; continue; } + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" fi else echo -e "\n$app_name\nMajor Release, update manually" From 61b8ab3444c9f72f76de11b8f0d6d3f61ddc0956 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 22 Jun 2022 22:33:34 -0600 Subject: [PATCH 153/823] Typo in --help --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index e0ae0adb..3da300dd 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -58,7 +58,7 @@ echo "Examples" echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" -echo "bash --restore" +echo "bash heavy_script.sh --restore" echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" echo exit From ec6e0884ef1ce5067895a25385975b37cca55ae8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 05:52:34 -0600 Subject: [PATCH 154/823] testing new self update --- heavy_script.sh | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 176a0582..f52fb90e 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,8 +3,6 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -echo "yep" - args=("$@") self_update() { @@ -14,23 +12,27 @@ SCRIPTNAME="$0" cd $SCRIPTPATH git fetch &> /dev/null -[[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]] && { +if [[ -n $(git diff --name-only origin/main | grep $SCRIPTNAME) ]]; then echo "Found a new version of HeavyScript, updating myself..." - git pull --force &> /dev/null + git reset --hard -q + git pull --force -q echo -e "Running the new version...\n" count=0 for i in "${args[@]}" do - [[ "$i" == "--self-update" ]] && unset "args[$count]" && break - ((count++)) + [[ "$i" == "--self-update" ]] && unset "args[$count]" && args+=("--updated") && break + ((count++)) done sleep 5 exec bash "$SCRIPTNAME" "${args[@]}" # Now exit this old instance - exit 1 - } - echo -e "Already the latest version.\n" + exit +elif [[ $self_update == "true" ]]; then + echo -e "HeavyScript has been updated\n" +else + echo -e "HeavyScript is already the latest version\n" +fi } @@ -59,7 +61,7 @@ echo "Examples" echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" -echo "bash /mnt/tank/scripts/heavy_script.sh --restore" +echo "bash heavy_script.sh --restore" echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" echo exit @@ -218,7 +220,7 @@ export -f sync update_apps(){ -mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|$)" | sort) +mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|\b)" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" @@ -269,7 +271,7 @@ do else #user must not be using -S, just update echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || { echo "FAILED"; continue; } + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" fi else echo -e "\n$app_name\nMajor Release, update manually" @@ -372,10 +374,10 @@ do case $opt in -) case "${OPTARG}" in - help) + help) help="true" ;; - self-update) + self-update) self_update="true" ;; dns) @@ -390,6 +392,9 @@ do delete-backup) deleteBackup="true" ;; + updated) + self_update="true" + ;; *) echo -e "Invalid Option \"--$OPTARG\"\n" && help exit @@ -455,8 +460,8 @@ done [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit #Continue to call functions in specific order -[[ "$self_update" == "true" ]] && self_update [[ "$help" == "true" ]] && help +[[ "$self_update" == "true" ]] && self_update [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit @@ -464,4 +469,4 @@ done [[ "$number_of_backups" -ge 1 ]] && backup [[ "$sync" == "true" ]] && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && update_apps -[[ "$prune" == "true" ]] && prune \ No newline at end of file +[[ "$prune" == "true" ]] && prune From cf004dd928faa0f627fc23b2d84e5889e31e52a3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 05:54:30 -0600 Subject: [PATCH 155/823] beta --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index f52fb90e..f04acab5 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -12,7 +12,7 @@ SCRIPTNAME="$0" cd $SCRIPTPATH git fetch &> /dev/null -if [[ -n $(git diff --name-only origin/main | grep $SCRIPTNAME) ]]; then +if [[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]]; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q From 0237617ba2bf9e31ef7ab9296e767e62a1496647 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 05:56:59 -0600 Subject: [PATCH 156/823] var name --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index f04acab5..042d0d0c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -28,7 +28,7 @@ if [[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]]; then # Now exit this old instance exit -elif [[ $self_update == "true" ]]; then +elif [[ $self_updated == "true" ]]; then echo -e "HeavyScript has been updated\n" else echo -e "HeavyScript is already the latest version\n" @@ -393,7 +393,7 @@ do deleteBackup="true" ;; updated) - self_update="true" + self_updated="true" ;; *) echo -e "Invalid Option \"--$OPTARG\"\n" && help From 8d410dfb2e48390a76f11dd37220c7e497c7508b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 05:59:54 -0600 Subject: [PATCH 157/823] null change --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 042d0d0c..078b570c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -36,6 +36,7 @@ fi } + help(){ [[ $help == "true" ]] && clear -x echo "Basic Utilities" From 9468664baec6684b231d5bc25808bd1023afac52 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 06:04:16 -0600 Subject: [PATCH 158/823] test --- heavy_script.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 078b570c..6baba984 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -28,8 +28,6 @@ if [[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]]; then # Now exit this old instance exit -elif [[ $self_updated == "true" ]]; then - echo -e "HeavyScript has been updated\n" else echo -e "HeavyScript is already the latest version\n" fi @@ -462,6 +460,7 @@ done #Continue to call functions in specific order [[ "$help" == "true" ]] && help +[[ $self_updated == "true" ]] && echo -e "HeavyScript has been updated\n" [[ "$self_update" == "true" ]] && self_update [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit From e6966744861c680677ebf2829fba4543ad78c4bf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 06:16:33 -0600 Subject: [PATCH 159/823] self update + regex fixes --- heavy_script.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 3da300dd..4ef4d342 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -12,7 +12,7 @@ SCRIPTNAME="$0" cd $SCRIPTPATH git fetch &> /dev/null -[[ -n $(git diff --name-only origin/main | grep $SCRIPTNAME) ]] && { +if git diff --name-only origin/main | grep -q $SCRIPTNAME ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q @@ -20,7 +20,7 @@ git fetch &> /dev/null count=0 for i in "${args[@]}" do - [[ "$i" == "--self-update" ]] && unset "args[$count]" && break + [[ "$i" == "--self-update" ]] && unset "args[$count]" && args+=("--updated") && break ((count++)) done sleep 5 @@ -28,11 +28,13 @@ git fetch &> /dev/null # Now exit this old instance exit - } - echo -e "HeavyScript is already the latest version.\n" +else + echo -e "HeavyScript is already the latest version\n" +fi } + help(){ [[ $help == "true" ]] && clear -x echo "Basic Utilities" @@ -217,7 +219,7 @@ export -f sync update_apps(){ -mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|$)" | sort) +mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|\b)" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" @@ -389,6 +391,9 @@ do delete-backup) deleteBackup="true" ;; + updated) + self_updated="true" + ;; *) echo -e "Invalid Option \"--$OPTARG\"\n" && help exit @@ -455,6 +460,7 @@ done #Continue to call functions in specific order [[ "$help" == "true" ]] && help +[[ $self_updated == "true" ]] && echo -e "HeavyScript has been updated\n" [[ "$self_update" == "true" ]] && self_update [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit From 2b8a4f1593ecc76d32bc83979106ea262eb2f727 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 06:18:58 -0600 Subject: [PATCH 160/823] remove whitespace --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 4ef4d342..ab1282c4 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -34,7 +34,6 @@ fi } - help(){ [[ $help == "true" ]] && clear -x echo "Basic Utilities" From 31c1c7cd9b1d6a47d244a3a3c80e972bcf4fd357 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 06:20:40 -0600 Subject: [PATCH 161/823] quoting var --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index ab1282c4..f19bb3f5 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -459,7 +459,7 @@ done #Continue to call functions in specific order [[ "$help" == "true" ]] && help -[[ $self_updated == "true" ]] && echo -e "HeavyScript has been updated\n" +[[ "$self_updated" == "true" ]] && echo -e "HeavyScript has been updated\n" [[ "$self_update" == "true" ]] && self_update [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit From 9241f27c2d9c91522e849c8ce0731c31be6f8162 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 06:29:29 -0600 Subject: [PATCH 162/823] quoting --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index f19bb3f5..71827226 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -12,7 +12,7 @@ SCRIPTNAME="$0" cd $SCRIPTPATH git fetch &> /dev/null -if git diff --name-only origin/main | grep -q $SCRIPTNAME ; then +if git diff --name-only origin/main | grep -q "$SCRIPTNAME" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q From d3fe6a6954a6645aad954f1c9a53ac276ccef508 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 06:35:32 -0600 Subject: [PATCH 163/823] fix self update --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 71827226..42539763 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -8,7 +8,7 @@ args=("$@") self_update() { SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") -SCRIPTNAME="$0" +SCRIPTNAME="heavy_script.sh" cd $SCRIPTPATH git fetch &> /dev/null From 3eb9a1a28c8f4e8a76fbcec4f5ee8e09e6b80264 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 06:38:51 -0600 Subject: [PATCH 164/823] self update fixes --- heavy_script.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 42539763..f35243d8 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -6,13 +6,13 @@ args=("$@") self_update() { -SCRIPT=$(readlink -f "$0") -SCRIPTPATH=$(dirname "$SCRIPT") -SCRIPTNAME="heavy_script.sh" -cd $SCRIPTPATH +script=$(readlink -f "$0") +script_path=$(dirname "$script") +script_name="heavy_script.sh" +cd "$script_path" || exit git fetch &> /dev/null -if git diff --name-only origin/main | grep -q "$SCRIPTNAME" ; then +if git diff --name-only origin/main | grep -q "$script_name" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q @@ -24,7 +24,7 @@ if git diff --name-only origin/main | grep -q "$SCRIPTNAME" ; then ((count++)) done sleep 5 - exec bash "$SCRIPTNAME" "${args[@]}" + exec bash "$script_name" "${args[@]}" # Now exit this old instance exit From 36f0c0b485675e5fb939737af106c95ef5c56c4e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 06:45:22 -0600 Subject: [PATCH 165/823] remove updated --- heavy_script.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index f35243d8..1a3dcf2c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -20,7 +20,7 @@ if git diff --name-only origin/main | grep -q "$script_name" ; then count=0 for i in "${args[@]}" do - [[ "$i" == "--self-update" ]] && unset "args[$count]" && args+=("--updated") && break + [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done sleep 5 @@ -390,9 +390,6 @@ do delete-backup) deleteBackup="true" ;; - updated) - self_updated="true" - ;; *) echo -e "Invalid Option \"--$OPTARG\"\n" && help exit @@ -459,7 +456,6 @@ done #Continue to call functions in specific order [[ "$help" == "true" ]] && help -[[ "$self_updated" == "true" ]] && echo -e "HeavyScript has been updated\n" [[ "$self_update" == "true" ]] && self_update [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit From 264fda6d121979552b62e91bf3f229bc9af76b91 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 06:52:09 -0600 Subject: [PATCH 166/823] force change --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 1a3dcf2c..8d38d6bf 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -464,4 +464,4 @@ done [[ "$number_of_backups" -ge 1 ]] && backup [[ "$sync" == "true" ]] && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && update_apps -[[ "$prune" == "true" ]] && prune +[[ "$prune" == "true" ]] && prune \ No newline at end of file From 319f65d7d65e49379a31565b45753b4725cc8225 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 07:28:15 -0600 Subject: [PATCH 167/823] todo --- heavy_script.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heavy_script.sh b/heavy_script.sh index 8d38d6bf..8f38bfad 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -218,6 +218,8 @@ export -f sync update_apps(){ +# Replace with line below after testing +# cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|\b)" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" From 1af355a8f6fa112210f576cc736c4b235291eac3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 19:15:56 -0600 Subject: [PATCH 168/823] bring in changes from stable --- heavy_script.sh | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 176a0582..8f38bfad 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,34 +3,34 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -echo "yep" - args=("$@") self_update() { -SCRIPT=$(readlink -f "$0") -SCRIPTPATH=$(dirname "$SCRIPT") -SCRIPTNAME="$0" -cd $SCRIPTPATH +script=$(readlink -f "$0") +script_path=$(dirname "$script") +script_name="heavy_script.sh" +cd "$script_path" || exit git fetch &> /dev/null -[[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]] && { +if git diff --name-only origin/main | grep -q "$script_name" ; then echo "Found a new version of HeavyScript, updating myself..." - git pull --force &> /dev/null + git reset --hard -q + git pull --force -q echo -e "Running the new version...\n" count=0 for i in "${args[@]}" do - [[ "$i" == "--self-update" ]] && unset "args[$count]" && break - ((count++)) + [[ "$i" == "--self-update" ]] && unset "args[$count]" && break + ((count++)) done sleep 5 - exec bash "$SCRIPTNAME" "${args[@]}" + exec bash "$script_name" "${args[@]}" # Now exit this old instance - exit 1 - } - echo -e "Already the latest version.\n" + exit +else + echo -e "HeavyScript is already the latest version\n" +fi } @@ -59,7 +59,7 @@ echo "Examples" echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" -echo "bash /mnt/tank/scripts/heavy_script.sh --restore" +echo "bash heavy_script.sh --restore" echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" echo exit @@ -218,7 +218,9 @@ export -f sync update_apps(){ -mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|$)" | sort) +# Replace with line below after testing +# cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort +mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|\b)" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" @@ -269,7 +271,7 @@ do else #user must not be using -S, just update echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || { echo "FAILED"; continue; } + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" fi else echo -e "\n$app_name\nMajor Release, update manually" @@ -372,10 +374,10 @@ do case $opt in -) case "${OPTARG}" in - help) + help) help="true" ;; - self-update) + self-update) self_update="true" ;; dns) @@ -455,8 +457,8 @@ done [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit #Continue to call functions in specific order -[[ "$self_update" == "true" ]] && self_update [[ "$help" == "true" ]] && help +[[ "$self_update" == "true" ]] && self_update [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit From 8c762f436b8f3b0ea74cd3ca0e9d529931112ec0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 19:22:10 -0600 Subject: [PATCH 169/823] update to stable --- heavy_script.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 41a001f4..8f38bfad 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -34,7 +34,6 @@ fi } - help(){ [[ $help == "true" ]] && clear -x echo "Basic Utilities" @@ -393,9 +392,6 @@ do delete-backup) deleteBackup="true" ;; - updated) - self_updated="true" - ;; *) echo -e "Invalid Option \"--$OPTARG\"\n" && help exit @@ -470,4 +466,4 @@ done [[ "$number_of_backups" -ge 1 ]] && backup [[ "$sync" == "true" ]] && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && update_apps -[[ "$prune" == "true" ]] && prune +[[ "$prune" == "true" ]] && prune \ No newline at end of file From 34de2750d8b7a7149911d96ab97f634b9a389cd8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 20:29:58 -0600 Subject: [PATCH 170/823] refactor --- functions/backup.sh | 74 ++++++++ functions/dns.sh | 27 +++ functions/misc.sh | 57 ++++++ functions/mount.sh | 63 +++++++ functions/self_update.sh | 32 ++++ functions/update_apps.sh | 132 ++++++++++++++ heavy_script.sh | 374 ++------------------------------------- 7 files changed, 397 insertions(+), 362 deletions(-) create mode 100644 functions/backup.sh create mode 100644 functions/dns.sh create mode 100644 functions/misc.sh create mode 100644 functions/mount.sh create mode 100644 functions/self_update.sh create mode 100644 functions/update_apps.sh diff --git a/functions/backup.sh b/functions/backup.sh new file mode 100644 index 00000000..a4684ca1 --- /dev/null +++ b/functions/backup.sh @@ -0,0 +1,74 @@ +#!/bin/bash + + +backup(){ +echo -e "\nNumber of backups was set to $number_of_backups" +date=$(date '+%Y_%m_%d_%H_%M_%S') +[[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' +[[ -z "$verbose" ]] && echo -e "\nNew Backup Name:" && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 +mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") +if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then + echo -e "\nDeleting the oldest backup(s) for exceeding limit:" + overflow=$(( ${#list_backups[@]} - "$number_of_backups" )) + mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") + for i in "${list_overflow[@]}" + do + cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo "Failed to delete $i" + echo "$i" + done +fi +} +export -f backup + + + +deleteBackup(){ +clear -x && echo "pulling all restore points.." +list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) +clear -x +[[ -z "$list_backups" ]] && echo "No restore points available" && exit +title +echo -e "Choose a restore point to delete\nThese may be out of order if they are not all HeavyScript backups" +echo "$list_backups" +read -pr -t 600 "Please type a number: " selection +restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') +if [[ -z "$selection" ]]; then #Check for valid selection. If none, kill script + echo "Your selection cannot be empty" + exit +elif [[ -z "$restore_point" ]]; then #Check for valid selection. If none, kill script + echo "Invalid Selection: $selection, was not an option" + exit +fi +echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" +echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" +read -rp -t 120 "Please type a number: " yesno || { echo "Failed to make a valid selection"; exit; } +if [[ $yesno == "1" ]]; then + echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo "Sucessfully deleted" || echo "Deletion Failed" +elif [[ $yesno == "2" ]]; then + echo "You've chosen NO, killing script." +else + echo "Invalid Selection" +fi +} +export -f deleteBackup + + +restore(){ +clear -x && echo "pulling restore points.." +list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) +clear -x +[[ -z "$list_backups" ]] && echo "No HeavyScript restore points available" && exit || { title; echo "Choose a restore point" ; } +echo "$list_backups" && read -t 600 -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') +[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script +[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script +echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" || { echo "FAILED"; exit; } +echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -t 120 -p "Please type a number: " yesno || { echo "FAILED"; exit; } +if [[ $yesno == "1" ]]; then + echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" +elif [[ $yesno == "2" ]]; then + echo "You've chosen NO, killing script. Good luck." +else + echo "Invalid Selection" +fi +} +export -f restore \ No newline at end of file diff --git a/functions/dns.sh b/functions/dns.sh new file mode 100644 index 00000000..c4316139 --- /dev/null +++ b/functions/dns.sh @@ -0,0 +1,27 @@ +#!/bin/bash + + +dns(){ +clear -x +echo "Generating DNS Names.." +#ignored dependency pods, may need to add more in the future. +dep_ignore="\-cronjob\-|^kube-system|\ssvclb|NAME|\-memcached\-.[^custom\-app]|\-postgresql\-.[^custom\-app]|\-redis\-.[^custom\-app]|\-mariadb\-.[^custom\-app]|\-promtail\-.[^custom\-app]" + +# Pulling pod names +mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$dep_ignore" | sort) + +# Pulling all ports +all_ports=$(k3s kubectl get service -A) + +clear -x +count=0 +for i in "${main[@]}" +do + [[ count -le 0 ]] && echo -e "\n" && ((count++)) + appName=$(echo "$i" | awk '{print $2}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//') + ixName=$(echo "$i" | awk '{print $1}') + port=$(echo "$all_ports" | grep -E "\s$appName\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}") + echo -e "$appName.$ixName.svc.cluster.local $port" +done | uniq | nl -b t | sed 's/\s\s\s$/- -------- ----/' | column -t -R 1 -N "#,DNS_Name,Port" -L +} +export -f dns \ No newline at end of file diff --git a/functions/misc.sh b/functions/misc.sh new file mode 100644 index 00000000..f854381b --- /dev/null +++ b/functions/misc.sh @@ -0,0 +1,57 @@ +#!/bin/bash + + +sync(){ +echo -e "\nSyncing all catalogs, please wait.." && cli -c 'app catalog sync_all' &> /dev/null && echo -e "Catalog sync complete" +} +export -f sync + +prune(){ +echo -e "\nPruning Docker Images" && docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" +} +export -f prune + +title(){ +echo ' _ _ _____ _ _ ' +echo '| | | | / ___| (_) | | ' +echo '| |_| | ___ __ ___ ___ _\ `--. ___ _ __ _ _ __ | |_' +echo "| _ |/ _ \/ _\` \ \ / / | | |\`--. \/ __| '__| | '_ \| __|" +echo '| | | | __/ (_| |\ V /| |_| /\__/ / (__| | | | |_) | |_ ' +echo '\_| |_/\___|\__,_| \_/ \__, \____/ \___|_| |_| .__/ \__|' +echo ' __/ | | | ' +echo ' |___/ |_| ' +echo +} +export -f title + +help(){ +[[ $help == "true" ]] && clear -x +echo "Basic Utilities" +echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" +echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset" +echo "--delete-backup | Opens a menu to delete backups on your system" +echo "--dns | list all of your applications DNS names and their web ports" +echo +echo "Update Options" +echo "-U | Update all applications, ignores versions" +echo "-u | Update all applications, does not update Major releases" +echo "-b | Back-up your ix-applications dataset, specify a number after -b" +echo "-i | Add application to ignore list, one by one, see example below." +echo "-R | THIS OPTION WILL DEPRICATE SOON, USE \"-r\" instead. Roll-back applications if they fail to update" +echo "-r | Roll-back applications if they fail to update" +echo "-S | Shutdown applications prior to updating" +echo "-v | verbose output" +echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" +echo "-s | sync catalog" +echo "-p | Prune unused/old docker images" +echo +echo "Examples" +echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" +echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" +echo "bash /mnt/tank/scripts/heavy_script.sh --dns" +echo "bash heavy_script.sh --restore" +echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" +echo +exit +} +export -f help \ No newline at end of file diff --git a/functions/mount.sh b/functions/mount.sh new file mode 100644 index 00000000..88d9af21 --- /dev/null +++ b/functions/mount.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +mount(){ +clear -x +title +echo -e "1 Mount\n2 Unmount All" && read -t 600 -p "Please type a number: " selection +[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script +if [[ $selection == "1" ]]; then + list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + echo "$list" && read -t 120 -p "Please type a number: " selection + [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script + app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script + pvc=$(echo -e "$list" | grep ^"$selection ") + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + if [[ "$status" != "STOPPED" ]]; then + [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" + SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null + else + echo -e "\n$app is already stopped" + fi + while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] + do + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 + done + data_name=$(echo "$pvc" | awk '{print $3}') + mount=$(echo "$pvc" | awk '{print $4}') + volume_name=$(echo "$pvc" | awk '{print $4}') + mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') + if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + echo "$app is a name used on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') + fi + echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" + zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" + echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" + exit +elif [[ $selection == "2" ]]; then + mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") + [[ -z $unmount_array ]] && echo "Theres nothing to unmount" && exit + for i in "${unmount_array[@]}" + do + main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') + app=$(echo "$main" | awk '{print $1}' | cut -c 4-) + pvc=$(echo "$main" | awk '{print $3}') + mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + else + zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + fi + done + rmdir /mnt/heavyscript +else + echo "Invalid selection, \"$selection\" was not an option" +fi +} +export -f mount \ No newline at end of file diff --git a/functions/self_update.sh b/functions/self_update.sh new file mode 100644 index 00000000..340d5a5d --- /dev/null +++ b/functions/self_update.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +args=("$@") + +self_update() { +script=$(readlink -f "$0") +script_path=$(dirname "$script") +script_name="heavy_script.sh" +cd "$script_path" || exit +git fetch &> /dev/null + +if git diff --name-only origin/main | grep -q "$script_name" ; then + echo "Found a new version of HeavyScript, updating myself..." + git reset --hard -q + git pull --force -q + echo -e "Running the new version...\n" + count=0 + for i in "${args[@]}" + do + [[ "$i" == "--self-update" ]] && unset "args[$count]" && break + ((count++)) + done + sleep 5 + exec bash "$script_name" "${args[@]}" + + # Now exit this old instance + exit +else + echo -e "HeavyScript is already the latest version\n" +fi +} +export -f self_update \ No newline at end of file diff --git a/functions/update_apps.sh b/functions/update_apps.sh new file mode 100644 index 00000000..a406e46d --- /dev/null +++ b/functions/update_apps.sh @@ -0,0 +1,132 @@ +#!/bin/bash + + +update_apps(){ +# Replace with line below after testing +# cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort +mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|\b)" | sort) +[[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" +[[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" +[[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" +for i in "${array[@]}" +do + app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. + old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version + new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version + old_chart_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version + new_chart_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version + status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE + startstatus=$status + diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions + diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions + old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From + new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To + rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') + printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && continue #If application is on ignore list, skip + if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update + if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not + if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop + echo -e "\n$app_name" + [[ "$verbose" == "true" ]] && echo "Updating.." + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" + continue + else # if status was not STOPPED, stop the app prior to updating + echo -e "\n$app_name" + [[ "$verbose" == "true" ]] && echo "Stopping prior to update.." + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" + while [[ "$status" != "STOPPED" ]] + do + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + if [[ "$status" == "STOPPED" ]]; then + echo "Stopped" + [[ "$verbose" == "true" ]] && echo "Updating.." + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "Failed to update" + break + elif [[ "$SECONDS" -ge "$timeout" ]]; then + echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" + break + elif [[ "$status" != "STOPPED" ]]; then + [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED" + sleep 10 + continue + fi + done + fi + else #user must not be using -S, just update + echo -e "\n$app_name" + [[ "$verbose" == "true" ]] && echo "Updating.." + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" + fi + else + echo -e "\n$app_name\nMajor Release, update manually" + continue + fi +done +} +export -f update_apps + + +after_update_actions(){ +SECONDS=0 +count=0 +if [[ $rollback == "true" ]]; then + while true + do + (( count++ )) + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then + [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" + break + elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" != "true" ]]; then + echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update.." + midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null + [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update + break + elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" == "true" ]]; then + echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning" + break + elif [[ "$status" == "STOPPED" ]]; then + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + echo "Stopped" && break #if reports stopped any time after the first loop, assume its extermal services. + elif [[ "$status" == "ACTIVE" ]]; then + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check + echo "Active" && break #if reports active any time after the first loop, assume actually active. + else + [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" + sleep 15 + continue + fi + done +else + if [[ "$startstatus" == "STOPPED" ]]; then + while true #using a constant while loop, then breaking out of the loop with break commands below. + do + (( count++ )) + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + if [[ "$status" == "STOPPED" ]]; then + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + echo "Stopped" && break #assume actually stopped anytime AFTER the first loop + break + elif [[ "$status" == "ACTIVE" ]]; then + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" + break + elif [[ "$SECONDS" -ge "$timeout" ]]; then + echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" + break + else + [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" + sleep 10 + continue + fi + done + fi +fi +} +export -f after_update_actions \ No newline at end of file diff --git a/heavy_script.sh b/heavy_script.sh index 8f38bfad..90eb0575 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,369 +3,19 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -args=("$@") -self_update() { -script=$(readlink -f "$0") -script_path=$(dirname "$script") -script_name="heavy_script.sh" -cd "$script_path" || exit -git fetch &> /dev/null - -if git diff --name-only origin/main | grep -q "$script_name" ; then - echo "Found a new version of HeavyScript, updating myself..." - git reset --hard -q - git pull --force -q - echo -e "Running the new version...\n" - count=0 - for i in "${args[@]}" - do - [[ "$i" == "--self-update" ]] && unset "args[$count]" && break - ((count++)) - done - sleep 5 - exec bash "$script_name" "${args[@]}" - - # Now exit this old instance - exit -else - echo -e "HeavyScript is already the latest version\n" -fi -} - - -help(){ -[[ $help == "true" ]] && clear -x -echo "Basic Utilities" -echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" -echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset" -echo "--delete-backup | Opens a menu to delete backups on your system" -echo "--dns | list all of your applications DNS names and their web ports" -echo -echo "Update Options" -echo "-U | Update all applications, ignores versions" -echo "-u | Update all applications, does not update Major releases" -echo "-b | Back-up your ix-applications dataset, specify a number after -b" -echo "-i | Add application to ignore list, one by one, see example below." -echo "-R | THIS OPTION WILL DEPRICATE SOON, USE \"-r\" instead. Roll-back applications if they fail to update" -echo "-r | Roll-back applications if they fail to update" -echo "-S | Shutdown applications prior to updating" -echo "-v | verbose output" -echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" -echo "-s | sync catalog" -echo "-p | Prune unused/old docker images" -echo -echo "Examples" -echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" -echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" -echo "bash /mnt/tank/scripts/heavy_script.sh --dns" -echo "bash heavy_script.sh --restore" -echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" -echo -exit -} -export -f help - - -deleteBackup(){ -clear -x && echo "pulling all restore points.." -list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) -clear -x -[[ -z "$list_backups" ]] && echo "No restore points available" && exit || { title; echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" ; } -echo "$list_backups" && read -t 600 -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') -[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script -echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" || { echo "FAILED"; exit; } -echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -t 120 -p "Please type a number: " yesno || { echo "FAILED"; exit; } -if [[ $yesno == "1" ]]; then - echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo "Sucessfully deleted" || echo "Deletion Failed" -elif [[ $yesno == "2" ]]; then - echo "You've chosen NO, killing script." -else - echo "Invalid Selection" -fi -} -export -f deleteBackup - - -backup(){ -echo -e "\nNumber of backups was set to $number_of_backups" -date=$(date '+%Y_%m_%d_%H_%M_%S') -[[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' -[[ -z "$verbose" ]] && echo -e "\nNew Backup Name:" && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 -mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") -if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then - echo -e "\nDeleting the oldest backup(s) for exceeding limit:" - overflow=$(( ${#list_backups[@]} - "$number_of_backups" )) - mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") - for i in "${list_overflow[@]}" - do - cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo "Failed to delete $i" - echo "$i" - done -fi -} -export -f backup - - -restore(){ -clear -x && echo "pulling restore points.." -list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) -clear -x -[[ -z "$list_backups" ]] && echo "No HeavyScript restore points available" && exit || { title; echo "Choose a restore point" ; } -echo "$list_backups" && read -t 600 -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') -[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script -echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" || { echo "FAILED"; exit; } -echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -t 120 -p "Please type a number: " yesno || { echo "FAILED"; exit; } -if [[ $yesno == "1" ]]; then - echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" -elif [[ $yesno == "2" ]]; then - echo "You've chosen NO, killing script. Good luck." -else - echo "Invalid Selection" -fi -} -export -f restore - - -dns(){ -clear -x -echo "Generating DNS Names.." -#ignored dependency pods, may need to add more in the future. -dep_ignore="\-cronjob\-|^kube-system|\ssvclb|NAME|\-memcached\-.[^custom\-app]|\-postgresql\-.[^custom\-app]|\-redis\-.[^custom\-app]|\-mariadb\-.[^custom\-app]|\-promtail\-.[^custom\-app]" - -# Pulling pod names -mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$dep_ignore" | sort) - -# Pulling all ports -all_ports=$(k3s kubectl get service -A) - -clear -x -count=0 -for i in "${main[@]}" -do - [[ count -le 0 ]] && echo -e "\n" && ((count++)) - appName=$(echo "$i" | awk '{print $2}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//') - ixName=$(echo "$i" | awk '{print $1}') - port=$(echo "$all_ports" | grep -E "\s$appName\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}") - echo -e "$appName.$ixName.svc.cluster.local $port" -done | uniq | nl -b t | sed 's/\s\s\s$/- -------- ----/' | column -t -R 1 -N "#,DNS_Name,Port" -L -} -export -f dns - - -mount(){ -clear -x -title -echo -e "1 Mount\n2 Unmount All" && read -t 600 -p "Please type a number: " selection -[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -if [[ $selection == "1" ]]; then - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") - echo "$list" && read -t 120 -p "Please type a number: " selection - [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script - app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script - pvc=$(echo -e "$list" | grep ^"$selection ") - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - if [[ "$status" != "STOPPED" ]]; then - [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" - SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null - else - echo -e "\n$app is already stopped" - fi - while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] - do - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 - done - data_name=$(echo "$pvc" | awk '{print $3}') - mount=$(echo "$pvc" | awk '{print $4}') - volume_name=$(echo "$pvc" | awk '{print $4}') - full_path=$(zfs list | grep "$volume_name" | awk '{print $1}') - echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" && zfs set mountpoint=/heavyscript/"$data_name" "$full_path" && echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy "$full_path" && rmdir /mnt/heavyscript/"$data_name"\n\nOr use the Unmount All option\n" - exit -elif [[ $selection == "2" ]]; then - mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") - [[ -z $unmount_array ]] && echo "Theres nothing to unmount" && exit - for i in "${unmount_array[@]}" - do - main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') - app=$(echo "$main" | awk '{print $1}' | cut -c 4-) - pvc=$(echo "$main" | awk '{print $3}') - mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused. - echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" - else - zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" - fi - done - rmdir /mnt/heavyscript -else - echo "Invalid selection, \"$selection\" was not an option" -fi -} -export -f mount - - -sync(){ -echo -e "\nSyncing all catalogs, please wait.." && cli -c 'app catalog sync_all' &> /dev/null && echo -e "Catalog sync complete" -} -export -f sync - - -update_apps(){ -# Replace with line below after testing -# cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort -mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|\b)" | sort) -[[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" -[[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" -[[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -for i in "${array[@]}" -do - app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. - old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version - new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version - old_chart_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version - new_chart_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version - status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE - startstatus=$status - diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions - diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions - old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From - new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To - rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') - printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && continue #If application is on ignore list, skip - if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update - if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not - if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" - continue - else # if status was not STOPPED, stop the app prior to updating - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Stopping prior to update.." - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" - while [[ "$status" != "STOPPED" ]] - do - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') - if [[ "$status" == "STOPPED" ]]; then - echo "Stopped" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "Failed to update" - break - elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" - break - elif [[ "$status" != "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED" - sleep 10 - continue - fi - done - fi - else #user must not be using -S, just update - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" - fi - else - echo -e "\n$app_name\nMajor Release, update manually" - continue - fi -done -} -export -f update_apps - - -after_update_actions(){ -SECONDS=0 -count=0 -if [[ $rollback == "true" ]]; then - while [[ "0" != "1" ]] - do - (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') - if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" - break - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" != "true" ]]; then - echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update.." - midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null - [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update - break - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" == "true" ]]; then - echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning" - break - elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - echo "Stopped" && break #if reports stopped any time after the first loop, assume its extermal services. - elif [[ "$status" == "ACTIVE" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - echo "Active" && break #if reports active any time after the first loop, assume actually active. - else - [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" - sleep 15 - continue - fi - done -else - if [[ "$startstatus" == "STOPPED" ]]; then - while [[ "0" != "1" ]] #using a constant while loop, then breaking out of the loop with break commands below. - do - (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') - if [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - echo "Stopped" && break #assume actually stopped anytime AFTER the first loop - break - elif [[ "$status" == "ACTIVE" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" - break - elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" - break - else - [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" - sleep 10 - continue - fi - done - fi -fi -} -export -f after_update_actions - - -prune(){ -echo -e "\nPruning Docker Images" && docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" -} -export -f prune - - -title(){ -echo ' _ _ _____ _ _ ' -echo '| | | | / ___| (_) | | ' -echo '| |_| | ___ __ ___ ___ _\ `--. ___ _ __ _ _ __ | |_' -echo "| _ |/ _ \/ _\` \ \ / / | | |\`--. \/ __| '__| | '_ \| __|" -echo '| | | | __/ (_| |\ V /| |_| /\__/ / (__| | | | |_) | |_ ' -echo '\_| |_/\___|\__,_| \_/ \__, \____/ \___|_| |_| .__/ \__|' -echo ' __/ | | | ' -echo ' |___/ |_| ' -echo -} -export -f title +# shellcheck source=functions/backup.sh +source functions/backup.sh +# shellcheck source=functions/dns.sh +source functions/dns.sh +# shellcheck source=functions/misc.sh +source functions/misc.sh +# shellcheck source=functions/mount.sh +source functions/mount.sh +# shellcheck source=functions/self_update.sh +source functions/self_update.sh +# shellcheck source=functions/update_apps.sh +source functions/update_apps.sh # Parse script options From d7136fe270da807791f0fdf10312b422e48e0cc0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:03:57 -0600 Subject: [PATCH 171/823] test --- functions/update_apps.sh | 54 +++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a406e46d..dcce0351 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -1,35 +1,45 @@ #!/bin/bash -update_apps(){ -# Replace with line below after testing -# cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort -mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|\b)" | sort) +mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -for i in "${array[@]}" -do - app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. - old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version - new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version - old_chart_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version - new_chart_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version - status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE - startstatus=$status - diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions - diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions - old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From - new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To - rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') - printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && continue #If application is on ignore list, skip + +update_limit=5 +count=0 + for i in "${array[@]}" + do + update_apps "$i" & + (( count++ )) + while [[ "$count" -ge "$update_limit" ]] + do + wait + done + done + + +update_apps(){ +app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. +old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version +new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version +old_chart_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version +new_chart_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version +status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE +startstatus=$status +diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions +diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions +old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From +new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To +rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Updating.." cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" - continue + return else # if status was not STOPPED, stop the app prior to updating echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Stopping prior to update.." @@ -48,7 +58,6 @@ do elif [[ "$status" != "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED" sleep 10 - continue fi done fi @@ -59,9 +68,8 @@ do fi else echo -e "\n$app_name\nMajor Release, update manually" - continue + return fi -done } export -f update_apps From a0104e65e2f1aae45444c168f92af3a8b66aab9e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:07:24 -0600 Subject: [PATCH 172/823] waiting --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index dcce0351..dea780d6 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,6 +14,7 @@ count=0 (( count++ )) while [[ "$count" -ge "$update_limit" ]] do + echo "waiting for free space" wait done done From 63ec2b586adc3a585f9dc2d36600e1282cdf9605 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:11:04 -0600 Subject: [PATCH 173/823] commander func --- functions/update_apps.sh | 5 +++-- heavy_script.sh | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index dea780d6..e5691bce 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -1,6 +1,6 @@ #!/bin/bash - +commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" @@ -18,7 +18,8 @@ count=0 wait done done - +} +export -f commander update_apps(){ app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. diff --git a/heavy_script.sh b/heavy_script.sh index 90eb0575..905e50de 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -115,5 +115,5 @@ done [[ "$mount" == "true" ]] && mount && exit [[ "$number_of_backups" -ge 1 ]] && backup [[ "$sync" == "true" ]] && sync -[[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && update_apps +[[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander [[ "$prune" == "true" ]] && prune \ No newline at end of file From c60593da882782789c396e386d352627c6d607a9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:12:46 -0600 Subject: [PATCH 174/823] reset count --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e5691bce..8bf95187 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -16,6 +16,7 @@ count=0 do echo "waiting for free space" wait + count=0 done done } From 9079cf7a3318ca39e94778af44e1a664f609e370 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:19:14 -0600 Subject: [PATCH 175/823] return --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 8bf95187..8b4f3431 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -139,5 +139,6 @@ else done fi fi +return } export -f after_update_actions \ No newline at end of file From 1b89f902302038a39d4a763ec7d39aeef2d15bff Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:23:57 -0600 Subject: [PATCH 176/823] wait --- functions/update_apps.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 8b4f3431..5284beab 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -12,6 +12,7 @@ count=0 do update_apps "$i" & (( count++ )) + processes+=($!) while [[ "$count" -ge "$update_limit" ]] do echo "waiting for free space" @@ -19,6 +20,12 @@ count=0 count=0 done done + +for proc in "${processes[@]}" +do + wait "$proc" +done + } export -f commander From 5d17035dffb7c71b99cd8a6e333cd5b317cc39b1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:26:43 -0600 Subject: [PATCH 177/823] wait --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 5284beab..c28f9f55 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -16,7 +16,7 @@ count=0 while [[ "$count" -ge "$update_limit" ]] do echo "waiting for free space" - wait + wait -n "${processes[@]}" count=0 done done From bed013a5840c60dc964bc8ae3244a1082f2fba43 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:27:41 -0600 Subject: [PATCH 178/823] count --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index c28f9f55..b91cb9b6 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -17,7 +17,7 @@ count=0 do echo "waiting for free space" wait -n "${processes[@]}" - count=0 + (( count-- )) done done From 7268ae55949b971bac7818f932a04dd2435fb91b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:39:27 -0600 Subject: [PATCH 179/823] jobs --- functions/update_apps.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index b91cb9b6..d02ea7c5 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,9 +15,11 @@ count=0 processes+=($!) while [[ "$count" -ge "$update_limit" ]] do + jobs -p + pidcount=0 echo "waiting for free space" - wait -n "${processes[@]}" - (( count-- )) + wait -n "${processes[pidcount]}" && (( count-- )) + (( pidcount ++ )) done done From f2143d7330ca6e0fc74d6b71e0a547c628e41d72 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:39:53 -0600 Subject: [PATCH 180/823] jobs --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d02ea7c5..46d647db 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -13,6 +13,7 @@ count=0 update_apps "$i" & (( count++ )) processes+=($!) + jobs -p while [[ "$count" -ge "$update_limit" ]] do jobs -p From 9cf49ed6c32c656115435acfe6e8c28ec365f83e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:45:38 -0600 Subject: [PATCH 181/823] output supress --- functions/update_apps.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 46d647db..7af4f387 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -13,14 +13,10 @@ count=0 update_apps "$i" & (( count++ )) processes+=($!) - jobs -p while [[ "$count" -ge "$update_limit" ]] do - jobs -p - pidcount=0 echo "waiting for free space" - wait -n "${processes[pidcount]}" && (( count-- )) - (( pidcount ++ )) + wait -n "${processes[@]}" &> /dev/null && (( count-- )) done done From 4fe1589aef2d62ab4550d7fd1e253f8f8080bb58 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 23:12:15 -0600 Subject: [PATCH 182/823] proccount --- functions/update_apps.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 7af4f387..2c01edb0 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,12 +11,14 @@ count=0 for i in "${array[@]}" do update_apps "$i" & - (( count++ )) processes+=($!) - while [[ "$count" -ge "$update_limit" ]] + proc_count=0 + while [[ "${#processes[@]}" -ge "$update_limit" ]] do echo "waiting for free space" - wait -n "${processes[@]}" &> /dev/null && (( count-- )) + wait -n "${processes[$proc_count]}" &> /dev/null + (( proc_count++ )) + unset "processes[$proc_count]" done done From 9000d47a18af80d5f21519182643c8224e65238f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 23:34:20 -0600 Subject: [PATCH 183/823] revamp --- functions/update_apps.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2c01edb0..027d53d5 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -13,12 +13,14 @@ count=0 update_apps "$i" & processes+=($!) proc_count=0 + count=$(jobs -p | wc -l) while [[ "${#processes[@]}" -ge "$update_limit" ]] do - echo "waiting for free space" - wait -n "${processes[$proc_count]}" &> /dev/null - (( proc_count++ )) - unset "processes[$proc_count]" + for proc in "${processes[@]}" + do + kill -0 "$proc" || unset "processes[$proc_count]" + (( proc_count++ )) + done done done From c347a7c5f8dc84ace276af4ac3bfd0fa16bb3c09 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 23:35:03 -0600 Subject: [PATCH 184/823] lower app limit for test --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 027d53d5..ebd6aa51 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -6,7 +6,7 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -update_limit=5 +update_limit=2 count=0 for i in "${array[@]}" do From 7cd8de351af27118ecd65d1a301cc124c346d908 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 23:38:14 -0600 Subject: [PATCH 185/823] test --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ebd6aa51..f3e8d22d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -18,7 +18,7 @@ count=0 do for proc in "${processes[@]}" do - kill -0 "$proc" || unset "processes[$proc_count]" + kill -0 "$proc" || { unset "processes[$proc_count]"; break; } (( proc_count++ )) done done From b6ec4d4c67fd62bc8d72998147c5218f26859666 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 14:06:40 -0600 Subject: [PATCH 186/823] new method --- functions/update_apps.sh | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f3e8d22d..db857f38 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -7,20 +7,15 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" update_limit=2 -count=0 +current_updates=0 for i in "${array[@]}" do update_apps "$i" & + (( current_updates++ )) processes+=($!) - proc_count=0 - count=$(jobs -p | wc -l) - while [[ "${#processes[@]}" -ge "$update_limit" ]] + while [[ current_updates -ge "$update_limit" ]] do - for proc in "${processes[@]}" - do - kill -0 "$proc" || { unset "processes[$proc_count]"; break; } - (( proc_count++ )) - done + sleep 5 done done @@ -45,13 +40,14 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && (( current_updates-- )) && return #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Updating.." cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" + (( current_updates-- )) return else # if status was not STOPPED, stop the app prior to updating echo -e "\n$app_name" @@ -81,8 +77,10 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name fi else echo -e "\n$app_name\nMajor Release, update manually" + (( current_updates-- )) return fi +(( current_updates-- )) } export -f update_apps @@ -149,6 +147,5 @@ else done fi fi -return } export -f after_update_actions \ No newline at end of file From 96a412387ce703490d34f1ad8fbdbaef19957e37 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 14:10:57 -0600 Subject: [PATCH 187/823] uhh --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index db857f38..3d6b125b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -13,7 +13,7 @@ current_updates=0 update_apps "$i" & (( current_updates++ )) processes+=($!) - while [[ current_updates -ge "$update_limit" ]] + while [[ "$current_updates" -ge "$update_limit" ]] do sleep 5 done From 53a7048dc4e7270927db0193b13f4125266e2516 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 14:16:08 -0600 Subject: [PATCH 188/823] global --- functions/update_apps.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 3d6b125b..a4f3ff49 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -1,13 +1,14 @@ #!/bin/bash +current_updates=0 + commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" - update_limit=2 -current_updates=0 + for i in "${array[@]}" do update_apps "$i" & From 13a13cdbd7a796e22d32ccc3242821d92a83946a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 14:28:04 -0600 Subject: [PATCH 189/823] who knowws --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a4f3ff49..092609e4 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,7 +11,7 @@ update_limit=2 for i in "${array[@]}" do - update_apps "$i" & + update_apps "$i" && (( current_updates-- )) & (( current_updates++ )) processes+=($!) while [[ "$current_updates" -ge "$update_limit" ]] From a12ead1bef8742997e210c1110a3c213c5da0fcf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 14:42:57 -0600 Subject: [PATCH 190/823] huih --- functions/update_apps.sh | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 092609e4..28758d57 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -1,6 +1,5 @@ #!/bin/bash -current_updates=0 commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) @@ -8,17 +7,33 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" update_limit=2 +current_updates=0 - for i in "${array[@]}" - do - update_apps "$i" && (( current_updates-- )) & - (( current_updates++ )) - processes+=($!) - while [[ "$current_updates" -ge "$update_limit" ]] + +while true +do + if [[ current_updates -ge "$update_limit" ]]; then + sleep 5 + else + for i in "${array[@]}" do - sleep 5 + update_apps "$i" && (( current_updates-- )) & (( current_updates++ )) + processes+=($!) done - done + fi +done + + + + + + + + + + + + for proc in "${processes[@]}" do From 2d5987229be8813178de55cd41387a85a196b1a1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 14:45:43 -0600 Subject: [PATCH 191/823] test --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 28758d57..f013b78c 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -17,7 +17,7 @@ do else for i in "${array[@]}" do - update_apps "$i" && (( current_updates-- )) & (( current_updates++ )) + { update_apps "$i"; (( current_updates-- )) ;} & (( current_updates++ )) processes+=($!) done fi From 10cb46633b2839772a679aea3b303643024f7c89 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 15:02:47 -0600 Subject: [PATCH 192/823] while loop --- functions/update_apps.sh | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f013b78c..29770ad2 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,32 +9,22 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl update_limit=2 current_updates=0 - -while true +it=0 +while [[ $it -lt ${#array[@]} ]] do - if [[ current_updates -ge "$update_limit" ]]; then - sleep 5 + jobs=$(jobs -p | wc -l) + if [[ "$jobs" -ge "$update_limit" ]]; then + sleep 3 else - for i in "${array[@]}" - do - { update_apps "$i"; (( current_updates-- )) ;} & (( current_updates++ )) - processes+=($!) - done + update_apps "${#array[$it]}" & + processes+=($!) + ((it++)) fi done - - - - - - - - - for proc in "${processes[@]}" do wait "$proc" From f0e7624c51bbdd468a13131d8f691859aaf711e3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 15:06:18 -0600 Subject: [PATCH 193/823] whoops --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 29770ad2..b5cf1632 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -16,7 +16,7 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - update_apps "${#array[$it]}" & + update_apps "${array[$it]}" & processes+=($!) ((it++)) fi From 69875f8fda58ddb19cfa3aa7e1424471241d482e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 15:15:25 -0600 Subject: [PATCH 194/823] huh --- functions/update_apps.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index b5cf1632..6344be3b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -7,7 +7,6 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" update_limit=2 -current_updates=0 it=0 while [[ $it -lt ${#array[@]} ]] @@ -16,15 +15,14 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - update_apps "${array[$it]}" & + application="${array[$it]}" + update_apps "$application" & processes+=($!) ((it++)) fi done - - for proc in "${processes[@]}" do wait "$proc" From 26bfaf5306a8de5bb94bfaacfe282bf46c8e8667 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 15:17:35 -0600 Subject: [PATCH 195/823] update --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 6344be3b..6651e331 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,8 +15,7 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - application="${array[$it]}" - update_apps "$application" & + update_apps "${array[$it]}" & processes+=($!) ((it++)) fi @@ -32,6 +31,7 @@ done export -f commander update_apps(){ +i=${array[$it]} app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version From 36cc4c1143a08db3c4267a8ed6835943167a9cab Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 15:20:32 -0600 Subject: [PATCH 196/823] async --- functions/update_apps.sh | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 6651e331..6ff12b6f 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -31,27 +31,25 @@ done export -f commander update_apps(){ -i=${array[$it]} -app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. -old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version -new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version -old_chart_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version -new_chart_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version -status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE +app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. +old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version +new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version +old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version +new_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version +status=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE startstatus=$status diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions -old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From -new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To -rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && (( current_updates-- )) && return #If application is on ignore list, skip +old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From +new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To +rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Updating.." cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" - (( current_updates-- )) return else # if status was not STOPPED, stop the app prior to updating echo -e "\n$app_name" @@ -81,10 +79,8 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name fi else echo -e "\n$app_name\nMajor Release, update manually" - (( current_updates-- )) return fi -(( current_updates-- )) } export -f update_apps From 71dca98533faf4c21bb9b361ee48cdd4397256c0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 15:21:26 -0600 Subject: [PATCH 197/823] update limit --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 6ff12b6f..e0b813ba 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -6,7 +6,7 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -update_limit=2 +update_limit=4 it=0 while [[ $it -lt ${#array[@]} ]] From 0de879ef38f0bca88d77fe2f56b448fa70658fb7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 15:59:51 -0600 Subject: [PATCH 198/823] idk --- functions/update_apps.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e0b813ba..84221570 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,18 +15,20 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - update_apps "${array[$it]}" & + output=$(update_apps "${array[$it]}" &) processes+=($!) ((it++)) fi done - +echo "$output" for proc in "${processes[@]}" do wait "$proc" done + + } export -f commander From 8f3b9e99228499fc9905866cb148d0ab51832b52 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:04:43 -0600 Subject: [PATCH 199/823] array? --- functions/update_apps.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 84221570..bdf438e0 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,12 +15,16 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - output=$(update_apps "${array[$it]}" &) + mapfile -t output < <(update_apps "${array[$it]}" &) processes+=($!) ((it++)) fi done -echo "$output" + +for i in "${output[@]}" +do + echo "$i" +done for proc in "${processes[@]}" do From 017edabaf0a0f0184cd3d5236d9f39fbd5f213df Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:05:37 -0600 Subject: [PATCH 200/823] wait for processes first --- functions/update_apps.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index bdf438e0..8fb9a588 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -21,15 +21,17 @@ do fi done +for proc in "${processes[@]}" +do + wait "$proc" +done + + for i in "${output[@]}" do echo "$i" done -for proc in "${processes[@]}" -do - wait "$proc" -done From a8d26c072ee878ea7cc6421d4579682c0fca4d7c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:08:05 -0600 Subject: [PATCH 201/823] hmm --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 8fb9a588..d3239c49 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,7 +15,7 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - mapfile -t output < <(update_apps "${array[$it]}" &) + mapfile -t output < <(update_apps "${array[$it]}") & processes+=($!) ((it++)) fi From b499b87dc177f0734d540f9dbb40e9deb6639001 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:23:50 -0600 Subject: [PATCH 202/823] uh --- functions/update_apps.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d3239c49..a97238ff 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,7 +15,7 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - mapfile -t output < <(update_apps "${array[$it]}") & + coproc update_appsfd { update_apps "${array[$it]}" ; } processes+=($!) ((it++)) fi @@ -26,13 +26,9 @@ do wait "$proc" done +IFS= read -r -d '' -u "${update_appsfd[0]}" update_output -for i in "${output[@]}" -do - echo "$i" -done - - +echo "$update_output" } From 749b591c46070ae63c583ac3fa09b9749a9c7797 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:46:05 -0600 Subject: [PATCH 203/823] test --- functions/update_apps.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a97238ff..23a8eee2 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,13 +9,14 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl update_limit=4 it=0 + while [[ $it -lt ${#array[@]} ]] do jobs=$(jobs -p | wc -l) if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - coproc update_appsfd { update_apps "${array[$it]}" ; } + update_apps "${array[$it]}" processes+=($!) ((it++)) fi @@ -26,10 +27,6 @@ do wait "$proc" done -IFS= read -r -d '' -u "${update_appsfd[0]}" update_output - -echo "$update_output" - } export -f commander @@ -85,7 +82,7 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name echo -e "\n$app_name\nMajor Release, update manually" return fi -} +} | sort export -f update_apps From 143326d0cb5152b649048c54ff88007c64454fa0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:48:17 -0600 Subject: [PATCH 204/823] asdf --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 23a8eee2..2544c030 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -16,7 +16,7 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - update_apps "${array[$it]}" + update_apps "${array[$it]}" & processes+=($!) ((it++)) fi From 0bc4d50e777c94e7390f121c312ef6d86379e159 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:50:44 -0600 Subject: [PATCH 205/823] append output to array --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2544c030..dd6d80fd 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -44,7 +44,7 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo_array+=(echo -e "\n$app_name\nIgnored, skipping") && return #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop @@ -82,7 +82,7 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name echo -e "\n$app_name\nMajor Release, update manually" return fi -} | sort +} export -f update_apps From 394486c7a32e5bc541a6436ceb3dced8b3b8b5a7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:52:51 -0600 Subject: [PATCH 206/823] dump array --- functions/update_apps.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index dd6d80fd..476078f1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -82,6 +82,13 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo_array+=(echo -e echo -e "\n$app_name\nMajor Release, update manually" return fi + +#dump array +for i in "${echo_array[@]}" +do + echo "$i" +done + } export -f update_apps From 015f0df2c121a32c0bf3588006668796e4ebf76e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:56:40 -0600 Subject: [PATCH 207/823] array --- functions/update_apps.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 476078f1..93ae1598 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -44,42 +44,42 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo_array+=(echo -e "\n$app_name\nIgnored, skipping") && return #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" + echo_array+=(echo -e "\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=(echo "Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=(echo -e "Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=(echo "FAILED") return else # if status was not STOPPED, stop the app prior to updating - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Stopping prior to update.." - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" + echo_array+=(echo -e "\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=(echo "Stopping prior to update..") + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=(echo -e "FAILED") while [[ "$status" != "STOPPED" ]] do status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then - echo "Stopped" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "Failed to update" + echo_array+=(echo "Stopped") + [[ "$verbose" == "true" ]] && echo_array+=(echo "Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=(echo -e "Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "Failed to update" break elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" + echo_array+=(echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)") break elif [[ "$status" != "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED" + [[ "$verbose" == "true" ]] && echo_array+=(echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED") sleep 10 fi done fi else #user must not be using -S, just update - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" + echo_array+=(echo -e "\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=(echo "Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=(echo -e "Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "FAILED" fi else - echo -e "\n$app_name\nMajor Release, update manually" + echo_array+=(echo -e "\n$app_name\nMajor Release, update manually") return fi From 337c6faa9e3e10408e1c240571f119385e48ea39 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:57:56 -0600 Subject: [PATCH 208/823] huh --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 93ae1598..a69ddfe7 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -86,7 +86,7 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name #dump array for i in "${echo_array[@]}" do - echo "$i" + echo -e "$i" done } From 25236e8b15c2e955915415a04ea4dbd5db4b7ec2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 17:06:59 -0600 Subject: [PATCH 209/823] remove echo --- functions/update_apps.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a69ddfe7..a274a3b5 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -48,38 +48,38 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop - echo_array+=(echo -e "\n$app_name") - [[ "$verbose" == "true" ]] && echo_array+=(echo "Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=(echo -e "Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=(echo "FAILED") + echo_array+=("\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=("Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") return else # if status was not STOPPED, stop the app prior to updating - echo_array+=(echo -e "\n$app_name") - [[ "$verbose" == "true" ]] && echo_array+=(echo "Stopping prior to update..") - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=(echo -e "FAILED") + echo_array+=("\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=("FAILED") while [[ "$status" != "STOPPED" ]] do status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then - echo_array+=(echo "Stopped") - [[ "$verbose" == "true" ]] && echo_array+=(echo "Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=(echo -e "Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "Failed to update" + echo_array+=("Stopped") + [[ "$verbose" == "true" ]] && echo_array+=("Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "Failed to update" break elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo_array+=(echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)") + echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") break elif [[ "$status" != "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo_array+=(echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED") + [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED") sleep 10 fi done fi else #user must not be using -S, just update - echo_array+=(echo -e "\n$app_name") - [[ "$verbose" == "true" ]] && echo_array+=(echo "Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=(echo -e "Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "FAILED" + echo_array+=("\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=("Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "FAILED" fi else - echo_array+=(echo -e "\n$app_name\nMajor Release, update manually") + echo_array+=("\n$app_name\nMajor Release, update manually") return fi From 3e125a009ef4b6eb081745b36606c49645b3df3e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 17:11:56 -0600 Subject: [PATCH 210/823] losing --- functions/update_apps.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a274a3b5..503ef0b3 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -62,7 +62,7 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name if [[ "$status" == "STOPPED" ]]; then echo_array+=("Stopped") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "Failed to update" + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("Failed to update") break elif [[ "$SECONDS" -ge "$timeout" ]]; then echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") @@ -76,7 +76,7 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name else #user must not be using -S, just update echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "FAILED" + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") fi else echo_array+=("\n$app_name\nMajor Release, update manually") @@ -102,27 +102,27 @@ if [[ $rollback == "true" ]]; then (( count++ )) status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" + [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") break elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" != "true" ]]; then - echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update.." + echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update..") midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update break elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" == "true" ]]; then - echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning" + echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning") break elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - echo "Stopped" && break #if reports stopped any time after the first loop, assume its extermal services. + echo_array+=("Stopped") && break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$status" == "ACTIVE" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check echo "Active" && break #if reports active any time after the first loop, assume actually active. else - [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" + [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") sleep 15 continue fi @@ -134,21 +134,21 @@ else (( count++ )) status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - echo "Stopped" && break #assume actually stopped anytime AFTER the first loop + echo_array+=("Stopped") && break #assume actually stopped anytime AFTER the first loop break elif [[ "$status" == "ACTIVE" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" + [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") break elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" + echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") break else - [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" + [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") sleep 10 continue fi From b0c122098b99eda6a519e5486a840fb1f6a72292 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 17:21:41 -0600 Subject: [PATCH 211/823] move dunmp to after action --- functions/update_apps.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 503ef0b3..dc13a2ff 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -83,11 +83,6 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name return fi -#dump array -for i in "${echo_array[@]}" -do - echo -e "$i" -done } export -f update_apps @@ -155,5 +150,13 @@ else done fi fi + +#dump array +for i in "${echo_array[@]}" +do + echo -e "$i" +done + + } export -f after_update_actions \ No newline at end of file From ee7608b1da88f6ad7f9e8c075ab88982a4618666 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 17:38:10 -0600 Subject: [PATCH 212/823] forgot echo --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index dc13a2ff..ed1a11f2 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -115,7 +115,7 @@ if [[ $rollback == "true" ]]; then elif [[ "$status" == "ACTIVE" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - echo "Active" && break #if reports active any time after the first loop, assume actually active. + echo_array+=(echo "Active") && break #if reports active any time after the first loop, assume actually active. else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") sleep 15 @@ -151,7 +151,7 @@ else fi fi -#dump array +#Dump the echo_array, ensures all output is in a neat order. for i in "${echo_array[@]}" do echo -e "$i" From c13153959049d97b26585e0b738355fa3167da31 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 17:40:05 -0600 Subject: [PATCH 213/823] remove redun echo --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ed1a11f2..df93a344 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -115,7 +115,7 @@ if [[ $rollback == "true" ]]; then elif [[ "$status" == "ACTIVE" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - echo_array+=(echo "Active") && break #if reports active any time after the first loop, assume actually active. + echo_array+=("Active") && break #if reports active any time after the first loop, assume actually active. else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") sleep 15 From 02aa8b6c22eb5ebb911a33f51fa3e495b453a0b3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 17:45:35 -0600 Subject: [PATCH 214/823] enhance --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index df93a344..917fbfdf 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,7 +14,7 @@ while [[ $it -lt ${#array[@]} ]] do jobs=$(jobs -p | wc -l) if [[ "$jobs" -ge "$update_limit" ]]; then - sleep 3 + sleep 1 else update_apps "${array[$it]}" & processes+=($!) From 7f41fd1d8d50deaa6e06a6ddee22256e0550df7a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 21:47:14 -0600 Subject: [PATCH 215/823] test --- heavy_script.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 905e50de..d0df8bed 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -52,10 +52,10 @@ do echo -e "Invalid Option \"-$OPTARG\"\n" && help exit ;; - :) - echo -e "Option: \"-$OPTARG\" requires an argument\n" && help - exit - ;; + # :) + # echo -e "Option: \"-$OPTARG\" requires an argument\n" && help + # exit + # ;; b) re='^[0-9]+$' number_of_backups=$OPTARG @@ -66,6 +66,7 @@ do rollback="true" ;; i) + [[ -z "$OPTARG" ]] && echo "\"-i\" requires an argument" && exit ignore+=("$OPTARG") ;; t) @@ -88,10 +89,6 @@ do p) prune="true" ;; - R) - rollback="true" - echo "WARNING: -R is being transisitioned to -r, this is due to a refactor in the script. Please Make the change ASAP!" - ;; v) verbose="true" ;; From 00e765a14d84ea41a3b94b37a0008370766712d1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 21:49:47 -0600 Subject: [PATCH 216/823] test --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index d0df8bed..5ee2afcc 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -66,8 +66,8 @@ do rollback="true" ;; i) - [[ -z "$OPTARG" ]] && echo "\"-i\" requires an argument" && exit ignore+=("$OPTARG") + [[ -z "$ignore" ]] && echo "\"-i\" requires an argument" && exit ;; t) re='^[0-9]+$' @@ -93,7 +93,7 @@ do verbose="true" ;; *) - echo -e "Invalid Option \"--$OPTARG\"\n" && help + echo -e "Invalid Option \"-$OPTARG\"\n" && help exit ;; esac From eec9afa5dffdca56ead282df07d48fd9a7bb2282 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 21:55:46 -0600 Subject: [PATCH 217/823] test --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 5ee2afcc..1edaf814 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -19,7 +19,7 @@ source functions/update_apps.sh # Parse script options -while getopts ":si:rb:t:uUpSRv-:" opt +while getopts ":sii:rb:t:uUpSRv-:" opt do case $opt in -) @@ -67,7 +67,7 @@ do ;; i) ignore+=("$OPTARG") - [[ -z "$ignore" ]] && echo "\"-i\" requires an argument" && exit + [[ -z "$OPTARG" ]] && echo "\"-i\" requires an argument" && exit ;; t) re='^[0-9]+$' From 54dc8969e5afc7ea96cdc7d3ca37f4d63a3403e5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 21:59:00 -0600 Subject: [PATCH 218/823] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 1edaf814..89eef577 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -67,7 +67,7 @@ do ;; i) ignore+=("$OPTARG") - [[ -z "$OPTARG" ]] && echo "\"-i\" requires an argument" && exit + [[ -z "$ignore" ]] && echo "\"-i\" requires an argument" && exit ;; t) re='^[0-9]+$' From b92627c77f45de4c9fcf836f760cb1faee8fff69 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:02:19 -0600 Subject: [PATCH 219/823] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 89eef577..5ee2afcc 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -19,7 +19,7 @@ source functions/update_apps.sh # Parse script options -while getopts ":sii:rb:t:uUpSRv-:" opt +while getopts ":si:rb:t:uUpSRv-:" opt do case $opt in -) From 0367588c65bea5d4f4be839e7149bd4fd4c52c23 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:05:55 -0600 Subject: [PATCH 220/823] test --- heavy_script.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 5ee2afcc..3c453ca6 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -48,10 +48,6 @@ do ;; esac ;; - \?) - echo -e "Invalid Option \"-$OPTARG\"\n" && help - exit - ;; # :) # echo -e "Option: \"-$OPTARG\" requires an argument\n" && help # exit @@ -92,6 +88,10 @@ do v) verbose="true" ;; + \?) + echo -e "Invalid Option \"-$OPTARG\"\n" && help + exit + ;; *) echo -e "Invalid Option \"-$OPTARG\"\n" && help exit From f468cfbd8227b021794134f76b4a973de7b466a3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:11:51 -0600 Subject: [PATCH 221/823] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 3c453ca6..36e82e6f 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -19,7 +19,7 @@ source functions/update_apps.sh # Parse script options -while getopts ":si:rb:t:uUpSRv-:" opt +while getopts ":si::rb:t:uUpSRv-:" opt do case $opt in -) From 07be73ce57c42311cf26a520d9b2af598dbbe21b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:19:07 -0600 Subject: [PATCH 222/823] test --- heavy_script.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 36e82e6f..4abeeccb 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -19,7 +19,7 @@ source functions/update_apps.sh # Parse script options -while getopts ":si::rb:t:uUpSRv-:" opt +while getopts ":sirb:t:uUpSRv-:" opt do case $opt in -) @@ -48,10 +48,10 @@ do ;; esac ;; - # :) - # echo -e "Option: \"-$OPTARG\" requires an argument\n" && help - # exit - # ;; + :) + echo -e "Option: \"-$OPTARG\" requires an argument\n" && help + exit + ;; b) re='^[0-9]+$' number_of_backups=$OPTARG @@ -62,8 +62,15 @@ do rollback="true" ;; i) - ignore+=("$OPTARG") - [[ -z "$ignore" ]] && echo "\"-i\" requires an argument" && exit + # Check next positional parameter + eval nextopt=${!OPTIND} + # existing or starting with dash? + if [[ -n $nextopt && $nextopt != -* ]] ; then + OPTIND=$((OPTIND + 1)) + ignore+=("$OPTARG") + else + echo "Option: \"-i\" requires an argument" + fi ;; t) re='^[0-9]+$' From 738765a5f6ee0608e010934804904e4e8e04951d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:20:06 -0600 Subject: [PATCH 223/823] forgot exit --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 4abeeccb..c9ac1957 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -70,6 +70,7 @@ do ignore+=("$OPTARG") else echo "Option: \"-i\" requires an argument" + exit fi ;; t) From d71e2494229380d67ae22ab27ab88e44e8c30802 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:24:26 -0600 Subject: [PATCH 224/823] test --- functions/update_apps.sh | 2 +- heavy_script.sh | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 917fbfdf..a4a9d8a7 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -6,7 +6,7 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -update_limit=4 +echo "Asynchronous Updates: 1" it=0 diff --git a/heavy_script.sh b/heavy_script.sh index c9ac1957..0b1292c6 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -83,9 +83,27 @@ do ;; U) update_all_apps="true" + # Check next positional parameter + eval nextopt=${!OPTIND} + # existing or starting with dash? + if [[ -n $nextopt && $nextopt != -* ]] ; then + OPTIND=$((OPTIND + 1)) + update_limit=("$OPTARG") + else + update_limit=1 + fi ;; u) update_apps="true" + # Check next positional parameter + eval nextopt=${!OPTIND} + # existing or starting with dash? + if [[ -n $nextopt && $nextopt != -* ]] ; then + OPTIND=$((OPTIND + 1)) + update_limit=("$OPTARG") + else + update_limit=1 + fi ;; S) stop_before_update="true" From d511df4fb4d08f09dd0077579b5520ba5776c8e9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:25:14 -0600 Subject: [PATCH 225/823] reporting --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a4a9d8a7..55b772fc 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -6,7 +6,7 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -echo "Asynchronous Updates: 1" +echo "Asynchronous Updates: $update_limit" it=0 From 5b1b0a73d903d358b149a7d1b5613d6046b823ef Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:28:16 -0600 Subject: [PATCH 226/823] fix --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 0b1292c6..7f319681 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -100,7 +100,7 @@ do # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then OPTIND=$((OPTIND + 1)) - update_limit=("$OPTARG") + update_limit=$OPTARG else update_limit=1 fi From c3fcc5a10d1ee50a7b5c3855e028fd1dd88549cc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:34:07 -0600 Subject: [PATCH 227/823] hmm --- functions/update_apps.sh | 1 - heavy_script.sh | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 55b772fc..2dba0fab 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,7 +9,6 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl echo "Asynchronous Updates: $update_limit" it=0 - while [[ $it -lt ${#array[@]} ]] do jobs=$(jobs -p | wc -l) diff --git a/heavy_script.sh b/heavy_script.sh index 7f319681..82087420 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -88,7 +88,7 @@ do # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then OPTIND=$((OPTIND + 1)) - update_limit=("$OPTARG") + update_limit="$OPTARG" else update_limit=1 fi @@ -100,7 +100,7 @@ do # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then OPTIND=$((OPTIND + 1)) - update_limit=$OPTARG + update_limit="$OPTARG" else update_limit=1 fi From 3547a67f0193c9387a6b2935bc4bfda90d54cbb6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:37:21 -0600 Subject: [PATCH 228/823] test --- heavy_script.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 82087420..29f90c3e 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -87,8 +87,8 @@ do eval nextopt=${!OPTIND} # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then - OPTIND=$((OPTIND + 1)) - update_limit="$OPTARG" + OPTIND=$((OPTIND++)) + update_limit="$nextopt" else update_limit=1 fi @@ -99,8 +99,8 @@ do eval nextopt=${!OPTIND} # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then - OPTIND=$((OPTIND + 1)) - update_limit="$OPTARG" + OPTIND=$((OPTIND++)) + update_limit="$nextopt" else update_limit=1 fi From 6c24507dd71274a7f06c56f819b3c65b61182f96 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:40:05 -0600 Subject: [PATCH 229/823] woo --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 29f90c3e..a452cbd8 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -67,7 +67,7 @@ do # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then OPTIND=$((OPTIND + 1)) - ignore+=("$OPTARG") + ignore+=("$nextopt") else echo "Option: \"-i\" requires an argument" exit From dc083bf59f913e168ab4d042ba76fa9cdad59ab7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:45:19 -0600 Subject: [PATCH 230/823] ignore return code --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2dba0fab..81b3acd9 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -43,7 +43,7 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop From 118e921306682efb84ad6fc67b95de0bbed9126f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:47:08 -0600 Subject: [PATCH 231/823] uhh --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 81b3acd9..b712d348 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -43,7 +43,7 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && exit #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop From 11dfd4a1a7981e45a7c6461bd6a279aa9d53163e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:51:54 -0600 Subject: [PATCH 232/823] test --- functions/update_apps.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index b712d348..fff889fa 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -43,14 +43,14 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && exit #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 1 #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") - return + return 0 else # if status was not STOPPED, stop the app prior to updating echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") @@ -79,7 +79,7 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name fi else echo_array+=("\n$app_name\nMajor Release, update manually") - return + return 0 fi From 355ab29b0bfe4aac1565d35209ce88513593fd77 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:59:13 -0600 Subject: [PATCH 233/823] idk --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index fff889fa..997a2adb 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,6 +32,7 @@ export -f commander update_apps(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version @@ -43,7 +44,6 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 1 #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop From 0517819e654ae6422f83a2cffc973d25dfef5d5e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:01:40 -0600 Subject: [PATCH 234/823] sadf --- functions/update_apps.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 997a2adb..db9fb9a8 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,7 +32,13 @@ export -f commander update_apps(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip + +if printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" ; then + echo -e "\n$app_name\nIgnored, skipping" + return 0 #If application is on ignore list, skip + +fi + old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version From 545f57b8e8fe5fc1f54662b6c0c3b1af7c2578e9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:06:08 -0600 Subject: [PATCH 235/823] idk --- functions/update_apps.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index db9fb9a8..cbf7193c 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,7 +15,7 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 1 else - update_apps "${array[$it]}" & + { update_apps "${array[$it]}" ;} & processes+=($!) ((it++)) fi @@ -32,13 +32,7 @@ export -f commander update_apps(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. - -if printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" ; then - echo -e "\n$app_name\nIgnored, skipping" - return 0 #If application is on ignore list, skip - -fi - +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version From 54ba3685c9448f43060175c1c02190bb2319aa30 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:12:36 -0600 Subject: [PATCH 236/823] testing --- functions/update_apps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index cbf7193c..08d84581 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,9 +15,10 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 1 else - { update_apps "${array[$it]}" ;} & + update_apps "${array[$it]}" & processes+=($!) ((it++)) + echo "$processes" fi done From 4cb021f97979a3c36378fbff64cdac3f7de74537 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:17:04 -0600 Subject: [PATCH 237/823] a --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 08d84581..e03aa7a3 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -33,7 +33,7 @@ export -f commander update_apps(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && disown && return 0 #If application is on ignore list, skip old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version From 27b8d258cf85ec1ef6783a49018ee6368ebd7ba1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:19:18 -0600 Subject: [PATCH 238/823] test --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e03aa7a3..e4fbcc71 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -33,7 +33,7 @@ export -f commander update_apps(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && disown && return 0 #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && exit 0 #If application is on ignore list, skip old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version From 51eacf44a2653c6e62dd87397549437033cfabd1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:38:29 -0600 Subject: [PATCH 239/823] test --- functions/update_apps.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e4fbcc71..460e9169 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,14 +11,18 @@ echo "Asynchronous Updates: $update_limit" it=0 while [[ $it -lt ${#array[@]} ]] do - jobs=$(jobs -p | wc -l) - if [[ "$jobs" -ge "$update_limit" ]]; then + proc_count=${#processes[@]} + for proc in "${processes[@]}" + do + kill -0 "$proc" || ((proc_count--)) + done + #jobs=$(jobs -p | wc -l) + if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 1 else update_apps "${array[$it]}" & processes+=($!) ((it++)) - echo "$processes" fi done @@ -33,7 +37,7 @@ export -f commander update_apps(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && exit 0 #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version From a498bfe6cda96266a041967b67ec45f0cb0c78df Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:40:32 -0600 Subject: [PATCH 240/823] hide output --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 460e9169..427a131b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,7 +14,7 @@ do proc_count=${#processes[@]} for proc in "${processes[@]}" do - kill -0 "$proc" || ((proc_count--)) + kill -0 "$proc" &> /dev/null || ((proc_count--)) done #jobs=$(jobs -p | wc -l) if [[ "$proc_count" -ge "$update_limit" ]]; then From 5889438cbdfab70e7ee220e9d23ae231f25c0a97 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:44:09 -0600 Subject: [PATCH 241/823] lop --- functions/update_apps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 427a131b..94db2c24 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -12,9 +12,10 @@ it=0 while [[ $it -lt ${#array[@]} ]] do proc_count=${#processes[@]} + count=0 for proc in "${processes[@]}" do - kill -0 "$proc" &> /dev/null || ((proc_count--)) + kill -0 "$proc" &> /dev/null || { ((proc_count--)) ; unset "processes[$count]" ;} done #jobs=$(jobs -p | wc -l) if [[ "$proc_count" -ge "$update_limit" ]]; then From 2d0388d9b5d889e0a3778a18950a901c844e09bc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:44:55 -0600 Subject: [PATCH 242/823] best --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 94db2c24..4664de1b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,7 +15,7 @@ do count=0 for proc in "${processes[@]}" do - kill -0 "$proc" &> /dev/null || { ((proc_count--)) ; unset "processes[$count]" ;} + kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } done #jobs=$(jobs -p | wc -l) if [[ "$proc_count" -ge "$update_limit" ]]; then From 682ead72a71ca5ca68d2ad34a4f4c01cfabdb097 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:53:45 -0600 Subject: [PATCH 243/823] ignore --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index a452cbd8..49786818 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -66,7 +66,7 @@ do eval nextopt=${!OPTIND} # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then - OPTIND=$((OPTIND + 1)) + OPTIND=$((OPTIND++)) ignore+=("$nextopt") else echo "Option: \"-i\" requires an argument" From 0fde7bf999dff3705ff673ad9af93266c844e964 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 00:04:39 -0600 Subject: [PATCH 244/823] not sure --- heavy_script.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 49786818..5e82664f 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -66,7 +66,7 @@ do eval nextopt=${!OPTIND} # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then - OPTIND=$((OPTIND++)) + OPTIND=$((OPTIND + 1)) ignore+=("$nextopt") else echo "Option: \"-i\" requires an argument" @@ -87,7 +87,7 @@ do eval nextopt=${!OPTIND} # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then - OPTIND=$((OPTIND++)) + OPTIND=$((OPTIND + 1)) update_limit="$nextopt" else update_limit=1 @@ -99,7 +99,7 @@ do eval nextopt=${!OPTIND} # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then - OPTIND=$((OPTIND++)) + OPTIND=$((OPTIND + 1)) update_limit="$nextopt" else update_limit=1 From 221e06317f6a1946bccc929c0ec22801589df634 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 00:23:27 -0600 Subject: [PATCH 245/823] sync and backup --- heavy_script.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 5e82664f..7015f348 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -136,7 +136,12 @@ done [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit -[[ "$number_of_backups" -ge 1 ]] && backup -[[ "$sync" == "true" ]] && sync +if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync at the same time + backup & + sync & + wait +fi +[[ "$number_of_backups" -ge 1 && "$sync" == "false" ]] && backup +[[ "$sync" == "true" && "$number_of_backups" -le 1 ]] && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander [[ "$prune" == "true" ]] && prune \ No newline at end of file From 70109420c985eafd51acdc852e84a11c493ef78a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 00:32:37 -0600 Subject: [PATCH 246/823] more async --- functions/backup.sh | 16 +++++++++++----- functions/misc.sh | 8 +++++++- heavy_script.sh | 1 + 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index a4684ca1..58409915 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -2,21 +2,27 @@ backup(){ -echo -e "\nNumber of backups was set to $number_of_backups" +echo_backup+=("\nNumber of backups was set to $number_of_backups") date=$(date '+%Y_%m_%d_%H_%M_%S') [[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' -[[ -z "$verbose" ]] && echo -e "\nNew Backup Name:" && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 +[[ -z "$verbose" ]] && echo_backup+=("\nNew Backup Name:") && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then - echo -e "\nDeleting the oldest backup(s) for exceeding limit:" + echo_backup+=("\nDeleting the oldest backup(s) for exceeding limit:") overflow=$(( ${#list_backups[@]} - "$number_of_backups" )) mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") for i in "${list_overflow[@]}" do - cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo "Failed to delete $i" - echo "$i" + cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo_backup+=("Failed to delete $i") + echo_backup+=("$i") done fi + +#Dump the echo_array, ensures all output is in a neat order. +for i in "${echo_backup[@]}" +do + echo -e "$i" +done } export -f backup diff --git a/functions/misc.sh b/functions/misc.sh index f854381b..d0d9a410 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -2,7 +2,13 @@ sync(){ -echo -e "\nSyncing all catalogs, please wait.." && cli -c 'app catalog sync_all' &> /dev/null && echo -e "Catalog sync complete" +echo_sync+=("\nSyncing all catalogs, please wait..") && cli -c 'app catalog sync_all' &> /dev/null && echo_sync+=("Catalog sync complete") + +#Dump the echo_array, ensures all output is in a neat order. +for i in "${echo_sync[@]}" +do + echo -e "$i" +done } export -f sync diff --git a/heavy_script.sh b/heavy_script.sh index 7015f348..9e810ab6 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -137,6 +137,7 @@ done [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync at the same time + echo "Backing up and syncing catalogs at the same time, please wait for output.." backup & sync & wait From 8456f40fd2651661e994fb41db6f01c73e60d6dc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 00:39:25 -0600 Subject: [PATCH 247/823] output --- functions/backup.sh | 4 ++-- heavy_script.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 58409915..03c0003b 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -4,8 +4,8 @@ backup(){ echo_backup+=("\nNumber of backups was set to $number_of_backups") date=$(date '+%Y_%m_%d_%H_%M_%S') -[[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' -[[ -z "$verbose" ]] && echo_backup+=("\nNew Backup Name:") && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 +[[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' &> /dev/null && echo_backup+=(HeavyScript_"$date") +[[ -z "$verbose" ]] && echo_backup+=("\nNew Backup Name:") && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 &> /dev/null && echo_backup+=(HeavyScript_"$date") mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then echo_backup+=("\nDeleting the oldest backup(s) for exceeding limit:") diff --git a/heavy_script.sh b/heavy_script.sh index 9e810ab6..ac01dbac 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -137,7 +137,7 @@ done [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync at the same time - echo "Backing up and syncing catalogs at the same time, please wait for output.." + echo -e "Backing up and syncing catalogs at the same time, please wait for output..\n" backup & sync & wait From 88a655f9443650435b7922bd62eaa86bd72ec6f4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 00:42:58 -0600 Subject: [PATCH 248/823] message --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index ac01dbac..72628b77 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -142,7 +142,7 @@ if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync & wait fi -[[ "$number_of_backups" -ge 1 && "$sync" == "false" ]] && backup -[[ "$sync" == "true" && "$number_of_backups" -le 1 ]] && sync +[[ "$number_of_backups" -ge 1 && "$sync" == "false" ]] && echo "Please wait for output, this could take a while.." && backup +[[ "$sync" == "true" && "$number_of_backups" -le 1 ]] && echo "Please wait for output, this could take a while.." && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander [[ "$prune" == "true" ]] && prune \ No newline at end of file From f80be88a71ee52459ff25903fc7b9b89edb79303 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 00:53:53 -0600 Subject: [PATCH 249/823] lt instead of le --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 72628b77..51c0c16a 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -143,6 +143,6 @@ if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and wait fi [[ "$number_of_backups" -ge 1 && "$sync" == "false" ]] && echo "Please wait for output, this could take a while.." && backup -[[ "$sync" == "true" && "$number_of_backups" -le 1 ]] && echo "Please wait for output, this could take a while.." && sync +[[ "$sync" == "true" && "$number_of_backups" -lt 1 ]] && echo "Please wait for output, this could take a while.." && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander -[[ "$prune" == "true" ]] && prune \ No newline at end of file +[[ "$prune" == "true" ]] && prune From 3888aef71bf261d0f71ed7aa69dd134359d8cd61 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:08:33 -0600 Subject: [PATCH 250/823] menu --- functions/menu.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++++ heavy_script.sh | 4 +++- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 functions/menu.sh diff --git a/functions/menu.sh b/functions/menu.sh new file mode 100644 index 00000000..2dc39f69 --- /dev/null +++ b/functions/menu.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +menu(){ + echo "0 Help" + echo "1 List DNS Names" + echo "2 Mount and Unmount PVC storage" + echo "3 Create a Backup" + echo "4 Restore a Backup" + echo "5 Delete a Backup" + echo "6 Update All Apps" + read -rt 600 -p "Please select an option by number: " selection + + case $selection in + 0) + help="true" + ;; + 1) + dns="true" + ;; + 2) + mount="true" + ;; + 4) + read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups + re='^[0-9]+$' + number_of_backups=$number_of_backups + ! [[ $number_of_backups =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit + [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit + backup "$number_of_backups" + ;; + 5) + restore="true" + ;; + 6) + deleteBackup="true" + ;; + 9) + echo "" + echo "1 Update Apps Excluding likely breaking major changes" + echo "2 Update Apps Including likely breaking major changes" + read -rt 600 -p "Please select an option by number: " updateType + if [[ "$updateType" == "1" ]]; then + update_apps="true" + elif [[ "$updateType" == "2" ]]; then + update_all_apps="true" + else + echo "INVALID ENTRY" && exit 1 + fi + ;; + *) + echo "Unknown option" && exit 1 + ;; + esac + echo "" +} +export -f menu \ No newline at end of file diff --git a/heavy_script.sh b/heavy_script.sh index 72628b77..d136c8c8 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,13 +1,15 @@ #!/bin/bash #If no argument is passed, kill the script. -[[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit +[[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && menu # shellcheck source=functions/backup.sh source functions/backup.sh # shellcheck source=functions/dns.sh source functions/dns.sh +# shellcheck source=functions/menu.sh +source functions/menu.sh # shellcheck source=functions/misc.sh source functions/misc.sh # shellcheck source=functions/mount.sh From 7a4622b3e37d727722f9fe0d590ee6cbde72b465 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:10:09 -0600 Subject: [PATCH 251/823] re-arrange --- functions/menu.sh | 2 +- heavy_script.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 2dc39f69..72e3df90 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -34,7 +34,7 @@ menu(){ 6) deleteBackup="true" ;; - 9) + 7) echo "" echo "1 Update Apps Excluding likely breaking major changes" echo "2 Update Apps Including likely breaking major changes" diff --git a/heavy_script.sh b/heavy_script.sh index 1428a86e..0977b086 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,9 +1,5 @@ #!/bin/bash -#If no argument is passed, kill the script. -[[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && menu - - # shellcheck source=functions/backup.sh source functions/backup.sh # shellcheck source=functions/dns.sh @@ -20,6 +16,10 @@ source functions/self_update.sh source functions/update_apps.sh +#If no argument is passed, kill the script. +[[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && menu + + # Parse script options while getopts ":sirb:t:uUpSRv-:" opt do From 813396df2adf44a8f982985aa54de18e1c4c8bb3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:11:14 -0600 Subject: [PATCH 252/823] number order --- functions/menu.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 72e3df90..8e127ca9 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -20,7 +20,7 @@ menu(){ 2) mount="true" ;; - 4) + 3) read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups re='^[0-9]+$' number_of_backups=$number_of_backups @@ -28,13 +28,13 @@ menu(){ [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit backup "$number_of_backups" ;; - 5) + 4) restore="true" ;; - 6) + 5) deleteBackup="true" ;; - 7) + 6) echo "" echo "1 Update Apps Excluding likely breaking major changes" echo "2 Update Apps Including likely breaking major changes" From 064fecfb33fb533fe51e10762bc36eb09113e157 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:12:21 -0600 Subject: [PATCH 253/823] text --- functions/menu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/menu.sh b/functions/menu.sh index 8e127ca9..c19d9eb1 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -26,6 +26,7 @@ menu(){ number_of_backups=$number_of_backups ! [[ $number_of_backups =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit + echo "Generating backup, please be patient for output.." backup "$number_of_backups" ;; 4) From 08a86ad238658599ba9dbcf3ecbbf874dc2c86c6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:15:49 -0600 Subject: [PATCH 254/823] title --- functions/menu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/menu.sh b/functions/menu.sh index c19d9eb1..9b6cae17 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -1,6 +1,7 @@ #!/bin/bash menu(){ + title echo "0 Help" echo "1 List DNS Names" echo "2 Mount and Unmount PVC storage" From 5f31a134936cc10e8d36a49a8b33f590d3e4addc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:16:15 -0600 Subject: [PATCH 255/823] clear --- functions/menu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/menu.sh b/functions/menu.sh index 9b6cae17..9903aa33 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -1,6 +1,7 @@ #!/bin/bash menu(){ + clear -x title echo "0 Help" echo "1 List DNS Names" From 666c1e81682ced372d2b2c064620fa91ee9674a5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:29:30 -0600 Subject: [PATCH 256/823] maybe --- functions/menu.sh | 34 +++++++++++++++++++++++----------- functions/misc.sh | 1 - 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 9903aa33..5a9aa0a6 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -38,17 +38,29 @@ menu(){ deleteBackup="true" ;; 6) - echo "" - echo "1 Update Apps Excluding likely breaking major changes" - echo "2 Update Apps Including likely breaking major changes" - read -rt 600 -p "Please select an option by number: " updateType - if [[ "$updateType" == "1" ]]; then - update_apps="true" - elif [[ "$updateType" == "2" ]]; then - update_all_apps="true" - else - echo "INVALID ENTRY" && exit 1 - fi + script=$(readlink -f "$0") + script_path=$(dirname "$script") + script_name="heavy_script.sh" + cd "$script_path" || exit + clear -x + echo "Choose your update options" + echo + echo "-U | Update all applications, ignores versions" + echo "-u | Update all applications, does not update Major releases" + echo "-b | Back-up your ix-applications dataset, specify a number after -b" + echo "-i | Add application to ignore list, one by one, see example below." + echo "-r | Roll-back applications if they fail to update" + echo "-S | Shutdown applications prior to updating" + echo "-v | verbose output" + echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo "-s | sync catalog" + echo "-p | Prune unused/old docker images" + echo + echo "Example: -u 3 -b 14 -rSvsp -i nextcloud" + + read -rt 600 -p "Please type the flags you wish, with options above: " update_selection + exec bash "$script_name" "$update_selection" + ;; *) echo "Unknown option" && exit 1 diff --git a/functions/misc.sh b/functions/misc.sh index d0d9a410..8fcdbbed 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -43,7 +43,6 @@ echo "-U | Update all applications, ignores versions" echo "-u | Update all applications, does not update Major releases" echo "-b | Back-up your ix-applications dataset, specify a number after -b" echo "-i | Add application to ignore list, one by one, see example below." -echo "-R | THIS OPTION WILL DEPRICATE SOON, USE \"-r\" instead. Roll-back applications if they fail to update" echo "-r | Roll-back applications if they fail to update" echo "-S | Shutdown applications prior to updating" echo "-v | verbose output" From a04d928c1ceda320ce221c006e4e81c4b53b9e24 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:33:59 -0600 Subject: [PATCH 257/823] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 5a9aa0a6..9b59e1ee 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -59,7 +59,7 @@ menu(){ echo "Example: -u 3 -b 14 -rSvsp -i nextcloud" read -rt 600 -p "Please type the flags you wish, with options above: " update_selection - exec bash "$script_name" "$update_selection" + exec bash "$script_name" "${update_selection[@]}" ;; *) From 15147eccc72c28d4f9e86d81c300da2818339d2d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:35:16 -0600 Subject: [PATCH 258/823] self update beta --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 340d5a5d..024630d1 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -9,7 +9,7 @@ script_name="heavy_script.sh" cd "$script_path" || exit git fetch &> /dev/null -if git diff --name-only origin/main | grep -q "$script_name" ; then +if git diff --name-only origin/beta | grep -q "$script_name" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q From 3c11bb4f54c170f2a7c56cadb146bbb778393669 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:35:52 -0600 Subject: [PATCH 259/823] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 9b59e1ee..3198e7f7 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -43,7 +43,7 @@ menu(){ script_name="heavy_script.sh" cd "$script_path" || exit clear -x - echo "Choose your update options" + echo "Choose your update options " echo echo "-U | Update all applications, ignores versions" echo "-u | Update all applications, does not update Major releases" From 1e92da6db0a920992bafea06fadc55325157cedc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:36:22 -0600 Subject: [PATCH 260/823] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 0977b086..fef23378 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -128,7 +128,7 @@ do done -#exit if incompatable functions are called +#exit if incompatable functions are called [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit #Continue to call functions in specific order From c52502a04d820d0f7a83905fae406e53bd044c08 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:37:38 -0600 Subject: [PATCH 261/823] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index fef23378..dcfcb1e0 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -144,7 +144,7 @@ if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync & wait fi -[[ "$number_of_backups" -ge 1 && "$sync" == "false" ]] && echo "Please wait for output, this could take a while.." && backup +[[ "$number_of_backups" -ge 1 && -z "$sync" ]] && echo "Please wait for output, this could take a while.." && backup [[ "$sync" == "true" && "$number_of_backups" -lt 1 ]] && echo "Please wait for output, this could take a while.." && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander [[ "$prune" == "true" ]] && prune From e0fb20b14df9f24fe46a20bf7c0695c9bb8977e7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:39:06 -0600 Subject: [PATCH 262/823] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 3198e7f7..45ce389c 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -59,7 +59,7 @@ menu(){ echo "Example: -u 3 -b 14 -rSvsp -i nextcloud" read -rt 600 -p "Please type the flags you wish, with options above: " update_selection - exec bash "$script_name" "${update_selection[@]}" + exec bash "$script_name" $update_selection ;; *) From 702325b8c152a100c19bff1145314bbdb1ba6ba3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:41:02 -0600 Subject: [PATCH 263/823] array --- functions/menu.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 45ce389c..25b3e5af 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -59,7 +59,8 @@ menu(){ echo "Example: -u 3 -b 14 -rSvsp -i nextcloud" read -rt 600 -p "Please type the flags you wish, with options above: " update_selection - exec bash "$script_name" $update_selection + args=("$update_selection") + exec bash "$script_name" "${args[@]}" ;; *) From 48bb34fdfdc8993ee30912318ea2397359745324 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:49:58 -0600 Subject: [PATCH 264/823] test while --- functions/menu.sh | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 25b3e5af..1e178b3c 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -43,25 +43,32 @@ menu(){ script_name="heavy_script.sh" cd "$script_path" || exit clear -x + while true + do echo "Choose your update options " echo - echo "-U | Update all applications, ignores versions" - echo "-u | Update all applications, does not update Major releases" - echo "-b | Back-up your ix-applications dataset, specify a number after -b" - echo "-i | Add application to ignore list, one by one, see example below." - echo "-r | Roll-back applications if they fail to update" - echo "-S | Shutdown applications prior to updating" - echo "-v | verbose output" - echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" - echo "-s | sync catalog" - echo "-p | Prune unused/old docker images" + echo "1) -U | Update all applications, ignores versions" + echo "2) -u | Update all applications, does not update Major releases" + echo "3) -b | Back-up your ix-applications dataset, specify a number after -b" + echo "4) -i | Add application to ignore list, one by one, see example below." + echo "5) -r | Roll-back applications if they fail to update" + echo "6) -S | Shutdown applications prior to updating" + echo "7) -v | verbose output" + echo "8) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo "9) -s | sync catalog" + echo "10) -p | Prune unused/old docker images" + echo + echo "0) Done making selections, proceed with update" echo - echo "Example: -u 3 -b 14 -rSvsp -i nextcloud" - read -rt 600 -p "Please type the flags you wish, with options above: " update_selection - args=("$update_selection") - exec bash "$script_name" "${args[@]}" + read -rt 600 -p "Please type the number associated with the flag above: " current_selection + if [[ $current_selection == 0 ]]; then + exec bash "$script_name" "${args[@]}" + else + update_selection+=("$current_selection") + fi + done ;; *) echo "Unknown option" && exit 1 From eab21168b3d8ebea5e5a50f6650ec3a99cd048c0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:50:56 -0600 Subject: [PATCH 265/823] fix --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 1e178b3c..76276bf7 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -63,7 +63,7 @@ menu(){ read -rt 600 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 0 ]]; then - exec bash "$script_name" "${args[@]}" + exec bash "$script_name" "${update_selection[@]}" else update_selection+=("$current_selection") From ad20acf844a17885353d8b2ac3fdf5bc9fab79fc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:52:09 -0600 Subject: [PATCH 266/823] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 76276bf7..7fef071d 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -64,7 +64,7 @@ menu(){ read -rt 600 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 0 ]]; then exec bash "$script_name" "${update_selection[@]}" - + exit else update_selection+=("$current_selection") fi From b37870370916efabe7a99623f3cbbb773c2cd528 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:04:31 -0600 Subject: [PATCH 267/823] test sloppy --- functions/menu.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 7fef071d..469cd581 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -66,7 +66,30 @@ menu(){ exec bash "$script_name" "${update_selection[@]}" exit else - update_selection+=("$current_selection") + if [[ $current_selection == 1 ]]; then + update_selection+=("-U") + elif [[ $current_selection == 2 ]]; then + update_selection+=("-u") + elif [[ $current_selection == 3 ]]; then + read -rt 600 -p "Up to how many backups should we keep?\n Please type an integer: " up_backups + update_selection+=("-b $up_backups") + elif [[ $current_selection == 4 ]]; then + read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + update_selection+=("-i $up_ignore") + elif [[ $current_selection == 5 ]]; then + update_selection+=("-r") + elif [[ $current_selection == 6 ]]; then + update_selection+=("-S") + elif [[ $current_selection == 7 ]]; then + update_selection+=("-v") + elif [[ $current_selection == 8 ]]; then + read -rt 600 -p "What do you want your timeout to be?: " up_timeout + update_selection+=("-t $up_timeout") + elif [[ $current_selection == 9 ]]; then + update_selection+=("-s") + elif [[ $current_selection == 10 ]]; then + update_selection+=("-p") + fi fi done ;; From 9db9c1d4be88cf534357c93ba44f114b747485e6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:07:04 -0600 Subject: [PATCH 268/823] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 469cd581..8b60b7c4 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -75,7 +75,7 @@ menu(){ update_selection+=("-b $up_backups") elif [[ $current_selection == 4 ]]; then read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - update_selection+=("-i $up_ignore") + update_selection+=("-i" "$up_ignore") elif [[ $current_selection == 5 ]]; then update_selection+=("-r") elif [[ $current_selection == 6 ]]; then From e3f8dc954217d8a522fcb65811df8821ce8c34ed Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:15:42 -0600 Subject: [PATCH 269/823] improved --- functions/menu.sh | 85 ++++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 38 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 8b60b7c4..136da234 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -9,7 +9,7 @@ menu(){ echo "3 Create a Backup" echo "4 Restore a Backup" echo "5 Delete a Backup" - echo "6 Update All Apps" + echo "6 Update Applications" read -rt 600 -p "Please select an option by number: " selection case $selection in @@ -43,20 +43,35 @@ menu(){ script_name="heavy_script.sh" cd "$script_path" || exit clear -x - while true - do - echo "Choose your update options " - echo + + echo "What type of update would you like?" echo "1) -U | Update all applications, ignores versions" echo "2) -u | Update all applications, does not update Major releases" - echo "3) -b | Back-up your ix-applications dataset, specify a number after -b" - echo "4) -i | Add application to ignore list, one by one, see example below." - echo "5) -r | Roll-back applications if they fail to update" - echo "6) -S | Shutdown applications prior to updating" - echo "7) -v | verbose output" - echo "8) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" - echo "9) -s | sync catalog" - echo "10) -p | Prune unused/old docker images" + echo "0) Exit" + read -rt 600 -p "Please type the number associated with the flag above: " current_selection + if [[ $current_selection == 1 ]]; then + update_selection+=("-U") + elif [[ $current_selection == 2 ]]; then + update_selection+=("-u") + elif [[ $current_selection == 0 ]]; then + echo "Exiting.." + exit + else + echo "$current_selection was not an option, try again" + fi + while true + do + clear -x + echo "Choose your update options " + echo + echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" + echo "2) -i | Add application to ignore list, one by one, see example below." + echo "3) -r | Roll-back applications if they fail to update" + echo "4) -S | Shutdown applications prior to updating" + echo "5) -v | verbose output" + echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo "7) -s | sync catalog" + echo "8) -p | Prune unused/old docker images" echo echo "0) Done making selections, proceed with update" echo @@ -65,31 +80,25 @@ menu(){ if [[ $current_selection == 0 ]]; then exec bash "$script_name" "${update_selection[@]}" exit - else - if [[ $current_selection == 1 ]]; then - update_selection+=("-U") - elif [[ $current_selection == 2 ]]; then - update_selection+=("-u") - elif [[ $current_selection == 3 ]]; then - read -rt 600 -p "Up to how many backups should we keep?\n Please type an integer: " up_backups - update_selection+=("-b $up_backups") - elif [[ $current_selection == 4 ]]; then - read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - update_selection+=("-i" "$up_ignore") - elif [[ $current_selection == 5 ]]; then - update_selection+=("-r") - elif [[ $current_selection == 6 ]]; then - update_selection+=("-S") - elif [[ $current_selection == 7 ]]; then - update_selection+=("-v") - elif [[ $current_selection == 8 ]]; then - read -rt 600 -p "What do you want your timeout to be?: " up_timeout - update_selection+=("-t $up_timeout") - elif [[ $current_selection == 9 ]]; then - update_selection+=("-s") - elif [[ $current_selection == 10 ]]; then - update_selection+=("-p") - fi + elif [[ $current_selection == 3 ]]; then + read -rt 600 -p "Up to how many backups should we keep?\n Please type an integer: " up_backups + update_selection+=("-b" "$up_backups") + elif [[ $current_selection == 4 ]]; then + read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + update_selection+=("-i" "$up_ignore") + elif [[ $current_selection == 5 ]]; then + update_selection+=("-r") + elif [[ $current_selection == 6 ]]; then + update_selection+=("-S") + elif [[ $current_selection == 7 ]]; then + update_selection+=("-v") + elif [[ $current_selection == 8 ]]; then + read -rt 600 -p "What do you want your timeout to be?: " up_timeout + update_selection+=("-t" "$up_timeout") + elif [[ $current_selection == 9 ]]; then + update_selection+=("-s") + elif [[ $current_selection == 10 ]]; then + update_selection+=("-p") fi done ;; From ee366875809ef538f55a5447a65aa912aceab760 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:16:51 -0600 Subject: [PATCH 270/823] fix --- functions/menu.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 136da234..0f17f205 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -80,24 +80,24 @@ menu(){ if [[ $current_selection == 0 ]]; then exec bash "$script_name" "${update_selection[@]}" exit - elif [[ $current_selection == 3 ]]; then + elif [[ $current_selection == 1 ]]; then read -rt 600 -p "Up to how many backups should we keep?\n Please type an integer: " up_backups update_selection+=("-b" "$up_backups") - elif [[ $current_selection == 4 ]]; then + elif [[ $current_selection == 2 ]]; then read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore update_selection+=("-i" "$up_ignore") - elif [[ $current_selection == 5 ]]; then + elif [[ $current_selection == 3 ]]; then update_selection+=("-r") - elif [[ $current_selection == 6 ]]; then + elif [[ $current_selection == 4 ]]; then update_selection+=("-S") - elif [[ $current_selection == 7 ]]; then + elif [[ $current_selection == 5 ]]; then update_selection+=("-v") - elif [[ $current_selection == 8 ]]; then + elif [[ $current_selection == 6 ]]; then read -rt 600 -p "What do you want your timeout to be?: " up_timeout update_selection+=("-t" "$up_timeout") - elif [[ $current_selection == 9 ]]; then + elif [[ $current_selection == 7 ]]; then update_selection+=("-s") - elif [[ $current_selection == 10 ]]; then + elif [[ $current_selection == 8 ]]; then update_selection+=("-p") fi done From c60b8d168bbbd2ffa1aa8c3b8d8b8dc5b1e66a07 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:26:19 -0600 Subject: [PATCH 271/823] async in menu --- functions/menu.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 0f17f205..a92b6660 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -50,9 +50,11 @@ menu(){ echo "0) Exit" read -rt 600 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 1 ]]; then - update_selection+=("-U") - elif [[ $current_selection == 2 ]]; then - update_selection+=("-u") + read -rt 600 -p "How many applications do you want updating at the same time?\n Please type an integer: " up_async + update_selection+=("-U" "$up_async") + elif [[ $current_selection == 2 ]]; then + read -rt 600 -p "How many applications do you want updating at the same time?\n Please type an integer: " up_async + update_selection+=("-u" "$up_async") elif [[ $current_selection == 0 ]]; then echo "Exiting.." exit From 36aa0cfec37e01b4784c35216abf754ae51251e1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:29:59 -0600 Subject: [PATCH 272/823] fixes --- functions/menu.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index a92b6660..1cfa8148 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -47,13 +47,16 @@ menu(){ echo "What type of update would you like?" echo "1) -U | Update all applications, ignores versions" echo "2) -u | Update all applications, does not update Major releases" + echo echo "0) Exit" read -rt 600 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 1 ]]; then - read -rt 600 -p "How many applications do you want updating at the same time?\n Please type an integer: " up_async + echo "How many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async update_selection+=("-U" "$up_async") elif [[ $current_selection == 2 ]]; then - read -rt 600 -p "How many applications do you want updating at the same time?\n Please type an integer: " up_async + echo "How many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async update_selection+=("-u" "$up_async") elif [[ $current_selection == 0 ]]; then echo "Exiting.." From 09acdf6ac26860ffdae0e5816a88dbbb57bca85e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:30:41 -0600 Subject: [PATCH 273/823] exit --- functions/menu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/menu.sh b/functions/menu.sh index 1cfa8148..d8f65618 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -63,6 +63,7 @@ menu(){ exit else echo "$current_selection was not an option, try again" + exit fi while true do From 218ff297fceed85fd741d606bc3b783120207f46 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:31:30 -0600 Subject: [PATCH 274/823] title of course --- functions/menu.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index d8f65618..574e1c16 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -43,7 +43,7 @@ menu(){ script_name="heavy_script.sh" cd "$script_path" || exit clear -x - + title echo "What type of update would you like?" echo "1) -U | Update all applications, ignores versions" echo "2) -u | Update all applications, does not update Major releases" @@ -68,6 +68,7 @@ menu(){ while true do clear -x + title echo "Choose your update options " echo echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" From d46a128fcd061586e5b2a927acd4e72f0f369d79 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:32:21 -0600 Subject: [PATCH 275/823] newlines --- functions/menu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 574e1c16..a2c247bd 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -51,11 +51,11 @@ menu(){ echo "0) Exit" read -rt 600 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 1 ]]; then - echo "How many applications do you want updating at the same time?" + echo -e "\nHow many applications do you want updating at the same time?" read -rt 600 -p "Please type an integer greater than 0: " up_async update_selection+=("-U" "$up_async") elif [[ $current_selection == 2 ]]; then - echo "How many applications do you want updating at the same time?" + echo -e "\nHow many applications do you want updating at the same time?" read -rt 600 -p "Please type an integer greater than 0: " up_async update_selection+=("-u" "$up_async") elif [[ $current_selection == 0 ]]; then From 3f939f6b1e7229247d8c258513702eb2cc2872cf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:35:25 -0600 Subject: [PATCH 276/823] polish --- functions/menu.sh | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index a2c247bd..5695a4f6 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -3,26 +3,27 @@ menu(){ clear -x title - echo "0 Help" - echo "1 List DNS Names" - echo "2 Mount and Unmount PVC storage" - echo "3 Create a Backup" - echo "4 Restore a Backup" - echo "5 Delete a Backup" - echo "6 Update Applications" + echo "1 Help" + echo "2 List DNS Names" + echo "3 Mount and Unmount PVC storage" + echo "4 Create a Backup" + echo "5 Restore a Backup" + echo "6 Delete a Backup" + echo "7 Update HeavyScript" + echo "8 Update Applications" read -rt 600 -p "Please select an option by number: " selection case $selection in - 0) + 1) help="true" ;; - 1) + 2) dns="true" ;; - 2) + 3) mount="true" ;; - 3) + 4) read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups re='^[0-9]+$' number_of_backups=$number_of_backups @@ -31,13 +32,16 @@ menu(){ echo "Generating backup, please be patient for output.." backup "$number_of_backups" ;; - 4) + 5) restore="true" ;; - 5) + 6) deleteBackup="true" ;; - 6) + 7) + self_update="true" + ;; + 8) script=$(readlink -f "$0") script_path=$(dirname "$script") script_name="heavy_script.sh" From 07058f5a0bf1520b8f68cc8d13e5bef7231199cb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:36:48 -0600 Subject: [PATCH 277/823] exit --- functions/menu.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index 5695a4f6..5910f92e 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -11,9 +11,14 @@ menu(){ echo "6 Delete a Backup" echo "7 Update HeavyScript" echo "8 Update Applications" + echo + echo "0 Exit" read -rt 600 -p "Please select an option by number: " selection case $selection in + 0) + exit + ;; 1) help="true" ;; From 064e90a44c37c3ec719fcb7fe7ea798bc90c44ac Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:37:46 -0600 Subject: [PATCH 278/823] more polishing --- functions/menu.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 5910f92e..20fbc2ec 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -3,16 +3,16 @@ menu(){ clear -x title - echo "1 Help" - echo "2 List DNS Names" - echo "3 Mount and Unmount PVC storage" - echo "4 Create a Backup" - echo "5 Restore a Backup" - echo "6 Delete a Backup" - echo "7 Update HeavyScript" - echo "8 Update Applications" + echo "1) Help" + echo "2) List DNS Names" + echo "3) Mount and Unmount PVC storage" + echo "4) Create a Backup" + echo "5) Restore a Backup" + echo "6) Delete a Backup" + echo "7) Update HeavyScript" + echo "8) Update Applications" echo - echo "0 Exit" + echo "0) Exit" read -rt 600 -p "Please select an option by number: " selection case $selection in @@ -58,6 +58,7 @@ menu(){ echo "2) -u | Update all applications, does not update Major releases" echo echo "0) Exit" + echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 1 ]]; then echo -e "\nHow many applications do you want updating at the same time?" From 15697089988cd0de4516b73d6edeba1f8fb81bbe Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:43:02 -0600 Subject: [PATCH 279/823] ez --- functions/menu.sh | 83 ++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 20fbc2ec..4c65a68e 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -53,7 +53,7 @@ menu(){ cd "$script_path" || exit clear -x title - echo "What type of update would you like?" + echo "--Choose your update type--" echo "1) -U | Update all applications, ignores versions" echo "2) -u | Update all applications, does not update Major releases" echo @@ -77,46 +77,47 @@ menu(){ fi while true do - clear -x - title - echo "Choose your update options " - echo - echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" - echo "2) -i | Add application to ignore list, one by one, see example below." - echo "3) -r | Roll-back applications if they fail to update" - echo "4) -S | Shutdown applications prior to updating" - echo "5) -v | verbose output" - echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" - echo "7) -s | sync catalog" - echo "8) -p | Prune unused/old docker images" - echo - echo "0) Done making selections, proceed with update" - echo - - read -rt 600 -p "Please type the number associated with the flag above: " current_selection - if [[ $current_selection == 0 ]]; then - exec bash "$script_name" "${update_selection[@]}" - exit - elif [[ $current_selection == 1 ]]; then - read -rt 600 -p "Up to how many backups should we keep?\n Please type an integer: " up_backups - update_selection+=("-b" "$up_backups") - elif [[ $current_selection == 2 ]]; then - read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - update_selection+=("-i" "$up_ignore") - elif [[ $current_selection == 3 ]]; then - update_selection+=("-r") - elif [[ $current_selection == 4 ]]; then - update_selection+=("-S") - elif [[ $current_selection == 5 ]]; then - update_selection+=("-v") - elif [[ $current_selection == 6 ]]; then - read -rt 600 -p "What do you want your timeout to be?: " up_timeout - update_selection+=("-t" "$up_timeout") - elif [[ $current_selection == 7 ]]; then - update_selection+=("-s") - elif [[ $current_selection == 8 ]]; then - update_selection+=("-p") - fi + clear -x + title + echo "--Choose your update options--" + echo + echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" + echo "2) -i | Add application to ignore list, one by one, see example below." + echo "3) -r | Roll-back applications if they fail to update" + echo "4) -S | Shutdown applications prior to updating" + echo "5) -v | verbose output" + echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo "7) -s | sync catalog" + echo "8) -p | Prune unused/old docker images" + echo + echo "0) Done making selections, proceed with update" + echo + read -rt 600 -p "Please type the number associated with the flag above: " current_selection + if [[ $current_selection == 0 ]]; then + exec bash "$script_name" "${update_selection[@]}" + exit + elif [[ $current_selection == 1 ]]; then + echo "Up to how many backups should we keep?" + read -rt 600 -p "Please type an integer: " up_backups + update_selection+=("-b" "$up_backups") + elif [[ $current_selection == 2 ]]; then + read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + update_selection+=("-i" "$up_ignore") + elif [[ $current_selection == 3 ]]; then + update_selection+=("-r") + elif [[ $current_selection == 4 ]]; then + update_selection+=("-S") + elif [[ $current_selection == 5 ]]; then + update_selection+=("-v") + elif [[ $current_selection == 6 ]]; then + echo "What do you want your timeout to be?" + read -rt 600 -p "Please type an integer: " up_timeout + update_selection+=("-t" "$up_timeout") + elif [[ $current_selection == 7 ]]; then + update_selection+=("-s") + elif [[ $current_selection == 8 ]]; then + update_selection+=("-p") + fi done ;; *) From 340b5b7e6dd2cd9ac27f4afeb8592cddd39d7471 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:44:29 -0600 Subject: [PATCH 280/823] formatting --- functions/menu.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 4c65a68e..bc79d7b8 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -53,7 +53,8 @@ menu(){ cd "$script_path" || exit clear -x title - echo "--Choose your update type--" + echo "Choose your update type" + echo "_______________________" echo "1) -U | Update all applications, ignores versions" echo "2) -u | Update all applications, does not update Major releases" echo @@ -79,8 +80,8 @@ menu(){ do clear -x title - echo "--Choose your update options--" - echo + echo "Choose your update options" + echo "__________________________" echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" echo "2) -i | Add application to ignore list, one by one, see example below." echo "3) -r | Roll-back applications if they fail to update" From 1b329c0661548a7733fdbebcb89f1519b4da7265 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 15:02:20 -0600 Subject: [PATCH 281/823] null --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index dcfcb1e0..28f111fb 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -128,6 +128,7 @@ do done + #exit if incompatable functions are called [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit From a748bb3fa5c1b1fe40ec0d603191b94538b11c09 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 15:06:30 -0600 Subject: [PATCH 282/823] version --- heavy_script.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heavy_script.sh b/heavy_script.sh index 28f111fb..9708cf1f 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Version 0.1 + # shellcheck source=functions/backup.sh source functions/backup.sh # shellcheck source=functions/dns.sh From 2e06b25dd62fd3f0934b5ef55ed88b3eaf1d7583 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:21:03 -0600 Subject: [PATCH 283/823] else statement --- functions/menu.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index bc79d7b8..ec2e57c9 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -117,7 +117,9 @@ menu(){ elif [[ $current_selection == 7 ]]; then update_selection+=("-s") elif [[ $current_selection == 8 ]]; then - update_selection+=("-p") + update_selection+=("-p") + else + echo "$current_selection was not an option, try again" fi done ;; From c9db9cfc3e2cdcaf4b1b0d441b5bd5f753b22a33 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:21:41 -0600 Subject: [PATCH 284/823] test self --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 024630d1..34319a4f 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -9,7 +9,7 @@ script_name="heavy_script.sh" cd "$script_path" || exit git fetch &> /dev/null -if git diff --name-only origin/beta | grep -q "$script_name" ; then +if git diff --name-only origin/beta ; then #| grep -q "$script_name" echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q From 5e6f6a7ea070f0d5b7829e59f92879d07935c269 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:23:41 -0600 Subject: [PATCH 285/823] test --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 34319a4f..197e5440 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -9,7 +9,7 @@ script_name="heavy_script.sh" cd "$script_path" || exit git fetch &> /dev/null -if git diff --name-only origin/beta ; then #| grep -q "$script_name" +if git diff --name-only origin/beta | grep -eq ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q From f907cf746a30d4f6f3db29076d90b58917e31176 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:24:22 -0600 Subject: [PATCH 286/823] quiet? --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 197e5440..c52875f5 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -9,7 +9,7 @@ script_name="heavy_script.sh" cd "$script_path" || exit git fetch &> /dev/null -if git diff --name-only origin/beta | grep -eq ".sh" ; then +if git diff --name-only origin/beta | grep -e -q ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q From f11e0a4fa74e61104fbfed7579f4810fabbec285 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:25:38 -0600 Subject: [PATCH 287/823] asd --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index c52875f5..93543752 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -9,7 +9,7 @@ script_name="heavy_script.sh" cd "$script_path" || exit git fetch &> /dev/null -if git diff --name-only origin/beta | grep -e -q ".sh" ; then +if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q From 47aaaac2729a2aed0112cd5828c38820ce48e7da Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:26:07 -0600 Subject: [PATCH 288/823] asd --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 93543752..b3678e2a 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -8,7 +8,7 @@ script_path=$(dirname "$script") script_name="heavy_script.sh" cd "$script_path" || exit git fetch &> /dev/null - +#update if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q From 929360806e973763266896b60a612d09023ea0b5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:26:43 -0600 Subject: [PATCH 289/823] test --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index b3678e2a..93543752 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -8,7 +8,7 @@ script_path=$(dirname "$script") script_name="heavy_script.sh" cd "$script_path" || exit git fetch &> /dev/null -#update + if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q From 7845b76d2b0274781b73a5dbc77425be3f4d95d0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:27:20 -0600 Subject: [PATCH 290/823] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 9708cf1f..4009f53c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,6 +1,5 @@ #!/bin/bash -# Version 0.1 # shellcheck source=functions/backup.sh source functions/backup.sh From 9df82d6cc995ece1d0ffa1b3d0ead11099a99188 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:28:35 -0600 Subject: [PATCH 291/823] format --- functions/menu.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index ec2e57c9..712d580a 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -53,8 +53,8 @@ menu(){ cd "$script_path" || exit clear -x title - echo "Choose your update type" - echo "_______________________" + echo "Choose Your Update Type" + echo "-----------------------" echo "1) -U | Update all applications, ignores versions" echo "2) -u | Update all applications, does not update Major releases" echo @@ -81,7 +81,7 @@ menu(){ clear -x title echo "Choose your update options" - echo "__________________________" + echo "--------------------------" echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" echo "2) -i | Add application to ignore list, one by one, see example below." echo "3) -r | Roll-back applications if they fail to update" From 8a2fd2a976c23c8fef70164d344f0f4c502dde71 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:35:31 -0600 Subject: [PATCH 292/823] regex --- functions/menu.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 712d580a..aa024a84 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -64,11 +64,9 @@ menu(){ if [[ $current_selection == 1 ]]; then echo -e "\nHow many applications do you want updating at the same time?" read -rt 600 -p "Please type an integer greater than 0: " up_async - update_selection+=("-U" "$up_async") elif [[ $current_selection == 2 ]]; then echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - update_selection+=("-u" "$up_async") + read -rt 600 -p "Please type an integer greater than 0: " up_async elif [[ $current_selection == 0 ]]; then echo "Exiting.." exit @@ -76,6 +74,15 @@ menu(){ echo "$current_selection was not an option, try again" exit fi + if [[ $up_async == 0 ]]; then + echo "0 was not an option.. exiting" + exit + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: $up_async is invalid, it needs to be an integer" + exit + else + update_selection+=("-u" "$up_async") + fi while true do clear -x From c44e09e300b06cce7cc19d3e1a27ea8bcf4484ed Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:36:16 -0600 Subject: [PATCH 293/823] quotation --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index aa024a84..ba34ac0d 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -78,7 +78,7 @@ menu(){ echo "0 was not an option.. exiting" exit elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: $up_async is invalid, it needs to be an integer" + echo "Error: \"$up_async\" is invalid, it needs to be an integer" exit else update_selection+=("-u" "$up_async") From dd14c6665c179f60a4b15dc84ae36409ad324251 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:45:52 -0600 Subject: [PATCH 294/823] input validation --- functions/menu.sh | 5 +++-- heavy_script.sh | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index ba34ac0d..90ba29dc 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -30,9 +30,8 @@ menu(){ ;; 4) read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups - re='^[0-9]+$' number_of_backups=$number_of_backups - ! [[ $number_of_backups =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit + ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit echo "Generating backup, please be patient for output.." backup "$number_of_backups" @@ -107,6 +106,7 @@ menu(){ elif [[ $current_selection == 1 ]]; then echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups + ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-b" "$up_backups") elif [[ $current_selection == 2 ]]; then read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore @@ -120,6 +120,7 @@ menu(){ elif [[ $current_selection == 6 ]]; then echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout + ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-t" "$up_timeout") elif [[ $current_selection == 7 ]]; then update_selection+=("-s") diff --git a/heavy_script.sh b/heavy_script.sh index 4009f53c..7dff535c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -56,9 +56,8 @@ do exit ;; b) - re='^[0-9]+$' number_of_backups=$OPTARG - ! [[ $OPTARG =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit + ! [[ $OPTARG =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit ;; r) @@ -77,9 +76,8 @@ do fi ;; t) - re='^[0-9]+$' timeout=$OPTARG - ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n\"""$timeout""\" is not an interger" >&2 && exit + ! [[ $timeout =~ ^[0-9]+$ ]] && echo -e "Error: -t needs to be assigned an interger\n\"""$timeout""\" is not an interger" >&2 && exit ;; s) sync="true" From cdf7bf640152615c820d2b647ec8cd063d4eafe4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:49:23 -0600 Subject: [PATCH 295/823] check for 0 backups --- functions/menu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/menu.sh b/functions/menu.sh index 90ba29dc..7821c7aa 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -107,6 +107,7 @@ menu(){ echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-b" "$up_backups") elif [[ $current_selection == 2 ]]; then read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore From b286877af0d4b2eb8d7f32139d4f296882926b3d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:52:32 -0600 Subject: [PATCH 296/823] print current selection --- functions/menu.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index 7821c7aa..35ae5f4d 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -100,6 +100,11 @@ menu(){ echo "0) Done making selections, proceed with update" echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection + + for i in "${current_selection[@]}" + do + echo "$i" + done if [[ $current_selection == 0 ]]; then exec bash "$script_name" "${update_selection[@]}" exit From 366fbb089821dd36e109ca544e6aabba03e02965 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:54:46 -0600 Subject: [PATCH 297/823] fix --- functions/menu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 35ae5f4d..304c2cd1 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -101,7 +101,7 @@ menu(){ echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection - for i in "${current_selection[@]}" + for i in "${update_selection[@]}" do echo "$i" done @@ -133,7 +133,7 @@ menu(){ elif [[ $current_selection == 8 ]]; then update_selection+=("-p") else - echo "$current_selection was not an option, try again" + echo "$current_selection was not an option, try again" && sleep 5 && continue fi done ;; From 194500bbf0a3fbb637470cf6a8bfb7df9e7c376c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:01:00 -0600 Subject: [PATCH 298/823] test --- functions/menu.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 304c2cd1..d6296e10 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -99,12 +99,15 @@ menu(){ echo echo "0) Done making selections, proceed with update" echo - read -rt 600 -p "Please type the number associated with the flag above: " current_selection - + echo "Current Choices" + echo "---------------" for i in "${update_selection[@]}" do echo "$i" done + read -rt 600 -p "Please type the number associated with the flag above: " current_selection + + if [[ $current_selection == 0 ]]; then exec bash "$script_name" "${update_selection[@]}" exit From e965e5c3cdd9cf663ddbbcfeadc3ac880a693d1a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:04:39 -0600 Subject: [PATCH 299/823] new list array --- functions/menu.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index d6296e10..ffb3790d 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -101,10 +101,11 @@ menu(){ echo echo "Current Choices" echo "---------------" - for i in "${update_selection[@]}" + for i in "${update_list[@]}" do echo "$i" done + echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection @@ -116,24 +117,32 @@ menu(){ read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue + update_list+=("-b $up_backups") update_selection+=("-b" "$up_backups") elif [[ $current_selection == 2 ]]; then read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + update_list+=("-b $up_ignore") update_selection+=("-i" "$up_ignore") elif [[ $current_selection == 3 ]]; then + update_list+=("-r") update_selection+=("-r") elif [[ $current_selection == 4 ]]; then + update_list+=("-S") update_selection+=("-S") elif [[ $current_selection == 5 ]]; then + update_list+=("-v") update_selection+=("-v") elif [[ $current_selection == 6 ]]; then echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + update_list+=("-t $up_timeout") update_selection+=("-t" "$up_timeout") elif [[ $current_selection == 7 ]]; then + update_list+=("-s") update_selection+=("-s") elif [[ $current_selection == 8 ]]; then + update_list+=("-p") update_selection+=("-p") else echo "$current_selection was not an option, try again" && sleep 5 && continue From 0fb6383ce5d10b2973cc62e4a1f8dc4c3e25087d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:07:01 -0600 Subject: [PATCH 300/823] test --- functions/menu.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index ffb3790d..9c25d271 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -81,6 +81,7 @@ menu(){ exit else update_selection+=("-u" "$up_async") + update_list+=("-u") fi while true do @@ -101,14 +102,10 @@ menu(){ echo echo "Current Choices" echo "---------------" - for i in "${update_list[@]}" - do - echo "$i" - done + echo "${update_list[*]}" echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection - if [[ $current_selection == 0 ]]; then exec bash "$script_name" "${update_selection[@]}" exit @@ -121,7 +118,7 @@ menu(){ update_selection+=("-b" "$up_backups") elif [[ $current_selection == 2 ]]; then read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - update_list+=("-b $up_ignore") + update_list+=("-i $up_ignore") update_selection+=("-i" "$up_ignore") elif [[ $current_selection == 3 ]]; then update_list+=("-r") From 3d151ed8578f214988c1be67f3b4fafa8ca37b59 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:28:51 -0600 Subject: [PATCH 301/823] testing --- functions/menu.sh | 89 +++++++++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 33 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 9c25d271..cef8c1d0 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -50,39 +50,62 @@ menu(){ script_path=$(dirname "$script") script_name="heavy_script.sh" cd "$script_path" || exit - clear -x - title - echo "Choose Your Update Type" - echo "-----------------------" - echo "1) -U | Update all applications, ignores versions" - echo "2) -u | Update all applications, does not update Major releases" - echo - echo "0) Exit" - echo - read -rt 600 -p "Please type the number associated with the flag above: " current_selection - if [[ $current_selection == 1 ]]; then - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - elif [[ $current_selection == 2 ]]; then - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - elif [[ $current_selection == 0 ]]; then - echo "Exiting.." - exit - else - echo "$current_selection was not an option, try again" - exit - fi - if [[ $up_async == 0 ]]; then - echo "0 was not an option.. exiting" - exit - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - exit - else - update_selection+=("-u" "$up_async") - update_list+=("-u") - fi + while true + do + clear -x + title + echo "Choose Your Update Type" + echo "-----------------------" + echo "1) -U | Update all applications, ignores versions" + echo "2) -u | Update all applications, does not update Major releases" + echo + echo "0) Exit" + echo + read -rt 600 -p "Please type the number associated with the flag above: " current_selection + if [[ $current_selection == 1 ]]; then + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 5 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 5 + continue + else + update_selection+=("-U" "$up_async") + update_list+=("-U") + break + fi + elif [[ $current_selection == 2 ]]; then + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 5 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 5 + continue + else + update_selection+=("-u" "$up_async") + update_list+=("-u") + break + fi + elif [[ $current_selection == 0 ]]; then + echo "Exiting.." + exit + else + echo "$current_selection was not an option, try again" + exit + fi + done while true do clear -x From 681c0eb7c9e7364eb9a31bf1f21769cf58af8d9a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:29:51 -0600 Subject: [PATCH 302/823] test --- functions/menu.sh | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index cef8c1d0..6616091a 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -77,7 +77,6 @@ menu(){ continue else update_selection+=("-U" "$up_async") - update_list+=("-U") break fi elif [[ $current_selection == 2 ]]; then @@ -95,7 +94,6 @@ menu(){ continue else update_selection+=("-u" "$up_async") - update_list+=("-u") break fi elif [[ $current_selection == 0 ]]; then @@ -125,7 +123,7 @@ menu(){ echo echo "Current Choices" echo "---------------" - echo "${update_list[*]}" + echo "${update_selection[*]}" echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection @@ -137,32 +135,32 @@ menu(){ read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue - update_list+=("-b $up_backups") + update_selection+=("-b" "$up_backups") elif [[ $current_selection == 2 ]]; then read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - update_list+=("-i $up_ignore") + update_selection+=("-i" "$up_ignore") elif [[ $current_selection == 3 ]]; then - update_list+=("-r") + update_selection+=("-r") elif [[ $current_selection == 4 ]]; then - update_list+=("-S") + update_selection+=("-S") elif [[ $current_selection == 5 ]]; then - update_list+=("-v") + update_selection+=("-v") elif [[ $current_selection == 6 ]]; then echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - update_list+=("-t $up_timeout") + update_selection+=("-t" "$up_timeout") elif [[ $current_selection == 7 ]]; then - update_list+=("-s") + update_selection+=("-s") elif [[ $current_selection == 8 ]]; then - update_list+=("-p") + update_selection+=("-p") else echo "$current_selection was not an option, try again" && sleep 5 && continue From bd5569457be112ab4a126c84d216aa32acbb1e2c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:30:54 -0600 Subject: [PATCH 303/823] QOL --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 6616091a..188bd13e 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -123,7 +123,7 @@ menu(){ echo echo "Current Choices" echo "---------------" - echo "${update_selection[*]}" + echo "bash heavy_script.sh ${update_selection[*]}" echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection From 882f4033c995977399ff7d18b57b787cc1febc5b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:43:06 -0600 Subject: [PATCH 304/823] polish messages --- functions/backup.sh | 2 +- functions/menu.sh | 2 ++ functions/misc.sh | 2 +- heavy_script.sh | 5 ++++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 03c0003b..a4eff30b 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -8,7 +8,7 @@ date=$(date '+%Y_%m_%d_%H_%M_%S') [[ -z "$verbose" ]] && echo_backup+=("\nNew Backup Name:") && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 &> /dev/null && echo_backup+=(HeavyScript_"$date") mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then - echo_backup+=("\nDeleting the oldest backup(s) for exceeding limit:") + echo_backup+=("\nDeleted the oldest backup(s) for exceeding limit:") overflow=$(( ${#list_backups[@]} - "$number_of_backups" )) mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") for i in "${list_overflow[@]}" diff --git a/functions/menu.sh b/functions/menu.sh index 188bd13e..acb24d7c 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -128,6 +128,8 @@ menu(){ read -rt 600 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 0 ]]; then + clear -x + echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" exec bash "$script_name" "${update_selection[@]}" exit elif [[ $current_selection == 1 ]]; then diff --git a/functions/misc.sh b/functions/misc.sh index 8fcdbbed..e6439e9f 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -2,7 +2,7 @@ sync(){ -echo_sync+=("\nSyncing all catalogs, please wait..") && cli -c 'app catalog sync_all' &> /dev/null && echo_sync+=("Catalog sync complete") +cli -c 'app catalog sync_all' &> /dev/null && echo_sync+=("Catalog sync complete") #Dump the echo_array, ensures all output is in a neat order. for i in "${echo_sync[@]}" diff --git a/heavy_script.sh b/heavy_script.sh index 7dff535c..ce8742ce 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -139,7 +139,10 @@ done [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync at the same time - echo -e "Backing up and syncing catalogs at the same time, please wait for output..\n" + echo "Running the following two tasks at the same time" + echo "------------------------------------------------" + echo -e "Backing up ix-applications dataset\nSyncing catalog(s)" + echo -e "This can take a LONG time, please wait for the output..\n" backup & sync & wait From 85eb4a17a1771c10466941f79b412e9a24cb9ecc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:53:08 -0600 Subject: [PATCH 305/823] Titles --- functions/backup.sh | 4 +++- functions/menu.sh | 1 + functions/misc.sh | 7 ++++++- functions/update_apps.sh | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index a4eff30b..f2221932 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -2,7 +2,9 @@ backup(){ -echo_backup+=("\nNumber of backups was set to $number_of_backups") +echo_backup+=("\nBackup Output") +echo_backup+=("--------------") +echo_backup+=("Number of backups was set to $number_of_backups") date=$(date '+%Y_%m_%d_%H_%M_%S') [[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' &> /dev/null && echo_backup+=(HeavyScript_"$date") [[ -z "$verbose" ]] && echo_backup+=("\nNew Backup Name:") && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 &> /dev/null && echo_backup+=(HeavyScript_"$date") diff --git a/functions/menu.sh b/functions/menu.sh index acb24d7c..440c3f29 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -130,6 +130,7 @@ menu(){ if [[ $current_selection == 0 ]]; then clear -x echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" + echo exec bash "$script_name" "${update_selection[@]}" exit elif [[ $current_selection == 1 ]]; then diff --git a/functions/misc.sh b/functions/misc.sh index e6439e9f..96ca57e1 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -2,6 +2,8 @@ sync(){ +echo_sync+=("\nSync Output") +echo_sync+=("-----------") cli -c 'app catalog sync_all' &> /dev/null && echo_sync+=("Catalog sync complete") #Dump the echo_array, ensures all output is in a neat order. @@ -13,7 +15,10 @@ done export -f sync prune(){ -echo -e "\nPruning Docker Images" && docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" +echo -e "\nDocker Prune Output" +echo "-------------------" +echo "Pruned Docker Images" +docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" } export -f prune diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 4664de1b..f036f3f9 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -3,6 +3,8 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) +echo "Aplication Update Output" +echo "------------------------" [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" From 9aa6e15f4e8b142aa41aa5238bd977ac3ee95614 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:58:02 -0600 Subject: [PATCH 306/823] formatting --- functions/menu.sh | 4 ++-- functions/update_apps.sh | 2 +- heavy_script.sh | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 440c3f29..bf7157c8 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -108,7 +108,7 @@ menu(){ do clear -x title - echo "Choose your update options" + echo "Choose Your Update Options" echo "--------------------------" echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" echo "2) -i | Add application to ignore list, one by one, see example below." @@ -174,6 +174,6 @@ menu(){ echo "Unknown option" && exit 1 ;; esac - echo "" + echo } export -f menu \ No newline at end of file diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f036f3f9..6ea07838 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -3,7 +3,7 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) -echo "Aplication Update Output" +echo -e "\nAplication Update Output" echo "------------------------" [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" diff --git a/heavy_script.sh b/heavy_script.sh index ce8742ce..ac4e4e48 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -147,7 +147,7 @@ if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync & wait fi -[[ "$number_of_backups" -ge 1 && -z "$sync" ]] && echo "Please wait for output, this could take a while.." && backup -[[ "$sync" == "true" && "$number_of_backups" -lt 1 ]] && echo "Please wait for output, this could take a while.." && sync +[[ "$number_of_backups" -ge 1 && -z "$sync" ]] && echo "Backing up \"ix-applications\" dataset, please wait.." && backup +[[ "$sync" == "true" && "$number_of_backups" -lt 1 ]] && echo "Syncing catalogs, this takes a LONG time, please wait.." && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander [[ "$prune" == "true" ]] && prune From ac95a304d7722f35d67a8db890f49f58c8cca85f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:00:03 -0600 Subject: [PATCH 307/823] more formatting --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 6ea07838..ce642ff2 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -5,8 +5,8 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) echo -e "\nAplication Update Output" echo "------------------------" -[[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" -[[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" +[[ -z $array ]] && echo "There are no updates available" && return 0 || echo "${#array[@]} update(s) available" +[[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" echo "Asynchronous Updates: $update_limit" From 61a591f0230c98fb337fc645deac999a38df4ee8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:16:56 -0600 Subject: [PATCH 308/823] while loop for menu test --- functions/menu.sh | 335 ++++++++++++++++++++------------------- functions/update_apps.sh | 1 - 2 files changed, 172 insertions(+), 164 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index bf7157c8..2091e1d4 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -1,179 +1,188 @@ #!/bin/bash menu(){ - clear -x - title - echo "1) Help" - echo "2) List DNS Names" - echo "3) Mount and Unmount PVC storage" - echo "4) Create a Backup" - echo "5) Restore a Backup" - echo "6) Delete a Backup" - echo "7) Update HeavyScript" - echo "8) Update Applications" - echo - echo "0) Exit" - read -rt 600 -p "Please select an option by number: " selection - - case $selection in - 0) - exit - ;; - 1) - help="true" - ;; - 2) - dns="true" - ;; - 3) - mount="true" - ;; - 4) - read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups - number_of_backups=$number_of_backups - ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit - [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit - echo "Generating backup, please be patient for output.." - backup "$number_of_backups" - ;; - 5) - restore="true" - ;; - 6) - deleteBackup="true" - ;; - 7) - self_update="true" - ;; - 8) - script=$(readlink -f "$0") - script_path=$(dirname "$script") - script_name="heavy_script.sh" - cd "$script_path" || exit - while true - do - clear -x - title - echo "Choose Your Update Type" - echo "-----------------------" - echo "1) -U | Update all applications, ignores versions" - echo "2) -u | Update all applications, does not update Major releases" - echo - echo "0) Exit" - echo - read -rt 600 -p "Please type the number associated with the flag above: " current_selection - if [[ $current_selection == 1 ]]; then - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 5 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 5 - continue - else - update_selection+=("-U" "$up_async") - break - fi - elif [[ $current_selection == 2 ]]; then - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 5 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 5 - continue - else - update_selection+=("-u" "$up_async") - break - fi - elif [[ $current_selection == 0 ]]; then - echo "Exiting.." + clear -x + title + echo "1) Help" + echo "2) List DNS Names" + echo "3) Mount and Unmount PVC storage" + echo "4) Create a Backup" + echo "5) Restore a Backup" + echo "6) Delete a Backup" + echo "7) Update HeavyScript" + echo "8) Update Applications" + echo + echo "0) Exit" + read -rt 600 -p "Please select an option by number: " selection + while true + do + case $selection in + 0) exit - else - echo "$current_selection was not an option, try again" + ;; + 1) + help="true" exit - fi - done - while true - do - clear -x - title - echo "Choose Your Update Options" - echo "--------------------------" - echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" - echo "2) -i | Add application to ignore list, one by one, see example below." - echo "3) -r | Roll-back applications if they fail to update" - echo "4) -S | Shutdown applications prior to updating" - echo "5) -v | verbose output" - echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" - echo "7) -s | sync catalog" - echo "8) -p | Prune unused/old docker images" - echo - echo "0) Done making selections, proceed with update" - echo - echo "Current Choices" - echo "---------------" - echo "bash heavy_script.sh ${update_selection[*]}" - echo - read -rt 600 -p "Please type the number associated with the flag above: " current_selection - - if [[ $current_selection == 0 ]]; then - clear -x - echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" - echo - exec bash "$script_name" "${update_selection[@]}" + ;; + 2) + dns="true" exit - elif [[ $current_selection == 1 ]]; then - echo "Up to how many backups should we keep?" - read -rt 600 -p "Please type an integer: " up_backups - ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue + ;; + 3) + mount="true" + exit + ;; + 4) + read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups + number_of_backups=$number_of_backups + ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit + [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit + echo "Generating backup, please be patient for output.." + backup "$number_of_backups" + ;; + 5) + restore="true" + exit + ;; + 6) + deleteBackup="true" + exit + ;; + 7) + self_update="true" + exit + ;; + 8) + script=$(readlink -f "$0") + script_path=$(dirname "$script") + script_name="heavy_script.sh" + cd "$script_path" || exit + while true + do + clear -x + title + echo "Choose Your Update Type" + echo "-----------------------" + echo "1) -U | Update all applications, ignores versions" + echo "2) -u | Update all applications, does not update Major releases" + echo + echo "0) Exit" + echo + read -rt 600 -p "Please type the number associated with the flag above: " current_selection + if [[ $current_selection == 1 ]]; then + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 5 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 5 + continue + else + update_selection+=("-U" "$up_async") + break + fi + elif [[ $current_selection == 2 ]]; then + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 5 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 5 + continue + else + update_selection+=("-u" "$up_async") + break + fi + elif [[ $current_selection == 0 ]]; then + echo "Exiting.." + exit + else + echo "$current_selection was not an option, try again" + exit + fi + done + while true + do + clear -x + title + echo "Choose Your Update Options" + echo "--------------------------" + echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" + echo "2) -i | Add application to ignore list, one by one, see example below." + echo "3) -r | Roll-back applications if they fail to update" + echo "4) -S | Shutdown applications prior to updating" + echo "5) -v | verbose output" + echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo "7) -s | sync catalog" + echo "8) -p | Prune unused/old docker images" + echo + echo "0) Done making selections, proceed with update" + echo + echo "Current Choices" + echo "---------------" + echo "bash heavy_script.sh ${update_selection[*]}" + echo + read -rt 600 -p "Please type the number associated with the flag above: " current_selection - update_selection+=("-b" "$up_backups") - elif [[ $current_selection == 2 ]]; then - read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + if [[ $current_selection == 0 ]]; then + clear -x + echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" + echo + exec bash "$script_name" "${update_selection[@]}" + exit + elif [[ $current_selection == 1 ]]; then + echo "Up to how many backups should we keep?" + read -rt 600 -p "Please type an integer: " up_backups + ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue - update_selection+=("-i" "$up_ignore") - elif [[ $current_selection == 3 ]]; then + update_selection+=("-b" "$up_backups") + elif [[ $current_selection == 2 ]]; then + read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - update_selection+=("-r") - elif [[ $current_selection == 4 ]]; then + update_selection+=("-i" "$up_ignore") + elif [[ $current_selection == 3 ]]; then - update_selection+=("-S") - elif [[ $current_selection == 5 ]]; then + update_selection+=("-r") + elif [[ $current_selection == 4 ]]; then - update_selection+=("-v") - elif [[ $current_selection == 6 ]]; then - echo "What do you want your timeout to be?" - read -rt 600 -p "Please type an integer: " up_timeout - ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + update_selection+=("-S") + elif [[ $current_selection == 5 ]]; then - update_selection+=("-t" "$up_timeout") - elif [[ $current_selection == 7 ]]; then + update_selection+=("-v") + elif [[ $current_selection == 6 ]]; then + echo "What do you want your timeout to be?" + read -rt 600 -p "Please type an integer: " up_timeout + ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - update_selection+=("-s") - elif [[ $current_selection == 8 ]]; then + update_selection+=("-t" "$up_timeout") + elif [[ $current_selection == 7 ]]; then - update_selection+=("-p") - else - echo "$current_selection was not an option, try again" && sleep 5 && continue - fi - done - ;; - *) - echo "Unknown option" && exit 1 - ;; - esac - echo + update_selection+=("-s") + elif [[ $current_selection == 8 ]]; then + + update_selection+=("-p") + else + echo "$current_selection was not an option, try again" && sleep 5 && continue + fi + done + exit + ;; + *) + echo "That was not an option, please try again" && sleep 5 + ;; + esac + echo + done } export -f menu \ No newline at end of file diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ce642ff2..320a0351 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -19,7 +19,6 @@ do do kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } done - #jobs=$(jobs -p | wc -l) if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 1 else From 5a325d210ac8a279f7875c738de747b07f0f31e3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:18:20 -0600 Subject: [PATCH 309/823] test --- functions/menu.sh | 2 +- functions/update_apps.sh | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 2091e1d4..6aec0511 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -179,7 +179,7 @@ menu(){ exit ;; *) - echo "That was not an option, please try again" && sleep 5 + echo "That was not an option, please try again" && sleep 5 && menu ;; esac echo diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 320a0351..d1abed7e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,8 +32,6 @@ for proc in "${processes[@]}" do wait "$proc" done - - } export -f commander From 987bc9812cea18ab87626e45ec378db580cb0f91 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:19:01 -0600 Subject: [PATCH 310/823] test --- functions/menu.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 6aec0511..be39eb69 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -22,15 +22,12 @@ menu(){ ;; 1) help="true" - exit ;; 2) dns="true" - exit ;; 3) mount="true" - exit ;; 4) read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups @@ -42,15 +39,12 @@ menu(){ ;; 5) restore="true" - exit ;; 6) deleteBackup="true" - exit ;; 7) self_update="true" - exit ;; 8) script=$(readlink -f "$0") From 8b0b8393a1b75bef3c62ee90d23fe70f25a81d55 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:21:45 -0600 Subject: [PATCH 311/823] test --- functions/menu.sh | 347 +++++++++++++++++++++++----------------------- 1 file changed, 172 insertions(+), 175 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index be39eb69..4028433e 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -1,182 +1,179 @@ #!/bin/bash menu(){ - clear -x - title - echo "1) Help" - echo "2) List DNS Names" - echo "3) Mount and Unmount PVC storage" - echo "4) Create a Backup" - echo "5) Restore a Backup" - echo "6) Delete a Backup" - echo "7) Update HeavyScript" - echo "8) Update Applications" - echo - echo "0) Exit" - read -rt 600 -p "Please select an option by number: " selection - while true - do - case $selection in - 0) + clear -x + title + echo "1) Help" + echo "2) List DNS Names" + echo "3) Mount and Unmount PVC storage" + echo "4) Create a Backup" + echo "5) Restore a Backup" + echo "6) Delete a Backup" + echo "7) Update HeavyScript" + echo "8) Update Applications" + echo + echo "0) Exit" + read -rt 600 -p "Please select an option by number: " selection + + case $selection in + 0) + exit + ;; + 1) + help="true" + ;; + 2) + dns="true" + ;; + 3) + mount="true" + ;; + 4) + read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups + number_of_backups=$number_of_backups + ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit + [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit + echo "Generating backup, please be patient for output.." + backup "$number_of_backups" + ;; + 5) + restore="true" + ;; + 6) + deleteBackup="true" + ;; + 7) + self_update="true" + ;; + 8) + script=$(readlink -f "$0") + script_path=$(dirname "$script") + script_name="heavy_script.sh" + cd "$script_path" || exit + while true + do + clear -x + title + echo "Choose Your Update Type" + echo "-----------------------" + echo "1) -U | Update all applications, ignores versions" + echo "2) -u | Update all applications, does not update Major releases" + echo + echo "0) Exit" + echo + read -rt 600 -p "Please type the number associated with the flag above: " current_selection + if [[ $current_selection == 1 ]]; then + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 5 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 5 + continue + else + update_selection+=("-U" "$up_async") + break + fi + elif [[ $current_selection == 2 ]]; then + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 5 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 5 + continue + else + update_selection+=("-u" "$up_async") + break + fi + elif [[ $current_selection == 0 ]]; then + echo "Exiting.." exit - ;; - 1) - help="true" - ;; - 2) - dns="true" - ;; - 3) - mount="true" - ;; - 4) - read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups - number_of_backups=$number_of_backups - ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit - [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit - echo "Generating backup, please be patient for output.." - backup "$number_of_backups" - ;; - 5) - restore="true" - ;; - 6) - deleteBackup="true" - ;; - 7) - self_update="true" - ;; - 8) - script=$(readlink -f "$0") - script_path=$(dirname "$script") - script_name="heavy_script.sh" - cd "$script_path" || exit - while true - do - clear -x - title - echo "Choose Your Update Type" - echo "-----------------------" - echo "1) -U | Update all applications, ignores versions" - echo "2) -u | Update all applications, does not update Major releases" - echo - echo "0) Exit" - echo - read -rt 600 -p "Please type the number associated with the flag above: " current_selection - if [[ $current_selection == 1 ]]; then - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 5 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 5 - continue - else - update_selection+=("-U" "$up_async") - break - fi - elif [[ $current_selection == 2 ]]; then - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 5 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 5 - continue - else - update_selection+=("-u" "$up_async") - break - fi - elif [[ $current_selection == 0 ]]; then - echo "Exiting.." - exit - else - echo "$current_selection was not an option, try again" - exit - fi - done - while true - do - clear -x - title - echo "Choose Your Update Options" - echo "--------------------------" - echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" - echo "2) -i | Add application to ignore list, one by one, see example below." - echo "3) -r | Roll-back applications if they fail to update" - echo "4) -S | Shutdown applications prior to updating" - echo "5) -v | verbose output" - echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" - echo "7) -s | sync catalog" - echo "8) -p | Prune unused/old docker images" - echo - echo "0) Done making selections, proceed with update" - echo - echo "Current Choices" - echo "---------------" - echo "bash heavy_script.sh ${update_selection[*]}" - echo - read -rt 600 -p "Please type the number associated with the flag above: " current_selection - - if [[ $current_selection == 0 ]]; then - clear -x - echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" - echo - exec bash "$script_name" "${update_selection[@]}" - exit - elif [[ $current_selection == 1 ]]; then - echo "Up to how many backups should we keep?" - read -rt 600 -p "Please type an integer: " up_backups - ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue - - update_selection+=("-b" "$up_backups") - elif [[ $current_selection == 2 ]]; then - read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - - update_selection+=("-i" "$up_ignore") - elif [[ $current_selection == 3 ]]; then - - update_selection+=("-r") - elif [[ $current_selection == 4 ]]; then - - update_selection+=("-S") - elif [[ $current_selection == 5 ]]; then - - update_selection+=("-v") - elif [[ $current_selection == 6 ]]; then - echo "What do you want your timeout to be?" - read -rt 600 -p "Please type an integer: " up_timeout - ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - - update_selection+=("-t" "$up_timeout") - elif [[ $current_selection == 7 ]]; then - - update_selection+=("-s") - elif [[ $current_selection == 8 ]]; then - - update_selection+=("-p") - else - echo "$current_selection was not an option, try again" && sleep 5 && continue - fi - done + else + echo "$current_selection was not an option, try again" exit - ;; - *) - echo "That was not an option, please try again" && sleep 5 && menu - ;; - esac - echo - done + fi + done + while true + do + clear -x + title + echo "Choose Your Update Options" + echo "--------------------------" + echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" + echo "2) -i | Add application to ignore list, one by one, see example below." + echo "3) -r | Roll-back applications if they fail to update" + echo "4) -S | Shutdown applications prior to updating" + echo "5) -v | verbose output" + echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo "7) -s | sync catalog" + echo "8) -p | Prune unused/old docker images" + echo + echo "0) Done making selections, proceed with update" + echo + echo "Current Choices" + echo "---------------" + echo "bash heavy_script.sh ${update_selection[*]}" + echo + read -rt 600 -p "Please type the number associated with the flag above: " current_selection + + if [[ $current_selection == 0 ]]; then + clear -x + echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" + echo + exec bash "$script_name" "${update_selection[@]}" + exit + elif [[ $current_selection == 1 ]]; then + echo "Up to how many backups should we keep?" + read -rt 600 -p "Please type an integer: " up_backups + ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue + + update_selection+=("-b" "$up_backups") + elif [[ $current_selection == 2 ]]; then + read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + + update_selection+=("-i" "$up_ignore") + elif [[ $current_selection == 3 ]]; then + + update_selection+=("-r") + elif [[ $current_selection == 4 ]]; then + + update_selection+=("-S") + elif [[ $current_selection == 5 ]]; then + + update_selection+=("-v") + elif [[ $current_selection == 6 ]]; then + echo "What do you want your timeout to be?" + read -rt 600 -p "Please type an integer: " up_timeout + ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + + update_selection+=("-t" "$up_timeout") + elif [[ $current_selection == 7 ]]; then + + update_selection+=("-s") + elif [[ $current_selection == 8 ]]; then + + update_selection+=("-p") + else + echo "$current_selection was not an option, try again" && sleep 5 && continue + fi + done + ;; + *) + echo "That was not an option, please try agian" && menu + ;; + esac + echo } export -f menu \ No newline at end of file From 939ce2f7312b8e44f7c2fa1c2e40fd894f6980fd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:22:19 -0600 Subject: [PATCH 312/823] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 4028433e..6c36be3d 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -171,7 +171,7 @@ menu(){ done ;; *) - echo "That was not an option, please try agian" && menu + echo "That was not an option, please try agian" && sleep 5 && menu ;; esac echo From 46184a772201512086221baf303a94e41de491a3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:28:23 -0600 Subject: [PATCH 313/823] fix backups --- functions/menu.sh | 1 + heavy_script.sh | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 6c36be3d..595c0444 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -34,6 +34,7 @@ menu(){ ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit echo "Generating backup, please be patient for output.." + menu_backup="true" backup "$number_of_backups" ;; 5) diff --git a/heavy_script.sh b/heavy_script.sh index ac4e4e48..db3cb062 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -56,6 +56,7 @@ do exit ;; b) + backup="true" number_of_backups=$OPTARG ! [[ $OPTARG =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit @@ -138,7 +139,7 @@ done [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit -if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync at the same time +if [[ "$backup" == "true" && "$sync" == "true" ]]; then # Run backup and sync at the same time echo "Running the following two tasks at the same time" echo "------------------------------------------------" echo -e "Backing up ix-applications dataset\nSyncing catalog(s)" @@ -147,7 +148,7 @@ if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync & wait fi -[[ "$number_of_backups" -ge 1 && -z "$sync" ]] && echo "Backing up \"ix-applications\" dataset, please wait.." && backup -[[ "$sync" == "true" && "$number_of_backups" -lt 1 ]] && echo "Syncing catalogs, this takes a LONG time, please wait.." && sync +[[ "$backup" == "true" && -z "$sync" ]] && echo "Backing up \"ix-applications\" dataset, please wait.." && backup +[[ "$sync" == "true" && -z "$backup" ]] && echo "Syncing catalogs, this takes a LONG time, please wait.." && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander [[ "$prune" == "true" ]] && prune From 13a2a2f8b2a3b77469ad90c097d889afc25d8aa6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:32:35 -0600 Subject: [PATCH 314/823] fix delete backup --- functions/menu.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 595c0444..6d405efb 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -1,6 +1,10 @@ #!/bin/bash menu(){ + script=$(readlink -f "$0") + script_path=$(dirname "$script") + script_name="heavy_script.sh" + cd "$script_path" || exit clear -x title echo "1) Help" @@ -42,15 +46,13 @@ menu(){ ;; 6) deleteBackup="true" + exec bash "$script_name" --restore + exit ;; 7) self_update="true" ;; 8) - script=$(readlink -f "$0") - script_path=$(dirname "$script") - script_name="heavy_script.sh" - cd "$script_path" || exit while true do clear -x From 065a809da3467273decf2205766dcdc7bf4ba119 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:33:58 -0600 Subject: [PATCH 315/823] woops lol --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 6d405efb..3466b84d 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -46,7 +46,7 @@ menu(){ ;; 6) deleteBackup="true" - exec bash "$script_name" --restore + exec bash "$script_name" --delete-backup exit ;; 7) From 27bf546869f2bba69b4ea327e46b73e934cac4ad Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:36:08 -0600 Subject: [PATCH 316/823] uhh --- functions/menu.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 3466b84d..75618d27 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -46,8 +46,6 @@ menu(){ ;; 6) deleteBackup="true" - exec bash "$script_name" --delete-backup - exit ;; 7) self_update="true" From c2002979a8613f8699c67ddf9c79a2edd9c7db99 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:37:34 -0600 Subject: [PATCH 317/823] test --- functions/menu.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 75618d27..f4fe1dc7 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -45,7 +45,8 @@ menu(){ restore="true" ;; 6) - deleteBackup="true" + exec bash "$script_name" --delete-backup + exit ;; 7) self_update="true" From 88ba5b18af49d2a6a06ea7f7163f270dd678efd4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:40:07 -0600 Subject: [PATCH 318/823] no idea --- functions/menu.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index f4fe1dc7..75618d27 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -45,8 +45,7 @@ menu(){ restore="true" ;; 6) - exec bash "$script_name" --delete-backup - exit + deleteBackup="true" ;; 7) self_update="true" From 3f73c98fbec492285e4aa1a37be587aac2e4cb4e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:40:57 -0600 Subject: [PATCH 319/823] test --- functions/backup.sh | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index f2221932..fc81dce3 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -34,22 +34,12 @@ deleteBackup(){ clear -x && echo "pulling all restore points.." list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) clear -x -[[ -z "$list_backups" ]] && echo "No restore points available" && exit -title -echo -e "Choose a restore point to delete\nThese may be out of order if they are not all HeavyScript backups" -echo "$list_backups" -read -pr -t 600 "Please type a number: " selection -restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') -if [[ -z "$selection" ]]; then #Check for valid selection. If none, kill script - echo "Your selection cannot be empty" - exit -elif [[ -z "$restore_point" ]]; then #Check for valid selection. If none, kill script - echo "Invalid Selection: $selection, was not an option" - exit -fi -echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" -echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" -read -rp -t 120 "Please type a number: " yesno || { echo "Failed to make a valid selection"; exit; } +[[ -z "$list_backups" ]] && echo "No restore points available" && exit || { title; echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" ; } +echo "$list_backups" && read -t 600 -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') +[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script +[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script +echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" || { echo "FAILED"; exit; } +echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -t 120 -p "Please type a number: " yesno || { echo "FAILED"; exit; } if [[ $yesno == "1" ]]; then echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo "Sucessfully deleted" || echo "Deletion Failed" elif [[ $yesno == "2" ]]; then From e459cce2413da0fcf92c4127cf874fb0579d0594 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:44:55 -0600 Subject: [PATCH 320/823] update readme --- README.md | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index f7717f6e..bcfb7e7a 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ | Flag | Example | Parameter | Description | |----------------- |------------------------ |----------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| --self-update | --self-update | None | Updates HeavyScript prior to running it
_You no longer need to git pull_ | | --delete-backup | --delete-backup | None | Opens a menu to delete backups
_Useful if you need to delete old system backups or backups from other scripts_ | | --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot | | --mount | --mount | None | Initiates mounting feature
Choose between unmounting and mounting PVC data | @@ -36,7 +37,7 @@ ### Examples #### Typical Cron Job ``` -bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsup +bash heavy_script.sh --self-update -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsup ``` > `-b` is set to 14. Up to 14 snapshots of your ix-applications dataset will be saved @@ -53,6 +54,8 @@ bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsup > `-p` Prune docker images. +> `--self-update` Will update the script prior to running anything else. + #### Mounting PVC Data ``` @@ -79,7 +82,7 @@ bash /mnt/tank/scripts/heavy_script/heavy_script.sh --dns #### My personal Cron Job ``` -git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -rsup +bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 14 -rsup ```
@@ -111,7 +114,7 @@ cd heavy_script From here, you can just run Heavy_Script with `bash heavy_script.sh -ARGUMENTS` -> Note: `chmod +x` is NOT required. Doing this will break the `git pull` function. Just run the script with `bash heavy_script.sh` +> Note: `chmod +x` is NOT required. Doing this will break the `git pull` (or self update) function. Just run the script with `bash heavy_script.sh`
@@ -132,20 +135,13 @@ git pull ```
-### Update with your Cron Job +### Update with the scripts built-in option -Here, we will update the script prior to running it, incase there is a bugfix, or any new additions to the script - -**Cron Job Command** ``` -git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -rsup +bash heavyscript.sh --self-update -b 14 -supr ``` -> The important command here is the `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull` +> The important argument here is the `--self-update`, you can still use all of your same arguments with this option. -> This command will allow you to preform a `git pull` on a remote directory, which will ensure your script is udated prior to running it - -> `&&` Is used to run a command AFTER the previous command completed successfully ->> So once the `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull` command completes, THEN it will run the `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh -b 14 -rsup` command

@@ -161,7 +157,7 @@ git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_scr | Name | Value | Reason | |------------------------ |------------------------------------------------------------------------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `Description` | HeavyScript git pull and Update apps | This is up to you, put whatever you think is a good description in here | -| `Command` | `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull && bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh -b 14 -rsup` | This is the command you will be running on your schedule I personally use: `git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -rsup` | +| `Command` | `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh --self-update -b 14 -rsup` | This is the command you will be running on your schedule I personally use: `bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 14 -rsup` | | `Run As User` | `root` | Running the script as `root` is REQUIRED. You cannot access all of the kubernetes functions without this user. | | `Schedule` | Up to you, I run mine everyday at `0400` | Again up to you | | `Hide Standard Output` | `False` or Unticked | I like to receive an email report of how the script ran, what apps updated etc. | @@ -184,4 +180,3 @@ git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_scr | ![image](https://user-images.githubusercontent.com/20793231/167971188-07f71d02-8da3-4e0c-b9a0-cd26e7f63613.png) | ![image](https://user-images.githubusercontent.com/20793231/167972033-dc8d4ab4-4fb2-4c8a-b7dc-b9311ae55cf8.png) | - From feb42b49e677581d1b3d68bcf47d637ea853cf22 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:57:22 -0600 Subject: [PATCH 321/823] update readme --- README.md | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index bcfb7e7a..627502b9 100644 --- a/README.md +++ b/README.md @@ -12,24 +12,24 @@ ## Arguments -| Flag | Example | Parameter | Description | -|----------------- |------------------------ |----------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| --self-update | --self-update | None | Updates HeavyScript prior to running it
_You no longer need to git pull_ | -| --delete-backup | --delete-backup | None | Opens a menu to delete backups
_Useful if you need to delete old system backups or backups from other scripts_ | -| --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot | -| --mount | --mount | None | Initiates mounting feature
Choose between unmounting and mounting PVC data | -| --dns | --dns | None | list all of your applications DNS names and their web ports | -| -U | -U | None | Update applications, ignoring major version changes | -| -u | -u | None | Update applications, do NOT update if there was a major version change | -| -b | -b 14 | Integer | Backup `ix-appliactions` dataset
_Creates backups up to the number you've chosen_ | -| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating
_List one application after another as shown in the example_ | -| (-R\|-r) | -r | None | Monitors applications after they update
If the app does not become "ACTIVE" after either:
The custom Timeout, or Default Timeout,
rollback the application.
__Warning: deprecating `-R` please begin using `-r` instead__ | -| -v | -v | None | Verbose Output
_Look at the bottom of this page for an example_ | -| -S | -S | None | Shutdown the application prior to updating it | -| -t | -t 150 | Integer | Set a custom timeout to be used with either:
`-m`
_Time the script will wait for application to be "STOPPED"_
or
`-(u\|U)`
_Time the script will wait for application to be either "STOPPED" or "ACTIVE"_ | -| -s | -s | None | Sync Catalogs prior to updating | -| -p | -p | None | Prune old/unused docker images | - +| Flag | Example | Parameter | Description | +|----------------- |------------------------ |----------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| NULL | NULL | NULL | If you choose not to supply an option, it will open the menu for easier access to the utilities | +| --self-update | --self-update | None | Updates HeavyScript prior to running it
_You no longer need to git pull_ | +| --delete-backup | --delete-backup | None | Opens a menu to delete backups
_Useful if you need to delete old system backups or backups from other scripts_ | +| --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot | +| --mount | --mount | None | Initiates mounting feature
Choose between unmounting and mounting PVC data | +| --dns | --dns | None | list all of your applications DNS names and their web ports | +| -U | -U
-U 5 | None or Integer | Update applications, ignoring major version changes
_Optionally, you can supply a number after the argument to update multiple applications at once_ | +| -u | -u
-u 5 | None or Integer | Update applications, do NOT update if there was a major version change
_Optionally, you can supply a number after the argument to update multiple applications at once_ | +| -b | -b 14 | Integer | Backup `ix-appliactions` dataset
_Creates backups up to the number you've chosen_ | +| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating
_List one application after another as shown in the example_ | +| -r | -r | None | Monitors applications after they update
If the app does not become "ACTIVE" after either:
The custom Timeout, or Default Timeout,
rollback the application. | +| -v | -v | None | Verbose Output
_Look at the bottom of this page for an example_ | +| -S | -S | None | Shutdown the application prior to updating it | +| -t | -t 150 | Integer | Set a custom timeout to be used with either:
`-m`
_Time the script will wait for application to be "STOPPED"_
or
`-(u\|U)`
_Time the script will wait for application to be either "STOPPED" or "ACTIVE"_ | +| -s | -s | None | Sync Catalogs prior to updating | +| -p | -p | None | Prune old/unused docker images |

@@ -37,7 +37,7 @@ ### Examples #### Typical Cron Job ``` -bash heavy_script.sh --self-update -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsup +bash heavy_script.sh --self-update -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsp -u 5 ``` > `-b` is set to 14. Up to 14 snapshots of your ix-applications dataset will be saved @@ -50,10 +50,11 @@ bash heavy_script.sh --self-update -b 14 -i portainer -i arch -i sonarr -i radar > `-s` will just sync the repositories, ensuring you are downloading the latest updates. -> `-u` update applications as long as the major version has absolutely no change, if it does have a change it will ask the user to update manually. - > `-p` Prune docker images. +> `-u` update applications as long as the major version has absolutely no change, if it does have a change it will ask the user to update manually. +> The `5` after the `-u` means up to 5 applications will be updating and monitored at one time + > `--self-update` Will update the script prior to running anything else. #### Mounting PVC Data @@ -82,7 +83,7 @@ bash /mnt/tank/scripts/heavy_script/heavy_script.sh --dns #### My personal Cron Job ``` -bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 14 -rsup +bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 14 -rsp -u 10 ```
From e0ba0935b837622dc316b8e5be617460959dafaa Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:58:17 -0600 Subject: [PATCH 322/823] readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 627502b9..8ab10a50 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ bash heavy_script.sh --self-update -b 14 -i portainer -i arch -i sonarr -i radar > `-p` Prune docker images. > `-u` update applications as long as the major version has absolutely no change, if it does have a change it will ask the user to update manually. -> The `5` after the `-u` means up to 5 applications will be updating and monitored at one time +>> The `5` after the `-u` means up to 5 applications will be updating and monitored at one time > `--self-update` Will update the script prior to running anything else. From 05051adf233764dcd6f28cf0a7240ee8ecefc626 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 19:04:27 -0600 Subject: [PATCH 323/823] cleanup --- functions/menu.sh | 40 ++++++++++++++++++++-------------------- functions/update_apps.sh | 3 +-- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 75618d27..e965ed7b 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -1,25 +1,25 @@ #!/bin/bash menu(){ - script=$(readlink -f "$0") - script_path=$(dirname "$script") - script_name="heavy_script.sh" - cd "$script_path" || exit - clear -x - title - echo "1) Help" - echo "2) List DNS Names" - echo "3) Mount and Unmount PVC storage" - echo "4) Create a Backup" - echo "5) Restore a Backup" - echo "6) Delete a Backup" - echo "7) Update HeavyScript" - echo "8) Update Applications" - echo - echo "0) Exit" - read -rt 600 -p "Please select an option by number: " selection +script=$(readlink -f "$0") +script_path=$(dirname "$script") +script_name="heavy_script.sh" +cd "$script_path" || exit +clear -x +title +echo "1) Help" +echo "2) List DNS Names" +echo "3) Mount and Unmount PVC storage" +echo "4) Create a Backup" +echo "5) Restore a Backup" +echo "6) Delete a Backup" +echo "7) Update HeavyScript" +echo "8) Update Applications" +echo +echo "0) Exit" +read -rt 600 -p "Please select an option by number: " selection - case $selection in +case $selection in 0) exit ;; @@ -174,7 +174,7 @@ menu(){ *) echo "That was not an option, please try agian" && sleep 5 && menu ;; - esac - echo +esac +echo } export -f menu \ No newline at end of file diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d1abed7e..92aeab24 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -35,6 +35,7 @@ done } export -f commander + update_apps(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip @@ -86,8 +87,6 @@ rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' ' echo_array+=("\n$app_name\nMajor Release, update manually") return 0 fi - - } export -f update_apps From 0884c75ec257e04dfb3663bcf2e4bed3c2039ca0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 19:06:57 -0600 Subject: [PATCH 324/823] todo --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 93543752..20461d04 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -8,7 +8,7 @@ script_path=$(dirname "$script") script_name="heavy_script.sh" cd "$script_path" || exit git fetch &> /dev/null - +# TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q From f2d30a74e501f46ffdb36a380d5369febd625739 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 20:20:16 -0600 Subject: [PATCH 325/823] remove uneeded --- functions/backup.sh | 2 +- functions/menu.sh | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index fc81dce3..f7626653 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -9,7 +9,7 @@ date=$(date '+%Y_%m_%d_%H_%M_%S') [[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' &> /dev/null && echo_backup+=(HeavyScript_"$date") [[ -z "$verbose" ]] && echo_backup+=("\nNew Backup Name:") && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 &> /dev/null && echo_backup+=(HeavyScript_"$date") mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") -if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then +if [[ ${#list_backups[@]} -gt "$number_of_backups" ]]; then echo_backup+=("\nDeleted the oldest backup(s) for exceeding limit:") overflow=$(( ${#list_backups[@]} - "$number_of_backups" )) mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") diff --git a/functions/menu.sh b/functions/menu.sh index e965ed7b..06c138b8 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -34,12 +34,9 @@ case $selection in ;; 4) read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups - number_of_backups=$number_of_backups ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit echo "Generating backup, please be patient for output.." - menu_backup="true" - backup "$number_of_backups" ;; 5) restore="true" From d262ad52f93628b8cb92bb50f3071cab6304dc29 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 20:21:48 -0600 Subject: [PATCH 326/823] test --- functions/menu.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 06c138b8..e4bff97a 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -33,10 +33,7 @@ case $selection in mount="true" ;; 4) - read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups - ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit - [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit - echo "Generating backup, please be patient for output.." + backup="true" ;; 5) restore="true" From 890677c72f920fa75e72a8db017cda5466d51f64 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 20:23:52 -0600 Subject: [PATCH 327/823] test --- functions/menu.sh | 1 + heavy_script.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index e4bff97a..f78bbb6b 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -33,6 +33,7 @@ case $selection in mount="true" ;; 4) + read -rt 600 -p "What is the maximun number of backups you would like?: " number_of_backups backup="true" ;; 5) diff --git a/heavy_script.sh b/heavy_script.sh index db3cb062..27abd6f7 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -56,10 +56,10 @@ do exit ;; b) - backup="true" number_of_backups=$OPTARG ! [[ $OPTARG =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit + backup="true" ;; r) rollback="true" From 6f1fbd8bcf0957faa6345d216285b36c7478c012 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 20:31:44 -0600 Subject: [PATCH 328/823] update help --- functions/misc.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index 96ca57e1..35601d93 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -44,19 +44,24 @@ echo "--delete-backup | Opens a menu to delete backups on your system" echo "--dns | list all of your applications DNS names and their web ports" echo echo "Update Options" -echo "-U | Update all applications, ignores versions" -echo "-u | Update all applications, does not update Major releases" -echo "-b | Back-up your ix-applications dataset, specify a number after -b" -echo "-i | Add application to ignore list, one by one, see example below." -echo "-r | Roll-back applications if they fail to update" -echo "-S | Shutdown applications prior to updating" -echo "-v | verbose output" -echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" -echo "-s | sync catalog" -echo "-p | Prune unused/old docker images" +echo "-U | Update all applications, ignores versions" +echo "-U 5 | Same as above, but updates 5 applications at one time" +echo "-u | Update all applications, does not update Major releases" +echo "-u 5 | Same as above, but updates 5 applications at one time" +echo +echo "Additional Options" +echo "-b | Back-up your ix-applications dataset, specify a number after -b" +echo "-i | Add application to ignore list, one by one, see example below." +echo "-r | Roll-back applications if they fail to update" +echo "-S | Shutdown applications prior to updating" +echo "-v | verbose output" +echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" +echo "-s | sync catalog" +echo "-p | Prune unused/old docker images" echo echo "Examples" echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" +echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsp -U 10" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" echo "bash heavy_script.sh --restore" From 73feac7b95e8850c7b75fd93dabaf26089ccc77e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 20:34:18 -0600 Subject: [PATCH 329/823] help fix --- functions/misc.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/functions/misc.sh b/functions/misc.sh index 35601d93..9b61a053 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -37,19 +37,28 @@ export -f title help(){ [[ $help == "true" ]] && clear -x + +echo "Access the HeavyScript Menu" +echo "---------------------------" +echo "(Just dont send any other argument)" +echo "bash heavy_script.sh" +echo echo "Basic Utilities" +echo "---------------" echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset" echo "--delete-backup | Opens a menu to delete backups on your system" echo "--dns | list all of your applications DNS names and their web ports" echo echo "Update Options" +echo "--------------" echo "-U | Update all applications, ignores versions" echo "-U 5 | Same as above, but updates 5 applications at one time" echo "-u | Update all applications, does not update Major releases" echo "-u 5 | Same as above, but updates 5 applications at one time" echo echo "Additional Options" +echo "------------------" echo "-b | Back-up your ix-applications dataset, specify a number after -b" echo "-i | Add application to ignore list, one by one, see example below." echo "-r | Roll-back applications if they fail to update" @@ -60,12 +69,14 @@ echo "-s | sync catalog" echo "-p | Prune unused/old docker images" echo echo "Examples" +echo "--------" echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsp -U 10" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" echo "bash heavy_script.sh --restore" echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" +echo "bash heavy_script.sh" echo exit } From c836ff5ce246564d249fe82452f75605b5ad5332 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 20:36:18 -0600 Subject: [PATCH 330/823] cleanup help --- functions/misc.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index 9b61a053..ce13f395 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -57,8 +57,8 @@ echo "-U 5 | Same as above, but updates 5 applications at one time" echo "-u | Update all applications, does not update Major releases" echo "-u 5 | Same as above, but updates 5 applications at one time" echo -echo "Additional Options" -echo "------------------" +echo "Additional Update Options" +echo "-------------------------" echo "-b | Back-up your ix-applications dataset, specify a number after -b" echo "-i | Add application to ignore list, one by one, see example below." echo "-r | Roll-back applications if they fail to update" From 587fefee3be6c5f63b9770dc9d7bcb5cc32f0cd3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 20:38:18 -0600 Subject: [PATCH 331/823] final readme --- functions/misc.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index ce13f395..7956fe53 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -52,31 +52,31 @@ echo "--dns | list all of your applications DNS names and their web po echo echo "Update Options" echo "--------------" -echo "-U | Update all applications, ignores versions" -echo "-U 5 | Same as above, but updates 5 applications at one time" -echo "-u | Update all applications, does not update Major releases" -echo "-u 5 | Same as above, but updates 5 applications at one time" +echo "-U | Update all applications, ignores versions" +echo "-U 5 | Same as above, but updates 5 applications at one time" +echo "-u | Update all applications, does not update Major releases" +echo "-u 5 | Same as above, but updates 5 applications at one time" echo echo "Additional Update Options" echo "-------------------------" -echo "-b | Back-up your ix-applications dataset, specify a number after -b" -echo "-i | Add application to ignore list, one by one, see example below." -echo "-r | Roll-back applications if they fail to update" -echo "-S | Shutdown applications prior to updating" -echo "-v | verbose output" -echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" -echo "-s | sync catalog" -echo "-p | Prune unused/old docker images" +echo "-b 14 | Back-up your ix-applications dataset, specify a number after -b" +echo "-i | Add application to ignore list, one by one, see example below." +echo "-r | Roll-back applications if they fail to update" +echo "-S | Shutdown applications prior to updating" +echo "-v | verbose output" +echo "-t 500| Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" +echo "-s | sync catalog" +echo "-p | Prune unused/old docker images" echo echo "Examples" echo "--------" -echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" -echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsp -U 10" +echo "bash heavy_script.sh" +echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -t 600 -vrsUp" +echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -t 600 -vrsp -U 10" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" echo "bash heavy_script.sh --restore" echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" -echo "bash heavy_script.sh" echo exit } From 84f272abde456e8137ca62e15e9bcf95de3190a6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 22:45:12 -0600 Subject: [PATCH 332/823] attempt case --- functions/menu.sh | 103 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 30 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index f78bbb6b..c13c7247 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -35,7 +35,7 @@ case $selection in 4) read -rt 600 -p "What is the maximun number of backups you would like?: " number_of_backups backup="true" - ;; + ;; 5) restore="true" ;; @@ -123,47 +123,90 @@ case $selection in echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection - if [[ $current_selection == 0 ]]; then - clear -x - echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" - echo - exec bash "$script_name" "${update_selection[@]}" - exit - elif [[ $current_selection == 1 ]]; then + case $current_selection in + 0) + clear -x + echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" + echo + exec bash "$script_name" "${update_selection[@]}" + exit + ;; + 1) echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue - update_selection+=("-b" "$up_backups") - elif [[ $current_selection == 2 ]]; then - read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + ;; + 2) + read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + update_selection+=("-i" "$up_ignore") + ;; + 3) + update_selection+=("-r") + ;; + 4) + update_selection+=("-S") + ;; + 5) + update_selection+=("-v") + ;; + 6) + echo "What do you want your timeout to be?" + read -rt 600 -p "Please type an integer: " up_timeout + ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + ;; + 7) + update_selection+=("-s") + ;; + 8) + update_selection+=("-p") + ;; + *) + echo "$current_selection was not an option, try again" && sleep 5 && continue + ;; + esac + # if [[ $current_selection == 0 ]]; then + # clear -x + # echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" + # echo + # exec bash "$script_name" "${update_selection[@]}" + # exit + # elif [[ $current_selection == 1 ]]; then + # echo "Up to how many backups should we keep?" + # read -rt 600 -p "Please type an integer: " up_backups + # ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + # [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue - update_selection+=("-i" "$up_ignore") - elif [[ $current_selection == 3 ]]; then + # update_selection+=("-b" "$up_backups") + # elif [[ $current_selection == 2 ]]; then + # read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - update_selection+=("-r") - elif [[ $current_selection == 4 ]]; then + # update_selection+=("-i" "$up_ignore") + # elif [[ $current_selection == 3 ]]; then - update_selection+=("-S") - elif [[ $current_selection == 5 ]]; then + # update_selection+=("-r") + # elif [[ $current_selection == 4 ]]; then - update_selection+=("-v") - elif [[ $current_selection == 6 ]]; then - echo "What do you want your timeout to be?" - read -rt 600 -p "Please type an integer: " up_timeout - ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + # update_selection+=("-S") + # elif [[ $current_selection == 5 ]]; then - update_selection+=("-t" "$up_timeout") - elif [[ $current_selection == 7 ]]; then + # update_selection+=("-v") + # elif [[ $current_selection == 6 ]]; then + # echo "What do you want your timeout to be?" + # read -rt 600 -p "Please type an integer: " up_timeout + # ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - update_selection+=("-s") - elif [[ $current_selection == 8 ]]; then + # update_selection+=("-t" "$up_timeout") + # elif [[ $current_selection == 7 ]]; then - update_selection+=("-p") - else - echo "$current_selection was not an option, try again" && sleep 5 && continue - fi + # update_selection+=("-s") + # elif [[ $current_selection == 8 ]]; then + + # update_selection+=("-p") + # else + # echo "$current_selection was not an option, try again" && sleep 5 && continue + # fi done ;; *) From 42282b5017fd052ef63d4c302c06bbdca1d105d3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 22:46:58 -0600 Subject: [PATCH 333/823] success --- functions/menu.sh | 51 +++++------------------------------------------ 1 file changed, 5 insertions(+), 46 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index c13c7247..d011a072 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -132,11 +132,11 @@ case $selection in exit ;; 1) - echo "Up to how many backups should we keep?" - read -rt 600 -p "Please type an integer: " up_backups - ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue - update_selection+=("-b" "$up_backups") + echo "Up to how many backups should we keep?" + read -rt 600 -p "Please type an integer: " up_backups + ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue + update_selection+=("-b" "$up_backups") ;; 2) read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore @@ -166,47 +166,6 @@ case $selection in echo "$current_selection was not an option, try again" && sleep 5 && continue ;; esac - # if [[ $current_selection == 0 ]]; then - # clear -x - # echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" - # echo - # exec bash "$script_name" "${update_selection[@]}" - # exit - # elif [[ $current_selection == 1 ]]; then - # echo "Up to how many backups should we keep?" - # read -rt 600 -p "Please type an integer: " up_backups - # ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - # [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue - - # update_selection+=("-b" "$up_backups") - # elif [[ $current_selection == 2 ]]; then - # read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - - # update_selection+=("-i" "$up_ignore") - # elif [[ $current_selection == 3 ]]; then - - # update_selection+=("-r") - # elif [[ $current_selection == 4 ]]; then - - # update_selection+=("-S") - # elif [[ $current_selection == 5 ]]; then - - # update_selection+=("-v") - # elif [[ $current_selection == 6 ]]; then - # echo "What do you want your timeout to be?" - # read -rt 600 -p "Please type an integer: " up_timeout - # ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - - # update_selection+=("-t" "$up_timeout") - # elif [[ $current_selection == 7 ]]; then - - # update_selection+=("-s") - # elif [[ $current_selection == 8 ]]; then - - # update_selection+=("-p") - # else - # echo "$current_selection was not an option, try again" && sleep 5 && continue - # fi done ;; *) From 39b7928f68e9faef723d0ad1c640f35851858f14 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 22:48:46 -0600 Subject: [PATCH 334/823] cleaning --- functions/menu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index d011a072..e15fbe31 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -163,13 +163,13 @@ case $selection in update_selection+=("-p") ;; *) - echo "$current_selection was not an option, try again" && sleep 5 && continue + echo "\"$OPTARG\" was not an option, try again" && sleep 5 && continue ;; esac done ;; *) - echo "That was not an option, please try agian" && sleep 5 && menu + echo "\"$OPTARG\" was not an option, please try agian" && sleep 5 && menu ;; esac echo From e83e7c8a80e0c1557276002e70cae84db79bbaf8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 22:50:00 -0600 Subject: [PATCH 335/823] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index e15fbe31..fbd46c27 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -97,7 +97,7 @@ case $selection in exit else echo "$current_selection was not an option, try again" - exit + continue fi done while true From e794d71be9318e95619230842363909ee2aebb2c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 22:50:32 -0600 Subject: [PATCH 336/823] fix --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index fbd46c27..a5fa27f8 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -96,7 +96,7 @@ case $selection in echo "Exiting.." exit else - echo "$current_selection was not an option, try again" + echo "$current_selection was not an option, try again" && sleep 5 continue fi done From 7f210da6b8d3564e1a6dcb3d4bc12473edc9b953 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 22:53:05 -0600 Subject: [PATCH 337/823] fix --- functions/menu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/menu.sh b/functions/menu.sh index a5fa27f8..f9bb003b 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -155,6 +155,7 @@ case $selection in echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + update_selection+=("-i" "$up_timeout") ;; 7) update_selection+=("-s") From 63f1d6c477b5303b23c81b421e274932d45f7258 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 22:54:14 -0600 Subject: [PATCH 338/823] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index f9bb003b..83978694 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -155,7 +155,7 @@ case $selection in echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - update_selection+=("-i" "$up_timeout") + update_selection+=("-t" "$up_timeout") ;; 7) update_selection+=("-s") From a44b250390d6e8d965bfafb38507e99477a548ff Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:00:12 -0600 Subject: [PATCH 339/823] test skip --- functions/menu.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index 83978694..8f564350 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -137,6 +137,7 @@ case $selection in ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-b" "$up_backups") + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 2) read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore @@ -144,24 +145,30 @@ case $selection in ;; 3) update_selection+=("-r") + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 4) update_selection+=("-S") + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 5) update_selection+=("-v") + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 6) echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-t" "$up_timeout") ;; 7) update_selection+=("-s") + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 8) update_selection+=("-p") + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; *) echo "\"$OPTARG\" was not an option, try again" && sleep 5 && continue From 0c7479801ed9881dc43607178fe0ebcdf3747fbf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:02:45 -0600 Subject: [PATCH 340/823] fix --- functions/menu.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 8f564350..04a6a66b 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -132,43 +132,44 @@ case $selection in exit ;; 1) + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-b" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-b" "$up_backups") - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 2) read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore update_selection+=("-i" "$up_ignore") ;; 3) + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-r" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-r") - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + ;; 4) + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-S" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-S") - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 5) + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-v" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-v") - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 6) + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-t" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-t" "$up_timeout") ;; 7) + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-s" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-s") - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 8) + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-p" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-p") - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; *) echo "\"$OPTARG\" was not an option, try again" && sleep 5 && continue From 2f7169ee11deb0c5221d022adb6819cf69dcf630 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:05:41 -0600 Subject: [PATCH 341/823] uhh --- functions/menu.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 04a6a66b..a6a5eee0 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -132,7 +132,7 @@ case $selection in exit ;; 1) - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-b" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz '-b' && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue @@ -144,31 +144,31 @@ case $selection in update_selection+=("-i" "$up_ignore") ;; 3) - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-r" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-r" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-r") ;; 4) - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-S" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-S" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-S") ;; 5) - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-v" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-v" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-v") ;; 6) - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-t" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-t" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-t" "$up_timeout") ;; 7) - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-s" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-s" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-s") ;; 8) - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-p" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-p" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-p") ;; *) From 4e15a6ba3eede92cc2de7eca879b6bbe6ee20e93 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:07:06 -0600 Subject: [PATCH 342/823] asd --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index a6a5eee0..7d065b58 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -132,7 +132,7 @@ case $selection in exit ;; 1) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz '-b' && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxq '-b' && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue From 20551b4df9b11513e806fbd370df92cf1125dda4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:08:55 -0600 Subject: [PATCH 343/823] escape? --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 7d065b58..60cb7dce 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -132,7 +132,7 @@ case $selection in exit ;; 1) - printf '%s\0' "${update_selection[@]}" | grep -Fxq '-b' && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz "\-b" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue From b0b9bce10e49a2f7587ca6f5fac2fddc037e8e4b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:10:16 -0600 Subject: [PATCH 344/823] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 60cb7dce..fc74d51b 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -132,7 +132,7 @@ case $selection in exit ;; 1) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz "\-b" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue From edfe7542f213b87684fa6dab4f6f66e9aaf98583 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:12:02 -0600 Subject: [PATCH 345/823] woo --- functions/menu.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index fc74d51b..b01f93b9 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -132,7 +132,7 @@ case $selection in exit ;; 1) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue @@ -144,31 +144,31 @@ case $selection in update_selection+=("-i" "$up_ignore") ;; 3) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-r" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-r") ;; 4) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-S" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-S" && echo -e "\"-S\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-S") ;; 5) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-v" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-v" && echo -e "\"-v\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-v") ;; 6) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-t" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-t" "$up_timeout") ;; 7) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-s" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-s" && echo -e "\"-s\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-s") ;; 8) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-p" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-p") ;; *) From 10d6336671956813b7d8541a07fdeaa2b53777c3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:21:10 -0600 Subject: [PATCH 346/823] test --- functions/menu.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index b01f93b9..0e5310b9 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -171,6 +171,16 @@ case $selection in printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-p") ;; + 99) + count=1 + echo "restarting" + for i in "${update_selection[@]:1}" + do + unset "update_selection[$count]" + echo "$i removed" + done + continue + ;; *) echo "\"$OPTARG\" was not an option, try again" && sleep 5 && continue ;; From 9f20f36d299f2eaef9578f7362a27defa8ef88a3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:22:55 -0600 Subject: [PATCH 347/823] test --- functions/menu.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 0e5310b9..de2182d4 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -172,12 +172,13 @@ case $selection in update_selection+=("-p") ;; 99) - count=1 + count=2 echo "restarting" - for i in "${update_selection[@]:1}" + for i in "${update_selection[@]:2}" do unset "update_selection[$count]" echo "$i removed" + ((count++)) done continue ;; From 20ed6d7babae07399c9274a3be7c2c9e406af4ae Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:25:08 -0600 Subject: [PATCH 348/823] test --- functions/menu.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index de2182d4..b4145a9d 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -115,7 +115,8 @@ case $selection in echo "7) -s | sync catalog" echo "8) -p | Prune unused/old docker images" echo - echo "0) Done making selections, proceed with update" + echo "99) Remove Update Options, Restart" + echo "00) Done making selections, proceed with update" echo echo "Current Choices" echo "---------------" @@ -124,7 +125,7 @@ case $selection in read -rt 600 -p "Please type the number associated with the flag above: " current_selection case $current_selection in - 0) + 00) clear -x echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" echo @@ -180,6 +181,7 @@ case $selection in echo "$i removed" ((count++)) done + sleep 5 continue ;; *) From f97d4be4815e3b8135a6dbdb03ebe11c0be6d950 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:34:50 -0600 Subject: [PATCH 349/823] correct var --- functions/menu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index b4145a9d..057a700f 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -185,13 +185,13 @@ case $selection in continue ;; *) - echo "\"$OPTARG\" was not an option, try again" && sleep 5 && continue + echo "\"$current_selection\" was not an option, try again" && sleep 5 && continue ;; esac done ;; *) - echo "\"$OPTARG\" was not an option, please try agian" && sleep 5 && menu + echo "\"$selection\" was not an option, please try agian" && sleep 5 && menu ;; esac echo From 767c18a62a42206e71ecb6e0f6c617425e55c33f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:40:48 -0600 Subject: [PATCH 350/823] optional flag --- functions/menu.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 057a700f..ff127da7 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -132,7 +132,7 @@ case $selection in exec bash "$script_name" "${update_selection[@]}" exit ;; - 1) + 1 | -b) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups @@ -140,35 +140,35 @@ case $selection in [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-b" "$up_backups") ;; - 2) + 2 | -i) read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore update_selection+=("-i" "$up_ignore") ;; - 3) + 3 | -r) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-r") ;; - 4) + 4 | -S) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-S" && echo -e "\"-S\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-S") ;; - 5) + 5 | -v) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-v" && echo -e "\"-v\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-v") ;; - 6) + 6 | -t) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-t" "$up_timeout") ;; - 7) + 7 | -s) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-s" && echo -e "\"-s\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-s") ;; - 8) + 8 | -p) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-p") ;; From e38c9c65d4f2007151736f655fa2d4bbc4f82603 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:42:30 -0600 Subject: [PATCH 351/823] done for the night --- functions/menu.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index ff127da7..1ac5659e 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -123,7 +123,6 @@ case $selection in echo "bash heavy_script.sh ${update_selection[*]}" echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection - case $current_selection in 00) clear -x From 97b65f746d776f821c767ab27d9a4cf8eb401472 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 09:47:19 -0600 Subject: [PATCH 352/823] cd to script --- heavy_script.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/heavy_script.sh b/heavy_script.sh index 27abd6f7..a4552ac3 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,5 +1,9 @@ #!/bin/bash +# cd to script +script=$(readlink -f "$0") +script_path=$(dirname "$script") +cd "$script_path" || exit # shellcheck source=functions/backup.sh source functions/backup.sh From 27eb8b0e61199c5ec6837c34265c3f5827e1f04c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 10:03:34 -0600 Subject: [PATCH 353/823] polish format --- functions/misc.sh | 4 ++-- functions/update_apps.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index 7956fe53..663e93cc 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -2,7 +2,7 @@ sync(){ -echo_sync+=("\nSync Output") +echo_sync+=("\n\nSync Output") echo_sync+=("-----------") cli -c 'app catalog sync_all' &> /dev/null && echo_sync+=("Catalog sync complete") @@ -15,7 +15,7 @@ done export -f sync prune(){ -echo -e "\nDocker Prune Output" +echo -e "\n\nDocker Prune Output" echo "-------------------" echo "Pruned Docker Images" docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 92aeab24..6fe1e875 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -3,7 +3,7 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) -echo -e "\nAplication Update Output" +echo -e "\n\nAplication Update Output" echo "------------------------" [[ -z $array ]] && echo "There are no updates available" && return 0 || echo "${#array[@]} update(s) available" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" From 425564e75217f6e87a93597ea014aa33df76ee92 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 10:27:12 -0600 Subject: [PATCH 354/823] description --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index a4552ac3..18a08b36 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,6 +1,6 @@ #!/bin/bash -# cd to script +# cd to script, this ensures the script can find the source scripts below, even when ran from a seperate directory script=$(readlink -f "$0") script_path=$(dirname "$script") cd "$script_path" || exit From dfe359e34aadd34f25c570b9ff9e835c65930a18 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 10:31:43 -0600 Subject: [PATCH 355/823] silencing shellcheck --- functions/mount.sh | 2 +- functions/update_apps.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index 88d9af21..b7576ca9 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -39,7 +39,7 @@ if [[ $selection == "1" ]]; then exit elif [[ $selection == "2" ]]; then mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") - [[ -z $unmount_array ]] && echo "Theres nothing to unmount" && exit + [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit for i in "${unmount_array[@]}" do main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 6fe1e875..64104df1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -5,7 +5,7 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) echo -e "\n\nAplication Update Output" echo "------------------------" -[[ -z $array ]] && echo "There are no updates available" && return 0 || echo "${#array[@]} update(s) available" +[[ -z ${array[*]} ]] && echo "There are no updates available" && return 0 || echo "${#array[@]} update(s) available" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" echo "Asynchronous Updates: $update_limit" From d340f3164d50af24d2099e4c2c6c1d9c682795c4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 13:00:22 -0600 Subject: [PATCH 356/823] parent shell updates status --- functions/update_apps.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 92aeab24..06dabee1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -13,6 +13,7 @@ echo "Asynchronous Updates: $update_limit" it=0 while [[ $it -lt ${#array[@]} ]] do + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status') proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" @@ -20,7 +21,7 @@ do kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 1 + sleep 3 else update_apps "${array[$it]}" & processes+=($!) @@ -43,8 +44,7 @@ old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{prin new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version new_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version -status=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE -startstatus=$status +startstatus=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From @@ -52,7 +52,7 @@ new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not - if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop + if [[ "$startstatus" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") @@ -61,9 +61,9 @@ rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' ' echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=("FAILED") - while [[ "$status" != "STOPPED" ]] + while [[ "$startstatus" != "STOPPED" ]] do - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + #status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then echo_array+=("Stopped") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") @@ -98,7 +98,7 @@ if [[ $rollback == "true" ]]; then while true do (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + status=$(echo "$status" | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") @@ -130,7 +130,7 @@ else while true #using a constant while loop, then breaking out of the loop with break commands below. do (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + status=$(echo "$status" | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check From 6dc96419f464ac594bf9e48d04beb2c6ac77ccfd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 13:09:10 -0600 Subject: [PATCH 357/823] pos fix --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 90952be1..f8efb24d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -63,7 +63,7 @@ rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' ' midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=("FAILED") while [[ "$startstatus" != "STOPPED" ]] do - #status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + status=$(echo "$status" | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then echo_array+=("Stopped") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") From 8ff5886a9990e4779a4ae89001463349c7c68221 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 13:16:11 -0600 Subject: [PATCH 358/823] test --- functions/update_apps.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f8efb24d..2522c2c1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,7 +11,7 @@ echo "------------------------" echo "Asynchronous Updates: $update_limit" it=0 -while [[ $it -lt ${#array[@]} ]] +while true do status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status') proc_count=${#processes[@]} @@ -20,7 +20,9 @@ do do kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } done - if [[ "$proc_count" -ge "$update_limit" ]]; then + if [[ $it -eq ${#array[@]} && ${#processes[@]} == 0 ]]; then + break + elif [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 else update_apps "${array[$it]}" & From 8a61eb1f8aef9ef4e71a34f69d9d5b2c6fff69bb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 13:27:04 -0600 Subject: [PATCH 359/823] export --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2522c2c1..548a599b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,6 +14,7 @@ it=0 while true do status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status') + export status proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" From e12b72a97b58cae456d7b93853f856f46206c9b9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 13:47:44 -0600 Subject: [PATCH 360/823] revert changes --- functions/update_apps.sh | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 548a599b..64104df1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,20 +11,16 @@ echo "------------------------" echo "Asynchronous Updates: $update_limit" it=0 -while true +while [[ $it -lt ${#array[@]} ]] do - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status') - export status proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" do kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } done - if [[ $it -eq ${#array[@]} && ${#processes[@]} == 0 ]]; then - break - elif [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 3 + if [[ "$proc_count" -ge "$update_limit" ]]; then + sleep 1 else update_apps "${array[$it]}" & processes+=($!) @@ -47,7 +43,8 @@ old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{prin new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version new_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version -startstatus=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE +status=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE +startstatus=$status diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From @@ -55,7 +52,7 @@ new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not - if [[ "$startstatus" == "STOPPED" ]]; then # if status is already stopped, skip while loop + if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") @@ -64,9 +61,9 @@ rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' ' echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=("FAILED") - while [[ "$startstatus" != "STOPPED" ]] + while [[ "$status" != "STOPPED" ]] do - status=$(echo "$status" | grep "^$app_name," | awk -F ',' '{print $2}') + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then echo_array+=("Stopped") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") @@ -101,7 +98,7 @@ if [[ $rollback == "true" ]]; then while true do (( count++ )) - status=$(echo "$status" | grep "^$app_name," | awk -F ',' '{print $2}') + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") @@ -133,7 +130,7 @@ else while true #using a constant while loop, then breaking out of the loop with break commands below. do (( count++ )) - status=$(echo "$status" | grep "^$app_name," | awk -F ',' '{print $2}') + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check From cb25487dffe11eb93e6acd71e90d6e684f7e7e80 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 13:56:22 -0600 Subject: [PATCH 361/823] test file method --- functions/update_apps.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 64104df1..f609ef01 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -10,9 +10,11 @@ echo "------------------------" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" echo "Asynchronous Updates: $update_limit" +touch temp.txt it=0 while [[ $it -lt ${#array[@]} ]] do + cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' > temp.txt proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" @@ -20,13 +22,14 @@ do kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 1 + sleep 3 else update_apps "${array[$it]}" & processes+=($!) ((it++)) fi done +rm temp.txt for proc in "${processes[@]}" do @@ -63,7 +66,7 @@ rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' ' midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=("FAILED") while [[ "$status" != "STOPPED" ]] do - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then echo_array+=("Stopped") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") @@ -98,7 +101,7 @@ if [[ $rollback == "true" ]]; then while true do (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") @@ -130,7 +133,7 @@ else while true #using a constant while loop, then breaking out of the loop with break commands below. do (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check From 2fd4d0a92698f18cb9c4b93f6ee4fdca150c960e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 14:13:40 -0600 Subject: [PATCH 362/823] test --- functions/update_apps.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f609ef01..efb9d9a3 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -12,7 +12,7 @@ echo "Asynchronous Updates: $update_limit" touch temp.txt it=0 -while [[ $it -lt ${#array[@]} ]] +while true do cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' > temp.txt proc_count=${#processes[@]} @@ -23,18 +23,20 @@ do done if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 - else + elif [[ $it -lt ${#array[@]} ]]; then update_apps "${array[$it]}" & processes+=($!) ((it++)) + else + for proc in "${processes[@]}" + do + wait "$proc" + done + break fi done rm temp.txt -for proc in "${processes[@]}" -do - wait "$proc" -done } export -f commander From eb50e56e6bf79d031666fe4cb9a5b863f5ebc0d0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 14:36:23 -0600 Subject: [PATCH 363/823] test --- functions/update_apps.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index efb9d9a3..94f525ec 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -27,12 +27,10 @@ do update_apps "${array[$it]}" & processes+=($!) ((it++)) - else - for proc in "${processes[@]}" - do - wait "$proc" - done + elif [[ ${#processes[@]} == 0 ]]; then break + else + sleep 3 fi done rm temp.txt From 3da75f299d1a5e9b770a2066fbdbfb38a669aa23 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 14:40:46 -0600 Subject: [PATCH 364/823] test --- functions/update_apps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 94f525ec..36f5719b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,7 +14,8 @@ touch temp.txt it=0 while true do - cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' > temp.txt + while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status') + echo "$while_status" > temp.txt proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" From ef43d3c214153e5dac21d596a57001a2f4e640c4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 14:50:52 -0600 Subject: [PATCH 365/823] test --- functions/update_apps.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 36f5719b..472ded56 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -28,10 +28,10 @@ do update_apps "${array[$it]}" & processes+=($!) ((it++)) - elif [[ ${#processes[@]} == 0 ]]; then - break - else + elif [[ ${#processes[@]} != 0 ]]; then # Wait for all processes to finish sleep 3 + else + break fi done rm temp.txt From fd21a80db09334840e54d7319cdcc68691461fea Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 15:07:53 -0600 Subject: [PATCH 366/823] test --- functions/update_apps.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 472ded56..a856a945 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -21,6 +21,7 @@ do for proc in "${processes[@]}" do kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } + ((count++)) done if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 @@ -28,9 +29,10 @@ do update_apps "${array[$it]}" & processes+=($!) ((it++)) - elif [[ ${#processes[@]} != 0 ]]; then # Wait for all processes to finish + elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 - else + else # All processes must be completed, break out of loop + wait "${processes[*]}" break fi done From cf2f5000ee4f19ce8d912c3f82e3232776f159ab Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 15:23:56 -0600 Subject: [PATCH 367/823] test --- functions/update_apps.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a856a945..05e62519 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,7 +32,9 @@ do elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop - wait "${processes[*]}" + for proc in "${processes[@]}"; do + wait "$proc" + done break fi done From 2f180d1a4b33ceed6d8aa411c75f2da7f778a699 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 15:34:00 -0600 Subject: [PATCH 368/823] remove for loop --- functions/update_apps.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 05e62519..88018f7d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,9 +32,10 @@ do elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop - for proc in "${processes[@]}"; do - wait "$proc" - done + # Unessesary for loop. since processes have to be completed before getting to this point, it is unlikely we would ever have to wait on processes.. Will test more. + # for proc in "${processes[@]}"; do + # wait "$proc" + # done break fi done From 3bffd42f8cc7e63b7adafe39123e06ab06f33543 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 15:47:11 -0600 Subject: [PATCH 369/823] remove var --- functions/update_apps.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 88018f7d..a4dbdb72 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -52,8 +52,7 @@ old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{prin new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version new_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version -status=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE -startstatus=$status +startstatus=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From @@ -61,7 +60,7 @@ new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not - if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop + if [[ "$startstatus" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") From 12218c4976925c0bf246fffdd518f96fd3fff18e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 16:35:16 -0600 Subject: [PATCH 370/823] remove touch --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a4dbdb72..d2f00837 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -10,7 +10,7 @@ echo "------------------------" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" echo "Asynchronous Updates: $update_limit" -touch temp.txt + it=0 while true do From f52ef399d47782167ca5c909310ec7d3d96c5748 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 16:40:44 -0600 Subject: [PATCH 371/823] better format --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d2f00837..30c197ea 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -5,10 +5,10 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) echo -e "\n\nAplication Update Output" echo "------------------------" -[[ -z ${array[*]} ]] && echo "There are no updates available" && return 0 || echo "${#array[@]} update(s) available" +[[ -z ${array[*]} ]] && echo "There are no updates available" && return 0 || echo "Update(s) Available: ${#array[@]}" +echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -echo "Asynchronous Updates: $update_limit" it=0 From e365429ee48e8e47672e822f8fa55b22ed40a020 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 16:51:23 -0600 Subject: [PATCH 372/823] better mount message --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index b7576ca9..880ffce4 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -29,7 +29,7 @@ if [[ $selection == "1" ]]; then volume_name=$(echo "$pvc" | awk '{print $4}') mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - echo "$app is a name used on more than one pool.. attempting to use your current kubernetes apps pool" + echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') fi From 6c9bd67e42f1e8578b6fd29a86bcccf82cb4132d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 16:56:29 -0600 Subject: [PATCH 373/823] rm cd from selfupdate --- functions/self_update.sh | 4 ---- heavy_script.sh | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 20461d04..cd56e705 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -3,10 +3,6 @@ args=("$@") self_update() { -script=$(readlink -f "$0") -script_path=$(dirname "$script") -script_name="heavy_script.sh" -cd "$script_path" || exit git fetch &> /dev/null # TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then diff --git a/heavy_script.sh b/heavy_script.sh index 18a08b36..4b99e646 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,8 +3,10 @@ # cd to script, this ensures the script can find the source scripts below, even when ran from a seperate directory script=$(readlink -f "$0") script_path=$(dirname "$script") +script_name="heavy_script.sh" cd "$script_path" || exit + # shellcheck source=functions/backup.sh source functions/backup.sh # shellcheck source=functions/dns.sh From 5ac2b76c32769abd77a2023172742087b365f92e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 16:57:24 -0600 Subject: [PATCH 374/823] test change --- functions/self_update.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index cd56e705..fac45a1e 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -1,7 +1,6 @@ #!/bin/bash args=("$@") - self_update() { git fetch &> /dev/null # TODO: change beta to main once testing is complete From 6902e15c9cfa599839ff0f014b6b20d39de6c62f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 17:03:03 -0600 Subject: [PATCH 375/823] better message --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 4b99e646..024aec0c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,7 @@ script=$(readlink -f "$0") script_path=$(dirname "$script") script_name="heavy_script.sh" -cd "$script_path" || exit +cd "$script_path" || { echo "Error: Failed to change to script directory" ; exit ; } # shellcheck source=functions/backup.sh From d88762ea57019e8f2cb46f9871072310b80efc4a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 20:05:28 -0600 Subject: [PATCH 376/823] cleanup --- functions/update_apps.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 30c197ea..eb517a92 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,10 +32,6 @@ do elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop - # Unessesary for loop. since processes have to be completed before getting to this point, it is unlikely we would ever have to wait on processes.. Will test more. - # for proc in "${processes[@]}"; do - # wait "$proc" - # done break fi done From ca8d3f5b4e66de2cf1114a49e591896823bdb4fc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 13:31:48 -0600 Subject: [PATCH 377/823] fancy titles --- functions/backup.sh | 3 +-- functions/misc.sh | 6 ++---- functions/update_apps.sh | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index f7626653..56656b9d 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -2,8 +2,7 @@ backup(){ -echo_backup+=("\nBackup Output") -echo_backup+=("--------------") +echo_backup+=("\n🄱 🄰 🄲 🄺 🅄 🄿 🅂") echo_backup+=("Number of backups was set to $number_of_backups") date=$(date '+%Y_%m_%d_%H_%M_%S') [[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' &> /dev/null && echo_backup+=(HeavyScript_"$date") diff --git a/functions/misc.sh b/functions/misc.sh index 663e93cc..baa1583b 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -2,8 +2,7 @@ sync(){ -echo_sync+=("\n\nSync Output") -echo_sync+=("-----------") +echo_sync+=("\n\n🅂 🅈 🄽 🄲") cli -c 'app catalog sync_all' &> /dev/null && echo_sync+=("Catalog sync complete") #Dump the echo_array, ensures all output is in a neat order. @@ -15,8 +14,7 @@ done export -f sync prune(){ -echo -e "\n\nDocker Prune Output" -echo "-------------------" +echo -e "\n\n🄳 🄾 🄲 🄺 🄴 🅁 🄿 🅁 🅄 🄽 🄴" echo "Pruned Docker Images" docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" } diff --git a/functions/update_apps.sh b/functions/update_apps.sh index eb517a92..460877eb 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -3,8 +3,7 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) -echo -e "\n\nAplication Update Output" -echo "------------------------" +echo -e "\n\n🅄 🄿 🄳 🄰 🅃 🄴 🅂" [[ -z ${array[*]} ]] && echo "There are no updates available" && return 0 || echo "Update(s) Available: ${#array[@]}" echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" From 88e047e56acd8b693c44477060e5ef4aef02b248 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 13:50:34 -0600 Subject: [PATCH 378/823] format --- functions/misc.sh | 2 +- heavy_script.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index baa1583b..880de232 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -14,7 +14,7 @@ done export -f sync prune(){ -echo -e "\n\n🄳 🄾 🄲 🄺 🄴 🅁 🄿 🅁 🅄 🄽 🄴" +echo -e "\n\n🄿 🅁 🅄 🄽 🄴" echo "Pruned Docker Images" docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" } diff --git a/heavy_script.sh b/heavy_script.sh index 024aec0c..758296be 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -146,8 +146,7 @@ done [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit if [[ "$backup" == "true" && "$sync" == "true" ]]; then # Run backup and sync at the same time - echo "Running the following two tasks at the same time" - echo "------------------------------------------------" + echo "🅁 🅄 🄽 🄽 🄸 🄽 🄶 🅃 🄰 🅂 🄺 🅂 :" echo -e "Backing up ix-applications dataset\nSyncing catalog(s)" echo -e "This can take a LONG time, please wait for the output..\n" backup & From b0c7cb88509229318b632b9b0fd8fda27d5f74ca Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 13:55:35 -0600 Subject: [PATCH 379/823] More Titles --- functions/self_update.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/self_update.sh b/functions/self_update.sh index fac45a1e..690d2516 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -3,6 +3,7 @@ args=("$@") self_update() { git fetch &> /dev/null +echo "🅂 🄴 🄻 🄵 🅄 🄿 🄳 🄰 🅃 🄴 :" # TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." From 69258f9af5c159ba85a307216e1bf6f7ead7b233 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 13:59:50 -0600 Subject: [PATCH 380/823] format --- heavy_script.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 758296be..5d539c1d 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -146,9 +146,9 @@ done [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit if [[ "$backup" == "true" && "$sync" == "true" ]]; then # Run backup and sync at the same time - echo "🅁 🅄 🄽 🄽 🄸 🄽 🄶 🅃 🄰 🅂 🄺 🅂 :" - echo -e "Backing up ix-applications dataset\nSyncing catalog(s)" - echo -e "This can take a LONG time, please wait for the output..\n" + echo "🅃 🄰 🅂 🄺 🅂 :" + echo -e "-Backing up ix-applications dataset\n-Syncing catalog(s)" + echo -e "This can take a LONG time, please wait for both output..\n" backup & sync & wait From 0f9469cc3a317a82c177ab42a20442ffcbe85d4e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 14:02:57 -0600 Subject: [PATCH 381/823] self update fix --- functions/self_update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 690d2516..5b404492 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -9,16 +9,16 @@ if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q - echo -e "Running the new version...\n" count=0 for i in "${args[@]}" do [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done + [[ -z ${args[*]} ]] && exit + echo -e "Running the new version...\n" sleep 5 exec bash "$script_name" "${args[@]}" - # Now exit this old instance exit else From c9c77c1d6cb4d4ae41bca9ac2c4cb26b1404e6b9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 14:05:21 -0600 Subject: [PATCH 382/823] change just for test --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 5b404492..82342d33 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -4,7 +4,7 @@ args=("$@") self_update() { git fetch &> /dev/null echo "🅂 🄴 🄻 🄵 🅄 🄿 🄳 🄰 🅃 🄴 :" -# TODO: change beta to main once testing is complete +# TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q From 2adbf8d1f71701b0c9491e265fb8a6c29e1db09e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 14:06:10 -0600 Subject: [PATCH 383/823] explanation --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 82342d33..871276b7 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -15,7 +15,7 @@ if git diff --name-only origin/beta | grep -qs ".sh" ; then [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done - [[ -z ${args[*]} ]] && exit + [[ -z ${args[*]} ]] && echo "No more arguments, exiting.." && exit echo -e "Running the new version...\n" sleep 5 exec bash "$script_name" "${args[@]}" From 21baeaf4d8d773dd032274bb717c1ea3c963f549 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 14:06:40 -0600 Subject: [PATCH 384/823] testing self update again --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 871276b7..c5851484 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -4,7 +4,7 @@ args=("$@") self_update() { git fetch &> /dev/null echo "🅂 🄴 🄻 🄵 🅄 🄿 🄳 🄰 🅃 🄴 :" -# TODO: change beta to main once testing is complete +# TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q From 3bd0543fc587540f6fb6bf75d85c66968abd92ca Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 14:07:38 -0600 Subject: [PATCH 385/823] again --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index c5851484..871276b7 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -4,7 +4,7 @@ args=("$@") self_update() { git fetch &> /dev/null echo "🅂 🄴 🄻 🄵 🅄 🄿 🄳 🄰 🅃 🄴 :" -# TODO: change beta to main once testing is complete +# TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q From e5a28282a0469950cba728b030e9b7839c6b167a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 14:10:16 -0600 Subject: [PATCH 386/823] formatting --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 871276b7..96d017d9 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -15,7 +15,7 @@ if git diff --name-only origin/beta | grep -qs ".sh" ; then [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done - [[ -z ${args[*]} ]] && echo "No more arguments, exiting.." && exit + [[ -z ${args[*]} ]] && echo -e "No more arguments, exiting..\n" && exit echo -e "Running the new version...\n" sleep 5 exec bash "$script_name" "${args[@]}" From 9e2bd269a6c0d75e9bd3f2f7b9b55dbd25188d2d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 14:13:57 -0600 Subject: [PATCH 387/823] final --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 96d017d9..3f2445c3 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -3,7 +3,7 @@ args=("$@") self_update() { git fetch &> /dev/null -echo "🅂 🄴 🄻 🄵 🅄 🄿 🄳 🄰 🅃 🄴 :" +echo "🅂 🄴 🄻 🄵 - 🅄 🄿 🄳 🄰 🅃 🄴 :" # TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." From b8e649badf3979b076b00173302ed8ab348d0ae9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 14:21:21 -0600 Subject: [PATCH 388/823] remove colon --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 3f2445c3..b4b88664 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -3,7 +3,7 @@ args=("$@") self_update() { git fetch &> /dev/null -echo "🅂 🄴 🄻 🄵 - 🅄 🄿 🄳 🄰 🅃 🄴 :" +echo "🅂 🄴 🄻 🄵 - 🅄 🄿 🄳 🄰 🅃 🄴" # TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." From 8da7373f33ced2fb61bc49c9622805d95eeff9e4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 16:01:29 -0600 Subject: [PATCH 389/823] heavysetup readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 8ab10a50..af609280 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # heavy_script +## Website + +[HeavySetup - Further In-Depth Explanation](https://heavysetup.info/scripts/heavyscript/about/) + ## Table of contents: * [Arguments](#arguments) * [Examples](#examples) From e2dfead10a046008a64daa6f39f13efa5f272ba8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 16:04:41 -0600 Subject: [PATCH 390/823] selfupdate to menu update --- functions/menu.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index 1ac5659e..9fcafab9 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -114,6 +114,7 @@ case $selection in echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" echo "7) -s | sync catalog" echo "8) -p | Prune unused/old docker images" + echo "9) --self-update | Updates HeavyScript prior to running any other commands" echo echo "99) Remove Update Options, Restart" echo "00) Done making selections, proceed with update" @@ -171,6 +172,10 @@ case $selection in printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-p") ;; + 9 | --self-update ) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "--self-update" && echo -e "\"--self-update\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + update_selection+=("--self-update") + ;; 99) count=2 echo "restarting" From 8e654d5942c629357e8d1829636d974958c44f23 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 16:10:33 -0600 Subject: [PATCH 391/823] test ignore regex validation --- functions/menu.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 9fcafab9..2d4195a0 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -123,7 +123,7 @@ case $selection in echo "---------------" echo "bash heavy_script.sh ${update_selection[*]}" echo - read -rt 600 -p "Please type the number associated with the flag above: " current_selection + read -rt 600 -p "Type the Number OR Flag: " current_selection case $current_selection in 00) clear -x @@ -142,6 +142,7 @@ case $selection in ;; 2 | -i) read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + ! [[ $up_ignore =~ ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is invalid, that is not the name youre using for your application" && sleep 5 && continue update_selection+=("-i" "$up_ignore") ;; 3 | -r) From 1fa9e3f9084123497b3be9d9505c2d9cb6688762 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 16:48:27 -0600 Subject: [PATCH 392/823] regex changes for ignore --- functions/menu.sh | 2 +- heavy_script.sh | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 2d4195a0..95008b4a 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -142,7 +142,7 @@ case $selection in ;; 2 | -i) read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - ! [[ $up_ignore =~ ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is invalid, that is not the name youre using for your application" && sleep 5 && continue + ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is invalid, that is not the name youre using for your application" && sleep 5 && continue update_selection+=("-i" "$up_ignore") ;; 3 | -r) diff --git a/heavy_script.sh b/heavy_script.sh index 5d539c1d..61caec9a 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -71,15 +71,11 @@ do rollback="true" ;; i) - # Check next positional parameter - eval nextopt=${!OPTIND} - # existing or starting with dash? - if [[ -n $nextopt && $nextopt != -* ]] ; then - OPTIND=$((OPTIND + 1)) - ignore+=("$nextopt") - else - echo "Option: \"-i\" requires an argument" + if ! [[ $OPTARG =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]]; then # Using case insensitive version of the regex used by Truenas Scale + echo -e "Error: \"$OPTARG\" is invalid, that is not the name youre using for your application" exit + else + ignore+=("$OPTARG") fi ;; t) From 276f2126870e9c0cdc51986d7c933fad57bf9a74 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 17:00:45 -0600 Subject: [PATCH 393/823] remove hyphen in title --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index b4b88664..586cadc9 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -3,7 +3,7 @@ args=("$@") self_update() { git fetch &> /dev/null -echo "🅂 🄴 🄻 🄵 - 🅄 🄿 🄳 🄰 🅃 🄴" +echo "🅂 🄴 🄻 🄵 🅄 🄿 🄳 🄰 🅃 🄴" # TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." From 34c4e5f9cb50bb6b201cdba913237c4325f92c53 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 17:31:38 -0600 Subject: [PATCH 394/823] change ignore error message --- functions/menu.sh | 2 +- heavy_script.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 95008b4a..27e702a6 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -142,7 +142,7 @@ case $selection in ;; 2 | -i) read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is invalid, that is not the name youre using for your application" && sleep 5 && continue + ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is not a possible option for an application name" && sleep 5 && continue update_selection+=("-i" "$up_ignore") ;; 3 | -r) diff --git a/heavy_script.sh b/heavy_script.sh index 61caec9a..f0e3015c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -72,7 +72,7 @@ do ;; i) if ! [[ $OPTARG =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]]; then # Using case insensitive version of the regex used by Truenas Scale - echo -e "Error: \"$OPTARG\" is invalid, that is not the name youre using for your application" + echo -e "Error: \"$OPTARG\" is not a possible option for an application name" exit else ignore+=("$OPTARG") From 6e5a0480d9e80c82aad4537ada02cb90944d2168 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 22:23:10 -0600 Subject: [PATCH 395/823] test new mount --- functions/mount.sh | 245 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 191 insertions(+), 54 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index 880ffce4..c0785e64 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -1,63 +1,200 @@ #!/bin/bash +# mount(){ +# clear -x +# title +# echo -e "1 Mount\n2 Unmount All" && read -t 600 -p "Please type a number: " selection +# [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script +# if [[ $selection == "1" ]]; then +# list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") +# echo "$list" && read -t 120 -p "Please type a number: " selection +# [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script +# app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) +# [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script +# pvc=$(echo -e "$list" | grep ^"$selection ") +# status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") +# if [[ "$status" != "STOPPED" ]]; then +# [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" +# SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null +# else +# echo -e "\n$app is already stopped" +# fi +# while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] +# do +# status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") +# echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 +# done +# data_name=$(echo "$pvc" | awk '{print $3}') +# mount=$(echo "$pvc" | awk '{print $4}') +# volume_name=$(echo "$pvc" | awk '{print $4}') +# mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') +# if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. +# echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" +# pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") +# full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') +# fi +# echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" +# zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" +# echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" +# exit +# elif [[ $selection == "2" ]]; then +# mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") +# [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit +# for i in "${unmount_array[@]}" +# do +# main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') +# app=$(echo "$main" | awk '{print $1}' | cut -c 4-) +# pvc=$(echo "$main" | awk '{print $3}') +# mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) +# if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. +# echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" +# pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") +# full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) +# zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" +# else +# zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" +# fi +# done +# rmdir /mnt/heavyscript +# else +# echo "Invalid selection, \"$selection\" was not an option" +# fi +# } +# export -f mount + + + + mount(){ clear -x title -echo -e "1 Mount\n2 Unmount All" && read -t 600 -p "Please type a number: " selection -[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -if [[ $selection == "1" ]]; then - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") - echo "$list" && read -t 120 -p "Please type a number: " selection - [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script - app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script - pvc=$(echo -e "$list" | grep ^"$selection ") - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - if [[ "$status" != "STOPPED" ]]; then - [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" - SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null - else - echo -e "\n$app is already stopped" - fi - while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] - do +echo "1 Mount" +echo "2 Unmount All" +echo +echo "0 Exit" +read -rt 120 -p "Unmount All Please type a number: " selection + +case $selection in + 0) + echo "Exitting.." + exit + ;; + 1) + list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + echo "$list" + read -rt 120 -p "Please type a number: " selection + app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script + pvc=$(echo -e "$list" | grep ^"$selection ") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 - done - data_name=$(echo "$pvc" | awk '{print $3}') - mount=$(echo "$pvc" | awk '{print $4}') - volume_name=$(echo "$pvc" | awk '{print $4}') - mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') - if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') - fi - echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" - zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" - echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" - exit -elif [[ $selection == "2" ]]; then - mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") - [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit - for i in "${unmount_array[@]}" - do - main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') - app=$(echo "$main" | awk '{print $1}' | cut -c 4-) - pvc=$(echo "$main" | awk '{print $3}') - mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + if [[ "$status" != "STOPPED" ]]; then + [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" + SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null else - zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + echo -e "\n$app is already stopped" fi - done - rmdir /mnt/heavyscript -else - echo "Invalid selection, \"$selection\" was not an option" -fi + while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] + do + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 + done + data_name=$(echo "$pvc" | awk '{print $3}') + mount=$(echo "$pvc" | awk '{print $4}') + volume_name=$(echo "$pvc" | awk '{print $4}') + mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') + if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') + fi + echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" + zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" + echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" + exit + ;; + 2) + mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") + [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit + for i in "${unmount_array[@]}" + do + main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') + app=$(echo "$main" | awk '{print $1}' | cut -c 4-) + pvc=$(echo "$main" | awk '{print $3}') + mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + else + zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + fi + done + rmdir /mnt/heavyscript + ;; + *) + echo "Invalid selection, \"$selection\" was not an option" + ;; +esac } -export -f mount \ No newline at end of file +export -f mount + + + +# [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script +# if [[ $selection == "1" ]]; then + # list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + # echo "$list" && read -t 120 -p "Please type a number: " selection + # [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script + # app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) + # [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script + # pvc=$(echo -e "$list" | grep ^"$selection ") + # status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + # if [[ "$status" != "STOPPED" ]]; then + # [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" + # SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null + # else + # echo -e "\n$app is already stopped" + # fi + # while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] + # do + # status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + # echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 + # done + # data_name=$(echo "$pvc" | awk '{print $3}') + # mount=$(echo "$pvc" | awk '{print $4}') + # volume_name=$(echo "$pvc" | awk '{print $4}') + # mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') + # if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + # echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" + # pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + # full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') + # fi + # echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" + # zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" + # echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" + # exit +# elif [[ $selection == "2" ]]; then +# # mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") + # [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit + # for i in "${unmount_array[@]}" + # do + # main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') + # app=$(echo "$main" | awk '{print $1}' | cut -c 4-) + # pvc=$(echo "$main" | awk '{print $3}') + # mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + # if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + # echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" + # pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + # full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + # zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + # else + # zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + # fi + # done + # rmdir /mnt/heavyscript +# else +# echo "Invalid selection, \"$selection\" was not an option" +# fi +# } +# export -f mount \ No newline at end of file From 436599e7a93784e8cf7a90a16d95f71d5a9b10e4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 22:36:14 -0600 Subject: [PATCH 396/823] test new while loop for mount --- functions/mount.sh | 79 +++++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 29 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index c0785e64..ece5861d 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -76,41 +76,62 @@ read -rt 120 -p "Unmount All Please type a number: " selection case $selection in 0) - echo "Exitting.." + echo "Exiting.." exit ;; 1) - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") - echo "$list" - read -rt 120 -p "Please type a number: " selection - app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script - pvc=$(echo -e "$list" | grep ^"$selection ") - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - if [[ "$status" != "STOPPED" ]]; then - [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" - SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null - else - echo -e "\n$app is already stopped" - fi - while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] + while true do + list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + echo "$list" + read -rt 120 -p "Please type a number: " selection + app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script + pvc=$(echo -e "$list" | grep ^"$selection ") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 + if [[ "$status" != "STOPPED" ]]; then + [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" + SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null + else + echo -e "\n$app is already stopped" + fi + while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] + do + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 + done + data_name=$(echo "$pvc" | awk '{print $3}') + mount=$(echo "$pvc" | awk '{print $4}') + volume_name=$(echo "$pvc" | awk '{print $4}') + mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') + if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') + fi + echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" + zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" + echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" + while [[ $yesno != 0 ]] + do + echo "Would you like to mount anything else?" + echo "1 Yes" + echo "2 No" + read -rt 120 -p "Unmount All Please type a number: " yesno + case $yesno in + 1) + continue + ;; + 2) + exit + ;; + *) + echo "Invalid selection \"$yesno\" was not an option" sleep 3 + continue + ;; + esac + done done - data_name=$(echo "$pvc" | awk '{print $3}') - mount=$(echo "$pvc" | awk '{print $4}') - volume_name=$(echo "$pvc" | awk '{print $4}') - mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') - if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') - fi - echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" - zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" - echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" - exit ;; 2) mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") From 348fa7b3025c54df4eb01ef836fbfc2a7c724573 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 22:40:40 -0600 Subject: [PATCH 397/823] test --- functions/mount.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index ece5861d..8a8f60c0 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -112,24 +112,24 @@ case $selection in echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" - while [[ $yesno != 0 ]] + while true do - echo "Would you like to mount anything else?" - echo "1 Yes" - echo "2 No" - read -rt 120 -p "Unmount All Please type a number: " yesno - case $yesno in - 1) - continue - ;; - 2) - exit - ;; - *) - echo "Invalid selection \"$yesno\" was not an option" sleep 3 - continue - ;; - esac + echo "Would you like to mount anything else?" + echo "1 Yes" + echo "2 No" + read -rt 120 -p "Please type a number: " yesno + case $yesno in + 1) + break + ;; + 2) + exit + ;; + *) + echo "Invalid selection \"$yesno\" was not an option" sleep 3 + continue + ;; + esac done done ;; From 96cc369f32665f8822ae1b44a03bfd937bca6d3b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 22:44:28 -0600 Subject: [PATCH 398/823] test --- functions/mount.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index 8a8f60c0..6d757f56 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -68,10 +68,10 @@ mount(){ clear -x title -echo "1 Mount" -echo "2 Unmount All" +echo "1) Mount" +echo "2) Unmount All" echo -echo "0 Exit" +echo "0) Exit" read -rt 120 -p "Unmount All Please type a number: " selection case $selection in @@ -114,9 +114,9 @@ case $selection in echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" while true do - echo "Would you like to mount anything else?" - echo "1 Yes" - echo "2 No" + echo -e "\nWould you like to mount anything else?" + echo "1) Yes" + echo "2) No" read -rt 120 -p "Please type a number: " yesno case $yesno in 1) @@ -126,7 +126,8 @@ case $selection in exit ;; *) - echo "Invalid selection \"$yesno\" was not an option" sleep 3 + echo "Invalid selection \"$yesno\" was not an option" + sleep 2 continue ;; esac From a96092c37037076105a373ef1903273c8cee6c36 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 22:48:22 -0600 Subject: [PATCH 399/823] test --- functions/mount.sh | 181 +++++++++++++++++++++++---------------------- 1 file changed, 93 insertions(+), 88 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index 6d757f56..d2c4a7f9 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -66,98 +66,103 @@ mount(){ -clear -x -title -echo "1) Mount" -echo "2) Unmount All" -echo -echo "0) Exit" -read -rt 120 -p "Unmount All Please type a number: " selection +while true +do + clear -x + title + echo "1) Mount" + echo "2) Unmount All" + echo + echo "0) Exit" + read -rt 120 -p "Unmount All Please type a number: " selection -case $selection in - 0) - echo "Exiting.." - exit - ;; - 1) - while true - do - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") - echo "$list" - read -rt 120 -p "Please type a number: " selection - app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script - pvc=$(echo -e "$list" | grep ^"$selection ") - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - if [[ "$status" != "STOPPED" ]]; then - [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" - SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null - else - echo -e "\n$app is already stopped" - fi - while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] - do - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 - done - data_name=$(echo "$pvc" | awk '{print $3}') - mount=$(echo "$pvc" | awk '{print $4}') - volume_name=$(echo "$pvc" | awk '{print $4}') - mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') - if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') - fi - echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" - zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" - echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" + case $selection in + 0) + echo "Exiting.." + exit + ;; + 1) while true do - echo -e "\nWould you like to mount anything else?" - echo "1) Yes" - echo "2) No" - read -rt 120 -p "Please type a number: " yesno - case $yesno in - 1) - break - ;; - 2) - exit - ;; - *) - echo "Invalid selection \"$yesno\" was not an option" - sleep 2 - continue - ;; - esac + list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + echo "$list" + read -rt 120 -p "Please type a number: " selection + app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script + pvc=$(echo -e "$list" | grep ^"$selection ") + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + if [[ "$status" != "STOPPED" ]]; then + [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" + SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null + else + echo -e "\n$app is already stopped" + fi + while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] + do + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 + done + data_name=$(echo "$pvc" | awk '{print $3}') + mount=$(echo "$pvc" | awk '{print $4}') + volume_name=$(echo "$pvc" | awk '{print $4}') + mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') + if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') + fi + echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" + zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" + echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" + while true + do + echo -e "\nWould you like to mount anything else?" + echo "1) Yes" + echo "2) No" + read -rt 120 -p "Please type a number: " yesno + case $yesno in + 1) + break + ;; + 2) + exit + ;; + *) + echo "Invalid selection \"$yesno\" was not an option" + sleep 2 + continue + ;; + esac + done done - done - ;; - 2) - mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") - [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit - for i in "${unmount_array[@]}" - do - main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') - app=$(echo "$main" | awk '{print $1}' | cut -c 4-) - pvc=$(echo "$main" | awk '{print $3}') - mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" - else - zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" - fi - done - rmdir /mnt/heavyscript - ;; - *) - echo "Invalid selection, \"$selection\" was not an option" - ;; -esac + ;; + 2) + mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") + [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit + for i in "${unmount_array[@]}" + do + main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') + app=$(echo "$main" | awk '{print $1}' | cut -c 4-) + pvc=$(echo "$main" | awk '{print $3}') + mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + else + zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + fi + done + rmdir /mnt/heavyscript + ;; + *) + echo "Invalid selection, \"$selection\" was not an option" + sleep 2 + continue + ;; + esac +done } export -f mount From 5b51ba45b600e32c12e2989731745e83319e7441 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 22:52:54 -0600 Subject: [PATCH 400/823] remove exits from mount --- functions/mount.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index d2c4a7f9..9214da3e 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -88,7 +88,7 @@ do echo "$list" read -rt 120 -p "Please type a number: " selection app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 5 && continue #Check for valid selection. If none, kill script pvc=$(echo -e "$list" | grep ^"$selection ") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then @@ -138,7 +138,7 @@ do ;; 2) mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") - [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit + [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && sleep 3 && continue for i in "${unmount_array[@]}" do main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') From 5858610851a0e600c20ab8c8e10d0b0c6920a73f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:11:09 -0600 Subject: [PATCH 401/823] delete while loop --- functions/backup.sh | 57 ++++++++++++++++---- functions/mount.sh | 127 +------------------------------------------- 2 files changed, 47 insertions(+), 137 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 56656b9d..c28a2e7b 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -33,19 +33,54 @@ deleteBackup(){ clear -x && echo "pulling all restore points.." list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) clear -x -[[ -z "$list_backups" ]] && echo "No restore points available" && exit || { title; echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" ; } -echo "$list_backups" && read -t 600 -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') -[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script -echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" || { echo "FAILED"; exit; } -echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -t 120 -p "Please type a number: " yesno || { echo "FAILED"; exit; } -if [[ $yesno == "1" ]]; then - echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo "Sucessfully deleted" || echo "Deletion Failed" -elif [[ $yesno == "2" ]]; then - echo "You've chosen NO, killing script." +if [[ -z "$list_backups" ]]; then + echo "No restore points available" + exit else - echo "Invalid Selection" + title + echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" fi +echo "$list_backups" +read -rt 120 -p "Please type a number: " selection +restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') +#Check for valid selection. If none, kill script +if [[ -z "$selection" ]]; then + echo "Your selection cannot be empty" + exit +elif [[ -z "$restore_point" ]]; then + echo "Invalid Selection: $selection, was not an option" + exit +fi +while true +do + echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" + echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" + echo -e "Yes\n0 exit" + read -rt 120 -p "Type \"yes\" to continue, or exit with \"0\": " yesno + case $yesno in + [Yy][Ee][Ss]) + echo -e "\nDeleting $restore_point" + cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null || { echo "Failed to delete backup.."; exit; } + echo "Sucessfully deleted" + break + ;; + 0|[Ee][Xx][Ii][Tt]) + echo "Exiting" + exit + ;; + *) + echo "Invalid Selection" + ;; + esac +done +# while true +# do +# echo "Delete more?" +# echo + + +# done + } export -f deleteBackup diff --git a/functions/mount.sh b/functions/mount.sh index 9214da3e..aabc3989 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -1,70 +1,5 @@ #!/bin/bash -# mount(){ -# clear -x -# title -# echo -e "1 Mount\n2 Unmount All" && read -t 600 -p "Please type a number: " selection -# [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -# if [[ $selection == "1" ]]; then -# list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") -# echo "$list" && read -t 120 -p "Please type a number: " selection -# [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -# app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) -# [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script -# pvc=$(echo -e "$list" | grep ^"$selection ") -# status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") -# if [[ "$status" != "STOPPED" ]]; then -# [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" -# SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null -# else -# echo -e "\n$app is already stopped" -# fi -# while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] -# do -# status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") -# echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 -# done -# data_name=$(echo "$pvc" | awk '{print $3}') -# mount=$(echo "$pvc" | awk '{print $4}') -# volume_name=$(echo "$pvc" | awk '{print $4}') -# mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') -# if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. -# echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" -# pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") -# full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') -# fi -# echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" -# zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" -# echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" -# exit -# elif [[ $selection == "2" ]]; then -# mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") -# [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit -# for i in "${unmount_array[@]}" -# do -# main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') -# app=$(echo "$main" | awk '{print $1}' | cut -c 4-) -# pvc=$(echo "$main" | awk '{print $3}') -# mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) -# if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. -# echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" -# pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") -# full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) -# zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" -# else -# zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" -# fi -# done -# rmdir /mnt/heavyscript -# else -# echo "Invalid selection, \"$selection\" was not an option" -# fi -# } -# export -f mount - - - - mount(){ while true do @@ -164,64 +99,4 @@ do esac done } -export -f mount - - - -# [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -# if [[ $selection == "1" ]]; then - # list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") - # echo "$list" && read -t 120 -p "Please type a number: " selection - # [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script - # app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - # [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script - # pvc=$(echo -e "$list" | grep ^"$selection ") - # status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - # if [[ "$status" != "STOPPED" ]]; then - # [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" - # SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null - # else - # echo -e "\n$app is already stopped" - # fi - # while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] - # do - # status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - # echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 - # done - # data_name=$(echo "$pvc" | awk '{print $3}') - # mount=$(echo "$pvc" | awk '{print $4}') - # volume_name=$(echo "$pvc" | awk '{print $4}') - # mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') - # if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - # echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" - # pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - # full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') - # fi - # echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" - # zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" - # echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" - # exit -# elif [[ $selection == "2" ]]; then -# # mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") - # [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit - # for i in "${unmount_array[@]}" - # do - # main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') - # app=$(echo "$main" | awk '{print $1}' | cut -c 4-) - # pvc=$(echo "$main" | awk '{print $3}') - # mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - # if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - # echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" - # pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - # full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - # zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" - # else - # zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" - # fi - # done - # rmdir /mnt/heavyscript -# else -# echo "Invalid selection, \"$selection\" was not an option" -# fi -# } -# export -f mount \ No newline at end of file +export -f mount \ No newline at end of file From 26815e9783dbc9e16257cc6ad24d13f27813c2af Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:22:06 -0600 Subject: [PATCH 402/823] test loop --- functions/backup.sh | 113 +++++++++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 48 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index c28a2e7b..b8946e4a 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -30,57 +30,74 @@ export -f backup deleteBackup(){ -clear -x && echo "pulling all restore points.." -list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) -clear -x -if [[ -z "$list_backups" ]]; then - echo "No restore points available" - exit -else - title - echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" -fi -echo "$list_backups" -read -rt 120 -p "Please type a number: " selection -restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') -#Check for valid selection. If none, kill script -if [[ -z "$selection" ]]; then - echo "Your selection cannot be empty" - exit -elif [[ -z "$restore_point" ]]; then - echo "Invalid Selection: $selection, was not an option" - exit -fi while true do - echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" - echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" - echo -e "Yes\n0 exit" - read -rt 120 -p "Type \"yes\" to continue, or exit with \"0\": " yesno - case $yesno in - [Yy][Ee][Ss]) - echo -e "\nDeleting $restore_point" - cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null || { echo "Failed to delete backup.."; exit; } - echo "Sucessfully deleted" - break - ;; - 0|[Ee][Xx][Ii][Tt]) - echo "Exiting" - exit - ;; - *) - echo "Invalid Selection" - ;; - esac + clear -x && echo "pulling all restore points.." + list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) + clear -x + if [[ -z "$list_backups" ]]; then + echo "No restore points available" + exit + else + title + echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" + fi + echo "$list_backups" + read -rt 120 -p "Please type a number: " selection + restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') + #Check for valid selection. If none, kill script + if [[ -z "$selection" ]]; then + echo "Your selection cannot be empty" + continue + elif [[ -z "$restore_point" ]]; then + echo "Invalid Selection: $selection, was not an option" + continue + fi + while true + do + echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" + echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" + echo -e "Yes\n0 exit\n" + read -rt 120 -p "Type \"yes\" to continue, or exit with \"0\": " yesno + case $yesno in + [Yy][Ee][Ss]) + echo -e "\nDeleting $restore_point" + cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null || { echo "Failed to delete backup.."; exit; } + echo "Sucessfully deleted" + break + ;; + 0|[Ee][Xx][Ii][Tt]) + echo "Exiting" + exit + ;; + *) + echo "Invalid Selection" + ;; + esac + done + while true + do + echo "Delete more?" + echo "1 Yes" + echo "2 No" + read -rt 120 -p "Please type a number: " yesno + case $yesno in + 1) + break + ;; + 2) + exit + ;; + *) + echo "$yesno was not an option, try again" + sleep 2 + continue + ;; + + esac + + done done -# while true -# do -# echo "Delete more?" -# echo - - -# done - } export -f deleteBackup From 7c9cf2366448decc28d414086b43146db009a7c5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:32:01 -0600 Subject: [PATCH 403/823] test nl --- functions/backup.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index b8946e4a..f2e37b6f 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -33,7 +33,7 @@ deleteBackup(){ while true do clear -x && echo "pulling all restore points.." - list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) + list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s \) | column -t) clear -x if [[ -z "$list_backups" ]]; then echo "No restore points available" @@ -48,38 +48,43 @@ do #Check for valid selection. If none, kill script if [[ -z "$selection" ]]; then echo "Your selection cannot be empty" + sleep 3 continue elif [[ -z "$restore_point" ]]; then echo "Invalid Selection: $selection, was not an option" + sleep 3 continue fi while true do + clear -x echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" - echo -e "Yes\n0 exit\n" - read -rt 120 -p "Type \"yes\" to continue, or exit with \"0\": " yesno + echo -e "1) Yes\n2) Exit\n" + read -rt 120 -p "Please type a number: " yesno case $yesno in - [Yy][Ee][Ss]) + 1) echo -e "\nDeleting $restore_point" cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null || { echo "Failed to delete backup.."; exit; } echo "Sucessfully deleted" break ;; - 0|[Ee][Xx][Ii][Tt]) + 2) echo "Exiting" exit ;; *) - echo "Invalid Selection" + echo "That was not an option, try again" + sleep 3 + continue ;; esac done while true do echo "Delete more?" - echo "1 Yes" - echo "2 No" + echo "1) Yes" + echo "2) No" read -rt 120 -p "Please type a number: " yesno case $yesno in 1) From 7ad86534f0356758a55e9cdc7a9eded55d298dce Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:32:45 -0600 Subject: [PATCH 404/823] test --- functions/backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/backup.sh b/functions/backup.sh index f2e37b6f..7fa5f08f 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -33,7 +33,7 @@ deleteBackup(){ while true do clear -x && echo "pulling all restore points.." - list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s \) | column -t) + list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t) clear -x if [[ -z "$list_backups" ]]; then echo "No restore points available" From 048efbd4ba08b6a50d3aae680824606930a1e237 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:33:44 -0600 Subject: [PATCH 405/823] fix regex --- functions/backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/backup.sh b/functions/backup.sh index 7fa5f08f..80ab8ec2 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -44,7 +44,7 @@ do fi echo "$list_backups" read -rt 120 -p "Please type a number: " selection - restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') + restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') #Check for valid selection. If none, kill script if [[ -z "$selection" ]]; then echo "Your selection cannot be empty" From 4b3847c6fc391d46f54e536ef44d81c6cc72296a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:46:08 -0600 Subject: [PATCH 406/823] restore improvement --- functions/backup.sh | 66 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 80ab8ec2..ffc90786 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -108,21 +108,55 @@ export -f deleteBackup restore(){ -clear -x && echo "pulling restore points.." -list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) -clear -x -[[ -z "$list_backups" ]] && echo "No HeavyScript restore points available" && exit || { title; echo "Choose a restore point" ; } -echo "$list_backups" && read -t 600 -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') -[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script -echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" || { echo "FAILED"; exit; } -echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -t 120 -p "Please type a number: " yesno || { echo "FAILED"; exit; } -if [[ $yesno == "1" ]]; then - echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" -elif [[ $yesno == "2" ]]; then - echo "You've chosen NO, killing script. Good luck." -else - echo "Invalid Selection" -fi +while true +do + clear -x && echo "pulling restore points.." + list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t) + clear -x + if [[ -z "$list_backups" ]]; then + echo "No HeavyScript restore points available" + exit + else + title + echo "Choose a restore point" + fi + echo "$list_backups" + read -rt 120 -p "Please type a number: " selection + restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') + #Check for valid selection. If none, kill script + if [[ -z "$selection" ]]; then + echo "Your selection cannot be empty" + sleep 3 + continue + elif [[ -z "$restore_point" ]]; then + echo "Invalid Selection: $selection, was not an option" + sleep 3 + continue + fi + while true + do + clear -x + echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" + echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" + echo -e "1) Yes\n2) Exit\n" + read -rt 120 -p "Please type a number: " yesno + case $yesno in + 1) + echo -e "\nStarting Backup, this will take a LONG time." + cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || { echo "Failed to delete backup.."; exit; } + exit + ;; + 2) + echo "Exiting" + exit + ;; + *) + echo "That was not an option, try again" + sleep 3 + continue + ;; + esac + done +done } export -f restore \ No newline at end of file From 79f957f8ac26f296eb19ae69c6343f552736fc0a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:49:53 -0600 Subject: [PATCH 407/823] exit option --- functions/backup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/backup.sh b/functions/backup.sh index ffc90786..9199a560 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -121,7 +121,10 @@ do echo "Choose a restore point" fi echo "$list_backups" + echo + echo "0) Exit" read -rt 120 -p "Please type a number: " selection + [[ $selection == 0 ]] && echo "Exiting.." && exit restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') #Check for valid selection. If none, kill script if [[ -z "$selection" ]]; then From 719e1088af8a22a1596e6537809f417bea5ddebf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:51:33 -0600 Subject: [PATCH 408/823] exit option for deletebackup --- functions/backup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/backup.sh b/functions/backup.sh index 9199a560..adc3fece 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -43,7 +43,10 @@ do echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" fi echo "$list_backups" + echo + echo "0) Exit" read -rt 120 -p "Please type a number: " selection + [[ $selection == 0 ]] && echo "Exiting.." && exit restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') #Check for valid selection. If none, kill script if [[ -z "$selection" ]]; then From 4841c568fa0ad305c6c0bb398967291776f4dda0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:08:30 -0600 Subject: [PATCH 409/823] better message --- functions/backup.sh | 4 ++-- functions/mount.sh | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index adc3fece..1345eae2 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -40,7 +40,7 @@ do exit else title - echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" + echo -e "Choose a Restore Point to Delete\nThese may be out of order if they are not HeavyScript backups" fi echo "$list_backups" echo @@ -121,7 +121,7 @@ do exit else title - echo "Choose a restore point" + echo "Choose a Restore Point" fi echo "$list_backups" echo diff --git a/functions/mount.sh b/functions/mount.sh index aabc3989..8a096579 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -90,6 +90,7 @@ do fi done rmdir /mnt/heavyscript + sleep 2 ;; *) echo "Invalid selection, \"$selection\" was not an option" From 571e00a2f4f76da51cff664d26c7969886ddd308 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:25:20 -0600 Subject: [PATCH 410/823] delete-backup avoid extra calls --- functions/backup.sh | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 1345eae2..916291ff 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -42,22 +42,27 @@ do title echo -e "Choose a Restore Point to Delete\nThese may be out of order if they are not HeavyScript backups" fi - echo "$list_backups" - echo - echo "0) Exit" - read -rt 120 -p "Please type a number: " selection - [[ $selection == 0 ]] && echo "Exiting.." && exit - restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') - #Check for valid selection. If none, kill script - if [[ -z "$selection" ]]; then - echo "Your selection cannot be empty" - sleep 3 - continue - elif [[ -z "$restore_point" ]]; then - echo "Invalid Selection: $selection, was not an option" - sleep 3 - continue - fi + while true + do + echo "$list_backups" + echo + echo "0) Exit" + read -rt 120 -p "Please type a number: " selection + restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') + if [[ $selection == 0 ]]; then + echo "Exiting.." + exit + elif [[ -z "$selection" ]]; then + echo "Your selection cannot be empty" + sleep 3 + continue + elif [[ -z "$restore_point" ]]; then + echo "Invalid Selection: $selection, was not an option" + sleep 3 + continue + fi + break + done while true do clear -x From 291ad68542dc1db84e16a8773eff9332307e6770 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:26:47 -0600 Subject: [PATCH 411/823] fix --- functions/backup.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 916291ff..2dd2c960 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -34,16 +34,15 @@ while true do clear -x && echo "pulling all restore points.." list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t) - clear -x if [[ -z "$list_backups" ]]; then echo "No restore points available" exit - else - title - echo -e "Choose a Restore Point to Delete\nThese may be out of order if they are not HeavyScript backups" fi while true do + clear -x + title + echo -e "Choose a Restore Point to Delete\nThese may be out of order if they are not HeavyScript backups" echo "$list_backups" echo echo "0) Exit" From 73f060cea334d8325c7c744a5a909dbc9ff62024 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:34:55 -0600 Subject: [PATCH 412/823] restore update --- functions/backup.sh | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 2dd2c960..b875e08c 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -119,30 +119,33 @@ while true do clear -x && echo "pulling restore points.." list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t) - clear -x if [[ -z "$list_backups" ]]; then echo "No HeavyScript restore points available" exit - else + fi + while true + do + clear -x title echo "Choose a Restore Point" - fi - echo "$list_backups" - echo - echo "0) Exit" - read -rt 120 -p "Please type a number: " selection - [[ $selection == 0 ]] && echo "Exiting.." && exit - restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') - #Check for valid selection. If none, kill script - if [[ -z "$selection" ]]; then - echo "Your selection cannot be empty" - sleep 3 - continue - elif [[ -z "$restore_point" ]]; then - echo "Invalid Selection: $selection, was not an option" - sleep 3 - continue - fi + echo "$list_backups" + echo + echo "0) Exit" + read -rt 120 -p "Please type a number: " selection + restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') + if [[ $selection == 0 ]]; then + echo "Exiting.." + exit + elif [[ -z "$selection" ]]; then + echo "Your selection cannot be empty" + sleep 3 + continue + elif [[ -z "$restore_point" ]]; then + echo "Invalid Selection: $selection, was not an option" + sleep 3 + continue + fi + done while true do clear -x From 06c80dd5ebc1dc5619b4fa720adf33b06664b16a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:35:54 -0600 Subject: [PATCH 413/823] break --- functions/backup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/backup.sh b/functions/backup.sh index b875e08c..9561b5d6 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -145,6 +145,7 @@ do sleep 3 continue fi + break done while true do From 21c46258f62b523e35f3ea5e925961ed0678c156 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:45:22 -0600 Subject: [PATCH 414/823] break on bottom line --- functions/update_apps.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 460877eb..be33626f 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -117,11 +117,13 @@ if [[ $rollback == "true" ]]; then elif [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - echo_array+=("Stopped") && break #if reports stopped any time after the first loop, assume its extermal services. + echo_array+=("Stopped") + break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$status" == "ACTIVE" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - echo_array+=("Active") && break #if reports active any time after the first loop, assume actually active. + echo_array+=("Active") + break #if reports active any time after the first loop, assume actually active. else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") sleep 15 @@ -137,7 +139,7 @@ else if [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - echo_array+=("Stopped") && break #assume actually stopped anytime AFTER the first loop + echo_array+=("Stopped") #assume actually stopped anytime AFTER the first loop break elif [[ "$status" == "ACTIVE" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check From 542ac5ee0b6582f7d89aad286c5d73ffe5e46a9e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:47:38 -0600 Subject: [PATCH 415/823] remove unused help --- heavy_script.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index f0e3015c..adb5022c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -52,14 +52,14 @@ do deleteBackup="true" ;; *) - echo -e "Invalid Option \"--$OPTARG\"\n" && help - exit + echo -e "Invalid Option \"--$OPTARG\"\n" + help ;; esac ;; :) - echo -e "Option: \"-$OPTARG\" requires an argument\n" && help - exit + echo -e "Option: \"-$OPTARG\" requires an argument\n" + help ;; b) number_of_backups=$OPTARG @@ -119,12 +119,12 @@ do verbose="true" ;; \?) - echo -e "Invalid Option \"-$OPTARG\"\n" && help - exit + echo -e "Invalid Option \"-$OPTARG\"\n" + help ;; *) - echo -e "Invalid Option \"-$OPTARG\"\n" && help - exit + echo -e "Invalid Option \"-$OPTARG\"\n" + help ;; esac done From 3107bc97cd351ba5aa3f58b93c04dde5d5d85fd7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:50:33 -0600 Subject: [PATCH 416/823] change lines --- functions/mount.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index 8a096579..ec2d7938 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -84,9 +84,11 @@ do echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + zfs set mountpoint=legacy "$full_path""$pvc" + echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" else - zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + zfs set mountpoint=legacy "$path""$pvc" + echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" fi done rmdir /mnt/heavyscript From b1c62e68922664fe64f66a14752427816c246374 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:52:26 -0600 Subject: [PATCH 417/823] mount clear after continue --- functions/mount.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/mount.sh b/functions/mount.sh index ec2d7938..210f9699 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -57,6 +57,7 @@ do read -rt 120 -p "Please type a number: " yesno case $yesno in 1) + clear -x break ;; 2) From 42558612463d4c463f470e205492a050d6cbd3c3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:53:11 -0600 Subject: [PATCH 418/823] add title again --- functions/mount.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/mount.sh b/functions/mount.sh index 210f9699..da01352d 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -58,6 +58,7 @@ do case $yesno in 1) clear -x + title break ;; 2) From f1f495544ba59218b7802b890e81dcc214e4bb5c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:56:12 -0600 Subject: [PATCH 419/823] better output after invalid --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index da01352d..993e4d51 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -23,7 +23,7 @@ do echo "$list" read -rt 120 -p "Please type a number: " selection app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 5 && continue #Check for valid selection. If none, kill script + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && clear -x && title && echo "$list" continue #Check for valid selection. If none, contiue pvc=$(echo -e "$list" | grep ^"$selection ") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then From fd26ef349a38e7c6b9b597789bdd36197d5b35b5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:56:55 -0600 Subject: [PATCH 420/823] whoops --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index 993e4d51..c52ee704 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -23,7 +23,7 @@ do echo "$list" read -rt 120 -p "Please type a number: " selection app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && clear -x && title && echo "$list" continue #Check for valid selection. If none, contiue + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && clear -x && title && echo "$list" && continue #Check for valid selection. If none, contiue pvc=$(echo -e "$list" | grep ^"$selection ") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then From a211dc9a8ae7d72e68c66f0e334e60afed15913f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:58:49 -0600 Subject: [PATCH 421/823] tired --- functions/mount.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index c52ee704..d88253cd 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -20,10 +20,12 @@ do while true do list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + clear -x + title echo "$list" read -rt 120 -p "Please type a number: " selection app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && clear -x && title && echo "$list" && continue #Check for valid selection. If none, contiue + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && continue #Check for valid selection. If none, contiue pvc=$(echo -e "$list" | grep ^"$selection ") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then From 22589499ada538ad9272c9826fb335a47cae072d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:02:13 -0600 Subject: [PATCH 422/823] avoid calling more than once --- functions/mount.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index d88253cd..8082d0f8 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -10,7 +10,7 @@ do echo echo "0) Exit" read -rt 120 -p "Unmount All Please type a number: " selection - + list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") case $selection in 0) echo "Exiting.." @@ -19,7 +19,6 @@ do 1) while true do - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") clear -x title echo "$list" From 717306e01f39d075d1fc925c54d723aac8bbe452 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:03:01 -0600 Subject: [PATCH 423/823] only list with option 1 --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index 8082d0f8..422a10e3 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -10,13 +10,13 @@ do echo echo "0) Exit" read -rt 120 -p "Unmount All Please type a number: " selection - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") case $selection in 0) echo "Exiting.." exit ;; 1) + list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") while true do clear -x From 4f303e3489a40dbdcf1315cd367366e1c0af2302 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:22:59 -0600 Subject: [PATCH 424/823] while loop for async check --- functions/menu.sh | 72 ++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 27e702a6..710a144a 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -59,39 +59,47 @@ case $selection in echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 1 ]]; then - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 5 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 5 - continue - else - update_selection+=("-U" "$up_async") - break - fi + while true + do + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 5 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 5 + continue + else + update_selection+=("-U" "$up_async") + break + fi + done + break elif [[ $current_selection == 2 ]]; then - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 5 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 5 - continue - else - update_selection+=("-u" "$up_async") - break - fi + while true + do + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 5 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 5 + continue + else + update_selection+=("-u" "$up_async") + break + fi + done + break elif [[ $current_selection == 0 ]]; then echo "Exiting.." exit From c7c3be0d95a7a5ad3368d0d6ed0105add3e44313 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:26:47 -0600 Subject: [PATCH 425/823] exit for updates menu --- functions/menu.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index 710a144a..8330cc33 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -127,12 +127,18 @@ case $selection in echo "99) Remove Update Options, Restart" echo "00) Done making selections, proceed with update" echo + echo "0) Exit" + echo echo "Current Choices" echo "---------------" echo "bash heavy_script.sh ${update_selection[*]}" echo read -rt 600 -p "Type the Number OR Flag: " current_selection case $current_selection in + 0) + echo "Exiting.." + exit + ;; 00) clear -x echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" From 3baffef323f522cc511d994a2f5a42372050ce5b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:30:27 -0600 Subject: [PATCH 426/823] exit menu mount --- functions/mount.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/mount.sh b/functions/mount.sh index 422a10e3..c15158b3 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -22,7 +22,10 @@ do clear -x title echo "$list" + echo + echo "0 Exit" read -rt 120 -p "Please type a number: " selection + [[ $selection == 0 ]] && echo "Exiting.." && exit app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && continue #Check for valid selection. If none, contiue pvc=$(echo -e "$list" | grep ^"$selection ") From d70bb33dd3dadbba040402ab4cad42e23892e526 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:51:37 -0600 Subject: [PATCH 427/823] test --- functions/mount.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index c15158b3..cd700a67 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -16,7 +16,11 @@ do exit ;; 1) - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + call=$(k3s kubectl get pvc -A | sort -u | awk '{print $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + mount_list=$(echo "$call" | sed 1d | nl -s ") ") + mount_title=$(echo "$call" | head -n 1) + list=$(echo -e "$mount_title \n $mount_title") + while true do clear -x From e39912f0b1bee19658a0d484224cf11de7bb5935 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:52:27 -0600 Subject: [PATCH 428/823] test --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index cd700a67..d0c28ce1 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -19,7 +19,7 @@ do call=$(k3s kubectl get pvc -A | sort -u | awk '{print $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") mount_list=$(echo "$call" | sed 1d | nl -s ") ") mount_title=$(echo "$call" | head -n 1) - list=$(echo -e "$mount_title \n $mount_title") + list=$(echo -e "$mount_title\n$mount_list") while true do From dba0e738e6ec96d7f6f44299c71104b322f13ec4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:53:05 -0600 Subject: [PATCH 429/823] test --- functions/mount.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index d0c28ce1..0778a522 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -16,10 +16,10 @@ do exit ;; 1) - call=$(k3s kubectl get pvc -A | sort -u | awk '{print $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + call=$(k3s kubectl get pvc -A | sort -u | awk '{print $1 "\t" $2 "\t" $4}' | sed "s/^0/ /") mount_list=$(echo "$call" | sed 1d | nl -s ") ") mount_title=$(echo "$call" | head -n 1) - list=$(echo -e "$mount_title\n$mount_list") + list=$(echo -e "$mount_title\n$mount_list" | column -t) while true do From 978fdd7866b32f78d305fad2c8365c892818e1df Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:53:49 -0600 Subject: [PATCH 430/823] test --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index 0778a522..b155071e 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -19,7 +19,7 @@ do call=$(k3s kubectl get pvc -A | sort -u | awk '{print $1 "\t" $2 "\t" $4}' | sed "s/^0/ /") mount_list=$(echo "$call" | sed 1d | nl -s ") ") mount_title=$(echo "$call" | head -n 1) - list=$(echo -e "$mount_title\n$mount_list" | column -t) + list=$(echo -e "# $mount_title\n$mount_list" | column -t) while true do From 4e24d1577e5256ad9e84bedbe5ef3e246bdb78a8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:55:09 -0600 Subject: [PATCH 431/823] test --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index b155071e..82909364 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -19,7 +19,7 @@ do call=$(k3s kubectl get pvc -A | sort -u | awk '{print $1 "\t" $2 "\t" $4}' | sed "s/^0/ /") mount_list=$(echo "$call" | sed 1d | nl -s ") ") mount_title=$(echo "$call" | head -n 1) - list=$(echo -e "# $mount_title\n$mount_list" | column -t) + list=$(echo -e "# $mount_title\n$mount_list\n\n0) Exit" | column -t) while true do From 67a6436944e4f0eb6362c6728cd2f673fabf1819 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:56:58 -0600 Subject: [PATCH 432/823] mount number brackets --- functions/mount.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index 82909364..52a32359 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -19,7 +19,7 @@ do call=$(k3s kubectl get pvc -A | sort -u | awk '{print $1 "\t" $2 "\t" $4}' | sed "s/^0/ /") mount_list=$(echo "$call" | sed 1d | nl -s ") ") mount_title=$(echo "$call" | head -n 1) - list=$(echo -e "# $mount_title\n$mount_list\n\n0) Exit" | column -t) + list=$(echo -e "# $mount_title\n$mount_list" | column -t) while true do @@ -27,12 +27,12 @@ do title echo "$list" echo - echo "0 Exit" + echo "0) Exit" read -rt 120 -p "Please type a number: " selection [[ $selection == 0 ]] && echo "Exiting.." && exit - app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) + app=$(echo -e "$list" | grep ^"$selection)" | awk '{print $2}' | cut -c 4- ) [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && continue #Check for valid selection. If none, contiue - pvc=$(echo -e "$list" | grep ^"$selection ") + pvc=$(echo -e "$list" | grep ^"$selection)") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" From df19c4f553971e6fd7e1540598d354994bdcfedd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:58:44 -0600 Subject: [PATCH 433/823] mounting complete --- functions/mount.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index 52a32359..e574fcac 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -20,7 +20,6 @@ do mount_list=$(echo "$call" | sed 1d | nl -s ") ") mount_title=$(echo "$call" | head -n 1) list=$(echo -e "# $mount_title\n$mount_list" | column -t) - while true do clear -x From dd598adf6071743f58189c30e9365f4eee6c3ef6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 19:15:50 +0000 Subject: [PATCH 434/823] change self-update from beta to main --- functions/self_update.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 586cadc9..5c2178d0 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -4,8 +4,7 @@ args=("$@") self_update() { git fetch &> /dev/null echo "🅂 🄴 🄻 🄵 🅄 🄿 🄳 🄰 🅃 🄴" -# TODO: change beta to main once testing is complete -if git diff --name-only origin/beta | grep -qs ".sh" ; then +if git diff --name-only origin/main | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q @@ -25,4 +24,4 @@ else echo -e "HeavyScript is already the latest version\n" fi } -export -f self_update \ No newline at end of file +export -f self_update From 43075b8533864eaebc2bc74b3ea482d227b28edf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 20:19:59 +0000 Subject: [PATCH 435/823] remove spaces --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index eae9ad0b..3dd5d4d3 100644 --- a/README.md +++ b/README.md @@ -42,9 +42,7 @@ ### Examples #### Typical Cron Job ``` - bash heavy_script.sh --self-update -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsp -u 5 - ``` > `-b` is set to 14. Up to 14 snapshots of your ix-applications dataset will be saved From 14942a92e09f56d721ecc4ed0c786f68b0a279e7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 20:20:58 +0000 Subject: [PATCH 436/823] remove double --self-update --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 3dd5d4d3..45cea470 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,6 @@ bash heavy_script.sh --self-update -b 14 -i portainer -i arch -i sonarr -i radar > `--self-update` Will update the script prior to running anything else. -> `--self-update` Will update the script prior to running anything else. #### Mounting PVC Data From 482cc99837761a80c0d02f9ac9f8ffba3f435d96 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 20:33:30 +0000 Subject: [PATCH 437/823] return : in ignore --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 6de0e9de..db7068c2 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -32,7 +32,7 @@ source functions/update_apps.sh # Parse script options -while getopts ":sirb:t:uUpSRv-:" opt +while getopts ":si:rb:t:uUpSRv-:" opt do case $opt in -) From 1ce6422f2361353fd428212bcbbe75c8f34961ed Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 16:13:01 -0600 Subject: [PATCH 438/823] change invalid input to sleep 3 --- functions/backup.sh | 2 +- functions/menu.sh | 40 ++++++++++++++++++++-------------------- functions/mount.sh | 6 +++--- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 9561b5d6..9f2de90f 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -60,7 +60,7 @@ do sleep 3 continue fi - break + break # Break out of the loop if all of the If statement checks above are untrue done while true do diff --git a/functions/menu.sh b/functions/menu.sh index 8330cc33..b9d0bcc5 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -66,12 +66,12 @@ case $selection in if [[ $up_async == 0 ]]; then echo "Error: \"$up_async\" is less than 1" echo "NOT adding it to the list" - sleep 5 + sleep 3 continue elif ! [[ $up_async =~ ^[0-9]+$ ]]; then echo "Error: \"$up_async\" is invalid, it needs to be an integer" echo "NOT adding it to the list" - sleep 5 + sleep 3 continue else update_selection+=("-U" "$up_async") @@ -87,12 +87,12 @@ case $selection in if [[ $up_async == 0 ]]; then echo "Error: \"$up_async\" is less than 1" echo "NOT adding it to the list" - sleep 5 + sleep 3 continue elif ! [[ $up_async =~ ^[0-9]+$ ]]; then echo "Error: \"$up_async\" is invalid, it needs to be an integer" echo "NOT adding it to the list" - sleep 5 + sleep 3 continue else update_selection+=("-u" "$up_async") @@ -104,7 +104,7 @@ case $selection in echo "Exiting.." exit else - echo "$current_selection was not an option, try again" && sleep 5 + echo "$current_selection was not an option, try again" && sleep 3 continue fi done @@ -147,48 +147,48 @@ case $selection in exit ;; 1 | -b) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups - ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue + ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue + [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 3 && continue update_selection+=("-b" "$up_backups") ;; 2 | -i) read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is not a possible option for an application name" && sleep 5 && continue + ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is not a possible option for an application name" && sleep 3 && continue update_selection+=("-i" "$up_ignore") ;; 3 | -r) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it update_selection+=("-r") ;; 4 | -S) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-S" && echo -e "\"-S\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-S" && echo -e "\"-S\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it update_selection+=("-S") ;; 5 | -v) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-v" && echo -e "\"-v\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-v" && echo -e "\"-v\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it update_selection+=("-v") ;; 6 | -t) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout - ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue update_selection+=("-t" "$up_timeout") ;; 7 | -s) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-s" && echo -e "\"-s\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-s" && echo -e "\"-s\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it update_selection+=("-s") ;; 8 | -p) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it update_selection+=("-p") ;; 9 | --self-update ) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "--self-update" && echo -e "\"--self-update\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "--self-update" && echo -e "\"--self-update\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it update_selection+=("--self-update") ;; 99) @@ -200,17 +200,17 @@ case $selection in echo "$i removed" ((count++)) done - sleep 5 + sleep 3 continue ;; *) - echo "\"$current_selection\" was not an option, try again" && sleep 5 && continue + echo "\"$current_selection\" was not an option, try again" && sleep 3 && continue ;; esac done ;; *) - echo "\"$selection\" was not an option, please try agian" && sleep 5 && menu + echo "\"$selection\" was not an option, please try agian" && sleep 3 && menu ;; esac echo diff --git a/functions/mount.sh b/functions/mount.sh index e574fcac..db369b4c 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -73,7 +73,7 @@ do ;; *) echo "Invalid selection \"$yesno\" was not an option" - sleep 2 + sleep 3 continue ;; esac @@ -101,11 +101,11 @@ do fi done rmdir /mnt/heavyscript - sleep 2 + sleep 3 ;; *) echo "Invalid selection, \"$selection\" was not an option" - sleep 2 + sleep 3 continue ;; esac From c20898c396a53a5983c95c18881a223a85c96639 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 16:18:44 -0600 Subject: [PATCH 439/823] Change backups to 10 README --- README.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 45cea470..7199c34e 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ | --dns | --dns | None | list all of your applications DNS names and their web ports | | -U | -U
-U 5 | None or Integer | Update applications, ignoring major version changes
_Optionally, you can supply a number after the argument to update multiple applications at once_ | | -u | -u
-u 5 | None or Integer | Update applications, do NOT update if there was a major version change
_Optionally, you can supply a number after the argument to update multiple applications at once_ | -| -b | -b 14 | Integer | Backup `ix-appliactions` dataset
_Creates backups up to the number you've chosen_ | +| -b | -b 10 | Integer | Backup `ix-appliactions` dataset
_Creates backups up to the number you've chosen_ | | -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating
_List one application after another as shown in the example_ | | -r | -r | None | Monitors applications after they update
If the app does not become "ACTIVE" after either:
The custom Timeout, or Default Timeout,
rollback the application. | | -v | -v | None | Verbose Output
_Look at the bottom of this page for an example_ | @@ -42,10 +42,10 @@ ### Examples #### Typical Cron Job ``` -bash heavy_script.sh --self-update -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsp -u 5 +bash heavy_script.sh --self-update -b 10 -i portainer -i arch -i sonarr -i radarr -t 600 -rsp -u 5 ``` -> `-b` is set to 14. Up to 14 snapshots of your ix-applications dataset will be saved +> `-b` is set to 10. Up to 10 snapshots of your ix-applications dataset will be saved > `-i` is set to ignore portainer, arch, sonarr, and radarr. These applications will be ignored when it comes to updates. @@ -88,10 +88,9 @@ bash /mnt/tank/scripts/heavy_script/heavy_script.sh --dns ``` #### My personal Cron Job + ``` - -bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 14 -rsp -u 10 - +bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 10 -rsp -u 10 ```
@@ -147,7 +146,7 @@ git pull ### Update with the scripts built-in option ``` -bash heavyscript.sh --self-update -b 14 -supr +bash heavyscript.sh --self-update -b 10 -supr ``` > The important argument here is the `--self-update`, you can still use all of your same arguments with this option. @@ -166,7 +165,7 @@ bash heavyscript.sh --self-update -b 14 -supr | Name | Value | Reason | |------------------------ |------------------------------------------------------------------------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `Description` | HeavyScript git pull and Update apps | This is up to you, put whatever you think is a good description in here | -| `Command` | `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh --self-update -b 14 -rsup` | This is the command you will be running on your schedule I personally use: `bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 14 -rsup` | +| `Command` | `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh --self-update -b 10 -rsup` | This is the command you will be running on your schedule I personally use: `bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 10 -rsup` | | `Run As User` | `root` | Running the script as `root` is REQUIRED. You cannot access all of the kubernetes functions without this user. | | `Schedule` | Up to you, I run mine everyday at `0400` | Again up to you | | `Hide Standard Output` | `False` or Unticked | I like to receive an email report of how the script ran, what apps updated etc. | From d99e377134397a9bffecf56b49cae4e98691a9ea Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 30 Jul 2022 15:58:54 -0600 Subject: [PATCH 440/823] Remove redundant cd --- functions/menu.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index b9d0bcc5..3a671fc1 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -1,10 +1,6 @@ #!/bin/bash menu(){ -script=$(readlink -f "$0") -script_path=$(dirname "$script") -script_name="heavy_script.sh" -cd "$script_path" || exit clear -x title echo "1) Help" From ebb472dae789b5455e85aff53a62c9ba3ca4b084 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 30 Jul 2022 16:12:45 -0600 Subject: [PATCH 441/823] timeout 120 instead of 600 --- functions/menu.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 3a671fc1..365dd773 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -13,7 +13,7 @@ echo "7) Update HeavyScript" echo "8) Update Applications" echo echo "0) Exit" -read -rt 600 -p "Please select an option by number: " selection +read -rt 120 -p "Please select an option by number: " selection case $selection in 0) @@ -29,7 +29,7 @@ case $selection in mount="true" ;; 4) - read -rt 600 -p "What is the maximun number of backups you would like?: " number_of_backups + read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups backup="true" ;; 5) @@ -53,12 +53,12 @@ case $selection in echo echo "0) Exit" echo - read -rt 600 -p "Please type the number associated with the flag above: " current_selection + read -rt 120 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 1 ]]; then while true do echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async + read -rt 120 -p "Please type an integer greater than 0: " up_async if [[ $up_async == 0 ]]; then echo "Error: \"$up_async\" is less than 1" echo "NOT adding it to the list" @@ -79,7 +79,7 @@ case $selection in while true do echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async + read -rt 120 -p "Please type an integer greater than 0: " up_async if [[ $up_async == 0 ]]; then echo "Error: \"$up_async\" is less than 1" echo "NOT adding it to the list" @@ -129,7 +129,7 @@ case $selection in echo "---------------" echo "bash heavy_script.sh ${update_selection[*]}" echo - read -rt 600 -p "Type the Number OR Flag: " current_selection + read -rt 120 -p "Type the Number OR Flag: " current_selection case $current_selection in 0) echo "Exiting.." @@ -145,13 +145,13 @@ case $selection in 1 | -b) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" - read -rt 600 -p "Please type an integer: " up_backups + read -rt 120 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 3 && continue update_selection+=("-b" "$up_backups") ;; 2 | -i) - read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + read -rt 120 -p "What is the name of the application we should ignore?: " up_ignore ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is not a possible option for an application name" && sleep 3 && continue update_selection+=("-i" "$up_ignore") ;; @@ -171,7 +171,7 @@ case $selection in 6 | -t) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it echo "What do you want your timeout to be?" - read -rt 600 -p "Please type an integer: " up_timeout + read -rt 120 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue update_selection+=("-t" "$up_timeout") ;; From 0e60f84c22f7058d396b9a70bddaadbdb7f79957 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 30 Jul 2022 16:43:42 -0600 Subject: [PATCH 442/823] change user input --- functions/backup.sh | 30 ++++++------ functions/menu.sh | 117 +++++++++++++++++++++++--------------------- functions/mount.sh | 14 +++--- 3 files changed, 83 insertions(+), 78 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 9f2de90f..9cfac408 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -46,7 +46,7 @@ do echo "$list_backups" echo echo "0) Exit" - read -rt 120 -p "Please type a number: " selection + read -rt 240 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') if [[ $selection == 0 ]]; then echo "Exiting.." @@ -67,16 +67,16 @@ do clear -x echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" - echo -e "1) Yes\n2) Exit\n" - read -rt 120 -p "Please type a number: " yesno + echo -e "Y) Yes\nN) No\n" + read -rt 120 -p "Please type a number: " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in - 1) + [Yy]) echo -e "\nDeleting $restore_point" cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null || { echo "Failed to delete backup.."; exit; } echo "Sucessfully deleted" break ;; - 2) + [Nn]) echo "Exiting" exit ;; @@ -90,14 +90,14 @@ do while true do echo "Delete more?" - echo "1) Yes" - echo "2) No" - read -rt 120 -p "Please type a number: " yesno + echo "Y) Yes" + echo "N) No" + read -rt 120 -p "Please type a number: " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in - 1) + [Yy]) break ;; - 2) + [Nn]) exit ;; *) @@ -131,7 +131,7 @@ do echo "$list_backups" echo echo "0) Exit" - read -rt 120 -p "Please type a number: " selection + read -rt 240 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') if [[ $selection == 0 ]]; then echo "Exiting.." @@ -152,15 +152,15 @@ do clear -x echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" - echo -e "1) Yes\n2) Exit\n" - read -rt 120 -p "Please type a number: " yesno + echo -e "Y) Yes\nN) No\n" + read -rt 120 -p "Please type a number: " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in - 1) + [Yy]) echo -e "\nStarting Backup, this will take a LONG time." cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || { echo "Failed to delete backup.."; exit; } exit ;; - 2) + [Nn]) echo "Exiting" exit ;; diff --git a/functions/menu.sh b/functions/menu.sh index 365dd773..ec3a860b 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -29,7 +29,7 @@ case $selection in mount="true" ;; 4) - read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups + read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups || echo "Failed to make a selection" backup="true" ;; 5) @@ -53,56 +53,61 @@ case $selection in echo echo "0) Exit" echo - read -rt 120 -p "Please type the number associated with the flag above: " current_selection - if [[ $current_selection == 1 ]]; then - while true - do - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 120 -p "Please type an integer greater than 0: " up_async - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 3 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 3 - continue - else - update_selection+=("-U" "$up_async") - break - fi - done - break - elif [[ $current_selection == 2 ]]; then - while true - do - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 120 -p "Please type an integer greater than 0: " up_async - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 3 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 3 - continue - else - update_selection+=("-u" "$up_async") - break - fi - done - break - elif [[ $current_selection == 0 ]]; then - echo "Exiting.." - exit - else - echo "$current_selection was not an option, try again" && sleep 3 - continue - fi + read -rt 120 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; } + case $current_selection in + 0 | [Ee][Xx][Ii][Tt]) + echo "Exiting.." + exit + ;; + 1 | -U) + while true + do + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 3 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 3 + continue + else + update_selection+=("-U" "$up_async") + break + fi + done + break + ;; + 2 | -u) + while true + do + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 3 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 3 + continue + else + update_selection+=("-u" "$up_async") + break + fi + done + break + ;; + *) + echo "$current_selection was not an option, try again" && sleep 3 + continue + ;; + esac done while true do @@ -129,9 +134,9 @@ case $selection in echo "---------------" echo "bash heavy_script.sh ${update_selection[*]}" echo - read -rt 120 -p "Type the Number OR Flag: " current_selection + read -rt 600 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; } case $current_selection in - 0) + 0 | [Ee][Xx][Ii][Tt]) echo "Exiting.." exit ;; @@ -145,13 +150,13 @@ case $selection in 1 | -b) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" - read -rt 120 -p "Please type an integer: " up_backups + read -rt 120 -p "Please type an integer: " up_backups || { echo -e "\nFailed to make a selection in time" ; exit; } ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 3 && continue update_selection+=("-b" "$up_backups") ;; 2 | -i) - read -rt 120 -p "What is the name of the application we should ignore?: " up_ignore + read -rt 120 -p "What is the name of the application we should ignore?: " up_ignore || { echo -e "\nFailed to make a selection in time" ; exit; } ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is not a possible option for an application name" && sleep 3 && continue update_selection+=("-i" "$up_ignore") ;; @@ -171,7 +176,7 @@ case $selection in 6 | -t) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it echo "What do you want your timeout to be?" - read -rt 120 -p "Please type an integer: " up_timeout + read -rt 120 -p "Please type an integer: " up_timeout || { echo -e "\nFailed to make a selection in time" ; exit; } ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue update_selection+=("-t" "$up_timeout") ;; diff --git a/functions/mount.sh b/functions/mount.sh index db369b4c..dfb0ac22 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -9,7 +9,7 @@ do echo "2) Unmount All" echo echo "0) Exit" - read -rt 120 -p "Unmount All Please type a number: " selection + read -rt 120 -p "Unmount All Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } case $selection in 0) echo "Exiting.." @@ -27,7 +27,7 @@ do echo "$list" echo echo "0) Exit" - read -rt 120 -p "Please type a number: " selection + read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } [[ $selection == 0 ]] && echo "Exiting.." && exit app=$(echo -e "$list" | grep ^"$selection)" | awk '{print $2}' | cut -c 4- ) [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && continue #Check for valid selection. If none, contiue @@ -59,16 +59,16 @@ do while true do echo -e "\nWould you like to mount anything else?" - echo "1) Yes" - echo "2) No" - read -rt 120 -p "Please type a number: " yesno + echo "Y) Yes" + echo "N) No" + read -rt 120 -p "Please type a number: " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in - 1) + [Yy]) clear -x title break ;; - 2) + [Nn]) exit ;; *) From 79a0531da63d71c1d30a5c59be25711e4ad2da04 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 30 Jul 2022 16:57:52 -0600 Subject: [PATCH 443/823] yes no revamp --- functions/backup.sh | 27 +++++++++++---------------- functions/mount.sh | 10 ++++------ 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 9cfac408..07a6fb23 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -66,17 +66,16 @@ do do clear -x echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" - echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" - echo -e "Y) Yes\nN) No\n" - read -rt 120 -p "Please type a number: " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } + echo -e "\n\nYou have chosen:\n$restore_point\n\n" + read -rt 120 -p "Would you like to proceed with deletion? (y/N) " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in - [Yy]) + [Yy] | [Yy][Ee][Ss]) echo -e "\nDeleting $restore_point" cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null || { echo "Failed to delete backup.."; exit; } echo "Sucessfully deleted" break ;; - [Nn]) + [Nn] | [Nn][Oo]) echo "Exiting" exit ;; @@ -89,15 +88,12 @@ do done while true do - echo "Delete more?" - echo "Y) Yes" - echo "N) No" - read -rt 120 -p "Please type a number: " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } + read -rt 120 -p "Delete more backups? (y/N)" yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in - [Yy]) + [Yy] | [Yy][Ee][Ss]) break ;; - [Nn]) + [Nn] | [Nn][Oo]) exit ;; *) @@ -151,16 +147,15 @@ do do clear -x echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" - echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" - echo -e "Y) Yes\nN) No\n" - read -rt 120 -p "Please type a number: " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } + echo -e "\n\nYou have chosen:\n$restore_point\n\n" + read -rt 120 -p "Would you like to proceed with restore? (y/N) " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in - [Yy]) + [Yy] | [Yy][Ee][Ss]) echo -e "\nStarting Backup, this will take a LONG time." cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || { echo "Failed to delete backup.."; exit; } exit ;; - [Nn]) + [Nn] | [Nn][Oo]) echo "Exiting" exit ;; diff --git a/functions/mount.sh b/functions/mount.sh index dfb0ac22..b866d489 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -58,17 +58,15 @@ do echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" while true do - echo -e "\nWould you like to mount anything else?" - echo "Y) Yes" - echo "N) No" - read -rt 120 -p "Please type a number: " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } + echo + read -rt 120 -p "Would you like to mount anything else? (y/N) " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in - [Yy]) + [Yy] | [Yy][Ee][Ss]) clear -x title break ;; - [Nn]) + [Nn] | [Nn][Oo]) exit ;; *) From 18a231e9712504467ff35369f1685f9036e8c375 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 30 Jul 2022 17:07:28 -0600 Subject: [PATCH 444/823] colon and spaces --- functions/backup.sh | 6 +++--- functions/mount.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 07a6fb23..58fa1904 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -67,7 +67,7 @@ do clear -x echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" echo -e "\n\nYou have chosen:\n$restore_point\n\n" - read -rt 120 -p "Would you like to proceed with deletion? (y/N) " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } + read -rt 120 -p "Would you like to proceed with deletion? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in [Yy] | [Yy][Ee][Ss]) echo -e "\nDeleting $restore_point" @@ -88,7 +88,7 @@ do done while true do - read -rt 120 -p "Delete more backups? (y/N)" yesno || { echo -e "\nFailed to make a selection in time" ; exit; } + read -rt 120 -p "Delete more backups? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in [Yy] | [Yy][Ee][Ss]) break @@ -148,7 +148,7 @@ do clear -x echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" echo -e "\n\nYou have chosen:\n$restore_point\n\n" - read -rt 120 -p "Would you like to proceed with restore? (y/N) " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } + read -rt 120 -p "Would you like to proceed with restore? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in [Yy] | [Yy][Ee][Ss]) echo -e "\nStarting Backup, this will take a LONG time." diff --git a/functions/mount.sh b/functions/mount.sh index b866d489..ba2a1955 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -59,7 +59,7 @@ do while true do echo - read -rt 120 -p "Would you like to mount anything else? (y/N) " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } + read -rt 120 -p "Would you like to mount anything else? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in [Yy] | [Yy][Ee][Ss]) clear -x From e9c27d7800fb5d15772c917d7576740085923cdd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 30 Jul 2022 17:08:57 -0600 Subject: [PATCH 445/823] spelling mistake in mount --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index ba2a1955..26198633 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -9,7 +9,7 @@ do echo "2) Unmount All" echo echo "0) Exit" - read -rt 120 -p "Unmount All Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } case $selection in 0) echo "Exiting.." From 2be7b0c5a66887dc293cfe2a8166ee44b5384ed2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 30 Jul 2022 17:10:59 -0600 Subject: [PATCH 446/823] self-update title newline --- functions/self_update.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 5c2178d0..2e99e7bc 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -3,7 +3,8 @@ args=("$@") self_update() { git fetch &> /dev/null -echo "🅂 🄴 🄻 🄵 🅄 🄿 🄳 🄰 🅃 🄴" +echo "🅂 🄴 🄻 🄵" +echo "🅄 🄿 🄳 🄰 🅃 🄴" if git diff --name-only origin/main | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q From 263ffa377efd52a593b0cda799293e80bf3cd114 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 30 Jul 2022 17:18:27 -0600 Subject: [PATCH 447/823] dns numbers --- functions/dns.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/dns.sh b/functions/dns.sh index c4316139..986f3d3e 100644 --- a/functions/dns.sh +++ b/functions/dns.sh @@ -22,6 +22,6 @@ do ixName=$(echo "$i" | awk '{print $1}') port=$(echo "$all_ports" | grep -E "\s$appName\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}") echo -e "$appName.$ixName.svc.cluster.local $port" -done | uniq | nl -b t | sed 's/\s\s\s$/- -------- ----/' | column -t -R 1 -N "#,DNS_Name,Port" -L +done | uniq | nl -s ") " -b t | sed 's/\s\s\s$/- -------- ----/' | column -t -R 1 -N "#,DNS_Name,Port" -L } export -f dns \ No newline at end of file From c6e89cf356fa6bd91c9837a30feaad44a26c12af Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 30 Jul 2022 17:19:41 -0600 Subject: [PATCH 448/823] revert --- functions/dns.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/dns.sh b/functions/dns.sh index 986f3d3e..c4316139 100644 --- a/functions/dns.sh +++ b/functions/dns.sh @@ -22,6 +22,6 @@ do ixName=$(echo "$i" | awk '{print $1}') port=$(echo "$all_ports" | grep -E "\s$appName\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}") echo -e "$appName.$ixName.svc.cluster.local $port" -done | uniq | nl -s ") " -b t | sed 's/\s\s\s$/- -------- ----/' | column -t -R 1 -N "#,DNS_Name,Port" -L +done | uniq | nl -b t | sed 's/\s\s\s$/- -------- ----/' | column -t -R 1 -N "#,DNS_Name,Port" -L } export -f dns \ No newline at end of file From 41e2b9f9ffa759cfb59676fd88cd66d7da86bdea Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 31 Jul 2022 12:56:50 -0600 Subject: [PATCH 449/823] new spacing --- functions/backup.sh | 4 +++- functions/misc.sh | 4 +++- functions/self_update.sh | 6 +++--- heavy_script.sh | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 58fa1904..1226c9d3 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -2,7 +2,7 @@ backup(){ -echo_backup+=("\n🄱 🄰 🄲 🄺 🅄 🄿 🅂") +echo_backup+=("🄱 🄰 🄲 🄺 🅄 🄿 🅂") echo_backup+=("Number of backups was set to $number_of_backups") date=$(date '+%Y_%m_%d_%H_%M_%S') [[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' &> /dev/null && echo_backup+=(HeavyScript_"$date") @@ -24,6 +24,8 @@ for i in "${echo_backup[@]}" do echo -e "$i" done +echo +echo } export -f backup diff --git a/functions/misc.sh b/functions/misc.sh index 880de232..54eaefa1 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -2,7 +2,7 @@ sync(){ -echo_sync+=("\n\n🅂 🅈 🄽 🄲") +echo_sync+=("🅂 🅈 🄽 🄲") cli -c 'app catalog sync_all' &> /dev/null && echo_sync+=("Catalog sync complete") #Dump the echo_array, ensures all output is in a neat order. @@ -10,6 +10,8 @@ for i in "${echo_sync[@]}" do echo -e "$i" done +echo +echo } export -f sync diff --git a/functions/self_update.sh b/functions/self_update.sh index 2e99e7bc..98a3e19e 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -15,14 +15,14 @@ if git diff --name-only origin/main | grep -qs ".sh" ; then [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done - [[ -z ${args[*]} ]] && echo -e "No more arguments, exiting..\n" && exit - echo -e "Running the new version...\n" + [[ -z ${args[*]} ]] && echo -e "No more arguments, exiting..\n\n" && exit + echo -e "Running the new version...\n\n" sleep 5 exec bash "$script_name" "${args[@]}" # Now exit this old instance exit else - echo -e "HeavyScript is already the latest version\n" + echo -e "HeavyScript is already the latest version\n\n" fi } export -f self_update diff --git a/heavy_script.sh b/heavy_script.sh index db7068c2..c5e387c4 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -148,7 +148,7 @@ done if [[ "$backup" == "true" && "$sync" == "true" ]]; then # Run backup and sync at the same time echo "🅃 🄰 🅂 🄺 🅂 :" echo -e "-Backing up ix-applications dataset\n-Syncing catalog(s)" - echo -e "This can take a LONG time, please wait for both output..\n" + echo -e "This can take a LONG time, please wait for both output..\n\n" backup & sync & wait From 58ab28ef0fd5c2d0a79f3045d88609de049177b7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 31 Jul 2022 13:03:45 -0600 Subject: [PATCH 450/823] remove spaces --- functions/update_apps.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index be33626f..a8a19287 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -3,7 +3,7 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) -echo -e "\n\n🅄 🄿 🄳 🄰 🅃 🄴 🅂" +echo -e "🅄 🄿 🄳 🄰 🅃 🄴 🅂" [[ -z ${array[*]} ]] && echo "There are no updates available" && return 0 || echo "Update(s) Available: ${#array[@]}" echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" @@ -35,7 +35,8 @@ do fi done rm temp.txt - +echo +echo } export -f commander @@ -164,7 +165,5 @@ for i in "${echo_array[@]}" do echo -e "$i" done - - } export -f after_update_actions \ No newline at end of file From 07d4b2c791ee6d3d8e15cd6e1058525caee82d4f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 31 Jul 2022 13:06:00 -0600 Subject: [PATCH 451/823] remove newlines in prune --- functions/misc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/misc.sh b/functions/misc.sh index 54eaefa1..f4018c5b 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -16,7 +16,7 @@ echo export -f sync prune(){ -echo -e "\n\n🄿 🅁 🅄 🄽 🄴" +echo -e "🄿 🅁 🅄 🄽 🄴" echo "Pruned Docker Images" docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" } From c38915c775bc2e25db2b5a9158640d1fcae197af Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 31 Jul 2022 13:08:34 -0600 Subject: [PATCH 452/823] newlines before return --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a8a19287..a99cec60 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -4,7 +4,7 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) echo -e "🅄 🄿 🄳 🄰 🅃 🄴 🅂" -[[ -z ${array[*]} ]] && echo "There are no updates available" && return 0 || echo "Update(s) Available: ${#array[@]}" +[[ -z ${array[*]} ]] && echo "There are no updates available" && echo -e "\n\n" && return 0 || echo "Update(s) Available: ${#array[@]}" echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" From 74d4b423fa852fa9e148a376f7d289526923cc95 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 31 Jul 2022 13:16:40 -0600 Subject: [PATCH 453/823] remove extra newline --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a99cec60..ec738a6b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -4,7 +4,7 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) echo -e "🅄 🄿 🄳 🄰 🅃 🄴 🅂" -[[ -z ${array[*]} ]] && echo "There are no updates available" && echo -e "\n\n" && return 0 || echo "Update(s) Available: ${#array[@]}" +[[ -z ${array[*]} ]] && echo "There are no updates available" && echo -e "\n" && return 0 || echo "Update(s) Available: ${#array[@]}" echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" From 9cbcdb69704e3a247aabcfc5ce34c8dd51b4ca5a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 31 Jul 2022 13:25:00 -0600 Subject: [PATCH 454/823] sync and backup titles --- heavy_script.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index c5e387c4..6523ee96 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -152,9 +152,15 @@ if [[ "$backup" == "true" && "$sync" == "true" ]]; then # Run backup and sync at backup & sync & wait +elif [[ "$backup" == "true" && -z "$sync" ]]; then # If only backup is true, run it + echo "🅃 🄰 🅂 🄺 :" + echo -e "-Backing up \"ix-applications\" dataset, please wait..\n\n" + backup +elif [[ "$sync" == "true" && -z "$backup" ]]; then # If only sync is true, run it + echo "🅃 🄰 🅂 🄺 :" + echo -e "Syncing catalogs, this takes a LONG time, please wait..\n\n" + sync fi -[[ "$backup" == "true" && -z "$sync" ]] && echo "Backing up \"ix-applications\" dataset, please wait.." && backup -[[ "$sync" == "true" && -z "$backup" ]] && echo "Syncing catalogs, this takes a LONG time, please wait.." && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander [[ "$prune" == "true" ]] && prune From f23355ceb9afdc6c13f057ce3042ff2c5cb6d57e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 31 Jul 2022 13:30:37 -0600 Subject: [PATCH 455/823] little more formatting on output --- heavy_script.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 6523ee96..efecf333 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -147,18 +147,18 @@ done [[ "$mount" == "true" ]] && mount && exit if [[ "$backup" == "true" && "$sync" == "true" ]]; then # Run backup and sync at the same time echo "🅃 🄰 🅂 🄺 🅂 :" - echo -e "-Backing up ix-applications dataset\n-Syncing catalog(s)" - echo -e "This can take a LONG time, please wait for both output..\n\n" + echo -e "-Backing up ix-applications Dataset\n-Syncing catalog(s)" + echo -e "This can take a LONG time, Please Wait For Both Output..\n\n" backup & sync & wait elif [[ "$backup" == "true" && -z "$sync" ]]; then # If only backup is true, run it echo "🅃 🄰 🅂 🄺 :" - echo -e "-Backing up \"ix-applications\" dataset, please wait..\n\n" + echo -e "-Backing up \"ix-applications\" Dataset\nPlease Wait..\n\n" backup elif [[ "$sync" == "true" && -z "$backup" ]]; then # If only sync is true, run it echo "🅃 🄰 🅂 🄺 :" - echo -e "Syncing catalogs, this takes a LONG time, please wait..\n\n" + echo -e "Syncing Catalog(s)\nThis Takes a LONG Time, Please Wait..\n\n" sync fi [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander From 56094507f9b2510afccc70fdd6ff2da5b5d70a33 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 31 Jul 2022 19:01:16 -0600 Subject: [PATCH 456/823] change order in menu --- functions/menu.sh | 46 ++++++++++++++++++++++++---------------------- functions/misc.sh | 22 +++++++++++++--------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index ec3a860b..8800dd6c 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -113,14 +113,17 @@ case $selection in do clear -x title - echo "Choose Your Update Options" - echo "--------------------------" - echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" + echo "Update Options" + echo "--------------" + echo "1) -r | Roll-back applications if they fail to update" echo "2) -i | Add application to ignore list, one by one, see example below." - echo "3) -r | Roll-back applications if they fail to update" - echo "4) -S | Shutdown applications prior to updating" - echo "5) -v | verbose output" - echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo "3) -S | Shutdown applications prior to updating" + echo "4) -v | verbose output" + echo "5) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo + echo "Additional Options" + echo "------------------" + echo "6) -b | Back-up your ix-applications dataset, specify a number after -b" echo "7) -s | sync catalog" echo "8) -p | Prune unused/old docker images" echo "9) --self-update | Updates HeavyScript prior to running any other commands" @@ -147,39 +150,38 @@ case $selection in exec bash "$script_name" "${update_selection[@]}" exit ;; - 1 | -b) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - echo "Up to how many backups should we keep?" - read -rt 120 -p "Please type an integer: " up_backups || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue - [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 3 && continue - update_selection+=("-b" "$up_backups") + 1 | -r) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-r") ;; 2 | -i) read -rt 120 -p "What is the name of the application we should ignore?: " up_ignore || { echo -e "\nFailed to make a selection in time" ; exit; } ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is not a possible option for an application name" && sleep 3 && continue update_selection+=("-i" "$up_ignore") ;; - 3 | -r) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-r") - - ;; - 4 | -S) + 3 | -S) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-S" && echo -e "\"-S\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it update_selection+=("-S") ;; - 5 | -v) + 4 | -v) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-v" && echo -e "\"-v\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it update_selection+=("-v") ;; - 6 | -t) + 5 | -t) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it echo "What do you want your timeout to be?" read -rt 120 -p "Please type an integer: " up_timeout || { echo -e "\nFailed to make a selection in time" ; exit; } ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue update_selection+=("-t" "$up_timeout") ;; + 6 | -b) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + echo "Up to how many backups should we keep?" + read -rt 120 -p "Please type an integer: " up_backups || { echo -e "\nFailed to make a selection in time" ; exit; } + ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue + [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 3 && continue + update_selection+=("-b" "$up_backups") + ;; 7 | -s) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-s" && echo -e "\"-s\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it update_selection+=("-s") diff --git a/functions/misc.sh b/functions/misc.sh index f4018c5b..44ec0bec 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -43,36 +43,40 @@ echo "---------------------------" echo "(Just dont send any other argument)" echo "bash heavy_script.sh" echo -echo "Basic Utilities" -echo "---------------" +echo "Utilities" +echo "---------" echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset" echo "--delete-backup | Opens a menu to delete backups on your system" echo "--dns | list all of your applications DNS names and their web ports" echo -echo "Update Options" +echo "Update Types" echo "--------------" echo "-U | Update all applications, ignores versions" echo "-U 5 | Same as above, but updates 5 applications at one time" echo "-u | Update all applications, does not update Major releases" echo "-u 5 | Same as above, but updates 5 applications at one time" echo -echo "Additional Update Options" -echo "-------------------------" -echo "-b 14 | Back-up your ix-applications dataset, specify a number after -b" -echo "-i | Add application to ignore list, one by one, see example below." +echo "Update Options" +echo "--------------" echo "-r | Roll-back applications if they fail to update" +echo "-i | Add application to ignore list, one by one, see example below." echo "-S | Shutdown applications prior to updating" echo "-v | verbose output" echo "-t 500| Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" +echo +echo "Additional Options" +echo "------------------" +echo "-b 14 | Back-up your ix-applications dataset, specify a number after -b" echo "-s | sync catalog" echo "-p | Prune unused/old docker images" +echo "--self-update | Updates HeavyScript prior to running any other commands" echo echo "Examples" echo "--------" echo "bash heavy_script.sh" -echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -t 600 -vrsUp" -echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -t 600 -vrsp -U 10" +echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -t 600 -vrsUp --self-update" +echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -t 600 -vrsp -U 10 --self-update" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" echo "bash heavy_script.sh --restore" From 65f0175deb7e36f8dda932bfcd1222db0d436d68 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 31 Jul 2022 19:05:06 -0600 Subject: [PATCH 457/823] update help, formatting --- functions/misc.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index 44ec0bec..050055d8 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -40,7 +40,6 @@ help(){ echo "Access the HeavyScript Menu" echo "---------------------------" -echo "(Just dont send any other argument)" echo "bash heavy_script.sh" echo echo "Utilities" @@ -51,7 +50,7 @@ echo "--delete-backup | Opens a menu to delete backups on your system" echo "--dns | list all of your applications DNS names and their web ports" echo echo "Update Types" -echo "--------------" +echo "------------" echo "-U | Update all applications, ignores versions" echo "-U 5 | Same as above, but updates 5 applications at one time" echo "-u | Update all applications, does not update Major releases" From 8d789fe09a7984291318f4ee467d1ccc3bd38473 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 31 Jul 2022 23:14:00 -0600 Subject: [PATCH 458/823] Remove warning newline --- functions/backup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 1226c9d3..581b3bc1 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -148,7 +148,7 @@ do while true do clear -x - echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" + echo -e "WARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" echo -e "\n\nYou have chosen:\n$restore_point\n\n" read -rt 120 -p "Would you like to proceed with restore? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in @@ -170,4 +170,4 @@ do done done } -export -f restore \ No newline at end of file +export -f restore From 8d782e880b7b4034b518225782a63bc75b447ab7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 31 Jul 2022 23:21:38 -0600 Subject: [PATCH 459/823] remove newline before warning --- functions/backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/backup.sh b/functions/backup.sh index 581b3bc1..642b58f5 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -67,7 +67,7 @@ do while true do clear -x - echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" + echo -e "WARNING:\nYou CANNOT go back after deleting your restore point" echo -e "\n\nYou have chosen:\n$restore_point\n\n" read -rt 120 -p "Would you like to proceed with deletion? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in From 11a9935c099b384cd9835b36f019c4058e29e2ce Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 1 Aug 2022 14:16:54 -0600 Subject: [PATCH 460/823] Ignore description in menu --- functions/menu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 8800dd6c..22e4ac76 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -116,7 +116,7 @@ case $selection in echo "Update Options" echo "--------------" echo "1) -r | Roll-back applications if they fail to update" - echo "2) -i | Add application to ignore list, one by one, see example below." + echo "2) -i | Add application to ignore list" echo "3) -S | Shutdown applications prior to updating" echo "4) -v | verbose output" echo "5) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" @@ -218,4 +218,4 @@ case $selection in esac echo } -export -f menu \ No newline at end of file +export -f menu From 5007ab574f49a1be9d6a0cfb2895d44f0af5d3aa Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 1 Aug 2022 15:47:08 -0600 Subject: [PATCH 461/823] remove whitespaces --- functions/update_apps.sh | 64 ++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ec738a6b..9989a64e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -54,43 +54,43 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') - if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update - if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not - if [[ "$startstatus" == "STOPPED" ]]; then # if status is already stopped, skip while loop - echo_array+=("\n$app_name") - [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") - return 0 - else # if status was not STOPPED, stop the app prior to updating - echo_array+=("\n$app_name") - [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=("FAILED") - while [[ "$status" != "STOPPED" ]] - do - status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') - if [[ "$status" == "STOPPED" ]]; then - echo_array+=("Stopped") - [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("Failed to update") - break - elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") - break - elif [[ "$status" != "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED") - sleep 10 - fi - done - fi - else #user must not be using -S, just update +if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update + if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not + if [[ "$startstatus" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") + return 0 + else # if status was not STOPPED, stop the app prior to updating + echo_array+=("\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=("FAILED") + while [[ "$status" != "STOPPED" ]] + do + status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + if [[ "$status" == "STOPPED" ]]; then + echo_array+=("Stopped") + [[ "$verbose" == "true" ]] && echo_array+=("Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("Failed to update") + break + elif [[ "$SECONDS" -ge "$timeout" ]]; then + echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") + break + elif [[ "$status" != "STOPPED" ]]; then + [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED") + sleep 10 + fi + done fi - else - echo_array+=("\n$app_name\nMajor Release, update manually") - return 0 + else #user must not be using -S, just update + echo_array+=("\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=("Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") fi +else + echo_array+=("\n$app_name\nMajor Release, update manually") + return 0 +fi } export -f update_apps From 1d4be7191c617163c6e2481b4657ee4c10abb077 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 14:14:32 -0600 Subject: [PATCH 462/823] test ignore file for failed rollbacks --- functions/update_apps.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 9989a64e..05b44752 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -54,6 +54,14 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') +if grep -qs "^$app_name," failed.txt ; then + if diff <(grep "^$app_name," | awk -F ',' '{print $2}') <(echo "$new_full_ver") ; then + sed -i /"$app_name","$new_full_ver"/d failed.txt + else + echo "Skipping already failed version $new_full_ver" + return 0 + fi +fi if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$startstatus" == "STOPPED" ]]; then # if status is already stopped, skip while loop @@ -111,6 +119,7 @@ if [[ $rollback == "true" ]]; then echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update..") midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update + echo "$app_name,$new_full_ver" >> failed.txt break elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" == "true" ]]; then echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning") From 738a773975df5dc06d9b699391fd38c8e7624c73 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 14:19:48 -0600 Subject: [PATCH 463/823] diff supress and appname --- functions/update_apps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 05b44752..8784cba1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -55,9 +55,10 @@ old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') if grep -qs "^$app_name," failed.txt ; then - if diff <(grep "^$app_name," | awk -F ',' '{print $2}') <(echo "$new_full_ver") ; then + if diff <(grep "^$app_name," | awk -F ',' '{print $2}') <(echo "$new_full_ver") &> /dev/null ; then sed -i /"$app_name","$new_full_ver"/d failed.txt else + echo "$app_name" echo "Skipping already failed version $new_full_ver" return 0 fi From 286c215281529e4295d15a0025fb2b81cbcce215 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 14:20:40 -0600 Subject: [PATCH 464/823] newline for appname --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 8784cba1..6100d688 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -58,7 +58,7 @@ if grep -qs "^$app_name," failed.txt ; then if diff <(grep "^$app_name," | awk -F ',' '{print $2}') <(echo "$new_full_ver") &> /dev/null ; then sed -i /"$app_name","$new_full_ver"/d failed.txt else - echo "$app_name" + echo -e "\n$app_name" echo "Skipping already failed version $new_full_ver" return 0 fi From 9ad8673e8bfb3703c4af6491fde1e8f3b97a59bb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 14:36:39 -0600 Subject: [PATCH 465/823] test string --- functions/update_apps.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 6100d688..95a57cc8 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -55,8 +55,9 @@ old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') if grep -qs "^$app_name," failed.txt ; then - if diff <(grep "^$app_name," | awk -F ',' '{print $2}') <(echo "$new_full_ver") &> /dev/null ; then - sed -i /"$app_name","$new_full_ver"/d failed.txt + failed_ver=$(grep "^$app_name," | awk -F ',' '{print $2}') + if diff <(echo "$failed_ver") <(echo "$new_full_ver") &> /dev/null ; then + sed -inE /"$app_name",.*/d failed.txt else echo -e "\n$app_name" echo "Skipping already failed version $new_full_ver" From 0a2f3147a967900353f102b5abe666f1f2b247eb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 14:38:43 -0600 Subject: [PATCH 466/823] forgot filename --- functions/update_apps.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 95a57cc8..9369e095 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -55,8 +55,7 @@ old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') if grep -qs "^$app_name," failed.txt ; then - failed_ver=$(grep "^$app_name," | awk -F ',' '{print $2}') - if diff <(echo "$failed_ver") <(echo "$new_full_ver") &> /dev/null ; then + if diff <(grep "^$app_name," failed.txt | awk -F ',' '{print $2}') <(echo "$new_full_ver") &> /dev/null ; then sed -inE /"$app_name",.*/d failed.txt else echo -e "\n$app_name" From 8b1916c36f11bb68c62e48ef6c12ab22d86af598 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 14:40:55 -0600 Subject: [PATCH 467/823] uh --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 9369e095..e96c3135 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -56,7 +56,7 @@ new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') if grep -qs "^$app_name," failed.txt ; then if diff <(grep "^$app_name," failed.txt | awk -F ',' '{print $2}') <(echo "$new_full_ver") &> /dev/null ; then - sed -inE /"$app_name",.*/d failed.txt + sed -i /"$app_name",/d failed.txt else echo -e "\n$app_name" echo "Skipping already failed version $new_full_ver" From 7ba7b1fd9d20b0d243307df918909b9c896789e7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 14:46:00 -0600 Subject: [PATCH 468/823] test string compare instead of diff --- functions/update_apps.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e96c3135..18f17b9e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -55,12 +55,13 @@ old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') if grep -qs "^$app_name," failed.txt ; then - if diff <(grep "^$app_name," failed.txt | awk -F ',' '{print $2}') <(echo "$new_full_ver") &> /dev/null ; then - sed -i /"$app_name",/d failed.txt - else + failed_ver=$(grep "^$app_name," failed.txt | awk -F ',' '{print $2}') + if [[ "$failed_ver" == "$new_full_ver" ]] ; then echo -e "\n$app_name" echo "Skipping already failed version $new_full_ver" return 0 + else + sed -i /"$app_name",/d failed.txt fi fi if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update From c3a4915de22dca72204b4bf6d31d877412f1ac39 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 16:08:45 -0600 Subject: [PATCH 469/823] better skip message --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 18f17b9e..b511c850 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -58,10 +58,10 @@ if grep -qs "^$app_name," failed.txt ; then failed_ver=$(grep "^$app_name," failed.txt | awk -F ',' '{print $2}') if [[ "$failed_ver" == "$new_full_ver" ]] ; then echo -e "\n$app_name" - echo "Skipping already failed version $new_full_ver" + echo -e "Skipping previously failed version:\n$new_full_ver" return 0 else - sed -i /"$app_name",/d failed.txt + sed -i /"$app_name",/d failed.txt fi fi if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update From 42af8744b4fed00436c2e81a92c43bb1819d302d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 16:48:55 -0600 Subject: [PATCH 470/823] change after_update_actions --- functions/update_apps.sh | 55 +++++++++++++--------------------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index b511c850..e7b97d33 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -108,7 +108,7 @@ export -f update_apps after_update_actions(){ SECONDS=0 count=0 -if [[ $rollback == "true" ]]; then +if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do (( count++ )) @@ -117,15 +117,22 @@ if [[ $rollback == "true" ]]; then [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") break - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" != "true" ]]; then - echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update..") - midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null - [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update - echo "$app_name,$new_full_ver" >> failed.txt - break - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" == "true" ]]; then - echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning") - break + elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then + if [[ $rollback == "true" ]]; then + if [[ "$failed" != "true" ]]; then + echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update..") + midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null + [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update + echo "$app_name,$new_full_ver" >> failed.txt + break + elif [[ "$failed" == "true" ]]; then + echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning") + break + fi + else + echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") + break + fi elif [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check @@ -142,35 +149,9 @@ if [[ $rollback == "true" ]]; then continue fi done -else - if [[ "$startstatus" == "STOPPED" ]]; then - while true #using a constant while loop, then breaking out of the loop with break commands below. - do - (( count++ )) - status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') - if [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - echo_array+=("Stopped") #assume actually stopped anytime AFTER the first loop - break - elif [[ "$status" == "ACTIVE" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") - break - elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") - break - else - [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") - sleep 10 - continue - fi - done - fi fi + #Dump the echo_array, ensures all output is in a neat order. for i in "${echo_array[@]}" do From 2ba8a6c084a07b753dd927689b721c41da7b4b45 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 16:51:10 -0600 Subject: [PATCH 471/823] after update action call after update --- functions/update_apps.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e7b97d33..503e7afc 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -69,7 +69,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con if [[ "$startstatus" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") || echo_array+=("FAILED") return 0 else # if status was not STOPPED, stop the app prior to updating echo_array+=("\n$app_name") @@ -81,7 +81,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con if [[ "$status" == "STOPPED" ]]; then echo_array+=("Stopped") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("Failed to update") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") || echo_array+=("Failed to update") break elif [[ "$SECONDS" -ge "$timeout" ]]; then echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") @@ -95,12 +95,13 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con else #user must not be using -S, just update echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") || echo_array+=("FAILED") fi else echo_array+=("\n$app_name\nMajor Release, update manually") return 0 fi +after_update_actions } export -f update_apps From 0a6926c0d6567c6a9b05cdb023f4146e0bc0319a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 17:19:44 -0600 Subject: [PATCH 472/823] nested active check --- functions/update_apps.sh | 55 +++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 503e7afc..ec211d87 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -114,36 +114,45 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then do (( count++ )) status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') - if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") - break - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then - if [[ $rollback == "true" ]]; then - if [[ "$failed" != "true" ]]; then - echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update..") - midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null - [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update - echo "$app_name,$new_full_ver" >> failed.txt - break - elif [[ "$failed" == "true" ]]; then - echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning") - break - fi - else - echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") + if [[ "$status" == "ACTIVE" ]]; then + if [[ "$startstatus" == "STOPPED" ]]; then + [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") break + else + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check + echo_array+=("Active") + break #if reports active any time after the first loop, assume actually active. fi elif [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check echo_array+=("Stopped") break #if reports stopped any time after the first loop, assume its extermal services. - elif [[ "$status" == "ACTIVE" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - echo_array+=("Active") - break #if reports active any time after the first loop, assume actually active. + elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then + if [[ $rollback == "true" ]]; then + if [[ "$failed" != "true" ]]; then + echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") + echo_array+=("If this is a slow starting application, set a higher timeout with -t") + echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration") + echo_array+=("Reverting update..") + midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null + [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update + echo "$app_name,$new_full_ver" >> failed.txt + break + else + echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") + echo_array+=("The application failed to be ACTIVE even after a rollback") + echo_array+=("Manual intervention is required\nAbandoning") + break + fi + else + echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") + echo_array+=("If this is a slow starting application, set a higher timeout with -t") + echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration") + break + fi else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") sleep 15 From 1ad4690a2a9c875236d5d44ab07b1fd49323595b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 17:31:21 -0600 Subject: [PATCH 473/823] changed some error messages --- functions/update_apps.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ec211d87..421576e4 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -74,7 +74,8 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con else # if status was not STOPPED, stop the app prior to updating echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=("FAILED") + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || echo_array+=("Error: Failed to stop $app_name") + SECONDS=0 while [[ "$status" != "STOPPED" ]] do status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') @@ -117,7 +118,8 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } + echo_array+=("Stopped") break else [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check @@ -130,15 +132,15 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check echo_array+=("Stopped") break #if reports stopped any time after the first loop, assume its extermal services. - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then + elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then if [[ $rollback == "true" ]]; then if [[ "$failed" != "true" ]]; then echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") echo_array+=("If this is a slow starting application, set a higher timeout with -t") echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration") echo_array+=("Reverting update..") - midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null - [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update + midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null || { echo_array+=("Error: Failed to rollback $app_name") ; break ; } + [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions #run back after_update_actions function if the app was stopped prior to update echo "$app_name,$new_full_ver" >> failed.txt break else From 3eae25deded291726587a74f68f0a3292f11461f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 18:23:15 -0600 Subject: [PATCH 474/823] test more aggressive loop --- functions/update_apps.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 421576e4..ab30afd2 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -25,9 +25,12 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 elif [[ $it -lt ${#array[@]} ]]; then - update_apps "${array[$it]}" & - processes+=($!) - ((it++)) + until [[ ${#processes[@]} -ge "$update_limit" || ${#processes[@]} -ge ${#array[@]} ]] + do + update_apps "${array[$it]}" & + processes+=($!) + ((it++)) + done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop From c83354d1a57e742a034fd3e428a6994e9fff98d9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 18:54:15 -0600 Subject: [PATCH 475/823] update async --- functions/update_apps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ab30afd2..5df910ab 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -25,10 +25,11 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 elif [[ $it -lt ${#array[@]} ]]; then - until [[ ${#processes[@]} -ge "$update_limit" || ${#processes[@]} -ge ${#array[@]} ]] + until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & processes+=($!) + ((proc_count++)) ((it++)) done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish From cad29364a5095f62eb38c9af12607ffa705154d6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 19:07:33 -0600 Subject: [PATCH 476/823] sleep to avoid call timeout --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 5df910ab..793dc826 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,6 +32,7 @@ do ((proc_count++)) ((it++)) done + sleep 3 elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop From 17914fada84ab01c12505ef87e930cc5fe63c0fe Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 19:10:02 -0600 Subject: [PATCH 477/823] if gt than 1 sleep --- functions/update_apps.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 793dc826..2cfb6526 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -25,14 +25,16 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 elif [[ $it -lt ${#array[@]} ]]; then + new_updates=0 until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & processes+=($!) ((proc_count++)) ((it++)) + ((new_updates++)) done - sleep 3 + [[ $new_updates -gt 1 ]] && sleep 3 elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop From 561b84797a9f9c7a4b891c2726a078f46a69028f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 19:28:52 -0600 Subject: [PATCH 478/823] greater sleep for updates --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2cfb6526..7bf55310 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -34,7 +34,7 @@ do ((it++)) ((new_updates++)) done - [[ $new_updates -gt 1 ]] && sleep 3 + [[ $new_updates -gt 1 ]] && sleep 6 elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop From 33a77e0687087788f689f72bcae0543a1cee0597 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 19:32:14 -0600 Subject: [PATCH 479/823] assigning array # to string is off? --- functions/update_apps.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 7bf55310..96ff50ed 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,13 +9,12 @@ echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" - +proc_count=0 it=0 while true do while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status') echo "$while_status" > temp.txt - proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" do From 033db8d4a56e53f05b09599566ecfb37a51fd46d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 19:52:08 -0600 Subject: [PATCH 480/823] return array append --- functions/update_apps.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 96ff50ed..42d8a3c8 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,10 +11,12 @@ echo "Asynchronous Updates: $update_limit" proc_count=0 it=0 +ttl=0 while true do while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status') echo "$while_status" > temp.txt + proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" do @@ -25,15 +27,21 @@ do sleep 3 elif [[ $it -lt ${#array[@]} ]]; then new_updates=0 - until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] + until [[ "$proc_count" -eq "$update_limit" || $it -eq ${#array[@]} ]] do update_apps "${array[$it]}" & processes+=($!) - ((proc_count++)) ((it++)) ((new_updates++)) done - [[ $new_updates -gt 1 ]] && sleep 6 + ((ttl++)) + if [[ $ttl -eq 1 ]]; then + sleep 15 + elif [[ $new_updates -gt 1 ]]; then + sleep 6 + else + sleep 3 + fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop From 4faf03d1a00b7e1349750db60385d802b7d74920 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 19:58:19 -0600 Subject: [PATCH 481/823] ge instead of eq --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 42d8a3c8..6c56b332 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -27,7 +27,7 @@ do sleep 3 elif [[ $it -lt ${#array[@]} ]]; then new_updates=0 - until [[ "$proc_count" -eq "$update_limit" || $it -eq ${#array[@]} ]] + until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & processes+=($!) From 0fefd885e07d31d65687617f96c3030cd8c61a0d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:02:36 -0600 Subject: [PATCH 482/823] wow --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 6c56b332..2e1394d5 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -33,6 +33,7 @@ do processes+=($!) ((it++)) ((new_updates++)) + ((proc_count++)) done ((ttl++)) if [[ $ttl -eq 1 ]]; then From 1d9ca34227057b36abd575c4a0e25ba825c67171 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:08:57 -0600 Subject: [PATCH 483/823] raise sleep globally --- functions/update_apps.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2e1394d5..c9773bbb 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -38,13 +38,13 @@ do ((ttl++)) if [[ $ttl -eq 1 ]]; then sleep 15 - elif [[ $new_updates -gt 1 ]]; then - sleep 6 + # elif [[ $new_updates -gt 1 ]]; then + # sleep 15 else - sleep 3 + sleep 10 fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish - sleep 3 + sleep 10 else # All processes must be completed, break out of loop break fi @@ -104,7 +104,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con break elif [[ "$status" != "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED") - sleep 10 + sleep 15 fi done fi From 65d32d2155bcf70532310d4385448557bb46fe7d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:13:44 -0600 Subject: [PATCH 484/823] forgot a sleep timer --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index c9773bbb..bb778075 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -24,7 +24,7 @@ do ((count++)) done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 3 + sleep 10 elif [[ $it -lt ${#array[@]} ]]; then new_updates=0 until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] From 3cb21aa86ad7158fe50e73d85052fdfbfc473165 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:14:06 -0600 Subject: [PATCH 485/823] +5 to first sleep --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index bb778075..50288dde 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -37,7 +37,7 @@ do done ((ttl++)) if [[ $ttl -eq 1 ]]; then - sleep 15 + sleep 20 # elif [[ $new_updates -gt 1 ]]; then # sleep 15 else From fc022a13c5dd8f182175be4869c04eedb9552331 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:26:17 -0600 Subject: [PATCH 486/823] remove commentedout --- functions/update_apps.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 50288dde..2dfd897c 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -38,8 +38,6 @@ do ((ttl++)) if [[ $ttl -eq 1 ]]; then sleep 20 - # elif [[ $new_updates -gt 1 ]]; then - # sleep 15 else sleep 10 fi From d448916d5bf1fc6df27ce1fec2b523024e443535 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:27:44 -0600 Subject: [PATCH 487/823] reasigns to 0, un-needed --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2dfd897c..504a76f7 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,7 +9,7 @@ echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -proc_count=0 + it=0 ttl=0 while true From e496fc4c14f081149d542e94e10b67b9703c669d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:29:06 -0600 Subject: [PATCH 488/823] removed variable --- functions/update_apps.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 504a76f7..afaf1bd6 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -26,13 +26,11 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 10 elif [[ $it -lt ${#array[@]} ]]; then - new_updates=0 until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & processes+=($!) ((it++)) - ((new_updates++)) ((proc_count++)) done ((ttl++)) From 8a5237960992032a15271383e77fd02fda1f5817 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:29:57 -0600 Subject: [PATCH 489/823] test sleep time in until update --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index afaf1bd6..f6e57e48 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,6 +29,7 @@ do until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & + sleep 0.5 processes+=($!) ((it++)) ((proc_count++)) From a3d75393b2f511a9791dbf469d5bd5d61be4bf15 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:30:33 -0600 Subject: [PATCH 490/823] raise sleep to 1 --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f6e57e48..cb41a046 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,7 +29,7 @@ do until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & - sleep 0.5 + sleep 1 processes+=($!) ((it++)) ((proc_count++)) From e5e309ecaf72ffbec8ff9dafb25119713740a3cf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:37:08 -0600 Subject: [PATCH 491/823] try 2 for sleep --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index cb41a046..ceedeaed 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,7 +29,7 @@ do until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & - sleep 1 + sleep 2 processes+=($!) ((it++)) ((proc_count++)) From 2d39df3601d483adf42145e6736563806ba4378b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 21:05:01 -0600 Subject: [PATCH 492/823] racing original --- functions/update_apps.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ceedeaed..f7ca7045 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -24,12 +24,12 @@ do ((count++)) done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 10 + sleep 6 elif [[ $it -lt ${#array[@]} ]]; then until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & - sleep 2 + sleep 1 processes+=($!) ((it++)) ((proc_count++)) @@ -38,10 +38,10 @@ do if [[ $ttl -eq 1 ]]; then sleep 20 else - sleep 10 + sleep 6 fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish - sleep 10 + sleep 6 else # All processes must be completed, break out of loop break fi From fdcf899d56e75dd89ad19aa229fded4d0042ae64 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 21:16:17 -0600 Subject: [PATCH 493/823] test sleep after updates instead --- functions/update_apps.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f7ca7045..85d04f47 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,17 +29,17 @@ do until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & - sleep 1 + sleep 4 processes+=($!) ((it++)) ((proc_count++)) done ((ttl++)) - if [[ $ttl -eq 1 ]]; then - sleep 20 - else - sleep 6 - fi + # if [[ $ttl -eq 1 ]]; then + # sleep 20 + # else + # sleep 6 + # fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 else # All processes must be completed, break out of loop From 0323ba526e6fa6f56e7820162263aef197a2bb15 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 21:23:50 -0600 Subject: [PATCH 494/823] test sleep 3/4 --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 85d04f47..ffde4255 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,7 +9,7 @@ echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" - +# previous 20% 2 min 9 seconds it=0 ttl=0 while true @@ -29,7 +29,7 @@ do until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & - sleep 4 + sleep 3 processes+=($!) ((it++)) ((proc_count++)) From 59bd4c18bd751b0c147de26661a558a4a0cdd8f7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 21:32:23 -0600 Subject: [PATCH 495/823] new race test --- functions/update_apps.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ffde4255..e7273a25 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,17 +29,17 @@ do until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & - sleep 3 + sleep 1 processes+=($!) ((it++)) ((proc_count++)) done ((ttl++)) - # if [[ $ttl -eq 1 ]]; then - # sleep 20 - # else - # sleep 6 - # fi + if [[ $ttl -eq 1 ]]; then + sleep 20 + else + sleep 6 + fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 else # All processes must be completed, break out of loop From 382f6d2f6adcf0a74ac6e02c71183f008096d843 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 21:39:54 -0600 Subject: [PATCH 496/823] revert to fastest --- functions/update_apps.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e7273a25..91390eb0 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,17 +29,12 @@ do until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & - sleep 1 + sleep 4 processes+=($!) ((it++)) ((proc_count++)) done ((ttl++)) - if [[ $ttl -eq 1 ]]; then - sleep 20 - else - sleep 6 - fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 else # All processes must be completed, break out of loop From c52e1e86f930c1ba6f0bddc39904f880580668b4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 21:46:37 -0600 Subject: [PATCH 497/823] test --- functions/update_apps.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 91390eb0..470c342a 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,12 +29,16 @@ do until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & - sleep 4 processes+=($!) ((it++)) ((proc_count++)) done ((ttl++)) + if [[ $ttl -eq 1 ]]; then + sleep 15 + else + sleep 6 + fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 else # All processes must be completed, break out of loop From b1d7471eee7f046eeed6c0d562a5286ee76c1d32 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 21:56:26 -0600 Subject: [PATCH 498/823] test_rearrange --- functions/update_apps.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 470c342a..1dd6508d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,6 +9,26 @@ echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" +#rearange array +for i in ${array[$@]} +do + if printf '%s\0' "${ignore[@]}" | grep -iFxqz "$i" ; then + new_array+=("$i") + elif grep -qs "^$i," failed.txt ; then + new_array+=("$i") + fi +done + +for i in ${array[$@]} +do + printf '%s\0' "${new_array[@]}" | grep -iFxqz "$i" || new_array+=("$i") +done + +for i in ${new_array[$@]} +do + echo "$i" +done + # previous 20% 2 min 9 seconds it=0 ttl=0 From 116492cb92401a4ba883b995751366c78adcb7b4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 22:00:18 -0600 Subject: [PATCH 499/823] test --- functions/update_apps.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 1dd6508d..d32bf7da 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -12,7 +12,8 @@ echo "Asynchronous Updates: $update_limit" #rearange array for i in ${array[$@]} do - if printf '%s\0' "${ignore[@]}" | grep -iFxqz "$i" ; then + in=$(awk -F ',' '{print $1}') + if printf '%s\0' "${ignore[@]}" | grep -iFxqz "$in" ; then new_array+=("$i") elif grep -qs "^$i," failed.txt ; then new_array+=("$i") @@ -21,7 +22,8 @@ done for i in ${array[$@]} do - printf '%s\0' "${new_array[@]}" | grep -iFxqz "$i" || new_array+=("$i") + in=$(awk -F ',' '{print $1}') + printf '%s\0' "${new_array[@]}" | grep -iFxqz "$in" || new_array+=("$i") done for i in ${new_array[$@]} From 17fa578eb4f5931362f02472f353930e4bac7480 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 22:03:25 -0600 Subject: [PATCH 500/823] test --- functions/update_apps.sh | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d32bf7da..470c342a 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,28 +9,6 @@ echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -#rearange array -for i in ${array[$@]} -do - in=$(awk -F ',' '{print $1}') - if printf '%s\0' "${ignore[@]}" | grep -iFxqz "$in" ; then - new_array+=("$i") - elif grep -qs "^$i," failed.txt ; then - new_array+=("$i") - fi -done - -for i in ${array[$@]} -do - in=$(awk -F ',' '{print $1}') - printf '%s\0' "${new_array[@]}" | grep -iFxqz "$in" || new_array+=("$i") -done - -for i in ${new_array[$@]} -do - echo "$i" -done - # previous 20% 2 min 9 seconds it=0 ttl=0 From edb437b7181c833a56b98b0198e007b0e92ec0b5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 18:56:56 -0600 Subject: [PATCH 501/823] add branch variable --- functions/self_update.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 98a3e19e..b7b3e884 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -2,10 +2,11 @@ args=("$@") self_update() { +branch="ignore-file" git fetch &> /dev/null echo "🅂 🄴 🄻 🄵" echo "🅄 🄿 🄳 🄰 🅃 🄴" -if git diff --name-only origin/main | grep -qs ".sh" ; then +if git diff --name-only origin/$branch | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q From 6bafce8181f488252b67690a8bce2cdebdda7a7b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:12:09 -0600 Subject: [PATCH 502/823] cmd to container initial --- functions/menu.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index 22e4ac76..6d9063c9 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -11,6 +11,7 @@ echo "5) Restore a Backup" echo "6) Delete a Backup" echo "7) Update HeavyScript" echo "8) Update Applications" +echo "9) Command to Container" echo echo "0) Exit" read -rt 120 -p "Please select an option by number: " selection @@ -212,6 +213,40 @@ case $selection in esac done ;; + + 9) + title + clear -x + app_name=$(k3s kubectl get pods -A | awk '{print $1}' | sort -u | grep -v "system" | sed '1d' | sed 's/^[^-]*-//' | nl -s ") " | column -t) + echo "$app_name" + echo + echo "0) Exit" + [[ $selection == 0 ]] && echo "Exiting.." && exit + read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') + search=$(k3s crictl ps -a -s running) + mapfile -t pod_id < <(echo "$search" | grep "$app_name" | awk '{print $9}') + + containers=$( + for pod in "${pod_id[@]}" + do + echo "$search" | grep "$pod" | awk '{print $7}' + done | nl -s ") " | column -t) + clear -x + title + echo "$containers" + echo + echo "0) Exit" + read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + [[ $selection == 0 ]] && echo "Exiting.." && exit + + container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') + container_id=$(echo "$search" | grep "$container" | awk '{print $1}') + + read -rt 120 -p "What command would you like to submit to $app_name on $container?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } + k3s crictl exec "$container_id" $command + container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') + ;; *) echo "\"$selection\" was not an option, please try agian" && sleep 3 && menu ;; From 887e69cb36caac435935acfb81adf0657adbea0e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:28:36 -0600 Subject: [PATCH 503/823] while loops to cmd to cnter --- functions/menu.sh | 63 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 6d9063c9..b4cd224b 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -215,14 +215,26 @@ case $selection in ;; 9) - title - clear -x app_name=$(k3s kubectl get pods -A | awk '{print $1}' | sort -u | grep -v "system" | sed '1d' | sed 's/^[^-]*-//' | nl -s ") " | column -t) - echo "$app_name" - echo - echo "0) Exit" - [[ $selection == 0 ]] && echo "Exiting.." && exit - read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + while true + do + clear -x + title + echo "$app_name" + echo + echo "0) Exit" + read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $selection == 0 ]]; then + echo "Exitting.." + exit + elif ! echo -e "$app_name" | grep -qs ^"$selection)" ; then + echo "Error: \"$selection\" was not an option.. Try again" + sleep 3 + continue + else + break + fi + done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) mapfile -t pod_id < <(echo "$search" | grep "$app_name" | awk '{print $9}') @@ -232,18 +244,35 @@ case $selection in do echo "$search" | grep "$pod" | awk '{print $7}' done | nl -s ") " | column -t) - clear -x - title - echo "$containers" - echo - echo "0) Exit" - read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - [[ $selection == 0 ]] && echo "Exiting.." && exit - + while true + do + clear -x + title + echo "$containers" + echo + echo "0) Exit" + read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $selection == 0 ]]; then + echo "Exitting.." + exit + elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then + echo "Error: \"$selection\" was not an option.. Try again" + sleep 3 + continue + else + break + fi + done container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') container_id=$(echo "$search" | grep "$container" | awk '{print $1}') - - read -rt 120 -p "What command would you like to submit to $app_name on $container?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } + clear -x + title + echo "App Name: $app_name" + echo "Container $container" + echo + echo "0) Exit" + read -rt 120 -p "What command would you like to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } + [[ $command == 0 ]] && echo "Exitting.." && exit k3s crictl exec "$container_id" $command container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') ;; From 6a1c216da3c49e78a64c42859d70398f5a74dbd4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:29:58 -0600 Subject: [PATCH 504/823] Spelling --- functions/menu.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index b4cd224b..a59df8c9 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -225,7 +225,7 @@ case $selection in echo "0) Exit" read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } if [[ $selection == 0 ]]; then - echo "Exitting.." + echo "Exiting.." exit elif ! echo -e "$app_name" | grep -qs ^"$selection)" ; then echo "Error: \"$selection\" was not an option.. Try again" @@ -253,7 +253,7 @@ case $selection in echo "0) Exit" read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } if [[ $selection == 0 ]]; then - echo "Exitting.." + echo "Exiting.." exit elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then echo "Error: \"$selection\" was not an option.. Try again" @@ -272,7 +272,7 @@ case $selection in echo echo "0) Exit" read -rt 120 -p "What command would you like to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } - [[ $command == 0 ]] && echo "Exitting.." && exit + [[ $command == 0 ]] && echo "Exiting.." && exit k3s crictl exec "$container_id" $command container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') ;; From b6a796eb5bed41126ca1b2c78356e70d47fe40f4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:36:53 -0600 Subject: [PATCH 505/823] grep appname --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index a59df8c9..e05353bc 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -237,7 +237,7 @@ case $selection in done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep "$app_name" | awk '{print $9}') + mapfile -t pod_id < <(echo "$search" | grep " $app_name " | awk '{print $9}') containers=$( for pod in "${pod_id[@]}" From b845b650c5068098db3fc8f31e66cba7ce1900ed Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:41:53 -0600 Subject: [PATCH 506/823] search regex --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index e05353bc..ddf13880 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -237,7 +237,7 @@ case $selection in done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep " $app_name " | awk '{print $9}') + mapfile -t pod_id < <(echo "$search" | grep -E " $app_name(-)?" | awk '{print $9}') containers=$( for pod in "${pod_id[@]}" From a1ab1ffb8b89fff34507502f8d5bf94aebed3068 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:43:07 -0600 Subject: [PATCH 507/823] space or hyphen --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index ddf13880..88df690d 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -237,7 +237,7 @@ case $selection in done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep -E " $app_name(-)?" | awk '{print $9}') + mapfile -t pod_id < <(echo "$search" | grep -E " $app_name( |-)?" | awk '{print $9}') containers=$( for pod in "${pod_id[@]}" From c10ea958f30a9f93af138d1371f1207a08649210 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:46:06 -0600 Subject: [PATCH 508/823] test new regex --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 88df690d..704f9a46 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -237,7 +237,7 @@ case $selection in done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep -E " $app_name( |-)?" | awk '{print $9}') + mapfile -t pod_id < <(echo "$search" | grep -E " $app_name( *|-?)" | awk '{print $9}') containers=$( for pod in "${pod_id[@]}" From 65eaf1682d89020cea5a71cbe3666275d47bd3ac Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:52:35 -0600 Subject: [PATCH 509/823] test regex --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 704f9a46..14ad312a 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -237,7 +237,7 @@ case $selection in done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep -E " $app_name( *|-?)" | awk '{print $9}') + mapfile -t pod_id < <(echo "$search" | grep -E " $app_name(-|[[:alnum:]])*[[:space:]]" | awk '{print $9}') containers=$( for pod in "${pod_id[@]}" From df34a87089917a1e8e2c271275d2fbb5816ef25a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:53:29 -0600 Subject: [PATCH 510/823] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 14ad312a..a79fa21a 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -237,7 +237,7 @@ case $selection in done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep -E " $app_name(-|[[:alnum:]])*[[:space:]]" | awk '{print $9}') + mapfile -t pod_id < <(echo "$search" | grep -E " $app_name(-)?[[:alnum:]]*[[:space:]]" | awk '{print $9}') containers=$( for pod in "${pod_id[@]}" From 76f54786ba114099cc2a957d17b3343768fc5046 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:56:52 -0600 Subject: [PATCH 511/823] test again --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index a79fa21a..d0f595df 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -237,7 +237,7 @@ case $selection in done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep -E " $app_name(-)?[[:alnum:]]*[[:space:]]" | awk '{print $9}') + mapfile -t pod_id < <(echo "$search" | grep -E " $app_name( |-[[:alnum:]]*[[:space:]])" | awk '{print $9}') containers=$( for pod in "${pod_id[@]}" From bb453ec320ed8f9a7a6260281482f794dd212c56 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 21:00:04 -0600 Subject: [PATCH 512/823] final regex edit for now --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index d0f595df..a0f16986 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -237,7 +237,7 @@ case $selection in done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep -E " $app_name( |-[[:alnum:]]*[[:space:]])" | awk '{print $9}') + mapfile -t pod_id < <(echo "$search" | grep -E " $app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') containers=$( for pod in "${pod_id[@]}" From 99ad0cd1fe2e3aab717b40c4f894dead860ba3bd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 21:51:56 -0600 Subject: [PATCH 513/823] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index a0f16986..53ec177c 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -264,7 +264,7 @@ case $selection in fi done container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') - container_id=$(echo "$search" | grep "$container" | awk '{print $1}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') clear -x title echo "App Name: $app_name" From 08e98759783c5d3d3cff356330c203179c924595 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 21:58:54 -0600 Subject: [PATCH 514/823] exit message on no pods --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 53ec177c..0ae95ff3 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -238,7 +238,7 @@ case $selection in app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) mapfile -t pod_id < <(echo "$search" | grep -E " $app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') - + [[ "${#pod_id[@]}" == 0 ]] && echo "Are you sure the application in running?" && exit containers=$( for pod in "${pod_id[@]}" do From 835528a8c15fb6504d3830a98dbbf5f6ac8e5ad2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 21:59:58 -0600 Subject: [PATCH 515/823] better message --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 0ae95ff3..077fd917 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -238,7 +238,7 @@ case $selection in app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) mapfile -t pod_id < <(echo "$search" | grep -E " $app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') - [[ "${#pod_id[@]}" == 0 ]] && echo "Are you sure the application in running?" && exit + [[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit containers=$( for pod in "${pod_id[@]}" do From bd2e381bb8c5da6c330e873cf152dd2f40e41d78 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 22:17:15 -0600 Subject: [PATCH 516/823] test new call --- functions/cmd_to_container.sh | 66 +++++++++ functions/menu.sh | 248 ++-------------------------------- functions/script_create.sh | 174 ++++++++++++++++++++++++ heavy_script.sh | 11 +- 4 files changed, 256 insertions(+), 243 deletions(-) create mode 100644 functions/cmd_to_container.sh create mode 100644 functions/script_create.sh diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh new file mode 100644 index 00000000..00d2a0b4 --- /dev/null +++ b/functions/cmd_to_container.sh @@ -0,0 +1,66 @@ +#!/bin/bash + + +cmd_to_container(){ + app_name=$(k3s kubectl get pods -A | awk '{print $1}' | sort -u | grep -v "system" | sed '1d' | sed 's/^[^-]*-//' | nl -s ") " | column -t) + while true + do + clear -x + title + echo "$app_name" + echo + echo "0) Exit" + read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $selection == 0 ]]; then + echo "Exiting.." + exit + elif ! echo -e "$app_name" | grep -qs ^"$selection)" ; then + echo "Error: \"$selection\" was not an option.. Try again" + sleep 3 + continue + else + break + fi + done + app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') + search=$(k3s crictl ps -a -s running) + mapfile -t pod_id < <(echo "$search" | grep -E " $app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') + [[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit + containers=$( + for pod in "${pod_id[@]}" + do + echo "$search" | grep "$pod" | awk '{print $7}' + done | nl -s ") " | column -t) + while true + do + clear -x + title + echo "$containers" + echo + echo "0) Exit" + read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $selection == 0 ]]; then + echo "Exiting.." + exit + elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then + echo "Error: \"$selection\" was not an option.. Try again" + sleep 3 + continue + else + break + fi + done + container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') + clear -x + title + echo "App Name: $app_name" + echo "Container: $container" + echo + echo "0) Exit" + read -rt 120 -p "What command would you like to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } + [[ $command == 0 ]] && echo "Exiting.." && exit + k3s crictl exec "$container_id" $command + container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') +} +export -f cmd_to_container \ No newline at end of file diff --git a/functions/menu.sh b/functions/menu.sh index 077fd917..9ac93713 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -21,260 +21,38 @@ case $selection in exit ;; 1) - help="true" + help + exit ;; 2) - dns="true" + dns + exit ;; 3) - mount="true" + mount + exit ;; 4) read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups || echo "Failed to make a selection" backup="true" ;; 5) - restore="true" + restore + exit ;; 6) - deleteBackup="true" + deleteBackup + exit ;; 7) - self_update="true" + self_update ;; 8) - while true - do - clear -x - title - echo "Choose Your Update Type" - echo "-----------------------" - echo "1) -U | Update all applications, ignores versions" - echo "2) -u | Update all applications, does not update Major releases" - echo - echo "0) Exit" - echo - read -rt 120 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; } - case $current_selection in - 0 | [Ee][Xx][Ii][Tt]) - echo "Exiting.." - exit - ;; - 1 | -U) - while true - do - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 3 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 3 - continue - else - update_selection+=("-U" "$up_async") - break - fi - done - break - ;; - 2 | -u) - while true - do - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 3 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 3 - continue - else - update_selection+=("-u" "$up_async") - break - fi - done - break - ;; - *) - echo "$current_selection was not an option, try again" && sleep 3 - continue - ;; - esac - done - while true - do - clear -x - title - echo "Update Options" - echo "--------------" - echo "1) -r | Roll-back applications if they fail to update" - echo "2) -i | Add application to ignore list" - echo "3) -S | Shutdown applications prior to updating" - echo "4) -v | verbose output" - echo "5) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" - echo - echo "Additional Options" - echo "------------------" - echo "6) -b | Back-up your ix-applications dataset, specify a number after -b" - echo "7) -s | sync catalog" - echo "8) -p | Prune unused/old docker images" - echo "9) --self-update | Updates HeavyScript prior to running any other commands" - echo - echo "99) Remove Update Options, Restart" - echo "00) Done making selections, proceed with update" - echo - echo "0) Exit" - echo - echo "Current Choices" - echo "---------------" - echo "bash heavy_script.sh ${update_selection[*]}" - echo - read -rt 600 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; } - case $current_selection in - 0 | [Ee][Xx][Ii][Tt]) - echo "Exiting.." - exit - ;; - 00) - clear -x - echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" - echo - exec bash "$script_name" "${update_selection[@]}" - exit - ;; - 1 | -r) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-r") - ;; - 2 | -i) - read -rt 120 -p "What is the name of the application we should ignore?: " up_ignore || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is not a possible option for an application name" && sleep 3 && continue - update_selection+=("-i" "$up_ignore") - ;; - 3 | -S) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-S" && echo -e "\"-S\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-S") - ;; - 4 | -v) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-v" && echo -e "\"-v\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-v") - ;; - 5 | -t) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - echo "What do you want your timeout to be?" - read -rt 120 -p "Please type an integer: " up_timeout || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue - update_selection+=("-t" "$up_timeout") - ;; - 6 | -b) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - echo "Up to how many backups should we keep?" - read -rt 120 -p "Please type an integer: " up_backups || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue - [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 3 && continue - update_selection+=("-b" "$up_backups") - ;; - 7 | -s) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-s" && echo -e "\"-s\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-s") - ;; - 8 | -p) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-p") - ;; - 9 | --self-update ) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "--self-update" && echo -e "\"--self-update\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("--self-update") - ;; - 99) - count=2 - echo "restarting" - for i in "${update_selection[@]:2}" - do - unset "update_selection[$count]" - echo "$i removed" - ((count++)) - done - sleep 3 - continue - ;; - *) - echo "\"$current_selection\" was not an option, try again" && sleep 3 && continue - ;; - esac - done + script_create ;; 9) - app_name=$(k3s kubectl get pods -A | awk '{print $1}' | sort -u | grep -v "system" | sed '1d' | sed 's/^[^-]*-//' | nl -s ") " | column -t) - while true - do - clear -x - title - echo "$app_name" - echo - echo "0) Exit" - read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $selection == 0 ]]; then - echo "Exiting.." - exit - elif ! echo -e "$app_name" | grep -qs ^"$selection)" ; then - echo "Error: \"$selection\" was not an option.. Try again" - sleep 3 - continue - else - break - fi - done - app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') - search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep -E " $app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') - [[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit - containers=$( - for pod in "${pod_id[@]}" - do - echo "$search" | grep "$pod" | awk '{print $7}' - done | nl -s ") " | column -t) - while true - do - clear -x - title - echo "$containers" - echo - echo "0) Exit" - read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $selection == 0 ]]; then - echo "Exiting.." - exit - elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then - echo "Error: \"$selection\" was not an option.. Try again" - sleep 3 - continue - else - break - fi - done - container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') - container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') - clear -x - title - echo "App Name: $app_name" - echo "Container $container" - echo - echo "0) Exit" - read -rt 120 -p "What command would you like to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } - [[ $command == 0 ]] && echo "Exiting.." && exit - k3s crictl exec "$container_id" $command - container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') + cmd_to_container ;; *) echo "\"$selection\" was not an option, please try agian" && sleep 3 && menu diff --git a/functions/script_create.sh b/functions/script_create.sh new file mode 100644 index 00000000..78b4d287 --- /dev/null +++ b/functions/script_create.sh @@ -0,0 +1,174 @@ +#!/bin/bash + +script_create(){ + while true + do + clear -x + title + echo "Choose Your Update Type" + echo "-----------------------" + echo "1) -U | Update all applications, ignores versions" + echo "2) -u | Update all applications, does not update Major releases" + echo + echo "0) Exit" + echo + read -rt 120 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; } + case $current_selection in + 0 | [Ee][Xx][Ii][Tt]) + echo "Exiting.." + exit + ;; + 1 | -U) + while true + do + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 3 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 3 + continue + else + update_selection+=("-U" "$up_async") + break + fi + done + break + ;; + 2 | -u) + while true + do + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 3 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 3 + continue + else + update_selection+=("-u" "$up_async") + break + fi + done + break + ;; + *) + echo "$current_selection was not an option, try again" && sleep 3 + continue + ;; + esac + done + while true + do + clear -x + title + echo "Update Options" + echo "--------------" + echo "1) -r | Roll-back applications if they fail to update" + echo "2) -i | Add application to ignore list" + echo "3) -S | Shutdown applications prior to updating" + echo "4) -v | verbose output" + echo "5) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo + echo "Additional Options" + echo "------------------" + echo "6) -b | Back-up your ix-applications dataset, specify a number after -b" + echo "7) -s | sync catalog" + echo "8) -p | Prune unused/old docker images" + echo "9) --self-update | Updates HeavyScript prior to running any other commands" + echo + echo "99) Remove Update Options, Restart" + echo "00) Done making selections, proceed with update" + echo + echo "0) Exit" + echo + echo "Current Choices" + echo "---------------" + echo "bash heavy_script.sh ${update_selection[*]}" + echo + read -rt 600 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; } + case $current_selection in + 0 | [Ee][Xx][Ii][Tt]) + echo "Exiting.." + exit + ;; + 00) + clear -x + echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" + echo + exec bash "$script_name" "${update_selection[@]}" + exit + ;; + 1 | -r) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-r") + ;; + 2 | -i) + read -rt 120 -p "What is the name of the application we should ignore?: " up_ignore || { echo -e "\nFailed to make a selection in time" ; exit; } + ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is not a possible option for an application name" && sleep 3 && continue + update_selection+=("-i" "$up_ignore") + ;; + 3 | -S) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-S" && echo -e "\"-S\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-S") + ;; + 4 | -v) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-v" && echo -e "\"-v\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-v") + ;; + 5 | -t) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + echo "What do you want your timeout to be?" + read -rt 120 -p "Please type an integer: " up_timeout || { echo -e "\nFailed to make a selection in time" ; exit; } + ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue + update_selection+=("-t" "$up_timeout") + ;; + 6 | -b) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + echo "Up to how many backups should we keep?" + read -rt 120 -p "Please type an integer: " up_backups || { echo -e "\nFailed to make a selection in time" ; exit; } + ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue + [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 3 && continue + update_selection+=("-b" "$up_backups") + ;; + 7 | -s) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-s" && echo -e "\"-s\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-s") + ;; + 8 | -p) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-p") + ;; + 9 | --self-update ) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "--self-update" && echo -e "\"--self-update\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("--self-update") + ;; + 99) + count=2 + echo "restarting" + for i in "${update_selection[@]:2}" + do + unset "update_selection[$count]" + echo "$i removed" + ((count++)) + done + sleep 3 + continue + ;; + *) + echo "\"$current_selection\" was not an option, try again" && sleep 3 && continue + ;; + esac + done +} +export -f script_create \ No newline at end of file diff --git a/heavy_script.sh b/heavy_script.sh index efecf333..3b970e9f 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -8,20 +8,15 @@ script_name="heavy_script.sh" cd "$script_path" || { echo "Error: Failed to change to script directory" ; exit ; } -# shellcheck source=functions/backup.sh source functions/backup.sh -# shellcheck source=functions/dns.sh source functions/dns.sh -# shellcheck source=functions/menu.sh source functions/menu.sh -# shellcheck source=functions/misc.sh source functions/misc.sh -# shellcheck source=functions/mount.sh source functions/mount.sh -# shellcheck source=functions/self_update.sh source functions/self_update.sh -# shellcheck source=functions/update_apps.sh source functions/update_apps.sh +source functions/cmd_to_container.sh +source functions/script_create.sh @@ -139,8 +134,8 @@ done [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit #Continue to call functions in specific order -[[ "$help" == "true" ]] && help [[ "$self_update" == "true" ]] && self_update +[[ "$help" == "true" ]] && help [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit From f3e66e9327e4686fe40ce49c4ce6c8905dcdd116 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 22:18:37 -0600 Subject: [PATCH 517/823] remove exits --- functions/menu.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 9ac93713..79993400 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -22,15 +22,12 @@ case $selection in ;; 1) help - exit ;; 2) dns - exit ;; 3) mount - exit ;; 4) read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups || echo "Failed to make a selection" @@ -38,11 +35,9 @@ case $selection in ;; 5) restore - exit ;; 6) deleteBackup - exit ;; 7) self_update From 721dadf09ed59cc5a901e831698aac1c18a0e11b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 22:28:09 -0600 Subject: [PATCH 518/823] remove indents, test sleep timer async --- functions/cmd_to_container.sh | 120 ++++++------ functions/script_create.sh | 334 +++++++++++++++++----------------- functions/update_apps.sh | 13 +- 3 files changed, 234 insertions(+), 233 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 00d2a0b4..8b51cf76 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -2,65 +2,65 @@ cmd_to_container(){ - app_name=$(k3s kubectl get pods -A | awk '{print $1}' | sort -u | grep -v "system" | sed '1d' | sed 's/^[^-]*-//' | nl -s ") " | column -t) - while true - do - clear -x - title - echo "$app_name" - echo - echo "0) Exit" - read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $selection == 0 ]]; then - echo "Exiting.." - exit - elif ! echo -e "$app_name" | grep -qs ^"$selection)" ; then - echo "Error: \"$selection\" was not an option.. Try again" - sleep 3 - continue - else - break - fi - done - app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') - search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep -E " $app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') - [[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit - containers=$( - for pod in "${pod_id[@]}" - do - echo "$search" | grep "$pod" | awk '{print $7}' - done | nl -s ") " | column -t) - while true - do - clear -x - title - echo "$containers" - echo - echo "0) Exit" - read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $selection == 0 ]]; then - echo "Exiting.." - exit - elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then - echo "Error: \"$selection\" was not an option.. Try again" - sleep 3 - continue - else - break - fi - done - container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') - container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') - clear -x - title - echo "App Name: $app_name" - echo "Container: $container" - echo - echo "0) Exit" - read -rt 120 -p "What command would you like to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } - [[ $command == 0 ]] && echo "Exiting.." && exit - k3s crictl exec "$container_id" $command - container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') +app_name=$(k3s kubectl get pods -A | awk '{print $1}' | sort -u | grep -v "system" | sed '1d' | sed 's/^[^-]*-//' | nl -s ") " | column -t) +while true +do + clear -x + title + echo "$app_name" + echo + echo "0) Exit" + read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $selection == 0 ]]; then + echo "Exiting.." + exit + elif ! echo -e "$app_name" | grep -qs ^"$selection)" ; then + echo "Error: \"$selection\" was not an option.. Try again" + sleep 3 + continue + else + break + fi +done +app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') +search=$(k3s crictl ps -a -s running) +mapfile -t pod_id < <(echo "$search" | grep -E " $app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') +[[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit +containers=$( +for pod in "${pod_id[@]}" +do + echo "$search" | grep "$pod" | awk '{print $7}' +done | nl -s ") " | column -t) +while true +do + clear -x + title + echo "$containers" + echo + echo "0) Exit" + read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $selection == 0 ]]; then + echo "Exiting.." + exit + elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then + echo "Error: \"$selection\" was not an option.. Try again" + sleep 3 + continue + else + break + fi +done +container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') +container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') +clear -x +title +echo "App Name: $app_name" +echo "Container: $container" +echo +echo "0) Exit" +read -rt 120 -p "What command would you like to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } +[[ $command == 0 ]] && echo "Exiting.." && exit +k3s crictl exec "$container_id" $command +container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') } export -f cmd_to_container \ No newline at end of file diff --git a/functions/script_create.sh b/functions/script_create.sh index 78b4d287..b1448218 100644 --- a/functions/script_create.sh +++ b/functions/script_create.sh @@ -1,174 +1,174 @@ #!/bin/bash script_create(){ - while true - do - clear -x - title - echo "Choose Your Update Type" - echo "-----------------------" - echo "1) -U | Update all applications, ignores versions" - echo "2) -u | Update all applications, does not update Major releases" - echo - echo "0) Exit" - echo - read -rt 120 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; } - case $current_selection in - 0 | [Ee][Xx][Ii][Tt]) - echo "Exiting.." - exit - ;; - 1 | -U) - while true - do - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 3 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 3 - continue - else - update_selection+=("-U" "$up_async") - break - fi - done - break - ;; - 2 | -u) - while true - do - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 3 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 3 - continue - else - update_selection+=("-u" "$up_async") - break - fi - done - break - ;; - *) - echo "$current_selection was not an option, try again" && sleep 3 - continue - ;; - esac - done - while true - do - clear -x - title - echo "Update Options" - echo "--------------" - echo "1) -r | Roll-back applications if they fail to update" - echo "2) -i | Add application to ignore list" - echo "3) -S | Shutdown applications prior to updating" - echo "4) -v | verbose output" - echo "5) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" - echo - echo "Additional Options" - echo "------------------" - echo "6) -b | Back-up your ix-applications dataset, specify a number after -b" - echo "7) -s | sync catalog" - echo "8) -p | Prune unused/old docker images" - echo "9) --self-update | Updates HeavyScript prior to running any other commands" - echo - echo "99) Remove Update Options, Restart" - echo "00) Done making selections, proceed with update" - echo - echo "0) Exit" - echo - echo "Current Choices" - echo "---------------" - echo "bash heavy_script.sh ${update_selection[*]}" - echo - read -rt 600 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; } - case $current_selection in - 0 | [Ee][Xx][Ii][Tt]) - echo "Exiting.." - exit - ;; - 00) - clear -x - echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" - echo - exec bash "$script_name" "${update_selection[@]}" - exit - ;; - 1 | -r) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-r") - ;; - 2 | -i) - read -rt 120 -p "What is the name of the application we should ignore?: " up_ignore || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is not a possible option for an application name" && sleep 3 && continue - update_selection+=("-i" "$up_ignore") - ;; - 3 | -S) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-S" && echo -e "\"-S\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-S") - ;; - 4 | -v) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-v" && echo -e "\"-v\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-v") - ;; - 5 | -t) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - echo "What do you want your timeout to be?" - read -rt 120 -p "Please type an integer: " up_timeout || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue - update_selection+=("-t" "$up_timeout") - ;; - 6 | -b) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - echo "Up to how many backups should we keep?" - read -rt 120 -p "Please type an integer: " up_backups || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue - [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 3 && continue - update_selection+=("-b" "$up_backups") - ;; - 7 | -s) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-s" && echo -e "\"-s\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-s") - ;; - 8 | -p) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-p") - ;; - 9 | --self-update ) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "--self-update" && echo -e "\"--self-update\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("--self-update") - ;; - 99) - count=2 - echo "restarting" - for i in "${update_selection[@]:2}" - do - unset "update_selection[$count]" - echo "$i removed" - ((count++)) - done +while true +do + clear -x + title + echo "Choose Your Update Type" + echo "-----------------------" + echo "1) -U | Update all applications, ignores versions" + echo "2) -u | Update all applications, does not update Major releases" + echo + echo "0) Exit" + echo + read -rt 120 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; } + case $current_selection in + 0 | [Ee][Xx][Ii][Tt]) + echo "Exiting.." + exit + ;; + 1 | -U) + while true + do + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" sleep 3 continue - ;; - *) - echo "\"$current_selection\" was not an option, try again" && sleep 3 && continue - ;; - esac - done + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 3 + continue + else + update_selection+=("-U" "$up_async") + break + fi + done + break + ;; + 2 | -u) + while true + do + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 3 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 3 + continue + else + update_selection+=("-u" "$up_async") + break + fi + done + break + ;; + *) + echo "$current_selection was not an option, try again" && sleep 3 + continue + ;; + esac +done +while true +do + clear -x + title + echo "Update Options" + echo "--------------" + echo "1) -r | Roll-back applications if they fail to update" + echo "2) -i | Add application to ignore list" + echo "3) -S | Shutdown applications prior to updating" + echo "4) -v | verbose output" + echo "5) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo + echo "Additional Options" + echo "------------------" + echo "6) -b | Back-up your ix-applications dataset, specify a number after -b" + echo "7) -s | sync catalog" + echo "8) -p | Prune unused/old docker images" + echo "9) --self-update | Updates HeavyScript prior to running any other commands" + echo + echo "99) Remove Update Options, Restart" + echo "00) Done making selections, proceed with update" + echo + echo "0) Exit" + echo + echo "Current Choices" + echo "---------------" + echo "bash heavy_script.sh ${update_selection[*]}" + echo + read -rt 600 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; } + case $current_selection in + 0 | [Ee][Xx][Ii][Tt]) + echo "Exiting.." + exit + ;; + 00) + clear -x + echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" + echo + exec bash "$script_name" "${update_selection[@]}" + exit + ;; + 1 | -r) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-r") + ;; + 2 | -i) + read -rt 120 -p "What is the name of the application we should ignore?: " up_ignore || { echo -e "\nFailed to make a selection in time" ; exit; } + ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is not a possible option for an application name" && sleep 3 && continue + update_selection+=("-i" "$up_ignore") + ;; + 3 | -S) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-S" && echo -e "\"-S\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-S") + ;; + 4 | -v) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-v" && echo -e "\"-v\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-v") + ;; + 5 | -t) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + echo "What do you want your timeout to be?" + read -rt 120 -p "Please type an integer: " up_timeout || { echo -e "\nFailed to make a selection in time" ; exit; } + ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue + update_selection+=("-t" "$up_timeout") + ;; + 6 | -b) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + echo "Up to how many backups should we keep?" + read -rt 120 -p "Please type an integer: " up_backups || { echo -e "\nFailed to make a selection in time" ; exit; } + ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue + [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 3 && continue + update_selection+=("-b" "$up_backups") + ;; + 7 | -s) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-s" && echo -e "\"-s\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-s") + ;; + 8 | -p) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-p") + ;; + 9 | --self-update ) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "--self-update" && echo -e "\"--self-update\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("--self-update") + ;; + 99) + count=2 + echo "restarting" + for i in "${update_selection[@]:2}" + do + unset "update_selection[$count]" + echo "$i removed" + ((count++)) + done + sleep 3 + continue + ;; + *) + echo "\"$current_selection\" was not an option, try again" && sleep 3 && continue + ;; + esac +done } export -f script_create \ No newline at end of file diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 470c342a..ccc4cf4c 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -30,15 +30,16 @@ do do update_apps "${array[$it]}" & processes+=($!) + sleep 2 ((it++)) ((proc_count++)) done - ((ttl++)) - if [[ $ttl -eq 1 ]]; then - sleep 15 - else - sleep 6 - fi + # ((ttl++)) + # if [[ $ttl -eq 1 ]]; then + # sleep 15 + # else + # sleep 6 + # fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 else # All processes must be completed, break out of loop From 1b238e22519ca6d052f2632ab86ff4c855a37a6d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 22:43:07 -0600 Subject: [PATCH 519/823] test timeout --- functions/update_apps.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ccc4cf4c..d6069fe3 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,8 +14,16 @@ it=0 ttl=0 while true do - while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status') - echo "$while_status" > temp.txt + while true + do + if ! while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null); then + sleep 5 + else + echo "$while_status" > temp.txt + break + fi + done + proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" @@ -30,7 +38,7 @@ do do update_apps "${array[$it]}" & processes+=($!) - sleep 2 + sleep 3 ((it++)) ((proc_count++)) done From 4df204e15b2f380ca287214d817f6e3b97be68d9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 22:44:51 -0600 Subject: [PATCH 520/823] combo sleep --- functions/update_apps.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d6069fe3..57daeb88 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -38,16 +38,16 @@ do do update_apps "${array[$it]}" & processes+=($!) - sleep 3 + sleep 1 ((it++)) ((proc_count++)) done - # ((ttl++)) - # if [[ $ttl -eq 1 ]]; then - # sleep 15 - # else - # sleep 6 - # fi + ((ttl++)) + if [[ $ttl -eq 1 ]]; then + sleep 15 + else + sleep 6 + fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 else # All processes must be completed, break out of loop From 9155fd135dc7006b8fc5b3addc2fa870cacfaa67 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 22:45:47 -0600 Subject: [PATCH 521/823] message --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 57daeb88..a6ac26e2 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -17,6 +17,7 @@ do while true do if ! while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null); then + echo "Middlewared timed out, consider lowering your async updates" sleep 5 else echo "$while_status" > temp.txt From 68daf5f343c7cbe99ed43b5302fb2a196847a170 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 23:14:53 -0600 Subject: [PATCH 522/823] test sleep --- functions/update_apps.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a6ac26e2..cfeecea8 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -24,7 +24,6 @@ do break fi done - proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" @@ -45,7 +44,7 @@ do done ((ttl++)) if [[ $ttl -eq 1 ]]; then - sleep 15 + sleep 25 else sleep 6 fi From 99208d516590c352a0b107e76d4730ab4877ddb2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 23:30:41 -0600 Subject: [PATCH 523/823] who knows --- functions/update_apps.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index cfeecea8..b278a31e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,7 +11,7 @@ echo "Asynchronous Updates: $update_limit" # previous 20% 2 min 9 seconds it=0 -ttl=0 +first_run=0 while true do while true @@ -34,19 +34,24 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 6 elif [[ $it -lt ${#array[@]} ]]; then + ttl=0 until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & processes+=($!) - sleep 1 ((it++)) ((proc_count++)) + ((ttl++)) done - ((ttl++)) - if [[ $ttl -eq 1 ]]; then - sleep 25 - else - sleep 6 + ((first_run++)) + if [[ $first_run == 1 ]]; then + if [[ $ttl -le 5 ]]; then + sleep 15 + elif [[ $ttl -le 10 ]]; then + sleep 25 + elif [[ $ttl -gt 10 ]]; then + sleep 35 + fi fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 From 68f8934708c5b47a784a54abb156d6103dda70ed Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 23:47:34 -0600 Subject: [PATCH 524/823] test trigger --- functions/update_apps.sh | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index b278a31e..d5ab9391 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -12,18 +12,23 @@ echo "Asynchronous Updates: $update_limit" # previous 20% 2 min 9 seconds it=0 first_run=0 +while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) while true do - while true - do - if ! while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null); then - echo "Middlewared timed out, consider lowering your async updates" - sleep 5 - else - echo "$while_status" > temp.txt - break - fi - done + # while true + # do + # if ! while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null); then + # echo "Middlewared timed out, consider lowering your async updates" + # sleep 5 + # else + # echo "$while_status" > temp.txt + # break + # fi + # done + if [ ! -e "$file" ] ; then + while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) + echo "$while_status" > temp.txt + fi proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" @@ -101,6 +106,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || echo_array+=("Error: Failed to stop $app_name") SECONDS=0 + [[ ! -e trigger ]] && touch trigger while [[ "$status" != "STOPPED" ]] do status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') @@ -135,6 +141,7 @@ export -f update_apps after_update_actions(){ SECONDS=0 count=0 +[[ ! -e trigger ]] && touch trigger if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do From a5b6f912fdbec29dca20edef94bdbb9a696105ec Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 23:48:02 -0600 Subject: [PATCH 525/823] forgot to rm trigger --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d5ab9391..25868faf 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -65,6 +65,7 @@ do fi done rm temp.txt +rm trigger echo echo } From 9a0bc10b8eb63ae6d79a20d8e15921413f7ec5c5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 23:48:29 -0600 Subject: [PATCH 526/823] comment out un-needed --- functions/update_apps.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 25868faf..76d78053 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -48,16 +48,16 @@ do ((proc_count++)) ((ttl++)) done - ((first_run++)) - if [[ $first_run == 1 ]]; then - if [[ $ttl -le 5 ]]; then - sleep 15 - elif [[ $ttl -le 10 ]]; then - sleep 25 - elif [[ $ttl -gt 10 ]]; then - sleep 35 - fi - fi + # ((first_run++)) + # if [[ $first_run == 1 ]]; then + # if [[ $ttl -le 5 ]]; then + # sleep 15 + # elif [[ $ttl -le 10 ]]; then + # sleep 25 + # elif [[ $ttl -gt 10 ]]; then + # sleep 35 + # fi + # fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 else # All processes must be completed, break out of loop From da8df6b1807291c6818fb61343b7df70b3a87e61 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 23:53:01 -0600 Subject: [PATCH 527/823] temp creation --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 76d78053..cdb9fd2e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,8 +11,8 @@ echo "Asynchronous Updates: $update_limit" # previous 20% 2 min 9 seconds it=0 -first_run=0 -while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) +# first_run=0 +while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) > temp.txt while true do # while true From 053d971f7a8c57a6e05fe827657e234da46544c4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 23:58:07 -0600 Subject: [PATCH 528/823] wooo trigger works --- functions/update_apps.sh | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index cdb9fd2e..e9cd4d37 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,20 +11,9 @@ echo "Asynchronous Updates: $update_limit" # previous 20% 2 min 9 seconds it=0 -# first_run=0 while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) > temp.txt while true do - # while true - # do - # if ! while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null); then - # echo "Middlewared timed out, consider lowering your async updates" - # sleep 5 - # else - # echo "$while_status" > temp.txt - # break - # fi - # done if [ ! -e "$file" ] ; then while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) echo "$while_status" > temp.txt @@ -48,16 +37,6 @@ do ((proc_count++)) ((ttl++)) done - # ((first_run++)) - # if [[ $first_run == 1 ]]; then - # if [[ $ttl -le 5 ]]; then - # sleep 15 - # elif [[ $ttl -le 10 ]]; then - # sleep 25 - # elif [[ $ttl -gt 10 ]]; then - # sleep 35 - # fi - # fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 else # All processes must be completed, break out of loop From fbfce5ce269b795684441416ad539487ba94ec5e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 23:59:32 -0600 Subject: [PATCH 529/823] uhh --- functions/update_apps.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e9cd4d37..2ef0f803 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,7 +14,7 @@ it=0 while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) > temp.txt while true do - if [ ! -e "$file" ] ; then + if [ ! -e trigger ] ; then while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) echo "$while_status" > temp.txt fi @@ -28,14 +28,12 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 6 elif [[ $it -lt ${#array[@]} ]]; then - ttl=0 until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & processes+=($!) ((it++)) ((proc_count++)) - ((ttl++)) done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 From e97b61b2726c9e8aca901770ab64309e68870909 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 00:03:27 -0600 Subject: [PATCH 530/823] test --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2ef0f803..aecb5a6d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,7 +14,7 @@ it=0 while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) > temp.txt while true do - if [ ! -e trigger ] ; then + if [ -f trigger ]; then while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) echo "$while_status" > temp.txt fi From ba1f1f5358c21339edc066d612f2ab2130d5523c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 00:31:04 -0600 Subject: [PATCH 531/823] global sleep 5 --- functions/update_apps.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index aecb5a6d..70641491 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -98,7 +98,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con break elif [[ "$status" != "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED") - sleep 15 + sleep 5 fi done fi @@ -132,14 +132,14 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then echo_array+=("Stopped") break else - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 5 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 5 && continue #if reports active on FIRST time through loop, double check echo_array+=("Active") break #if reports active any time after the first loop, assume actually active. fi elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 5 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 5 && continue #if reports stopped on FIRST time through loop, double check echo_array+=("Stopped") break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then @@ -167,7 +167,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") - sleep 15 + sleep 5 continue fi done From f0b95738500d4810cb08c273306c54091d6e456c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 00:48:12 -0600 Subject: [PATCH 532/823] regression in speed --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 70641491..e8733940 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,6 +32,7 @@ do do update_apps "${array[$it]}" & processes+=($!) + sleep 3 ((it++)) ((proc_count++)) done From d75003c6f01d44ee37bcebf1a3ca3757e4817d37 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 12:05:18 -0600 Subject: [PATCH 533/823] revert global --- functions/update_apps.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e8733940..00ffeead 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -133,14 +133,14 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then echo_array+=("Stopped") break else - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 5 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 5 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check echo_array+=("Active") break #if reports active any time after the first loop, assume actually active. fi elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 5 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 5 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check echo_array+=("Stopped") break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then @@ -168,7 +168,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") - sleep 5 + sleep 15 continue fi done From 8dafa5eb44ddbe6ab4a7254c1f67213c324ca0a8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 12:16:15 -0600 Subject: [PATCH 534/823] major release fix --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 00ffeead..fab7ada7 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -109,7 +109,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") || echo_array+=("FAILED") fi else - echo_array+=("\n$app_name\nMajor Release, update manually") + echo -e "\n$app_name\nMajor Release, update manually" return 0 fi after_update_actions From 734f1b7ebc7eaf4fd85212cf81acba2c37425c3f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 12:19:24 -0600 Subject: [PATCH 535/823] check for file before deletion --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index fab7ada7..e1c7b45d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -43,7 +43,7 @@ do fi done rm temp.txt -rm trigger +[[ -e trigger ]] && rm trigger echo echo } From bac1658480eec127bd44ca758ce430871549a34c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 12:24:13 -0600 Subject: [PATCH 536/823] file rather than anything --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e1c7b45d..9516b0a3 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -43,7 +43,7 @@ do fi done rm temp.txt -[[ -e trigger ]] && rm trigger +[[ -f trigger ]] && rm trigger echo echo } From 495205253a7f437a5b293b6513a8f87c1fc0fb76 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 17:32:47 -0600 Subject: [PATCH 537/823] test new update --- functions/update_apps.sh | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 9516b0a3..0c51132e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -78,8 +78,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con if [[ "$startstatus" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") || echo_array+=("FAILED") - return 0 + update else # if status was not STOPPED, stop the app prior to updating echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") @@ -92,8 +91,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con if [[ "$status" == "STOPPED" ]]; then echo_array+=("Stopped") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") || echo_array+=("Failed to update") - break + update elif [[ "$SECONDS" -ge "$timeout" ]]; then echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") break @@ -106,7 +104,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con else #user must not be using -S, just update echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") || echo_array+=("FAILED") + update fi else echo -e "\n$app_name\nMajor Release, update manually" @@ -117,6 +115,23 @@ after_update_actions export -f update_apps +update(){ +count=0 +while [[ $count -lt 3 ]] +do + updated=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') + if cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || [[ $updated == "false" ]]; then + echo_array+=("Updated\n$old_full_ver\n$new_full_ver") + break + else + echo_array+=("Failed, trying again..") + ((count++)) + sleep 5 + fi +done +} +export -f update + after_update_actions(){ SECONDS=0 count=0 From b8616e988c639a189cbf380f08a6c31c3a649357 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 17:46:59 -0600 Subject: [PATCH 538/823] error message on failed update --- functions/update_apps.sh | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 0c51132e..f5c9e086 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -78,7 +78,12 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con if [[ "$startstatus" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - update + if update ;then + echo_array+=("Updated\n$old_full_ver\n$new_full_ver") + else + echo_array+=("Failed to update") + return + fi else # if status was not STOPPED, stop the app prior to updating echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") @@ -91,7 +96,12 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con if [[ "$status" == "STOPPED" ]]; then echo_array+=("Stopped") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - update + if update ;then + echo_array+=("Updated\n$old_full_ver\n$new_full_ver") + else + echo_array+=("Failed to update") + return + fi elif [[ "$SECONDS" -ge "$timeout" ]]; then echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") break @@ -104,7 +114,12 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con else #user must not be using -S, just update echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - update + if update ;then + echo_array+=("Updated\n$old_full_ver\n$new_full_ver") + else + echo_array+=("Failed to update") + return + fi fi else echo -e "\n$app_name\nMajor Release, update manually" @@ -121,10 +136,8 @@ while [[ $count -lt 3 ]] do updated=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') if cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || [[ $updated == "false" ]]; then - echo_array+=("Updated\n$old_full_ver\n$new_full_ver") break else - echo_array+=("Failed, trying again..") ((count++)) sleep 5 fi From ad4f507f6f1070af89bdcd969c7d5375e429248f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 17:52:11 -0600 Subject: [PATCH 539/823] return codes for failures --- functions/update_apps.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f5c9e086..ce410810 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -137,9 +137,11 @@ do updated=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') if cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || [[ $updated == "false" ]]; then break - else + elif [[ $count -lt 3 ]]; then ((count++)) sleep 5 + else + return 1 fi done } From 03c16717ccadaa603cb413812208695aa4b1e688 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 17:52:56 -0600 Subject: [PATCH 540/823] lower sleep --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ce410810..7e1941a9 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,7 +32,7 @@ do do update_apps "${array[$it]}" & processes+=($!) - sleep 3 + sleep 2 ((it++)) ((proc_count++)) done From 0d30de9e22ef2bfbdbc5a6769cf79004f56a7095 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 21:50:22 -0600 Subject: [PATCH 541/823] test shell --- functions/cmd_to_container.sh | 53 ++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 8b51cf76..e7603d74 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -52,15 +52,48 @@ do done container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') -clear -x -title -echo "App Name: $app_name" -echo "Container: $container" -echo -echo "0) Exit" -read -rt 120 -p "What command would you like to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } -[[ $command == 0 ]] && echo "Exiting.." && exit -k3s crictl exec "$container_id" $command -container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') +while true +do + clear -x + title + echo "App Name: $app_name" + echo "Container: $container" + echo + echo "1) Run a single command" + echo "2) Open Shell" + echo + echo "0) Exit" + read -rt 120 -p "Please choose an option: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + case $selection in + 0) + echo "Exiting.." + exit + ;; + + 1) + clear -x + title + read -rt 120 -p "What command do you want to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } + k3s crictl exec -it "$container_id" $command + break + ;; + + 2) + clear -x + title + + if ! k3s crictl exec -it "$container_id" /bin/bash ; then + k3s crictl exec -it "$container_id" /bin/sh + fi + break + ;; + + *) + echo "That was not an option.. Try again" + sleep 3 + ;; + esac +done + } export -f cmd_to_container \ No newline at end of file From 6b9be5102c052fb4dfebddd2bf117d7d536c33aa Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 21:53:47 -0600 Subject: [PATCH 542/823] error code --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index e7603d74..49b8ab29 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -82,7 +82,7 @@ do clear -x title - if ! k3s crictl exec -it "$container_id" /bin/bash ; then + if ! k3s crictl exec -it "$container_id" /bin/bash && $? != 130 ; then k3s crictl exec -it "$container_id" /bin/sh fi break From 7842b83700d6c5b04dfb6fb77f6ee3942204c247 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 22:06:41 -0600 Subject: [PATCH 543/823] test --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 49b8ab29..e7603d74 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -82,7 +82,7 @@ do clear -x title - if ! k3s crictl exec -it "$container_id" /bin/bash && $? != 130 ; then + if ! k3s crictl exec -it "$container_id" /bin/bash ; then k3s crictl exec -it "$container_id" /bin/sh fi break From 9c1258e02ece1a2245a64181c633cc249ed8d030 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 22:11:07 -0600 Subject: [PATCH 544/823] error message upon both sh and bash failure --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index e7603d74..24492c91 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -83,7 +83,7 @@ do title if ! k3s crictl exec -it "$container_id" /bin/bash ; then - k3s crictl exec -it "$container_id" /bin/sh + k3s crictl exec -it "$container_id" /bin/sh || echo "This application does not accept shell access apparently" fi break ;; From e331dc2deb727215336261229a44fa7545a5b471 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 22:12:15 -0600 Subject: [PATCH 545/823] better message --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 24492c91..9b3f128d 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -83,7 +83,7 @@ do title if ! k3s crictl exec -it "$container_id" /bin/bash ; then - k3s crictl exec -it "$container_id" /bin/sh || echo "This application does not accept shell access apparently" + k3s crictl exec -it "$container_id" /bin/sh || echo "This container does not accept shell access, try a different one." fi break ;; From c69d1b29831211f724be0c3c6328104e08b10ea2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 22:14:27 -0600 Subject: [PATCH 546/823] remove error messages --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 9b3f128d..d86e82b4 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -82,8 +82,8 @@ do clear -x title - if ! k3s crictl exec -it "$container_id" /bin/bash ; then - k3s crictl exec -it "$container_id" /bin/sh || echo "This container does not accept shell access, try a different one." + if ! k3s crictl exec -it "$container_id" /bin/bash 2>/dev/null; then + k3s crictl exec -it "$container_id" /bin/sh 2>/dev/null || echo "This container does not accept shell access, try a different one." fi break ;; From b935c755c9befcfa81c2f28380dd8f9fb59b9a50 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 22:15:21 -0600 Subject: [PATCH 547/823] hide both error and info --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index d86e82b4..3c50d5bf 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -82,8 +82,8 @@ do clear -x title - if ! k3s crictl exec -it "$container_id" /bin/bash 2>/dev/null; then - k3s crictl exec -it "$container_id" /bin/sh 2>/dev/null || echo "This container does not accept shell access, try a different one." + if ! k3s crictl exec -it "$container_id" /bin/bash &>/dev/null; then + k3s crictl exec -it "$container_id" /bin/sh &>/dev/null || echo "This container does not accept shell access, try a different one." fi break ;; From d05b8674b3a68119e0a99e65fd63fab25a7aa9e3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 22:16:49 -0600 Subject: [PATCH 548/823] only show stdout --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 3c50d5bf..d86e82b4 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -82,8 +82,8 @@ do clear -x title - if ! k3s crictl exec -it "$container_id" /bin/bash &>/dev/null; then - k3s crictl exec -it "$container_id" /bin/sh &>/dev/null || echo "This container does not accept shell access, try a different one." + if ! k3s crictl exec -it "$container_id" /bin/bash 2>/dev/null; then + k3s crictl exec -it "$container_id" /bin/sh 2>/dev/null || echo "This container does not accept shell access, try a different one." fi break ;; From 1c0e223648f2ceba1b8553be21d69c95628f5a47 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 22:27:16 -0600 Subject: [PATCH 549/823] cleanup --- functions/cmd_to_container.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index d86e82b4..ef378b14 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -69,7 +69,6 @@ do echo "Exiting.." exit ;; - 1) clear -x title @@ -77,17 +76,14 @@ do k3s crictl exec -it "$container_id" $command break ;; - 2) clear -x title - if ! k3s crictl exec -it "$container_id" /bin/bash 2>/dev/null; then k3s crictl exec -it "$container_id" /bin/sh 2>/dev/null || echo "This container does not accept shell access, try a different one." fi break ;; - *) echo "That was not an option.. Try again" sleep 3 From 51a5e5fcc2c447c41aa3f47eaaf7aee32518c1c2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 22:47:59 -0600 Subject: [PATCH 550/823] better update handler --- functions/update_apps.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 7e1941a9..362cadab 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -134,14 +134,19 @@ update(){ count=0 while [[ $count -lt 3 ]] do - updated=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') - if cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || [[ $updated == "false" ]]; then + update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') + if [[ $update_avail == "true" ]]; then + if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then + sleep 6 + ((count++)) + continue + fi + break + elif [[ $update_avail == "false" ]]; then break - elif [[ $count -lt 3 ]]; then - ((count++)) - sleep 5 else - return 1 + ((count++)) + sleep 6 fi done } From dcd562462bbfcdc3fffd6f94abbe6067159e3b95 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 23:03:39 -0600 Subject: [PATCH 551/823] add trigger to update --- functions/update_apps.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 362cadab..7fa3327d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -12,6 +12,7 @@ echo "Asynchronous Updates: $update_limit" # previous 20% 2 min 9 seconds it=0 while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) > temp.txt +echo "$while_status" > temp.txt while true do if [ -f trigger ]; then @@ -131,6 +132,7 @@ export -f update_apps update(){ +[[ ! -e trigger ]] && touch trigger count=0 while [[ $count -lt 3 ]] do @@ -155,7 +157,7 @@ export -f update after_update_actions(){ SECONDS=0 count=0 -[[ ! -e trigger ]] && touch trigger +# [[ ! -e trigger ]] && touch trigger if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do From 96b462fd5d4b05ad62d35452fe9001426bb368cd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 23:34:06 -0600 Subject: [PATCH 552/823] trigger fix --- functions/update_apps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 7fa3327d..38462066 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -13,9 +13,10 @@ echo "Asynchronous Updates: $update_limit" it=0 while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) > temp.txt echo "$while_status" > temp.txt +rm trigger &>/dev/null while true do - if [ -f trigger ]; then + if [[ -f trigger ]]; then while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) echo "$while_status" > temp.txt fi From 591120e2fe0afdea3e77385e06bed526d953d517 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 11:52:34 -0600 Subject: [PATCH 553/823] better placements of trigger file --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 38462066..dec7a1fc 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -133,13 +133,13 @@ export -f update_apps update(){ -[[ ! -e trigger ]] && touch trigger count=0 while [[ $count -lt 3 ]] do update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') if [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then + [[ ! -e trigger ]] && touch trigger sleep 6 ((count++)) continue @@ -158,8 +158,8 @@ export -f update after_update_actions(){ SECONDS=0 count=0 -# [[ ! -e trigger ]] && touch trigger if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then + [[ ! -e trigger ]] && touch trigger while true do (( count++ )) From fcd07cfa4fa4882745b2219f57cad7c4380d48f1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 11:53:24 -0600 Subject: [PATCH 554/823] slightly lower commander sleep timer --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index dec7a1fc..74641ac9 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -28,7 +28,7 @@ do ((count++)) done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 6 + sleep 4 elif [[ $it -lt ${#array[@]} ]]; then until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do @@ -39,7 +39,7 @@ do ((proc_count++)) done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish - sleep 6 + sleep 4 else # All processes must be completed, break out of loop break fi From e3e85cf38e5d435c97ca3fd66957b9f3c63b59e7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 13:57:50 -0600 Subject: [PATCH 555/823] pod_id regex --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index ef378b14..173aaca7 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -24,7 +24,7 @@ do done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) -mapfile -t pod_id < <(echo "$search" | grep -E " $app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') +mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') [[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit containers=$( for pod in "${pod_id[@]}" From 82a2deffa071668d2c53fa88cc79286a46f79a8b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 14:14:24 -0600 Subject: [PATCH 556/823] print only last column for pod --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 173aaca7..0dca8e79 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -29,7 +29,7 @@ mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]] containers=$( for pod in "${pod_id[@]}" do - echo "$search" | grep "$pod" | awk '{print $7}' + echo "$search" | grep "$pod" | awk '{print $(NF)}' done | nl -s ") " | column -t) while true do From 84c1fcd006d98bd91e45e0e25415a85f460ed669 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 14:16:31 -0600 Subject: [PATCH 557/823] whoops --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 0dca8e79..e5ae6e7b 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -24,12 +24,12 @@ do done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) -mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') +mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') [[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit containers=$( for pod in "${pod_id[@]}" do - echo "$search" | grep "$pod" | awk '{print $(NF)}' + echo "$search" | grep "$pod" | awk '{print $7}' done | nl -s ") " | column -t) while true do From 0852e29d8a9696a15baca61e49d8f70c0ecb5146 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 14:33:41 -0600 Subject: [PATCH 558/823] test remove dates, they messed up awk --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index e5ae6e7b..1428c4a1 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -23,13 +23,13 @@ do fi done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') -search=$(k3s crictl ps -a -s running) +search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]](an|hours)[[:space:]](hour)?[[:space:]]?ago//') mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') [[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit containers=$( for pod in "${pod_id[@]}" do - echo "$search" | grep "$pod" | awk '{print $7}' + echo "$search" | grep "$pod" | awk '{print $4}' done | nl -s ") " | column -t) while true do From 074b3d09cf2e2dafbbd169daf3c1a324b4fed4d6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 14:51:01 -0600 Subject: [PATCH 559/823] incase days are added --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 1428c4a1..85061063 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -23,7 +23,7 @@ do fi done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') -search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]](an|hours)[[:space:]](hour)?[[:space:]]?ago//') +search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]][a-z]{2,5}[[:space:]](hour)?[[:space:]]?ago//') mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') [[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit containers=$( From 6f7f18d6a4a5b0ed5b8390277bd3ac0588f31179 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 16:30:07 -0600 Subject: [PATCH 560/823] if only one container, auto select it --- functions/cmd_to_container.sh | 46 +++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 85061063..5af6cb4a 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -31,27 +31,31 @@ for pod in "${pod_id[@]}" do echo "$search" | grep "$pod" | awk '{print $4}' done | nl -s ") " | column -t) -while true -do - clear -x - title - echo "$containers" - echo - echo "0) Exit" - read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $selection == 0 ]]; then - echo "Exiting.." - exit - elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then - echo "Error: \"$selection\" was not an option.. Try again" - sleep 3 - continue - else - break - fi -done -container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') -container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') +if [[ "${#pod_id[@]}" == 1 ]]; then + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') +else + while true + do + clear -x + title + echo "$containers" + echo + echo "0) Exit" + read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $selection == 0 ]]; then + echo "Exiting.." + exit + elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then + echo "Error: \"$selection\" was not an option.. Try again" + sleep 3 + continue + else + break + fi + done + container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') +fi while true do clear -x From d830f7e10cc1dc4981114d9c4489b083ec9ac95d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 16:31:29 -0600 Subject: [PATCH 561/823] replace with podid --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 5af6cb4a..1effb5f0 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -32,7 +32,7 @@ do echo "$search" | grep "$pod" | awk '{print $4}' done | nl -s ") " | column -t) if [[ "${#pod_id[@]}" == 1 ]]; then - container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') + container_id=$(echo "$search" | grep -E "[[:space:]]${pod_id[*]}[[:space:]]" | awk '{print $1}') else while true do From 2dc9cc4742a98dbd88c61223765d72b7c0a7f033 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 16:33:59 -0600 Subject: [PATCH 562/823] whew --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 1effb5f0..9c198555 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -32,7 +32,7 @@ do echo "$search" | grep "$pod" | awk '{print $4}' done | nl -s ") " | column -t) if [[ "${#pod_id[@]}" == 1 ]]; then - container_id=$(echo "$search" | grep -E "[[:space:]]${pod_id[*]}[[:space:]]" | awk '{print $1}') + container_id=$(echo "$search" | grep -E "[[:space:]]${containers}[[:space:]]" | awk '{print $1}') else while true do From 26362944a5eb1d0ecc1374bd5c7657caf430d9e4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 16:39:42 -0600 Subject: [PATCH 563/823] fix --- functions/cmd_to_container.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 9c198555..56274270 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -25,15 +25,19 @@ done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]][a-z]{2,5}[[:space:]](hour)?[[:space:]]?ago//') mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') -[[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit -containers=$( -for pod in "${pod_id[@]}" -do - echo "$search" | grep "$pod" | awk '{print $4}' -done | nl -s ") " | column -t) + if [[ "${#pod_id[@]}" == 1 ]]; then - container_id=$(echo "$search" | grep -E "[[:space:]]${containers}[[:space:]]" | awk '{print $1}') + container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') +elif [[ "${#pod_id[@]}" == 0 ]]; then + echo -e "No containers available\nAre you sure the application in running?" + exit else + containers=$( + for pod in "${pod_id[@]}" + do + echo "$search" | grep "$pod" | awk '{print $4}' + done | nl -s ") " | column -t) while true do clear -x From a8b60f5c7175cd95c0aa6426991367067873cb7d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 16:58:07 -0600 Subject: [PATCH 564/823] check for number of containers not pods --- functions/cmd_to_container.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 56274270..8c68f768 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -25,24 +25,30 @@ done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]][a-z]{2,5}[[:space:]](hour)?[[:space:]]?ago//') mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') +for pod in "${pod_id[@]}" +do + mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') +done -if [[ "${#pod_id[@]}" == 1 ]]; then +if [[ "${#containers[@]}" == 1 ]]; then container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') -elif [[ "${#pod_id[@]}" == 0 ]]; then +elif [[ "${#containers[@]}" == 0 ]]; then echo -e "No containers available\nAre you sure the application in running?" exit else - containers=$( for pod in "${pod_id[@]}" do - echo "$search" | grep "$pod" | awk '{print $4}' - done | nl -s ") " | column -t) + mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') + done while true do clear -x title - echo "$containers" + for container in "${containers[@]}" + do + echo "$container" + done | nl -s ") " | column -t echo echo "0) Exit" read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } From bc694852a9709826821fb3220ba4949ffd6f7774 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:00:10 -0600 Subject: [PATCH 565/823] expand all for grep --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 8c68f768..d8eee929 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -55,7 +55,7 @@ else if [[ $selection == 0 ]]; then echo "Exiting.." exit - elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then + elif ! echo -e "${containers[*]}" | grep -qs ^"$selection)" ; then echo "Error: \"$selection\" was not an option.. Try again" sleep 3 continue @@ -63,7 +63,7 @@ else break fi done - container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') + container=$(echo "${containers[*]}" | grep ^"$selection)" | awk '{print $2}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') fi while true From a9b4cd02ed8df95edf50cc7b39f88a3eabb114ba Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:03:37 -0600 Subject: [PATCH 566/823] add nl to grep --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index d8eee929..9b30bbe1 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -55,7 +55,7 @@ else if [[ $selection == 0 ]]; then echo "Exiting.." exit - elif ! echo -e "${containers[*]}" | grep -qs ^"$selection)" ; then + elif ! echo -e "${containers[*]}" | nl -s ") " | grep -qs ^"$selection)" ; then echo "Error: \"$selection\" was not an option.. Try again" sleep 3 continue From dc5fd00681a335f2982c82986dfe542059a9187e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:04:46 -0600 Subject: [PATCH 567/823] expand by row --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 9b30bbe1..0362dead 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -55,7 +55,7 @@ else if [[ $selection == 0 ]]; then echo "Exiting.." exit - elif ! echo -e "${containers[*]}" | nl -s ") " | grep -qs ^"$selection)" ; then + elif ! echo -e "${containers[@]}" | nl -s ") " | grep -qs ^"$selection)" ; then echo "Error: \"$selection\" was not an option.. Try again" sleep 3 continue From 1949c2100c7878e676aa4705a63ad6cbcd8021cb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:09:30 -0600 Subject: [PATCH 568/823] append to variable to search works --- functions/cmd_to_container.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 0362dead..b6da7333 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -45,17 +45,20 @@ else do clear -x title + cont_search=$( for container in "${containers[@]}" do echo "$container" done | nl -s ") " | column -t + ) + echo "$cont_search" echo echo "0) Exit" read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } if [[ $selection == 0 ]]; then echo "Exiting.." exit - elif ! echo -e "${containers[@]}" | nl -s ") " | grep -qs ^"$selection)" ; then + elif ! echo -e "$cont_search}" | nl -s ") " | grep -qs ^"$selection)" ; then echo "Error: \"$selection\" was not an option.. Try again" sleep 3 continue @@ -63,7 +66,7 @@ else break fi done - container=$(echo "${containers[*]}" | grep ^"$selection)" | awk '{print $2}') + container=$(echo "$cont_search" | grep ^"$selection)" | awk '{print $2}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') fi while true From bff29b16378142a79feff80a97c355e821c415f8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:11:01 -0600 Subject: [PATCH 569/823] remove nl --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index b6da7333..5ce76e68 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -58,7 +58,7 @@ else if [[ $selection == 0 ]]; then echo "Exiting.." exit - elif ! echo -e "$cont_search}" | nl -s ") " | grep -qs ^"$selection)" ; then + elif ! echo -e "$cont_search}" | grep -qs ^"$selection)" ; then echo "Error: \"$selection\" was not an option.. Try again" sleep 3 continue From 04c0a983a2fc9b0ca67a63d67f2ed348d0d3788a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:13:48 -0600 Subject: [PATCH 570/823] pod id and container check --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 5ce76e68..00c0e6d5 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -30,7 +30,7 @@ do mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') done -if [[ "${#containers[@]}" == 1 ]]; then +if [[ "${#containers[@]}" == 1 && "${#pod_id[@]}" == 1 ]]; then container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') elif [[ "${#containers[@]}" == 0 ]]; then From dc1f9bb6030b5c4dd98bee095be2e534ba8e1f41 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:16:45 -0600 Subject: [PATCH 571/823] replace ind check with count --- functions/cmd_to_container.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 00c0e6d5..6df7509e 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -25,12 +25,14 @@ done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]][a-z]{2,5}[[:space:]](hour)?[[:space:]]?ago//') mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') +count=0 for pod in "${pod_id[@]}" do mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') + ((count++)) done -if [[ "${#containers[@]}" == 1 && "${#pod_id[@]}" == 1 ]]; then +if [[ $count == 1 ]]; then container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') elif [[ "${#containers[@]}" == 0 ]]; then From 94e78f756b21b1b89e0d915c6c053628820085eb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:20:34 -0600 Subject: [PATCH 572/823] variable is only being saved once --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 6df7509e..4f335a49 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -48,9 +48,9 @@ else clear -x title cont_search=$( - for container in "${containers[@]}" + for i in "${containers[@]}" do - echo "$container" + echo "$i" done | nl -s ") " | column -t ) echo "$cont_search" From b18818bbd503c932547f9876a439b918278d1b36 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:25:13 -0600 Subject: [PATCH 573/823] attempt new for loop --- functions/cmd_to_container.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 4f335a49..f1c35399 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -41,7 +41,8 @@ elif [[ "${#containers[@]}" == 0 ]]; then else for pod in "${pod_id[@]}" do - mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') + # mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') + IFS=" " read -r -a containers <<< "$(echo "$search" | grep "$pod" | awk '{print $4}')" done while true do From fd1b04279eed0db30717c566e4e770c495ba7777 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:28:42 -0600 Subject: [PATCH 574/823] testing --- functions/cmd_to_container.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index f1c35399..856b3756 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -41,8 +41,7 @@ elif [[ "${#containers[@]}" == 0 ]]; then else for pod in "${pod_id[@]}" do - # mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') - IFS=" " read -r -a containers <<< "$(echo "$search" | grep "$pod" | awk '{print $4}')" + echo "$pod" done while true do From a03eebb4beb43077a8bd94355b724b642453fd48 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:33:19 -0600 Subject: [PATCH 575/823] remove different pod id --- functions/cmd_to_container.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 856b3756..c4d0e34d 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -39,10 +39,6 @@ elif [[ "${#containers[@]}" == 0 ]]; then echo -e "No containers available\nAre you sure the application in running?" exit else - for pod in "${pod_id[@]}" - do - echo "$pod" - done while true do clear -x From 7b0cacbfebd04968352a44fab531018b51180547 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:36:42 -0600 Subject: [PATCH 576/823] sanity check --- functions/cmd_to_container.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index c4d0e34d..1f1c8d51 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -43,13 +43,13 @@ else do clear -x title - cont_search=$( + for i in "${containers[@]}" do echo "$i" done | nl -s ") " | column -t - ) - echo "$cont_search" + + echo echo "0) Exit" read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } From a5b17cdb964a34caf4e6b36b160f37e5d5d666ca Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:37:53 -0600 Subject: [PATCH 577/823] what the hell --- functions/cmd_to_container.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 1f1c8d51..3a55241a 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -29,6 +29,7 @@ count=0 for pod in "${pod_id[@]}" do mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') + echo "${#containers[@]}" ((count++)) done @@ -43,13 +44,13 @@ else do clear -x title - + cont_search=$( for i in "${containers[@]}" do echo "$i" done | nl -s ") " | column -t - - + ) + echo "$cont_search" echo echo "0) Exit" read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } From ba58fecf89cb5894a17e3ea5d5089673111d620b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:40:33 -0600 Subject: [PATCH 578/823] new array append method --- functions/cmd_to_container.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 3a55241a..70484252 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -25,15 +25,13 @@ done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]][a-z]{2,5}[[:space:]](hour)?[[:space:]]?ago//') mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') -count=0 for pod in "${pod_id[@]}" do - mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") echo "${#containers[@]}" - ((count++)) done -if [[ $count == 1 ]]; then +if [[ "${#containers[@]}" == 1 ]]; then container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') elif [[ "${#containers[@]}" == 0 ]]; then From c6d0926fc2b2aa390aa57974814e6c22d8e03757 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:41:51 -0600 Subject: [PATCH 579/823] works --- functions/cmd_to_container.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 70484252..d1dc1870 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -28,15 +28,14 @@ mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]] for pod in "${pod_id[@]}" do containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") - echo "${#containers[@]}" done -if [[ "${#containers[@]}" == 1 ]]; then - container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') - container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') -elif [[ "${#containers[@]}" == 0 ]]; then +if [[ "${#containers[@]}" == 0 ]]; then echo -e "No containers available\nAre you sure the application in running?" exit +elif [[ "${#containers[@]}" == 1 ]]; then + container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') else while true do From 665db11d8cb0c31d021a1780b99c2d11c0c4c290 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:46:01 -0600 Subject: [PATCH 580/823] replace ugly if statement with case --- functions/cmd_to_container.sh | 109 +++++++++++++++++++++++----------- 1 file changed, 75 insertions(+), 34 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index d1dc1870..787b1c62 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -30,41 +30,82 @@ do containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") done -if [[ "${#containers[@]}" == 0 ]]; then - echo -e "No containers available\nAre you sure the application in running?" - exit -elif [[ "${#containers[@]}" == 1 ]]; then - container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') - container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') -else - while true - do - clear -x - title - cont_search=$( - for i in "${containers[@]}" +case "${#containers[@]}" in + 0) + echo -e "No containers available\nAre you sure the application in running?" + exit + ;; + 1) + container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') + ;; + + *) + while true do - echo "$i" - done | nl -s ") " | column -t - ) - echo "$cont_search" - echo - echo "0) Exit" - read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $selection == 0 ]]; then - echo "Exiting.." - exit - elif ! echo -e "$cont_search}" | grep -qs ^"$selection)" ; then - echo "Error: \"$selection\" was not an option.. Try again" - sleep 3 - continue - else - break - fi - done - container=$(echo "$cont_search" | grep ^"$selection)" | awk '{print $2}') - container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') -fi + clear -x + title + cont_search=$( + for i in "${containers[@]}" + do + echo "$i" + done | nl -s ") " | column -t + ) + echo "$cont_search" + echo + echo "0) Exit" + read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $selection == 0 ]]; then + echo "Exiting.." + exit + elif ! echo -e "$cont_search}" | grep -qs ^"$selection)" ; then + echo "Error: \"$selection\" was not an option.. Try again" + sleep 3 + continue + else + break + fi + done + container=$(echo "$cont_search" | grep ^"$selection)" | awk '{print $2}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') + ;; +esac + +# if [[ "${#containers[@]}" == 0 ]]; then +# echo -e "No containers available\nAre you sure the application in running?" +# exit +# elif [[ "${#containers[@]}" == 1 ]]; then +# container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') +# container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') +# else +# while true +# do +# clear -x +# title +# cont_search=$( +# for i in "${containers[@]}" +# do +# echo "$i" +# done | nl -s ") " | column -t +# ) +# echo "$cont_search" +# echo +# echo "0) Exit" +# read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } +# if [[ $selection == 0 ]]; then +# echo "Exiting.." +# exit +# elif ! echo -e "$cont_search}" | grep -qs ^"$selection)" ; then +# echo "Error: \"$selection\" was not an option.. Try again" +# sleep 3 +# continue +# else +# break +# fi +# done +# container=$(echo "$cont_search" | grep ^"$selection)" | awk '{print $2}') +# container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') +# fi while true do clear -x From fc8dba252a018873be44788081d734c254d88b6d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:47:37 -0600 Subject: [PATCH 581/823] remove commented out if statement --- functions/cmd_to_container.sh | 37 ----------------------------------- 1 file changed, 37 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 787b1c62..2d011172 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -29,7 +29,6 @@ for pod in "${pod_id[@]}" do containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") done - case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" @@ -70,42 +69,6 @@ case "${#containers[@]}" in container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') ;; esac - -# if [[ "${#containers[@]}" == 0 ]]; then -# echo -e "No containers available\nAre you sure the application in running?" -# exit -# elif [[ "${#containers[@]}" == 1 ]]; then -# container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') -# container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') -# else -# while true -# do -# clear -x -# title -# cont_search=$( -# for i in "${containers[@]}" -# do -# echo "$i" -# done | nl -s ") " | column -t -# ) -# echo "$cont_search" -# echo -# echo "0) Exit" -# read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } -# if [[ $selection == 0 ]]; then -# echo "Exiting.." -# exit -# elif ! echo -e "$cont_search}" | grep -qs ^"$selection)" ; then -# echo "Error: \"$selection\" was not an option.. Try again" -# sleep 3 -# continue -# else -# break -# fi -# done -# container=$(echo "$cont_search" | grep ^"$selection)" | awk '{print $2}') -# container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') -# fi while true do clear -x From 83e7657c37de4647a8d3be21e445f2c895a5181a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:50:39 -0600 Subject: [PATCH 582/823] increase timeout for command submission --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 2d011172..115ad619 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -89,7 +89,7 @@ do 1) clear -x title - read -rt 120 -p "What command do you want to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } + read -rt 500 -p "What command do you want to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } k3s crictl exec -it "$container_id" $command break ;; From e21736cb8b0e5d3171362139de8b82f311b9478b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 18:44:52 -0600 Subject: [PATCH 583/823] sleep 1.5 instead of 2 --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 74641ac9..44e78211 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,7 +11,7 @@ echo "Asynchronous Updates: $update_limit" # previous 20% 2 min 9 seconds it=0 -while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) > temp.txt +while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) echo "$while_status" > temp.txt rm trigger &>/dev/null while true @@ -34,7 +34,7 @@ do do update_apps "${array[$it]}" & processes+=($!) - sleep 2 + sleep 1.5 ((it++)) ((proc_count++)) done From 2e146d1e581db8e44181b1b254b3e19a4af37dc5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 18:57:50 -0600 Subject: [PATCH 584/823] if status check times out, try again immediately --- functions/update_apps.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 44e78211..20095e28 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -17,8 +17,11 @@ rm trigger &>/dev/null while true do if [[ -f trigger ]]; then - while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) - echo "$while_status" > temp.txt + if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then + echo "$while_status" > temp.txt + else + continue + fi fi proc_count=${#processes[@]} count=0 From ffd23b7e154fc735e30ba31afeb52e13e6762508 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 19:05:10 -0600 Subject: [PATCH 585/823] set delay higher on trigger --- functions/update_apps.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 20095e28..a2c78df3 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,9 +14,11 @@ it=0 while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) echo "$while_status" > temp.txt rm trigger &>/dev/null +delay=2 while true do if [[ -f trigger ]]; then + delay=4 if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then echo "$while_status" > temp.txt else @@ -31,7 +33,7 @@ do ((count++)) done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 4 + sleep $delay elif [[ $it -lt ${#array[@]} ]]; then until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do @@ -42,7 +44,7 @@ do ((proc_count++)) done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish - sleep 4 + sleep $delay else # All processes must be completed, break out of loop break fi From 984b51e6b0a093398fab62c4103a2ec6dd6e6fd2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 19:11:52 -0600 Subject: [PATCH 586/823] echo error on middleware timeout --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a2c78df3..cd2ea0b5 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -22,6 +22,7 @@ do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then echo "$while_status" > temp.txt else + echo "Middlewared timed out. Consider setting a lower number for async applications" continue fi fi From 5511cbde46b7a5320be3574c560dc3557efb904e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 20:04:15 -0600 Subject: [PATCH 587/823] global sleep to 10, proper loop check for stopped --- functions/update_apps.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index cd2ea0b5..252158e8 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -172,19 +172,21 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } echo_array+=("Stopped") break else - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check echo_array+=("Active") break #if reports active any time after the first loop, assume actually active. fi elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 10 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports stopped on FIRST time through loop, double check echo_array+=("Stopped") break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then @@ -212,7 +214,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") - sleep 15 + sleep 5 continue fi done From e57cb90642417e449a355a8cad3dd926f36f985b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 20:15:38 -0600 Subject: [PATCH 588/823] test --- functions/update_apps.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 252158e8..0a0c6bf0 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -172,21 +172,21 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } echo_array+=("Stopped") break else - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check echo_array+=("Active") break #if reports active any time after the first loop, assume actually active. fi elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 10 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check echo_array+=("Stopped") break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then From 83d65a2a8fbcea235b99ce05822d12b31e7a5502 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 20:23:03 -0600 Subject: [PATCH 589/823] replace manual counter with array count --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 0a0c6bf0..2403ff2e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -44,7 +44,7 @@ do ((it++)) ((proc_count++)) done - elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish + elif [[ ${#processes[@]} != 0 ]]; then # Wait for all processes to finish sleep $delay else # All processes must be completed, break out of loop break From 36002c59fbf75f821a4c755b01578faa04000fc8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 20:36:24 -0600 Subject: [PATCH 590/823] once last check prior to exiting script --- functions/update_apps.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2403ff2e..d2a917ad 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,6 +15,7 @@ while_status=$(cli -m csv -c 'app chart_release query name,update_available,huma echo "$while_status" > temp.txt rm trigger &>/dev/null delay=2 +final_check=0 while true do if [[ -f trigger ]]; then @@ -44,9 +45,10 @@ do ((it++)) ((proc_count++)) done - elif [[ ${#processes[@]} != 0 ]]; then # Wait for all processes to finish + elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep $delay else # All processes must be completed, break out of loop + [[ $final_check == 0 ]] && ((final_check++)) && continue break fi done From 0ff74e42a7d27334aa1e7cab35cf635f0e37077d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 20:40:33 -0600 Subject: [PATCH 591/823] first app waits after trigger --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d2a917ad..7e5ec6de 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -147,7 +147,7 @@ do update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') if [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then - [[ ! -e trigger ]] && touch trigger + [[ ! -e trigger ]] && touch trigger && sleep 10 sleep 6 ((count++)) continue @@ -167,7 +167,7 @@ after_update_actions(){ SECONDS=0 count=0 if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then - [[ ! -e trigger ]] && touch trigger + [[ ! -e trigger ]] && touch trigger && sleep 10 while true do (( count++ )) From 3e0ad6d18e88d8cfae44871982ef1b387805fa8f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 21:09:20 -0600 Subject: [PATCH 592/823] test new sleep. just racing --- functions/update_apps.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 7e5ec6de..aa885700 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -41,7 +41,7 @@ do do update_apps "${array[$it]}" & processes+=($!) - sleep 1.5 + # sleep 1.5 ((it++)) ((proc_count++)) done @@ -174,21 +174,21 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } echo_array+=("Stopped") break else - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check echo_array+=("Active") break #if reports active any time after the first loop, assume actually active. fi elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 10 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports stopped on FIRST time through loop, double check echo_array+=("Stopped") break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then From 006d47503eec55c349730418ce40e0e8f076ee83 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 21:23:21 -0600 Subject: [PATCH 593/823] internal sleep 2 --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index aa885700..c69aa950 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -41,7 +41,7 @@ do do update_apps "${array[$it]}" & processes+=($!) - # sleep 1.5 + sleep 2 ((it++)) ((proc_count++)) done From 2bf137fbc55ba089c0a1f7f31aedde328c9294cd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 21:37:29 -0600 Subject: [PATCH 594/823] longer sleep --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index c69aa950..1f78da16 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -41,7 +41,7 @@ do do update_apps "${array[$it]}" & processes+=($!) - sleep 2 + sleep 4 ((it++)) ((proc_count++)) done From 31285a8d68f20e4ded74586e93de63e964f7f418 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 21:46:08 -0600 Subject: [PATCH 595/823] revert to original method +2 at a time --- functions/update_apps.sh | 84 +++++++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 22 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 1f78da16..05a2edec 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -10,23 +10,64 @@ echo "Asynchronous Updates: $update_limit" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" # previous 20% 2 min 9 seconds -it=0 -while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) -echo "$while_status" > temp.txt -rm trigger &>/dev/null -delay=2 +# it=0 +# while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) +# echo "$while_status" > temp.txt +# rm trigger &>/dev/null +# delay=2 +# final_check=0 +# while true +# do +# if [[ -f trigger ]]; then +# delay=4 +# if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then +# echo "$while_status" > temp.txt +# else +# echo "Middlewared timed out. Consider setting a lower number for async applications" +# continue +# fi +# fi +# proc_count=${#processes[@]} +# count=0 +# for proc in "${processes[@]}" +# do +# kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } +# ((count++)) +# done +# if [[ "$proc_count" -ge "$update_limit" ]]; then +# sleep $delay +# elif [[ $it -lt ${#array[@]} ]]; then +# until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] +# do +# update_apps "${array[$it]}" & +# processes+=($!) +# sleep 4 +# ((it++)) +# ((proc_count++)) +# done +# elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish +# sleep $delay +# else # All processes must be completed, break out of loop +# [[ $final_check == 0 ]] && ((final_check++)) && continue +# break +# fi +# done +# rm temp.txt +# [[ -f trigger ]] && rm trigger +# echo +# echo + final_check=0 +it=0 while true do - if [[ -f trigger ]]; then - delay=4 - if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then - echo "$while_status" > temp.txt - else - echo "Middlewared timed out. Consider setting a lower number for async applications" - continue - fi + if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then + echo "$while_status" > temp.txt + else + echo "Middlewared timed out. Consider setting a lower number for async applications" + continue fi + echo "$while_status" > temp.txt proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" @@ -35,27 +76,26 @@ do ((count++)) done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep $delay + sleep 3 elif [[ $it -lt ${#array[@]} ]]; then - until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] + until [[ "$proc_count" -ge 2 || $it -ge ${#array[@]} ]]; do update_apps "${array[$it]}" & processes+=($!) - sleep 4 - ((it++)) ((proc_count++)) + ((it++)) done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish - sleep $delay + sleep 3 else # All processes must be completed, break out of loop [[ $final_check == 0 ]] && ((final_check++)) && continue break fi done rm temp.txt -[[ -f trigger ]] && rm trigger echo echo + } export -f commander @@ -99,7 +139,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || echo_array+=("Error: Failed to stop $app_name") SECONDS=0 - [[ ! -e trigger ]] && touch trigger + # [[ ! -e trigger ]] && touch trigger while [[ "$status" != "STOPPED" ]] do status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') @@ -147,7 +187,7 @@ do update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') if [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then - [[ ! -e trigger ]] && touch trigger && sleep 10 + # [[ ! -e trigger ]] && touch trigger && sleep 10 sleep 6 ((count++)) continue @@ -167,7 +207,7 @@ after_update_actions(){ SECONDS=0 count=0 if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then - [[ ! -e trigger ]] && touch trigger && sleep 10 + # [[ ! -e trigger ]] && touch trigger && sleep 10 while true do (( count++ )) From eddf0937c440e8750be50bec09df5558bc142a37 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 21:50:32 -0600 Subject: [PATCH 596/823] give until loop its own variable.. --- functions/update_apps.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 05a2edec..73f1b7b6 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -78,11 +78,12 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 elif [[ $it -lt ${#array[@]} ]]; then - until [[ "$proc_count" -ge 2 || $it -ge ${#array[@]} ]]; + loop=0 + until [[ "$loop" -ge 2 || $it -ge ${#array[@]} ]]; do update_apps "${array[$it]}" & processes+=($!) - ((proc_count++)) + ((loop++)) ((it++)) done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish From b012416a07c4972b407a70392506b114b47605f9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:04:33 -0600 Subject: [PATCH 597/823] test --- functions/update_apps.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 73f1b7b6..fc0bdae3 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -78,14 +78,14 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 elif [[ $it -lt ${#array[@]} ]]; then - loop=0 - until [[ "$loop" -ge 2 || $it -ge ${#array[@]} ]]; - do + # loop=0 + # until [[ "$loop" -ge 2 || $it -ge ${#array[@]} ]]; + # do update_apps "${array[$it]}" & processes+=($!) ((loop++)) ((it++)) - done + # done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop From 06bb4e569f6cc9b2e0fa8c6493deff9d03290501 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:14:30 -0600 Subject: [PATCH 598/823] racing --- functions/update_apps.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index fc0bdae3..45a24abc 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -57,7 +57,6 @@ echo "Asynchronous Updates: $update_limit" # echo # echo -final_check=0 it=0 while true do @@ -78,18 +77,17 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 elif [[ $it -lt ${#array[@]} ]]; then - # loop=0 - # until [[ "$loop" -ge 2 || $it -ge ${#array[@]} ]]; - # do + loop=0 + until [[ "$loop" -ge 2 || $it -ge ${#array[@]} ]]; + do update_apps "${array[$it]}" & processes+=($!) ((loop++)) ((it++)) - # done + done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop - [[ $final_check == 0 ]] && ((final_check++)) && continue break fi done From c7afe81a387d129c595936658583639fa8339479 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:26:39 -0600 Subject: [PATCH 599/823] add proc count to Until loop --- functions/update_apps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 45a24abc..afa35d51 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -78,11 +78,12 @@ do sleep 3 elif [[ $it -lt ${#array[@]} ]]; then loop=0 - until [[ "$loop" -ge 2 || $it -ge ${#array[@]} ]]; + until [[ $loop -ge 2 || $proc_count -ge $update_limit || $it -ge ${#array[@]} ]]; do update_apps "${array[$it]}" & processes+=($!) ((loop++)) + ((proc_count++)) ((it++)) done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish From 8af787f2d4f77055bf91b3acfa5e000ee25249dd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:27:49 -0600 Subject: [PATCH 600/823] revert, un-needed due to condition above it --- functions/update_apps.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index afa35d51..078b6cd8 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -78,12 +78,11 @@ do sleep 3 elif [[ $it -lt ${#array[@]} ]]; then loop=0 - until [[ $loop -ge 2 || $proc_count -ge $update_limit || $it -ge ${#array[@]} ]]; + until [[ $loop -ge 2 || $it -ge ${#array[@]} ]]; do update_apps "${array[$it]}" & processes+=($!) ((loop++)) - ((proc_count++)) ((it++)) done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish From 116279db37b41b722c8c087724abe6c2f3dcb0b0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:35:30 -0600 Subject: [PATCH 601/823] sticking to one at a time, anymore is overloading --- functions/update_apps.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 078b6cd8..b5f08e75 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -77,14 +77,14 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 elif [[ $it -lt ${#array[@]} ]]; then - loop=0 - until [[ $loop -ge 2 || $it -ge ${#array[@]} ]]; - do - update_apps "${array[$it]}" & - processes+=($!) - ((loop++)) - ((it++)) - done + # loop=0 + # until [[ $loop -ge 2 || $it -ge ${#array[@]} ]]; + # do + update_apps "${array[$it]}" & + processes+=($!) + ((loop++)) + ((it++)) + # done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop From 4f944a62997eac30b9fa0ac4160c1763b9c75735 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:50:44 -0600 Subject: [PATCH 602/823] add count to the status file for cont change --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index b5f08e75..8397f580 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -61,7 +61,7 @@ it=0 while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then - echo "$while_status" > temp.txt + echo -e "$it\n$while_status" > temp.txt else echo "Middlewared timed out. Consider setting a lower number for async applications" continue @@ -255,7 +255,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") - sleep 5 + sleep 10 continue fi done From 54e4c3876e4ca7037511f8988ba4a5d9c49e7228 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:51:58 -0600 Subject: [PATCH 603/823] use its own count --- functions/update_apps.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 8397f580..74012adc 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -58,10 +58,12 @@ echo "Asynchronous Updates: $update_limit" # echo it=0 +while_count=0 while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then - echo -e "$it\n$while_status" > temp.txt + ((while_count++)) + echo -e "$while_count\n$while_status" > temp.txt else echo "Middlewared timed out. Consider setting a lower number for async applications" continue From 5edeb8c80bc1558c06f3757ba028dc0ed0accf59 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:55:20 -0600 Subject: [PATCH 604/823] count was not being appended --- functions/update_apps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 74012adc..4a241f64 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -63,7 +63,8 @@ while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then ((while_count++)) - echo -e "$while_count\n$while_status" > temp.txt + echo "$while_status" > temp.txt + echo "$while_count" >> temp.txt else echo "Middlewared timed out. Consider setting a lower number for async applications" continue From 4e617893470473bac49f3fbe9fc4f2842c8d366d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:58:51 -0600 Subject: [PATCH 605/823] remove redundant creation --- functions/update_apps.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 4a241f64..95b9030a 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -63,13 +63,11 @@ while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then ((while_count++)) - echo "$while_status" > temp.txt - echo "$while_count" >> temp.txt + echo -e "$while_count\n$while_status" > temp.txt else echo "Middlewared timed out. Consider setting a lower number for async applications" continue fi - echo "$while_status" > temp.txt proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" From 5888efa3d7a62af7bffe75556b2d70749d3a2da7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 23:27:11 -0600 Subject: [PATCH 606/823] wait for file change before continuing --- functions/update_apps.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 95b9030a..28801d9d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -210,8 +210,18 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then # [[ ! -e trigger ]] && touch trigger && sleep 10 while true do - (( count++ )) + if [[ $count -lt 1 ]]; then + while_count=$(head -n 1 temp.txt) + else + until [[ $while_count -lt $current_count ]] # Wait for a change in the file BEFORE continuing + do + current_count=$(head -n 1 temp.txt) + sleep 2 + done + while_count=$current_count + fi status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + (( count++ )) if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check From c1793c530691a2e6abd664a5f8bfa7ca9a079903 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 23:37:53 -0600 Subject: [PATCH 607/823] reduce sleep on file difference check --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 28801d9d..2c20ca27 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -216,7 +216,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then until [[ $while_count -lt $current_count ]] # Wait for a change in the file BEFORE continuing do current_count=$(head -n 1 temp.txt) - sleep 2 + sleep 1 done while_count=$current_count fi From c62da2c13dfaf614eb6b4b71399375ef15f253a7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 23:41:20 -0600 Subject: [PATCH 608/823] attempt removal of status double checks --- functions/update_apps.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2c20ca27..16a03446 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -224,21 +224,21 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then (( count++ )) if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check + # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check + # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } echo_array+=("Stopped") break else - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check + # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check + # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check echo_array+=("Active") break #if reports active any time after the first loop, assume actually active. fi elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 10 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports stopped on FIRST time through loop, double check + # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 10 && continue #if reports stopped on FIRST time through loop, double check + # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports stopped on FIRST time through loop, double check echo_array+=("Stopped") break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then From f56b03c0ebd5c34c63a769f6f4161a88f09f80da Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 23:45:46 -0600 Subject: [PATCH 609/823] still need the counter. --- functions/update_apps.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 16a03446..4d69cb16 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -224,21 +224,21 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then (( count++ )) if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then - # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check - # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } echo_array+=("Stopped") break else - # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check - # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check echo_array+=("Active") break #if reports active any time after the first loop, assume actually active. fi elif [[ "$status" == "STOPPED" ]]; then - # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 10 && continue #if reports stopped on FIRST time through loop, double check - # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check echo_array+=("Stopped") break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then From 850303e3287806c6d73a36561b871ef1c627033e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 23:55:45 -0600 Subject: [PATCH 610/823] try app specific status check instead of global --- functions/update_apps.sh | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 4d69cb16..946249ec 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -210,35 +210,46 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then # [[ ! -e trigger ]] && touch trigger && sleep 10 while true do - if [[ $count -lt 1 ]]; then - while_count=$(head -n 1 temp.txt) + if [[ $count -lt 1 ]]; then + old_status=$(grep "^$app_name," temp.txt) else - until [[ $while_count -lt $current_count ]] # Wait for a change in the file BEFORE continuing + until [[ "$new_status" != "$old_status" ]] # Wait for a change in the file BEFORE continuing do - current_count=$(head -n 1 temp.txt) + new_status=$(grep "^$app_name," temp.txt) sleep 1 done - while_count=$current_count + old_status=$new_status fi + + # if [[ $count -lt 1 ]]; then + # while_count=$(head -n 1 temp.txt) + # else + # until [[ $while_count -lt $current_count ]] # Wait for a change in the file BEFORE continuing + # do + # current_count=$(head -n 1 temp.txt) + # sleep 1 + # done + # while_count=$current_count + # fi status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') (( count++ )) if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check + # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check + # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } echo_array+=("Stopped") break else - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check + # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check + # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check echo_array+=("Active") break #if reports active any time after the first loop, assume actually active. fi elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check echo_array+=("Stopped") break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then From bef42eaaebf704ad1cc8a54021d10c7c209f6523 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 00:18:53 -0600 Subject: [PATCH 611/823] check for file changes and specific status --- functions/update_apps.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 946249ec..bc44d24c 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -213,10 +213,15 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then if [[ $count -lt 1 ]]; then old_status=$(grep "^$app_name," temp.txt) else - until [[ "$new_status" != "$old_status" ]] # Wait for a change in the file BEFORE continuing + before_loop=$(head -n 1 temp.txt) + until [[ "$new_status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a change in the file BEFORE continuing do new_status=$(grep "^$app_name," temp.txt) sleep 1 + if ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then + before_loop=$(head -n 1 temp.txt) + ((current_loop++)) + fi done old_status=$new_status fi @@ -235,21 +240,21 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then (( count++ )) if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then - # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check - # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } echo_array+=("Stopped") break else - # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check - # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && continue #if reports active on FIRST time through loop, double check echo_array+=("Active") break #if reports active any time after the first loop, assume actually active. fi elif [[ "$status" == "STOPPED" ]]; then - # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && continue #if reports stopped on FIRST time through loop, double check echo_array+=("Stopped") break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then From 06f0f7ea3aac75c4c53116794d4b1a6ff680cdc0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 01:48:31 -0600 Subject: [PATCH 612/823] fix status check --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index bc44d24c..339fb7bf 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -214,6 +214,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then old_status=$(grep "^$app_name," temp.txt) else before_loop=$(head -n 1 temp.txt) + new_status=old_status until [[ "$new_status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a change in the file BEFORE continuing do new_status=$(grep "^$app_name," temp.txt) From ec422e8db9e2e19226b34b067fd3d4508213e6bd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 01:50:41 -0600 Subject: [PATCH 613/823] assigned literal on accident.. --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 339fb7bf..f3734dc5 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -214,7 +214,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then old_status=$(grep "^$app_name," temp.txt) else before_loop=$(head -n 1 temp.txt) - new_status=old_status + new_status=$old_status until [[ "$new_status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a change in the file BEFORE continuing do new_status=$(grep "^$app_name," temp.txt) From ea7a3e94907ff4f478d7021d0f44d0627aee7f3c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 16:37:19 -0600 Subject: [PATCH 614/823] remove commented stuff --- functions/update_apps.sh | 76 ++++------------------------------------ 1 file changed, 7 insertions(+), 69 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f3734dc5..4cadd7f5 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,54 +9,6 @@ echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -# previous 20% 2 min 9 seconds -# it=0 -# while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) -# echo "$while_status" > temp.txt -# rm trigger &>/dev/null -# delay=2 -# final_check=0 -# while true -# do -# if [[ -f trigger ]]; then -# delay=4 -# if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then -# echo "$while_status" > temp.txt -# else -# echo "Middlewared timed out. Consider setting a lower number for async applications" -# continue -# fi -# fi -# proc_count=${#processes[@]} -# count=0 -# for proc in "${processes[@]}" -# do -# kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } -# ((count++)) -# done -# if [[ "$proc_count" -ge "$update_limit" ]]; then -# sleep $delay -# elif [[ $it -lt ${#array[@]} ]]; then -# until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] -# do -# update_apps "${array[$it]}" & -# processes+=($!) -# sleep 4 -# ((it++)) -# ((proc_count++)) -# done -# elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish -# sleep $delay -# else # All processes must be completed, break out of loop -# [[ $final_check == 0 ]] && ((final_check++)) && continue -# break -# fi -# done -# rm temp.txt -# [[ -f trigger ]] && rm trigger -# echo -# echo - it=0 while_count=0 while true @@ -83,8 +35,8 @@ do # do update_apps "${array[$it]}" & processes+=($!) - ((loop++)) ((it++)) + # ((loop++)) # done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 @@ -182,12 +134,13 @@ export -f update_apps update(){ count=0 -while [[ $count -lt 3 ]] +while true do update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') - if [[ $update_avail == "true" ]]; then + if [[ $count -gt 2 ]]; then + return 1 + elif [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then - # [[ ! -e trigger ]] && touch trigger && sleep 10 sleep 6 ((count++)) continue @@ -195,9 +148,6 @@ do break elif [[ $update_avail == "false" ]]; then break - else - ((count++)) - sleep 6 fi done } @@ -207,15 +157,14 @@ after_update_actions(){ SECONDS=0 count=0 if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then - # [[ ! -e trigger ]] && touch trigger && sleep 10 while true do - if [[ $count -lt 1 ]]; then + if [[ $count -lt 1 ]]; then old_status=$(grep "^$app_name," temp.txt) else before_loop=$(head -n 1 temp.txt) new_status=$old_status - until [[ "$new_status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a change in the file BEFORE continuing + until [[ "$new_status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do new_status=$(grep "^$app_name," temp.txt) sleep 1 @@ -226,17 +175,6 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then done old_status=$new_status fi - - # if [[ $count -lt 1 ]]; then - # while_count=$(head -n 1 temp.txt) - # else - # until [[ $while_count -lt $current_count ]] # Wait for a change in the file BEFORE continuing - # do - # current_count=$(head -n 1 temp.txt) - # sleep 1 - # done - # while_count=$current_count - # fi status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') (( count++ )) if [[ "$status" == "ACTIVE" ]]; then From 5d3470c2dd4b3cbb3c7404bc9fe87b06a3210eda Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 20:30:49 -0600 Subject: [PATCH 615/823] loop on update failure --- functions/update_apps.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 4cadd7f5..4ec0713a 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -141,9 +141,19 @@ do return 1 elif [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then - sleep 6 - ((count++)) - continue + # sleep 6 + # ((count++)) + # continue + before_loop=$(head -n 1 temp.txt) + current_loop=0 + until [[ "$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}')" != "$update_avail" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + do + sleep 1 + if ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then + before_loop=$(head -n 1 temp.txt) + ((current_loop++)) + fi + done fi break elif [[ $update_avail == "false" ]]; then @@ -164,6 +174,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then else before_loop=$(head -n 1 temp.txt) new_status=$old_status + current_loop=0 until [[ "$new_status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do new_status=$(grep "^$app_name," temp.txt) From e2942dd6264fe2a9eed8a94fd0f5fd0aff1f1a93 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 20:41:31 -0600 Subject: [PATCH 616/823] update update function --- functions/update_apps.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 4ec0713a..b87e8a18 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -137,27 +137,31 @@ count=0 while true do update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') - if [[ $count -gt 2 ]]; then - return 1 - elif [[ $update_avail == "true" ]]; then + # if [[ $count -gt 2 ]]; then + # return 1 + if [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then # sleep 6 # ((count++)) # continue before_loop=$(head -n 1 temp.txt) current_loop=0 - until [[ "$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}')" != "$update_avail" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + until [[ "$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}')" != "$update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do - sleep 1 - if ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then + if [[ $current_loop -gt 3 ]]; then + return 1 #App failed to update, return error code to update_apps func + elif ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then # The file has been updated, but nothing changed specifically for the app. before_loop=$(head -n 1 temp.txt) ((current_loop++)) fi + sleep 1 done fi break elif [[ $update_avail == "false" ]]; then break + else + sleep 3 fi done } From d926bf938d46d164e708473801a6019d11223363 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 20:51:42 -0600 Subject: [PATCH 617/823] only enter loop if status is not deploying --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index b87e8a18..99d169fa 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -175,7 +175,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then do if [[ $count -lt 1 ]]; then old_status=$(grep "^$app_name," temp.txt) - else + elif [[ $status != "DEPLOYING" ]]; then before_loop=$(head -n 1 temp.txt) new_status=$old_status current_loop=0 From 1473a969e275e6557329cce1f64a0ebf14fcd782 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 20:55:37 -0600 Subject: [PATCH 618/823] change status to activity specific --- functions/update_apps.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 99d169fa..7427fcfc 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -173,15 +173,16 @@ count=0 if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do + status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') if [[ $count -lt 1 ]]; then - old_status=$(grep "^$app_name," temp.txt) + old_status=$status elif [[ $status != "DEPLOYING" ]]; then before_loop=$(head -n 1 temp.txt) new_status=$old_status current_loop=0 until [[ "$new_status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do - new_status=$(grep "^$app_name," temp.txt) + new_status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') sleep 1 if ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then before_loop=$(head -n 1 temp.txt) @@ -190,7 +191,6 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then done old_status=$new_status fi - status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') (( count++ )) if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then From 99dc8fcef83d2a55368b1850b8af9f3bd79dff9f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 21:20:04 -0600 Subject: [PATCH 619/823] use bool to only verify if active/stopped 1st time --- functions/update_apps.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 7427fcfc..b5844fa0 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -176,7 +176,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') if [[ $count -lt 1 ]]; then old_status=$status - elif [[ $status != "DEPLOYING" ]]; then + elif [[ $verify == "true" ]]; then before_loop=$(head -n 1 temp.txt) new_status=$old_status current_loop=0 @@ -194,21 +194,21 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then (( count++ )) if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && verify="true" && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && verify="true" && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } echo_array+=("Stopped") break else - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && verify="true" && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && verify="true" && continue #if reports active on FIRST time through loop, double check echo_array+=("Active") break #if reports active any time after the first loop, assume actually active. fi elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && verify="true" && echo_array+=("Verifying Stopped..") && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && verify="true" && continue #if reports stopped on FIRST time through loop, double check echo_array+=("Stopped") break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then @@ -236,7 +236,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") - sleep 10 + sleep 5 continue fi done From 97896b27a2aac9362b7a1690d921af8df2ac1752 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 21:37:38 -0600 Subject: [PATCH 620/823] status check when leaving verify --- functions/update_apps.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index b5844fa0..766ace10 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -190,6 +190,8 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi done old_status=$new_status + status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + unset verify fi (( count++ )) if [[ "$status" == "ACTIVE" ]]; then From 61eea4c9a5f25fc72607ebda2ac51445de300a83 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 21:43:15 -0600 Subject: [PATCH 621/823] remove newstatus variable, just use status instead --- functions/update_apps.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 766ace10..ec807f5d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -178,19 +178,16 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then old_status=$status elif [[ $verify == "true" ]]; then before_loop=$(head -n 1 temp.txt) - new_status=$old_status current_loop=0 - until [[ "$new_status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + until [[ "$status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do - new_status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') sleep 1 if ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then before_loop=$(head -n 1 temp.txt) ((current_loop++)) fi done - old_status=$new_status - status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') unset verify fi (( count++ )) From 653e54804ad31db04280ad9136e1d3d9321e3c7b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 21:55:09 -0600 Subject: [PATCH 622/823] testing update function --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ec807f5d..82f4fe7d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -133,7 +133,7 @@ export -f update_apps update(){ -count=0 +# count=0 while true do update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') From c45bf0a5887477ac35ccf63b07285d4ba1d3c8d2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 22:15:17 -0600 Subject: [PATCH 623/823] add trigger for debugging --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 82f4fe7d..00a1c32f 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -141,6 +141,7 @@ do # return 1 if [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then + echo "Fail Trigger - Debugging" # sleep 6 # ((count++)) # continue From 4469d96cb69ea97157094b1d3e47db4d95c74788 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 22:42:43 -0600 Subject: [PATCH 624/823] if while status is empty.. call again --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 00a1c32f..0aaea2e2 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,8 +14,8 @@ while_count=0 while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then - ((while_count++)) - echo -e "$while_count\n$while_status" > temp.txt + ((while_count++)) + [[ -z $while_status ]] && continue || echo -e "$while_count\n$while_status" > temp.txt else echo "Middlewared timed out. Consider setting a lower number for async applications" continue From 3f5d8d4c734d10c58c5a7d8c5ab1ce77b5be9e63 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 22:52:45 -0600 Subject: [PATCH 625/823] attempt second update, if while_status empty, skip --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 0aaea2e2..cf0b6f77 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -150,7 +150,7 @@ do until [[ "$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}')" != "$update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do if [[ $current_loop -gt 3 ]]; then - return 1 #App failed to update, return error code to update_apps func + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || return 1 # After waiting, attempt an update once more, if fails, return error code elif ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then # The file has been updated, but nothing changed specifically for the app. before_loop=$(head -n 1 temp.txt) ((current_loop++)) From 592b739bf06d0fd2862c7e35480283668bd2ae04 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 06:37:30 -0600 Subject: [PATCH 626/823] stop app to cli rather than midctl, wait for compl --- functions/update_apps.sh | 71 +++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index cf0b6f77..12c5543e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -89,29 +89,12 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con else # if status was not STOPPED, stop the app prior to updating echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || echo_array+=("Error: Failed to stop $app_name") - SECONDS=0 - # [[ ! -e trigger ]] && touch trigger - while [[ "$status" != "STOPPED" ]] - do - status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') - if [[ "$status" == "STOPPED" ]]; then - echo_array+=("Stopped") - [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - if update ;then - echo_array+=("Updated\n$old_full_ver\n$new_full_ver") - else - echo_array+=("Failed to update") - return - fi - elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") - break - elif [[ "$status" != "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED") - sleep 5 - fi - done + if stop_app ; then + echo_array+=("Stopped") + else + echo_array+=("Error: Failed to stop $app_name") + return 1 + fi fi else #user must not be using -S, just update echo_array+=("\n$app_name") @@ -133,23 +116,18 @@ export -f update_apps update(){ -# count=0 +current_loop=0 while true do update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') - # if [[ $count -gt 2 ]]; then - # return 1 if [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then echo "Fail Trigger - Debugging" - # sleep 6 - # ((count++)) - # continue before_loop=$(head -n 1 temp.txt) current_loop=0 until [[ "$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}')" != "$update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do - if [[ $current_loop -gt 3 ]]; then + if [[ $current_loop -gt 2 ]]; then cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || return 1 # After waiting, attempt an update once more, if fails, return error code elif ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then # The file has been updated, but nothing changed specifically for the app. before_loop=$(head -n 1 temp.txt) @@ -168,6 +146,29 @@ done } export -f update +stop_app(){ +count=0 +while [[ "$status" != "STOPPED" ]] +do + status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + if [[ $count -gt 2 ]]; then # If failed to stop app 3 times, return failure to parent shell + return 1 + elif ! cli -c 'app chart_release scale release_name='\""$app_name"\"\ 'scale_options={"replica_count": 0}' &> /dev/null ; then + echo "Fail Trigger Stop - Debugging" + before_loop=$(head -n 1 temp.txt) + ((count++)) + until [[ $(head -n 1 temp.txt) != "$before_loop" ]] # Upon failure, wait for status update before continuing + do + sleep 1 + done + else + break + fi +done +} +export -f stop_app + + after_update_actions(){ SECONDS=0 count=0 @@ -197,8 +198,12 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && verify="true" && continue #if reports active on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && verify="true" && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } - echo_array+=("Stopped") + if stop_app ; then + echo_array+=("Stopped") + else + echo_array+=("Error: Failed to stop $app_name") + return 1 + fi break else [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && verify="true" && continue #if reports active on FIRST time through loop, double check @@ -249,4 +254,4 @@ do echo -e "$i" done } -export -f after_update_actions \ No newline at end of file +export -f after_update_actions From 7c7f42b9cb0348e35f602def497b9ea462760c05 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 06:53:35 -0600 Subject: [PATCH 627/823] always update prior to a_u_a --- functions/update_apps.sh | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 12c5543e..987dad83 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -79,13 +79,6 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$startstatus" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo_array+=("\n$app_name") - [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - if update ;then - echo_array+=("Updated\n$old_full_ver\n$new_full_ver") - else - echo_array+=("Failed to update") - return - fi else # if status was not STOPPED, stop the app prior to updating echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") @@ -98,18 +91,18 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con fi else #user must not be using -S, just update echo_array+=("\n$app_name") - [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - if update ;then - echo_array+=("Updated\n$old_full_ver\n$new_full_ver") - else - echo_array+=("Failed to update") - return - fi fi else echo -e "\n$app_name\nMajor Release, update manually" return 0 fi +[[ "$verbose" == "true" ]] && echo_array+=("Updating..") +if update ;then + echo_array+=("Updated\n$old_full_ver\n$new_full_ver") +else + echo_array+=("Failed to update") +return +fi after_update_actions } export -f update_apps From 714842a33f5d5a058a81b1accf365f181deb623f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 07:33:13 -0600 Subject: [PATCH 628/823] clean-up after_update_actions --- functions/update_apps.sh | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 987dad83..45f84f87 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -169,9 +169,9 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') - if [[ $count -lt 1 ]]; then + if [[ $count -lt 1 && $status != "Deploying" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. + [[ "$verbose" == "true" ]] && echo_array+=("Verifying $status..") old_status=$status - elif [[ $verify == "true" ]]; then before_loop=$(head -n 1 temp.txt) current_loop=0 until [[ "$status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. @@ -183,13 +183,10 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then ((current_loop++)) fi done - unset verify fi (( count++ )) if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && verify="true" && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && verify="true" && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") if stop_app ; then echo_array+=("Stopped") @@ -199,16 +196,12 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi break else - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && verify="true" && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && verify="true" && continue #if reports active on FIRST time through loop, double check echo_array+=("Active") - break #if reports active any time after the first loop, assume actually active. + break fi elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && verify="true" && echo_array+=("Verifying Stopped..") && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && verify="true" && continue #if reports stopped on FIRST time through loop, double check echo_array+=("Stopped") - break #if reports stopped any time after the first loop, assume its extermal services. + break elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then if [[ $rollback == "true" ]]; then if [[ "$failed" != "true" ]]; then From 0fbe428507e09e01771eba53cd14b3c1bfa64915 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 07:53:58 -0600 Subject: [PATCH 629/823] fix deploying comparison --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 45f84f87..afedf65a 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -169,7 +169,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') - if [[ $count -lt 1 && $status != "Deploying" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. + if [[ $count -lt 1 && $status != "DEPLOYING" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. [[ "$verbose" == "true" ]] && echo_array+=("Verifying $status..") old_status=$status before_loop=$(head -n 1 temp.txt) From 7f6018b5d591ff443bf5116f1d8ccd6ec601305b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 08:10:15 -0600 Subject: [PATCH 630/823] cmd to container regex --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 115ad619..d0a6c47b 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -23,7 +23,7 @@ do fi done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') -search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]][a-z]{2,5}[[:space:]](hour)?[[:space:]]?ago//') +search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do From a03598b1b7f45abd3072f8ad733f8e90a2b5cb8f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:13:37 -0600 Subject: [PATCH 631/823] do not add duplicate containers --- functions/cmd_to_container.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index d0a6c47b..277da7bb 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,6 +27,7 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do + printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}')" && continue containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") done case "${#containers[@]}" in From 7cbcf11fb2c6a9cdadeaa678175f4e969c7abee1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:22:00 -0600 Subject: [PATCH 632/823] try different method for rm-ing dupes --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 277da7bb..a4748c07 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,9 +27,9 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}')" && continue - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") + containers_temp+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") done +containers=(); while IFS= read -r -d '' x; do containers+=("$x"); done < <(printf "%s\0" "${containers_temp[@]}" | sort -uz) case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From cc8a0d370805b067610284f0543bfca09b6ef53d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:26:34 -0600 Subject: [PATCH 633/823] 3rd attempt --- functions/cmd_to_container.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index a4748c07..695c73ea 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,9 +27,9 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - containers_temp+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") done -containers=(); while IFS= read -r -d '' x; do containers+=("$x"); done < <(printf "%s\0" "${containers_temp[@]}" | sort -uz) +# containers=(); while IFS= read -r -d '' x; do containers+=("$x"); done < <(printf "%s\0" "${containers_temp[@]}" | sort -uz) case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" @@ -49,7 +49,7 @@ case "${#containers[@]}" in for i in "${containers[@]}" do echo "$i" - done | nl -s ") " | column -t + done | uniq | nl -s ") " | column -t ) echo "$cont_search" echo From 60418e846b738033b62f7875df8251d3315830ec Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:36:07 -0600 Subject: [PATCH 634/823] test --- functions/cmd_to_container.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 695c73ea..b2eda4cb 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,9 +27,9 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") + printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done -# containers=(); while IFS= read -r -d '' x; do containers+=("$x"); done < <(printf "%s\0" "${containers_temp[@]}" | sort -uz) case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" @@ -49,7 +49,7 @@ case "${#containers[@]}" in for i in "${containers[@]}" do echo "$i" - done | uniq | nl -s ") " | column -t + done | nl -s ") " | column -t ) echo "$cont_search" echo From 80d10a5df22d3b180a66367ecb8a44f5c9078f3e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:47:35 -0600 Subject: [PATCH 635/823] debugging --- functions/cmd_to_container.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index b2eda4cb..3b7fc50d 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -29,6 +29,7 @@ for pod in "${pod_id[@]}" do printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") + echo "ADDED" "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" done case "${#containers[@]}" in 0) From b0a4119df0f4437811ef245233986f0c66b96acf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:49:26 -0600 Subject: [PATCH 636/823] set array to 0 --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 3b7fc50d..b2938c9a 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -37,7 +37,7 @@ case "${#containers[@]}" in exit ;; 1) - container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') + container=$(echo "$search" | grep "${pod_id[0]}" | awk '{print $4}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') ;; From 61e46514d9e3bcd35e0ed41e19ee375bfb3444ca Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:51:06 -0600 Subject: [PATCH 637/823] use 0 element in array if 0-1 are equal --- functions/cmd_to_container.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index b2938c9a..6e7be5d7 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,9 +27,8 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") - echo "ADDED" "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" + printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}')" && continue + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") done case "${#containers[@]}" in 0) From 3b90402416a1719c660396fc06d415c42ce5668f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:54:59 -0600 Subject: [PATCH 638/823] test --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 6e7be5d7..43d2b8a7 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,8 +27,8 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}')" && continue - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") + printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done case "${#containers[@]}" in 0) From fc785b71b5102cada0a09ae7e7799429adcfb9dc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:59:56 -0600 Subject: [PATCH 639/823] test rebuild --- functions/cmd_to_container.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 43d2b8a7..16d8f5a5 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,9 +27,10 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") + printf '%s\0' "${containers_temp[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue + containers_temp+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done +containers=(); while IFS= read -r -d '' x; do containers+=("$x"); done < <(printf "%s\0" "${containers_temp[@]}" | sort -uz) case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From 6aa4458b1402e5ac5dc48c4b08a87e2891e97299 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 10:07:33 -0600 Subject: [PATCH 640/823] test --- functions/cmd_to_container.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 16d8f5a5..35f045b6 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,10 +27,14 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - printf '%s\0' "${containers_temp[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - containers_temp+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") + if [[ $(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " | wc -l) -gt 1 ]]; then + readarray -t containers <<<"$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" + continue + fi + printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") + done -containers=(); while IFS= read -r -d '' x; do containers+=("$x"); done < <(printf "%s\0" "${containers_temp[@]}" | sort -uz) case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From dc51517ccb34d1cb10eadaed3c0c7a2abef65001 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 10:09:20 -0600 Subject: [PATCH 641/823] test --- functions/cmd_to_container.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 35f045b6..7be74b0b 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,12 +27,13 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - if [[ $(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " | wc -l) -gt 1 ]]; then - readarray -t containers <<<"$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" - continue - fi printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") + # if [[ $(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " | wc -l) -gt 1 ]]; then + readarray -t containers <<<"$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" + # continue + # fi + + # containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done case "${#containers[@]}" in From 4294a1565fc7316a64025a0052ec8040fffe36a7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 10:10:32 -0600 Subject: [PATCH 642/823] revert --- functions/cmd_to_container.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 7be74b0b..35f045b6 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,13 +27,12 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - # if [[ $(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " | wc -l) -gt 1 ]]; then + if [[ $(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " | wc -l) -gt 1 ]]; then readarray -t containers <<<"$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" - # continue - # fi - - # containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") + continue + fi + printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done case "${#containers[@]}" in From c528757b887f23ffe2959ca933bc27575e3ef105 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 10:33:54 -0600 Subject: [PATCH 643/823] simplification of update_apps --- functions/update_apps.sh | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index afedf65a..ef554b5b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -33,7 +33,7 @@ do # loop=0 # until [[ $loop -ge 2 || $it -ge ${#array[@]} ]]; # do - update_apps "${array[$it]}" & + pre_process "${array[$it]}" & processes+=($!) ((it++)) # ((loop++)) @@ -52,7 +52,7 @@ echo export -f commander -update_apps(){ +pre_process(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version @@ -76,28 +76,23 @@ if grep -qs "^$app_name," failed.txt ; then fi fi if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update - if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not - if [[ "$startstatus" == "STOPPED" ]]; then # if status is already stopped, skip while loop - echo_array+=("\n$app_name") - else # if status was not STOPPED, stop the app prior to updating - echo_array+=("\n$app_name") - [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") - if stop_app ; then - echo_array+=("Stopped") - else - echo_array+=("Error: Failed to stop $app_name") - return 1 - fi - fi - else #user must not be using -S, just update + if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # Check to see if user is using -S or not echo_array+=("\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") + if stop_app ; then + echo_array+=("Stopped") + else + echo_array+=("Error: Failed to stop $app_name") + return 1 + fi fi else echo -e "\n$app_name\nMajor Release, update manually" return 0 fi +[[ ! $stop_before_update == "true" && "$startstatus" != "STOPPED" ]] && echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") -if update ;then +if update_app ;then echo_array+=("Updated\n$old_full_ver\n$new_full_ver") else echo_array+=("Failed to update") @@ -105,10 +100,10 @@ return fi after_update_actions } -export -f update_apps +export -f pre_process -update(){ +update_app(){ current_loop=0 while true do @@ -137,7 +132,7 @@ do fi done } -export -f update +export -f update_app stop_app(){ count=0 From bb50772fc2403f2d43a1bce45cf5571d931bb12f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 10:44:32 -0600 Subject: [PATCH 644/823] re-arrange echo array --- functions/update_apps.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ef554b5b..2807098f 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -75,9 +75,9 @@ if grep -qs "^$app_name," failed.txt ; then sed -i /"$app_name",/d failed.txt fi fi -if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update +echo_array+=("\n$app_name") +if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #Check for major versions or -U if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # Check to see if user is using -S or not - echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") if stop_app ; then echo_array+=("Stopped") @@ -90,7 +90,6 @@ else echo -e "\n$app_name\nMajor Release, update manually" return 0 fi -[[ ! $stop_before_update == "true" && "$startstatus" != "STOPPED" ]] && echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") if update_app ;then echo_array+=("Updated\n$old_full_ver\n$new_full_ver") From edf40ced53c450332960a8fc43e66a6b2117667e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 11:08:51 -0600 Subject: [PATCH 645/823] echo array to function to control output better --- functions/update_apps.sh | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2807098f..6846ed97 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -62,6 +62,7 @@ new_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{pr startstatus=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions +[[ "$diff_app" != "$diff_chart" ]] && echo -e "\n$app_name\nMajor Release, update manually" && return old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') @@ -76,26 +77,23 @@ if grep -qs "^$app_name," failed.txt ; then fi fi echo_array+=("\n$app_name") -if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #Check for major versions or -U - if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # Check to see if user is using -S or not - [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") - if stop_app ; then - echo_array+=("Stopped") - else - echo_array+=("Error: Failed to stop $app_name") - return 1 - fi +if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # Check to see if user is using -S or not + [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") + if stop_app ; then + echo_array+=("Stopped") + else + echo_array+=("Error: Failed to stop $app_name") + echo_array + return 1 fi -else - echo -e "\n$app_name\nMajor Release, update manually" - return 0 fi [[ "$verbose" == "true" ]] && echo_array+=("Updating..") if update_app ;then echo_array+=("Updated\n$old_full_ver\n$new_full_ver") else echo_array+=("Failed to update") -return + echo_array + return fi after_update_actions } @@ -186,6 +184,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then echo_array+=("Stopped") else echo_array+=("Error: Failed to stop $app_name") + echo_array return 1 fi break @@ -226,12 +225,17 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi done fi +echo_array +} +export -f after_update_actions +echo_array(){ #Dump the echo_array, ensures all output is in a neat order. for i in "${echo_array[@]}" do echo -e "$i" done + } -export -f after_update_actions +export -f echo_array From 0a9d157821b70147414187c11be6602426c9db5e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 00:35:24 -0600 Subject: [PATCH 646/823] limit major check to only -u not -U --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 6846ed97..2435b449 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -62,7 +62,7 @@ new_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{pr startstatus=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions -[[ "$diff_app" != "$diff_chart" ]] && echo -e "\n$app_name\nMajor Release, update manually" && return +[[ "$diff_app" != "$diff_chart" && $update_apps == "true" ]] && echo -e "\n$app_name\nMajor Release, update manually" && return old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') From ad4b9b24617110c6903a483e63feb2a6d4ffe195 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 10:37:48 -0600 Subject: [PATCH 647/823] test ext service --- functions/update_apps.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2435b449..8d89fac5 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -8,6 +8,7 @@ echo -e "🅄 🄿 🄳 🄰 🅃 🄴 🅂" echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" +pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") it=0 while_count=0 @@ -76,6 +77,21 @@ if grep -qs "^$app_name," failed.txt ; then sed -i /"$app_name",/d failed.txt fi fi + + +[[ ! -e external_services ]] && touch external_services + +if ! grep -qs "^$app_name," external_services ; then + if ! grep qs "/external-service" /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/"$(find . -maxdepth 1 -type d -printf '%P\n' | sort -r | head -n 1)"/Chart.yaml ; then + echo "$app_name,false" >> external_services + else + echo "$app_name,true" >> external_services + fi +fi + + + + echo_array+=("\n$app_name") if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # Check to see if user is using -S or not [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") @@ -166,7 +182,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then old_status=$status before_loop=$(head -n 1 temp.txt) current_loop=0 - until [[ "$status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + until [[ "$status" != "$old_status" || $current_loop -gt 4 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') sleep 1 From d6f95fa76b3e4e3cf23ac8452029f7ffe570aaf2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 10:41:35 -0600 Subject: [PATCH 648/823] test --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 8d89fac5..7ca830fc 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -82,7 +82,7 @@ fi [[ ! -e external_services ]] && touch external_services if ! grep -qs "^$app_name," external_services ; then - if ! grep qs "/external-service" /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/"$(find . -maxdepth 1 -type d -printf '%P\n' | sort -r | head -n 1)"/Chart.yaml ; then + if ! grep qs "/external-service" /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/"$(find /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/ -maxdepth 1 -type d -printf '%P\n' | sort -r | head -n 1)"/Chart.yaml ; then echo "$app_name,false" >> external_services else echo "$app_name,true" >> external_services From be064a818b07fb6536b6fa015d6b1c5ee01548ec Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 10:49:47 -0600 Subject: [PATCH 649/823] if app is external services, do not post process --- functions/update_apps.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 7ca830fc..20beb654 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -78,7 +78,6 @@ if grep -qs "^$app_name," failed.txt ; then fi fi - [[ ! -e external_services ]] && touch external_services if ! grep -qs "^$app_name," external_services ; then @@ -111,7 +110,12 @@ else echo_array return fi -after_update_actions +if grep -qs "^$app_name,true" external_services ; then + echo_array + return +else + after_update_actions +fi } export -f pre_process From 0faeefa71d9a32ab00bd71dc43250967ecbe9357 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 10:52:31 -0600 Subject: [PATCH 650/823] while sleep to 5 --- functions/update_apps.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 20beb654..c977978f 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,7 +29,7 @@ do ((count++)) done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 3 + sleep 5 elif [[ $it -lt ${#array[@]} ]]; then # loop=0 # until [[ $loop -ge 2 || $it -ge ${#array[@]} ]]; @@ -40,7 +40,7 @@ do # ((loop++)) # done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish - sleep 3 + sleep 5 else # All processes must be completed, break out of loop break fi @@ -79,7 +79,6 @@ if grep -qs "^$app_name," failed.txt ; then fi [[ ! -e external_services ]] && touch external_services - if ! grep -qs "^$app_name," external_services ; then if ! grep qs "/external-service" /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/"$(find /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/ -maxdepth 1 -type d -printf '%P\n' | sort -r | head -n 1)"/Chart.yaml ; then echo "$app_name,false" >> external_services @@ -88,9 +87,6 @@ if ! grep -qs "^$app_name," external_services ; then fi fi - - - echo_array+=("\n$app_name") if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # Check to see if user is using -S or not [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") From 67c2f39f869c5ee83bf7c1a69de1c4070270a578 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 15:07:06 -0600 Subject: [PATCH 651/823] test deploying file --- functions/update_apps.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index c977978f..ae65f945 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -17,6 +17,15 @@ do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then ((while_count++)) [[ -z $while_status ]] && continue || echo -e "$while_count\n$while_status" > temp.txt + for i in "${while_status[@]}" + do + app_name=$(echo "$i" | awk -F ',' '{print $1}') + status=$(echo "$i" | awk -F ',' '{print $2}') + if [[ $status == "DEPLOYING" ]]; then + [[ ! -e deploying ]] && touch deploying + grep -qs "$app_name,DEPLOYING" deploying || echo "$app_name,DEPLOYING" >> deploying + fi + done else echo "Middlewared timed out. Consider setting a lower number for async applications" continue @@ -46,6 +55,7 @@ do fi done rm temp.txt +rm deploying echo echo @@ -176,8 +186,8 @@ count=0 if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do - status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') - if [[ $count -lt 1 && $status != "DEPLOYING" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. + status=$(grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + if [[ $count -lt 1 && $status != "DEPLOYING" && "$(grep "^$app_name," deploying | awk -F ',' '{print $2}')" != "DEPLOYING" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. [[ "$verbose" == "true" ]] && echo_array+=("Verifying $status..") old_status=$status before_loop=$(head -n 1 temp.txt) From e1e7c529533f1b556b834088d3255519f5022f29 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 15:12:35 -0600 Subject: [PATCH 652/823] change to an array --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ae65f945..2db0b3a1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,9 +14,9 @@ it=0 while_count=0 while true do - if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then + if mapfile -t while_status < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then ((while_count++)) - [[ -z $while_status ]] && continue || echo -e "$while_count\n$while_status" > temp.txt + [[ -z ${while_status[*]} ]] && continue || echo -e "$while_count\n${while_status[*]}" > temp.txt for i in "${while_status[@]}" do app_name=$(echo "$i" | awk -F ',' '{print $1}') From 978bf40d5a03da234e7120b74643afe97c2c5b31 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 15:26:50 -0600 Subject: [PATCH 653/823] new method of deploying check --- functions/update_apps.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2db0b3a1..563f1913 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,16 +14,16 @@ it=0 while_count=0 while true do - if mapfile -t while_status < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then + if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then ((while_count++)) - [[ -z ${while_status[*]} ]] && continue || echo -e "$while_count\n${while_status[*]}" > temp.txt - for i in "${while_status[@]}" + [[ -z $while_status ]] && continue || echo -e "$while_count\n$while_status" > temp.txt + mapfile -t deploying_check < <(grep ",DEPLOYING," temp.txt) + for i in "${deploying_check[@]}" do app_name=$(echo "$i" | awk -F ',' '{print $1}') - status=$(echo "$i" | awk -F ',' '{print $2}') - if [[ $status == "DEPLOYING" ]]; then - [[ ! -e deploying ]] && touch deploying - grep -qs "$app_name,DEPLOYING" deploying || echo "$app_name,DEPLOYING" >> deploying + [[ ! -e deploying ]] && touch deploying + if ! grep -qs "$app_name,DEPLOYING" deploying; then + echo "$app_name,DEPLOYING" >> deploying fi done else From e82fa5f8c250b69537cc06177a7436320a04a07a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 15:29:14 -0600 Subject: [PATCH 654/823] rm deploying prior to starting --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 563f1913..60deb582 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -12,6 +12,7 @@ pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{pri it=0 while_count=0 +rm deploying while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then From 80374b5ea99b5f9bd89202191aab779868ee5a54 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 15:41:50 -0600 Subject: [PATCH 655/823] sleep back down to 3 --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 60deb582..f2ee0ea8 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -39,7 +39,7 @@ do ((count++)) done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 5 + sleep 3 elif [[ $it -lt ${#array[@]} ]]; then # loop=0 # until [[ $loop -ge 2 || $it -ge ${#array[@]} ]]; @@ -50,7 +50,7 @@ do # ((loop++)) # done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish - sleep 5 + sleep 3 else # All processes must be completed, break out of loop break fi From 96be5786c98f5ba54250cdda997da54845eb9683 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 17:03:32 -0600 Subject: [PATCH 656/823] remove stopped, since ext ser is handled earlier --- functions/update_apps.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f2ee0ea8..c4fc546b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -12,7 +12,7 @@ pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{pri it=0 while_count=0 -rm deploying +rm deploying 2>/dev/null while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then @@ -55,8 +55,8 @@ do break fi done -rm temp.txt -rm deploying +rm temp.txt 2>/dev/null +rm deploying 2>/dev/null echo echo @@ -219,9 +219,6 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then echo_array+=("Active") break fi - elif [[ "$status" == "STOPPED" ]]; then - echo_array+=("Stopped") - break elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then if [[ $rollback == "true" ]]; then if [[ "$failed" != "true" ]]; then From dff4f7678f2d7e3fc03857699e436d337f976495 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 17:07:27 -0600 Subject: [PATCH 657/823] remove deploying requirement on timeout --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index c4fc546b..5f9d35a7 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -219,7 +219,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then echo_array+=("Active") break fi - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then + elif [[ "$SECONDS" -ge "$timeout" ]]; then if [[ $rollback == "true" ]]; then if [[ "$failed" != "true" ]]; then echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") From ce2725f289e23ff75ff656b1e7703b327f2eb29f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 17:12:19 -0600 Subject: [PATCH 658/823] only pull in "active" containers --- functions/update_apps.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 5f9d35a7..c5b52c20 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -188,12 +188,11 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do status=$(grep "^$app_name," temp.txt | awk -F ',' '{print $2}') - if [[ $count -lt 1 && $status != "DEPLOYING" && "$(grep "^$app_name," deploying | awk -F ',' '{print $2}')" != "DEPLOYING" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. + if [[ $count -lt 1 && $status == "ACTIVE" && "$(grep "^$app_name," deploying | awk -F ',' '{print $2}')" != "DEPLOYING" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. [[ "$verbose" == "true" ]] && echo_array+=("Verifying $status..") - old_status=$status before_loop=$(head -n 1 temp.txt) current_loop=0 - until [[ "$status" != "$old_status" || $current_loop -gt 4 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + until [[ "$status" != "ACTIVE" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') sleep 1 From deb99d0af40b302a34f45221c1d834438ea5ee62 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 17:32:44 -0600 Subject: [PATCH 659/823] change temp.txt to all_app_status --- functions/update_apps.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index c5b52c20..c6981e3a 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -17,8 +17,8 @@ while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then ((while_count++)) - [[ -z $while_status ]] && continue || echo -e "$while_count\n$while_status" > temp.txt - mapfile -t deploying_check < <(grep ",DEPLOYING," temp.txt) + [[ -z $while_status ]] && continue || echo -e "$while_count\n$while_status" > all_app_status + mapfile -t deploying_check < <(grep ",DEPLOYING," all_app_status) for i in "${deploying_check[@]}" do app_name=$(echo "$i" | awk -F ',' '{print $1}') @@ -55,7 +55,7 @@ do break fi done -rm temp.txt 2>/dev/null +rm all_app_status 2>/dev/null rm deploying 2>/dev/null echo echo @@ -131,18 +131,18 @@ update_app(){ current_loop=0 while true do - update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') + update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}') if [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then echo "Fail Trigger - Debugging" - before_loop=$(head -n 1 temp.txt) + before_loop=$(head -n 1 all_app_status) current_loop=0 - until [[ "$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}')" != "$update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + until [[ "$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}')" != "$update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do if [[ $current_loop -gt 2 ]]; then cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || return 1 # After waiting, attempt an update once more, if fails, return error code - elif ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then # The file has been updated, but nothing changed specifically for the app. - before_loop=$(head -n 1 temp.txt) + elif ! echo -e "$(head -n 1 all_app_status)" | grep -qs ^"$before_loop" ; then # The file has been updated, but nothing changed specifically for the app. + before_loop=$(head -n 1 all_app_status) ((current_loop++)) fi sleep 1 @@ -162,14 +162,14 @@ stop_app(){ count=0 while [[ "$status" != "STOPPED" ]] do - status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + status=$( grep "^$app_name," all_app_status | awk -F ',' '{print $2}') if [[ $count -gt 2 ]]; then # If failed to stop app 3 times, return failure to parent shell return 1 elif ! cli -c 'app chart_release scale release_name='\""$app_name"\"\ 'scale_options={"replica_count": 0}' &> /dev/null ; then echo "Fail Trigger Stop - Debugging" - before_loop=$(head -n 1 temp.txt) + before_loop=$(head -n 1 all_app_status) ((count++)) - until [[ $(head -n 1 temp.txt) != "$before_loop" ]] # Upon failure, wait for status update before continuing + until [[ $(head -n 1 all_app_status) != "$before_loop" ]] # Upon failure, wait for status update before continuing do sleep 1 done @@ -187,17 +187,17 @@ count=0 if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do - status=$(grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + status=$(grep "^$app_name," all_app_status | awk -F ',' '{print $2}') if [[ $count -lt 1 && $status == "ACTIVE" && "$(grep "^$app_name," deploying | awk -F ',' '{print $2}')" != "DEPLOYING" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. [[ "$verbose" == "true" ]] && echo_array+=("Verifying $status..") - before_loop=$(head -n 1 temp.txt) + before_loop=$(head -n 1 all_app_status) current_loop=0 until [[ "$status" != "ACTIVE" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do - status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + status=$( grep "^$app_name," all_app_status | awk -F ',' '{print $2}') sleep 1 - if ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then - before_loop=$(head -n 1 temp.txt) + if ! echo -e "$(head -n 1 all_app_status)" | grep -qs ^"$before_loop" ; then + before_loop=$(head -n 1 all_app_status) ((current_loop++)) fi done From 18cfd761e2244e22b1e3d4e44d01935a37035041 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 17:36:19 -0600 Subject: [PATCH 660/823] higher req loop for active verification --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index c6981e3a..dd1c51a1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -192,7 +192,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo_array+=("Verifying $status..") before_loop=$(head -n 1 all_app_status) current_loop=0 - until [[ "$status" != "ACTIVE" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + until [[ "$status" != "ACTIVE" || $current_loop -gt 4 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do status=$( grep "^$app_name," all_app_status | awk -F ',' '{print $2}') sleep 1 From 7375d73ab5e90b15e13594963ad3dada280b86b2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 14 Aug 2022 17:43:07 -0600 Subject: [PATCH 661/823] suppress error messages --- functions/update_apps.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index dd1c51a1..ea226f48 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -78,20 +78,20 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -if grep -qs "^$app_name," failed.txt ; then - failed_ver=$(grep "^$app_name," failed.txt | awk -F ',' '{print $2}') +if grep -qs "^$app_name," failed 2>/dev/null; then + failed_ver=$(grep "^$app_name," failed | awk -F ',' '{print $2}') if [[ "$failed_ver" == "$new_full_ver" ]] ; then echo -e "\n$app_name" echo -e "Skipping previously failed version:\n$new_full_ver" return 0 else - sed -i /"$app_name",/d failed.txt + sed -i /"$app_name",/d failed fi fi [[ ! -e external_services ]] && touch external_services if ! grep -qs "^$app_name," external_services ; then - if ! grep qs "/external-service" /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/"$(find /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/ -maxdepth 1 -type d -printf '%P\n' | sort -r | head -n 1)"/Chart.yaml ; then + if ! grep qs "/external-service" /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/"$(find /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/ -maxdepth 1 -type d -printf '%P\n' | sort -r | head -n 1)"/Chart.yaml 2>/dev/null; then echo "$app_name,false" >> external_services else echo "$app_name,true" >> external_services @@ -194,7 +194,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then current_loop=0 until [[ "$status" != "ACTIVE" || $current_loop -gt 4 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do - status=$( grep "^$app_name," all_app_status | awk -F ',' '{print $2}') + status=$(grep "^$app_name," all_app_status | awk -F ',' '{print $2}') sleep 1 if ! echo -e "$(head -n 1 all_app_status)" | grep -qs ^"$before_loop" ; then before_loop=$(head -n 1 all_app_status) @@ -227,7 +227,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then echo_array+=("Reverting update..") midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null || { echo_array+=("Error: Failed to rollback $app_name") ; break ; } [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions #run back after_update_actions function if the app was stopped prior to update - echo "$app_name,$new_full_ver" >> failed.txt + echo "$app_name,$new_full_ver" >> failed break else echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") From 9b998c85530f87a5bc5c07bf7202840d07723825 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 14 Aug 2022 17:47:56 -0600 Subject: [PATCH 662/823] suppress error message --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ea226f48..4ee33c95 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -188,7 +188,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do status=$(grep "^$app_name," all_app_status | awk -F ',' '{print $2}') - if [[ $count -lt 1 && $status == "ACTIVE" && "$(grep "^$app_name," deploying | awk -F ',' '{print $2}')" != "DEPLOYING" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. + if [[ $count -lt 1 && $status == "ACTIVE" && "$(grep "^$app_name," deploying 2>/dev/null | awk -F ',' '{print $2}')" != "DEPLOYING" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. [[ "$verbose" == "true" ]] && echo_array+=("Verifying $status..") before_loop=$(head -n 1 all_app_status) current_loop=0 From 2af51cf0495adb5f050c881e36d8dcfd1eeda6ac Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 16 Aug 2022 20:08:03 -0600 Subject: [PATCH 663/823] add cmd to container to help and --cmd --- functions/misc.sh | 1 + heavy_script.sh | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/functions/misc.sh b/functions/misc.sh index 050055d8..87278b4b 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -48,6 +48,7 @@ echo "--mount | Initiates mounting feature, choose between unmounting an echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset" echo "--delete-backup | Opens a menu to delete backups on your system" echo "--dns | list all of your applications DNS names and their web ports" +echo "--cmd | Open a shell for one of your applications" echo echo "Update Types" echo "------------" diff --git a/heavy_script.sh b/heavy_script.sh index 3b970e9f..afea3b3a 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -41,6 +41,9 @@ do dns) dns="true" ;; + cmd) + cmd="true" + ;; restore) restore="true" ;; @@ -136,6 +139,7 @@ done #Continue to call functions in specific order [[ "$self_update" == "true" ]] && self_update [[ "$help" == "true" ]] && help +[[ "$cmd" == "true" ]] && cmd_to_container [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit From 89bba86722e10cbb720ec0f70bd1d5411969db69 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 16 Aug 2022 20:17:19 -0600 Subject: [PATCH 664/823] Update Readme --- README.md | 45 ++++++++++++++++++++++++++------------------- heavy_script.sh | 2 +- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 7199c34e..154e2093 100644 --- a/README.md +++ b/README.md @@ -14,27 +14,34 @@
-## Arguments +## Update Arguments +| Flag | Example | Parameter | Description | +|--------------- |------------------------ |----------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| -U | -U
-U 5 | None or Integer | Update applications, ignoring major version changes
_Optionally, you can supply a number after the argument to update multiple applications at once_ | +| -u | -u
-u 5 | None or Integer | Update applications, do NOT update if there was a major version change
_Optionally, you can supply a number after the argument to update multiple applications at once_ | +| -b | -b 14 | Integer | Backup `ix-appliactions` dataset
_Creates backups up to the number you've chosen_ | +| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating
_List one application after another as shown in the example_ | +| -r | -r | None | Monitors applications after they update
If the app does not become "ACTIVE" after either:
The custom Timeout, or Default Timeout,
rollback the application. | +| -v | -v | None | Verbose Output
_Look at the bottom of this page for an example_ | +| -S | -S | None | Shutdown the application prior to updating it | +| -t | -t 150 | Integer | Set a custom timeout to be used with either:
`-m`
_Time the script will wait for application to be "STOPPED"_
or
`-(u\|U)`
_Time the script will wait for application to be either "STOPPED" or "ACTIVE"_ | +| -s | -s | None | Sync Catalogs prior to updating | +| -p | -p | None | Prune old/unused docker images | +| --self-update | --self-update | None | Updates HeavyScript prior to running any other commands | -| Flag | Example | Parameter | Description | -|----------------- |------------------------ |----------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| NULL | NULL | NULL | If you choose not to supply an option, it will open the menu for easier access to the utilities | -| --self-update | --self-update | None | Updates HeavyScript prior to running it
_You no longer need to git pull_ | -| --delete-backup | --delete-backup | None | Opens a menu to delete backups
_Useful if you need to delete old system backups or backups from other scripts_ | -| --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot | -| --mount | --mount | None | Initiates mounting feature
Choose between unmounting and mounting PVC data | -| --dns | --dns | None | list all of your applications DNS names and their web ports | -| -U | -U
-U 5 | None or Integer | Update applications, ignoring major version changes
_Optionally, you can supply a number after the argument to update multiple applications at once_ | -| -u | -u
-u 5 | None or Integer | Update applications, do NOT update if there was a major version change
_Optionally, you can supply a number after the argument to update multiple applications at once_ | -| -b | -b 10 | Integer | Backup `ix-appliactions` dataset
_Creates backups up to the number you've chosen_ | -| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating
_List one application after another as shown in the example_ | -| -r | -r | None | Monitors applications after they update
If the app does not become "ACTIVE" after either:
The custom Timeout, or Default Timeout,
rollback the application. | -| -v | -v | None | Verbose Output
_Look at the bottom of this page for an example_ | -| -S | -S | None | Shutdown the application prior to updating it | -| -t | -t 150 | Integer | Set a custom timeout to be used with either:
`-m`
_Time the script will wait for application to be "STOPPED"_
or
`-(u\|U)`
_Time the script will wait for application to be either "STOPPED" or "ACTIVE"_ | -| -s | -s | None | Sync Catalogs prior to updating | -| -p | -p | None | Prune old/unused docker images | +
+
+## Other Utilities +> All of these can ALSO be accessed with the HeavyScript menu, that you can access simply by not providing an argument `bash heavy_script.sh` + +| Flag | Example | Parameter | Description | +|----------------- |----------------- |----------- |---------------------------------------------------------------------------------------------- | +| --mount | --mount | None | Initiates mounting feature, choose between unmounting and mounting PVC data | +| --restore | --restore | None | Opens a menu to restore a heavy_script backup that was taken on your ix-applications dataset | +| --delete-backup | --delete-backup | None | Opens a menu to delete backups on your system | +| --dns | --dns | None | list all of your applications DNS names and their web ports | +| --cmd | --cmd | None | Open a shell for one of your applications |

diff --git a/heavy_script.sh b/heavy_script.sh index afea3b3a..fad37d0c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -139,7 +139,7 @@ done #Continue to call functions in specific order [[ "$self_update" == "true" ]] && self_update [[ "$help" == "true" ]] && help -[[ "$cmd" == "true" ]] && cmd_to_container +[[ "$cmd" == "true" ]] && cmd_to_container && exit [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit From b6e831deb8a5fa8350e7d6024353166b5774b576 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 16 Aug 2022 20:19:46 -0600 Subject: [PATCH 665/823] prep menu --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 154e2093..864b7e92 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,11 @@
+## The Menu + + +
+ ## Update Arguments | Flag | Example | Parameter | Description | |--------------- |------------------------ |----------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | From a326f41fc34d0399a1151687a5cc630cc92c39ec Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 17 Aug 2022 02:20:50 +0000 Subject: [PATCH 666/823] Picture for README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 864b7e92..e4c29048 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ ## The Menu +![image](https://user-images.githubusercontent.com/20793231/185020236-7b389499-8081-407d-b653-10dffd70de8c.png) +
From 7a23b178e0a830db73302beeb83874a6da261159 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 16 Aug 2022 20:23:26 -0600 Subject: [PATCH 667/823] update readme --- README.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 864b7e92..0ef62f6b 100644 --- a/README.md +++ b/README.md @@ -34,24 +34,8 @@ | -p | -p | None | Prune old/unused docker images | | --self-update | --self-update | None | Updates HeavyScript prior to running any other commands | -
-
-## Other Utilities -> All of these can ALSO be accessed with the HeavyScript menu, that you can access simply by not providing an argument `bash heavy_script.sh` - -| Flag | Example | Parameter | Description | -|----------------- |----------------- |----------- |---------------------------------------------------------------------------------------------- | -| --mount | --mount | None | Initiates mounting feature, choose between unmounting and mounting PVC data | -| --restore | --restore | None | Opens a menu to restore a heavy_script backup that was taken on your ix-applications dataset | -| --delete-backup | --delete-backup | None | Opens a menu to delete backups on your system | -| --dns | --dns | None | list all of your applications DNS names and their web ports | -| --cmd | --cmd | None | Open a shell for one of your applications | - -
-
- -### Examples +### Example #### Typical Cron Job ``` bash heavy_script.sh --self-update -b 10 -i portainer -i arch -i sonarr -i radarr -t 600 -rsp -u 5 @@ -75,6 +59,22 @@ bash heavy_script.sh --self-update -b 10 -i portainer -i arch -i sonarr -i radar > `--self-update` Will update the script prior to running anything else. +
+ +## Other Utilities +> All of these can ALSO be accessed with the HeavyScript menu, that you can access simply by not providing an argument `bash heavy_script.sh` + +| Flag | Example | Parameter | Description | +|----------------- |----------------- |----------- |---------------------------------------------------------------------------------------------- | +| --mount | --mount | None | Initiates mounting feature, choose between unmounting and mounting PVC data | +| --restore | --restore | None | Opens a menu to restore a heavy_script backup that was taken on your ix-applications dataset | +| --delete-backup | --delete-backup | None | Opens a menu to delete backups on your system | +| --dns | --dns | None | list all of your applications DNS names and their web ports | +| --cmd | --cmd | None | Open a shell for one of your applications | + +
+ +### Examples #### Mounting PVC Data ``` @@ -177,7 +177,7 @@ bash heavyscript.sh --self-update -b 10 -supr | Name | Value | Reason | |------------------------ |------------------------------------------------------------------------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `Description` | HeavyScript git pull and Update apps | This is up to you, put whatever you think is a good description in here | -| `Command` | `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh --self-update -b 10 -rsup` | This is the command you will be running on your schedule I personally use: `bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 10 -rsup` | +| `Command` | `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh --self-update -b 10 -rsp -u 10` | This is the command you will be running on your schedule I personally use: `bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 10 -rsp -u 10` | | `Run As User` | `root` | Running the script as `root` is REQUIRED. You cannot access all of the kubernetes functions without this user. | | `Schedule` | Up to you, I run mine everyday at `0400` | Again up to you | | `Hide Standard Output` | `False` or Unticked | I like to receive an email report of how the script ran, what apps updated etc. | From 3feb8d97ce55eeb9f22bf37039d3f6ed91c12395 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 16 Aug 2022 20:24:15 -0600 Subject: [PATCH 668/823] menu --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eda5b691..3b2b8060 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ ## The Menu ![image](https://user-images.githubusercontent.com/20793231/185020236-7b389499-8081-407d-b653-10dffd70de8c.png) - +> Access this with `bash heavy_script.sh`
From 00cc643fb50dfeacd9249707bf121c1f75af4010 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 16 Aug 2022 20:25:47 -0600 Subject: [PATCH 669/823] spacing in readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3b2b8060..baad07ea 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ ![image](https://user-images.githubusercontent.com/20793231/185020236-7b389499-8081-407d-b653-10dffd70de8c.png) > Access this with `bash heavy_script.sh` +

## Update Arguments @@ -60,7 +61,7 @@ bash heavy_script.sh --self-update -b 10 -i portainer -i arch -i sonarr -i radar > `--self-update` Will update the script prior to running anything else. - +

## Other Utilities @@ -74,7 +75,6 @@ bash heavy_script.sh --self-update -b 10 -i portainer -i arch -i sonarr -i radar | --dns | --dns | None | list all of your applications DNS names and their web ports | | --cmd | --cmd | None | Open a shell for one of your applications | -
### Examples #### Mounting PVC Data From 83785c184b1fd92dd4b4824ec72cdef4d4ae3b4f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 16 Aug 2022 20:27:11 -0600 Subject: [PATCH 670/823] rm personal cron, add --cmd --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index baad07ea..c084ee68 100644 --- a/README.md +++ b/README.md @@ -101,10 +101,10 @@ bash /mnt/tank/scripts/heavy_script/heavy_script.sh --delete-backup bash /mnt/tank/scripts/heavy_script/heavy_script.sh --dns ``` -#### My personal Cron Job +#### Open a Containers Shell ``` -bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 10 -rsp -u 10 +bash /mnt/speed/scripts/heavy_script/heavy_script.sh --cmd ```
From 1577082435de18d193024ec1a49428226497cb00 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 16 Aug 2022 20:36:13 -0600 Subject: [PATCH 671/823] exit menu and backup if no valid selection --- functions/menu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 79993400..5b86ca5f 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -14,7 +14,7 @@ echo "8) Update Applications" echo "9) Command to Container" echo echo "0) Exit" -read -rt 120 -p "Please select an option by number: " selection +read -rt 120 -p "Please select an option by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } case $selection in 0) @@ -30,7 +30,7 @@ case $selection in mount ;; 4) - read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups || echo "Failed to make a selection" + read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups || { echo -e "\nFailed to make a selection in time" ; exit; } backup="true" ;; 5) From 595957f1c408c1e090a475694792cc4e777b49d9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 18 Aug 2022 00:09:10 -0600 Subject: [PATCH 672/823] new test --- functions/cmd_to_container.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 35f045b6..25c405e2 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -2,7 +2,7 @@ cmd_to_container(){ -app_name=$(k3s kubectl get pods -A | awk '{print $1}' | sort -u | grep -v "system" | sed '1d' | sed 's/^[^-]*-//' | nl -s ") " | column -t) +app_name=$(k3s crictl pods -s ready --namespace ix | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//' | sed '1d' | awk '{print $4}' | sort -u | nl -s ") " | column -t) while true do clear -x @@ -23,8 +23,9 @@ do fi done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') +search=$(k3s crictl pods -s ready --namespace ix) +mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $1}') search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') -mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do if [[ $(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " | wc -l) -gt 1 ]]; then From d58b25c35582b0665c66ef30a80679e85457e34b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 18 Aug 2022 00:13:05 -0600 Subject: [PATCH 673/823] cut out ix --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 25c405e2..c1021a5c 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -22,7 +22,7 @@ do break fi done -app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') +app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}' | cut -c4-) search=$(k3s crictl pods -s ready --namespace ix) mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $1}') search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') From 0e14b8abbb4b5c7808846392297d8046c52f0d3b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 18 Aug 2022 00:14:12 -0600 Subject: [PATCH 674/823] add cut to app list instead --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index c1021a5c..88b5cfaf 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -2,7 +2,7 @@ cmd_to_container(){ -app_name=$(k3s crictl pods -s ready --namespace ix | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//' | sed '1d' | awk '{print $4}' | sort -u | nl -s ") " | column -t) +app_name=$(k3s crictl pods -s ready --namespace ix | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//' | sed '1d' | awk '{print $4}' | cut -c4- | sort -u | nl -s ") " | column -t) while true do clear -x @@ -22,7 +22,7 @@ do break fi done -app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}' | cut -c4-) +app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}' ) search=$(k3s crictl pods -s ready --namespace ix) mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $1}') search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') From 3fe9c91f28a0e3f4528fb17a17e48914f15e7c2e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 18 Aug 2022 00:17:17 -0600 Subject: [PATCH 675/823] ix-chart apps are now working --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 88b5cfaf..79361515 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -22,7 +22,7 @@ do break fi done -app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}' ) +app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl pods -s ready --namespace ix) mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $1}') search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') From 423800850d32744d0e0ee706f61a35398f9be14b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 18 Aug 2022 00:36:54 -0600 Subject: [PATCH 676/823] remove ugly spacing --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 4ee33c95..0f26acce 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -59,7 +59,6 @@ rm all_app_status 2>/dev/null rm deploying 2>/dev/null echo echo - } export -f commander @@ -158,6 +157,7 @@ done } export -f update_app + stop_app(){ count=0 while [[ "$status" != "STOPPED" ]] From 5c7737f2291684947bf0f82b87cf83e2f4eb8e06 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 18 Aug 2022 00:40:40 -0600 Subject: [PATCH 677/823] take out un-needed examples for readme --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c084ee68..ce8d669c 100644 --- a/README.md +++ b/README.md @@ -67,13 +67,13 @@ bash heavy_script.sh --self-update -b 10 -i portainer -i arch -i sonarr -i radar ## Other Utilities > All of these can ALSO be accessed with the HeavyScript menu, that you can access simply by not providing an argument `bash heavy_script.sh` -| Flag | Example | Parameter | Description | -|----------------- |----------------- |----------- |---------------------------------------------------------------------------------------------- | -| --mount | --mount | None | Initiates mounting feature, choose between unmounting and mounting PVC data | -| --restore | --restore | None | Opens a menu to restore a heavy_script backup that was taken on your ix-applications dataset | -| --delete-backup | --delete-backup | None | Opens a menu to delete backups on your system | -| --dns | --dns | None | list all of your applications DNS names and their web ports | -| --cmd | --cmd | None | Open a shell for one of your applications | +| Flag | Description | +|-----------------|----------------------------------------------------------------------------------------------| +| --mount | Initiates mounting feature, choose between unmounting and mounting PVC data | +| --restore | Opens a menu to restore a heavy_script backup that was taken on your ix-applications dataset | +| --delete-backup | Opens a menu to delete backups on your system | +| --dns | list all of your applications DNS names and their web ports | +| --cmd | Open a shell for one of your applications | ### Examples From beeae110568fcb81f9aae8545be45090c4bcb312 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 18 Aug 2022 14:41:51 -0600 Subject: [PATCH 678/823] remove search variable --- functions/cmd_to_container.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 79361515..dfbc5215 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -23,8 +23,7 @@ do fi done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') -search=$(k3s crictl pods -s ready --namespace ix) -mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $1}') +mapfile -t pod_id < <(k3s crictl pods -s ready --namespace ix | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $1}') search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') for pod in "${pod_id[@]}" do From 1db4c18d88bb92994c2becfe28cd5e3eeae44b0e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 18 Aug 2022 20:56:40 -0600 Subject: [PATCH 679/823] prepare for PR --- functions/self_update.sh | 2 +- functions/update_apps.sh | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index b7b3e884..26b2fd56 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -2,7 +2,7 @@ args=("$@") self_update() { -branch="ignore-file" +branch="main" git fetch &> /dev/null echo "🅂 🄴 🄻 🄵" echo "🅄 🄿 🄳 🄰 🅃 🄴" diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 0f26acce..a32dc4a9 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -133,7 +133,6 @@ do update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}') if [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then - echo "Fail Trigger - Debugging" before_loop=$(head -n 1 all_app_status) current_loop=0 until [[ "$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}')" != "$update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. @@ -166,7 +165,6 @@ do if [[ $count -gt 2 ]]; then # If failed to stop app 3 times, return failure to parent shell return 1 elif ! cli -c 'app chart_release scale release_name='\""$app_name"\"\ 'scale_options={"replica_count": 0}' &> /dev/null ; then - echo "Fail Trigger Stop - Debugging" before_loop=$(head -n 1 all_app_status) ((count++)) until [[ $(head -n 1 all_app_status) != "$before_loop" ]] # Upon failure, wait for status update before continuing From b35893247df8e0890aff3a77b79403f40e05ae01 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 19 Aug 2022 03:34:00 +0000 Subject: [PATCH 680/823] Update Readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ce8d669c..f9bb9fbe 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ [HeavySetup - Further In-Depth Explanation](https://heavysetup.info/scripts/heavyscript/about/) ## Table of contents: -* [Arguments](#arguments) -* [Examples](#examples) +* [Update Arguments](#update-arguments) +* [Other Utilities](#other-utilities) * [How to Install](#how-to-install) * [How to Update](#how-to-update) * [Creating a Cron Job](#creating-a-cron-job) @@ -157,7 +157,7 @@ git pull ```
-### Update with the scripts built-in option +### Built-In Option ``` bash heavyscript.sh --self-update -b 10 -supr From 583920162ce416a7f1d993b90fc9e80194fc4295 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 19 Aug 2022 03:36:04 +0000 Subject: [PATCH 681/823] Update Readme --- README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f9bb9fbe..49ded17b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Website -[HeavySetup - Further In-Depth Explanation](https://heavysetup.info/scripts/heavyscript/about/) +[HeavySetup - Further Explanation](https://heavysetup.info/scripts/heavyscript/about/) ## Table of contents: * [Update Arguments](#update-arguments) @@ -142,6 +142,15 @@ From here, you can just run Heavy_Script with `bash heavy_script.sh -ARGUMENTS` ## How to Update +### Built-In Option + +``` +bash heavyscript.sh --self-update -b 10 -supr +``` +> The important argument here is the `--self-update`, you can still use all of your same arguments with this option. + +
+ ### Manually #### Open a Terminal @@ -155,14 +164,6 @@ cd /mnt/speed/scripts/heavy_script ``` git pull ``` -
- -### Built-In Option - -``` -bash heavyscript.sh --self-update -b 10 -supr -``` -> The important argument here is the `--self-update`, you can still use all of your same arguments with this option.
From 0d49bd4c92216248b1f99eacd7c488a775b1f2ac Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 16:44:22 -0600 Subject: [PATCH 682/823] add additional checks before exiting --- functions/update_apps.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a32dc4a9..f8af02f6 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -13,6 +13,7 @@ pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{pri it=0 while_count=0 rm deploying 2>/dev/null +rm all_app_status 2>/dev/null while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then @@ -49,13 +50,12 @@ do ((it++)) # ((loop++)) # done - elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish + elif [[ $proc_count != 0 ]] || grep -qs ",DEPLOYING," all_app_status 2>/dev/null ; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop break fi done -rm all_app_status 2>/dev/null rm deploying 2>/dev/null echo echo @@ -230,14 +230,29 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then else echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") echo_array+=("The application failed to be ACTIVE even after a rollback") - echo_array+=("Manual intervention is required\nAbandoning") + echo_array+=("Manual intervention is required\nStopping, then Abandoning") + if stop_app ; then + echo_array+=("Stopped") + else + echo_array+=("Error: Failed to stop $app_name") + echo_array + return 1 + fi break fi else echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") echo_array+=("If this is a slow starting application, set a higher timeout with -t") echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration") - break + echo_array+=("Manual intervention is required\nStopping, then Abandoning") + if stop_app ; then + echo_array+=("Stopped") + else + echo_array+=("Error: Failed to stop $app_name") + echo_array + return 1 + fi + break fi else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") From fe8c9b05533a4b080f0e4741c2e992613e399fe5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 16:45:53 -0600 Subject: [PATCH 683/823] indention on break --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f8af02f6..5bd890b4 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -252,7 +252,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then echo_array return 1 fi - break + break fi else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") From 846ea6011eb6ec94cbedf8892cb7b1db99472e28 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 17:54:10 -0600 Subject: [PATCH 684/823] create finished file to track finished shells --- functions/update_apps.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 5bd890b4..d8e67390 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -13,7 +13,7 @@ pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{pri it=0 while_count=0 rm deploying 2>/dev/null -rm all_app_status 2>/dev/null +rm finished 2>/dev/null while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then @@ -50,13 +50,14 @@ do ((it++)) # ((loop++)) # done - elif [[ $proc_count != 0 ]] || grep -qs ",DEPLOYING," all_app_status 2>/dev/null ; then # Wait for all processes to finish + elif [[ $proc_count != 0 || $(wc -l finished 2>/dev/null | awk '{ print $1 }') -lt "${#array[@]}" ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop break fi done rm deploying 2>/dev/null +rm finished 2>/dev/null echo echo } @@ -65,7 +66,7 @@ export -f commander pre_process(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && final_check && return 0 #If application is on ignore list, skip old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version @@ -73,7 +74,7 @@ new_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{pr startstatus=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions -[[ "$diff_app" != "$diff_chart" && $update_apps == "true" ]] && echo -e "\n$app_name\nMajor Release, update manually" && return +[[ "$diff_app" != "$diff_chart" && $update_apps == "true" ]] && echo -e "\n$app_name\nMajor Release, update manually" && final_check && return old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') @@ -82,6 +83,7 @@ if grep -qs "^$app_name," failed 2>/dev/null; then if [[ "$failed_ver" == "$new_full_ver" ]] ; then echo -e "\n$app_name" echo -e "Skipping previously failed version:\n$new_full_ver" + final_check return 0 else sed -i /"$app_name",/d failed @@ -105,6 +107,7 @@ if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # C else echo_array+=("Error: Failed to stop $app_name") echo_array + final_check return 1 fi fi @@ -114,13 +117,16 @@ if update_app ;then else echo_array+=("Failed to update") echo_array + final_check return fi if grep -qs "^$app_name,true" external_services ; then echo_array + final_check return else after_update_actions + final_check fi } export -f pre_process @@ -275,3 +281,8 @@ done } export -f echo_array + +final_check(){ + [[ ! -e finished ]] && touch finished + echo "$app_name,finished" >> finished +} From 7af36bb1a402b1714dffe57d1eb71edb60f84e5a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 21:31:01 -0600 Subject: [PATCH 685/823] testing cmd-to-container --- functions/cmd_to_container.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index dfbc5215..3752d6c0 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,10 +27,10 @@ mapfile -t pod_id < <(k3s crictl pods -s ready --namespace ix | grep -E "[[:spac search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') for pod in "${pod_id[@]}" do - if [[ $(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " | wc -l) -gt 1 ]]; then - readarray -t containers <<<"$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" - continue - fi + # if [[ $(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " | wc -l) -gt 1 ]]; then + # readarray -t containers <<<"$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" + # continue + # fi printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") From 9696082cc8c2d935303b417f9da4244afbbd8c2d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 21:36:27 -0600 Subject: [PATCH 686/823] test array rebuild --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 3752d6c0..66c606ce 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -33,8 +33,8 @@ do # fi printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") - done +readarray -t containers <<<"${containers[@]}" case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From d518de6e67b1aef1daf16165d5e1c9b536c0efa0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 21:37:56 -0600 Subject: [PATCH 687/823] change from var to array --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 66c606ce..0491dd3a 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -32,9 +32,9 @@ do # continue # fi printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") + containers+="$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" done -readarray -t containers <<<"${containers[@]}" +readarray -t containers <<<"$containers" case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From a0037cb4d095312f9387ae37aa9ac82e0025c89a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 21:43:01 -0600 Subject: [PATCH 688/823] read IFS --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 0491dd3a..b9bae6cc 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -34,7 +34,7 @@ do printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue containers+="$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" done -readarray -t containers <<<"$containers" +IFS=" " read -r -a containers <<< "$containers" case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From 389e0fbcd05fd86673c809122ef007e70270cffc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 21:50:59 -0600 Subject: [PATCH 689/823] readarray --- functions/cmd_to_container.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index b9bae6cc..1429b9fc 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -34,7 +34,8 @@ do printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue containers+="$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" done -IFS=" " read -r -a containers <<< "$containers" +readarray -t containers <<<"$containers" + case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From ba17b0dd136310601d4e31c1d2966410e6c2fcca Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 21:51:57 -0600 Subject: [PATCH 690/823] trying to rebuild array --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 1429b9fc..4db51b53 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -32,9 +32,9 @@ do # continue # fi printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - containers+="$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done -readarray -t containers <<<"$containers" +readarray -t containers <<<"${containers[*]}" case "${#containers[@]}" in 0) From bc9fed707e67653ee55a84de7390d2784a4a53d5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 21:58:24 -0600 Subject: [PATCH 691/823] rebuild array --- functions/cmd_to_container.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 4db51b53..c05228ba 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -34,8 +34,7 @@ do printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done -readarray -t containers <<<"${containers[*]}" - +readarray -td, containers <<<"${containers[@]}"; declare -p containers; case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From 0b786c3ef263412e60328a2019e60da66c16853f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:01:08 -0600 Subject: [PATCH 692/823] make only var --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index c05228ba..1ed5bd2d 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -32,9 +32,9 @@ do # continue # fi printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") + containers+="$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" done -readarray -td, containers <<<"${containers[@]}"; declare -p containers; +readarray -td, containers <<<"$containers"; declare -p containers; case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From 354e132d8fd7d50558709cb0288f7763fe5ade9f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:04:42 -0600 Subject: [PATCH 693/823] array rebuild --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 1ed5bd2d..cfdc13a8 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -32,9 +32,9 @@ do # continue # fi printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - containers+="$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done -readarray -td, containers <<<"$containers"; declare -p containers; +containers=("${containers[@]}") case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From 0aee51e7120e4ee25dc6be78cf66f2742955535d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:07:59 -0600 Subject: [PATCH 694/823] test --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index cfdc13a8..0ef71f46 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -34,7 +34,7 @@ do printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done -containers=("${containers[@]}") +containers=$("$("${containers[@]}")") case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From 4ed623d0ab29bfdce4c2c30710958d6b3816f214 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:10:49 -0600 Subject: [PATCH 695/823] mapfile --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 0ef71f46..ed18e75e 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -34,7 +34,7 @@ do printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done -containers=$("$("${containers[@]}")") +mapfile -t containers < <("${containers[@]}") case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From 8b60029b375d63879e3b29be2970c9b862f11d2a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:11:35 -0600 Subject: [PATCH 696/823] echo containers --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index ed18e75e..af0eaf7f 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -34,7 +34,7 @@ do printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done -mapfile -t containers < <("${containers[@]}") +mapfile -t containers < <("echo ${containers[*]}") case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From 3cacd0bb80e277be3b79d953e90a3036daebff83 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:12:13 -0600 Subject: [PATCH 697/823] quotations --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index af0eaf7f..84cb7291 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -34,7 +34,7 @@ do printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done -mapfile -t containers < <("echo ${containers[*]}") +mapfile -t containers < <(echo "${containers[*]}") case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From 61bf2efe8509b46d3c3fcbaed05a2fcb2e726c8e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:13:09 -0600 Subject: [PATCH 698/823] echo array for testting --- functions/cmd_to_container.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 84cb7291..bde8c2e9 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -35,6 +35,10 @@ do containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done mapfile -t containers < <(echo "${containers[*]}") +for i in "${containers[@]}" +do + echo "$i" +done case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From 509ee9054326e55af272d93d537d059271c6639f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:14:48 -0600 Subject: [PATCH 699/823] print array elements --- functions/cmd_to_container.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index bde8c2e9..2541e095 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -39,6 +39,7 @@ for i in "${containers[@]}" do echo "$i" done +printf '%s\n' "${containers[@]}" case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From ec37299970a7c763ea1c265a2b3cec719a2591ce Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:16:28 -0600 Subject: [PATCH 700/823] space in print output --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 2541e095..f3b97e6c 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -39,7 +39,7 @@ for i in "${containers[@]}" do echo "$i" done -printf '%s\n' "${containers[@]}" +printf '%s \n' "${containers[@]}" case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From cc43fb198374f682359fc23a683067aade233b52 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:21:17 -0600 Subject: [PATCH 701/823] change to newline with sed --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index f3b97e6c..d4a1d79e 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -32,7 +32,7 @@ do # continue # fi printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | sed 's/ /\n//')") done mapfile -t containers < <(echo "${containers[*]}") for i in "${containers[@]}" From ed96807938053d0ccb1b0a8aa45276f3e48448af Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:26:06 -0600 Subject: [PATCH 702/823] try using a file --- functions/cmd_to_container.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index d4a1d79e..19e4a7a3 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -31,15 +31,12 @@ do # readarray -t containers <<<"$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" # continue # fi - printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | sed 's/ /\n//')") + # printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue + "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" >> containers done -mapfile -t containers < <(echo "${containers[*]}") -for i in "${containers[@]}" -do - echo "$i" -done -printf '%s \n' "${containers[@]}" + +cat containers + case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From 7907af24ba2ee2178fbc2b59d318d273a74043dd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:26:51 -0600 Subject: [PATCH 703/823] dont supress output --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 19e4a7a3..f0745b97 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -32,7 +32,7 @@ do # continue # fi # printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" >> containers + echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " >> containers done cat containers From 7615f645543c61c1d0ccec626ca08891493d981d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:28:37 -0600 Subject: [PATCH 704/823] try file --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index f0745b97..df336f63 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -32,10 +32,10 @@ do # continue # fi # printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " >> containers + echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " >> cont_file done -cat containers +mapfile -t containers < cont_file case "${#containers[@]}" in 0) From 765a56a04883f930654593824b5d10cb9b0c48e8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:31:21 -0600 Subject: [PATCH 705/823] rm file and sort --- functions/cmd_to_container.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index df336f63..dbb7d76b 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -22,6 +22,7 @@ do break fi done +rm cont_file 2> /dev/null app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') mapfile -t pod_id < <(k3s crictl pods -s ready --namespace ix | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $1}') search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') @@ -34,9 +35,8 @@ do # printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " >> cont_file done - -mapfile -t containers < cont_file - +mapfile -t containers < "$(sort -u cont_file)" +rm cont_file 2> /dev/null case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From ffd0d1aaeb90f5a2e9baf61d5a8565fcf0a06a4e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:32:38 -0600 Subject: [PATCH 706/823] sort and clean --- functions/cmd_to_container.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index dbb7d76b..b8724a66 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -35,7 +35,8 @@ do # printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " >> cont_file done -mapfile -t containers < "$(sort -u cont_file)" +clean_list=$(sort -u cont_file) +mapfile -t containers < "$clean_list" rm cont_file 2> /dev/null case "${#containers[@]}" in 0) From fe7604130318c5ca6e57c47d8bd85fa5cc83de10 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:33:46 -0600 Subject: [PATCH 707/823] proper redirection --- functions/cmd_to_container.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index b8724a66..2adeba8f 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -35,8 +35,7 @@ do # printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " >> cont_file done -clean_list=$(sort -u cont_file) -mapfile -t containers < "$clean_list" +mapfile -t containers < <(sort -u cont_file) rm cont_file 2> /dev/null case "${#containers[@]}" in 0) From d930c734f733f46cd9f5b59e78fb6dae2bdcde98 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:36:24 -0600 Subject: [PATCH 708/823] remove error message on STOPPED application --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 2adeba8f..09f2ee55 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -35,7 +35,7 @@ do # printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " >> cont_file done -mapfile -t containers < <(sort -u cont_file) +mapfile -t containers < <(sort -u cont_file 2> /dev/null) rm cont_file 2> /dev/null case "${#containers[@]}" in 0) From 25cbd91818b52789e063a245be7deb9c03accb9d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:44:55 -0600 Subject: [PATCH 709/823] also grep pod for addon containers --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 09f2ee55..cda66710 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -74,7 +74,7 @@ case "${#containers[@]}" in fi done container=$(echo "$cont_search" | grep ^"$selection)" | awk '{print $2}') - container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | grep "${pod_id[0]}" | awk '{print $1}') ;; esac while true From fe8abe8938868c50b50198abb62c07d9add7f84d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:48:03 -0600 Subject: [PATCH 710/823] revert. looking for better solution --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index cda66710..09f2ee55 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -74,7 +74,7 @@ case "${#containers[@]}" in fi done container=$(echo "$cont_search" | grep ^"$selection)" | awk '{print $2}') - container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | grep "${pod_id[0]}" | awk '{print $1}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') ;; esac while true From 58a72fafb3d0d7e1c1e196b90c7a2605e22a6c3c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:58:29 -0600 Subject: [PATCH 711/823] testing output for new file --- functions/cmd_to_container.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 09f2ee55..e68fb3b2 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -28,15 +28,10 @@ mapfile -t pod_id < <(k3s crictl pods -s ready --namespace ix | grep -E "[[:spac search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') for pod in "${pod_id[@]}" do - # if [[ $(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " | wc -l) -gt 1 ]]; then - # readarray -t containers <<<"$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" - # continue - # fi - # printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " >> cont_file + echo "$search" | grep "$pod" | tr -d " \t\r " >> cont_file done mapfile -t containers < <(sort -u cont_file 2> /dev/null) -rm cont_file 2> /dev/null +# rm cont_file 2> /dev/null case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" @@ -46,7 +41,6 @@ case "${#containers[@]}" in container=$(echo "$search" | grep "${pod_id[0]}" | awk '{print $4}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') ;; - *) while true do From 6e6bfe7bf844b632b7939338cabfc38acb1ecec5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 22:59:29 -0600 Subject: [PATCH 712/823] rm tr --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index e68fb3b2..4c6bc98e 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -28,7 +28,7 @@ mapfile -t pod_id < <(k3s crictl pods -s ready --namespace ix | grep -E "[[:spac search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') for pod in "${pod_id[@]}" do - echo "$search" | grep "$pod" | tr -d " \t\r " >> cont_file + echo "$search" | grep "$pod" >> cont_file done mapfile -t containers < <(sort -u cont_file 2> /dev/null) # rm cont_file 2> /dev/null From 9af91e1e51d36c6d6e5d6b7f7276454a4eb601fc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 23:02:12 -0600 Subject: [PATCH 713/823] grep from file --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 4c6bc98e..f2d3bc73 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -38,8 +38,8 @@ case "${#containers[@]}" in exit ;; 1) - container=$(echo "$search" | grep "${pod_id[0]}" | awk '{print $4}') - container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') + container=$(grep "${pod_id[0]}" cont_file | awk '{print $4}') + container_id=$(grep -E "[[:space:]]${container}[[:space:]]" cont_file | awk '{print $1}') ;; *) while true From 2dfd8b01ab3c89f481bd8e9ea98b6a74712b7618 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 23:04:03 -0600 Subject: [PATCH 714/823] print name --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index f2d3bc73..88e395a9 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -49,7 +49,7 @@ case "${#containers[@]}" in cont_search=$( for i in "${containers[@]}" do - echo "$i" + echo "$i | awk '{print $4}'" done | nl -s ") " | column -t ) echo "$cont_search" From b5c3bdaf0db3b7fe2d88726fd5a2c91b71419f82 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 23:04:40 -0600 Subject: [PATCH 715/823] undo literal awk lol --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 88e395a9..3a6af823 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -49,7 +49,7 @@ case "${#containers[@]}" in cont_search=$( for i in "${containers[@]}" do - echo "$i | awk '{print $4}'" + echo "$i" | awk '{print $4}' done | nl -s ") " | column -t ) echo "$cont_search" From 518f7fa0d1806a99554bcaf585085c36b83c1c29 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 23:05:46 -0600 Subject: [PATCH 716/823] rm file once func is done --- functions/cmd_to_container.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 3a6af823..e40a1175 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -31,7 +31,6 @@ do echo "$search" | grep "$pod" >> cont_file done mapfile -t containers < <(sort -u cont_file 2> /dev/null) -# rm cont_file 2> /dev/null case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" @@ -109,6 +108,6 @@ do ;; esac done - +rm cont_file 2> /dev/null } export -f cmd_to_container \ No newline at end of file From 58e7765794772eea5e9ff668c36b35d33a5df80c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 21 Aug 2022 23:12:32 -0600 Subject: [PATCH 717/823] fix container_id var --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index e40a1175..72f79990 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -67,7 +67,7 @@ case "${#containers[@]}" in fi done container=$(echo "$cont_search" | grep ^"$selection)" | awk '{print $2}') - container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') + container_id=$(grep -E "[[:space:]]${container}[[:space:]]" cont_file | awk '{print $1}') ;; esac while true From 178079a39fee5fcce8b6ecc34ef6a99663421890 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 12:02:41 -0600 Subject: [PATCH 718/823] test title release and SU releases --- functions/misc.sh | 1 + functions/self_update.sh | 4 +++- heavy_script.sh | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/functions/misc.sh b/functions/misc.sh index 87278b4b..33b4d4c0 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -31,6 +31,7 @@ echo '| | | | __/ (_| |\ V /| |_| /\__/ / (__| | | | |_) | |_ ' echo '\_| |_/\___|\__,_| \_/ \__, \____/ \___|_| |_| .__/ \__|' echo ' __/ | | | ' echo ' |___/ |_| ' +echo "$hs_version" echo } export -f title diff --git a/functions/self_update.sh b/functions/self_update.sh index 26b2fd56..5df34f34 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -16,6 +16,7 @@ if git diff --name-only origin/$branch | grep -qs ".sh" ; then [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done + curl --silent "https://api.github.com/repos/HeavyBullets8/heavy_script/releases/latest" | jq -r .tag_name,.body [[ -z ${args[*]} ]] && echo -e "No more arguments, exiting..\n\n" && exit echo -e "Running the new version...\n\n" sleep 5 @@ -23,7 +24,8 @@ if git diff --name-only origin/$branch | grep -qs ".sh" ; then # Now exit this old instance exit else - echo -e "HeavyScript is already the latest version\n\n" + echo -e "HeavyScript is already the latest version:\n\n" + echo "$hs_version" fi } export -f self_update diff --git a/heavy_script.sh b/heavy_script.sh index fad37d0c..b8878186 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,5 +1,7 @@ #!/bin/bash +#Version +hs_version=$(curl --silent "https://api.github.com/repos/HeavyBullets8/heavy_script/releases/latest" | jq -r .tag_name) # cd to script, this ensures the script can find the source scripts below, even when ran from a seperate directory script=$(readlink -f "$0") From 3154177dd77148ca0962ac155b5dce2a5db4cfdc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 12:04:48 -0600 Subject: [PATCH 719/823] place version in title one line up --- functions/misc.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index 33b4d4c0..fee14883 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -30,8 +30,7 @@ echo "| _ |/ _ \/ _\` \ \ / / | | |\`--. \/ __| '__| | '_ \| __|" echo '| | | | __/ (_| |\ V /| |_| /\__/ / (__| | | | |_) | |_ ' echo '\_| |_/\___|\__,_| \_/ \__, \____/ \___|_| |_| .__/ \__|' echo ' __/ | | | ' -echo ' |___/ |_| ' -echo "$hs_version" +echo "$hs_version |___/ |_| " echo } export -f title From d3c875353d49662827c18e3c974e78f7827c83a3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 12:05:31 -0600 Subject: [PATCH 720/823] add spaces --- functions/misc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/misc.sh b/functions/misc.sh index fee14883..ee68ad7c 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -30,7 +30,7 @@ echo "| _ |/ _ \/ _\` \ \ / / | | |\`--. \/ __| '__| | '_ \| __|" echo '| | | | __/ (_| |\ V /| |_| /\__/ / (__| | | | |_) | |_ ' echo '\_| |_/\___|\__,_| \_/ \__, \____/ \___|_| |_| .__/ \__|' echo ' __/ | | | ' -echo "$hs_version |___/ |_| " +echo "$hs_version |___/ |_| " echo } export -f title From 202af8f147182d70dbd752eba6e6ac8bd0335c18 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 12:05:52 -0600 Subject: [PATCH 721/823] added one too many spaces --- functions/misc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/misc.sh b/functions/misc.sh index ee68ad7c..8b4aa6b3 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -30,7 +30,7 @@ echo "| _ |/ _ \/ _\` \ \ / / | | |\`--. \/ __| '__| | '_ \| __|" echo '| | | | __/ (_| |\ V /| |_| /\__/ / (__| | | | |_) | |_ ' echo '\_| |_/\___|\__,_| \_/ \__, \____/ \___|_| |_| .__/ \__|' echo ' __/ | | | ' -echo "$hs_version |___/ |_| " +echo "$hs_version |___/ |_| " echo } export -f title From a37a734910cadd0fdb28dd52df290b0990c494a0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 12:07:37 -0600 Subject: [PATCH 722/823] revert, place version under title, not in it --- functions/misc.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/misc.sh b/functions/misc.sh index 8b4aa6b3..33b4d4c0 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -30,7 +30,8 @@ echo "| _ |/ _ \/ _\` \ \ / / | | |\`--. \/ __| '__| | '_ \| __|" echo '| | | | __/ (_| |\ V /| |_| /\__/ / (__| | | | |_) | |_ ' echo '\_| |_/\___|\__,_| \_/ \__, \____/ \___|_| |_| .__/ \__|' echo ' __/ | | | ' -echo "$hs_version |___/ |_| " +echo ' |___/ |_| ' +echo "$hs_version" echo } export -f title From 3a8eabd57938f526924d07fc061bb05ef15b1400 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 12:10:53 -0600 Subject: [PATCH 723/823] include changelog in self_update --- functions/self_update.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 5df34f34..44e07454 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -16,6 +16,9 @@ if git diff --name-only origin/$branch | grep -qs ".sh" ; then [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done + echo "Updating from:" + echo "$hs_version" + echo "Updating To:" curl --silent "https://api.github.com/repos/HeavyBullets8/heavy_script/releases/latest" | jq -r .tag_name,.body [[ -z ${args[*]} ]] && echo -e "No more arguments, exiting..\n\n" && exit echo -e "Running the new version...\n\n" @@ -24,8 +27,8 @@ if git diff --name-only origin/$branch | grep -qs ".sh" ; then # Now exit this old instance exit else - echo -e "HeavyScript is already the latest version:\n\n" - echo "$hs_version" + echo "HeavyScript is already the latest version:" + echo -e "$hs_version\n\n" fi } export -f self_update From 9e0e40c12257079197877eef560af943850c245f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 12:37:16 -0600 Subject: [PATCH 724/823] self update tag release updates --- functions/self_update.sh | 7 ++++--- heavy_script.sh | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 44e07454..6aab3597 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -2,14 +2,15 @@ args=("$@") self_update() { -branch="main" + +latest_ver=$(git describe --tags "$(git rev-list --tags --max-count=1)") git fetch &> /dev/null echo "🅂 🄴 🄻 🄵" echo "🅄 🄿 🄳 🄰 🅃 🄴" -if git diff --name-only origin/$branch | grep -qs ".sh" ; then +if [[ "$hs_version" != "$latest_ver" ]] ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q - git pull --force -q + git checkout "$(latest_ver)" count=0 for i in "${args[@]}" do diff --git a/heavy_script.sh b/heavy_script.sh index b8878186..f772cb6d 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,7 +1,7 @@ #!/bin/bash #Version -hs_version=$(curl --silent "https://api.github.com/repos/HeavyBullets8/heavy_script/releases/latest" | jq -r .tag_name) +hs_version=$(git describe --tags) # cd to script, this ensures the script can find the source scripts below, even when ran from a seperate directory script=$(readlink -f "$0") From 1595d1963fe57a0b344199e4aa4357b89747de64 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 12:42:02 -0600 Subject: [PATCH 725/823] fix latestver --- functions/self_update.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 6aab3597..47f29854 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -9,8 +9,7 @@ echo "🅂 🄴 🄻 🄵" echo "🅄 🄿 🄳 🄰 🅃 🄴" if [[ "$hs_version" != "$latest_ver" ]] ; then echo "Found a new version of HeavyScript, updating myself..." - git reset --hard -q - git checkout "$(latest_ver)" + git checkout "($latest_ver)" count=0 for i in "${args[@]}" do From 66f4a3bdd1eb034d26bda7bb6445b61e97e8ae0c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 12:51:33 -0600 Subject: [PATCH 726/823] null change to push rl --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 47f29854..268cc21e 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -31,4 +31,4 @@ else echo -e "$hs_version\n\n" fi } -export -f self_update +export -f self_update \ No newline at end of file From b2e8274eab5aa865c24c333af2de06b562a85e88 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 12:53:19 -0600 Subject: [PATCH 727/823] git fetch tags --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 268cc21e..0e32e23a 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -4,7 +4,7 @@ args=("$@") self_update() { latest_ver=$(git describe --tags "$(git rev-list --tags --max-count=1)") -git fetch &> /dev/null +git fetch --tags &> /dev/null echo "🅂 🄴 🄻 🄵" echo "🅄 🄿 🄳 🄰 🅃 🄴" if [[ "$hs_version" != "$latest_ver" ]] ; then From 6fe076243431a87c332493652141fe8f53c622c6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 12:56:01 -0600 Subject: [PATCH 728/823] remove parenthesis in latestver --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 0e32e23a..8da4cc08 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -9,7 +9,7 @@ echo "🅂 🄴 🄻 🄵" echo "🅄 🄿 🄳 🄰 🅃 🄴" if [[ "$hs_version" != "$latest_ver" ]] ; then echo "Found a new version of HeavyScript, updating myself..." - git checkout "($latest_ver)" + git checkout "$latest_ver" count=0 for i in "${args[@]}" do From c4d52143506eac209515ba08a1fb1d373658344e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 12:58:51 -0600 Subject: [PATCH 729/823] null change for testing --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 8da4cc08..5f47e090 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -31,4 +31,4 @@ else echo -e "$hs_version\n\n" fi } -export -f self_update \ No newline at end of file +export -f self_update From cd836ba537a77d81f9a7813112c72b476f40acff Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 13:02:09 -0600 Subject: [PATCH 730/823] Formatting, only pull CL in curl --- functions/self_update.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 5f47e090..a6ff8064 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -4,22 +4,22 @@ args=("$@") self_update() { latest_ver=$(git describe --tags "$(git rev-list --tags --max-count=1)") -git fetch --tags &> /dev/null +git fetch --tags &>/dev/null echo "🅂 🄴 🄻 🄵" echo "🅄 🄿 🄳 🄰 🅃 🄴" if [[ "$hs_version" != "$latest_ver" ]] ; then echo "Found a new version of HeavyScript, updating myself..." - git checkout "$latest_ver" + git checkout "$latest_ver" &>/dev/null count=0 for i in "${args[@]}" do [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done - echo "Updating from:" - echo "$hs_version" - echo "Updating To:" - curl --silent "https://api.github.com/repos/HeavyBullets8/heavy_script/releases/latest" | jq -r .tag_name,.body + echo "Updating from: $hs_version" + echo "Updating To: $latest_ver" + echo "Changelog:" + curl --silent "https://api.github.com/repos/HeavyBullets8/heavy_script/releases/latest" | jq -r .body [[ -z ${args[*]} ]] && echo -e "No more arguments, exiting..\n\n" && exit echo -e "Running the new version...\n\n" sleep 5 From 910cde158c9b107531a266094d6227c63d75b42b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 13:04:10 -0600 Subject: [PATCH 731/823] add echo after changelog --- functions/self_update.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/self_update.sh b/functions/self_update.sh index a6ff8064..c38a46bc 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -20,6 +20,7 @@ if [[ "$hs_version" != "$latest_ver" ]] ; then echo "Updating To: $latest_ver" echo "Changelog:" curl --silent "https://api.github.com/repos/HeavyBullets8/heavy_script/releases/latest" | jq -r .body + echo [[ -z ${args[*]} ]] && echo -e "No more arguments, exiting..\n\n" && exit echo -e "Running the new version...\n\n" sleep 5 From 3d8fafb75ee3a9d5f8a7f317c226725eab4efbd8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 13:05:28 -0600 Subject: [PATCH 732/823] fetch before checking for new tags.. --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index c38a46bc..058f0640 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -3,8 +3,8 @@ args=("$@") self_update() { -latest_ver=$(git describe --tags "$(git rev-list --tags --max-count=1)") git fetch --tags &>/dev/null +latest_ver=$(git describe --tags "$(git rev-list --tags --max-count=1)") echo "🅂 🄴 🄻 🄵" echo "🅄 🄿 🄳 🄰 🅃 🄴" if [[ "$hs_version" != "$latest_ver" ]] ; then From cf01ae51b48786ff2ffa36f0f012da57bb3cafcb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 13:07:10 -0600 Subject: [PATCH 733/823] Null change for testing --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 058f0640..9c60d2b5 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -32,4 +32,4 @@ else echo -e "$hs_version\n\n" fi } -export -f self_update +export -f self_update \ No newline at end of file From c745c88f954d06e8df8da950fc0ace4f79dcb02d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 23 Aug 2022 16:08:08 -0600 Subject: [PATCH 734/823] update failed update message --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d8e67390..ceb35166 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -115,7 +115,7 @@ fi if update_app ;then echo_array+=("Updated\n$old_full_ver\n$new_full_ver") else - echo_array+=("Failed to update") + echo_array+=("Failed to update\nManual intervention may be required") echo_array final_check return From 46facda1f8c66ccf336ea46d32f709da9e98074e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 24 Aug 2022 05:09:59 -0600 Subject: [PATCH 735/823] fix external service check --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ceb35166..7b8fc969 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,7 +9,7 @@ echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - +rm external_services 2> /dev/null/ # TODO remove later it=0 while_count=0 rm deploying 2>/dev/null @@ -92,7 +92,7 @@ fi [[ ! -e external_services ]] && touch external_services if ! grep -qs "^$app_name," external_services ; then - if ! grep qs "/external-service" /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/"$(find /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/ -maxdepth 1 -type d -printf '%P\n' | sort -r | head -n 1)"/Chart.yaml 2>/dev/null; then + if ! grep -qs "/external-service" /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/"$(find /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/ -maxdepth 1 -type d -printf '%P\n' | sort -r | head -n 1)"/Chart.yaml; then echo "$app_name,false" >> external_services else echo "$app_name,true" >> external_services From 1c9917c9e7978bc977240eff4427a3dada1c820e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 24 Aug 2022 05:15:21 -0600 Subject: [PATCH 736/823] fix space after rm ext services --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 7b8fc969..73660172 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,7 +9,7 @@ echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") -rm external_services 2> /dev/null/ # TODO remove later +rm external_services 2>/dev/null/ # TODO remove later it=0 while_count=0 rm deploying 2>/dev/null From 4f83c3b59926c4ae28062e4269bcb1e93743b57f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 24 Aug 2022 05:21:43 -0600 Subject: [PATCH 737/823] remove trailing line on devnull --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 73660172..8a0c353f 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,7 +9,7 @@ echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") -rm external_services 2>/dev/null/ # TODO remove later +rm external_services 2>/dev/null # TODO remove later it=0 while_count=0 rm deploying 2>/dev/null From d229f2afb568731276d39aa33da7ffce33f3db22 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 24 Aug 2022 05:43:04 -0600 Subject: [PATCH 738/823] place ver check after cd --- heavy_script.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index f772cb6d..f9db3b84 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,14 +1,13 @@ #!/bin/bash -#Version -hs_version=$(git describe --tags) - # cd to script, this ensures the script can find the source scripts below, even when ran from a seperate directory script=$(readlink -f "$0") script_path=$(dirname "$script") script_name="heavy_script.sh" cd "$script_path" || { echo "Error: Failed to change to script directory" ; exit ; } +#Version +hs_version=$(git describe --tags) source functions/backup.sh source functions/dns.sh From def11937b8a8e8b372783336ec57f5e2cf840961 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 24 Aug 2022 15:51:19 -0600 Subject: [PATCH 739/823] improve rollback logic --- functions/update_apps.sh | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 8a0c353f..a72f54d9 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -192,7 +192,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do status=$(grep "^$app_name," all_app_status | awk -F ',' '{print $2}') - if [[ $count -lt 1 && $status == "ACTIVE" && "$(grep "^$app_name," deploying 2>/dev/null | awk -F ',' '{print $2}')" != "DEPLOYING" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. + if [[ $count -lt 1 && $status == "ACTIVE" && "$(grep "^$app_name," deploying 2>/dev/null | awk -F ',' '{print $2}')" != "DEPLOYING" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. [[ "$verbose" == "true" ]] && echo_array+=("Verifying $status..") before_loop=$(head -n 1 all_app_status) current_loop=0 @@ -229,10 +229,18 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then echo_array+=("If this is a slow starting application, set a higher timeout with -t") echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration") echo_array+=("Reverting update..") - midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null || { echo_array+=("Error: Failed to rollback $app_name") ; break ; } - [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions #run back after_update_actions function if the app was stopped prior to update echo "$app_name,$new_full_ver" >> failed - break + if rollback_app ; then + echo_array+=("Rolled Back") + else + echo_array+=("Error: Failed to rollback $app_name\nAbandoning") + echo_array + return 1 + fi + failed="true" + SECONDS=0 + count=0 + continue #run back after_update_actions function if the app was stopped prior to update else echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") echo_array+=("The application failed to be ACTIVE even after a rollback") @@ -251,6 +259,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then echo_array+=("If this is a slow starting application, set a higher timeout with -t") echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration") echo_array+=("Manual intervention is required\nStopping, then Abandoning") + echo "$app_name,$new_full_ver" >> failed if stop_app ; then echo_array+=("Stopped") else @@ -272,6 +281,26 @@ echo_array export -f after_update_actions +rollback_app(){ +count=0 +while [[ $update_avail != "true" ]] +do + update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}') + if [[ $count -gt 2 ]]; then # If failed to rollback app 3 times, return failure to parent shell + return 1 + elif ! cli -c "app chart_release rollback release_name=\"$app_name\" rollback_options={\"item_version\": \"$rollback_version\"}" &> /dev/null ; then + before_loop=$(head -n 1 all_app_status) + ((count++)) + until [[ $(head -n 1 all_app_status) != "$before_loop" ]] # Upon failure, wait for status update before continuing + do + sleep 1 + done + else + break + fi +done +} + echo_array(){ #Dump the echo_array, ensures all output is in a neat order. for i in "${echo_array[@]}" From fbdcf88a9995a31f27e5e6720c4cb4a89d3df970 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 24 Aug 2022 16:16:34 -0600 Subject: [PATCH 740/823] fix rollback_app logic --- functions/update_apps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a72f54d9..d695e4a2 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -283,7 +283,8 @@ export -f after_update_actions rollback_app(){ count=0 -while [[ $update_avail != "true" ]] +update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}') +while [[ $update_avail == "false" ]] do update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}') if [[ $count -gt 2 ]]; then # If failed to rollback app 3 times, return failure to parent shell From c1dc53c23166c549b07be5d1dc750a967244b485 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 24 Aug 2022 16:39:08 -0600 Subject: [PATCH 741/823] add support back for container updates --- functions/update_apps.sh | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d695e4a2..282e5c03 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -16,7 +16,7 @@ rm deploying 2>/dev/null rm finished 2>/dev/null while true do - if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then + if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' 2>/dev/null) ; then ((while_count++)) [[ -z $while_status ]] && continue || echo -e "$while_count\n$while_status" > all_app_status mapfile -t deploying_check < <(grep ",DEPLOYING," all_app_status) @@ -107,7 +107,6 @@ if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # C else echo_array+=("Error: Failed to stop $app_name") echo_array - final_check return 1 fi fi @@ -117,16 +116,13 @@ if update_app ;then else echo_array+=("Failed to update\nManual intervention may be required") echo_array - final_check return fi if grep -qs "^$app_name,true" external_services ; then echo_array - final_check return else after_update_actions - final_check fi } export -f pre_process @@ -136,12 +132,13 @@ update_app(){ current_loop=0 while true do - update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}') - if [[ $update_avail == "true" ]]; then + app_update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}') + cont_update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $6}') + if [[ $app_update_avail == "true" || $cont_update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then before_loop=$(head -n 1 all_app_status) current_loop=0 - until [[ "$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}')" != "$update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + until [[ "$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}')" != "$app_update_avail" || "$(grep "^$app_name," all_app_status | awk -F ',' '{print $6}')" != "$cont_update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do if [[ $current_loop -gt 2 ]]; then cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || return 1 # After waiting, attempt an update once more, if fails, return error code @@ -153,7 +150,7 @@ do done fi break - elif [[ $update_avail == "false" ]]; then + elif [[ $app_update_avail == "false" && $cont_update_avail == "false" ]]; then break else sleep 3 @@ -224,7 +221,13 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi elif [[ "$SECONDS" -ge "$timeout" ]]; then if [[ $rollback == "true" ]]; then - if [[ "$failed" != "true" ]]; then + if [[ $old_full_ver == "$new_full_ver" ]]; then + echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") + echo_array+=("This is the result of a container image update..") + echo_array+=("Reverting is not possible, Abandoning") + echo_array + return 1 + elif [[ "$failed" != "true" ]]; then echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") echo_array+=("If this is a slow starting application, set a higher timeout with -t") echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration") @@ -283,10 +286,10 @@ export -f after_update_actions rollback_app(){ count=0 -update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}') -while [[ $update_avail == "false" ]] +app_update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}') +while [[ $app_update_avail == "false" ]] do - update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}') + app_update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}') if [[ $count -gt 2 ]]; then # If failed to rollback app 3 times, return failure to parent shell return 1 elif ! cli -c "app chart_release rollback release_name=\"$app_name\" rollback_options={\"item_version\": \"$rollback_version\"}" &> /dev/null ; then @@ -308,10 +311,11 @@ for i in "${echo_array[@]}" do echo -e "$i" done - +final_check } export -f echo_array + final_check(){ [[ ! -e finished ]] && touch finished echo "$app_name,finished" >> finished From 2bc4ba3d6226a19fc5d5346828b9b72a873714a2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 24 Aug 2022 17:05:16 -0600 Subject: [PATCH 742/823] use regex rather than 2 variables to check update --- functions/update_apps.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 282e5c03..61d670a6 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -132,13 +132,12 @@ update_app(){ current_loop=0 while true do - app_update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}') - cont_update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $6}') - if [[ $app_update_avail == "true" || $cont_update_avail == "true" ]]; then + update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3","$6}') + if [[ $update_avail =~ "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then before_loop=$(head -n 1 all_app_status) current_loop=0 - until [[ "$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}')" != "$app_update_avail" || "$(grep "^$app_name," all_app_status | awk -F ',' '{print $6}')" != "$cont_update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + until [[ "$(grep "^$app_name," all_app_status | awk -F ',' '{print $3","$6}')" != "$update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do if [[ $current_loop -gt 2 ]]; then cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || return 1 # After waiting, attempt an update once more, if fails, return error code @@ -150,7 +149,7 @@ do done fi break - elif [[ $app_update_avail == "false" && $cont_update_avail == "false" ]]; then + elif [[ ! $update_avail =~ "true" ]]; then break else sleep 3 From 212e894744ef2d2e69aefc3b48e279fdbdb13b6b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 25 Aug 2022 22:00:26 -0600 Subject: [PATCH 743/823] exit code 0 on script end --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index f9db3b84..7a687b51 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -162,5 +162,5 @@ elif [[ "$sync" == "true" && -z "$backup" ]]; then # If only sync is true, run i sync fi [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander -[[ "$prune" == "true" ]] && prune - +[[ "$prune" == "true" ]] && prune +exit 0 \ No newline at end of file From fda0b7ca882be2ba2c8df23c3bf60df16093f4cc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 25 Aug 2022 22:16:44 -0600 Subject: [PATCH 744/823] git reset hard to force tagged updates --- functions/self_update.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 9c60d2b5..a0ee1d01 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -3,7 +3,8 @@ args=("$@") self_update() { -git fetch --tags &>/dev/null +git fetch --tags &>/dev/null +git reset --hard latest_ver=$(git describe --tags "$(git rev-list --tags --max-count=1)") echo "🅂 🄴 🄻 🄵" echo "🅄 🄿 🄳 🄰 🅃 🄴" From 72930e2f14a8ec39328849e62eb56a88f3ce7c5b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 25 Aug 2022 22:39:26 -0600 Subject: [PATCH 745/823] spacing, function explanation --- functions/backup.sh | 3 +- functions/menu.sh | 4 +- functions/misc.sh | 3 + functions/mount.sh | 1 + functions/script_create.sh | 1 + functions/self_update.sh | 1 + functions/update_apps.sh | 131 +++++++++++++++++++------------------ heavy_script.sh | 9 +-- 8 files changed, 77 insertions(+), 76 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 642b58f5..0ca69069 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -30,7 +30,6 @@ echo export -f backup - deleteBackup(){ while true do @@ -170,4 +169,4 @@ do done done } -export -f restore +export -f restore \ No newline at end of file diff --git a/functions/menu.sh b/functions/menu.sh index 5b86ca5f..a8677314 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -1,5 +1,6 @@ #!/bin/bash + menu(){ clear -x title @@ -45,7 +46,6 @@ case $selection in 8) script_create ;; - 9) cmd_to_container ;; @@ -55,4 +55,4 @@ case $selection in esac echo } -export -f menu +export -f menu \ No newline at end of file diff --git a/functions/misc.sh b/functions/misc.sh index 33b4d4c0..ebff4ff8 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -15,6 +15,7 @@ echo } export -f sync + prune(){ echo -e "🄿 🅁 🅄 🄽 🄴" echo "Pruned Docker Images" @@ -22,6 +23,7 @@ docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" } export -f prune + title(){ echo ' _ _ _____ _ _ ' echo '| | | | / ___| (_) | | ' @@ -36,6 +38,7 @@ echo } export -f title + help(){ [[ $help == "true" ]] && clear -x diff --git a/functions/mount.sh b/functions/mount.sh index 26198633..c915407e 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -1,5 +1,6 @@ #!/bin/bash + mount(){ while true do diff --git a/functions/script_create.sh b/functions/script_create.sh index b1448218..de761cc6 100644 --- a/functions/script_create.sh +++ b/functions/script_create.sh @@ -1,5 +1,6 @@ #!/bin/bash + script_create(){ while true do diff --git a/functions/self_update.sh b/functions/self_update.sh index a0ee1d01..144157d4 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -1,5 +1,6 @@ #!/bin/bash + args=("$@") self_update() { diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 61d670a6..50629e2e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,7 +9,6 @@ echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") -rm external_services 2>/dev/null # TODO remove later it=0 while_count=0 rm deploying 2>/dev/null @@ -42,14 +41,9 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 elif [[ $it -lt ${#array[@]} ]]; then - # loop=0 - # until [[ $loop -ge 2 || $it -ge ${#array[@]} ]]; - # do pre_process "${array[$it]}" & processes+=($!) ((it++)) - # ((loop++)) - # done elif [[ $proc_count != 0 || $(wc -l finished 2>/dev/null | awk '{ print $1 }') -lt "${#array[@]}" ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop @@ -78,6 +72,8 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') + +# Skip update if application previously failed on this exact update version if grep -qs "^$app_name," failed 2>/dev/null; then failed_ver=$(grep "^$app_name," failed | awk -F ',' '{print $2}') if [[ "$failed_ver" == "$new_full_ver" ]] ; then @@ -90,6 +86,7 @@ if grep -qs "^$app_name," failed 2>/dev/null; then fi fi +# Check if app is external services, append outcome to external_services file [[ ! -e external_services ]] && touch external_services if ! grep -qs "^$app_name," external_services ; then if ! grep -qs "/external-service" /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/"$(find /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/ -maxdepth 1 -type d -printf '%P\n' | sort -r | head -n 1)"/Chart.yaml; then @@ -99,6 +96,7 @@ if ! grep -qs "^$app_name," external_services ; then fi fi +# If user is using -S, stop app prior to updating echo_array+=("\n$app_name") if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # Check to see if user is using -S or not [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") @@ -110,6 +108,8 @@ if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # C return 1 fi fi + +# Send app through update function [[ "$verbose" == "true" ]] && echo_array+=("Updating..") if update_app ;then echo_array+=("Updated\n$old_full_ver\n$new_full_ver") @@ -118,70 +118,19 @@ else echo_array return fi + +# If app is external services, do not send for post processing if grep -qs "^$app_name,true" external_services ; then echo_array return else - after_update_actions + post_process fi } export -f pre_process -update_app(){ -current_loop=0 -while true -do - update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3","$6}') - if [[ $update_avail =~ "true" ]]; then - if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then - before_loop=$(head -n 1 all_app_status) - current_loop=0 - until [[ "$(grep "^$app_name," all_app_status | awk -F ',' '{print $3","$6}')" != "$update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. - do - if [[ $current_loop -gt 2 ]]; then - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || return 1 # After waiting, attempt an update once more, if fails, return error code - elif ! echo -e "$(head -n 1 all_app_status)" | grep -qs ^"$before_loop" ; then # The file has been updated, but nothing changed specifically for the app. - before_loop=$(head -n 1 all_app_status) - ((current_loop++)) - fi - sleep 1 - done - fi - break - elif [[ ! $update_avail =~ "true" ]]; then - break - else - sleep 3 - fi -done -} -export -f update_app - - -stop_app(){ -count=0 -while [[ "$status" != "STOPPED" ]] -do - status=$( grep "^$app_name," all_app_status | awk -F ',' '{print $2}') - if [[ $count -gt 2 ]]; then # If failed to stop app 3 times, return failure to parent shell - return 1 - elif ! cli -c 'app chart_release scale release_name='\""$app_name"\"\ 'scale_options={"replica_count": 0}' &> /dev/null ; then - before_loop=$(head -n 1 all_app_status) - ((count++)) - until [[ $(head -n 1 all_app_status) != "$before_loop" ]] # Upon failure, wait for status update before continuing - do - sleep 1 - done - else - break - fi -done -} -export -f stop_app - - -after_update_actions(){ +post_process(){ SECONDS=0 count=0 if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then @@ -242,7 +191,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then failed="true" SECONDS=0 count=0 - continue #run back after_update_actions function if the app was stopped prior to update + continue #run back post_process function if the app was stopped prior to update else echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") echo_array+=("The application failed to be ACTIVE even after a rollback") @@ -280,7 +229,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi echo_array } -export -f after_update_actions +export -f post_process rollback_app(){ @@ -304,6 +253,60 @@ do done } + +update_app(){ +current_loop=0 +while true +do + update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3","$6}') + if [[ $update_avail =~ "true" ]]; then + if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then + before_loop=$(head -n 1 all_app_status) + current_loop=0 + until [[ "$(grep "^$app_name," all_app_status | awk -F ',' '{print $3","$6}')" != "$update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + do + if [[ $current_loop -gt 2 ]]; then + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || return 1 # After waiting, attempt an update once more, if fails, return error code + elif ! echo -e "$(head -n 1 all_app_status)" | grep -qs ^"$before_loop" ; then # The file has been updated, but nothing changed specifically for the app. + before_loop=$(head -n 1 all_app_status) + ((current_loop++)) + fi + sleep 1 + done + fi + break + elif [[ ! $update_avail =~ "true" ]]; then + break + else + sleep 3 + fi +done +} +export -f update_app + + +stop_app(){ +count=0 +while [[ "$status" != "STOPPED" ]] +do + status=$( grep "^$app_name," all_app_status | awk -F ',' '{print $2}') + if [[ $count -gt 2 ]]; then # If failed to stop app 3 times, return failure to parent shell + return 1 + elif ! cli -c 'app chart_release scale release_name='\""$app_name"\"\ 'scale_options={"replica_count": 0}' &> /dev/null ; then + before_loop=$(head -n 1 all_app_status) + ((count++)) + until [[ $(head -n 1 all_app_status) != "$before_loop" ]] # Upon failure, wait for status update before continuing + do + sleep 1 + done + else + break + fi +done +} +export -f stop_app + + echo_array(){ #Dump the echo_array, ensures all output is in a neat order. for i in "${echo_array[@]}" @@ -318,4 +321,4 @@ export -f echo_array final_check(){ [[ ! -e finished ]] && touch finished echo "$app_name,finished" >> finished -} +} \ No newline at end of file diff --git a/heavy_script.sh b/heavy_script.sh index 7a687b51..6858ed4d 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,5 +1,6 @@ #!/bin/bash + # cd to script, this ensures the script can find the source scripts below, even when ran from a seperate directory script=$(readlink -f "$0") script_path=$(dirname "$script") @@ -20,13 +21,10 @@ source functions/cmd_to_container.sh source functions/script_create.sh - - #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && menu - # Parse script options while getopts ":si:rb:t:uUpSRv-:" opt do @@ -121,10 +119,6 @@ do v) verbose="true" ;; - \?) - echo -e "Invalid Option \"-$OPTARG\"\n" - help - ;; *) echo -e "Invalid Option \"-$OPTARG\"\n" help @@ -133,7 +127,6 @@ do done - #exit if incompatable functions are called [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit From f77ffd65430755f4a6ab401b340e9b56035b6021 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 25 Aug 2022 22:40:38 -0600 Subject: [PATCH 746/823] README typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 49ded17b..8d4a3bfe 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ |--------------- |------------------------ |----------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | -U | -U
-U 5 | None or Integer | Update applications, ignoring major version changes
_Optionally, you can supply a number after the argument to update multiple applications at once_ | | -u | -u
-u 5 | None or Integer | Update applications, do NOT update if there was a major version change
_Optionally, you can supply a number after the argument to update multiple applications at once_ | -| -b | -b 14 | Integer | Backup `ix-appliactions` dataset
_Creates backups up to the number you've chosen_ | +| -b | -b 14 | Integer | Backup `ix-applications` dataset
_Creates backups up to the number you've chosen_ | | -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating
_List one application after another as shown in the example_ | | -r | -r | None | Monitors applications after they update
If the app does not become "ACTIVE" after either:
The custom Timeout, or Default Timeout,
rollback the application. | | -v | -v | None | Verbose Output
_Look at the bottom of this page for an example_ | From c0f6ed10a83133a8f3dd520fe5089cf4c1ae44f1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 30 Aug 2022 21:36:34 -0600 Subject: [PATCH 747/823] Documentation, remove redundant code, spacing --- functions/menu.sh | 1 - functions/mount.sh | 4 ++-- functions/update_apps.sh | 3 +++ heavy_script.sh | 5 ++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index a8677314..921b64f6 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -32,7 +32,6 @@ case $selection in ;; 4) read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups || { echo -e "\nFailed to make a selection in time" ; exit; } - backup="true" ;; 5) restore diff --git a/functions/mount.sh b/functions/mount.sh index c915407e..c58f8571 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -51,7 +51,7 @@ do mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r") full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') fi echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" @@ -90,7 +90,7 @@ do mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r") full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) zfs set mountpoint=legacy "$full_path""$pvc" echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 50629e2e..ce6a4476 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -136,6 +136,8 @@ count=0 if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do + + # If app reports ACTIVE right away, assume its a false positive and wait for it to change, or trust it after 5 updates to all_app_status status=$(grep "^$app_name," all_app_status | awk -F ',' '{print $2}') if [[ $count -lt 1 && $status == "ACTIVE" && "$(grep "^$app_name," deploying 2>/dev/null | awk -F ',' '{print $2}')" != "DEPLOYING" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. [[ "$verbose" == "true" ]] && echo_array+=("Verifying $status..") @@ -152,6 +154,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then done fi (( count++ )) + if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") diff --git a/heavy_script.sh b/heavy_script.sh index 6858ed4d..76d03a9a 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -66,7 +66,6 @@ do number_of_backups=$OPTARG ! [[ $OPTARG =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit - backup="true" ;; r) rollback="true" @@ -138,14 +137,14 @@ done [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit -if [[ "$backup" == "true" && "$sync" == "true" ]]; then # Run backup and sync at the same time +if [[ "$backup" -gt 1 && "$sync" == "true" ]]; then # Run backup and sync at the same time echo "🅃 🄰 🅂 🄺 🅂 :" echo -e "-Backing up ix-applications Dataset\n-Syncing catalog(s)" echo -e "This can take a LONG time, Please Wait For Both Output..\n\n" backup & sync & wait -elif [[ "$backup" == "true" && -z "$sync" ]]; then # If only backup is true, run it +elif [[ "$backup" -gt 1 && -z "$sync" ]]; then # If only backup is true, run it echo "🅃 🄰 🅂 🄺 :" echo -e "-Backing up \"ix-applications\" Dataset\nPlease Wait..\n\n" backup From a406406002ffc8668edd121bdf9f7b5382792bb6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 30 Aug 2022 21:40:08 -0600 Subject: [PATCH 748/823] change backup variable --- heavy_script.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 76d03a9a..d669aac8 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -137,18 +137,18 @@ done [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit -if [[ "$backup" -gt 1 && "$sync" == "true" ]]; then # Run backup and sync at the same time +if [[ "$number_of_backups" -gt 1 && "$sync" == "true" ]]; then # Run backup and sync at the same time echo "🅃 🄰 🅂 🄺 🅂 :" echo -e "-Backing up ix-applications Dataset\n-Syncing catalog(s)" echo -e "This can take a LONG time, Please Wait For Both Output..\n\n" backup & sync & wait -elif [[ "$backup" -gt 1 && -z "$sync" ]]; then # If only backup is true, run it +elif [[ "$number_of_backups" -gt 1 && -z "$sync" ]]; then # If only backup is true, run it echo "🅃 🄰 🅂 🄺 :" echo -e "-Backing up \"ix-applications\" Dataset\nPlease Wait..\n\n" backup -elif [[ "$sync" == "true" && -z "$backup" ]]; then # If only sync is true, run it +elif [[ "$sync" == "true" && -z "$number_of_backups" ]]; then # If only sync is true, run it echo "🅃 🄰 🅂 🄺 :" echo -e "Syncing Catalog(s)\nThis Takes a LONG Time, Please Wait..\n\n" sync From 5a1f5a087e3e8bd0a75c60350763917b0f84dee7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 30 Aug 2022 22:06:20 -0600 Subject: [PATCH 749/823] validity check for backup --- functions/menu.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index 921b64f6..e4cf5a45 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -32,6 +32,8 @@ case $selection in ;; 4) read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups || { echo -e "\nFailed to make a selection in time" ; exit; } + ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit + [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit ;; 5) restore From b31818d074c5881186d96a7f9188841dd223d419 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 30 Aug 2022 22:08:29 -0600 Subject: [PATCH 750/823] change error message --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index e4cf5a45..cef7bc6c 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -32,7 +32,7 @@ case $selection in ;; 4) read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit + ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: The input must be an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit ;; 5) From dc2d476937c8a36a6522f0bbdc687fd561c870ee Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 31 Aug 2022 21:30:07 -0600 Subject: [PATCH 751/823] always pull pool name --- functions/mount.sh | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index c58f8571..fd71fc69 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -2,6 +2,7 @@ mount(){ +pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r") while true do clear -x @@ -48,12 +49,7 @@ do data_name=$(echo "$pvc" | awk '{print $3}') mount=$(echo "$pvc" | awk '{print $4}') volume_name=$(echo "$pvc" | awk '{print $4}') - mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') - if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r") - full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') - fi + full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" @@ -87,17 +83,9 @@ do main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') app=$(echo "$main" | awk '{print $1}' | cut -c 4-) pvc=$(echo "$main" | awk '{print $3}') - mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r") - full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - zfs set mountpoint=legacy "$full_path""$pvc" - echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" - else - zfs set mountpoint=legacy "$path""$pvc" - echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" - fi + full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + zfs set mountpoint=legacy "$full_path""$pvc" + echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" done rmdir /mnt/heavyscript sleep 3 From 56536136989b6cb45fa193de81f54108900c6cdc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 31 Aug 2022 21:37:17 -0600 Subject: [PATCH 752/823] use cli version to stop app, cleanup output --- functions/mount.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index fd71fc69..56bbac73 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -34,25 +34,24 @@ do app=$(echo -e "$list" | grep ^"$selection)" | awk '{print $2}' | cut -c 4- ) [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && continue #Check for valid selection. If none, contiue pvc=$(echo -e "$list" | grep ^"$selection)") + + #Stop applicaiton if not stopped status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then - [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" - SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null + cli -c 'app chart_release scale release_name='\""$app"\"\ 'scale_options={"replica_count": 0}' &> /dev/null else echo -e "\n$app is already stopped" fi - while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] - do - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 - done + + #Grab data then output data_name=$(echo "$pvc" | awk '{print $3}') - mount=$(echo "$pvc" | awk '{print $4}') volume_name=$(echo "$pvc" | awk '{print $4}') full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') - echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" + echo -e "\nMounting\n$data_name" zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" - echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" + echo -e "\nMounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" + + #Ask if user would like to mount something else while true do echo From 9b24252dc735fbc2807eae9ad1a0b716fd51889f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 31 Aug 2022 21:43:23 -0600 Subject: [PATCH 753/823] improve output, add error handling --- functions/mount.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index 56bbac73..db43f8ae 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -38,7 +38,13 @@ do #Stop applicaiton if not stopped status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then - cli -c 'app chart_release scale release_name='\""$app"\"\ 'scale_options={"replica_count": 0}' &> /dev/null + echo "Stopping $app prior to mount" + if ! cli -c 'app chart_release scale release_name='\""$app"\"\ 'scale_options={"replica_count": 0}' &> /dev/null; then + echo "Failed to stop $app" + exit 1 + else + echo "Stopped" + fi else echo -e "\n$app is already stopped" fi @@ -47,9 +53,13 @@ do data_name=$(echo "$pvc" | awk '{print $3}') volume_name=$(echo "$pvc" | awk '{print $4}') full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') - echo -e "\nMounting\n$data_name" - zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" - echo -e "\nMounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" + if ! zfs set mountpoint=/heavyscript/"$data_name" "$full_path" ; then + echo "Error: Failed to mount $app" + exit 1 + else + echo -e "\nMounted\n$data_name" + fi + echo -e "\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" #Ask if user would like to mount something else while true From d7f97836ca81ae81855e180e0994cfc12021aa9d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 31 Aug 2022 21:45:19 -0600 Subject: [PATCH 754/823] debugging --- functions/mount.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index db43f8ae..5c9c7fab 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -38,11 +38,13 @@ do #Stop applicaiton if not stopped status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then - echo "Stopping $app prior to mount" + echo -e "\nStopping $app prior to mount" if ! cli -c 'app chart_release scale release_name='\""$app"\"\ 'scale_options={"replica_count": 0}' &> /dev/null; then echo "Failed to stop $app" exit 1 else + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + echo "$status" echo "Stopped" fi else From d0015c876177ab89e07a18802903b74daceab1db Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 31 Aug 2022 21:51:49 -0600 Subject: [PATCH 755/823] remove debugging, checks passed, cleanup --- functions/mount.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index 5c9c7fab..22665cc0 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -30,9 +30,11 @@ do echo echo "0) Exit" read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + + #Check for valid selection. If no issues, continue [[ $selection == 0 ]] && echo "Exiting.." && exit app=$(echo -e "$list" | grep ^"$selection)" | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && continue #Check for valid selection. If none, contiue + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && continue pvc=$(echo -e "$list" | grep ^"$selection)") #Stop applicaiton if not stopped @@ -43,15 +45,13 @@ do echo "Failed to stop $app" exit 1 else - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - echo "$status" echo "Stopped" fi else echo -e "\n$app is already stopped" fi - #Grab data then output + #Grab data then output and mount data_name=$(echo "$pvc" | awk '{print $3}') volume_name=$(echo "$pvc" | awk '{print $4}') full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') From 74dc9404b6ceaa17c2e7e46e33c8064854561e71 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 31 Aug 2022 22:32:13 -0600 Subject: [PATCH 756/823] refactor code, remove long ignore list --- functions/dns.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/functions/dns.sh b/functions/dns.sh index c4316139..b8a55b92 100644 --- a/functions/dns.sh +++ b/functions/dns.sh @@ -4,24 +4,25 @@ dns(){ clear -x echo "Generating DNS Names.." -#ignored dependency pods, may need to add more in the future. -dep_ignore="\-cronjob\-|^kube-system|\ssvclb|NAME|\-memcached\-.[^custom\-app]|\-postgresql\-.[^custom\-app]|\-redis\-.[^custom\-app]|\-mariadb\-.[^custom\-app]|\-promtail\-.[^custom\-app]" +# Ignore svclb +dep_ignore='svclb-' # Pulling pod names -mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$dep_ignore" | sort) +k3s crictl pods --namespace ix -s Ready | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//' | grep -Ev -- "$dep_ignore" | sed '1d' >> dns_file +mapfile -t ixName < <(< dns_file awk '{print $4}' | sort -u ) # Pulling all ports all_ports=$(k3s kubectl get service -A) clear -x count=0 -for i in "${main[@]}" +for i in "${ixName[@]}" do [[ count -le 0 ]] && echo -e "\n" && ((count++)) - appName=$(echo "$i" | awk '{print $2}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//') - ixName=$(echo "$i" | awk '{print $1}') + appName=$(grep -E "\s$i\s" "dns_file" | awk '{print $3}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//' | head -n 1) port=$(echo "$all_ports" | grep -E "\s$appName\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}") - echo -e "$appName.$ixName.svc.cluster.local $port" -done | uniq | nl -b t | sed 's/\s\s\s$/- -------- ----/' | column -t -R 1 -N "#,DNS_Name,Port" -L + echo -e "$appName $appName.$i.svc.cluster.local $port" +done | nl -s ") " -b t | sed '0,/\s\s\s/{s/\s\s\s/- ----- -------- ----/}'| column -t -N "#,Name,DNS_Name,Port" +rm dns_file } export -f dns \ No newline at end of file From 2c8c24e2373c31325f9b5a89fa8702517a984602 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 31 Aug 2022 22:36:55 -0600 Subject: [PATCH 757/823] remove extra hyphen from name --- functions/dns.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/dns.sh b/functions/dns.sh index b8a55b92..3d9af33a 100644 --- a/functions/dns.sh +++ b/functions/dns.sh @@ -22,7 +22,7 @@ do appName=$(grep -E "\s$i\s" "dns_file" | awk '{print $3}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//' | head -n 1) port=$(echo "$all_ports" | grep -E "\s$appName\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}") echo -e "$appName $appName.$i.svc.cluster.local $port" -done | nl -s ") " -b t | sed '0,/\s\s\s/{s/\s\s\s/- ----- -------- ----/}'| column -t -N "#,Name,DNS_Name,Port" +done | nl -s ") " -b t | sed '0,/\s\s\s/{s/\s\s\s/- ---- -------- ----/}'| column -t -N "#,Name,DNS_Name,Port" rm dns_file } export -f dns \ No newline at end of file From 77e6be35a191d513d2e55fc9e4027e47dde5bb9d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 31 Aug 2022 22:54:58 -0600 Subject: [PATCH 758/823] silence git reset output --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 144157d4..e06b2dc9 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -5,7 +5,7 @@ args=("$@") self_update() { git fetch --tags &>/dev/null -git reset --hard +git reset --hard &>/dev/null latest_ver=$(git describe --tags "$(git rev-list --tags --max-count=1)") echo "🅂 🄴 🄻 🄵" echo "🅄 🄿 🄳 🄰 🅃 🄴" From 3f299e0ba3322563632f3b50b9d8357a8a46b5ff Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 31 Aug 2022 23:10:26 -0600 Subject: [PATCH 759/823] change variables and appname to non-full --- functions/dns.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/functions/dns.sh b/functions/dns.sh index 3d9af33a..05441da8 100644 --- a/functions/dns.sh +++ b/functions/dns.sh @@ -9,19 +9,20 @@ dep_ignore='svclb-' # Pulling pod names k3s crictl pods --namespace ix -s Ready | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//' | grep -Ev -- "$dep_ignore" | sed '1d' >> dns_file -mapfile -t ixName < <(< dns_file awk '{print $4}' | sort -u ) +mapfile -t ix_name_array < <(< dns_file awk '{print $4}' | sort -u ) # Pulling all ports all_ports=$(k3s kubectl get service -A) clear -x count=0 -for i in "${ixName[@]}" +for i in "${ix_name_array[@]}" do [[ count -le 0 ]] && echo -e "\n" && ((count++)) - appName=$(grep -E "\s$i\s" "dns_file" | awk '{print $3}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//' | head -n 1) - port=$(echo "$all_ports" | grep -E "\s$appName\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}") - echo -e "$appName $appName.$i.svc.cluster.local $port" + full_app_name=$(grep -E "\s$i\s" "dns_file" | awk '{print $3}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//' | head -n 1) + app_name=$(echo $i | cut -c 4-) + port=$(echo "$all_ports" | grep -E "\s$full_app_name\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}") + echo -e "$app_name $full_app_name.$i.svc.cluster.local $port" done | nl -s ") " -b t | sed '0,/\s\s\s/{s/\s\s\s/- ---- -------- ----/}'| column -t -N "#,Name,DNS_Name,Port" rm dns_file } From 2b758961766bebc85d4dfe03cf4df6ef08cb8bb5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 31 Aug 2022 23:10:45 -0600 Subject: [PATCH 760/823] remove ignore var --- functions/dns.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/functions/dns.sh b/functions/dns.sh index 05441da8..ad6536d3 100644 --- a/functions/dns.sh +++ b/functions/dns.sh @@ -4,11 +4,9 @@ dns(){ clear -x echo "Generating DNS Names.." -# Ignore svclb -dep_ignore='svclb-' # Pulling pod names -k3s crictl pods --namespace ix -s Ready | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//' | grep -Ev -- "$dep_ignore" | sed '1d' >> dns_file +k3s crictl pods --namespace ix -s Ready | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//' | grep -v 'svclb-' | sed '1d' >> dns_file mapfile -t ix_name_array < <(< dns_file awk '{print $4}' | sort -u ) # Pulling all ports @@ -20,7 +18,7 @@ for i in "${ix_name_array[@]}" do [[ count -le 0 ]] && echo -e "\n" && ((count++)) full_app_name=$(grep -E "\s$i\s" "dns_file" | awk '{print $3}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//' | head -n 1) - app_name=$(echo $i | cut -c 4-) + app_name=$(echo "$i" | cut -c 4-) port=$(echo "$all_ports" | grep -E "\s$full_app_name\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}") echo -e "$app_name $full_app_name.$i.svc.cluster.local $port" done | nl -s ") " -b t | sed '0,/\s\s\s/{s/\s\s\s/- ---- -------- ----/}'| column -t -N "#,Name,DNS_Name,Port" From 046e03f9c223390f1817e1cf246b165521717083 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 2 Sep 2022 17:15:28 -0600 Subject: [PATCH 761/823] compact backup menu --- functions/menu.sh | 60 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index cef7bc6c..122390c6 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -7,18 +7,17 @@ title echo "1) Help" echo "2) List DNS Names" echo "3) Mount and Unmount PVC storage" -echo "4) Create a Backup" -echo "5) Restore a Backup" -echo "6) Delete a Backup" -echo "7) Update HeavyScript" -echo "8) Update Applications" -echo "9) Command to Container" +echo "4) Backup Options" +echo "5) Update HeavyScript" +echo "6) Update Applications" +echo "7) Command to Container" echo echo "0) Exit" read -rt 120 -p "Please select an option by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } case $selection in 0) + echo "Exiting.." exit ;; 1) @@ -31,23 +30,50 @@ case $selection in mount ;; 4) - read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: The input must be an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit - [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit + while [[ $backup_selection != true ]] + do + clear -x + title + echo "Backup Menu" + echo "1) Create Backup" + echo "2) Delete Backup" + echo "3) Restore Backup" + echo + echo "0) Exit" + read -rt 120 -p "Please select an option by number: " backup_selection || { echo -e "\nFailed to make a selection in time" ; exit; } + case $backup_selection in + 0) + echo "Exiting.." + exit + ;; + 1) + read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups || { echo -e "\nFailed to make a selection in time" ; exit; } + ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: The input must be an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit + [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit + backup_selection=true + ;; + 2) + backup_selection=true + deleteBackup + ;; + 3) + backup_selection=true + restore + ;; + *) + echo "\"$selection\" was not an option, please try agian" && sleep 3 && continue + ;; + esac + done ;; + 5) - restore - ;; - 6) - deleteBackup - ;; - 7) self_update ;; - 8) + 6) script_create ;; - 9) + 7) cmd_to_container ;; *) From 800cac096fed2fb029e0b59d722cf43d1a7427cf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 2 Sep 2022 17:24:37 -0600 Subject: [PATCH 762/823] add titles to utility menu --- functions/cmd_to_container.sh | 4 ++++ functions/menu.sh | 3 +++ 2 files changed, 7 insertions(+) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 72f79990..ad8bf630 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -7,6 +7,8 @@ while true do clear -x title + echo "Command to Container Menu" + echo "-------------------------" echo "$app_name" echo echo "0) Exit" @@ -45,6 +47,8 @@ case "${#containers[@]}" in do clear -x title + echo "Available Containers" + echo "--------------------" cont_search=$( for i in "${containers[@]}" do diff --git a/functions/menu.sh b/functions/menu.sh index 122390c6..164bdd7b 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -4,6 +4,8 @@ menu(){ clear -x title +echo "Available Utilities" +echo "-------------------" echo "1) Help" echo "2) List DNS Names" echo "3) Mount and Unmount PVC storage" @@ -35,6 +37,7 @@ case $selection in clear -x title echo "Backup Menu" + echo "-----------" echo "1) Create Backup" echo "2) Delete Backup" echo "3) Restore Backup" From 73ce3939fb3c643308c5521e57dfd9e3b1c6160a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 2 Sep 2022 17:28:47 -0600 Subject: [PATCH 763/823] add title for mount menu --- functions/mount.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions/mount.sh b/functions/mount.sh index 22665cc0..00c3cf93 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -7,6 +7,8 @@ while true do clear -x title + echo "PVC Mount Menu" + echo "--------------" echo "1) Mount" echo "2) Unmount All" echo From 7b67b8871b1db03b435130e807e6dfd71f8ad02b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 3 Sep 2022 18:45:53 -0600 Subject: [PATCH 764/823] remove timeout from help --- functions/misc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/misc.sh b/functions/misc.sh index ebff4ff8..3812e72a 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -67,7 +67,7 @@ echo "-r | Roll-back applications if they fail to update" echo "-i | Add application to ignore list, one by one, see example below." echo "-S | Shutdown applications prior to updating" echo "-v | verbose output" -echo "-t 500| Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" +echo "-t 500| The amount of time HS will wait for an application to be ACTIVE. Defaults to 500 seconds" echo echo "Additional Options" echo "------------------" From b49c21bee87adf2b9719aaada86605580933495b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 4 Sep 2022 16:56:24 -0600 Subject: [PATCH 765/823] Dont send container image updates to post --- functions/update_apps.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ce6a4476..6a62f9aa 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -112,7 +112,11 @@ fi # Send app through update function [[ "$verbose" == "true" ]] && echo_array+=("Updating..") if update_app ;then - echo_array+=("Updated\n$old_full_ver\n$new_full_ver") + if [[ $old_full_ver == "$new_full_ver" ]]; then + echo_array+=("Container Image Update") + else + echo_array+=("Updated\n$old_full_ver\n$new_full_ver") + fi else echo_array+=("Failed to update\nManual intervention may be required") echo_array @@ -123,6 +127,10 @@ fi if grep -qs "^$app_name,true" external_services ; then echo_array return +# If app is container image update, dont send for post processing +elif [[ $old_full_ver == "$new_full_ver" ]]; then + echo_array + return else post_process fi From 07707135a9b2ae827b08f5e0d907e5e6c9f47886 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 4 Sep 2022 16:58:20 -0600 Subject: [PATCH 766/823] more fitting message for container image --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 6a62f9aa..a0d286e1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -113,7 +113,7 @@ fi [[ "$verbose" == "true" ]] && echo_array+=("Updating..") if update_app ;then if [[ $old_full_ver == "$new_full_ver" ]]; then - echo_array+=("Container Image Update") + echo_array+=("Updated Container Image") else echo_array+=("Updated\n$old_full_ver\n$new_full_ver") fi From 19d52e058a6deb4b26d0c2f6a8b83663a4405cdc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 4 Sep 2022 17:23:22 -0600 Subject: [PATCH 767/823] add sleep to while loop --- functions/update_apps.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a0d286e1..e128e12b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -96,6 +96,20 @@ if ! grep -qs "^$app_name," external_services ; then fi fi +# If application is deploying prior to updating, attempt to wait for it to finish +if [[ "$startstatus" == "DEPLOYING" ]]; then + SECONDS=0 + while [[ "$status" == "DEPLOYING" ]] + do + status=$(grep "^$app_name," all_app_status | awk -F ',' '{print $2}') + if [[ "$SECONDS" -ge "$timeout" ]]; then + echo_array+=("Application is stuck Deploying, Skipping to avoid damage") + return + fi + sleep 5 + done +fi + # If user is using -S, stop app prior to updating echo_array+=("\n$app_name") if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # Check to see if user is using -S or not From cc9091de150c7995d44421b8c0704a8ce8e7e65a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 4 Sep 2022 17:27:58 -0600 Subject: [PATCH 768/823] echo array before return --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e128e12b..df34f752 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -104,6 +104,7 @@ if [[ "$startstatus" == "DEPLOYING" ]]; then status=$(grep "^$app_name," all_app_status | awk -F ',' '{print $2}') if [[ "$SECONDS" -ge "$timeout" ]]; then echo_array+=("Application is stuck Deploying, Skipping to avoid damage") + echo_array return fi sleep 5 From b1f6b01e611ca5d63e1bc7451718daa83cb4f371 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 4 Sep 2022 17:40:29 -0600 Subject: [PATCH 769/823] replace while true --- functions/update_apps.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index df34f752..44e19f98 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -13,7 +13,7 @@ it=0 while_count=0 rm deploying 2>/dev/null rm finished 2>/dev/null -while true +while [[ $proc_count != 0 || $(wc -l finished 2>/dev/null | awk '{ print $1 }') -lt "${#array[@]}" ]] do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' 2>/dev/null) ; then ((while_count++)) @@ -38,16 +38,12 @@ do kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } ((count++)) done - if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 3 - elif [[ $it -lt ${#array[@]} ]]; then + if [[ $it -lt ${#array[@]} && "$proc_count" -lt "$update_limit" ]]; then pre_process "${array[$it]}" & processes+=($!) ((it++)) - elif [[ $proc_count != 0 || $(wc -l finished 2>/dev/null | awk '{ print $1 }') -lt "${#array[@]}" ]]; then # Wait for all processes to finish + else sleep 3 - else # All processes must be completed, break out of loop - break fi done rm deploying 2>/dev/null From 5e966e148b65655af24649f303d3948b33fbb419 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 5 Sep 2022 00:43:10 -0600 Subject: [PATCH 770/823] test new regex to better match apps --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index ad8bf630..472995b5 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -26,7 +26,7 @@ do done rm cont_file 2> /dev/null app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') -mapfile -t pod_id < <(k3s crictl pods -s ready --namespace ix | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $1}') +mapfile -t pod_id < <(k3s crictl pods -s ready --namespace ix | grep -E "[[:space:]]$app_name-(ix-chart-)?(custom-app-)?((([[:alnum:]]|[[a-z]]){8,10}-([-[:alnum:]]|[[a-z]]){5})|([[:alnum:]]|[[a-z]])*-0)" | awk '{print $1}') search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') for pod in "${pod_id[@]}" do From 4348deb7fe56ec48b5add037064fe01f7b90c7f0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 5 Sep 2022 00:46:17 -0600 Subject: [PATCH 771/823] add space after -0 for dep containers --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 472995b5..b683bcb0 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -26,7 +26,7 @@ do done rm cont_file 2> /dev/null app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') -mapfile -t pod_id < <(k3s crictl pods -s ready --namespace ix | grep -E "[[:space:]]$app_name-(ix-chart-)?(custom-app-)?((([[:alnum:]]|[[a-z]]){8,10}-([-[:alnum:]]|[[a-z]]){5})|([[:alnum:]]|[[a-z]])*-0)" | awk '{print $1}') +mapfile -t pod_id < <(k3s crictl pods -s ready --namespace ix | grep -E "[[:space:]]$app_name-(ix-chart-)?(custom-app-)?((([[:alnum:]]|[[a-z]]){8,10}-([-[:alnum:]]|[[a-z]]){5})|([[:alnum:]]|[[a-z]])*-0[[:space:]])" | awk '{print $1}') search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') for pod in "${pod_id[@]}" do From 093d6ca1d7c1f23eabd12d97bd38f67f1baed3e2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 5 Sep 2022 01:01:43 -0600 Subject: [PATCH 772/823] grab containers by namespace name --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index b683bcb0..fa2803b6 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -26,7 +26,7 @@ do done rm cont_file 2> /dev/null app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') -mapfile -t pod_id < <(k3s crictl pods -s ready --namespace ix | grep -E "[[:space:]]$app_name-(ix-chart-)?(custom-app-)?((([[:alnum:]]|[[a-z]]){8,10}-([-[:alnum:]]|[[a-z]]){5})|([[:alnum:]]|[[a-z]])*-0[[:space:]])" | awk '{print $1}') +mapfile -t pod_id < <(k3s crictl pods -s ready --namespace ix | grep -v "[[:space:]]svclb-" | grep -E "[[:space:]]ix-${app_name}[[:space:]]" | awk '{print $1}') search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') for pod in "${pod_id[@]}" do From de5ef940fd289a63e4b3c2e2d8be5ac9e9a42cb5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 5 Sep 2022 01:44:09 -0600 Subject: [PATCH 773/823] parse exeptions first --- functions/update_apps.sh | 41 +++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 44e19f98..bacb008e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,6 +9,31 @@ echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + +index=0 +for app in "${array[@]}" +do + app_name=$(echo "$app" | awk -F ',' '{print $1}') #print out first catagory, name. + old_app_ver=$(echo "$app" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version + new_app_ver=$(echo "$app" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version + old_chart_ver=$(echo "$app" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version + new_chart_ver=$(echo "$app" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version + diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions + diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions + + #Skip application if its on ignore list + if printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" ; then + echo -e "\n$app_name\nIgnored, skipping" + unset "array[$index]" + #Skip appliaction if major update and not ignoreing major versions + elif [[ "$diff_app" != "$diff_chart" && $update_apps == "true" ]] ; then + echo -e "\n$app_name\nMajor Release, update manually" + unset "array[$index]" + fi + ((index++)) +done + + it=0 while_count=0 rm deploying 2>/dev/null @@ -56,15 +81,7 @@ export -f commander pre_process(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && final_check && return 0 #If application is on ignore list, skip -old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version -new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version -old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version -new_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version startstatus=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE -diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions -diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions -[[ "$diff_app" != "$diff_chart" && $update_apps == "true" ]] && echo -e "\n$app_name\nMajor Release, update manually" && final_check && return old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') @@ -191,13 +208,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi elif [[ "$SECONDS" -ge "$timeout" ]]; then if [[ $rollback == "true" ]]; then - if [[ $old_full_ver == "$new_full_ver" ]]; then - echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") - echo_array+=("This is the result of a container image update..") - echo_array+=("Reverting is not possible, Abandoning") - echo_array - return 1 - elif [[ "$failed" != "true" ]]; then + if [[ "$failed" != "true" ]]; then echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") echo_array+=("If this is a slow starting application, set a higher timeout with -t") echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration") From a9a23633845885035e3c73792ff57d3776f3c6b9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 5 Sep 2022 01:44:29 -0600 Subject: [PATCH 774/823] add skip prev failed --- functions/update_apps.sh | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index bacb008e..89753cca 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,6 +29,16 @@ do elif [[ "$diff_app" != "$diff_chart" && $update_apps == "true" ]] ; then echo -e "\n$app_name\nMajor Release, update manually" unset "array[$index]" + # Skip update if application previously failed on this exact update version + elif grep -qs "^$app_name," failed 2>/dev/null; then + failed_ver=$(grep "^$app_name," failed | awk -F ',' '{print $2}') + if [[ "$failed_ver" == "$new_full_ver" ]] ; then + echo -e "\n$app_name" + echo -e "Skipping previously failed version:\n$new_full_ver" + else + sed -i /"$app_name",/d failed + fi + unset "array[$index]" fi ((index++)) done @@ -86,18 +96,6 @@ old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -# Skip update if application previously failed on this exact update version -if grep -qs "^$app_name," failed 2>/dev/null; then - failed_ver=$(grep "^$app_name," failed | awk -F ',' '{print $2}') - if [[ "$failed_ver" == "$new_full_ver" ]] ; then - echo -e "\n$app_name" - echo -e "Skipping previously failed version:\n$new_full_ver" - final_check - return 0 - else - sed -i /"$app_name",/d failed - fi -fi # Check if app is external services, append outcome to external_services file [[ ! -e external_services ]] && touch external_services From fc8af22d07c20f1bb40368c6681f34e471647b9e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 5 Sep 2022 01:51:35 -0600 Subject: [PATCH 775/823] if nothing remains in array, return --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 89753cca..545dfd6b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -43,6 +43,7 @@ do ((index++)) done +[[ ${#array[@]} == 0 ]] && return it=0 while_count=0 From bb9e332a34fef98622a7224befc17bcd410f0dd9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 5 Sep 2022 02:46:41 -0600 Subject: [PATCH 776/823] rebuild array --- functions/update_apps.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 545dfd6b..a48551d4 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -45,6 +45,8 @@ done [[ ${#array[@]} == 0 ]] && return +array=("${array[@]}") + it=0 while_count=0 rm deploying 2>/dev/null From 3b502bd93a2e54dd0104fae8593a5db001063066 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 5 Sep 2022 12:29:45 -0600 Subject: [PATCH 777/823] reassign array rather than use proccount --- functions/update_apps.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a48551d4..a95b67ef 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -51,7 +51,7 @@ it=0 while_count=0 rm deploying 2>/dev/null rm finished 2>/dev/null -while [[ $proc_count != 0 || $(wc -l finished 2>/dev/null | awk '{ print $1 }') -lt "${#array[@]}" ]] +while [[ ${#processes[@]} != 0 || $(wc -l finished 2>/dev/null | awk '{ print $1 }') -lt "${#array[@]}" ]] do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' 2>/dev/null) ; then ((while_count++)) @@ -69,14 +69,14 @@ do echo "Middlewared timed out. Consider setting a lower number for async applications" continue fi - proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" do - kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } + kill -0 "$proc" &> /dev/null || unset "processes[$count]" ((count++)) done - if [[ $it -lt ${#array[@]} && "$proc_count" -lt "$update_limit" ]]; then + processes=("${processes[@]}") + if [[ $it -lt ${#array[@]} && "${#processes[@]}" -lt "$update_limit" ]]; then pre_process "${array[$it]}" & processes+=($!) ((it++)) From ad0c8e07f51952fce53262f72c5687e763dffd32 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 5 Sep 2022 12:38:01 -0600 Subject: [PATCH 778/823] reassign array prior to element check --- functions/update_apps.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a95b67ef..1ad97377 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -42,10 +42,9 @@ do fi ((index++)) done - +array=("${array[@]}") [[ ${#array[@]} == 0 ]] && return -array=("${array[@]}") it=0 while_count=0 From c05570885080d3ed92c8bcaf5acc3eecf6f381a9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 5 Sep 2022 12:43:01 -0600 Subject: [PATCH 779/823] rename it to index --- functions/update_apps.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 1ad97377..01962ff8 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -43,10 +43,10 @@ do ((index++)) done array=("${array[@]}") -[[ ${#array[@]} == 0 ]] && return +[[ ${#array[@]} == 0 ]] && echo && echo && return -it=0 +index=0 while_count=0 rm deploying 2>/dev/null rm finished 2>/dev/null @@ -75,10 +75,10 @@ do ((count++)) done processes=("${processes[@]}") - if [[ $it -lt ${#array[@]} && "${#processes[@]}" -lt "$update_limit" ]]; then - pre_process "${array[$it]}" & + if [[ $index -lt ${#array[@]} && "${#processes[@]}" -lt "$update_limit" ]]; then + pre_process "${array[$index]}" & processes+=($!) - ((it++)) + ((index++)) else sleep 3 fi From 317377705acd501b9a39ea2d29fe9ffae869bd9e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 5 Sep 2022 13:09:24 -0600 Subject: [PATCH 780/823] also rename indexes in pre_process --- functions/update_apps.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 01962ff8..812f4123 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -92,11 +92,11 @@ export -f commander pre_process(){ -app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. -startstatus=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE -old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From -new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To -rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') +app_name=$(echo "${array[$index]}" | awk -F ',' '{print $1}') #print out first catagory, name. +startstatus=$(echo "${array[$index]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE +old_full_ver=$(echo "${array[$index]}" | awk -F ',' '{print $4}') #Upgraded From +new_full_ver=$(echo "${array[$index]}" | awk -F ',' '{print $5}') #Upraded To +rollback_version=$(echo "${array[$index]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') # Check if app is external services, append outcome to external_services file From 9ac0c78daea7bbbefdfc4fbb7bdcea920cf32f5f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 6 Sep 2022 03:59:15 +0000 Subject: [PATCH 781/823] Update README --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8d4a3bfe..cfa6c6b8 100644 --- a/README.md +++ b/README.md @@ -32,25 +32,25 @@ | -r | -r | None | Monitors applications after they update
If the app does not become "ACTIVE" after either:
The custom Timeout, or Default Timeout,
rollback the application. | | -v | -v | None | Verbose Output
_Look at the bottom of this page for an example_ | | -S | -S | None | Shutdown the application prior to updating it | -| -t | -t 150 | Integer | Set a custom timeout to be used with either:
`-m`
_Time the script will wait for application to be "STOPPED"_
or
`-(u\|U)`
_Time the script will wait for application to be either "STOPPED" or "ACTIVE"_ | +| -t | -t 150 | Integer | Time in seconds that HeavyScript will wait for an application to no longer be deploying before declaring failure
Default: 500 | | -s | -s | None | Sync Catalogs prior to updating | | -p | -p | None | Prune old/unused docker images | | --self-update | --self-update | None | Updates HeavyScript prior to running any other commands | ### Example -#### Typical Cron Job +#### Cron Job ``` -bash heavy_script.sh --self-update -b 10 -i portainer -i arch -i sonarr -i radarr -t 600 -rsp -u 5 +bash heavy_script.sh --self-update -b 10 -i nextcloud -i sonarr -t 600 -rsp -u 5 ``` > `-b` is set to 10. Up to 10 snapshots of your ix-applications dataset will be saved -> `-i` is set to ignore portainer, arch, sonarr, and radarr. These applications will be ignored when it comes to updates. +> `-i` is set to ignore __nextcloud__ and __sonarr__. These applications will be skipped if they have an update. -> `-t` I set it to 600 seconds, this means the script will wait 600 seconds for the application to become ACTIVE before timing out and continuing to a different application. +> `-t` I set it to 600 seconds, this means the script will wait 600 seconds for the application to become ACTIVE before timing out and rolling back to the previous version since `-r` is used. -> `-r` Will rollback applications if they fail to deploy after updating. +> `-r` Will rollback applications if they fail to deploy within the timeout, after updating. > `-s` will just sync the repositories, ensuring you are downloading the latest updates. @@ -80,7 +80,7 @@ bash heavy_script.sh --self-update -b 10 -i portainer -i arch -i sonarr -i radar #### Mounting PVC Data ``` -bash /mnt/tank/scripts/heavy_script.sh -t 300 --mount +bash /mnt/tank/scripts/heavy_script.sh --mount ``` #### Restoring ix-applications dataset From 7a40e12cf9088512416e4978548721111ea853aa Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 6 Sep 2022 20:15:27 -0600 Subject: [PATCH 782/823] unset array only if app prev failed --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 812f4123..378d3f75 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -35,10 +35,10 @@ do if [[ "$failed_ver" == "$new_full_ver" ]] ; then echo -e "\n$app_name" echo -e "Skipping previously failed version:\n$new_full_ver" + unset "array[$index]" else sed -i /"$app_name",/d failed fi - unset "array[$index]" fi ((index++)) done From 233ecc1820bfbb284e965da0ed58b7efb23ca05a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 6 Sep 2022 20:23:20 -0600 Subject: [PATCH 783/823] failed append fix --- functions/update_apps.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 378d3f75..58cb332f 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -209,11 +209,11 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then elif [[ "$SECONDS" -ge "$timeout" ]]; then if [[ $rollback == "true" ]]; then if [[ "$failed" != "true" ]]; then + echo "$app_name,$new_full_ver" >> failed echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") echo_array+=("If this is a slow starting application, set a higher timeout with -t") echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration") - echo_array+=("Reverting update..") - echo "$app_name,$new_full_ver" >> failed + echo_array+=("Reverting update..") if rollback_app ; then echo_array+=("Rolled Back") else @@ -239,11 +239,11 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then break fi else + echo "$app_name,$new_full_ver" >> failed echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") echo_array+=("If this is a slow starting application, set a higher timeout with -t") echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration") echo_array+=("Manual intervention is required\nStopping, then Abandoning") - echo "$app_name,$new_full_ver" >> failed if stop_app ; then echo_array+=("Stopped") else From 93bd47acc9f68529f59cb9d2d3d3820142324c4c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 8 Sep 2022 15:02:54 -0600 Subject: [PATCH 784/823] add ability to ignore container image updates --- functions/misc.sh | 1 + functions/script_create.sh | 11 ++++++++--- functions/update_apps.sh | 8 ++++++-- heavy_script.sh | 3 +++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index 3812e72a..407c1c41 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -74,6 +74,7 @@ echo "------------------" echo "-b 14 | Back-up your ix-applications dataset, specify a number after -b" echo "-s | sync catalog" echo "-p | Prune unused/old docker images" +echo "--ignore-img | Ignore container image updates" echo "--self-update | Updates HeavyScript prior to running any other commands" echo echo "Examples" diff --git a/functions/script_create.sh b/functions/script_create.sh index de761cc6..63802e63 100644 --- a/functions/script_create.sh +++ b/functions/script_create.sh @@ -83,10 +83,11 @@ do echo echo "Additional Options" echo "------------------" - echo "6) -b | Back-up your ix-applications dataset, specify a number after -b" + echo "6) -b | Back-up your ix-applications dataset" echo "7) -s | sync catalog" echo "8) -p | Prune unused/old docker images" - echo "9) --self-update | Updates HeavyScript prior to running any other commands" + echo "9) --ignore-img | Ignore container image updates" + echo "10) --self-update | Updates HeavyScript prior to running any other commands" echo echo "99) Remove Update Options, Restart" echo "00) Done making selections, proceed with update" @@ -150,7 +151,11 @@ do printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it update_selection+=("-p") ;; - 9 | --self-update ) + 9 | --ignore-img ) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "--ignore-img" && echo -e "\"--ignore-img\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("--ignore-img") + ;; + 10 | --self-update ) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "--self-update" && echo -e "\"--self-update\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it update_selection+=("--self-update") ;; diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 58cb332f..40dbdee3 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -8,6 +8,7 @@ echo -e "🅄 🄿 🄳 🄰 🅃 🄴 🅂" echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" +[[ $ignore_image_update == "true" ]] && echo "Image Updates: Disabled" || echo "Image Updates: Enabled" pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") index=0 @@ -33,12 +34,15 @@ do elif grep -qs "^$app_name," failed 2>/dev/null; then failed_ver=$(grep "^$app_name," failed | awk -F ',' '{print $2}') if [[ "$failed_ver" == "$new_full_ver" ]] ; then - echo -e "\n$app_name" - echo -e "Skipping previously failed version:\n$new_full_ver" + echo -e "\n$app_name\nSkipping previously failed version:\n$new_full_ver" unset "array[$index]" else sed -i /"$app_name",/d failed fi + #Skip Image updates if ignore image updates is set to true + elif [[ $old_full_ver == "$new_full_ver" && $ignore_image_update == "true" ]]; then + echo -e "\n$app_name\nImage update, skipping.." + unset "array[$index]" fi ((index++)) done diff --git a/heavy_script.sh b/heavy_script.sh index d669aac8..0d39316f 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -52,6 +52,9 @@ do delete-backup) deleteBackup="true" ;; + ignore-img) + ignore_image_update="true" + ;; *) echo -e "Invalid Option \"--$OPTARG\"\n" help From 0d4969042bc874893a030e7d928dd33d1de4332b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 8 Sep 2022 23:19:12 +0000 Subject: [PATCH 785/823] Update README --- README.md | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index cfa6c6b8..609f09b4 100644 --- a/README.md +++ b/README.md @@ -23,25 +23,26 @@
## Update Arguments -| Flag | Example | Parameter | Description | -|--------------- |------------------------ |----------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| -U | -U
-U 5 | None or Integer | Update applications, ignoring major version changes
_Optionally, you can supply a number after the argument to update multiple applications at once_ | -| -u | -u
-u 5 | None or Integer | Update applications, do NOT update if there was a major version change
_Optionally, you can supply a number after the argument to update multiple applications at once_ | -| -b | -b 14 | Integer | Backup `ix-applications` dataset
_Creates backups up to the number you've chosen_ | -| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating
_List one application after another as shown in the example_ | -| -r | -r | None | Monitors applications after they update
If the app does not become "ACTIVE" after either:
The custom Timeout, or Default Timeout,
rollback the application. | -| -v | -v | None | Verbose Output
_Look at the bottom of this page for an example_ | -| -S | -S | None | Shutdown the application prior to updating it | -| -t | -t 150 | Integer | Time in seconds that HeavyScript will wait for an application to no longer be deploying before declaring failure
Default: 500 | -| -s | -s | None | Sync Catalogs prior to updating | -| -p | -p | None | Prune old/unused docker images | -| --self-update | --self-update | None | Updates HeavyScript prior to running any other commands | +| Flag | Example | Parameter | Description | +|---------------|------------------------|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| -U | -U
-U 5 | Optional Integer | Update applications, ignoring major version changes
_Optionally, you can supply a number after the argument to update multiple applications at once_ | +| -u | -u
-u 5 | Optional Integer | Update applications, do NOT update if there was a major version change
_Optionally, you can supply a number after the argument to update multiple applications at once_ | +| -b | -b 14 | Integer | Snapshot ix-applications dataset
_Creates backups UP TO the number you've chosen_ | +| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating
_List one application after another as shown in the example_ | +| -r | -r | | Monitors applications after they update
If the app does not become "ACTIVE" after the timeout, rollback the application. | +| -v | -v | | Verbose Output
_Look at the bottom of this page for an example_ | +| -S | -S | | Shutdown the application prior to updating it | +| -t | -t 400 | Integer | Time in seconds that HeavyScript will wait for an application to no longer be deploying before declaring failure
Default: 500 | +| -s | -s | | Sync Catalogs prior to updating | +| -p | -p | | Prune unused docker images | +| --ignore-img | --ignore-img | | Ignore container image updates | +| --self-update | --self-update | | Updates HeavyScript prior to running any other commands | ### Example #### Cron Job ``` -bash heavy_script.sh --self-update -b 10 -i nextcloud -i sonarr -t 600 -rsp -u 5 +bash heavy_script.sh --self-update -b 10 -i nextcloud -i sonarr -t 600 --ignore-img -rsp -u 5 ``` > `-b` is set to 10. Up to 10 snapshots of your ix-applications dataset will be saved @@ -50,6 +51,8 @@ bash heavy_script.sh --self-update -b 10 -i nextcloud -i sonarr -t 600 -rsp -u 5 > `-t` I set it to 600 seconds, this means the script will wait 600 seconds for the application to become ACTIVE before timing out and rolling back to the previous version since `-r` is used. +> `--ignore-img` Will not update the application if it is only a container image update + > `-r` Will rollback applications if they fail to deploy within the timeout, after updating. > `-s` will just sync the repositories, ensuring you are downloading the latest updates. @@ -61,6 +64,13 @@ bash heavy_script.sh --self-update -b 10 -i nextcloud -i sonarr -t 600 -rsp -u 5 > `--self-update` Will update the script prior to running anything else. +
+ +#### My Personal Cron Job +``` +bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 10 -rsp -u 10 +``` +

@@ -142,12 +152,13 @@ From here, you can just run Heavy_Script with `bash heavy_script.sh -ARGUMENTS` ## How to Update -### Built-In Option +### Built-In Option (Reccommended) ``` bash heavyscript.sh --self-update -b 10 -supr ``` > The important argument here is the `--self-update`, you can still use all of your same arguments with this option. +>> `--self-update` will place users on the latest tag, as well as showing the changelog when new releases come out. So this is the preferred method. Not using this method, will instead place the user on `main`, where the changes are tested, but not as rigerously as they are on the releases.
@@ -164,7 +175,7 @@ cd /mnt/speed/scripts/heavy_script ``` git pull ``` - +> This is not recommended because the changes to main are not tested as much as the changes that are pushed to releases are tested, think of this method of updating as being in development.

From a6213a65e3c0f05291c2becd8a93ea482592cbee Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 8 Sep 2022 17:26:23 -0600 Subject: [PATCH 786/823] fix container updates always marked as true --- functions/update_apps.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 40dbdee3..7bb79888 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -21,6 +21,8 @@ do new_chart_ver=$(echo "$app" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions + old_full_ver=$(echo "${array[$index]}" | awk -F ',' '{print $4}') #Upgraded From + new_full_ver=$(echo "${array[$index]}" | awk -F ',' '{print $5}') #Upraded To #Skip application if its on ignore list if printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" ; then From 63dc1ed002f8a986a3154ff728cc737f130d1412 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 8 Sep 2022 23:34:08 +0000 Subject: [PATCH 787/823] typo in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 609f09b4..5d2105ed 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ From here, you can just run Heavy_Script with `bash heavy_script.sh -ARGUMENTS` ## How to Update -### Built-In Option (Reccommended) +### Built-In Option (Recommended) ``` bash heavyscript.sh --self-update -b 10 -supr From 6b7c68317bae95b5627e02423cccbb659f7e5ff2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 14 Sep 2022 19:06:04 -0600 Subject: [PATCH 788/823] include truetool backups in overflow --- functions/backup.sh | 6 +++--- functions/update_apps.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 0ca69069..c1b2f4a0 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -7,11 +7,11 @@ echo_backup+=("Number of backups was set to $number_of_backups") date=$(date '+%Y_%m_%d_%H_%M_%S') [[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' &> /dev/null && echo_backup+=(HeavyScript_"$date") [[ -z "$verbose" ]] && echo_backup+=("\nNew Backup Name:") && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 &> /dev/null && echo_backup+=(HeavyScript_"$date") -mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") +mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep -E "HeavyScript_|TrueTool_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") if [[ ${#list_backups[@]} -gt "$number_of_backups" ]]; then echo_backup+=("\nDeleted the oldest backup(s) for exceeding limit:") overflow=$(( ${#list_backups[@]} - "$number_of_backups" )) - mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") + mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep -E "HeavyScript_|TrueTool_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") for i in "${list_overflow[@]}" do cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo_backup+=("Failed to delete $i") @@ -115,7 +115,7 @@ restore(){ while true do clear -x && echo "pulling restore points.." - list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t) + list_backups=$(cli -c 'app kubernetes list_backups' | grep -E "HeavyScript_|TrueTool_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t) if [[ -z "$list_backups" ]]; then echo "No HeavyScript restore points available" exit diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 7bb79888..9f54bb33 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -21,8 +21,8 @@ do new_chart_ver=$(echo "$app" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions - old_full_ver=$(echo "${array[$index]}" | awk -F ',' '{print $4}') #Upgraded From - new_full_ver=$(echo "${array[$index]}" | awk -F ',' '{print $5}') #Upraded To + old_full_ver=$(echo "$app" | awk -F ',' '{print $4}') #Upgraded From + new_full_ver=$(echo "$app" | awk -F ',' '{print $5}') #Upraded To #Skip application if its on ignore list if printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" ; then From b4e05510018d6af1a3fc13e8d328d3f8aaa07043 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 15 Sep 2022 10:21:53 -0600 Subject: [PATCH 789/823] remove } after var --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index fa2803b6..84187526 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -62,7 +62,7 @@ case "${#containers[@]}" in if [[ $selection == 0 ]]; then echo "Exiting.." exit - elif ! echo -e "$cont_search}" | grep -qs ^"$selection)" ; then + elif ! echo -e "$cont_search" | grep -qs ^"$selection)" ; then echo "Error: \"$selection\" was not an option.. Try again" sleep 3 continue From 8d50d27fe97934fcfe6c1942b6beb1b5bd15c0ee Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Wed, 21 Sep 2022 21:02:45 -0600 Subject: [PATCH 790/823] zfs list improvements for mount --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index 00c3cf93..8615a2b5 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -56,7 +56,7 @@ do #Grab data then output and mount data_name=$(echo "$pvc" | awk '{print $3}') volume_name=$(echo "$pvc" | awk '{print $4}') - full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') + full_path=$(zfs list -t filesystem -r "$pool"/ix-applications/releases/"$app"/volumes -o name -H | grep "$volume_name") if ! zfs set mountpoint=/heavyscript/"$data_name" "$full_path" ; then echo "Error: Failed to mount $app" exit 1 From c79273cf022711b5ece75b4904b8547f7cd46fd2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 22 Oct 2022 11:41:06 -0600 Subject: [PATCH 791/823] set dataset properties for restore --- functions/backup.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index c1b2f4a0..e5753072 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -152,8 +152,25 @@ do read -rt 120 -p "Would you like to proceed with restore? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in [Yy] | [Yy][Ee][Ss]) - echo -e "\nStarting Backup, this will take a LONG time." - cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || { echo "Failed to delete backup.."; exit; } + + # Set mountpoints to legacy prior to restore, ensures correct properties for the dataset are set + echo -e "\nSetting correct dataset properties.." + for pvc in $(zfs list -t filesystem -r "$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r")" -o name -H | grep "/ix-applications/" | grep "volumes/pvc") + do + if zfs set mountpoint=legacy "$pvc"; then + echo "Success for - \"$pvc\"" + else + echo "Error: Setting properties for \"$pvc\", failed.." + fi + done + echo "Finished setting properties.." + + # Beginning snapshot restore + echo -e "\nStarting restore, this will take a LONG time." + if ! cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"'; then + echo "Restore failed, exiting.." + exit 1 + fi exit ;; [Nn] | [Nn][Oo]) From 715f50b90660c4dc3d229993ad08cffea0c0b845 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 22 Oct 2022 12:02:25 -0600 Subject: [PATCH 792/823] reword message --- functions/backup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index e5753072..ccf662bc 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -153,8 +153,8 @@ do case $yesno in [Yy] | [Yy][Ee][Ss]) - # Set mountpoints to legacy prior to restore, ensures correct properties for the dataset are set - echo -e "\nSetting correct dataset properties.." + # Set mountpoints to legacy prior to restore, ensures correct properties for the are set + echo -e "\nSetting correct ZFS properties for application volumes.." for pvc in $(zfs list -t filesystem -r "$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r")" -o name -H | grep "/ix-applications/" | grep "volumes/pvc") do if zfs set mountpoint=legacy "$pvc"; then From 358fe207ca40077b6e22a7c9e0966a39d3114b0c Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Wed, 26 Oct 2022 20:12:59 -0600 Subject: [PATCH 793/823] turn readonly zfs property off --- functions/backup.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/functions/backup.sh b/functions/backup.sh index ccf662bc..c13847f0 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -152,10 +152,11 @@ do read -rt 120 -p "Would you like to proceed with restore? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in [Yy] | [Yy][Ee][Ss]) + pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r") # Set mountpoints to legacy prior to restore, ensures correct properties for the are set echo -e "\nSetting correct ZFS properties for application volumes.." - for pvc in $(zfs list -t filesystem -r "$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r")" -o name -H | grep "/ix-applications/" | grep "volumes/pvc") + for pvc in $(zfs list -t filesystem -r "$pool"/ix-applications -o name -H | grep "volumes/pvc") do if zfs set mountpoint=legacy "$pvc"; then echo "Success for - \"$pvc\"" @@ -163,6 +164,10 @@ do echo "Error: Setting properties for \"$pvc\", failed.." fi done + + # Ensure readonly is turned off + zfs set readonly=off "$pool"/ix-applications + echo "Finished setting properties.." # Beginning snapshot restore From 639f89962721147d48706305d508b4da250c744c Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Wed, 26 Oct 2022 20:28:26 -0600 Subject: [PATCH 794/823] error message for failed readonly disable --- functions/backup.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/functions/backup.sh b/functions/backup.sh index c13847f0..7985843b 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -166,7 +166,11 @@ do done # Ensure readonly is turned off - zfs set readonly=off "$pool"/ix-applications + if ! zfs set readonly=off "$pool"/ix-applications;then + echo -e "Error: Failed to set ZFS ReadOnly to \"off\"" + echo -e "After the restore, attempt to run the following command manually:" + echo "zfs set readonly=off $pool/ix-applications" + fi echo "Finished setting properties.." From 9e29b7b0eb50f92811249bea9e45cc26fd65bd95 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 29 Oct 2022 16:01:52 -0600 Subject: [PATCH 795/823] tack on releases folder to ZFS restrict --- functions/backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/backup.sh b/functions/backup.sh index 7985843b..7be2305e 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -156,7 +156,7 @@ do # Set mountpoints to legacy prior to restore, ensures correct properties for the are set echo -e "\nSetting correct ZFS properties for application volumes.." - for pvc in $(zfs list -t filesystem -r "$pool"/ix-applications -o name -H | grep "volumes/pvc") + for pvc in $(zfs list -t filesystem -r "$pool"/ix-applications/releases -o name -H | grep "volumes/pvc") do if zfs set mountpoint=legacy "$pvc"; then echo "Success for - \"$pvc\"" From 2a8c9645832a54ae5195024aca8e8ea850bfc2f1 Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Tue, 1 Nov 2022 18:55:53 -0600 Subject: [PATCH 796/823] match app name until comma in mount --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index 8615a2b5..7badfc58 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -40,7 +40,7 @@ do pvc=$(echo -e "$list" | grep ^"$selection)") #Stop applicaiton if not stopped - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + status=$(cli -m csv -c 'app chart_release query name,status' | grep "^$app," | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then echo -e "\nStopping $app prior to mount" if ! cli -c 'app chart_release scale release_name='\""$app"\"\ 'scale_options={"replica_count": 0}' &> /dev/null; then From 94d8c610199eaf028050d479cb2b79ea5e883051 Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Wed, 14 Dec 2022 11:40:26 -0700 Subject: [PATCH 797/823] update prune --- functions/misc.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/functions/misc.sh b/functions/misc.sh index 407c1c41..fd0d3845 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -19,7 +19,10 @@ export -f sync prune(){ echo -e "🄿 🅁 🅄 🄽 🄴" echo "Pruned Docker Images" -docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" +if ! cli -c 'app container config prune prune_options={"remove_unused_images": true, "remove_stopped_containers": true}' | head -n -4: +then + echo "Failed to Prune Docker Images" +fi } export -f prune From 9af1148705a984f6fda1afdd0a994fd7ca342f47 Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Wed, 14 Dec 2022 11:43:04 -0700 Subject: [PATCH 798/823] whoops --- functions/misc.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index fd0d3845..5c75583b 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -19,8 +19,7 @@ export -f sync prune(){ echo -e "🄿 🅁 🅄 🄽 🄴" echo "Pruned Docker Images" -if ! cli -c 'app container config prune prune_options={"remove_unused_images": true, "remove_stopped_containers": true}' | head -n -4: -then +if ! cli -c 'app container config prune prune_options={"remove_unused_images": true, "remove_stopped_containers": true}' | head -n -4; then echo "Failed to Prune Docker Images" fi } From af302499879a487433fab0e4c12c675e988d1147 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 15 Dec 2022 00:04:18 -0700 Subject: [PATCH 799/823] prune based on current version --- functions/misc.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index 5c75583b..7f4f51de 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -18,9 +18,15 @@ export -f sync prune(){ echo -e "🄿 🅁 🅄 🄽 🄴" -echo "Pruned Docker Images" -if ! cli -c 'app container config prune prune_options={"remove_unused_images": true, "remove_stopped_containers": true}' | head -n -4; then - echo "Failed to Prune Docker Images" +version="$(cli -c 'system version' | awk -F '-' '{print $3}' | tr -d " \t\r\.")" +if (( "$version" <= 22120 )); then + if ! cli -c 'app container config prune prune_options={"remove_unused_images": true, "remove_stopped_containers": true}' | head -n -4; then + echo "Failed to Prune Docker Images" + fi +else + if ! docker image prune -af | grep "^Total"; then + echo "Failed to Prune Docker Images" + fi fi } export -f prune From a3c052dce6a562bdbb2b817e3574f8f9da8b76c9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 15 Dec 2022 07:10:21 +0000 Subject: [PATCH 800/823] reverse gt symbol --- functions/misc.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index 7f4f51de..c14576d0 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -19,7 +19,7 @@ export -f sync prune(){ echo -e "🄿 🅁 🅄 🄽 🄴" version="$(cli -c 'system version' | awk -F '-' '{print $3}' | tr -d " \t\r\.")" -if (( "$version" <= 22120 )); then +if (( "$version" >= 22120 )); then if ! cli -c 'app container config prune prune_options={"remove_unused_images": true, "remove_stopped_containers": true}' | head -n -4; then echo "Failed to Prune Docker Images" fi @@ -97,4 +97,4 @@ echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" echo exit } -export -f help \ No newline at end of file +export -f help From 36d92ddeb071750c4e9b4ab259f3a9fe86958d64 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 15 Dec 2022 00:24:59 -0700 Subject: [PATCH 801/823] only print first 4 numbers of version --- functions/misc.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index c14576d0..66b93410 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -18,8 +18,8 @@ export -f sync prune(){ echo -e "🄿 🅁 🅄 🄽 🄴" -version="$(cli -c 'system version' | awk -F '-' '{print $3}' | tr -d " \t\r\.")" -if (( "$version" >= 22120 )); then +version="$(cli -c 'system version' | awk -F '-' '{print $3}' | awk -F '.' '{print $1 $2}' | tr -d " \t\r\.")" +if (( "$version" >= 2212 )); then if ! cli -c 'app container config prune prune_options={"remove_unused_images": true, "remove_stopped_containers": true}' | head -n -4; then echo "Failed to Prune Docker Images" fi From bcadb12e114b1efea3ef5738eacbb19fdc53dc01 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 15 Dec 2022 17:24:29 -0700 Subject: [PATCH 802/823] warning message when restoring to prev version --- functions/backup.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/functions/backup.sh b/functions/backup.sh index 7be2305e..c0acb93f 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -144,6 +144,43 @@ do fi break done + + + # Get the date of system version and when it was updated + current_version=$(cli -m csv -c 'system version' | awk -F '-' '{print $3}') + when_updated=$(cli -m csv -c 'system bootenv query created,realname' | grep "$current_version",\ + | awk -F ',' '{print $2}' | sed 's/[T|-]/_/g' | sed 's/:/_/g' | awk -F '_' '{print $1 $2 $3 $4 $5}') + + + # Get the date of the chosen restore point + restore_point_date=$(echo "$restore_point" | awk -F '_' '{print $2 $3 $4 $5 $6}' | tr -d "_") + + + # Compare the dates + if (("$restore_point_date" < "$when_updated" )); then + clear -x + echo "The restore point you have chosen is from an older version of Truenas Scale" + echo "This is not recommended, as it may cause issues with the system" + if read -rt 120 -p "Would you like to proceed? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; }; then + case $yesno in + [Yy] | [Yy][Ee][Ss]) + echo "Proceeding.." + sleep 3 + ;; + [Nn] | [Nn][Oo]) + echo "Exiting" + exit + ;; + *) + echo "That was not an option, try again" + sleep 3 + continue + ;; + esac + fi + fi + + while true do clear -x From 948b3fd5adc3e7ede513126b78fb6f35a4bcce48 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 15 Dec 2022 19:57:32 -0700 Subject: [PATCH 803/823] add while loop and general improvements --- functions/backup.sh | 326 ++++++++++++++++++++++---------------------- 1 file changed, 166 insertions(+), 160 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index c0acb93f..43b44b70 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -31,193 +31,146 @@ export -f backup deleteBackup(){ +clear -x && echo "pulling all restore points.." +list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t) +if [[ -z "$list_backups" ]]; then + echo "No restore points available" + exit +fi + +#Select a restore point while true do - clear -x && echo "pulling all restore points.." - list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t) - if [[ -z "$list_backups" ]]; then - echo "No restore points available" + clear -x + title + echo -e "Choose a Restore Point to Delete\nThese may be out of order if they are not HeavyScript backups" + echo "$list_backups" + echo + echo "0) Exit" + read -rt 240 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') + if [[ $selection == 0 ]]; then + echo "Exiting.." exit + elif [[ -z "$selection" ]]; then + echo "Your selection cannot be empty" + sleep 3 + continue + elif [[ -z "$restore_point" ]]; then + echo "Invalid Selection: $selection, was not an option" + sleep 3 + continue fi - while true - do - clear -x - title - echo -e "Choose a Restore Point to Delete\nThese may be out of order if they are not HeavyScript backups" - echo "$list_backups" - echo - echo "0) Exit" - read -rt 240 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') - if [[ $selection == 0 ]]; then - echo "Exiting.." + break # Break out of the loop if all of the If statement checks above are untrue +done + +#Confirm deletion +while true +do + clear -x + echo -e "WARNING:\nYou CANNOT go back after deleting your restore point" + echo -e "\n\nYou have chosen:\n$restore_point\n\n" + read -rt 120 -p "Would you like to proceed with deletion? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } + case $yesno in + [Yy] | [Yy][Ee][Ss]) + echo -e "\nDeleting $restore_point" + cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null || { echo "Failed to delete backup.."; exit; } + echo "Sucessfully deleted" + break + ;; + [Nn] | [Nn][Oo]) + echo "Exiting" exit - elif [[ -z "$selection" ]]; then - echo "Your selection cannot be empty" + ;; + *) + echo "That was not an option, try again" sleep 3 continue - elif [[ -z "$restore_point" ]]; then - echo "Invalid Selection: $selection, was not an option" - sleep 3 + ;; + esac +done + +#Check if there are more backups to delete +while true +do + read -rt 120 -p "Delete more backups? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } + case $yesno in + [Yy] | [Yy][Ee][Ss]) + break + ;; + [Nn] | [Nn][Oo]) + exit + ;; + *) + echo "$yesno was not an option, try again" + sleep 2 continue - fi - break # Break out of the loop if all of the If statement checks above are untrue - done - while true - do - clear -x - echo -e "WARNING:\nYou CANNOT go back after deleting your restore point" - echo -e "\n\nYou have chosen:\n$restore_point\n\n" - read -rt 120 -p "Would you like to proceed with deletion? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } - case $yesno in - [Yy] | [Yy][Ee][Ss]) - echo -e "\nDeleting $restore_point" - cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null || { echo "Failed to delete backup.."; exit; } - echo "Sucessfully deleted" - break - ;; - [Nn] | [Nn][Oo]) - echo "Exiting" - exit - ;; - *) - echo "That was not an option, try again" - sleep 3 - continue - ;; - esac - done - while true - do - read -rt 120 -p "Delete more backups? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } - case $yesno in - [Yy] | [Yy][Ee][Ss]) - break - ;; - [Nn] | [Nn][Oo]) - exit - ;; - *) - echo "$yesno was not an option, try again" - sleep 2 - continue - ;; + ;; - esac + esac - done done } export -f deleteBackup restore(){ +clear -x && echo "pulling restore points.." +list_backups=$(cli -c 'app kubernetes list_backups' | grep -E "HeavyScript_|TrueTool_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t) +if [[ -z "$list_backups" ]]; then + echo "No HeavyScript restore points available" + exit +fi + +#Select a restore point while true do - clear -x && echo "pulling restore points.." - list_backups=$(cli -c 'app kubernetes list_backups' | grep -E "HeavyScript_|TrueTool_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t) - if [[ -z "$list_backups" ]]; then - echo "No HeavyScript restore points available" + clear -x + title + echo "Choose a Restore Point" + echo "$list_backups" + echo + echo "0) Exit" + read -rt 240 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') + if [[ $selection == 0 ]]; then + echo "Exiting.." exit + elif [[ -z "$selection" ]]; then + echo "Your selection cannot be empty" + sleep 3 + continue + elif [[ -z "$restore_point" ]]; then + echo "Invalid Selection: $selection, was not an option" + sleep 3 + continue fi - while true - do - clear -x - title - echo "Choose a Restore Point" - echo "$list_backups" - echo - echo "0) Exit" - read -rt 240 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') - if [[ $selection == 0 ]]; then - echo "Exiting.." - exit - elif [[ -z "$selection" ]]; then - echo "Your selection cannot be empty" - sleep 3 - continue - elif [[ -z "$restore_point" ]]; then - echo "Invalid Selection: $selection, was not an option" - sleep 3 - continue - fi - break - done + break +done - # Get the date of system version and when it was updated - current_version=$(cli -m csv -c 'system version' | awk -F '-' '{print $3}') - when_updated=$(cli -m csv -c 'system bootenv query created,realname' | grep "$current_version",\ - | awk -F ',' '{print $2}' | sed 's/[T|-]/_/g' | sed 's/:/_/g' | awk -F '_' '{print $1 $2 $3 $4 $5}') +# Get the date of system version and when it was updated +current_version=$(cli -m csv -c 'system version' | awk -F '-' '{print $3}') +when_updated=$(cli -m csv -c 'system bootenv query created,realname' | grep "$current_version",\ +| awk -F ',' '{print $2}' | sed 's/[T|-]/_/g' | sed 's/:/_/g' | awk -F '_' '{print $1 $2 $3 $4 $5}') - # Get the date of the chosen restore point - restore_point_date=$(echo "$restore_point" | awk -F '_' '{print $2 $3 $4 $5 $6}' | tr -d "_") +# Get the date of the chosen restore point +restore_point_date=$(echo "$restore_point" | awk -F '_' '{print $2 $3 $4 $5 $6}' | tr -d "_") - # Compare the dates - if (("$restore_point_date" < "$when_updated" )); then - clear -x - echo "The restore point you have chosen is from an older version of Truenas Scale" - echo "This is not recommended, as it may cause issues with the system" - if read -rt 120 -p "Would you like to proceed? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; }; then - case $yesno in - [Yy] | [Yy][Ee][Ss]) - echo "Proceeding.." - sleep 3 - ;; - [Nn] | [Nn][Oo]) - echo "Exiting" - exit - ;; - *) - echo "That was not an option, try again" - sleep 3 - continue - ;; - esac - fi - fi - - - while true - do - clear -x - echo -e "WARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" - echo -e "\n\nYou have chosen:\n$restore_point\n\n" - read -rt 120 -p "Would you like to proceed with restore? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } +# Compare the dates +while (("$restore_point_date" < "$when_updated" )) +do + clear -x + echo "The restore point you have chosen is from an older version of Truenas Scale" + echo "This is not recommended, as it may cause issues with the system" + if read -rt 120 -p "Would you like to proceed? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; }; then case $yesno in [Yy] | [Yy][Ee][Ss]) - pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r") - - # Set mountpoints to legacy prior to restore, ensures correct properties for the are set - echo -e "\nSetting correct ZFS properties for application volumes.." - for pvc in $(zfs list -t filesystem -r "$pool"/ix-applications/releases -o name -H | grep "volumes/pvc") - do - if zfs set mountpoint=legacy "$pvc"; then - echo "Success for - \"$pvc\"" - else - echo "Error: Setting properties for \"$pvc\", failed.." - fi - done - - # Ensure readonly is turned off - if ! zfs set readonly=off "$pool"/ix-applications;then - echo -e "Error: Failed to set ZFS ReadOnly to \"off\"" - echo -e "After the restore, attempt to run the following command manually:" - echo "zfs set readonly=off $pool/ix-applications" - fi - - echo "Finished setting properties.." - - # Beginning snapshot restore - echo -e "\nStarting restore, this will take a LONG time." - if ! cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"'; then - echo "Restore failed, exiting.." - exit 1 - fi - exit + echo "Proceeding.." + sleep 3 + break ;; [Nn] | [Nn][Oo]) echo "Exiting" @@ -229,7 +182,60 @@ do continue ;; esac - done + fi done + + +#Confirm restore +while true +do + clear -x + echo -e "WARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" + echo -e "\n\nYou have chosen:\n$restore_point\n\n" + read -rt 120 -p "Would you like to proceed with restore? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } + case $yesno in + [Yy] | [Yy][Ee][Ss]) + pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r") + + # Set mountpoints to legacy prior to restore, ensures correct properties for the are set + echo -e "\nSetting correct ZFS properties for application volumes.." + for pvc in $(zfs list -t filesystem -r "$pool"/ix-applications/releases -o name -H | grep "volumes/pvc") + do + if zfs set mountpoint=legacy "$pvc"; then + echo "Success for - \"$pvc\"" + else + echo "Error: Setting properties for \"$pvc\", failed.." + fi + done + + # Ensure readonly is turned off + if ! zfs set readonly=off "$pool"/ix-applications;then + echo -e "Error: Failed to set ZFS ReadOnly to \"off\"" + echo -e "After the restore, attempt to run the following command manually:" + echo "zfs set readonly=off $pool/ix-applications" + fi + + echo "Finished setting properties.." + + # Beginning snapshot restore + echo -e "\nStarting restore, this will take a LONG time." + if ! cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"'; then + echo "Restore failed, exiting.." + exit 1 + fi + exit + ;; + [Nn] | [Nn][Oo]) + echo "Exiting" + exit + ;; + *) + echo "That was not an option, try again" + sleep 3 + continue + ;; + esac +done + } export -f restore \ No newline at end of file From 27eec996aaeb98fc07017c23baeafb39a548876d Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Sat, 17 Dec 2022 20:27:53 -0700 Subject: [PATCH 804/823] Edit restore message on scale ver change --- functions/backup.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/functions/backup.sh b/functions/backup.sh index 43b44b70..3d795cd2 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -149,9 +149,13 @@ do done +# Boot Query +boot_query=$(cli -m csv -c 'system bootenv query created,realname') + + # Get the date of system version and when it was updated current_version=$(cli -m csv -c 'system version' | awk -F '-' '{print $3}') -when_updated=$(cli -m csv -c 'system bootenv query created,realname' | grep "$current_version",\ +when_updated=$(echo "$boot_query" | grep "$current_version",\ | awk -F ',' '{print $2}' | sed 's/[T|-]/_/g' | sed 's/:/_/g' | awk -F '_' '{print $1 $2 $3 $4 $5}') @@ -159,12 +163,25 @@ when_updated=$(cli -m csv -c 'system bootenv query created,realname' | grep "$cu restore_point_date=$(echo "$restore_point" | awk -F '_' '{print $2 $3 $4 $5 $6}' | tr -d "_") +# Grab previous version +previous_version=$(echo "$boot_query" | sort -nr | grep -A 1 "$current_version," | tail -n 1) + + # Compare the dates while (("$restore_point_date" < "$when_updated" )) do clear -x echo "The restore point you have chosen is from an older version of Truenas Scale" echo "This is not recommended, as it may cause issues with the system" + echo + echo "Current SCALE Information:" + echo "Version: $current_version" + echo "When Updated: $(echo "$restore_point" | awk -F '_' '{print $2 "-" $3 "-" $4}')" + echo + echo "Restore Point SCALE Information:" + echo "Version: $(echo "$previous_version" | awk -F ',' '{print $1}')" + echo "When Updated: $(echo "$previous_version" | awk -F ',' '{print $2}' | awk -F 'T' '{print $1}')" + echo if read -rt 120 -p "Would you like to proceed? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; }; then case $yesno in [Yy] | [Yy][Ee][Ss]) From 12100cf3f04f7d94cb57c248f26360c3f7bbed66 Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Sun, 18 Dec 2022 10:41:04 -0700 Subject: [PATCH 805/823] initial backup validity checks --- functions/backup.sh | 110 +++++++++++++++++++++++++++++++------------- 1 file changed, 78 insertions(+), 32 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 3d795cd2..cd57075e 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -149,40 +149,87 @@ do done -# Boot Query -boot_query=$(cli -m csv -c 'system bootenv query created,realname') +## Check to see if empty PVC data is present in any of the applications ## +# Find all pv_info.json files two subfolders deep +pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r") +files=$(find "$(find /mnt/"$pool"/ix-applications/backups -maxdepth 0 )" -name pv_info.json | grep "$restore_point"); -# Get the date of system version and when it was updated -current_version=$(cli -m csv -c 'system version' | awk -F '-' '{print $3}') -when_updated=$(echo "$boot_query" | grep "$current_version",\ -| awk -F ',' '{print $2}' | sed 's/[T|-]/_/g' | sed 's/:/_/g' | awk -F '_' '{print $1 $2 $3 $4 $5}') +# Iterate over the list of files +for file in $files; do + # Check if the file only contains {} subfolders two deep + contents=$(cat $file) + if [[ "$contents" == '{}' ]]; then + # Print the file if it meets the criterion + file=$(echo "$file" | awk -F '/' '{print $7}') + borked_array+="$file\n" + borked=True + fi +done - -# Get the date of the chosen restore point -restore_point_date=$(echo "$restore_point" | awk -F '_' '{print $2 $3 $4 $5 $6}' | tr -d "_") - - -# Grab previous version -previous_version=$(echo "$boot_query" | sort -nr | grep -A 1 "$current_version," | tail -n 1) - - -# Compare the dates -while (("$restore_point_date" < "$when_updated" )) -do - clear -x - echo "The restore point you have chosen is from an older version of Truenas Scale" - echo "This is not recommended, as it may cause issues with the system" - echo - echo "Current SCALE Information:" - echo "Version: $current_version" - echo "When Updated: $(echo "$restore_point" | awk -F '_' '{print $2 "-" $3 "-" $4}')" - echo - echo "Restore Point SCALE Information:" - echo "Version: $(echo "$previous_version" | awk -F ',' '{print $1}')" - echo "When Updated: $(echo "$previous_version" | awk -F ',' '{print $2}' | awk -F 'T' '{print $1}')" - echo - if read -rt 120 -p "Would you like to proceed? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; }; then +# If there is empty PVC data, exit +if [[ $borked == True ]]; then + echo "Warning!:" + echo "The following applications have empty PVC data:" + for file in $borked_array; do + echo -e "$file" + done + echo "You need to ensure these applications are not supposed to have PVC data before proceeding" + while true + do + read -rt 120 -p "Would you like to proceed? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } + case $yesno in + [Yy] | [Yy][Ee][Ss]) + echo "Proceeding.." + sleep 3 + break + ;; + [Nn] | [Nn][Oo]) + echo "Exiting" + exit + ;; + *) + echo "That was not an option, try again" + sleep 3 + continue + ;; + esac + done +fi + + + +## Check the restore point, and ensure it is the same version as the current system ## +# Boot Query +boot_query=$(cli -m csv -c 'system bootenv query created,realname') + +# Get the date of system version and when it was updated +current_version=$(cli -m csv -c 'system version' | awk -F '-' '{print $3}') +when_updated=$(echo "$boot_query" | grep "$current_version",\ +| awk -F ',' '{print $2}' | sed 's/[T|-]/_/g' | sed 's/:/_/g' | awk -F '_' '{print $1 $2 $3 $4 $5}') + +# Get the date of the chosen restore point +restore_point_date=$(echo "$restore_point" | awk -F '_' '{print $2 $3 $4 $5 $6}' | tr -d "_") + +# Grab previous version +previous_version=$(echo "$boot_query" | sort -nr | grep -A 1 "$current_version," | tail -n 1) + +# Compare the dates +while (("$restore_point_date" < "$when_updated" )) +do + clear -x + echo "The restore point you have chosen is from an older version of Truenas Scale" + echo "This is not recommended, as it may cause issues with the system" + echo + echo "Current SCALE Information:" + echo "Version: $current_version" + echo "When Updated: $(echo "$restore_point" | awk -F '_' '{print $2 "-" $3 "-" $4}')" + echo + echo "Restore Point SCALE Information:" + echo "Version: $(echo "$previous_version" | awk -F ',' '{print $1}')" + echo "When Updated: $(echo "$previous_version" | awk -F ',' '{print $2}' | awk -F 'T' '{print $1}')" + echo + read -rt 120 -p "Would you like to proceed? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in [Yy] | [Yy][Ee][Ss]) echo "Proceeding.." @@ -199,7 +246,6 @@ do continue ;; esac - fi done From 6bbfa17e1c8100682d983926d623b937bb4749a7 Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Sun, 18 Dec 2022 13:26:56 -0700 Subject: [PATCH 806/823] Hot patch --- functions/menu.sh | 4 +++ functions/misc.sh | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index 164bdd7b..67543d08 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -13,6 +13,7 @@ echo "4) Backup Options" echo "5) Update HeavyScript" echo "6) Update Applications" echo "7) Command to Container" +echo "8) Patch 22.12.0" echo echo "0) Exit" read -rt 120 -p "Please select an option by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } @@ -79,6 +80,9 @@ case $selection in 7) cmd_to_container ;; + 8) + patch_2212_backups + ;; *) echo "\"$selection\" was not an option, please try agian" && sleep 3 && menu ;; diff --git a/functions/misc.sh b/functions/misc.sh index 66b93410..decf8899 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -98,3 +98,76 @@ echo exit } export -f help + + + +patch_2212_backups(){ +clear -x +#Check TrueNAS version, skip if not 22.12.0 +if ! [ "$(cli -m csv -c 'system version' | awk -F '-' '{print $3}')" == "22.12.0" ]; then + echo "This patch does not apply to your version of TrueNAS" + return +fi + + +#Description +echo "This patch will fix the issue with backups not restoring properly" +echo "Due to Ix-Systems not saving PVC in backups, this patch will fix that" +echo "Otherwise backups will not restore properly" +echo "You only need to run this patch once, it will not run again" +echo + + +#Download patch +echo "Downloading Backup Patch" +if ! wget -q https://github.com/truecharts/truetool/raw/main/hotpatch/2212/HP1.patch; then + echo "Failed to download Backup Patch" + exit +else + echo "Downloaded Backup Patch" +fi + +echo + +# Apply patch +echo "Applying Backup Patch" +if patch -N --reject-file=/dev/null -s -p0 -d /usr/lib/python3/dist-packages/middlewared/ < HP1.patch &>/dev/null; then + echo "Backup Patch applied" + rm -rf HP1.patch +else + echo "Backup Patch already applied" + rm -rf HP1.patch + exit +fi + +echo + +#Restart middlewared +while true +do + echo "We need to restart middlewared to finish the patch" + echo "This will cause a short downtime for your system" + read -rt 120 -p "Would you like to proceed? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } + case $yesno in + [Yy] | [Yy][Ee][Ss]) + echo "Restarting middlewared" + service middlewared restart & + wait $! + break + ;; + [Nn] | [Nn][Oo]) + echo "Exiting" + echo "Please restart middlewared manually" + echo "You can do: service middlewared restart" + exit + ;; + *) + echo "That was not an option, try again" + sleep 3 + continue + ;; + esac +done +} +export -f patchv22120 + From 5083926056f7be3512a80e86f8f142e9ed3e05ef Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Sun, 18 Dec 2022 13:28:52 -0700 Subject: [PATCH 807/823] edit wording --- functions/misc.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions/misc.sh b/functions/misc.sh index decf8899..43e2947a 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -153,6 +153,8 @@ do echo "Restarting middlewared" service middlewared restart & wait $! + echo "Restarted middlewared" + echo "You are set, there is no need to run this patch again" break ;; [Nn] | [Nn][Oo]) From 8ef2a91a73c64a8079c7a1297e8830a92dbddf78 Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Sun, 18 Dec 2022 13:31:25 -0700 Subject: [PATCH 808/823] last commit on wording --- functions/misc.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/misc.sh b/functions/misc.sh index 43e2947a..372b42d4 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -146,7 +146,8 @@ echo while true do echo "We need to restart middlewared to finish the patch" - echo "This will cause a short downtime for your system" + echo "This will cause a short downtime for some minor services approximately 10-30 seconds" + echo "Applications should not be affected" read -rt 120 -p "Would you like to proceed? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in [Yy] | [Yy][Ee][Ss]) From e653880e8ea772ee124fc03cd95b4ee87378472d Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Sun, 18 Dec 2022 15:34:22 -0700 Subject: [PATCH 809/823] update backup validation --- functions/backup.sh | 62 ++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index cd57075e..199b83fe 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -151,50 +151,53 @@ done ## Check to see if empty PVC data is present in any of the applications ## -# Find all pv_info.json files two subfolders deep +# Find all pv_info.json files two subfolders deep with the restore point name pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r") files=$(find "$(find /mnt/"$pool"/ix-applications/backups -maxdepth 0 )" -name pv_info.json | grep "$restore_point"); # Iterate over the list of files for file in $files; do - # Check if the file only contains {} subfolders two deep - contents=$(cat $file) + # Check if the file only contains {} subfolders + contents=$(cat "$file") if [[ "$contents" == '{}' ]]; then # Print the file if it meets the criterion file=$(echo "$file" | awk -F '/' '{print $7}') - borked_array+="$file\n" - borked=True + borked_array+=("${file}") fi done -# If there is empty PVC data, exit + +# Grab applications that are supposed to have PVC data +mapfile -t apps_with_pvc < <(k3s kubectl get pvc -A | sort -u | awk '{print $1 "\t" $2 "\t" $4}' | sed "s/^0/ /" | awk '{print $1}' | cut -c 4-) + + +# Iterate over the list of applications with empty PVC data +# Unset the application if it is not supposed to have PVC data +index=0 +for app in "${borked_array[@]}"; do + if ! printf '%s\0' "${apps_with_pvc[@]}" | grep -iFxqz "${app}" ; then + unset "borked_array[$index]" + else + borked=True + fi + index+=1 +done + + + +# If there is still empty PVC data, exit if [[ $borked == True ]]; then echo "Warning!:" echo "The following applications have empty PVC data:" - for file in $borked_array; do - echo -e "$file" + for app in "${borked_array[@]}"; do + echo -e "$app" done - echo "You need to ensure these applications are not supposed to have PVC data before proceeding" - while true - do - read -rt 120 -p "Would you like to proceed? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } - case $yesno in - [Yy] | [Yy][Ee][Ss]) - echo "Proceeding.." - sleep 3 - break - ;; - [Nn] | [Nn][Oo]) - echo "Exiting" - exit - ;; - *) - echo "That was not an option, try again" - sleep 3 - continue - ;; - esac - done + echo "We have no choice but to exit" + echo "If you were to restore, you would lose all of your application data" + echo "If you are on Bluefin version: 22.12.0, and have not yet ran the patch, you will need to run it" + echo "Afterwards you will be able to create backups and restore them" + echo "This is a known ix-systems bug, and has nothing to do with HeavyScript" + exit fi @@ -220,6 +223,7 @@ do clear -x echo "The restore point you have chosen is from an older version of Truenas Scale" echo "This is not recommended, as it may cause issues with the system" + echo "Either that, or your systems date is incorrect.." echo echo "Current SCALE Information:" echo "Version: $current_version" From c65d93bdba7e3455846e6bcb378ac1bd110983e8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 18 Dec 2022 23:05:44 +0000 Subject: [PATCH 810/823] Fix python style incremental --- functions/backup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 199b83fe..1b05177e 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -180,7 +180,7 @@ for app in "${borked_array[@]}"; do else borked=True fi - index+=1 + ((index++)) done @@ -305,4 +305,4 @@ do done } -export -f restore \ No newline at end of file +export -f restore From d50290ba21eff21f9a37632e9fa03cba995a521c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 19 Dec 2022 06:34:53 -0700 Subject: [PATCH 811/823] remove non-existant func export --- functions/misc.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/misc.sh b/functions/misc.sh index 372b42d4..25501cf7 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -172,5 +172,4 @@ do esac done } -export -f patchv22120 From b13eaf0ff6de5a0ec723effeb024c7970f16f407 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 20 Dec 2022 07:08:42 -0700 Subject: [PATCH 812/823] shellcheck --- .github/workflows/shellcheck.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/shellcheck.yml diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 00000000..29c41a73 --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,21 @@ +on: + push: + pull_request: + workflow_dispatch: + +name: ShellCheck + +jobs: + ShellCheck: + name: ShellCheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + env: + SHELLCHECK_OPTS: -e SC2154 + with: + check_together: 'yes' + format: gcc + From d86250e14dfc612198e58e3e45738d65de67cb65 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 20 Dec 2022 11:27:51 -0700 Subject: [PATCH 813/823] remove invalid errors --- functions/backup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions/backup.sh b/functions/backup.sh index 1b05177e..3a2e9b71 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -32,7 +32,9 @@ export -f backup deleteBackup(){ clear -x && echo "pulling all restore points.." +# shellcheck disable=SC2178 list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t) +# shellcheck disable=SC2128 if [[ -z "$list_backups" ]]; then echo "No restore points available" exit From ed67c026b5b88b99fdec413057ac45f244b08d87 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 20 Dec 2022 11:31:26 -0700 Subject: [PATCH 814/823] remove shellcheck error --- functions/cmd_to_container.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 84187526..e6f36f48 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -95,6 +95,8 @@ do clear -x title read -rt 500 -p "What command do you want to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } + # shellcheck disable=SC2086 + # Quoting $command as suggested, causes the k3s command to fail k3s crictl exec -it "$container_id" $command break ;; From ce012b28901504e2cba854761551dbc5c548fd80 Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Mon, 26 Dec 2022 14:36:35 -0700 Subject: [PATCH 815/823] backup patch 2 --- functions/menu.sh | 4 +++ functions/misc.sh | 58 +++++++++++++++++++++++++++++++++++++ patches/backup_patch2.patch | 11 +++++++ 3 files changed, 73 insertions(+) create mode 100644 patches/backup_patch2.patch diff --git a/functions/menu.sh b/functions/menu.sh index 67543d08..82a04e03 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -14,6 +14,7 @@ echo "5) Update HeavyScript" echo "6) Update Applications" echo "7) Command to Container" echo "8) Patch 22.12.0" +echo "9) Patch 22.12.0 (2)" echo echo "0) Exit" read -rt 120 -p "Please select an option by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } @@ -83,6 +84,9 @@ case $selection in 8) patch_2212_backups ;; + 9) + patch_2212_backups2 + ;; *) echo "\"$selection\" was not an option, please try agian" && sleep 3 && menu ;; diff --git a/functions/misc.sh b/functions/misc.sh index 25501cf7..efb503d6 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -173,3 +173,61 @@ do done } + +patch_2212_backups2(){ +clear -x +#Check TrueNAS version, skip if not 22.12.0 +if ! [ "$(cli -m csv -c 'system version' | awk -F '-' '{print $3}')" == "22.12.0" ]; then + echo "This patch does not apply to your version of TrueNAS" + return +fi + + +#Description +echo "This patch will fix the issue certain applicattions breaking backups" +echo "You only need to run this patch once, it will not run again" +echo + + +# Apply patch +echo "Applying Backup Patch" +if patch -N --reject-file=/dev/null -s -p0 -d /usr/lib/python3/dist-packages/middlewared/plugins/kubernetes_linux/backup.py < patches/backup_patch2.patch &>/dev/null; then + echo "Backup Patch applied" +else + echo "Backup Patch already applied" + exit +fi + +echo + +#Restart middlewared +while true +do + echo "We need to restart middlewared to finish the patch" + echo "This will cause a short downtime for some minor services approximately 10-30 seconds" + echo "Applications should not be affected" + read -rt 120 -p "Would you like to proceed? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } + case $yesno in + [Yy] | [Yy][Ee][Ss]) + echo "Restarting middlewared" + service middlewared restart & + wait $! + echo "Restarted middlewared" + echo "You are set, there is no need to run this patch again" + break + ;; + [Nn] | [Nn][Oo]) + echo "Exiting" + echo "Please restart middlewared manually" + echo "You can do: service middlewared restart" + exit + ;; + *) + echo "That was not an option, try again" + sleep 3 + continue + ;; + esac +done +} + diff --git a/patches/backup_patch2.patch b/patches/backup_patch2.patch new file mode 100644 index 00000000..3ce5de06 --- /dev/null +++ b/patches/backup_patch2.patch @@ -0,0 +1,11 @@ +--- /usr/lib/python3/dist-packages/middlewared/plugins/kubernetes_linux/backup.py 2022-12-13 05:32:23.000000000 -0700 ++++ backups.patch 2022-12-26 14:14:25.075037767 -0700 +@@ -61,7 +61,8 @@ + ['metadata.namespace', '=', chart_release['namespace']] + ] + ) +- for secret in sorted(secrets, key=lambda d: d['metadata']['name']): ++ # We ignore this keeping in line with helm behaviour where the secret malformed is ignored by helm ++ for secret in sorted(filter(lambda d: d.get('data'), secrets), key=lambda d: d['metadata']['name']): + with open(os.path.join(secrets_dir, secret['metadata']['name']), 'w') as f: + f.write(self.middleware.call_sync('k8s.secret.export_to_yaml_internal', secret)) \ No newline at end of file From 0d76ba4901bb8bd717920f39405a6f0f4282f6e7 Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Mon, 26 Dec 2022 14:45:05 -0700 Subject: [PATCH 816/823] try this --- heavy_script.sh | 2 +- patches/{backup_patch2.patch => backups.patch} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename patches/{backup_patch2.patch => backups.patch} (100%) diff --git a/heavy_script.sh b/heavy_script.sh index 0d39316f..91c0bc36 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -158,4 +158,4 @@ elif [[ "$sync" == "true" && -z "$number_of_backups" ]]; then # If only sync is fi [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander [[ "$prune" == "true" ]] && prune -exit 0 \ No newline at end of file +exit 0 diff --git a/patches/backup_patch2.patch b/patches/backups.patch similarity index 100% rename from patches/backup_patch2.patch rename to patches/backups.patch From 05aee2b22c35e0d2715fb31972a6723cd690fb0b Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Mon, 26 Dec 2022 14:45:52 -0700 Subject: [PATCH 817/823] rename command --- functions/misc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/misc.sh b/functions/misc.sh index efb503d6..7025d0b9 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -191,7 +191,7 @@ echo # Apply patch echo "Applying Backup Patch" -if patch -N --reject-file=/dev/null -s -p0 -d /usr/lib/python3/dist-packages/middlewared/plugins/kubernetes_linux/backup.py < patches/backup_patch2.patch &>/dev/null; then +if patch -N --reject-file=/dev/null -s -p0 -d /usr/lib/python3/dist-packages/middlewared/plugins/kubernetes_linux/backup.py < patches/backups.patch &>/dev/null; then echo "Backup Patch applied" else echo "Backup Patch already applied" From a8fbcfcef71515ac5ad73b495992606462ba9815 Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Mon, 26 Dec 2022 14:47:33 -0700 Subject: [PATCH 818/823] remove directory argument --- functions/misc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/misc.sh b/functions/misc.sh index 7025d0b9..408fcd58 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -191,7 +191,7 @@ echo # Apply patch echo "Applying Backup Patch" -if patch -N --reject-file=/dev/null -s -p0 -d /usr/lib/python3/dist-packages/middlewared/plugins/kubernetes_linux/backup.py < patches/backups.patch &>/dev/null; then +if patch -N --reject-file=/dev/null -s -p0 /usr/lib/python3/dist-packages/middlewared/plugins/kubernetes_linux/backup.py < patches/backups.patch &>/dev/null; then echo "Backup Patch applied" else echo "Backup Patch already applied" From b5069589865ba908ee23f425d02273f90b91a4f0 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Tue, 27 Dec 2022 11:51:56 +0100 Subject: [PATCH 819/823] remove current content --- .github/renovate-config.js | 25 ----- .github/renovate.json5 | 23 ---- .github/workflows/renovate.yml | 18 ---- .github/workflows/shellcheck.yml | 26 ----- .pre-commit-config.yaml | 21 ---- LICENSE | 29 ----- README.md | 131 ---------------------- hotpatch/2212/HP1.patch | 125 --------------------- hotpatch/2212/HP2.patch | 14 --- includes/backup.sh | 96 ----------------- includes/chores.sh | 42 -------- includes/colors.sh | 113 ------------------- includes/dns.sh | 27 ----- includes/help.sh | 35 ------ includes/mount.sh | 57 ---------- includes/no_args.sh | 72 ------------- includes/patch.sh | 18 ---- includes/title.sh | 22 ---- includes/update.sh | 123 --------------------- includes/update_self.sh | 31 ------ truetool.sh | 179 ------------------------------- 21 files changed, 1227 deletions(-) delete mode 100644 .github/renovate-config.js delete mode 100644 .github/renovate.json5 delete mode 100644 .github/workflows/renovate.yml delete mode 100644 .github/workflows/shellcheck.yml delete mode 100644 .pre-commit-config.yaml delete mode 100644 LICENSE delete mode 100644 README.md delete mode 100644 hotpatch/2212/HP1.patch delete mode 100644 hotpatch/2212/HP2.patch delete mode 100755 includes/backup.sh delete mode 100755 includes/chores.sh delete mode 100755 includes/colors.sh delete mode 100755 includes/dns.sh delete mode 100755 includes/help.sh delete mode 100755 includes/mount.sh delete mode 100755 includes/no_args.sh delete mode 100644 includes/patch.sh delete mode 100755 includes/title.sh delete mode 100755 includes/update.sh delete mode 100755 includes/update_self.sh delete mode 100755 truetool.sh diff --git a/.github/renovate-config.js b/.github/renovate-config.js deleted file mode 100644 index da91bb42..00000000 --- a/.github/renovate-config.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - dryRun: false, - username: 'truecharts-admin', - gitAuthor: 'truecharts-admin ', - onboarding: false, - platform: 'github', - repositories: [ - 'truecharts/truetool', - ], - packageRules: [ - { - description: 'lockFileMaintenance', - matchUpdateTypes: [ - 'pin', - 'digest', - 'patch', - 'minor', - 'major', - 'lockFileMaintenance', - ], - dependencyDashboardApproval: false, - stabilityDays: 0, - }, - ], -}; diff --git a/.github/renovate.json5 b/.github/renovate.json5 deleted file mode 100644 index de107f43..00000000 --- a/.github/renovate.json5 +++ /dev/null @@ -1,23 +0,0 @@ -{ - "semanticCommits": "enabled", - "extends": ["helpers:pinGitHubActionDigests"], - "dependencyDashboard": true, - "dependencyDashboardTitle": "Renovate Dashboard 🤖", - "suppressNotifications": ["prIgnoreNotification"], - "commitMessageTopic": "{{depName}}", - "commitMessageExtra": "to {{newVersion}}", - "commitMessageSuffix": "", - "rebaseWhen": "conflicted", - "prConcurrentLimit": 100, - "pinDigests": true, - "automerge": true, - "gitAuthor": "TrueCharts-Admin ", - "packageRules": [ - // Setup datasources for github actions - { - "matchManagers": ["github-actions"], - "commitMessageTopic": "github-action {{depName}} [skip ci]", - "automerge": true, - } - ] -} diff --git a/.github/workflows/renovate.yml b/.github/workflows/renovate.yml deleted file mode 100644 index 0816077f..00000000 --- a/.github/workflows/renovate.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Renovate -on: - workflow_dispatch: - schedule: - - cron: "0 */6 * * *" -jobs: - renovate: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0 - with: - token: ${{ secrets.BOT_TOKEN }} - - name: Self-hosted Renovate - uses: renovatebot/github-action@d4496c2d9b06c4e43b227fc3f331a434e99eaef5 # v34.73.3 - with: - configurationFile: .github/renovate-config.js - token: ${{ secrets.BOT_TOKEN }} diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml deleted file mode 100644 index 43b3800b..00000000 --- a/.github/workflows/shellcheck.yml +++ /dev/null @@ -1,26 +0,0 @@ -on: - push: - pull_request: - workflow_dispatch: - -name: 'Lint and Test' - -jobs: - shellcheck: - name: Shellcheck - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 - - name: Run ShellCheck - uses: ludeeus/action-shellcheck@master - with: - check_together: 'yes' - env: - SHELLCHECK_OPTS: -e SC2154 - - pre-commit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 - - uses: actions/setup-python@5ccb29d8773c3f3f653e1705f474dfaa8a06a912 # v4 - - uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507 # tag=v3.0.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index cce767d4..00000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# See https://pre-commit.com for more information -repos: -- repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.1.10 - hooks: - - id: remove-tabs - -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: fix-byte-order-marker - - id: mixed-line-ending - - id: check-merge-conflict - - id: check-case-conflict - - id: check-executables-have-shebangs - - id: check-docstring-first - - id: check-symlinks - - id: destroyed-symlinks - - id: fix-byte-order-marker diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 0a7a3987..00000000 --- a/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2022, TrueCharts -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md deleted file mode 100644 index 2e072dc1..00000000 --- a/README.md +++ /dev/null @@ -1,131 +0,0 @@ -# truetool - -An easy tool for frequently used TrueNAS SCALE CLI utilities. - -Please before using this tool, [read this note](https://truecharts.org/manual/guides/Important-MUST-READ) - -## Table of contents: - -* [Synopsis](#synopsis) -* [Arguments](#arguments) -* [How to Install](#how-to-install) -* [How to Update](#how-to-update) -* [Creating a Cron Job](#creating-a-cron-job) -* [Additional Information](#additional-information) - -
- -## Synopsis - -TrueTool is a command line tool, designed to enable some features of TrueNAS SCALE that are either not-enabled by default or not-available in the Web-GUI. -It also offers a few handy shortcuts for commonly required chores, like: Enabling Apt or Helm - -## Arguments - -| Flag | Example | Parameter | Description | -| --------------- | ---------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| --delete-backup | --delete-backup | None | Opens a menu to delete backups
_Useful if you need to delete old system backups or backups from other scripts_ | -| --restore | --restore | None | Restore TrueTool specific `ix-applications dataset` snapshot | -| --mount | --mount | None | Initiates mounting feature
Choose between unmounting and mounting PVC data | -| --dns | --dns | None | list all of your applications DNS names and their web ports | -| --list-backups | --list-backups | None | Prints a list of backups available | -| --helm-enable | --helm-enable | None | Enables Helm command access on SCALE | -| --kubeapi-enable | --kubeapi-enable | None | Enables external access to Kuberntes API port | -| --apt-enable | --apt-enable | None | Enables Apt command access on SCALE | -| --no-color | --no-color | None | Disables showing colors in terminal output, usefull for SCALE Email output | -| -U | -U | None | Update applications, ignoring major version changes | -| -u | -u | None | Update applications, do NOT update if there was a major version change | -| -b | -b 14 | Integer | Backup `ix-applications` dataset
_Creates backups up to the number you've chosen_ | -| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating
_List one application after another as shown in the example_ | -| -v | -v | None | Verbose Output
| -| -t | -t 150 | Integer | Set a custom timeout to be used with either:
`-m`
_Time the script will wait for application to be "STOPPED"_
or
`-(u\|U)`
_Time the script will wait for application to be either "STOPPED" or "ACTIVE"_ | -| -s | -s | None | Sync Catalogs prior to updating | -| -p | -p | None | Prune old/unused docker images | - - -
-
- -## How to Install - -### Choose a folder - -It's important to save the script in a folder that is persistent across TrueNAS System Updates. -This saves you from reinstalling or experiencing an accidental lack-of-backups after an update. - -##### New dataset - -In this example we created a `scripts` dataset on the TrueNAS SCALE system, feel free to use another folder. - -##### Root folder - -The `/root` folder houses files for the root user. -It's also persistent across updates and hence can be safely used for storing the script. - -### Open a Terminal - -**Change Directory to your scripts folder** - -``` -cd /mnt/pool/scripts -``` - -**Git Clone truetool** - -``` -git clone https://github.com/truecharts/truetool.git -``` - -**Change Directory to truetool folder** - -``` -cd truetool -``` - -From here, you can just run truetool with `bash truetool.sh -ARGUMENTS` - -
- -## How to Update - -TrueTool updates itself automatically. - -
- - -## Creating a Cron Job - -1. TrueNAS SCALE GUI -2. System Settings -3. Advanced -4. Cron Jobs - 1. Click Add - -| Name | Value | Reason | -| ---------------------- | -------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -| `Description` | TrueTool Update apps | This is up to you, put whatever you think is a good description in here | -| `Command` | `bash /PATH/TO/truetool_DIRECTORY/truetool.sh --no-color -b 14 -sup` | This is the command you will be running on your schedule, example: `bash /mnt/speed/scripts/truetool/truetool.sh -b 14 -sup` | -| `Run As User` | `root` | Running the script as `root` is REQUIRED. You cannot access all of the kubernetes functions without this user. | -| `Schedule` | Up to you, example: `0400` | Again up to you | -| `Hide Standard Output` | `False` or Un-ticked | It's best to keep an eye on updates and enable this to receive email reports | -| `Hide Standard Error` | `False` or Un-ticked | We definitely want to see what errors occurred during updating | -| `Enabled` | `True` or Ticked | This will Enable the script to run on your schedule | - -
-
- -### Additional Information - -#### TrueTool vs HeavyScript - -TrueTool and HeavyScript are based, in essence, based on the original (python based) TrueUpdate and TrueTool. -Then Support-Manager for TrueCharts, HeavyBullets8, ported this to Bash and started adding some additional logic and options for tasks we frequently needed our users to do, such as mounting PVC's. - -After a month or so, the TrueCharts Team officially started refactoring this expanded bash-port. Due to personal reasons, HeavyBullets by then decided to separate from TrueCharts after merging the TrueCharts refactor into his own work. The beauty of OpenSource. - -From this point onwards the HeavyScript and TrueTool diverged a bit. -We internally review changes within our staff team, to verify we somewhat stick to best-practices. This means, in some cases, we decided not to port certain features from HeavyScript and did decide to add features we think are useful and safe. -But this also means we can give guarantees TrueTool works optimally with our Catalog of TrueNAS SCALE Apps, as well as official Apps. - -Users from HeavyScript can safely start using TrueTool, as we've made precautions to ensure the backups take over smoothly. -We, however, do _not_ advise using HeavyScript with TrueCharts Apps. Not because it's a bad App, but because we offer an alternative that is validated by our Staff. diff --git a/hotpatch/2212/HP1.patch b/hotpatch/2212/HP1.patch deleted file mode 100644 index 72e293a9..00000000 --- a/hotpatch/2212/HP1.patch +++ /dev/null @@ -1,125 +0,0 @@ -diff --git plugins/chart_releases_linux/chart_release.py plugins/chart_releases_linux/chart_release.py -index 76e3825bc0f..f65cc0eac24 100644 ---- plugins/chart_releases_linux/chart_release.py -+++ plugins/chart_releases_linux/chart_release.py -@@ -606,7 +606,7 @@ async def do_delete(self, job, release_name, options): - # If we had pre-install jobs, it's possible we have leftover pods which the job did not remove - # based on dev specified settings of cleaning it up - let's remove those - for pod in await self.middleware.call('k8s.pod.query', [['metadata.namespace', '=', namespace]]): -- owner_references = pod['metadata'].get('owner_references') -+ owner_references = pod['metadata'].get('ownerReferences') - if not isinstance(owner_references, list) or all( - owner_reference.get('name') not in pre_install_jobs for owner_reference in owner_references - ): -@@ -658,7 +658,7 @@ async def remove_storage_class_and_dataset(self, release_name, job=None): - pvc_volume_ds = os.path.join(release_ds, 'volumes') - for pv in await self.middleware.call( - 'k8s.pv.query', [ -- ['spec.csi.volume_attributes.openebs\\.io/poolname', '=', pvc_volume_ds] -+ ['spec.csi.volumeAttributes.openebs\\.io/poolname', '=', pvc_volume_ds] - ] - ): - await self.middleware.call('k8s.pv.delete', pv['metadata']['name']) -diff --git plugins/chart_releases_linux/resources.py plugins/chart_releases_linux/resources.py -index c7180147a5f..941de79da45 100644 ---- plugins/chart_releases_linux/resources.py -+++ plugins/chart_releases_linux/resources.py -@@ -158,13 +158,13 @@ async def retrieve_pv_pvc_mapping_internal(self, chart_release): - } - - for pv in chart_release['resources']['persistent_volumes']: -- claim_name = pv['spec'].get('claim_ref', {}).get('name') -+ claim_name = pv['spec'].get('claimRef', {}).get('name') - if claim_name: - csi_spec = pv['spec']['csi'] -- volumes_ds = csi_spec['volume_attributes']['openebs.io/poolname'] -+ volumes_ds = csi_spec['volumeAttributes']['openebs.io/poolname'] - if ( - os.path.join(chart_release['dataset'], 'volumes') != volumes_ds or -- csi_spec['volume_handle'] not in zfs_volumes -+ csi_spec['volumeHandle'] not in zfs_volumes - ): - # We are only going to backup/restore pvc's which were consuming - # their respective storage class and we have related zfs volume present -@@ -174,8 +174,8 @@ async def retrieve_pv_pvc_mapping_internal(self, chart_release): - mapping[claim_name] = { - 'name': pv_name, - 'pv_details': pv, -- 'dataset': os.path.join(volumes_ds, csi_spec['volume_handle']), -- 'zv_details': zfs_volumes[csi_spec['volume_handle']], -+ 'dataset': os.path.join(volumes_ds, csi_spec['volumeHandle']), -+ 'zv_details': zfs_volumes[csi_spec['volumeHandle']], - } - return mapping - -@@ -247,11 +247,11 @@ async def get_workload_storage_details(self): - # because of chart release reclaim policy being retain - for pv in await self.middleware.call( - 'k8s.pv.query', [[ -- 'spec.csi.volume_attributes.openebs\\.io/poolname', '^', -+ 'spec.csi.volumeAttributes.openebs\\.io/poolname', '^', - f'{os.path.join(k8s_config["dataset"], "releases")}/' - ]] - ): -- dataset = pv['spec']['csi']['volume_attributes']['openebs.io/poolname'] -+ dataset = pv['spec']['csi']['volumeAttributes']['openebs.io/poolname'] - rl = dataset.split('/', 4) - if len(rl) > 4: - mapping['persistent_volumes'][rl[3]].append(pv) -diff --git plugins/chart_releases_linux/scale_workload.py plugins/chart_releases_linux/scale_workload.py -index 117dab3a79c..e9525150278 100644 ---- plugins/chart_releases_linux/scale_workload.py -+++ plugins/chart_releases_linux/scale_workload.py -@@ -246,10 +246,10 @@ async def get_workload_to_pod_mapping(self, namespace): - for r in await self.middleware.call( - f'k8s.{key}.query', [ - ['metadata.namespace', '=', namespace], -- ['metadata', 'rin', 'owner_references'], -+ ['metadata', 'rin', 'ownerReferences'], - ], {'select': ['metadata']} - ): -- for owner_reference in filter(lambda o: o.get('uid'), r['metadata']['owner_references'] or []): -+ for owner_reference in filter(lambda o: o.get('uid'), r['metadata']['ownerReferences'] or []): - mapping[key][owner_reference['uid']][r['metadata']['uid']] = r - - pod_mapping = defaultdict(list) -diff --git plugins/kubernetes_linux/restore.py plugins/kubernetes_linux/restore.py -index 4897e3f8b7a..ec13a332b6e 100644 ---- plugins/kubernetes_linux/restore.py -+++ plugins/kubernetes_linux/restore.py -@@ -218,7 +218,11 @@ def restore_backup(self, job, backup_name, options): - failed_pv_restores.append(f'Unable to create ZFS Volume for {pvc!r} PVC: {e}') - continue - -+ # We need to safely access claim_ref vollume attribute keys as with k8s client api re-write -+ # camel casing which was done by kubernetes asyncio package is not happening anymore - pv_spec = pv['pv_details']['spec'] -+ claim_ref = pv_spec.get('claim_ref') or pv_spec['claimRef'] -+ pv_volume_attrs = pv_spec['csi'].get('volume_attributes') or pv_spec['csi']['volumeAttributes'] - try: - self.middleware.call_sync('k8s.pv.create', { - 'metadata': { -@@ -229,18 +233,18 @@ def restore_backup(self, job, backup_name, options): - 'storage': pv_spec['capacity']['storage'], - }, - 'claimRef': { -- 'name': pv_spec['claim_ref']['name'], -- 'namespace': pv_spec['claim_ref']['namespace'], -+ 'name': claim_ref['name'], -+ 'namespace': claim_ref['namespace'], - }, - 'csi': { - 'volumeAttributes': { - 'openebs.io/poolname': RE_POOL.sub( -- f'{k8s_pool}\\1', pv_spec['csi']['volume_attributes']['openebs.io/poolname'] -+ f'{k8s_pool}\\1', pv_volume_attrs['openebs.io/poolname'] - ) - }, -- 'volumeHandle': pv_spec['csi']['volume_handle'], -+ 'volumeHandle': pv_spec['csi'].get('volume_handle') or pv_spec['csi']['volumeHandle'], - }, -- 'storageClassName': pv_spec['storage_class_name'], -+ 'storageClassName': pv_spec.get('storage_class_name') or pv_spec['storageClassName'], - }, - }) - except Exception as e: diff --git a/hotpatch/2212/HP2.patch b/hotpatch/2212/HP2.patch deleted file mode 100644 index 30357c93..00000000 --- a/hotpatch/2212/HP2.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git plugins/kubernetes_linux/backup.py plugins/kubernetes_linux/backup.py -index 365cd1718b4..1046a64c2a5 100644 -index d8a48d45f89..365cd1718b4 100644 ---- plugins/kubernetes_linux/backup.py -+++ plugins/kubernetes_linux/backup.py -@@ -61,7 +61,8 @@ def backup_chart_releases(self, job, backup_name): - ['metadata.namespace', '=', chart_release['namespace']] - ] - ) -- for secret in sorted(secrets, key=lambda d: d['metadata']['name']): -+ # We ignore this keeping in line with helm behaviour where the secret malformed is ignored by helm -+ for secret in sorted(filter(lambda d: d.get('data'), secrets), key=lambda d: d['metadata']['name']): - with open(os.path.join(secrets_dir, secret['metadata']['name']), 'w') as f: - f.write(self.middleware.call_sync('k8s.secret.export_to_yaml_internal', secret)) diff --git a/includes/backup.sh b/includes/backup.sh deleted file mode 100755 index e09449f9..00000000 --- a/includes/backup.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash - -## Simple shortcut to just list the backups without promts and such -listBackups(){ -echo -e "${BWhite}Backup Listing Tool${Color_Off}" -clear -x && echo "pulling all restore points.." -list_backups=$(cli -c 'app kubernetes list_backups' | grep -v system-update | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) -[[ -z "$list_backups" ]] && echo -e "${IRed}No restore points available${Color_Off}" && exit || echo "Detected Backups:" && echo "$list_backups" -} -export -f listBackups - -## Lists backups, except system-created backups, and promts which one to delete -deleteBackup(){ -echo -e "${BWhite}Backup Deletion Tool${Color_Off}" -clear -x && echo "pulling all restore points.." -list_delete_backups=$(cli -c 'app kubernetes list_backups' | grep -v system-update | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) -clear -x -# shellcheck disable=SC2015 -[[ -z "$list_delete_backups" ]] && echo -e "${IRed}No restore points available${Color_Off}" && exit || { title; echo -e "Choose a restore point to delete\nThese may be out of order if they are not TrueTool backups" ; } -# shellcheck disable=SC2015 -echo "$list_delete_backups" && read -rt 600 -p "Please type a number: " selection && restore_point=$(echo "$list_delete_backups" | grep ^"$selection " | awk '{print $2}') -[[ -z "$selection" ]] && echo "${IRed}Your selection cannot be empty${Color_Off}" && exit #Check for valid selection. If none, kill script -[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script -echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" || { echo "${IRed}FAILED${Color_Off}"; exit; } -# shellcheck disable=SC2015 -echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -rt 120 -p "Please type a number: " yesno || { echo "${IRed}FAILED${Color_Off}"; exit; } -if [[ $yesno == "1" ]]; then - echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo -e "${IGreen}Sucessfully deleted${Color_Off}" || echo -e "${IRed}Deletion FAILED${Color_Off}" -elif [[ $yesno == "2" ]]; then - echo "You've chosen NO, killing script." -else - echo -e "${IRed}Invalid Selection${Color_Off}" -fi -} -export -f deleteBackup - -## Creates backups and deletes backups if a "backups to keep"-count is exceeded. -# backups-to-keep takes only heavyscript and truetool created backups into account, as other backups aren't guaranteed to be sorted correctly -backup(){ -echo -e "${BWhite}Backup Tool${Color_Off}" -echo -e "\nNumber of backups was set to $number_of_backups" -date=$(date '+%Y_%m_%d_%H_%M_%S') -[[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'TrueTool_"$date"'"' -[[ -z "$verbose" ]] && echo -e "\nNew Backup Name:" && cli -c 'app kubernetes backup_chart_releases backup_name=''"'TrueTool_"$date"'"' | tail -n 1 -mapfile -t list_create_backups < <(cli -c 'app kubernetes list_backups' | grep 'HeavyScript\|TrueTool_' | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") -# shellcheck disable=SC2309 -if [[ ${#list_create_backups[@]} -gt "number_of_backups" ]]; then - echo -e "\nDeleting the oldest backup(s) for exceeding limit:" - overflow=$(( ${#list_create_backups[@]} - "$number_of_backups" )) - mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "TrueTool_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") - for i in "${list_overflow[@]}" - do - cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo "${IRed}FAILED${Color_Off} to delete $i" - echo "$i" - done -fi -} -export -f backup - -## Lists available backup and prompts the users to select a backup to restore -restore(){ -echo -e "${BWhite}Backup Restoration Tool${Color_Off}" -clear -x && echo "pulling restore points.." -list_restore_backups=$(cli -c 'app kubernetes list_backups' | grep "TrueTool_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) -clear -x -# shellcheck disable=SC2015 -[[ -z "$list_restore_backups" ]] && echo "No TrueTool restore points available" && exit || { title; echo "Choose a restore point" ; } -echo "$list_restore_backups" && read -rt 600 -p "Please type a number: " selection && restore_point=$(echo "$list_restore_backups" | grep ^"$selection " | awk '{print $2}') -[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script -echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" || { echo "${IRed}FAILED${Color_Off}"; exit; } -# shellcheck disable=SC2015 -echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -rt 120 -p "Please type a number: " yesno || { echo "${IRed}FAILED${Color_Off}"; exit; } -if [[ $yesno == "1" ]]; then - echo -e "\nStarting Restore, this will take a ${BWhite}LONG${Color_Off} time." - pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r") - echo "Correcting PVC mountpoints..." - for pvc in $(zfs list -t filesystem -r "$pool"/ix-applications -o name -H | grep "/ix-applications/" | grep "volumes/pvc") - do - zfs set mountpoint=legacy "${pvc}" || echo "Fixing PVC mountpoints Failed for ${pvc}... Continuing..." - done - # Ensure readonly is turned off - if ! zfs set readonly=off "$pool"/ix-applications;then - echo -e "Error: Failed to set ZFS ReadOnly to \"off\"" - echo -e "After the restore, attempt to run the following command manually:" - echo "zfs set readonly=off $pool/ix-applications" - fi - echo "Triggering restore process..." - cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore ${IRed}FAILED${Color_Off}" -elif [[ $yesno == "2" ]]; then - echo "You've chosen NO, killing script. Good luck." -else - echo -e "${IRed}Invalid Selection${Color_Off}" -fi -} -export -f restore diff --git a/includes/chores.sh b/includes/chores.sh deleted file mode 100755 index 9f3cbc6a..00000000 --- a/includes/chores.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -helmEnable(){ -echo -e "${BWhite}Enabling Helm${Color_Off}" -export KUBECONFIG=/etc/rancher/k3s/k3s.yaml && echo -e "${IGreen}Helm Enabled${Color_Off}"|| echo -e "${IRed}Helm Enable FAILED${Color_Off}" -} -export -f helmEnable - -aptEnable(){ -echo -e "${BWhite}Enabling Apt-Commands${Color_Off}" -chmod +x /usr/bin/apt* && echo -e "${IGreen}APT enabled${Color_Off}"|| echo -e "${IRed}APT Enable FAILED${Color_Off}" -} -export -f aptEnable - -kubeapiEnable(){ -local -r comment='iX Custom Rule to drop connection requests to k8s cluster from external sources' -echo -e "${BWhite}Enabling Kubernetes API${Color_Off}" -if iptables -t filter -L INPUT 2> /dev/null | grep -q "${comment}" ; then - iptables -D INPUT -p tcp -m tcp --dport 6443 -m comment --comment "${comment}" -j DROP && echo -e "${IGreen}Kubernetes API enabled${Color_Off}"|| echo -e "${IRed}Kubernetes API Enable FAILED${Color_Off}" -else - echo -e "${IGreen}Kubernetes API already enabled${Color_Off}" -fi -} -export -f kubeapiEnable - -# Prune unused docker images to prevent dataset/snapshot bloat related slowdowns on SCALE -prune(){ -echo -e "${BWhite}Docker Prune${Color_Off}" -echo "Pruning Docker Images..." -docker image prune -af | grep "^Total" && echo -e "${IGreen}Docker Prune Successfull${Color_Off}" || echo "Docker Prune ${IRed}FAILED${Color_Off}" - -# TODO Switch to middleware prune on next release -# midclt call container.prune '{"remove_unused_images": true, "remove_stopped_containers": true}' &> /dev/null && echo "Docker Prune completed"|| echo "Docker Prune ${IRed}FAILED${Color_Off}" -} -export -f prune - -# -sync(){ -echo -e "${BWhite}Starting Catalog Sync...${Color_Off}" -cli -c 'app catalog sync_all' &> /dev/null && echo -e "${IGreen}Catalog sync complete${Color_Off}" || echo -e "${IRed}Catalog Sync Failed${Color_Off}" -} -export -f sync diff --git a/includes/colors.sh b/includes/colors.sh deleted file mode 100755 index a1f8cbdd..00000000 --- a/includes/colors.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC2034 - -# Reset -Color_Off='\033[0m' # Text Reset - -# Regular Colors -Black='\033[0;30m' # Black -Red='\033[0;31m' # Red -Green='\033[0;32m' # Green -Yellow='\033[0;33m' # Yellow -Blue='\033[0;34m' # Blue -Purple='\033[0;35m' # Purple -Cyan='\033[0;36m' # Cyan -White='\033[0;37m' # White - -# Bold -BBlack='\033[1;30m' # Black -BRed='\033[1;31m' # Red -BGreen='\033[1;32m' # Green -BYellow='\033[1;33m' # Yellow -BBlue='\033[1;34m' # Blue -BPurple='\033[1;35m' # Purple -BCyan='\033[1;36m' # Cyan -BWhite='\033[1;37m' # White - -# Underline -UBlack='\033[4;30m' # Black -URed='\033[4;31m' # Red -UGreen='\033[4;32m' # Green -UYellow='\033[4;33m' # Yellow -UBlue='\033[4;34m' # Blue -UPurple='\033[4;35m' # Purple -UCyan='\033[4;36m' # Cyan -UWhite='\033[4;37m' # White - -# High Intensity -IBlack='\033[0;90m' # Black -IRed='\033[0;91m' # Red -IGreen='\033[0;92m' # Green -IYellow='\033[0;93m' # Yellow -IBlue='\033[0;94m' # Blue -IPurple='\033[0;95m' # Purple -ICyan='\033[0;96m' # Cyan -IWhite='\033[0;97m' # White - - -# Bold High Intensity -BIBlack='\033[1;90m' # Black -BIRed='\033[1;91m' # Red -BIGreen='\033[1;92m' # Green -BIYellow='\033[1;93m' # Yellow -BIBlue='\033[1;94m' # Blue -BIPurple='\033[1;95m' # Purple -BICyan='\033[1;96m' # Cyan -BIWhite='\033[1;97m' # White - -noColor(){ -# Reset -Color_Off="" - -# Regular Colors -Black="" -Red="" -Green="" -Yellow="" -Blue="" -Purple="" -Cyan="" -White="" - -# Bold -BBlack="" -BRed="" -BGreen="" -BYellow="" -BBlue="" -BPurple="" -BCyan="" -BWhite="" - -# Underline -UBlack="" -URed="" -UGreen="" -UYellow="" -UBlue="" -UPurple="" -UCyan="" -UWhite="" - -# High Intensity -IBlack="" -IRed="" -IGreen="" -IYellow="" -IBlue="" -IPurple="" -ICyan="" -IWhite="" - - -# Bold High Intensity -BIBlack="" -BIRed="" -BIGreen="" -BIYellow="" -BIBlue="" -BIPurple="" -BICyan="" -BIWhite="" - } - export -f noColor diff --git a/includes/dns.sh b/includes/dns.sh deleted file mode 100755 index 0e12e90a..00000000 --- a/includes/dns.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -dns(){ - echo -e "${BWhite}Service DNS Names Tool${Color_Off}" -clear -x -echo "Generating Internal Service DNS Names..." -#ignored dependency pods, may need to add more in the future. -dep_ignore="\-cronjob\-|^kube-system|\ssvclb|NAME|\-memcached\-.[^custom\-app]|\-postgresql\-.[^custom\-app]|\-redis\-.[^custom\-app]|\-mariadb\-.[^custom\-app]|\-promtail\-.[^custom\-app]" - -# Pulling pod names -mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$dep_ignore" | sort) - -# Pulling all ports -all_ports=$(k3s kubectl get service -A) - -clear -x -count=0 -for i in "${main[@]}" -do - [[ count -le 0 ]] && echo -e "\n" && ((count++)) - appName=$(echo "$i" | awk '{print $2}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//') - ixName=$(echo "$i" | awk '{print $1}') - port=$(echo "$all_ports" | grep -E "\s$appName\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}") - [[ -n "$port" ]] && echo -e "$appName.$ixName.svc.cluster.local $port" -done | uniq | nl -b t | sed 's/\s\s\s$/- -------- ----/' | column -t -R 1 -N "#,DNS_Name,Port" -L -} -export -f dns diff --git a/includes/help.sh b/includes/help.sh deleted file mode 100755 index a31cd4fc..00000000 --- a/includes/help.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -help(){ -[[ $help == "true" ]] && clear -x -echo "" -echo -e "${BWhite}Basic Utilities${Color_Off}" -echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" -echo "--restore | Opens a menu to restore a \"truetool\" backup that was taken on your \"ix-applications\" dataset" -echo "--delete-backup | Opens a menu to delete backups on your system" -echo "--list-backups | Prints a list of backups available" -echo "--helm-enable | Enables Helm command access on SCALE" -echo "--apt-enable | Enables Apt command access on SCALE" -echo "--kubeapi-enable | Enables external access to Kuberntes API port" -echo "--dns | List all of your applications DNS names and their web ports" -echo -echo -e "${BWhite}Update Options${Color_Off}" -echo "-U | Update all applications, ignores versions" -echo "-u | Update all applications, does not update Major releases" -echo "-b | Back-up your ix-applications dataset, specify a number after -b" -echo "-i | Add application to ignore list, one by one, see example below." -echo "-v | verbose output" -echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" -echo "-s | sync catalog" -echo "-p | Prune unused/old docker images" -echo -echo -e "${BWhite}Examples${Color_Off}" -echo "bash truetool.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vsUp" -echo "bash /mnt/tank/scripts/truetool.sh -t 150 --mount" -echo "bash /mnt/tank/scripts/truetool.sh --dns" -echo "bash /mnt/tank/scripts/truetool.sh --restore" -echo "bash /mnt/tank/scripts/truetool.sh --delete-backup" -echo -exit -} -export -f help diff --git a/includes/mount.sh b/includes/mount.sh deleted file mode 100755 index 7d5a6019..00000000 --- a/includes/mount.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -mountPVC(){ -echo -e "${BWhite}PVC Mounting Tool${Color_Off}" -clear -x -title -echo -e "1 Mount\n2 Unmount All" && read -rt 600 -p "Please type a number: " selection -[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -if [[ $selection == "1" ]]; then - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") - echo "$list" && read -rt 120 -p "Please type a number: " selection - [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script - app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script - pvc=$(echo -e "$list" | grep ^"$selection ") - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - if [[ "$status" != "STOPPED" ]]; then - [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" - SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null - else - echo -e "\n$app is already stopped" - fi - while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] - do - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 - done - data_name=$(echo "$pvc" | awk '{print $3}') - volume_name=$(echo "$pvc" | awk '{print $4}') - full_path=$(zfs list | grep "$volume_name" | awk '{print $1}') - echo -e "\nMounting\n$full_path\nTo\n/mnt/truetool/$data_name" && zfs set mountpoint="/truetool/$data_name" "$full_path" && echo -e "Mounted, Use the Unmount All option to unmount\n" - exit -elif [[ $selection == "2" ]]; then - mapfile -t unmount_array < <(basename -a /mnt/truetool/* | sed "s/*//") - [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit - for i in "${unmount_array[@]}" - do - main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') - app=$(echo "$main" | awk '{print $1}' | cut -c 4-) - pvc=$(echo "$main" | awk '{print $3}') - mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused. - echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/truetool/"$i" || echo "${IRed}FAILED${Color_Off} to unmount $i" - else - # shellcheck disable=SC2128 - zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/truetool/"$i" || echo "${IRed}FAILED${Color_Off} to unmount $i" - fi - done - rmdir /mnt/truetool -else - echo -e "${IRed}Invalid selection, \"$selection\" was not an option${Color_Off}" -fi -} -export -f mountPVC diff --git a/includes/no_args.sh b/includes/no_args.sh deleted file mode 100755 index 9ff0f3c0..00000000 --- a/includes/no_args.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC2034 - -no_args(){ - echo "0 Show Help" - echo "1 List Internal Service DNS Names" - echo "2 Mount and Unmount PVC storage for easy access" - echo "3 List Backups" - echo "4 Create a Backup" - echo "5 Restore a Backup" - echo "6 Delete a Backup" - echo "7 Enable Helm Commands" - echo "8 Enable Apt and Apt-Get Commands" - echo "9 Update All Apps" - echo "10 Enable external access to Kuberntes API port" - read -rt 600 -p "Please select an option by number: " selection - - case $selection in - 0) - help="true" - ;; - 1) - dns="true" - ;; - 2) - mountPVC="true" - ;; - 3) - listBackups="true" - ;; - 4) - read -rt 600 -p "Please type the max number of backups to keep: " backups - re='^[0-9]+$' - number_of_backups=$backups - ! [[ $backups =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit - [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit - ;; - 5) - restore="true" - ;; - 6) - deleteBackup="true" - ;; - 7) - helmEnable="true" - ;; - 8) - aptEnable="true" - ;; - 9) - echo "" - echo "1 Update Apps Excluding likely breaking major changes" - echo "2 Update Apps Including likely breaking major changes" - read -rt 600 -p "Please select an option by number: " updateType - if [[ "$updateType" == "1" ]]; then - update_apps="true" - elif [[ "$updateType" == "2" ]]; then - update_all_apps="true" - else - echo "INVALID ENTRY" && exit 1 - fi - ;; - 10) - kubeapiEnable="true" - ;; - *) - echo "Unknown option" && exit 1 - ;; - esac - echo "" -} -export -f no_args diff --git a/includes/patch.sh b/includes/patch.sh deleted file mode 100644 index 82393dea..00000000 --- a/includes/patch.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -patchv22120(){ -echo "Applying 22.12 HotPatch 1" -( wget -q -P /tmp https://github.com/truecharts/truetool/raw/main/hotpatch/2212/HP1.patch && echo "download completed" || echo "download failed" ) && ( patch -N -s -p0 -d /usr/lib/python3/dist-packages/middlewared/ < /tmp/HP1.patch && service middlewared restart && echo "waiting 20 seconds for middleware restart..." && sleep 20 && echo "patch completed" || echo "patch failed or skipped, not critical" ) && rm -rf /tmp/HP1.patch -echo "Applying 22.12 HotPatch 2" -( wget -q -P /tmp https://github.com/truecharts/truetool/raw/main/hotpatch/2212/HP2.patch && echo "download completed" || echo "download failed" ) && ( patch -N -s -p0 -d /usr/lib/python3/dist-packages/middlewared/ < /tmp/HP2.patch && service middlewared restart && echo "waiting 20 seconds for middleware restart..." && sleep 20 && echo "patch completed" || echo "patch failed or skipped, not critical" ) && rm -rf /tmp/HP2.patch -} -export -f patchv22120 - - -hotpatch(){ -echo "Starting hotpatcher..." -if [ "$(cli -m csv -c 'system version' | awk -F '-' '{print $3}')" == "22.12.0" ]; then - patchv22120 -fi -} -export -f hotpatch diff --git a/includes/title.sh b/includes/title.sh deleted file mode 100755 index b6c9e740..00000000 --- a/includes/title.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# Fancy ascii title. -title(){ -if [[ -z $titleShown ]]; then - echo -e "${IRed} _______ _____ _ _ "; - echo " |__ __| / ____| | | | "; - echo " | |_ __ _ _ ___| | | |__ __ _ _ __| |_ ___ "; - echo -e "${IYellow} | | '__| | | |/ _ \ | | '_ \ / _\` | '__| __/ __|"; - echo " | | | | |_| | __/ |____| | | | (_| | | | |_\__ \\"; - echo -e "${IGreen} __|_|_| \__,_|\___|\_____|_| |_|\__,_|_| \__|___/"; - echo " |__ __| |__ __| | | "; - echo -e "${IBlue} | |_ __ _ _ ___| | ___ ___ | | "; - echo " | | '__| | | |/ _ \ |/ _ \ / _ \| | "; - echo -e "${IPurple} | | | | |_| | __/ | (_) | (_) | | "; - echo " |_|_| \__,_|\___|_|\___/ \___/|_| "; - echo " "; - echo -e "${Color_Off} "; -fi -titleShown='true' -} -export -f title diff --git a/includes/update.sh b/includes/update.sh deleted file mode 100755 index 0aaa7506..00000000 --- a/includes/update.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/bash - -update_apps(){ -echo -e "${BWhite}App Updater${Color_Off}" -[[ -z $timeout ]] && echo -e "Default Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" -[[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" - -echo "" -echo "Creating list of Apps to update..." - -# Render a list of ignored applications, so users can verify their ignores got parsed correctly. -if [[ -z ${ignore[*]} ]]; then - echo "No apps added to ignore list, continuing..." -else - echo "ignored applications:" - for ignored in "${ignore[@]}" - do - echo "${ignored}" - done -fi -echo "" - -mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|$)" | sort) -[[ -z ${array[*]} ]] && echo -e "\nThere are no updates available or middleware timed out" && return 0 || echo -e "\n${#array[@]} update(s) available:" -PIDlist=() - -# Draft a list of app names, seperate from actuall execution -# This prevents outputs getting mixed together -for i in "${array[@]}" -do - app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. - echo "$app_name" -done - -echo "" -echo "Updating Apps..." - -# Create a background task for each update as async solution -for i in "${array[@]}" -do - executeUpdate "${i}" & - PIDlist+=($!) -done -echo "" -echo "Waiting for update results..." - -# Wait for all the async updates to complete -for p in "${PIDlist[@]}" -do - wait "${p}" ||: -done - -} -export -f update_apps - - - -# This is a combination of stopping previously-stopped apps and apps stuck Deploying after update -after_update_actions(){ -SECONDS=0 -count=0 -sleep 15 - -# Keep this running and exit the endless-loop based on a timer, instead of a countered-while-loop -# shellcheck disable=SC2050 -while [[ "0" != "1" ]] -do - (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') - if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" - break - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" != "true" ]]; then - echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update.." - midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null - [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update - break - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" == "true" ]]; then - echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning" - break - elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - echo "Stopped" && break #if reports stopped any time after the first loop, assume its extermal services. - elif [[ "$status" == "ACTIVE" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - echo "Active" && break #if reports active any time after the first loop, assume actually active. - else - [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" - sleep 15 - continue - fi -done -} -export -f after_update_actions - -# Determine what all the required information for the App to update, check it and execute the update using the SCALE API -executeUpdate(){ - app_name=$(echo "$1" | awk -F ',' '{print $1}') #print out first catagory, name. - old_app_ver=$(echo "$1" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version - new_app_ver=$(echo "$1" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version - old_chart_ver=$(echo "$1" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version - new_chart_ver=$(echo "$1" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version - status=$(echo "$1" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE - startstatus=$status - diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions - diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions - old_full_ver=$(echo "$1" | awk -F ',' '{print $4}') #Upgraded From - new_full_ver=$(echo "$1" | awk -F ',' '{print $5}') #Upraded To - rollback_version=$(echo "$1" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') - printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return #If application is on ignore list, skip - if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update - [[ "$verbose" == "true" ]] && echo "Updating.." - # shellcheck disable=SC2015 - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated $app_name\n$old_full_ver\n$new_full_ver" && after_update_actions || { echo -e "$app_name: update ${IRed}FAILED${Color_Off}"; return; } - else - echo -e "\n$app_name\nMajor Release, update manually" - return - fi -} -export -f executeUpdate diff --git a/includes/update_self.sh b/includes/update_self.sh deleted file mode 100755 index 7ade24e2..00000000 --- a/includes/update_self.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -## AutoUpdate TrueTool using Git -updater(){ -echo -e "${BWhite}Checking for updates...${Color_Off}" -git remote set-url origin "${targetRepo}" -BRANCH=$(git rev-parse --abbrev-ref HEAD) -git fetch -q -git update-index -q --refresh -if [[ $(git status --branch --porcelain) == *"behind"* ]]; then - echo -e "${IPurple}TrueTool requires update${Color_Off}" - git reset --hard -q - git checkout -q "${BRANCH}" - git pull -q - echo "script updated" - if [[ "$CHANGED" == "true" ]]; then - echo "LOOP DETECTED, exiting" - exit 1 - else - echo "restarting script after update..." - export CHANGED="true" - . "${SCRIPT_DIR}/truetool.sh" "$@" - exit - fi -else - echo -e "${IGreen}script up-to-date${Color_Off}" - export CHANGED="false" -fi -echo "" -} -export -f updater diff --git a/truetool.sh b/truetool.sh deleted file mode 100755 index 6e03990f..00000000 --- a/truetool.sh +++ /dev/null @@ -1,179 +0,0 @@ -#!/bin/bash - -# Constants -SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"; -dir=$(basename "$SCRIPT_DIR") - -# Change this if you want to fork the project -enableUpdate="true" -targetRepo="https://github.com/truecharts/truetool.git" - -# CD to the folder containing the script to ensure consistent runs -cd "${SCRIPT_DIR}" || echo -e "ERROR: Something went wrong accessing the script directory" - -# Includes -# shellcheck source=includes/backup.sh -source includes/backup.sh -# shellcheck source=includes/chores.sh -source includes/chores.sh -# shellcheck source=includes/colors.sh -source includes/colors.sh -# shellcheck source=includes/dns.sh -source includes/dns.sh -# shellcheck source=includes/help.sh -source includes/help.sh -# shellcheck source=includes/help.sh -source includes/patch.sh -# shellcheck source=includes/mount.sh -source includes/mount.sh -# shellcheck source=includes/no_args.sh -source includes/no_args.sh -# shellcheck source=includes/title.sh -source includes/title.sh -# shellcheck source=includes/update.sh -source includes/update.sh -# shellcheck source=includes/update_self.sh -source includes/update_self.sh - -#If no argument is passed, set flag to show menu -if [[ -z "$*" || "-" == "$*" || "--" == "$*" ]]; then - no_args="true" -else - - # Parse script options - while getopts ":si:b:t:uUpSv-:" opt - do - case $opt in - -) - case "${OPTARG}" in - help) - help="true" - ;; - dns) - dns="true" - ;; - mount) - mountPVC="true" - ;; - restore) - restore="true" - ;; - delete-backup) - deleteBackup="true" - ;; - list-backups) - listBackups="true" - ;; - helm-enable) - helmEnable="true" - ;; - apt-enable) - aptEnable="true" - ;; - kubeapi-enable) - kubeapiEnable="true" - ;; - no-color) - noColor - ;; - *) - echo -e "Invalid Option \"--$OPTARG\"\n" && help - exit - ;; - esac - ;; - \?) - echo -e "Invalid Option \"-$OPTARG\"\n" && help - exit - ;; - :) - echo -e "Option: \"-$OPTARG\" requires an argument\n" && help - exit - ;; - b) - re='^[0-9]+$' - number_of_backups=$OPTARG - ! [[ $OPTARG =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit - [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit - ;; - i) - ignore+=("$OPTARG") - ;; - t) - re='^[0-9]+$' - timeout=$OPTARG - ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n\"""$timeout""\" is not an interger" >&2 && exit - ;; - s) - sync="true" - ;; - U) - update_all_apps="true" - ;; - u) - update_apps="true" - ;; - p) - prune="true" - ;; - v) - verbose="true" - ;; - *) - echo -e "Invalid Option \"--$OPTARG\"\n" && help - exit - ;; - esac - done -fi - -title - -[[ "$enableUpdate" == "true" ]] && updater "$@" - -## Always check if a hotpatch needs to be applied -hotpatch - -# Show menu if menu flag is set -if [[ "$no_args" == "true" ]]; then - no_args -fi - -## Exit if incompatable functions are called -[[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit - -## Exit if unsafe combinations are used -# Restore and update right after eachother, might cause super weird issues tha are hard to bugtrace -[[ ( "$update_all_apps" == "true" || "$update_apps" == "true" ) && ( "$restore" == "true" ) ]] && echo -e "Update and Restore cannot both be done in the same run..." && exit - -# Backup Deletion is generally considered to be a "once in a while" thing and not great to sync with automated updates for that reason -[[ ( "$update_all_apps" == "true" || "$update_apps" == "true" ) && ( "$deleteBackup" == "true" ) ]] && echo -e "Update Backup-Deletion cannot both be done in the same run..." && exit - -# Backup Deletion is generally considered to be a "once in a while" thing and not great to sync with automated updates for that reason -[[ ( "$update_all_apps" == "true" || "$update_apps" == "true" ) && ( "$deleteBackup" == "true" ) ]] && echo -e "Update and Backup-Deletion cannot both be done in the same run..." && exit - -# Backup listing is a printout, which would either clutter the output or be already outdated when combined with backup -[[ ( "$update_all_apps" == "true" || "$update_apps" == "true" ) && ( "$listBackups" == "true" ) ]] && echo -e "Update and Listing Backups cannot both be done in the same run..." && exit - -# Backup backup would be done after a backup is restored, which would lead to a backup that is... the same as the one restored... -[[ ( "$restore" == "true" && "$number_of_backups" -ge 1 )]] && echo -e "Restoring a backup and making a backup cannot both be done in the same run..." && exit - -# While technically possible, this is asking for user error... where a user by habit mistakes one prompt, for the other. -[[ ( "$restore" == "true" && "$deleteBackup" == "true" )]] && echo -e "restoring a backup and deleting a backup cannot both be done in the same run..." && exit - - -# Continue to call functions in specific order -[[ "$help" == "true" ]] && help -[[ "$helmEnable" == "true" ]] && helmEnable -[[ "$aptEnable" == "true" ]] && aptEnable -[[ "$kubeapiEnable" == "true" ]] && kubeapiEnable -[[ "$aptEnable" == "true" || "$helmEnable" == "true" || "$kubeapiEnable" == "true" ]] && exit -[[ "$listBackups" == "true" ]] && listBackups && exit -[[ "$deleteBackup" == "true" ]] && deleteBackup && exit -[[ "$dns" == "true" ]] && dns && exit -[[ "$restore" == "true" ]] && restore && exit -[[ "$mountPVC" == "true" ]] && mountPVC && exit -[[ "$number_of_backups" -ge 1 ]] && backup -[[ "$sync" == "true" ]] && sync -[[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && update_apps -[[ "$prune" == "true" ]] && prune From ac1cdb755ca3d4cc88931b00d990d87bc3a514f1 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Tue, 27 Dec 2022 11:55:52 +0100 Subject: [PATCH 820/823] Put back TrueTool content --- .github/renovate-config.js | 25 ++ .github/renovate.json5 | 23 + .github/workflows/renovate.yml | 18 + .github/workflows/shellcheck.yml | 29 +- .pre-commit-config.yaml | 21 + LICENSE | 703 ++----------------------------- README.md | 231 ++++------ hotpatch/2212/HP1.patch | 125 ++++++ hotpatch/2212/HP2.patch | 14 + includes/backup.sh | 96 +++++ includes/chores.sh | 42 ++ includes/colors.sh | 113 +++++ includes/dns.sh | 27 ++ includes/help.sh | 35 ++ includes/mount.sh | 57 +++ includes/no_args.sh | 72 ++++ includes/patch.sh | 18 + includes/title.sh | 22 + includes/update.sh | 123 ++++++ includes/update_self.sh | 31 ++ truetool.sh | 179 ++++++++ 21 files changed, 1160 insertions(+), 844 deletions(-) create mode 100644 .github/renovate-config.js create mode 100644 .github/renovate.json5 create mode 100644 .github/workflows/renovate.yml create mode 100644 .pre-commit-config.yaml create mode 100644 hotpatch/2212/HP1.patch create mode 100644 hotpatch/2212/HP2.patch create mode 100644 includes/backup.sh create mode 100644 includes/chores.sh create mode 100644 includes/colors.sh create mode 100644 includes/dns.sh create mode 100644 includes/help.sh create mode 100644 includes/mount.sh create mode 100644 includes/no_args.sh create mode 100644 includes/patch.sh create mode 100644 includes/title.sh create mode 100644 includes/update.sh create mode 100644 includes/update_self.sh create mode 100644 truetool.sh diff --git a/.github/renovate-config.js b/.github/renovate-config.js new file mode 100644 index 00000000..da91bb42 --- /dev/null +++ b/.github/renovate-config.js @@ -0,0 +1,25 @@ +module.exports = { + dryRun: false, + username: 'truecharts-admin', + gitAuthor: 'truecharts-admin ', + onboarding: false, + platform: 'github', + repositories: [ + 'truecharts/truetool', + ], + packageRules: [ + { + description: 'lockFileMaintenance', + matchUpdateTypes: [ + 'pin', + 'digest', + 'patch', + 'minor', + 'major', + 'lockFileMaintenance', + ], + dependencyDashboardApproval: false, + stabilityDays: 0, + }, + ], +}; diff --git a/.github/renovate.json5 b/.github/renovate.json5 new file mode 100644 index 00000000..de107f43 --- /dev/null +++ b/.github/renovate.json5 @@ -0,0 +1,23 @@ +{ + "semanticCommits": "enabled", + "extends": ["helpers:pinGitHubActionDigests"], + "dependencyDashboard": true, + "dependencyDashboardTitle": "Renovate Dashboard 🤖", + "suppressNotifications": ["prIgnoreNotification"], + "commitMessageTopic": "{{depName}}", + "commitMessageExtra": "to {{newVersion}}", + "commitMessageSuffix": "", + "rebaseWhen": "conflicted", + "prConcurrentLimit": 100, + "pinDigests": true, + "automerge": true, + "gitAuthor": "TrueCharts-Admin ", + "packageRules": [ + // Setup datasources for github actions + { + "matchManagers": ["github-actions"], + "commitMessageTopic": "github-action {{depName}} [skip ci]", + "automerge": true, + } + ] +} diff --git a/.github/workflows/renovate.yml b/.github/workflows/renovate.yml new file mode 100644 index 00000000..0816077f --- /dev/null +++ b/.github/workflows/renovate.yml @@ -0,0 +1,18 @@ +name: Renovate +on: + workflow_dispatch: + schedule: + - cron: "0 */6 * * *" +jobs: + renovate: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0 + with: + token: ${{ secrets.BOT_TOKEN }} + - name: Self-hosted Renovate + uses: renovatebot/github-action@d4496c2d9b06c4e43b227fc3f331a434e99eaef5 # v34.73.3 + with: + configurationFile: .github/renovate-config.js + token: ${{ secrets.BOT_TOKEN }} diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index 29c41a73..43b3800b 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -2,20 +2,25 @@ on: push: pull_request: workflow_dispatch: - -name: ShellCheck + +name: 'Lint and Test' jobs: - ShellCheck: - name: ShellCheck + shellcheck: + name: Shellcheck runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Run ShellCheck - uses: ludeeus/action-shellcheck@master - env: - SHELLCHECK_OPTS: -e SC2154 - with: - check_together: 'yes' - format: gcc + - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + with: + check_together: 'yes' + env: + SHELLCHECK_OPTS: -e SC2154 + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + - uses: actions/setup-python@5ccb29d8773c3f3f653e1705f474dfaa8a06a912 # v4 + - uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507 # tag=v3.0.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..cce767d4 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +# See https://pre-commit.com for more information +repos: +- repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.1.10 + hooks: + - id: remove-tabs + +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: fix-byte-order-marker + - id: mixed-line-ending + - id: check-merge-conflict + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-docstring-first + - id: check-symlinks + - id: destroyed-symlinks + - id: fix-byte-order-marker diff --git a/LICENSE b/LICENSE index f288702d..0a7a3987 100644 --- a/LICENSE +++ b/LICENSE @@ -1,674 +1,29 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. +BSD 3-Clause License + +Copyright (c) 2022, TrueCharts +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index 5d2105ed..2e072dc1 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ -# heavy_script +# truetool -## Website +An easy tool for frequently used TrueNAS SCALE CLI utilities. -[HeavySetup - Further Explanation](https://heavysetup.info/scripts/heavyscript/about/) +Please before using this tool, [read this note](https://truecharts.org/manual/guides/Important-MUST-READ) ## Table of contents: -* [Update Arguments](#update-arguments) -* [Other Utilities](#other-utilities) + +* [Synopsis](#synopsis) +* [Arguments](#arguments) * [How to Install](#how-to-install) * [How to Update](#how-to-update) * [Creating a Cron Job](#creating-a-cron-job) @@ -14,171 +15,83 @@
-## The Menu +## Synopsis -![image](https://user-images.githubusercontent.com/20793231/185020236-7b389499-8081-407d-b653-10dffd70de8c.png) -> Access this with `bash heavy_script.sh` +TrueTool is a command line tool, designed to enable some features of TrueNAS SCALE that are either not-enabled by default or not-available in the Web-GUI. +It also offers a few handy shortcuts for commonly required chores, like: Enabling Apt or Helm -
-
+## Arguments -## Update Arguments -| Flag | Example | Parameter | Description | -|---------------|------------------------|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| -U | -U
-U 5 | Optional Integer | Update applications, ignoring major version changes
_Optionally, you can supply a number after the argument to update multiple applications at once_ | -| -u | -u
-u 5 | Optional Integer | Update applications, do NOT update if there was a major version change
_Optionally, you can supply a number after the argument to update multiple applications at once_ | -| -b | -b 14 | Integer | Snapshot ix-applications dataset
_Creates backups UP TO the number you've chosen_ | -| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating
_List one application after another as shown in the example_ | -| -r | -r | | Monitors applications after they update
If the app does not become "ACTIVE" after the timeout, rollback the application. | -| -v | -v | | Verbose Output
_Look at the bottom of this page for an example_ | -| -S | -S | | Shutdown the application prior to updating it | -| -t | -t 400 | Integer | Time in seconds that HeavyScript will wait for an application to no longer be deploying before declaring failure
Default: 500 | -| -s | -s | | Sync Catalogs prior to updating | -| -p | -p | | Prune unused docker images | -| --ignore-img | --ignore-img | | Ignore container image updates | -| --self-update | --self-update | | Updates HeavyScript prior to running any other commands | +| Flag | Example | Parameter | Description | +| --------------- | ---------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| --delete-backup | --delete-backup | None | Opens a menu to delete backups
_Useful if you need to delete old system backups or backups from other scripts_ | +| --restore | --restore | None | Restore TrueTool specific `ix-applications dataset` snapshot | +| --mount | --mount | None | Initiates mounting feature
Choose between unmounting and mounting PVC data | +| --dns | --dns | None | list all of your applications DNS names and their web ports | +| --list-backups | --list-backups | None | Prints a list of backups available | +| --helm-enable | --helm-enable | None | Enables Helm command access on SCALE | +| --kubeapi-enable | --kubeapi-enable | None | Enables external access to Kuberntes API port | +| --apt-enable | --apt-enable | None | Enables Apt command access on SCALE | +| --no-color | --no-color | None | Disables showing colors in terminal output, usefull for SCALE Email output | +| -U | -U | None | Update applications, ignoring major version changes | +| -u | -u | None | Update applications, do NOT update if there was a major version change | +| -b | -b 14 | Integer | Backup `ix-applications` dataset
_Creates backups up to the number you've chosen_ | +| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating
_List one application after another as shown in the example_ | +| -v | -v | None | Verbose Output
| +| -t | -t 150 | Integer | Set a custom timeout to be used with either:
`-m`
_Time the script will wait for application to be "STOPPED"_
or
`-(u\|U)`
_Time the script will wait for application to be either "STOPPED" or "ACTIVE"_ | +| -s | -s | None | Sync Catalogs prior to updating | +| -p | -p | None | Prune old/unused docker images | -### Example -#### Cron Job -``` -bash heavy_script.sh --self-update -b 10 -i nextcloud -i sonarr -t 600 --ignore-img -rsp -u 5 -``` - -> `-b` is set to 10. Up to 10 snapshots of your ix-applications dataset will be saved - -> `-i` is set to ignore __nextcloud__ and __sonarr__. These applications will be skipped if they have an update. - -> `-t` I set it to 600 seconds, this means the script will wait 600 seconds for the application to become ACTIVE before timing out and rolling back to the previous version since `-r` is used. - -> `--ignore-img` Will not update the application if it is only a container image update - -> `-r` Will rollback applications if they fail to deploy within the timeout, after updating. - -> `-s` will just sync the repositories, ensuring you are downloading the latest updates. - -> `-p` Prune docker images. - -> `-u` update applications as long as the major version has absolutely no change, if it does have a change it will ask the user to update manually. ->> The `5` after the `-u` means up to 5 applications will be updating and monitored at one time - -> `--self-update` Will update the script prior to running anything else. - -
- -#### My Personal Cron Job -``` -bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 10 -rsp -u 10 -``` - -
-
- -## Other Utilities -> All of these can ALSO be accessed with the HeavyScript menu, that you can access simply by not providing an argument `bash heavy_script.sh` - -| Flag | Description | -|-----------------|----------------------------------------------------------------------------------------------| -| --mount | Initiates mounting feature, choose between unmounting and mounting PVC data | -| --restore | Opens a menu to restore a heavy_script backup that was taken on your ix-applications dataset | -| --delete-backup | Opens a menu to delete backups on your system | -| --dns | list all of your applications DNS names and their web ports | -| --cmd | Open a shell for one of your applications | - - -### Examples -#### Mounting PVC Data - -``` -bash /mnt/tank/scripts/heavy_script.sh --mount -``` - -#### Restoring ix-applications dataset - -``` -bash /mnt/tank/scripts/heavy_script/heavy_script.sh --restore -``` - -#### Deleting Backups - -``` -bash /mnt/tank/scripts/heavy_script/heavy_script.sh --delete-backup -``` - -#### List All DNS Names - -``` -bash /mnt/tank/scripts/heavy_script/heavy_script.sh --dns -``` - -#### Open a Containers Shell - -``` -bash /mnt/speed/scripts/heavy_script/heavy_script.sh --cmd -``` -

- ## How to Install -### Create a Scripts Dataset +### Choose a folder -I created a `scripts` dataset on my Truenas SCALE system, this is where all my scripts will remain. +It's important to save the script in a folder that is persistent across TrueNAS System Updates. +This saves you from reinstalling or experiencing an accidental lack-of-backups after an update. -### Open a Terminal +##### New dataset + +In this example we created a `scripts` dataset on the TrueNAS SCALE system, feel free to use another folder. + +##### Root folder + +The `/root` folder houses files for the root user. +It's also persistent across updates and hence can be safely used for storing the script. + +### Open a Terminal **Change Directory to your scripts folder** + ``` -cd /mnt/speed/scripts +cd /mnt/pool/scripts ``` -**Git Clone Heavy_Script** +**Git Clone truetool** + ``` -git clone https://github.com/Heavybullets8/heavy_script.git +git clone https://github.com/truecharts/truetool.git ``` -**Change Directory to Heavy_Script folder** +**Change Directory to truetool folder** + ``` -cd heavy_script +cd truetool ``` -From here, you can just run Heavy_Script with `bash heavy_script.sh -ARGUMENTS` - -> Note: `chmod +x` is NOT required. Doing this will break the `git pull` (or self update) function. Just run the script with `bash heavy_script.sh` +From here, you can just run truetool with `bash truetool.sh -ARGUMENTS`
-## How to Update +## How to Update -### Built-In Option (Recommended) - -``` -bash heavyscript.sh --self-update -b 10 -supr -``` -> The important argument here is the `--self-update`, you can still use all of your same arguments with this option. ->> `--self-update` will place users on the latest tag, as well as showing the changelog when new releases come out. So this is the preferred method. Not using this method, will instead place the user on `main`, where the changes are tested, but not as rigerously as they are on the releases. +TrueTool updates itself automatically.
-### Manually - -#### Open a Terminal - -**Change Directory to your heavy_script folder** -``` -cd /mnt/speed/scripts/heavy_script -``` - -**git pull** -``` -git pull -``` -> This is not recommended because the changes to main are not tested as much as the changes that are pushed to releases are tested, think of this method of updating as being in development. - -
-
## Creating a Cron Job @@ -188,29 +101,31 @@ git pull 4. Cron Jobs 1. Click Add -| Name | Value | Reason | -|------------------------ |------------------------------------------------------------------------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `Description` | HeavyScript git pull and Update apps | This is up to you, put whatever you think is a good description in here | -| `Command` | `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh --self-update -b 10 -rsp -u 10` | This is the command you will be running on your schedule I personally use: `bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 10 -rsp -u 10` | -| `Run As User` | `root` | Running the script as `root` is REQUIRED. You cannot access all of the kubernetes functions without this user. | -| `Schedule` | Up to you, I run mine everyday at `0400` | Again up to you | -| `Hide Standard Output` | `False` or Unticked | I like to receive an email report of how the script ran, what apps updated etc. | -| `Hide Standard Error` | `False` or Unticked | I want to see any errors that occur | -| `Enabled` | `True` or Ticked | This will Enable the script to run on your schedule | - - +| Name | Value | Reason | +| ---------------------- | -------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | +| `Description` | TrueTool Update apps | This is up to you, put whatever you think is a good description in here | +| `Command` | `bash /PATH/TO/truetool_DIRECTORY/truetool.sh --no-color -b 14 -sup` | This is the command you will be running on your schedule, example: `bash /mnt/speed/scripts/truetool/truetool.sh -b 14 -sup` | +| `Run As User` | `root` | Running the script as `root` is REQUIRED. You cannot access all of the kubernetes functions without this user. | +| `Schedule` | Up to you, example: `0400` | Again up to you | +| `Hide Standard Output` | `False` or Un-ticked | It's best to keep an eye on updates and enable this to receive email reports | +| `Hide Standard Error` | `False` or Un-ticked | We definitely want to see what errors occurred during updating | +| `Enabled` | `True` or Ticked | This will Enable the script to run on your schedule |

### Additional Information -#### Verbose vs Non-Verbose -- Verbose used `bash heavy_script.sh -b 5 -Srupv` -- Non-Verbose used `bash heavy_script.sh -b 5 -Srup` +#### TrueTool vs HeavyScript -| Verbose | Non-Verbose | -|--------- |------------- | -| ![image](https://user-images.githubusercontent.com/20793231/167971188-07f71d02-8da3-4e0c-b9a0-cd26e7f63613.png) | ![image](https://user-images.githubusercontent.com/20793231/167972033-dc8d4ab4-4fb2-4c8a-b7dc-b9311ae55cf8.png) | - +TrueTool and HeavyScript are based, in essence, based on the original (python based) TrueUpdate and TrueTool. +Then Support-Manager for TrueCharts, HeavyBullets8, ported this to Bash and started adding some additional logic and options for tasks we frequently needed our users to do, such as mounting PVC's. +After a month or so, the TrueCharts Team officially started refactoring this expanded bash-port. Due to personal reasons, HeavyBullets by then decided to separate from TrueCharts after merging the TrueCharts refactor into his own work. The beauty of OpenSource. + +From this point onwards the HeavyScript and TrueTool diverged a bit. +We internally review changes within our staff team, to verify we somewhat stick to best-practices. This means, in some cases, we decided not to port certain features from HeavyScript and did decide to add features we think are useful and safe. +But this also means we can give guarantees TrueTool works optimally with our Catalog of TrueNAS SCALE Apps, as well as official Apps. + +Users from HeavyScript can safely start using TrueTool, as we've made precautions to ensure the backups take over smoothly. +We, however, do _not_ advise using HeavyScript with TrueCharts Apps. Not because it's a bad App, but because we offer an alternative that is validated by our Staff. diff --git a/hotpatch/2212/HP1.patch b/hotpatch/2212/HP1.patch new file mode 100644 index 00000000..72e293a9 --- /dev/null +++ b/hotpatch/2212/HP1.patch @@ -0,0 +1,125 @@ +diff --git plugins/chart_releases_linux/chart_release.py plugins/chart_releases_linux/chart_release.py +index 76e3825bc0f..f65cc0eac24 100644 +--- plugins/chart_releases_linux/chart_release.py ++++ plugins/chart_releases_linux/chart_release.py +@@ -606,7 +606,7 @@ async def do_delete(self, job, release_name, options): + # If we had pre-install jobs, it's possible we have leftover pods which the job did not remove + # based on dev specified settings of cleaning it up - let's remove those + for pod in await self.middleware.call('k8s.pod.query', [['metadata.namespace', '=', namespace]]): +- owner_references = pod['metadata'].get('owner_references') ++ owner_references = pod['metadata'].get('ownerReferences') + if not isinstance(owner_references, list) or all( + owner_reference.get('name') not in pre_install_jobs for owner_reference in owner_references + ): +@@ -658,7 +658,7 @@ async def remove_storage_class_and_dataset(self, release_name, job=None): + pvc_volume_ds = os.path.join(release_ds, 'volumes') + for pv in await self.middleware.call( + 'k8s.pv.query', [ +- ['spec.csi.volume_attributes.openebs\\.io/poolname', '=', pvc_volume_ds] ++ ['spec.csi.volumeAttributes.openebs\\.io/poolname', '=', pvc_volume_ds] + ] + ): + await self.middleware.call('k8s.pv.delete', pv['metadata']['name']) +diff --git plugins/chart_releases_linux/resources.py plugins/chart_releases_linux/resources.py +index c7180147a5f..941de79da45 100644 +--- plugins/chart_releases_linux/resources.py ++++ plugins/chart_releases_linux/resources.py +@@ -158,13 +158,13 @@ async def retrieve_pv_pvc_mapping_internal(self, chart_release): + } + + for pv in chart_release['resources']['persistent_volumes']: +- claim_name = pv['spec'].get('claim_ref', {}).get('name') ++ claim_name = pv['spec'].get('claimRef', {}).get('name') + if claim_name: + csi_spec = pv['spec']['csi'] +- volumes_ds = csi_spec['volume_attributes']['openebs.io/poolname'] ++ volumes_ds = csi_spec['volumeAttributes']['openebs.io/poolname'] + if ( + os.path.join(chart_release['dataset'], 'volumes') != volumes_ds or +- csi_spec['volume_handle'] not in zfs_volumes ++ csi_spec['volumeHandle'] not in zfs_volumes + ): + # We are only going to backup/restore pvc's which were consuming + # their respective storage class and we have related zfs volume present +@@ -174,8 +174,8 @@ async def retrieve_pv_pvc_mapping_internal(self, chart_release): + mapping[claim_name] = { + 'name': pv_name, + 'pv_details': pv, +- 'dataset': os.path.join(volumes_ds, csi_spec['volume_handle']), +- 'zv_details': zfs_volumes[csi_spec['volume_handle']], ++ 'dataset': os.path.join(volumes_ds, csi_spec['volumeHandle']), ++ 'zv_details': zfs_volumes[csi_spec['volumeHandle']], + } + return mapping + +@@ -247,11 +247,11 @@ async def get_workload_storage_details(self): + # because of chart release reclaim policy being retain + for pv in await self.middleware.call( + 'k8s.pv.query', [[ +- 'spec.csi.volume_attributes.openebs\\.io/poolname', '^', ++ 'spec.csi.volumeAttributes.openebs\\.io/poolname', '^', + f'{os.path.join(k8s_config["dataset"], "releases")}/' + ]] + ): +- dataset = pv['spec']['csi']['volume_attributes']['openebs.io/poolname'] ++ dataset = pv['spec']['csi']['volumeAttributes']['openebs.io/poolname'] + rl = dataset.split('/', 4) + if len(rl) > 4: + mapping['persistent_volumes'][rl[3]].append(pv) +diff --git plugins/chart_releases_linux/scale_workload.py plugins/chart_releases_linux/scale_workload.py +index 117dab3a79c..e9525150278 100644 +--- plugins/chart_releases_linux/scale_workload.py ++++ plugins/chart_releases_linux/scale_workload.py +@@ -246,10 +246,10 @@ async def get_workload_to_pod_mapping(self, namespace): + for r in await self.middleware.call( + f'k8s.{key}.query', [ + ['metadata.namespace', '=', namespace], +- ['metadata', 'rin', 'owner_references'], ++ ['metadata', 'rin', 'ownerReferences'], + ], {'select': ['metadata']} + ): +- for owner_reference in filter(lambda o: o.get('uid'), r['metadata']['owner_references'] or []): ++ for owner_reference in filter(lambda o: o.get('uid'), r['metadata']['ownerReferences'] or []): + mapping[key][owner_reference['uid']][r['metadata']['uid']] = r + + pod_mapping = defaultdict(list) +diff --git plugins/kubernetes_linux/restore.py plugins/kubernetes_linux/restore.py +index 4897e3f8b7a..ec13a332b6e 100644 +--- plugins/kubernetes_linux/restore.py ++++ plugins/kubernetes_linux/restore.py +@@ -218,7 +218,11 @@ def restore_backup(self, job, backup_name, options): + failed_pv_restores.append(f'Unable to create ZFS Volume for {pvc!r} PVC: {e}') + continue + ++ # We need to safely access claim_ref vollume attribute keys as with k8s client api re-write ++ # camel casing which was done by kubernetes asyncio package is not happening anymore + pv_spec = pv['pv_details']['spec'] ++ claim_ref = pv_spec.get('claim_ref') or pv_spec['claimRef'] ++ pv_volume_attrs = pv_spec['csi'].get('volume_attributes') or pv_spec['csi']['volumeAttributes'] + try: + self.middleware.call_sync('k8s.pv.create', { + 'metadata': { +@@ -229,18 +233,18 @@ def restore_backup(self, job, backup_name, options): + 'storage': pv_spec['capacity']['storage'], + }, + 'claimRef': { +- 'name': pv_spec['claim_ref']['name'], +- 'namespace': pv_spec['claim_ref']['namespace'], ++ 'name': claim_ref['name'], ++ 'namespace': claim_ref['namespace'], + }, + 'csi': { + 'volumeAttributes': { + 'openebs.io/poolname': RE_POOL.sub( +- f'{k8s_pool}\\1', pv_spec['csi']['volume_attributes']['openebs.io/poolname'] ++ f'{k8s_pool}\\1', pv_volume_attrs['openebs.io/poolname'] + ) + }, +- 'volumeHandle': pv_spec['csi']['volume_handle'], ++ 'volumeHandle': pv_spec['csi'].get('volume_handle') or pv_spec['csi']['volumeHandle'], + }, +- 'storageClassName': pv_spec['storage_class_name'], ++ 'storageClassName': pv_spec.get('storage_class_name') or pv_spec['storageClassName'], + }, + }) + except Exception as e: diff --git a/hotpatch/2212/HP2.patch b/hotpatch/2212/HP2.patch new file mode 100644 index 00000000..30357c93 --- /dev/null +++ b/hotpatch/2212/HP2.patch @@ -0,0 +1,14 @@ +diff --git plugins/kubernetes_linux/backup.py plugins/kubernetes_linux/backup.py +index 365cd1718b4..1046a64c2a5 100644 +index d8a48d45f89..365cd1718b4 100644 +--- plugins/kubernetes_linux/backup.py ++++ plugins/kubernetes_linux/backup.py +@@ -61,7 +61,8 @@ def backup_chart_releases(self, job, backup_name): + ['metadata.namespace', '=', chart_release['namespace']] + ] + ) +- for secret in sorted(secrets, key=lambda d: d['metadata']['name']): ++ # We ignore this keeping in line with helm behaviour where the secret malformed is ignored by helm ++ for secret in sorted(filter(lambda d: d.get('data'), secrets), key=lambda d: d['metadata']['name']): + with open(os.path.join(secrets_dir, secret['metadata']['name']), 'w') as f: + f.write(self.middleware.call_sync('k8s.secret.export_to_yaml_internal', secret)) diff --git a/includes/backup.sh b/includes/backup.sh new file mode 100644 index 00000000..e09449f9 --- /dev/null +++ b/includes/backup.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +## Simple shortcut to just list the backups without promts and such +listBackups(){ +echo -e "${BWhite}Backup Listing Tool${Color_Off}" +clear -x && echo "pulling all restore points.." +list_backups=$(cli -c 'app kubernetes list_backups' | grep -v system-update | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) +[[ -z "$list_backups" ]] && echo -e "${IRed}No restore points available${Color_Off}" && exit || echo "Detected Backups:" && echo "$list_backups" +} +export -f listBackups + +## Lists backups, except system-created backups, and promts which one to delete +deleteBackup(){ +echo -e "${BWhite}Backup Deletion Tool${Color_Off}" +clear -x && echo "pulling all restore points.." +list_delete_backups=$(cli -c 'app kubernetes list_backups' | grep -v system-update | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) +clear -x +# shellcheck disable=SC2015 +[[ -z "$list_delete_backups" ]] && echo -e "${IRed}No restore points available${Color_Off}" && exit || { title; echo -e "Choose a restore point to delete\nThese may be out of order if they are not TrueTool backups" ; } +# shellcheck disable=SC2015 +echo "$list_delete_backups" && read -rt 600 -p "Please type a number: " selection && restore_point=$(echo "$list_delete_backups" | grep ^"$selection " | awk '{print $2}') +[[ -z "$selection" ]] && echo "${IRed}Your selection cannot be empty${Color_Off}" && exit #Check for valid selection. If none, kill script +[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script +echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" || { echo "${IRed}FAILED${Color_Off}"; exit; } +# shellcheck disable=SC2015 +echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -rt 120 -p "Please type a number: " yesno || { echo "${IRed}FAILED${Color_Off}"; exit; } +if [[ $yesno == "1" ]]; then + echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo -e "${IGreen}Sucessfully deleted${Color_Off}" || echo -e "${IRed}Deletion FAILED${Color_Off}" +elif [[ $yesno == "2" ]]; then + echo "You've chosen NO, killing script." +else + echo -e "${IRed}Invalid Selection${Color_Off}" +fi +} +export -f deleteBackup + +## Creates backups and deletes backups if a "backups to keep"-count is exceeded. +# backups-to-keep takes only heavyscript and truetool created backups into account, as other backups aren't guaranteed to be sorted correctly +backup(){ +echo -e "${BWhite}Backup Tool${Color_Off}" +echo -e "\nNumber of backups was set to $number_of_backups" +date=$(date '+%Y_%m_%d_%H_%M_%S') +[[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'TrueTool_"$date"'"' +[[ -z "$verbose" ]] && echo -e "\nNew Backup Name:" && cli -c 'app kubernetes backup_chart_releases backup_name=''"'TrueTool_"$date"'"' | tail -n 1 +mapfile -t list_create_backups < <(cli -c 'app kubernetes list_backups' | grep 'HeavyScript\|TrueTool_' | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") +# shellcheck disable=SC2309 +if [[ ${#list_create_backups[@]} -gt "number_of_backups" ]]; then + echo -e "\nDeleting the oldest backup(s) for exceeding limit:" + overflow=$(( ${#list_create_backups[@]} - "$number_of_backups" )) + mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "TrueTool_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") + for i in "${list_overflow[@]}" + do + cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo "${IRed}FAILED${Color_Off} to delete $i" + echo "$i" + done +fi +} +export -f backup + +## Lists available backup and prompts the users to select a backup to restore +restore(){ +echo -e "${BWhite}Backup Restoration Tool${Color_Off}" +clear -x && echo "pulling restore points.." +list_restore_backups=$(cli -c 'app kubernetes list_backups' | grep "TrueTool_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) +clear -x +# shellcheck disable=SC2015 +[[ -z "$list_restore_backups" ]] && echo "No TrueTool restore points available" && exit || { title; echo "Choose a restore point" ; } +echo "$list_restore_backups" && read -rt 600 -p "Please type a number: " selection && restore_point=$(echo "$list_restore_backups" | grep ^"$selection " | awk '{print $2}') +[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script +[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script +echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" || { echo "${IRed}FAILED${Color_Off}"; exit; } +# shellcheck disable=SC2015 +echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -rt 120 -p "Please type a number: " yesno || { echo "${IRed}FAILED${Color_Off}"; exit; } +if [[ $yesno == "1" ]]; then + echo -e "\nStarting Restore, this will take a ${BWhite}LONG${Color_Off} time." + pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r") + echo "Correcting PVC mountpoints..." + for pvc in $(zfs list -t filesystem -r "$pool"/ix-applications -o name -H | grep "/ix-applications/" | grep "volumes/pvc") + do + zfs set mountpoint=legacy "${pvc}" || echo "Fixing PVC mountpoints Failed for ${pvc}... Continuing..." + done + # Ensure readonly is turned off + if ! zfs set readonly=off "$pool"/ix-applications;then + echo -e "Error: Failed to set ZFS ReadOnly to \"off\"" + echo -e "After the restore, attempt to run the following command manually:" + echo "zfs set readonly=off $pool/ix-applications" + fi + echo "Triggering restore process..." + cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore ${IRed}FAILED${Color_Off}" +elif [[ $yesno == "2" ]]; then + echo "You've chosen NO, killing script. Good luck." +else + echo -e "${IRed}Invalid Selection${Color_Off}" +fi +} +export -f restore diff --git a/includes/chores.sh b/includes/chores.sh new file mode 100644 index 00000000..9f3cbc6a --- /dev/null +++ b/includes/chores.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +helmEnable(){ +echo -e "${BWhite}Enabling Helm${Color_Off}" +export KUBECONFIG=/etc/rancher/k3s/k3s.yaml && echo -e "${IGreen}Helm Enabled${Color_Off}"|| echo -e "${IRed}Helm Enable FAILED${Color_Off}" +} +export -f helmEnable + +aptEnable(){ +echo -e "${BWhite}Enabling Apt-Commands${Color_Off}" +chmod +x /usr/bin/apt* && echo -e "${IGreen}APT enabled${Color_Off}"|| echo -e "${IRed}APT Enable FAILED${Color_Off}" +} +export -f aptEnable + +kubeapiEnable(){ +local -r comment='iX Custom Rule to drop connection requests to k8s cluster from external sources' +echo -e "${BWhite}Enabling Kubernetes API${Color_Off}" +if iptables -t filter -L INPUT 2> /dev/null | grep -q "${comment}" ; then + iptables -D INPUT -p tcp -m tcp --dport 6443 -m comment --comment "${comment}" -j DROP && echo -e "${IGreen}Kubernetes API enabled${Color_Off}"|| echo -e "${IRed}Kubernetes API Enable FAILED${Color_Off}" +else + echo -e "${IGreen}Kubernetes API already enabled${Color_Off}" +fi +} +export -f kubeapiEnable + +# Prune unused docker images to prevent dataset/snapshot bloat related slowdowns on SCALE +prune(){ +echo -e "${BWhite}Docker Prune${Color_Off}" +echo "Pruning Docker Images..." +docker image prune -af | grep "^Total" && echo -e "${IGreen}Docker Prune Successfull${Color_Off}" || echo "Docker Prune ${IRed}FAILED${Color_Off}" + +# TODO Switch to middleware prune on next release +# midclt call container.prune '{"remove_unused_images": true, "remove_stopped_containers": true}' &> /dev/null && echo "Docker Prune completed"|| echo "Docker Prune ${IRed}FAILED${Color_Off}" +} +export -f prune + +# +sync(){ +echo -e "${BWhite}Starting Catalog Sync...${Color_Off}" +cli -c 'app catalog sync_all' &> /dev/null && echo -e "${IGreen}Catalog sync complete${Color_Off}" || echo -e "${IRed}Catalog Sync Failed${Color_Off}" +} +export -f sync diff --git a/includes/colors.sh b/includes/colors.sh new file mode 100644 index 00000000..a1f8cbdd --- /dev/null +++ b/includes/colors.sh @@ -0,0 +1,113 @@ +#!/bin/bash +# shellcheck disable=SC2034 + +# Reset +Color_Off='\033[0m' # Text Reset + +# Regular Colors +Black='\033[0;30m' # Black +Red='\033[0;31m' # Red +Green='\033[0;32m' # Green +Yellow='\033[0;33m' # Yellow +Blue='\033[0;34m' # Blue +Purple='\033[0;35m' # Purple +Cyan='\033[0;36m' # Cyan +White='\033[0;37m' # White + +# Bold +BBlack='\033[1;30m' # Black +BRed='\033[1;31m' # Red +BGreen='\033[1;32m' # Green +BYellow='\033[1;33m' # Yellow +BBlue='\033[1;34m' # Blue +BPurple='\033[1;35m' # Purple +BCyan='\033[1;36m' # Cyan +BWhite='\033[1;37m' # White + +# Underline +UBlack='\033[4;30m' # Black +URed='\033[4;31m' # Red +UGreen='\033[4;32m' # Green +UYellow='\033[4;33m' # Yellow +UBlue='\033[4;34m' # Blue +UPurple='\033[4;35m' # Purple +UCyan='\033[4;36m' # Cyan +UWhite='\033[4;37m' # White + +# High Intensity +IBlack='\033[0;90m' # Black +IRed='\033[0;91m' # Red +IGreen='\033[0;92m' # Green +IYellow='\033[0;93m' # Yellow +IBlue='\033[0;94m' # Blue +IPurple='\033[0;95m' # Purple +ICyan='\033[0;96m' # Cyan +IWhite='\033[0;97m' # White + + +# Bold High Intensity +BIBlack='\033[1;90m' # Black +BIRed='\033[1;91m' # Red +BIGreen='\033[1;92m' # Green +BIYellow='\033[1;93m' # Yellow +BIBlue='\033[1;94m' # Blue +BIPurple='\033[1;95m' # Purple +BICyan='\033[1;96m' # Cyan +BIWhite='\033[1;97m' # White + +noColor(){ +# Reset +Color_Off="" + +# Regular Colors +Black="" +Red="" +Green="" +Yellow="" +Blue="" +Purple="" +Cyan="" +White="" + +# Bold +BBlack="" +BRed="" +BGreen="" +BYellow="" +BBlue="" +BPurple="" +BCyan="" +BWhite="" + +# Underline +UBlack="" +URed="" +UGreen="" +UYellow="" +UBlue="" +UPurple="" +UCyan="" +UWhite="" + +# High Intensity +IBlack="" +IRed="" +IGreen="" +IYellow="" +IBlue="" +IPurple="" +ICyan="" +IWhite="" + + +# Bold High Intensity +BIBlack="" +BIRed="" +BIGreen="" +BIYellow="" +BIBlue="" +BIPurple="" +BICyan="" +BIWhite="" + } + export -f noColor diff --git a/includes/dns.sh b/includes/dns.sh new file mode 100644 index 00000000..0e12e90a --- /dev/null +++ b/includes/dns.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +dns(){ + echo -e "${BWhite}Service DNS Names Tool${Color_Off}" +clear -x +echo "Generating Internal Service DNS Names..." +#ignored dependency pods, may need to add more in the future. +dep_ignore="\-cronjob\-|^kube-system|\ssvclb|NAME|\-memcached\-.[^custom\-app]|\-postgresql\-.[^custom\-app]|\-redis\-.[^custom\-app]|\-mariadb\-.[^custom\-app]|\-promtail\-.[^custom\-app]" + +# Pulling pod names +mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$dep_ignore" | sort) + +# Pulling all ports +all_ports=$(k3s kubectl get service -A) + +clear -x +count=0 +for i in "${main[@]}" +do + [[ count -le 0 ]] && echo -e "\n" && ((count++)) + appName=$(echo "$i" | awk '{print $2}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//') + ixName=$(echo "$i" | awk '{print $1}') + port=$(echo "$all_ports" | grep -E "\s$appName\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}") + [[ -n "$port" ]] && echo -e "$appName.$ixName.svc.cluster.local $port" +done | uniq | nl -b t | sed 's/\s\s\s$/- -------- ----/' | column -t -R 1 -N "#,DNS_Name,Port" -L +} +export -f dns diff --git a/includes/help.sh b/includes/help.sh new file mode 100644 index 00000000..a31cd4fc --- /dev/null +++ b/includes/help.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +help(){ +[[ $help == "true" ]] && clear -x +echo "" +echo -e "${BWhite}Basic Utilities${Color_Off}" +echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" +echo "--restore | Opens a menu to restore a \"truetool\" backup that was taken on your \"ix-applications\" dataset" +echo "--delete-backup | Opens a menu to delete backups on your system" +echo "--list-backups | Prints a list of backups available" +echo "--helm-enable | Enables Helm command access on SCALE" +echo "--apt-enable | Enables Apt command access on SCALE" +echo "--kubeapi-enable | Enables external access to Kuberntes API port" +echo "--dns | List all of your applications DNS names and their web ports" +echo +echo -e "${BWhite}Update Options${Color_Off}" +echo "-U | Update all applications, ignores versions" +echo "-u | Update all applications, does not update Major releases" +echo "-b | Back-up your ix-applications dataset, specify a number after -b" +echo "-i | Add application to ignore list, one by one, see example below." +echo "-v | verbose output" +echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" +echo "-s | sync catalog" +echo "-p | Prune unused/old docker images" +echo +echo -e "${BWhite}Examples${Color_Off}" +echo "bash truetool.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vsUp" +echo "bash /mnt/tank/scripts/truetool.sh -t 150 --mount" +echo "bash /mnt/tank/scripts/truetool.sh --dns" +echo "bash /mnt/tank/scripts/truetool.sh --restore" +echo "bash /mnt/tank/scripts/truetool.sh --delete-backup" +echo +exit +} +export -f help diff --git a/includes/mount.sh b/includes/mount.sh new file mode 100644 index 00000000..7d5a6019 --- /dev/null +++ b/includes/mount.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +mountPVC(){ +echo -e "${BWhite}PVC Mounting Tool${Color_Off}" +clear -x +title +echo -e "1 Mount\n2 Unmount All" && read -rt 600 -p "Please type a number: " selection +[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script +if [[ $selection == "1" ]]; then + list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + echo "$list" && read -rt 120 -p "Please type a number: " selection + [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script + app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script + pvc=$(echo -e "$list" | grep ^"$selection ") + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + if [[ "$status" != "STOPPED" ]]; then + [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" + SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null + else + echo -e "\n$app is already stopped" + fi + while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] + do + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 + done + data_name=$(echo "$pvc" | awk '{print $3}') + volume_name=$(echo "$pvc" | awk '{print $4}') + full_path=$(zfs list | grep "$volume_name" | awk '{print $1}') + echo -e "\nMounting\n$full_path\nTo\n/mnt/truetool/$data_name" && zfs set mountpoint="/truetool/$data_name" "$full_path" && echo -e "Mounted, Use the Unmount All option to unmount\n" + exit +elif [[ $selection == "2" ]]; then + mapfile -t unmount_array < <(basename -a /mnt/truetool/* | sed "s/*//") + [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit + for i in "${unmount_array[@]}" + do + main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') + app=$(echo "$main" | awk '{print $1}' | cut -c 4-) + pvc=$(echo "$main" | awk '{print $3}') + mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused. + echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/truetool/"$i" || echo "${IRed}FAILED${Color_Off} to unmount $i" + else + # shellcheck disable=SC2128 + zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/truetool/"$i" || echo "${IRed}FAILED${Color_Off} to unmount $i" + fi + done + rmdir /mnt/truetool +else + echo -e "${IRed}Invalid selection, \"$selection\" was not an option${Color_Off}" +fi +} +export -f mountPVC diff --git a/includes/no_args.sh b/includes/no_args.sh new file mode 100644 index 00000000..9ff0f3c0 --- /dev/null +++ b/includes/no_args.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# shellcheck disable=SC2034 + +no_args(){ + echo "0 Show Help" + echo "1 List Internal Service DNS Names" + echo "2 Mount and Unmount PVC storage for easy access" + echo "3 List Backups" + echo "4 Create a Backup" + echo "5 Restore a Backup" + echo "6 Delete a Backup" + echo "7 Enable Helm Commands" + echo "8 Enable Apt and Apt-Get Commands" + echo "9 Update All Apps" + echo "10 Enable external access to Kuberntes API port" + read -rt 600 -p "Please select an option by number: " selection + + case $selection in + 0) + help="true" + ;; + 1) + dns="true" + ;; + 2) + mountPVC="true" + ;; + 3) + listBackups="true" + ;; + 4) + read -rt 600 -p "Please type the max number of backups to keep: " backups + re='^[0-9]+$' + number_of_backups=$backups + ! [[ $backups =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit + [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit + ;; + 5) + restore="true" + ;; + 6) + deleteBackup="true" + ;; + 7) + helmEnable="true" + ;; + 8) + aptEnable="true" + ;; + 9) + echo "" + echo "1 Update Apps Excluding likely breaking major changes" + echo "2 Update Apps Including likely breaking major changes" + read -rt 600 -p "Please select an option by number: " updateType + if [[ "$updateType" == "1" ]]; then + update_apps="true" + elif [[ "$updateType" == "2" ]]; then + update_all_apps="true" + else + echo "INVALID ENTRY" && exit 1 + fi + ;; + 10) + kubeapiEnable="true" + ;; + *) + echo "Unknown option" && exit 1 + ;; + esac + echo "" +} +export -f no_args diff --git a/includes/patch.sh b/includes/patch.sh new file mode 100644 index 00000000..82393dea --- /dev/null +++ b/includes/patch.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +patchv22120(){ +echo "Applying 22.12 HotPatch 1" +( wget -q -P /tmp https://github.com/truecharts/truetool/raw/main/hotpatch/2212/HP1.patch && echo "download completed" || echo "download failed" ) && ( patch -N -s -p0 -d /usr/lib/python3/dist-packages/middlewared/ < /tmp/HP1.patch && service middlewared restart && echo "waiting 20 seconds for middleware restart..." && sleep 20 && echo "patch completed" || echo "patch failed or skipped, not critical" ) && rm -rf /tmp/HP1.patch +echo "Applying 22.12 HotPatch 2" +( wget -q -P /tmp https://github.com/truecharts/truetool/raw/main/hotpatch/2212/HP2.patch && echo "download completed" || echo "download failed" ) && ( patch -N -s -p0 -d /usr/lib/python3/dist-packages/middlewared/ < /tmp/HP2.patch && service middlewared restart && echo "waiting 20 seconds for middleware restart..." && sleep 20 && echo "patch completed" || echo "patch failed or skipped, not critical" ) && rm -rf /tmp/HP2.patch +} +export -f patchv22120 + + +hotpatch(){ +echo "Starting hotpatcher..." +if [ "$(cli -m csv -c 'system version' | awk -F '-' '{print $3}')" == "22.12.0" ]; then + patchv22120 +fi +} +export -f hotpatch diff --git a/includes/title.sh b/includes/title.sh new file mode 100644 index 00000000..b6c9e740 --- /dev/null +++ b/includes/title.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Fancy ascii title. +title(){ +if [[ -z $titleShown ]]; then + echo -e "${IRed} _______ _____ _ _ "; + echo " |__ __| / ____| | | | "; + echo " | |_ __ _ _ ___| | | |__ __ _ _ __| |_ ___ "; + echo -e "${IYellow} | | '__| | | |/ _ \ | | '_ \ / _\` | '__| __/ __|"; + echo " | | | | |_| | __/ |____| | | | (_| | | | |_\__ \\"; + echo -e "${IGreen} __|_|_| \__,_|\___|\_____|_| |_|\__,_|_| \__|___/"; + echo " |__ __| |__ __| | | "; + echo -e "${IBlue} | |_ __ _ _ ___| | ___ ___ | | "; + echo " | | '__| | | |/ _ \ |/ _ \ / _ \| | "; + echo -e "${IPurple} | | | | |_| | __/ | (_) | (_) | | "; + echo " |_|_| \__,_|\___|_|\___/ \___/|_| "; + echo " "; + echo -e "${Color_Off} "; +fi +titleShown='true' +} +export -f title diff --git a/includes/update.sh b/includes/update.sh new file mode 100644 index 00000000..0aaa7506 --- /dev/null +++ b/includes/update.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +update_apps(){ +echo -e "${BWhite}App Updater${Color_Off}" +[[ -z $timeout ]] && echo -e "Default Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" +[[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" + +echo "" +echo "Creating list of Apps to update..." + +# Render a list of ignored applications, so users can verify their ignores got parsed correctly. +if [[ -z ${ignore[*]} ]]; then + echo "No apps added to ignore list, continuing..." +else + echo "ignored applications:" + for ignored in "${ignore[@]}" + do + echo "${ignored}" + done +fi +echo "" + +mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|$)" | sort) +[[ -z ${array[*]} ]] && echo -e "\nThere are no updates available or middleware timed out" && return 0 || echo -e "\n${#array[@]} update(s) available:" +PIDlist=() + +# Draft a list of app names, seperate from actuall execution +# This prevents outputs getting mixed together +for i in "${array[@]}" +do + app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. + echo "$app_name" +done + +echo "" +echo "Updating Apps..." + +# Create a background task for each update as async solution +for i in "${array[@]}" +do + executeUpdate "${i}" & + PIDlist+=($!) +done +echo "" +echo "Waiting for update results..." + +# Wait for all the async updates to complete +for p in "${PIDlist[@]}" +do + wait "${p}" ||: +done + +} +export -f update_apps + + + +# This is a combination of stopping previously-stopped apps and apps stuck Deploying after update +after_update_actions(){ +SECONDS=0 +count=0 +sleep 15 + +# Keep this running and exit the endless-loop based on a timer, instead of a countered-while-loop +# shellcheck disable=SC2050 +while [[ "0" != "1" ]] +do + (( count++ )) + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then + [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" + break + elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" != "true" ]]; then + echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update.." + midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null + [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update + break + elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" == "true" ]]; then + echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning" + break + elif [[ "$status" == "STOPPED" ]]; then + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + echo "Stopped" && break #if reports stopped any time after the first loop, assume its extermal services. + elif [[ "$status" == "ACTIVE" ]]; then + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check + echo "Active" && break #if reports active any time after the first loop, assume actually active. + else + [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" + sleep 15 + continue + fi +done +} +export -f after_update_actions + +# Determine what all the required information for the App to update, check it and execute the update using the SCALE API +executeUpdate(){ + app_name=$(echo "$1" | awk -F ',' '{print $1}') #print out first catagory, name. + old_app_ver=$(echo "$1" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version + new_app_ver=$(echo "$1" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version + old_chart_ver=$(echo "$1" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version + new_chart_ver=$(echo "$1" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version + status=$(echo "$1" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE + startstatus=$status + diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions + diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions + old_full_ver=$(echo "$1" | awk -F ',' '{print $4}') #Upgraded From + new_full_ver=$(echo "$1" | awk -F ',' '{print $5}') #Upraded To + rollback_version=$(echo "$1" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') + printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return #If application is on ignore list, skip + if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update + [[ "$verbose" == "true" ]] && echo "Updating.." + # shellcheck disable=SC2015 + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated $app_name\n$old_full_ver\n$new_full_ver" && after_update_actions || { echo -e "$app_name: update ${IRed}FAILED${Color_Off}"; return; } + else + echo -e "\n$app_name\nMajor Release, update manually" + return + fi +} +export -f executeUpdate diff --git a/includes/update_self.sh b/includes/update_self.sh new file mode 100644 index 00000000..7ade24e2 --- /dev/null +++ b/includes/update_self.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +## AutoUpdate TrueTool using Git +updater(){ +echo -e "${BWhite}Checking for updates...${Color_Off}" +git remote set-url origin "${targetRepo}" +BRANCH=$(git rev-parse --abbrev-ref HEAD) +git fetch -q +git update-index -q --refresh +if [[ $(git status --branch --porcelain) == *"behind"* ]]; then + echo -e "${IPurple}TrueTool requires update${Color_Off}" + git reset --hard -q + git checkout -q "${BRANCH}" + git pull -q + echo "script updated" + if [[ "$CHANGED" == "true" ]]; then + echo "LOOP DETECTED, exiting" + exit 1 + else + echo "restarting script after update..." + export CHANGED="true" + . "${SCRIPT_DIR}/truetool.sh" "$@" + exit + fi +else + echo -e "${IGreen}script up-to-date${Color_Off}" + export CHANGED="false" +fi +echo "" +} +export -f updater diff --git a/truetool.sh b/truetool.sh new file mode 100644 index 00000000..6e03990f --- /dev/null +++ b/truetool.sh @@ -0,0 +1,179 @@ +#!/bin/bash + +# Constants +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"; +dir=$(basename "$SCRIPT_DIR") + +# Change this if you want to fork the project +enableUpdate="true" +targetRepo="https://github.com/truecharts/truetool.git" + +# CD to the folder containing the script to ensure consistent runs +cd "${SCRIPT_DIR}" || echo -e "ERROR: Something went wrong accessing the script directory" + +# Includes +# shellcheck source=includes/backup.sh +source includes/backup.sh +# shellcheck source=includes/chores.sh +source includes/chores.sh +# shellcheck source=includes/colors.sh +source includes/colors.sh +# shellcheck source=includes/dns.sh +source includes/dns.sh +# shellcheck source=includes/help.sh +source includes/help.sh +# shellcheck source=includes/help.sh +source includes/patch.sh +# shellcheck source=includes/mount.sh +source includes/mount.sh +# shellcheck source=includes/no_args.sh +source includes/no_args.sh +# shellcheck source=includes/title.sh +source includes/title.sh +# shellcheck source=includes/update.sh +source includes/update.sh +# shellcheck source=includes/update_self.sh +source includes/update_self.sh + +#If no argument is passed, set flag to show menu +if [[ -z "$*" || "-" == "$*" || "--" == "$*" ]]; then + no_args="true" +else + + # Parse script options + while getopts ":si:b:t:uUpSv-:" opt + do + case $opt in + -) + case "${OPTARG}" in + help) + help="true" + ;; + dns) + dns="true" + ;; + mount) + mountPVC="true" + ;; + restore) + restore="true" + ;; + delete-backup) + deleteBackup="true" + ;; + list-backups) + listBackups="true" + ;; + helm-enable) + helmEnable="true" + ;; + apt-enable) + aptEnable="true" + ;; + kubeapi-enable) + kubeapiEnable="true" + ;; + no-color) + noColor + ;; + *) + echo -e "Invalid Option \"--$OPTARG\"\n" && help + exit + ;; + esac + ;; + \?) + echo -e "Invalid Option \"-$OPTARG\"\n" && help + exit + ;; + :) + echo -e "Option: \"-$OPTARG\" requires an argument\n" && help + exit + ;; + b) + re='^[0-9]+$' + number_of_backups=$OPTARG + ! [[ $OPTARG =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit + [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit + ;; + i) + ignore+=("$OPTARG") + ;; + t) + re='^[0-9]+$' + timeout=$OPTARG + ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n\"""$timeout""\" is not an interger" >&2 && exit + ;; + s) + sync="true" + ;; + U) + update_all_apps="true" + ;; + u) + update_apps="true" + ;; + p) + prune="true" + ;; + v) + verbose="true" + ;; + *) + echo -e "Invalid Option \"--$OPTARG\"\n" && help + exit + ;; + esac + done +fi + +title + +[[ "$enableUpdate" == "true" ]] && updater "$@" + +## Always check if a hotpatch needs to be applied +hotpatch + +# Show menu if menu flag is set +if [[ "$no_args" == "true" ]]; then + no_args +fi + +## Exit if incompatable functions are called +[[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit + +## Exit if unsafe combinations are used +# Restore and update right after eachother, might cause super weird issues tha are hard to bugtrace +[[ ( "$update_all_apps" == "true" || "$update_apps" == "true" ) && ( "$restore" == "true" ) ]] && echo -e "Update and Restore cannot both be done in the same run..." && exit + +# Backup Deletion is generally considered to be a "once in a while" thing and not great to sync with automated updates for that reason +[[ ( "$update_all_apps" == "true" || "$update_apps" == "true" ) && ( "$deleteBackup" == "true" ) ]] && echo -e "Update Backup-Deletion cannot both be done in the same run..." && exit + +# Backup Deletion is generally considered to be a "once in a while" thing and not great to sync with automated updates for that reason +[[ ( "$update_all_apps" == "true" || "$update_apps" == "true" ) && ( "$deleteBackup" == "true" ) ]] && echo -e "Update and Backup-Deletion cannot both be done in the same run..." && exit + +# Backup listing is a printout, which would either clutter the output or be already outdated when combined with backup +[[ ( "$update_all_apps" == "true" || "$update_apps" == "true" ) && ( "$listBackups" == "true" ) ]] && echo -e "Update and Listing Backups cannot both be done in the same run..." && exit + +# Backup backup would be done after a backup is restored, which would lead to a backup that is... the same as the one restored... +[[ ( "$restore" == "true" && "$number_of_backups" -ge 1 )]] && echo -e "Restoring a backup and making a backup cannot both be done in the same run..." && exit + +# While technically possible, this is asking for user error... where a user by habit mistakes one prompt, for the other. +[[ ( "$restore" == "true" && "$deleteBackup" == "true" )]] && echo -e "restoring a backup and deleting a backup cannot both be done in the same run..." && exit + + +# Continue to call functions in specific order +[[ "$help" == "true" ]] && help +[[ "$helmEnable" == "true" ]] && helmEnable +[[ "$aptEnable" == "true" ]] && aptEnable +[[ "$kubeapiEnable" == "true" ]] && kubeapiEnable +[[ "$aptEnable" == "true" || "$helmEnable" == "true" || "$kubeapiEnable" == "true" ]] && exit +[[ "$listBackups" == "true" ]] && listBackups && exit +[[ "$deleteBackup" == "true" ]] && deleteBackup && exit +[[ "$dns" == "true" ]] && dns && exit +[[ "$restore" == "true" ]] && restore && exit +[[ "$mountPVC" == "true" ]] && mountPVC && exit +[[ "$number_of_backups" -ge 1 ]] && backup +[[ "$sync" == "true" ]] && sync +[[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && update_apps +[[ "$prune" == "true" ]] && prune From 664fc455db606bd1df0361d010e64b4cac9e3e73 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Tue, 27 Dec 2022 11:56:40 +0100 Subject: [PATCH 821/823] remove unused folder --- patches/backups.patch | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 patches/backups.patch diff --git a/patches/backups.patch b/patches/backups.patch deleted file mode 100644 index 3ce5de06..00000000 --- a/patches/backups.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- /usr/lib/python3/dist-packages/middlewared/plugins/kubernetes_linux/backup.py 2022-12-13 05:32:23.000000000 -0700 -+++ backups.patch 2022-12-26 14:14:25.075037767 -0700 -@@ -61,7 +61,8 @@ - ['metadata.namespace', '=', chart_release['namespace']] - ] - ) -- for secret in sorted(secrets, key=lambda d: d['metadata']['name']): -+ # We ignore this keeping in line with helm behaviour where the secret malformed is ignored by helm -+ for secret in sorted(filter(lambda d: d.get('data'), secrets), key=lambda d: d['metadata']['name']): - with open(os.path.join(secrets_dir, secret['metadata']['name']), 'w') as f: - f.write(self.middleware.call_sync('k8s.secret.export_to_yaml_internal', secret)) \ No newline at end of file From a58d53ac4ee50ed3c28cc1ba77a366f173efa08e Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Tue, 27 Dec 2022 11:57:57 +0100 Subject: [PATCH 822/823] add license to Heavyscript functions --- functions/LICENSE | 674 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 functions/LICENSE diff --git a/functions/LICENSE b/functions/LICENSE new file mode 100644 index 00000000..f288702d --- /dev/null +++ b/functions/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From 407ebddbca345bf311b4159b17002427e6c95541 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Tue, 27 Dec 2022 12:02:56 +0100 Subject: [PATCH 823/823] run pre-commit --- functions/backup.sh | 14 +++++++------- functions/cmd_to_container.sh | 6 +++--- functions/dns.sh | 2 +- functions/menu.sh | 8 ++++---- functions/misc.sh | 11 +++++------ functions/mount.sh | 16 ++++++++-------- functions/script_create.sh | 18 +++++++++--------- functions/self_update.sh | 8 ++++---- functions/update_apps.sh | 28 ++++++++++++++-------------- heavy_script.sh | 8 ++++---- 10 files changed, 59 insertions(+), 60 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 3a2e9b71..f0c2baf6 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -19,7 +19,7 @@ if [[ ${#list_backups[@]} -gt "$number_of_backups" ]]; then done fi -#Dump the echo_array, ensures all output is in a neat order. +#Dump the echo_array, ensures all output is in a neat order. for i in "${echo_backup[@]}" do echo -e "$i" @@ -52,9 +52,9 @@ do read -rt 240 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') if [[ $selection == 0 ]]; then - echo "Exiting.." + echo "Exiting.." exit - elif [[ -z "$selection" ]]; then + elif [[ -z "$selection" ]]; then echo "Your selection cannot be empty" sleep 3 continue @@ -70,7 +70,7 @@ done while true do clear -x - echo -e "WARNING:\nYou CANNOT go back after deleting your restore point" + echo -e "WARNING:\nYou CANNOT go back after deleting your restore point" echo -e "\n\nYou have chosen:\n$restore_point\n\n" read -rt 120 -p "Would you like to proceed with deletion? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } case $yesno in @@ -104,7 +104,7 @@ do exit ;; *) - echo "$yesno was not an option, try again" + echo "$yesno was not an option, try again" sleep 2 continue ;; @@ -136,9 +136,9 @@ do read -rt 240 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') if [[ $selection == 0 ]]; then - echo "Exiting.." + echo "Exiting.." exit - elif [[ -z "$selection" ]]; then + elif [[ -z "$selection" ]]; then echo "Your selection cannot be empty" sleep 3 continue diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index e6f36f48..a9a4132e 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -6,7 +6,7 @@ app_name=$(k3s crictl pods -s ready --namespace ix | sed -E 's/[[:space:]]([0-9] while true do clear -x - title + title echo "Command to Container Menu" echo "-------------------------" echo "$app_name" @@ -92,7 +92,7 @@ do exit ;; 1) - clear -x + clear -x title read -rt 500 -p "What command do you want to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } # shellcheck disable=SC2086 @@ -116,4 +116,4 @@ do done rm cont_file 2> /dev/null } -export -f cmd_to_container \ No newline at end of file +export -f cmd_to_container diff --git a/functions/dns.sh b/functions/dns.sh index ad6536d3..e628c12a 100644 --- a/functions/dns.sh +++ b/functions/dns.sh @@ -24,4 +24,4 @@ do done | nl -s ") " -b t | sed '0,/\s\s\s/{s/\s\s\s/- ---- -------- ----/}'| column -t -N "#,Name,DNS_Name,Port" rm dns_file } -export -f dns \ No newline at end of file +export -f dns diff --git a/functions/menu.sh b/functions/menu.sh index 82a04e03..8f808c57 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -28,7 +28,7 @@ case $selection in help ;; 2) - dns + dns ;; 3) mount @@ -71,7 +71,7 @@ case $selection in esac done ;; - + 5) self_update ;; @@ -84,7 +84,7 @@ case $selection in 8) patch_2212_backups ;; - 9) + 9) patch_2212_backups2 ;; *) @@ -93,4 +93,4 @@ case $selection in esac echo } -export -f menu \ No newline at end of file +export -f menu diff --git a/functions/misc.sh b/functions/misc.sh index 408fcd58..dd1ae239 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -2,10 +2,10 @@ sync(){ -echo_sync+=("🅂 🅈 🄽 🄲") +echo_sync+=("🅂 🅈 🄽 🄲") cli -c 'app catalog sync_all' &> /dev/null && echo_sync+=("Catalog sync complete") -#Dump the echo_array, ensures all output is in a neat order. +#Dump the echo_array, ensures all output is in a neat order. for i in "${echo_sync[@]}" do echo -e "$i" @@ -17,7 +17,7 @@ export -f sync prune(){ -echo -e "🄿 🅁 🅄 🄽 🄴" +echo -e "🄿 🅁 🅄 🄽 🄴" version="$(cli -c 'system version' | awk -F '-' '{print $3}' | awk -F '.' '{print $1 $2}' | tr -d " \t\r\.")" if (( "$version" >= 2212 )); then if ! cli -c 'app container config prune prune_options={"remove_unused_images": true, "remove_stopped_containers": true}' | head -n -4; then @@ -170,7 +170,7 @@ do continue ;; esac -done +done } @@ -228,6 +228,5 @@ do continue ;; esac -done +done } - diff --git a/functions/mount.sh b/functions/mount.sh index 7badfc58..371c98d7 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -28,15 +28,15 @@ do do clear -x title - echo "$list" - echo + echo "$list" + echo echo "0) Exit" read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - + #Check for valid selection. If no issues, continue [[ $selection == 0 ]] && echo "Exiting.." && exit app=$(echo -e "$list" | grep ^"$selection)" | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && continue + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && continue pvc=$(echo -e "$list" | grep ^"$selection)") #Stop applicaiton if not stopped @@ -64,7 +64,7 @@ do echo -e "\nMounted\n$data_name" fi echo -e "\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" - + #Ask if user would like to mount something else while true do @@ -80,7 +80,7 @@ do exit ;; *) - echo "Invalid selection \"$yesno\" was not an option" + echo "Invalid selection \"$yesno\" was not an option" sleep 3 continue ;; @@ -97,7 +97,7 @@ do app=$(echo "$main" | awk '{print $1}' | cut -c 4-) pvc=$(echo "$main" | awk '{print $3}') full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - zfs set mountpoint=legacy "$full_path""$pvc" + zfs set mountpoint=legacy "$full_path""$pvc" echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" done rmdir /mnt/heavyscript @@ -111,4 +111,4 @@ do esac done } -export -f mount \ No newline at end of file +export -f mount diff --git a/functions/script_create.sh b/functions/script_create.sh index 63802e63..3f1c26e4 100644 --- a/functions/script_create.sh +++ b/functions/script_create.sh @@ -2,7 +2,7 @@ script_create(){ -while true +while true do clear -x title @@ -19,7 +19,7 @@ do echo "Exiting.." exit ;; - 1 | -U) + 1 | -U) while true do echo -e "\nHow many applications do you want updating at the same time?" @@ -69,7 +69,7 @@ do ;; esac done -while true +while true do clear -x title @@ -91,9 +91,9 @@ do echo echo "99) Remove Update Options, Restart" echo "00) Done making selections, proceed with update" - echo + echo echo "0) Exit" - echo + echo echo "Current Choices" echo "---------------" echo "bash heavy_script.sh ${update_selection[*]}" @@ -153,11 +153,11 @@ do ;; 9 | --ignore-img ) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "--ignore-img" && echo -e "\"--ignore-img\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("--ignore-img") + update_selection+=("--ignore-img") ;; 10 | --self-update ) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "--self-update" && echo -e "\"--self-update\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("--self-update") + update_selection+=("--self-update") ;; 99) count=2 @@ -172,9 +172,9 @@ do continue ;; *) - echo "\"$current_selection\" was not an option, try again" && sleep 3 && continue + echo "\"$current_selection\" was not an option, try again" && sleep 3 && continue ;; esac done } -export -f script_create \ No newline at end of file +export -f script_create diff --git a/functions/self_update.sh b/functions/self_update.sh index e06b2dc9..32795d01 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -11,7 +11,7 @@ echo "🅂 🄴 🄻 🄵" echo "🅄 🄿 🄳 🄰 🅃 🄴" if [[ "$hs_version" != "$latest_ver" ]] ; then echo "Found a new version of HeavyScript, updating myself..." - git checkout "$latest_ver" &>/dev/null + git checkout "$latest_ver" &>/dev/null count=0 for i in "${args[@]}" do @@ -22,16 +22,16 @@ if [[ "$hs_version" != "$latest_ver" ]] ; then echo "Updating To: $latest_ver" echo "Changelog:" curl --silent "https://api.github.com/repos/HeavyBullets8/heavy_script/releases/latest" | jq -r .body - echo + echo [[ -z ${args[*]} ]] && echo -e "No more arguments, exiting..\n\n" && exit echo -e "Running the new version...\n\n" sleep 5 exec bash "$script_name" "${args[@]}" # Now exit this old instance exit -else +else echo "HeavyScript is already the latest version:" echo -e "$hs_version\n\n" fi } -export -f self_update \ No newline at end of file +export -f self_update diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 9f54bb33..6ad0d59f 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -38,7 +38,7 @@ do if [[ "$failed_ver" == "$new_full_ver" ]] ; then echo -e "\n$app_name\nSkipping previously failed version:\n$new_full_ver" unset "array[$index]" - else + else sed -i /"$app_name",/d failed fi #Skip Image updates if ignore image updates is set to true @@ -59,7 +59,7 @@ rm finished 2>/dev/null while [[ ${#processes[@]} != 0 || $(wc -l finished 2>/dev/null | awk '{ print $1 }') -lt "${#array[@]}" ]] do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' 2>/dev/null) ; then - ((while_count++)) + ((while_count++)) [[ -z $while_status ]] && continue || echo -e "$while_count\n$while_status" > all_app_status mapfile -t deploying_check < <(grep ",DEPLOYING," all_app_status) for i in "${deploying_check[@]}" @@ -78,14 +78,14 @@ do for proc in "${processes[@]}" do kill -0 "$proc" &> /dev/null || unset "processes[$count]" - ((count++)) + ((count++)) done processes=("${processes[@]}") if [[ $index -lt ${#array[@]} && "${#processes[@]}" -lt "$update_limit" ]]; then pre_process "${array[$index]}" & processes+=($!) ((index++)) - else + else sleep 3 fi done @@ -107,7 +107,7 @@ rollback_version=$(echo "${array[$index]}" | awk -F ',' '{print $4}' | awk -F '_ # Check if app is external services, append outcome to external_services file [[ ! -e external_services ]] && touch external_services -if ! grep -qs "^$app_name," external_services ; then +if ! grep -qs "^$app_name," external_services ; then if ! grep -qs "/external-service" /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/"$(find /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/ -maxdepth 1 -type d -printf '%P\n' | sort -r | head -n 1)"/Chart.yaml; then echo "$app_name,false" >> external_services else @@ -178,7 +178,7 @@ count=0 if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do - + # If app reports ACTIVE right away, assume its a false positive and wait for it to change, or trust it after 5 updates to all_app_status status=$(grep "^$app_name," all_app_status | awk -F ',' '{print $2}') if [[ $count -lt 1 && $status == "ACTIVE" && "$(grep "^$app_name," deploying 2>/dev/null | awk -F ',' '{print $2}')" != "DEPLOYING" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. @@ -210,7 +210,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then break else echo_array+=("Active") - break + break fi elif [[ "$SECONDS" -ge "$timeout" ]]; then if [[ $rollback == "true" ]]; then @@ -219,14 +219,14 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") echo_array+=("If this is a slow starting application, set a higher timeout with -t") echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration") - echo_array+=("Reverting update..") + echo_array+=("Reverting update..") if rollback_app ; then echo_array+=("Rolled Back") else echo_array+=("Error: Failed to rollback $app_name\nAbandoning") echo_array return 1 - fi + fi failed="true" SECONDS=0 count=0 @@ -286,7 +286,7 @@ do do sleep 1 done - else + else break fi done @@ -316,7 +316,7 @@ do break elif [[ ! $update_avail =~ "true" ]]; then break - else + else sleep 3 fi done @@ -338,7 +338,7 @@ do do sleep 1 done - else + else break fi done @@ -347,7 +347,7 @@ export -f stop_app echo_array(){ -#Dump the echo_array, ensures all output is in a neat order. +#Dump the echo_array, ensures all output is in a neat order. for i in "${echo_array[@]}" do echo -e "$i" @@ -360,4 +360,4 @@ export -f echo_array final_check(){ [[ ! -e finished ]] && touch finished echo "$app_name,finished" >> finished -} \ No newline at end of file +} diff --git a/heavy_script.sh b/heavy_script.sh index 91c0bc36..065a4c76 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,7 +5,7 @@ script=$(readlink -f "$0") script_path=$(dirname "$script") script_name="heavy_script.sh" -cd "$script_path" || { echo "Error: Failed to change to script directory" ; exit ; } +cd "$script_path" || { echo "Error: Failed to change to script directory" ; exit ; } #Version hs_version=$(git describe --tags) @@ -98,7 +98,7 @@ do update_limit="$nextopt" else update_limit=1 - fi + fi ;; u) update_apps="true" @@ -129,7 +129,7 @@ do done -#exit if incompatable functions are called +#exit if incompatable functions are called [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit #Continue to call functions in specific order @@ -157,5 +157,5 @@ elif [[ "$sync" == "true" && -z "$number_of_backups" ]]; then # If only sync is sync fi [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander -[[ "$prune" == "true" ]] && prune +[[ "$prune" == "true" ]] && prune exit 0