diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..a2423474 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ + +menu/start.sh +menu/hcloud/LICENSE +menu/gce/functions/oldfile.sh + diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..06df1b53 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,200 @@ + +## Unreleased 1.0.5 (date) + +### New Features + +### Improvements +- added self test to the config screen for plex_autoscan. + +### Fixes +- plex_autoscan config improvements, still needs more work but should be a little more robust now. + +----- + +## Pre 1.0.5 changelog. + +**WIKI will updated soon** +Update PTS from 22.10.2018 + +**PTS_Install** +* install.sh used now more ansible +* aliase role added +* folder role added +* systemtweak role added + +# +Update PTS from 19.10.2018 + +**BASE_System** +* Processing disk part changed and fixxed +* PGUI Switch command fixed ( read and executed now the right files ) +* PGUI Switch _ print now [ open or closed Ports ] + PGUI - domain +* is Domain not set -> +``` +[6] Comm UI : [ On ] | Port [ 8555 ] | **pgui.NOT-SET** +``` +is Domain set -> +``` +[6] Comm UI : [ On ] | Port [ 8555 ] | **pgui.print-domain.com** +``` + +* is port status CLOSED -> +``` +[6] Comm UI : [ On ] | Port [ **CLOSED** ] | pgui.NOT-SET +``` +* is port status OPEN -> +``` +[6] Comm UI : [ On ] | Port [ **8555 **] | **pgui.print-domain.com** +``` + +**rClone** +* small updates in cloneclean.sh +* variable set ( uaganet automatic create random agent for first install ) +* cloneclean preset to 600min +* cloneclean.sh fixed ; remove empty folder in "$hdpath/move" + +**PTS Vault** +* used the VFS Settings / useragent now + + + +*** + +Update PTS from 16.10.2019 + +**rClone:** +* mounts fixxed ( sorry ) + +**MAIN - SYSTEM** +* mot.d : +1. hostname print as header ( colored ) +2. Space - local and Space - Cloud edit +* remove qoute ( old shit part ) and replay with /usr/games/fortune -as +* new command : autobackup +* Layout edit ( interface ) + + +**Vault** +* autobackup add + +**Install:** +* small fix for install + +**Core Apps** +* rtorrent -main stage fixxed + + +*** + +Update PTS from 15.10.2019 +** + +* Traefik : untouched +* Shield : untouched + + +**MAIN - SYSTEM** +* mergerfs role fixxed +* rclone role fixxed +* update role included +* system update role included +* docker latest stable version install over role +* autmatic install journal role +* automatic install mergerfs ( latest release ) +* autmatic install rclone ( latest release ) + + + +**rClone** +* backup & restore Keys and rclone.config in seperate folder on gdrive +* pgblitz / move added +``` + --exclude-from="/opt/appdata/plexguide/transport.exclude" + --exclude-from="/opt/pgclone/excluded/excluded.folder" +```` +* cloneclean edit = for catching the right folder +* services gdrvie / tdrive --stats \ added +* Update gaccount.sh for first install +* update useraganet : variable is 32 characters for no duplicates of agents +* automatic retrieng to mount GDrive / Tdrive and GCrypt / TCrypt 5x +* automatic restarting docker after deploy new VFS Setting + + + +**BASE-SYSTEM** +* small fixxes in the pts-function +* small fixxes in the install.sh +* docker role based for ubuntu & debian +* small fix in mountcheck +* removing the most Brandings +* google_cloud_sdk install over ansible role ( automatic ) +* hetzner_cloud enige installed now the latest version ( automatic ) + + +**APPS** +* all apps now support goauth +* downloader folder + +**finished :** +* NZB clients = /mnt/downloands/nzb +* Torrent = /mnt/downloands/torrent + +**Plex** +* support now LinuxServer:IO image +* Media Plugins added +* HAMA / SONARR / RADARR autmatic installed over ansible +* Some DB edits = db size to 2000 + +**rutorrent** +* downloasd going to /mnt/incomplete/torrent after finished automatic moved to /mnt/downloads/torrent/ + +**NZBGET** +* some pugins added + + +**(( remote mapping ))** +* radarr / sonarr : +* one folder for NZB / torrent now +* /mnt/downloads/nzb = all NZB clients **[ CORE APPS !! ]** +* /mnt/downloads/torrent = all torrent clients **[ CORE APPS !! ]** + +**apps comm:** + +* all apps support now GOauth +* Community UI edit | for list used spaces +* Google Drive used space reloading daily + +**short Commands** +* scommands add for list all possible commands | included infos now +* same short commands added + + + +**Vault** + +* small fixxes for upload tweaking +* useragent included now + +**traktarr ( old pgtrakt )** + +* max year from 2019 to 2050 +* anime now possible +* commands are the same as before + + +**system tweaks** + +* crontabs added + +``` +#Ansible: Build a Cron Job - Auto Prune +@daily prune 1>/dev/null 2>&1 +#Ansible: Build a Cron Job - Journal Purge +@daily jpurge 1>/dev/null 2>&1 +#Ansible: Build a Cron Job - Update Weekly +@weekly update 1>/dev/null 2>&1 +#Ansible: Build a Cron Job - remove logs after reboot +@reboot kill_logs 1>/dev/null 2>&1 +#Ansible: Build a Cron Job - remove logs daily +@daily kill_logs 1>/dev/null 2>&1 +``` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..f3229c5b --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ +.. 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..42ec365d --- /dev/null +++ b/README.md @@ -0,0 +1,120 @@ + +_**Table of Contents**_ + +1. [Install](#1-install) +2. [Project Statement](#2-project-statement) +3. [Functional Use](#3-functional-use) +4. [Testimonials](#4-testimonials) +5. [Recommended Reading](#5-recommended-reading) +6. [Having Issues?](#6-having-issues) + + +---- + +# 1. Install + +## (i) Backup your current server using PTS Vault before installing PTS. + +Your PTS backup can be used to restore your applications in PTS fork after install (see later) +**NOTE** Tested and working for PG v8.5-8.7 + +Type the following to access your current build's menu: `sudo pgblitz` +Select `[7] PTS vault [Backup & Restore]` then +Select `[1] Utlizie PTS Vault` then +Select `[1] Data Backup` - At this stage you can either type `all` (to backup all apps) OR `appname` (to queue/stack apps which you would like to backup) followed by typing `A`. + + +**IMPORTANT** +If you have an encrypted drive and have forgotten, not documented or not backed up your SALT/password for PTS Clone, you should at this stage also backup your keys/rclone.config to gdrive. This can be done by the following: + +Type or paste the following to backup your keys: +``` +sudo wget -N https://raw.githubusercontent.com/PTS-Team/PTS-Clone/final/functions/backup-keys.sh +``` + + +## (ii) Installing PTS + +**NOTE** +The ideal method of installing the PTS fork is to delete your current build and install PTS fork on a clean system. PTS fork works best on **ubuntu 18.XX** and this tutorial will assume you are using ubuntu 18.XX. If you are unsure on how to do this, please refer to the documentation provided by your server provider. + +Once your server has an OS installed, login to your server using SSH. + +Type or paste the following to install PTS fork: + +``` +sudo rm -rf /opt/plexguide && sudo rm -rf /var/plexguide && sudo apt-get install wget -y && sudo wget -qO - https://raw.githubusercontent.com/PTS-Team/Install/master/install.sh | sudo bash + +``` + +The installation will then take you through the setup which is self-explanatory. + + +### Alternative method of installing PTS fork (without removing your current build) + +**NOTE** This has currently only been tested with PG v8.5-8.7 + +Type or paste the following: + +``` +sudo rm -rf /opt/plexguide && sudo rm -rf /var/plexguide && sudo apt-get install wget -y && sudo wget -qO - https://raw.githubusercontent.com/PTS-Team/Install/master/install.sh | sudo bash + +``` + +After the install has completed, you will need to **rerun** the above command again. This is required in order to override all the files created by your previous build. Many applications in PTS use env date and NON-set methods, these have to be overwritten and set back to NON-SET. + + +## Configuring PTS + +Configuring PTS fork is the same as configuring PG / PlexGuide. + +Type the following to run the PTS menu: `sudo pts` + +* Set up and deploy Traefik ([see here](https://github.com/PTS-Team/PTS-Team/wiki/Traefik)) + +* Close ports using Port Guard ([see here](https://github.com/PTS-Team/PTS-Team/wiki/PTS-Port-Guard)) + +* Deploy PTS Shield (GOAuth - all apps supported) [see here](https://github.com/PTS-Team/PTS-Team/wiki/PTS-Shield) + +* Set up and deploy rClone. You can restore you backup keys at this stage. [see here](https://github.com/PTS-Team/PTS-Team/wiki/PTS-Clone) + +* (Optional) Restore PTS backup (created in step 1) using PTS Vault. [see here](https://github.com/PTS-Team/PTS-Team/wiki/PTS-Vault---Data-Storage) + +* Install desired core/community applications (Do this regardless of whether it is a fresh install with restore or overwrite) [see here](https://github.com/PTS-Team/PTS-Team/wiki/core-apps) + +* (Optional) If overwriting/restoring, you will need to change 2 remote path mappings in applications (NZB clients / Torrent clients / radarr / sonarr / lidarr etc) [see here](https://github.com/PTS-Team/PTS-Team/wiki/Remote-Path-Mappings) + + +**Why do I need to change remote paths?** +PTS will create one download folder for completed downloads using any NZB client `/mnt/downloads/nzb` and one download folder for completed downloads using any torrent client `/mnt/downloads/torrent`. Both folder names are different to those used in previous versions of PTS. This remote paths need to be changed in your configuration settings (nzbget/radarr/sonarr etc) which you can do in either in terminal or webUI. + + +**NOTE** PTS fork does **not** install PTSUI by default. You will need to do this through [5]APPBox. If you are overwriting your current build you and wish to continue using PGUI, you must first remove PGUI from your current build and reinstall it using [5]APPBox. You can do this by typing the following command: `sudo rm -rf /opt/appdata/pgui/*` + + +# 2. Project Statement + +PTS is a **fork ** of PG / Plexguide, an all-in-one media solution that deploys a Media Server through the use of either your local HDD or Google Drive; serving as unlimited back-end storage. PTS utilizes Ansible and Docker to streamline your Media Server while deploying multiple tools for your server operations. + +# 3. Functional Use + +1. Deploys multiple programs/apps and functional within 10 - 30 seconds +1. Deploy PTS on a remote machine, local machine, VPS, or virtual machines +1. Deploy PTS utilizing Google's GSuite for unlimited space or through the solo or multiple HD editions +1. Deploys a Reverse Proxy (Traefik) so you can obtain https:// certificates on all your containers +1. Backup and Restore data through your Google Drive +1. Aligns data and ports for efficiency +1. Deploys with a simple installer and a GUI like interface (commands do not have to be typed out) + +# 4. Testimonials + + + + +# 5. Recommended Reading + +[**[Click Here]**](https://github.com/PTS-Team/PTS-Team/wiki/Pre-Reading) to view the list! + +## 6. Having Issues? + +[**[Click Here]**](https://github.com/PTS-Team/PTS-Team/wiki/Common-Issues) for more information! diff --git a/menu/alias/alias.yml b/menu/alias/alias.yml new file mode 100644 index 00000000..28a036e0 --- /dev/null +++ b/menu/alias/alias.yml @@ -0,0 +1,174 @@ +#!/bin/bash +# +# Title: PTS List commands +# Author(s): MrDoobPG +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + ###### Install PTSupdate + + - name: PTSupdate + template: + src: ptsupdate + dest: /bin/ptsupdate + force: yes + mode: 0775 + + ###### Install PGBlitz + + - name: PlexGuide + template: + src: plexguide + dest: /bin/plexguide + force: yes + mode: 0775 + owner: root + + - name: PTS + template: + src: pts + dest: /bin/pts + force: yes + mode: 0775 + owner: root + + - name: PGBlitz + template: + src: pgblitz + dest: /bin/pgblitz + force: yes + mode: 0775 + owner: root + + ###### Server reboot + + - name: server reboot + template: + src: reboot + dest: /bin/reboot + force: yes + mode: 0775 + + ###### Check list of services + + - name: list systemd services + template: + src: slist + dest: /bin/slist + force: yes + mode: 0775 + owner: root + + - name: list pts commands + template: + src: scommands + dest: /bin/scommands + force: yes + mode: 0775 + owner: root + + ###### Server update + + - name: update server + template: + src: update + dest: /bin/update + force: yes + mode: 0775 + + ###### Server upgrade + + - name: upgrade server + template: + src: upgrade + dest: /bin/upgrade + force: yes + mode: 0775 + owner: root + + ###### Install app + + - name: install appname + template: + src: install + dest: /bin/install + force: yes + mode: 0775 + owner: root + + ###### Autoremove installed app packages + + - name: autoremove unused packages after app install + template: + src: autoremove + dest: /bin/autoremove + force: yes + mode: 0775 + owner: root + + - name: Prune docker containers appname + template: + src: prune + dest: /bin/prune + force: yes + mode: 0775 + owner: root + + - name: Install PTS-User ADD + template: + src: ptsadd + dest: /bin/ptsadd + force: yes + mode: 0775 + + - name: Install rclone updater + template: + src: rcupdate + dest: /bin/rcupdate + force: yes + mode: 0775 + + - name: Install mergerfes updater + template: + src: mgupdate + dest: /bin/mgupdate + force: yes + mode: 0775 + + - name: Install Backup & Restore + template: + src: backup + dest: /bin/backup + force: yes + mode: 0775 + + - name: GCE + template: + src: gce + dest: /bin/gce + force: yes + mode: 0775 + + - name: purge old Journal files + template: + src: jpurge + dest: /bin/jpurge + force: yes + mode: 0775 + + - name: purge old log files + template: + src: kill_logs + dest: /bin/kill_logs + force: yes + mode: 0775 + + - name: automatic backup /opt/appdata + template: + src: autobackup + dest: /bin/autobackup + force: yes + mode: 0775 \ No newline at end of file diff --git a/menu/alias/templates/autobackup b/menu/alias/templates/autobackup new file mode 100644 index 00000000..08b95569 --- /dev/null +++ b/menu/alias/templates/autobackup @@ -0,0 +1,5 @@ +#!/bin/bash + +#### automatic backup apps + +bash /opt/plexguide/menu/pgvault/autobackup.sh \ No newline at end of file diff --git a/menu/alias/templates/autoremove b/menu/alias/templates/autoremove new file mode 100644 index 00000000..316e25eb --- /dev/null +++ b/menu/alias/templates/autoremove @@ -0,0 +1,9 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +sudo apt autoremove diff --git a/menu/alias/templates/backup b/menu/alias/templates/backup new file mode 100644 index 00000000..9c6e7252 --- /dev/null +++ b/menu/alias/templates/backup @@ -0,0 +1,8 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +bash /opt/plexguide/menu/pgcloner/pgvault.sh \ No newline at end of file diff --git a/menu/alias/templates/gce b/menu/alias/templates/gce new file mode 100644 index 00000000..581fa0df --- /dev/null +++ b/menu/alias/templates/gce @@ -0,0 +1,8 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +bash /opt/plexguide/menu/pgcloner/blitzgce.sh diff --git a/menu/alias/templates/install b/menu/alias/templates/install new file mode 100644 index 00000000..36b1d1ba --- /dev/null +++ b/menu/alias/templates/install @@ -0,0 +1,8 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +sudo apt install diff --git a/menu/alias/templates/jpurge b/menu/alias/templates/jpurge new file mode 100644 index 00000000..910e54df --- /dev/null +++ b/menu/alias/templates/jpurge @@ -0,0 +1,7 @@ +#!/bin/bash +## cleanup old Journal files + +journalctl --flush +journalctl --rotate +journalctl --vacuum-time=1s +journalctl --vacuum-size=10M diff --git a/menu/alias/templates/kill_logs b/menu/alias/templates/kill_logs new file mode 100644 index 00000000..ff747013 --- /dev/null +++ b/menu/alias/templates/kill_logs @@ -0,0 +1,6 @@ +#!/bin/bash +## cleanup old log files + +bash /opt/plexguide/menu/log/kill_log.sh 1>/dev/null 2>&1 + +echo "/var/log/ is cleared for your security" diff --git a/menu/alias/templates/mgupdate b/menu/alias/templates/mgupdate new file mode 100644 index 00000000..7ae94dd0 --- /dev/null +++ b/menu/alias/templates/mgupdate @@ -0,0 +1,42 @@ +#!/bin/bash +# +# Title: mergerfs updater +# GNU: General Public License v3.0 +################################################################################ + +mgversion="$(curl -s https://api.github.com/repos/trapexit/mergerfs/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')" +mgstored="$(mergerfs -v | grep 'mergerfs version:' | awk '{print $3}')" + +tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + mergerfs Update Panel --local version $mgstored +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +mergerfs installed version = $mgstored +mergerfs latest version = $mgversion + +[Y] UPDATE to lateste version + +[Z] Exit +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + +read -p 'Type Y or Z | Press [ENTER]: ' typed /dev/null & +chmod 0755 /bin/pgblitz &>/dev/null & +# pg deploy contains pgdeploy at end +pginstall diff --git a/menu/alias/templates/pgblitz b/menu/alias/templates/pgblitz new file mode 100644 index 00000000..36c228d4 --- /dev/null +++ b/menu/alias/templates/pgblitz @@ -0,0 +1,39 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +file="/var/plexguide/pg.number" +if [ -e "$file" ]; then + check="$(cat /var/plexguide/pg.number | head -c 1)" + if [[ "$check" == "5" || "$check" == "6" || "$check" == "7" ]]; then + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 INSTALLER BLOCK: Notice +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +We detected PG Version $check is running! Per the instructions, PG 8 +must be installed on a FRESH BOX! Exiting! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + exit + fi +fi + +source /opt/plexguide/menu/functions/functions.sh +source /opt/plexguide/menu/functions/start.sh +source /opt/plexguide/menu/functions/install.sh + +mkdir -p /opt/plexguide/roles/log +mkdir -p /var/plexguide/logs +mkdir -p /opt/appdata/plexguide + +sudocheck +missingpull + +# pg deploy contains pgdeploy at end +pginstall diff --git a/menu/alias/templates/plexguide b/menu/alias/templates/plexguide new file mode 100644 index 00000000..8206d134 --- /dev/null +++ b/menu/alias/templates/plexguide @@ -0,0 +1,44 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +file="/var/plexguide/pg.number" +if [ -e "$file" ]; then + check="$(cat /var/plexguide/pg.number | head -c 1)" + if [[ "$check" == "5" || "$check" == "6" || "$check" == "7" ]]; then + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 INSTALLER BLOCK: Notice +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +We detected PG Version $check is running! Per the instructions, PG 8 +must be installed on a FRESH BOX! Exiting! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + exit + fi +fi + +source /opt/plexguide/menu/functions/functions.sh +source /opt/plexguide/menu/functions/start.sh +source /opt/plexguide/menu/functions/install.sh + +mkdir -p /opt/plexguide/roles/log +mkdir -p /var/plexguide/logs +mkdir -p /opt/appdata/plexguide + +sudocheck +missingpull + +if [[ ! -e "/bin/pgblitz" ]]; then + cp /opt/plexguide/menu/alias/templates/pgblitz /bin/ &>/dev/null & + chown 1000:1000 /bin/pgblitz + chmod 0755 /bin/pgblitz +fi +# pg deploy contains pgdeploy at end +pginstall diff --git a/menu/alias/templates/prune b/menu/alias/templates/prune new file mode 100644 index 00000000..98b2e24c --- /dev/null +++ b/menu/alias/templates/prune @@ -0,0 +1,7 @@ +#!/bin/bash +# +# docker autoprune unused docker/ volumes +################################################################################ +#sudo docker system prune -a -f +docker image prune -a -f +docker system prune --volumes -a -f diff --git a/menu/alias/templates/pts b/menu/alias/templates/pts new file mode 100644 index 00000000..36c228d4 --- /dev/null +++ b/menu/alias/templates/pts @@ -0,0 +1,39 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +file="/var/plexguide/pg.number" +if [ -e "$file" ]; then + check="$(cat /var/plexguide/pg.number | head -c 1)" + if [[ "$check" == "5" || "$check" == "6" || "$check" == "7" ]]; then + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 INSTALLER BLOCK: Notice +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +We detected PG Version $check is running! Per the instructions, PG 8 +must be installed on a FRESH BOX! Exiting! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + exit + fi +fi + +source /opt/plexguide/menu/functions/functions.sh +source /opt/plexguide/menu/functions/start.sh +source /opt/plexguide/menu/functions/install.sh + +mkdir -p /opt/plexguide/roles/log +mkdir -p /var/plexguide/logs +mkdir -p /opt/appdata/plexguide + +sudocheck +missingpull + +# pg deploy contains pgdeploy at end +pginstall diff --git a/menu/alias/templates/ptsadd b/menu/alias/templates/ptsadd new file mode 100644 index 00000000..4eb0b822 --- /dev/null +++ b/menu/alias/templates/ptsadd @@ -0,0 +1,44 @@ +#!/bin/bash +##usercheck +if [ $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}') ]; then + usermod -aG sudo $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}') + sudo usermod -s /bin/bash $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}') + sudo usermod -aG video $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}') + sudo usermod -aG docker $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}') + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo "" + echo " ✅ PASSED ! We found the user UID " $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}') + echo "" + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +else + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo " ⌛ INFO ! " + echo " ⌛ INFO ! Only lowercase and dont empty parts" + echo " ⌛ INFO ! Enter a password (8+ chars)" + echo " ⌛ INFO ! " + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo "" + read -p "Enter username : " username + read -s -p "Enter password : " password + echo "" + egrep "^$username" /etc/passwd >/dev/null + pass=$(perl -e 'print crypt($ARGV[0], "password")' $password) + useradd -m -p $pass $username + usermod -aG sudo $username + sudo usermod -s /bin/bash $username + usermod -aG video $username + usermod -aG docker $username + echo "" + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo " ✅ PASSED ! User has been added to system!" + echo " ✅ PASSED ! Your Username : " $username + echo " ✅ PASSED ! Your Password : " $password + echo " ✅ PASSED ! " + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +fi +tee <<-EOF +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +😂 What a Lame name: $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}') +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF +exit 0 diff --git a/menu/alias/templates/ptsupdate b/menu/alias/templates/ptsupdate new file mode 100644 index 00000000..04aa3e4c --- /dev/null +++ b/menu/alias/templates/ptsupdate @@ -0,0 +1,14 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +source /opt/plexguide/menu/functions/functions.sh +source /opt/plexguide/menu/functions/start.sh + +sudocheck +missingpull +exitcheck +templatespart2 diff --git a/menu/alias/templates/rcupdate b/menu/alias/templates/rcupdate new file mode 100644 index 00000000..8c379f81 --- /dev/null +++ b/menu/alias/templates/rcupdate @@ -0,0 +1,43 @@ +#!/bin/bash +# +# Title: rclone updater +# GNU: General Public License v3.0 +################################################################################ + +rcversion="$(curl -s https://api.github.com/repos/rclone/rclone/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')" +rcstored="$(rclone --version | awk '{print $2}' | tail -n 3 | head -n 1)" + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + rClone Update Panel $rcstored +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +rclone installed version = $rcstored +rclone latest version = $rcversion + +[Y] UPDATE to lateste version + +[Z] Exit +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + +read -p 'Type Y or Z | Press [ENTER]: ' typed /dev/null 2>&1 + ;; + y) + ansible-playbook /opt/plexguide/menu/pg.yml --tags rcloneinstall + bash /opt/plexguide/menu/pgui/templates/check.sh >/dev/null 2>&1 + ;; + z) + exit + ;; + Z) + exit + ;; +esac diff --git a/menu/alias/templates/reboot b/menu/alias/templates/reboot new file mode 100644 index 00000000..b78e4606 --- /dev/null +++ b/menu/alias/templates/reboot @@ -0,0 +1,8 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +sudo reboot diff --git a/menu/alias/templates/scommands b/menu/alias/templates/scommands new file mode 100644 index 00000000..191fbfaa --- /dev/null +++ b/menu/alias/templates/scommands @@ -0,0 +1,6 @@ + +#!/bin/bash +# Title: PTS List commands +# Author(s): MrDoobPG +############################################################## +cat /opt/plexguide/menu/commands/scommands.log diff --git a/menu/alias/templates/slist b/menu/alias/templates/slist new file mode 100644 index 00000000..2af3b3b9 --- /dev/null +++ b/menu/alias/templates/slist @@ -0,0 +1,8 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +sudo ls /etc/systemd/system diff --git a/menu/alias/templates/update b/menu/alias/templates/update new file mode 100644 index 00000000..db14b837 --- /dev/null +++ b/menu/alias/templates/update @@ -0,0 +1,8 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +sudo ansible-playbook /opt/plexguide/menu/pg.yml --tags update diff --git a/menu/alias/templates/upgrade b/menu/alias/templates/upgrade new file mode 100644 index 00000000..582c6740 --- /dev/null +++ b/menu/alias/templates/upgrade @@ -0,0 +1,8 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +sudo apt upgrade -y diff --git a/menu/amazonaws/amazonaws.sh b/menu/amazonaws/amazonaws.sh new file mode 100644 index 00000000..2a41604b --- /dev/null +++ b/menu/amazonaws/amazonaws.sh @@ -0,0 +1,245 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +test=$(hcloud server list) +if [ "$test" == "" ]; then + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ WARNING! - You Must Input an API from Hetzner First! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +* Activate a Hetzner Cloud Account and Create a Project +* Click Access (left hand side) and then click API Tokens +* Create a Token and Save It (and paste below here) +* Not Ready? Just Something & Press [ENTER] + +EOF + hcloud context create plexguide + + test=$(hcloud server list) + if [ "$test" == "" ]; then + hcloud context delete plexguide + exit + fi + +fi + +# Start Process +tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 PTS - Hetzner's Cloud Generator +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +[1] Deploy a New Server +[2] Destroy a Server +A - List Server Info +B - Display Inital Server Passwords +Z - Exit + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF +read -p 'Type a Number | Press [ENTER]: ' typed /opt/appdata/plexguide/server.info + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ PTS - New Server Information - [$name] +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + cat /opt/appdata/plexguide/server.info + + # Creates Log + touch /opt/appdata/plexguide/server.store + cat /opt/appdata/plexguide/server.info >>/opt/appdata/plexguide/server.store + echo "Server Name: $name" >>/opt/appdata/plexguide/server.store + echo "" >>/opt/appdata/plexguide/server.store + + # Variable Info + serverip=$(cat /opt/appdata/plexguide/server.info | tail -n +3 | head -n 1 | cut -d " " -f2-) + initialpw=$(cat /opt/appdata/plexguide/server.info | tail -n +4 | cut -d " " -f3-) + + tee <<-EOF + +⚠️ To Reach Your Server >>> EXIT PTS >>> TYPE: pts-$name ⚠️ + +✅️ [IMPORTANT NOTE] + +Wait for one minute for the server to boot! Typing pts-$name will +display your initial password! Also can manually by typing: + +Command: ssh root@$serverip +FIRST TIME LOGIN - Initial Password: $initialpw + +EOF + read -p 'Press [ENTER] to Exit ' fill >/bin/pg-$name + echo "echo ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" >/bin/pg-$name + echo "echo '↘️ Server - $name | Initial Password $initialpw'" >>/bin/pg-$name + echo "echo ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" >>/bin/pg-$name + echo "echo ''" >>/bin/pg-$name + echo "ssh root@$serverip" >>/bin/pg-$name + chmod 777 /bin/pg-$name + chown 1000:1000 /bin/pg-$name + + bash /opt/plexguide/menu/hetzner/hetzner.sh + exit + +elif [ "$typed" == "A" ] || [ "$typed" == "a" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ PTS - Hetzner Server Cloud List +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Server Name +━━━━━━━━━━━ +EOF + hcloud server list | tail -n +2 | cut -d " " -f2- | cut -d " " -f2- | cut -d " " -f2- + echo + read -p 'Press [ENTER] to Continue! ' typed ") + if [ "$next" == "0" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ PTS - Server: $destroy - Does Not Exist! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p 'Press [ENTER] to Continue! ' typed old) +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + + touch /opt/appdata/plexguide/server.store + tac -r /opt/appdata/plexguide/server.store + echo "" & + echo "" + read -p 'Press [ENTER] to Continue! ' corn " | cut -d " " -f2- | cut -d " " -f2- | cut -d " " -f2-) +#ipcheck=$(echo $check | awk '{ print $3 }') +#⛔️ WARNING! - Must Configure RClone First /w >>> gdrive +# read -n 1 -s -r -p "Press [ANY] Key to Continue " diff --git a/menu/app_template/_template.yml b/menu/app_template/_template.yml new file mode 100644 index 00000000..d9cb4347 --- /dev/null +++ b/menu/app_template/_template.yml @@ -0,0 +1,68 @@ +#!/bin/bash +# +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + # FACTS ####################################################################### + - name: 'Set Known Facts' + set_fact: + pgrole: 'name' + intport: 'port' + extport: 'port' + image: 'image name' + + # CORE (MANDATORY) ############################################################ + - name: 'Including cron job' + include_tasks: '/opt/communityapps/apps/_core.yml' + + # LABELS ###################################################################### + - name: 'Adding Traefik' + set_fact: + pg_labels: + traefik.enable: 'true' + traefik.port: '{{intport}}' + traefik.frontend.auth.forward.address: '{{gauth}}' + traefik.frontend.rule: 'Host:{{pgrole}}.{{domain.stdout}}{{tldset}}{{cname}}' + traefik.frontend.headers.SSLHost: '{{domain.stdout}}' + traefik.frontend.headers.SSLRedirect: 'true' + traefik.frontend.headers.STSIncludeSubdomains: 'true' + traefik.frontend.headers.STSPreload: 'true' + traefik.frontend.headers.STSSeconds: '315360000' + traefik.frontend.headers.browserXSSFilter: 'true' + traefik.frontend.headers.contentTypeNosniff: 'true' + traefik.frontend.headers.customResponseHeaders: 'X-Robots-Tag:noindex,nofollow,nosnippet,noarchive,notranslate,noimageindex' + traefik.frontend.headers.forceSTSHeader: 'true' + + - name: 'Setting {{pgrole}} Volumes' + set_fact: + pg_volumes: + - '/opt/appdata/{{pgrole}}:/name of folder' + - '{{path.stdout}}:{{path.stdout}}' + - '/etc/localtime:/etc/localtime:ro' + + - name: 'Setting {{pgrole}} ENV' + set_fact: + pg_env: + PUID: '1000' + PGID: '1000' + + # MAIN DEPLOYMENT ############################################################# + - name: 'Deploying {{pgrole}}' + docker_container: + name: '{{pgrole}}' + image: '{{image}}' + pull: yes + published_ports: + - '{{ports.stdout}}{{extport}}:{{intport}}' + volumes: '{{pg_volumes}}' + env: '{{pg_env}}' + restart_policy: unless-stopped + networks: + - name: plexguide + aliases: + - '{{pgrole}}' + state: started + labels: '{{pg_labels}}' + diff --git a/menu/appguard/appguard.sh b/menu/appguard/appguard.sh new file mode 100644 index 00000000..0c843498 --- /dev/null +++ b/menu/appguard/appguard.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +# KEY VARIABLE RECALL & EXECUTION +program=$(cat /tmp/program_var) +mkdir -p /var/plexguide/cron/ +mkdir -p /opt/appdata/plexguide/cron +# FUNCTIONS START ############################################################## +source /opt/plexguide/menu/functions/functions.sh + +# FIRST QUESTION +question1() { + appguard=$(cat /var/plexguide/server.ht) + if [ "$appguard" == "" ]; then + guard="DISABLED" && opp="Enable" + else guard="ENABLED" && opp="Disable"; fi + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 Welcome to AppGuard! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⚡ Reference: http://appguard.pgblitz.com + +Currently: [$guard] + +1. $opp AppGuard +Z. Exit + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + + read -p 'Type a Number | Press [ENTER]: ' typed /var/plexguide/server.ht; fi + bash /opt/plexguide/menu/appguard/rebuild.sh + elif [[ "$typed" == "z" || "$typed" == "Z" ]]; then + exit + else badinput1; fi +} + +# FUNCTIONS END ############################################################## + +break=off && while [ "$break" == "off" ]; do question1; done diff --git a/menu/appguard/rebuild.sh b/menu/appguard/rebuild.sh new file mode 100644 index 00000000..487b1b1d --- /dev/null +++ b/menu/appguard/rebuild.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +docker ps -a --format "{{.Names}}" >/var/plexguide/container.running + +sed -i -e "/traefik/d" /var/plexguide/container.running +sed -i -e "/watchtower/d" /var/plexguide/container.running +sed -i -e "/wp-*/d" /var/plexguide/container.running +sed -i -e "/plex/d" /var/plexguide/container.running +sed -i -e "/emby/d" /var/plexguide/container.running +sed -i -e "/jellyfin/d" /var/plexguide/container.running +sed -i -e "/ombi/d" /var/plexguide/container.running +sed -i -e "/oauth/d" /var/plexguide/container.running +sed -i -e "/portainer/d" /var/plexguide/container.running +sed -i -e "/dockergc/d" /var/plexguide/container.running + +count=$(wc -l /tmp/program_var + + if [ -e "/opt/coreapps/apps/$app.yml" ]; then ansible-playbook /opt/coreapps/apps/$app.yml; fi + if [ -e "/opt/communityapps/$app.yml" ]; then ansible-playbook /opt/communityapps/apps/$app.yml; fi +done + +echo "" +tee <<-EOF + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + ✅️ AppGuard - Completed! All Containers were Rebuilt! + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF +read -p 'Continue? | Press [ENTER] ' name /var/plexguide/final.choice + +#### Note How to Make It Select a Type - echo "removal" > /var/plexguide/type.choice +program=$(cat /var/plexguide/type.choice) + +menu=$(echo "on") + +while [ "$menu" != "break" ]; do + menu=$(cat /var/plexguide/final.choice) + + ### Loads Key Variables + bash /opt/plexguide/menu/interface/$program/var.sh + ### Loads Key Execution + ansible-playbook /opt/plexguide/menu/core/selection.yml + ### Executes Actions + bash /opt/plexguide/menu/interface/$program/file.sh + + ### Calls Variable Again - Incase of Break + menu=$(cat /var/plexguide/final.choice) + + if [ "$menu" == "break" ]; then + echo "" + echo "---------------------------------------------------" + echo "SYSTEM MESSAGE: User Selected to Exit the Interface" + echo "---------------------------------------------------" + echo "" + sleep .5 + fi + +done diff --git a/menu/core/selection.yml b/menu/core/selection.yml new file mode 100644 index 00000000..5f0520a6 --- /dev/null +++ b/menu/core/selection.yml @@ -0,0 +1,182 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + + - name: Recall Menu Type + shell: "cat /var/plexguide/type.choice" + register: menutemp + + - name: "Set Facts for Menu" + set_fact: + menu: "{{menutemp.stdout}}" + +################ Key Variable to Set Menu Length + - name: "Default Blank Variables" + set_fact: + info1: "\n\n1. Exit Interface" + info2: "" + info3: "" + info4: "" + info5: "" + info6: "" + info7: "" + info8: "" + info9: "" + + - name: Launch Container Primary Information + include_tasks: "../interface/{{menu}}/choice.yml" + +################ Blank Out Variable Recall + - name: Recall Menu Type + shell: "cat /var/plexguide/menu.number" + register: tempnumber + + - name: "Blank Out Variable Recall" + set_fact: + numberselect: "{{tempnumber.stdout}}" + +################ Sets Choice Limitation + - name: "Choice Number {{numberselect}}" + set_fact: + choices: choice.user_input == "1" or + choice.user_input == "2" + when: numberselect == "2" + + - name: "Choice Number {{numberselect}}" + set_fact: + choices: choice.user_input == "1" or + choice.user_input == "2" or + choice.user_input == "3" + when: numberselect == "3" + + - name: "Choice Number {{numberselect}}" + set_fact: + choices: choice.user_input == "1" or + choice.user_input == "2" or + choice.user_input == "3" or + choice.user_input == "4" + when: numberselect == "4" + + - name: "Choice Number {{numberselect}}" + set_fact: + choices: choice.user_input == "1" or + choice.user_input == "2" or + choice.user_input == "3" or + choice.user_input == "4" or + choice.user_input == "5" + when: numberselect == "5" + + - name: "Choice Number {{numberselect}}" + set_fact: + choices: choice.user_input == "1" or + choice.user_input == "2" or + choice.user_input == "3" or + choice.user_input == "4" or + choice.user_input == "5" or + choice.user_input == "6" + when: numberselect == "6" + + - name: "Choice Number {{numberselect}}" + set_fact: + choices: choice.user_input == "1" or + choice.user_input == "2" or + choice.user_input == "3" or + choice.user_input == "4" or + choice.user_input == "5" or + choice.user_input == "6" or + choice.user_input == "7" + when: numberselect == "7" + + - name: "Choice Number {{numberselect}}" + set_fact: + choices: choice.user_input == "1" or + choice.user_input == "2" or + choice.user_input == "3" or + choice.user_input == "4" or + choice.user_input == "5" or + choice.user_input == "6" or + choice.user_input == "7" or + choice.user_input == "8" + when: numberselect == "8" + + - name: "Choice Number {{numberselect}}" + set_fact: + choices: choice.user_input == "1" or + choice.user_input == "2" or + choice.user_input == "3" or + choice.user_input == "4" or + choice.user_input == "5" or + choice.user_input == "6" or + choice.user_input == "7" or + choice.user_input == "8" or + choice.user_input == "9" + when: numberselect == "9" +################# Recalls Variables for Set Length + - name: PG Main Menu + pause: + prompt: "\n------------------------------------------------------------- + {{head1}} + {{head2}} + \n------------------------------------------------------------- + {{info1}} + {{info2}} + {{info3}} + {{info4}} + {{info5}} + {{info6}} + {{info7}} + {{info8}} + {{info9}} + \n\nType a [NUMBER] Choice & Press [ENTER]" + register: choice + until: "{{choices}}" + retries: 99 + delay: 1 + + - name: Set Choice + set_fact: + fchoice: "{{choice.user_input}}" + + - name: Exiting Interface + shell: "echo break > /var/plexguide/final.choice" + when: fchoice == "1" + + - name: Choice 2 Selected + shell: "echo 2 > /var/plexguide/final.choice" + when: fchoice == "2" + + - name: Choice 3 Selected + shell: "echo 3 > /var/plexguide/final.choice" + when: fchoice == "3" + + - name: Choice 4 Selected + shell: "echo 4 > /var/plexguide/final.choice" + when: fchoice == "4" + + - name: Choice 5 Selected + shell: "echo 5 > /var/plexguide/final.choice" + when: fchoice == "5" + + - name: Choice 6 Selected + shell: "echo 6 > /var/plexguide/final.choice" + when: fchoice == "6" + + - name: Choice 7 Selected + shell: "echo 7 > /var/plexguide/final.choice" + when: fchoice == "7" + + - name: Choice 8 Selected + shell: "echo 8 > /var/plexguide/final.choice" + when: fchoice == "8" + + - name: Choice 9 Selected + shell: "echo 9 > /var/plexguide/final.choice" + when: fchoice == "9" diff --git a/menu/cron/bcron.sh b/menu/cron/bcron.sh new file mode 100644 index 00000000..807597eb --- /dev/null +++ b/menu/cron/bcron.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +pgrole=$(cat /tmp/program_var) +path=$(cat /var/plexguide/server.hd.path) +tarlocation=$(cat /var/plexguide/data.location) +serverid=$(cat /var/plexguide/pg.serverid) + +doc=no +rolecheck=$(docker ps | grep -c "\<$pgrole\>") +if [ $rolecheck != 0 ]; then docker stop $pgrole && doc=yes; fi + +tar \ + --ignore-failed-read \ + --warning=no-file-changed \ + --warning=no-file-removed \ + -cvzf $tarlocation/$pgrole.tar /opt/appdata/$pgrole/ + +if [ $doc == yes ]; then docker restart $pgrole; fi + +chown -R 1000:1000 $tarlocation +rclone --config /opt/appdata/plexguide/rclone.conf copy $tarlocation/$pgrole.tar gdrive:/plexguide/backup/$serverid -v --checksum --drive-chunk-size=64M + +du -sh --apparent-size /opt/appdata/$pgrole | awk '{print $1}' +rm -rf '$tarlocation/$pgrole.tar' diff --git a/menu/cron/cron.sh b/menu/cron/cron.sh new file mode 100644 index 00000000..6b1856ad --- /dev/null +++ b/menu/cron/cron.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +# KEY VARIABLE RECALL & EXECUTION +program=$(cat /tmp/program_var) +mkdir -p /var/plexguide/cron/ +mkdir -p /opt/appdata/plexguide/cron +# FUNCTIONS START ############################################################## +source /opt/plexguide/menu/functions/functions.sh +RAN=$(head /dev/urandom | tr -dc 0-7 | head -c 1) +# FIRST QUESTION +question1() { + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⌛ Cron - Schedule Cron Jobs (Backups) | $program? +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +[ 1 ] No + +[ 2 ] Yes + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + + read -p '↘️ Type Number | Press [ENTER]: ' typed /var/plexguide/cron/cron.day && break=1; +elif [ "$typed" == "8" ]; then echo "*" > /var/plexguide/cron/cron.day && break=1; +elif [ "$typed" == "9" ]; then echo $RAN >/var/plexguide/cron/cron.day && break=1; +else badinput; fi +} + +# THIRD QUESTION +question3() { + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⌛ Cron - Hour of the Day? +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Type an HOUR from [0 to 23] + +0 = 00:00 | 12AM +12 = 12:00 | 12PM +18 = 18:00 | 6 PM + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + + read -p '↘️ Type a Number | Press [ENTER]: ' typed /var/plexguide/cron/cron.hour && break=1 + else badinput; fi +} + +# FUNCTIONS END ############################################################## + +break=off && while [ "$break" == "off" ]; do question1; done +break=off && while [ "$break" == "off" ]; do question2; done +break=off && while [ "$break" == "off" ]; do question3; done + +echo $(($RANDOM % 59)) >/var/plexguide/cron/cron.minute +ansible-playbook /opt/plexguide/menu/cron/cron.yml diff --git a/menu/cron/cron.yml b/menu/cron/cron.yml new file mode 100644 index 00000000..48a7a8d4 --- /dev/null +++ b/menu/cron/cron.yml @@ -0,0 +1,42 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + # KEY VARIABLES ################################################################ + - name: Set crontab + shell: 'cat /tmp/program_var' + register: pgrole + + - name: Set cron hour + shell: 'cat /var/plexguide/cron/cron.hour' + register: cronhour + + - name: Set cron minute + shell: 'cat /var/plexguide/cron/cron.minute' + register: cronminute + + - name: Set cron day + shell: 'cat /var/plexguide/cron/cron.day' + register: cronday + + # CRON START ################################################################### + # - name: Build Cron Job File + # shell: echo "ansible-playbook /opt/plexguide/menu/cron/bcron.yml --extra-vars 'program_var={{pgrole.stdout}}'" > /opt/appdata/plexguide/cron/{{pgrole.stdout}} + + - name: Build Cron Job Schedule + cron: + name: '{{pgrole.stdout}}' + weekday: '{{cronday.stdout}}' + minute: '{{cronminute.stdout}}' + hour: '{{cronhour.stdout}}' + user: root + job: 'echo {{pgrole.stdout}} >/tmp/program_var && bash /opt/pgvault/pgcron' + state: present + become_user: root diff --git a/menu/cron/mass.sh b/menu/cron/mass.sh new file mode 100644 index 00000000..7f9b7134 --- /dev/null +++ b/menu/cron/mass.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################# + +# KEY VARIABLE RECALL & EXECUTION +mkdir -p /var/plexguide/cron/ +mkdir -p /opt/appdata/plexguide/cron +# FUNCTIONS START ############################################################## +source /opt/plexguide/menu/functions/functions.sh + +weekrandom() { + while read p; do + echo "$p" >/tmp/program_var + echo $(($RANDOM % 23)) >/var/plexguide/cron/cron.hour + echo $(($RANDOM % 59)) >/var/plexguide/cron/cron.minute + echo $(($RANDOM % 6)) >/var/plexguide/cron/cron.day + ansible-playbook /opt/plexguide/menu/cron/cron.yml + done /tmp/program_var + echo $(($RANDOM % 23)) >/var/plexguide/cron/cron.hour + echo $(($RANDOM % 59)) >/var/plexguide/cron/cron.minute + echo "*/1" >/var/plexguide/cron/cron.day + ansible-playbook /opt/plexguide/menu/cron/cron.yml + done /tmp/program_var + bash /opt/plexguide/menu/cron/cron.sh + done $1; fi +} + +# For ZipLocations + +variable /var/plexguide/server.hd.path "/mnt" +pgpath=$(cat /var/plexguide/server.hd.path) + +used=$(df -h $pgpath | tail -n +2 | awk '{print $3}') +capacity=$(df -h $pgpath | tail -n +2 | awk '{print $2}') +percentage=$(df -h $pgpath | tail -n +2 | awk '{print $5}') +###################### FOR VARIABLS ROLE SO DOESNT CREATE RED - START + +# Menu Interface +tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 Processing Disk Interface +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +🌵 Processing Disk : $pgpath + Processing Space: $used of $capacity | $percentage Used Capacity + +☑️ PTS does not format your second disk, nor mount it! We can +only assist by changing the location path! + +☑️ Enables PTS System to process items on a SECONDARY Drive rather +than tax the PRIMARY DRIVE. Like Windows, you can have your items +process on a (D): Drive instead of on a (C): Drive. + +Do You Want To Change the Processing Disk? + +[1] No +[2] Yes + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF +# Standby +read -p '↘️ Type a Number | Press [ENTER]: ' typed >> exit +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + + # Standby + read -p '↘️ Type the NEW PATH (Follow Above Examples): ' typed /dev/null 2>&1 + + file="$typed/test" + if [ -e "$file" ]; then + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅️ WOOT WOOT: Location Is Valid - $typed +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 2 + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⌛ STANDBY: Setting Up Your Permissions +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 2 + + chown 1000:1000 "$typed" + chmod 0775 "$typed" + rm -rf "$typed/test" + echo $typed >/var/plexguide/server.hd.path + break=off + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⌛ STANDBY: Making Folders & Rebuilding the Systems Docker Containers! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 2 + + ansible-playbook /opt/plexguide/menu/installer/folders.yml + bash /opt/plexguide/menu/dlpath/rebuild.sh + + tee <<-EOF +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅️ WOOT WOOT: Process Complete! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + else + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ WARNING! - Mount Error! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +$typed does not exist! + +You may have forgotten to create it, but PTS is unable to see it! +Try >>> cd $path and see what happens! + +Exiting! Nothing has changed! + +EOF + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + fi +else + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🍖 NOM NOM: Failed to Make a Valid Selection! Restarting the Process! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 3 + bash /opt/plexguide/menu/dlpath/dlpath.sh + exit +fi + +exit diff --git a/menu/dlpath/rebuild.sh b/menu/dlpath/rebuild.sh new file mode 100644 index 00000000..1f5c310a --- /dev/null +++ b/menu/dlpath/rebuild.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +docker ps -a --format "{{.Names}}" >/var/plexguide/container.running + +sed -i -e "/traefik/d" /var/plexguide/container.running +sed -i -e "/watchtower/d" /var/plexguide/container.running +sed -i -e "/wp-*/d" /var/plexguide/container.running +sed -i -e "/plex/d" /var/plexguide/container.running +sed -i -e "/emby/d" /var/plexguide/container.running +sed -i -e "/jellyfin/d" /var/plexguide/container.running +sed -i -e "/pgblitz/d" /var/plexguide/container.running +sed -i -e "/oauth/d" /var/plexguide/container.running +sed -i -e "/dockergc/d" /var/plexguide/container.running +sed -i -e "/pgui/d" /var/plexguide/container.running + +### Your Wondering Why No While Loop, using a While Loops Screws Up Ansible Prompts +### BackDoor WorkAround to Stop This Behavior +count=$(wc -l /tmp/program_var + if [ -e "/opt/coreapps/apps/$app.yml" ]; then ansible-playbook /opt/coreapps/apps/$app.yml; fi + if [ -e "/opt/communityapps/$app.yml" ]; then ansible-playbook /opt/communityapps/apps/$app.yml; fi + if [ -e "/opt/mycontainers/$app.yml" ]; then ansible-playbook /opt/mycontainers/apps/$app.yml; fi +done + +echo "" +echo 'INFO - Rebuilding Complete!' >/var/plexguide/logs/pg.log && bash /opt/plexguide/menu/log/log.sh diff --git a/menu/functions/bench.sh b/menu/functions/bench.sh new file mode 100644 index 00000000..237cc67e --- /dev/null +++ b/menu/functions/bench.sh @@ -0,0 +1,550 @@ +#!/bin/bash +# serverreview-benchmark by @sayem314 +# Github: https://github.com/sayem314/serverreview-benchmark + +# shellcheck disable=SC1117,SC2086,SC2003,SC1001,SC2116,SC2046,2128,2124 + +about () { + echo "" + echo " ========================================================= " + echo " \ Serverreview Benchmark Script / " + echo " \ Basic system info, I/O test and speedtest / " + echo " \ V 3.0.3 (13 Sep 2019) / " + echo " \ Created by Sayem Chowdhury / " + echo " ========================================================= " + echo "" + echo " This script is based on bench.sh by camarg from akamaras.com" + echo " Later it was modified by dmmcintyre3 on FreeVPS.us" + echo " Thanks to Hidden_Refuge for the update of this script" + echo "" +} + +prms () { + echo " Arguments:" + echo " $(tput setaf 3)-info$(tput sgr0) - Check basic system information" + echo " $(tput setaf 3)-io$(tput sgr0) - Run I/O test with or w/ cache" + echo " $(tput setaf 3)-cdn$(tput sgr0) - Check download speed from CDN" + echo " $(tput setaf 3)-northamercia$(tput sgr0) - Download speed from North America" + echo " $(tput setaf 3)-europe$(tput sgr0) - Download speed from Europe" + echo " $(tput setaf 3)-asia$(tput sgr0) - Download speed from asia" + echo " $(tput setaf 3)-a$(tput sgr0) - Test and check all above things at once" + echo " $(tput setaf 3)-b$(tput sgr0) - System info, CDN speedtest and I/O test" + echo " $(tput setaf 3)-ispeed$(tput sgr0) - Install speedtest-cli (python 2.4-3.4 required)" + echo " $(tput setaf 3)-speed$(tput sgr0) - Check internet speed using speedtest-cli" + echo " $(tput setaf 3)-about$(tput sgr0) - Check about this script" + echo "" + echo " Parameters" + echo " $(tput setaf 3)share$(tput sgr0) - upload results (default to ubuntu paste)" + echo " Available option for share:" + echo " ubuntu # upload results to ubuntu paste (default)" + echo " haste # upload results to hastebin" + echo " clbin # upload results to clbin" + echo " ptpb # upload results to ptpb" +} + +howto () { + echo "" + echo " Wrong parameters. Use $(tput setaf 3)bash $BASH_SOURCE -help$(tput sgr0) to see parameters" + echo " ex: $(tput setaf 3)bash $BASH_SOURCE -info$(tput sgr0) (without quotes) for system information" + echo "" +} + +benchinit() { + if ! hash curl 2>$NULL; then + echo "missing dependency curl" + echo "please install curl first" + exit + fi +} + +CMD="$1" +PRM1="$2" +PRM2="$3" +log="$HOME/bench.log" +ARG="$BASH_SOURCE $@" +benchram="/mnt/tmpbenchram" +NULL="/dev/null" +true > $log + +cancel () { + echo "" + rm -f test + echo " Abort" + if [[ -d $benchram ]]; then + rm $benchram/zero + umount $benchram + rm -rf $benchram + fi + exit +} + +trap cancel SIGINT + +systeminfo () { + # Systeminfo + echo "" | tee -a $log + echo " $(tput setaf 6)## System Information$(tput sgr0)" + echo " ## System Information" >> $log + echo "" | tee -a $log + + # OS Information (Name) + cpubits=$( uname -m ) + if echo $cpubits | grep -q 64; then + bits=" (64 bit)" + elif echo $cpubits | grep -q 86; then + bits=" (32 bit)" + elif echo $cpubits | grep -q armv5; then + bits=" (armv5)" + elif echo $cpubits | grep -q armv6l; then + bits=" (armv6l)" + elif echo $cpubits | grep -q armv7l; then + bits=" (armv7l)" + else + bits="unknown" + fi + + if hash lsb_release 2>$NULL; then + soalt=$(lsb_release -d) + echo -e " OS Name : "${soalt:13} $bits | tee -a $log + else + so=$(awk 'NF' /etc/issue) + pos=$(expr index "$so" 123456789) + so=${so/\/} + extra="" + if [[ "$so" == Debian*9* ]]; then + extra="(stretch)" + elif [[ "$so" == Debian*8* ]]; then + extra="(jessie)" + elif [[ "$so" == Debian*7* ]]; then + extra="(wheezy)" + elif [[ "$so" == Debian*6* ]]; then + extra="(squeeze)" + fi + if [[ "$so" == *Proxmox* ]]; then + so="Debian 7.6 (wheezy)"; + fi + otro=$(expr index "$so" \S) + if [[ "$otro" == 2 ]]; then + so=$(cat /etc/*-release) + pos=$(expr index "$so" NAME) + pos=$((pos-2)) + so=${so/\/} + fi + echo -e " OS Name : "${so:0:($pos+2)}$extra$bits | tr -d '\n' | tee -a $log + echo "" | tee -a $log + fi + sleep 0.1 + + #Detect virtualization + if hash ifconfig 2>$NULL; then + eth=$(ifconfig) + fi + virtualx=$(dmesg) + if [[ -f /proc/user_beancounters ]]; then + virtual="OpenVZ" + elif [[ "$virtualx" == *kvm-clock* ]]; then + virtual="KVM" + elif [[ "$virtualx" == *"VMware Virtual Platform"* ]]; then + virtual="VMware" + elif [[ "$virtualx" == *"Parallels Software International"* ]]; then + virtual="Parallels" + elif [[ "$virtualx" == *VirtualBox* ]]; then + virtual="VirtualBox" + elif [[ "$eth" == *eth0* ]];then + virtual="Dedicated" + elif [[ -e /proc/xen ]]; then + virtual="Xen" + fi + + #Kernel + echo " Kernel : $virtual / $(uname -r)" | tee -a $log + sleep 0.1 + + # Hostname + echo " Hostname : $(hostname)" | tee -a $log + sleep 0.1 + + # CPU Model Name + cpumodel=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo ) + echo " CPU Model :$cpumodel" | tee -a $log + sleep 0.1 + + # CPU Cores + cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo ) + corescache=$( awk -F: '/cache size/ {cache=$2} END {print cache}' /proc/cpuinfo ) + freq=$( awk -F: ' /cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo ) + if [[ $cores == "1" ]]; then + echo " CPU Cores : $cores core @ $freq MHz" | tee -a $log + else + echo " CPU Cores : $cores cores @ $freq MHz" | tee -a $log + fi + sleep 0.1 + echo " CPU Cache :$corescache" | tee -a $log + sleep 0.1 + + # RAM Information + tram="$( free -m | grep Mem | awk 'NR=1 {print $2}' ) MiB" + fram="$( free -m | grep Mem | awk 'NR=1 {print $7}' ) MiB" + fswap=$( free -m | grep Swap | awk 'NR=1 {print $4}' )MiB + echo " Total RAM : $tram (Free $fram)" | tee -a $log + sleep 0.1 + + # Swap Information + tswap="$( free -m | grep Swap | awk 'NR=1 {print $2}' ) MiB" + tswap0=$( grep SwapTotal < /proc/meminfo | awk 'NR=1 {print $2$3}' ) + if [[ "$tswap0" == "0kB" ]]; then + echo " Total SWAP : SWAP not enabled" | tee -a $log + else + echo " Total SWAP : $tswap (Free $fswap)" | tee -a $log + fi + sleep 0.1 + + # HDD information + hdd=$( df -h --total --local -x tmpfs | grep 'total' | awk '{print $2}' )B + hddfree=$( df -h --total | grep 'total' | awk '{print $5}' ) + echo " Total Space : $hdd ($hddfree used)" | tee -a $log + sleep 0.1 + + # Uptime + secs=$( awk '{print $1}' /proc/uptime | cut -f1 -d"." ) + if [[ $secs -lt 120 ]]; then + sysuptime="$secs seconds" + elif [[ $secs -lt 3600 ]]; then + sysuptime=$( printf '%d minutes %d seconds\n' $((secs%3600/60)) $((secs%60)) ) + elif [[ $secs -lt 86400 ]]; then + sysuptime=$( printf '%dhrs %dmin %dsec\n' $((secs/3600)) $((secs%3600/60)) $((secs%60)) ) + else + sysuptime=$( echo $((secs/86400))"days - "$(date -d "1970-01-01 + $secs seconds" "+%Hhrs %Mmin %Ssec") ) + fi + echo " Running for : $sysuptime" | tee -a $log + echo "" | tee -a $log +} + +echostyle(){ + if hash tput 2>$NULL; then + echo " $(tput setaf 6)$1$(tput sgr0)" + echo " $1" >> $log + else + echo " $1" | tee -a $log + fi +} + +FormatBytes() { + bytes=${1%.*} + local Mbps=$( printf "%s" "$bytes" | awk '{ printf "%.2f", $0 / 1024 / 1024 * 8 } END { if (NR == 0) { print "error" } }' ) + if [[ $bytes -lt 1000 ]]; then + printf "%8i B/s | N/A " $bytes + elif [[ $bytes -lt 1000000 ]]; then + local KiBs=$( printf "%s" "$bytes" | awk '{ printf "%.2f", $0 / 1024 } END { if (NR == 0) { print "error" } }' ) + printf "%7s KiB/s | %7s Mbps" "$KiBs" "$Mbps" + else + # awk way for accuracy + local MiBs=$( printf "%s" "$bytes" | awk '{ printf "%.2f", $0 / 1024 / 1024 } END { if (NR == 0) { print "error" } }' ) + printf "%7s MiB/s | %7s Mbps" "$MiBs" "$Mbps" + + # bash way + # printf "%4s MiB/s | %4s Mbps""$(( bytes / 1024 / 1024 ))" "$(( bytes / 1024 / 1024 * 8 ))" + fi +} + +pingtest() { + # ping one time + local ping_link=$( echo ${1#*//} | cut -d"/" -f1 ) + local ping_ms=$( ping -w1 -c1 $ping_link | grep 'rtt' | cut -d"/" -f5 ) + + # get download speed and print + if [[ $ping_ms == "" ]]; then + printf " | ping error!" + else + printf " | ping %3i.%sms" "${ping_ms%.*}" "${ping_ms#*.}" + fi +} + +# main function for speed checking +# the report speed are average per file +speed() { + # print name + printf "%s" " $1" | tee -a $log + + # get download speed and print + C_DL=$( curl -m 4 -w '%{speed_download}\n' -o $NULL -s "$2" ) + printf "%s\n" "$(FormatBytes $C_DL) $(pingtest $2)" | tee -a $log +} + +# 2 location (200MB) +cdnspeedtest () { + echo "" | tee -a $log + echostyle "## CDN Speedtest" + echo "" | tee -a $log + speed "CacheFly :" "http://cachefly.cachefly.net/100mb.test" + + # google drive speed test + TMP_COOKIES="/tmp/cookies.txt" + TMP_FILE="/tmp/gdrive" + DRIVE="drive.google.com" + FILE_ID="0B1MVW1mFO2zmdGhyaUJESWROQkE" + + printf " Gdrive :" | tee -a $log + curl -c $TMP_COOKIES -o $TMP_FILE -s "https://$DRIVE/uc?id=$FILE_ID&export=download" + D_ID=$( grep "confirm=" < $TMP_FILE | awk -F "confirm=" '{ print $NF }' | awk -F "&" '{ print $1 }' ) + C_DL=$( curl -m 4 -Lb $TMP_COOKIES -w '%{speed_download}\n' -o $NULL \ + -s "https://$DRIVE/uc?export=download&confirm=$D_ID&id=$FILE_ID" ) + printf "%s\n" "$(FormatBytes $C_DL) $(pingtest $DRIVE)" | tee -a $log + echo "" | tee -a $log +} + +# 10 location (1GB) +northamerciaspeedtest () { + echo "" | tee -a $log + echostyle "## North America Speedtest" + echo "" | tee -a $log + speed "Softlayer, Washington, USA :" "http://speedtest.wdc04.softlayer.com/downloads/test100.zip" + speed "SoftLayer, San Jose, USA :" "http://speedtest.sjc01.softlayer.com/downloads/test100.zip" + speed "SoftLayer, Dallas, USA :" "http://speedtest.dal01.softlayer.com/downloads/test100.zip" + speed "Vultr, New Jersey, USA :" "http://nj-us-ping.vultr.com/vultr.com.100MB.bin" + speed "Vultr, Seattle, USA :" "http://wa-us-ping.vultr.com/vultr.com.100MB.bin" + speed "Vultr, Dallas, USA :" "http://tx-us-ping.vultr.com/vultr.com.100MB.bin" + speed "Vultr, Los Angeles, USA :" "https://lax-ca-us-ping.vultr.com/vultr.com.100MB.bin" + speed "Ramnode, New York, USA :" "http://lg.nyc.ramnode.com/static/100MB.test" + speed "Ramnode, Atlanta, USA :" "http://lg.atl.ramnode.com/static/100MB.test" + speed "OVH, Beauharnois, Canada :" "http://bhs.proof.ovh.net/files/100Mio.dat" + echo "" +} + +# 9 location (900MB) +europespeedtest () { + echo "" | tee -a $log + echostyle "## Europe Speedtest" + echo "" | tee -a $log + speed "Vultr, London, UK :" "http://lon-gb-ping.vultr.com/vultr.com.100MB.bin" + speed "LeaseWeb, Frankfurt, Germany :" "http://mirror.de.leaseweb.net/speedtest/100mb.bin" + speed "Hetzner, Germany :" "https://speed.hetzner.de/100MB.bin" + speed "Ramnode, Alblasserdam, NL :" "http://lg.nl.ramnode.com/static/100MB.test" + speed "Vultr, Amsterdam, NL :" "http://ams-nl-ping.vultr.com/vultr.com.100MB.bin" + speed "EDIS, Stockholm, Sweden :" "http://se.edis.at/100MB.test" + speed "OVH, Roubaix, France :" "http://rbx.proof.ovh.net/files/100Mio.dat" + speed "Online, France :" "http://ping.online.net/100Mo.dat" + speed "Prometeus, Milan, Italy :" "http://mirrors.prometeus.net/test/test100.bin" + echo "" | tee -a $log +} + +# 4 location (200MB) +exoticpeedtest () { + echo "" | tee -a $log + echostyle "## Exotic Speedtest" + echo "" | tee -a $log + speed "Sydney, Australia :" "https://syd-au-ping.vultr.com/vultr.com.100MB.bin" + speed "Lagoon, New Caledonia :" "http://mirror.lagoon.nc/speedtestfiles/test50M.bin" + speed "Hosteasy, Moldova :" "http://mirror.as43289.net/speedtest/100mb.bin" + speed "Prima, Argentina :" "http://sftp.fibertel.com.ar/services/file-50MB.img" + echo "" | tee -a $log +} + +# 4 location (400MB) +asiaspeedtest () { + echo "" | tee -a $log + echostyle "## Asia Speedtest" + echo "" | tee -a $log + speed "SoftLayer, Singapore :" "http://speedtest.sng01.softlayer.com/downloads/test100.zip" + speed "Linode, Tokyo, Japan :" "http://speedtest.tokyo2.linode.com/100MB-tokyo2.bin" + speed "Linode, Singapore :" "http://speedtest.singapore.linode.com/100MB-singapore.bin" + speed "Vultr, Tokyo, Japan :" "http://hnd-jp-ping.vultr.com/vultr.com.100MB.bin" + echo "" | tee -a $log +} + +freedisk() { + # check free space + freespace=$( df -m . | awk 'NR==2 {print $4}' ) + if [[ $freespace -ge 1024 ]]; then + printf "%s" $((1024*2)) + elif [[ $freespace -ge 512 ]]; then + printf "%s" $((512*2)) + elif [[ $freespace -ge 256 ]]; then + printf "%s" $((256*2)) + elif [[ $freespace -ge 128 ]]; then + printf "%s" $((128*2)) + else + printf 1 + fi +} + +averageio() { + ioraw1=$( echo $1 | awk 'NR==1 {print $1}' ) + [ "$(echo $1 | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw1=$( awk 'BEGIN{print '$ioraw1' * 1024}' ) + ioraw2=$( echo $2 | awk 'NR==1 {print $1}' ) + [ "$(echo $2 | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw2=$( awk 'BEGIN{print '$ioraw2' * 1024}' ) + ioraw3=$( echo $3 | awk 'NR==1 {print $1}' ) + [ "$(echo $3 | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw3=$( awk 'BEGIN{print '$ioraw3' * 1024}' ) + ioall=$( awk 'BEGIN{print '$ioraw1' + '$ioraw2' + '$ioraw3'}' ) + ioavg=$( awk 'BEGIN{printf "%.1f", '$ioall' / 3}' ) + printf "%s" "$ioavg" +} + +cpubench() { + if hash $1 2>$NULL; then + io=$( ( dd if=/dev/zero bs=512K count=$2 | $1 ) 2>&1 | grep 'copied' | awk -F, '{io=$NF} END { print io}' ) + if [[ $io != *"."* ]]; then + printf " %4i %s" "${io% *}" "${io##* }" + else + printf "%4i.%s" "${io%.*}" "${io#*.}" + fi + else + printf " %s not found on system." "$1" + fi +} + +iotest () { + echo "" | tee -a $log + echostyle "## IO Test" + echo "" | tee -a $log + + # start testing + writemb=$(freedisk) + if [[ $writemb -gt 512 ]]; then + writemb_size="$(( writemb / 2 / 2 ))MB" + writemb_cpu="$(( writemb / 2 ))" + else + writemb_size="$writemb"MB + writemb_cpu=$writemb + fi + + # CPU Speed test + printf " CPU Speed:\n" | tee -a $log + printf " bzip2 %s -" "$writemb_size" | tee -a $log + printf "%s\n" "$( cpubench bzip2 $writemb_cpu )" | tee -a $log + printf " sha256 %s -" "$writemb_size" | tee -a $log + printf "%s\n" "$( cpubench sha256sum $writemb_cpu )" | tee -a $log + printf " md5sum %s -" "$writemb_size" | tee -a $log + printf "%s\n\n" "$( cpubench md5sum $writemb_cpu )" | tee -a $log + + # Disk test + echo " Disk Speed ($writemb_size):" | tee -a $log + if [[ $writemb != "1" ]]; then + io=$( ( dd bs=512K count=$writemb if=/dev/zero of=test; rm -f test ) 2>&1 | awk -F, '{io=$NF} END { print io}' ) + echo " I/O Speed -$io" | tee -a $log + + io=$( ( dd bs=512K count=$writemb if=/dev/zero of=test oflag=dsync; rm -f test ) 2>&1 | awk -F, '{io=$NF} END { print io}' ) + echo " I/O Direct -$io" | tee -a $log + else + echo " Not enough space to test." | tee -a $log + fi + echo "" | tee -a $log + + # RAM Speed test + # set ram allocation for mount + tram_mb="$( free -m | grep Mem | awk 'NR=1 {print $2}' )" + if [[ tram_mb -gt 1900 ]]; then + sbram=1024M + sbcount=2048 + else + sbram=$(( tram_mb / 2 ))M + sbcount=$tram_mb + fi + [[ -d $benchram ]] || mkdir $benchram + mount -t tmpfs -o size=$sbram tmpfs $benchram/ + printf " RAM Speed (%sB):\n" "$sbram" | tee -a $log + iow1=$( ( dd if=/dev/zero of=$benchram/zero bs=512K count=$sbcount ) 2>&1 | awk -F, '{io=$NF} END { print io}' ) + ior1=$( ( dd if=$benchram/zero of=$NULL bs=512K count=$sbcount; rm -f test ) 2>&1 | awk -F, '{io=$NF} END { print io}' ) + iow2=$( ( dd if=/dev/zero of=$benchram/zero bs=512K count=$sbcount ) 2>&1 | awk -F, '{io=$NF} END { print io}' ) + ior2=$( ( dd if=$benchram/zero of=$NULL bs=512K count=$sbcount; rm -f test ) 2>&1 | awk -F, '{io=$NF} END { print io}' ) + iow3=$( ( dd if=/dev/zero of=$benchram/zero bs=512K count=$sbcount ) 2>&1 | awk -F, '{io=$NF} END { print io}' ) + ior3=$( ( dd if=$benchram/zero of=$NULL bs=512K count=$sbcount; rm -f test ) 2>&1 | awk -F, '{io=$NF} END { print io}' ) + echo " Avg. write - $(averageio "$iow1" "$iow2" "$iow3") MB/s" | tee -a $log + echo " Avg. read - $(averageio "$ior1" "$ior2" "$ior3") MB/s" | tee -a $log + rm $benchram/zero + umount $benchram + rm -rf $benchram + echo "" | tee -a $log +} + +speedtestresults () { + #Testing Speedtest + if hash python 2>$NULL; then + curl -Lso speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py + python speedtest-cli --share | tee -a $log + rm -f speedtest-cli + echo "" + else + echo " Python is not installed." + echo " First install python, then re-run the script." + echo "" + fi +} + +startedon() { + echo "\$ $ARG" >> $log + echo "" | tee -a $log + benchstart=$(date +"%d-%b-%Y %H:%M:%S") + start_seconds=$(date +%s) + echo " Benchmark started on $benchstart" | tee -a $log +} + +finishedon() { + end_seconds=$(date +%s) + echo " Benchmark finished in $((end_seconds-start_seconds)) seconds" | tee -a $log + echo " results saved on $log" + echo "" | tee -a $log +} + +sharetest() { + case $1 in + 'ubuntu') + share_link=$( curl -v --data-urlencode "content@$log" -d "poster=bench.log" -d "syntax=text" "https://paste.ubuntu.com" 2>&1 | \ + grep "Location" | awk '{print $3}' );; + 'haste' ) + share_link=$( curl -X POST -s -d "$(cat $log)" https://hastebin.com/documents | awk -F '"' '{print "https://hastebin.com/"$4}' );; + 'clbin' ) + share_link=$( curl -sF 'clbin=<-' https://clbin.com < $log );; + 'ptpb' ) + share_link=$( curl -sF c=@- https://ptpb.pw/?u=1 < $log );; + esac + + # print result info + echo " Share result:" + echo " $share_link" + echo "" + +} + +case $CMD in + '-info'|'-information'|'--info'|'--information' ) + systeminfo;; + '-io'|'-drivespeed'|'--io'|'--drivespeed' ) + iotest;; + '-northamercia'|'-na'|'--northamercia'|'--na' ) + benchinit; northamerciaspeedtest;; + '-europe'|'-eu'|'--europe'|'--eu' ) + benchinit; europespeedtest;; + '-exotic'|'--exotic' ) + benchinit; exoticpeedtest;; + '-asia'|'--asia' ) + benchinit; asiaspeedtest;; + '-cdn'|'--cdn' ) + benchinit; cdnspeedtest;; + '-b'|'--b' ) + benchinit; startedon; systeminfo; cdnspeedtest; iotest; finishedon;; + '-a'|'-all'|'-bench'|'--a'|'--all'|'--bench' ) + benchinit; startedon; systeminfo; cdnspeedtest; northamerciaspeedtest; + europespeedtest; exoticpeedtest; asiaspeedtest; iotest; finishedon;; + '-speed'|'-speedtest'|'-speedcheck'|'--speed'|'--speedtest'|'--speedcheck' ) + benchinit; speedtestresults;; + '-help'|'--help'|'help' ) + prms;; + '-about'|'--about'|'about' ) + about;; + *) + howto;; +esac + +case $PRM1 in + '-share'|'--share'|'share' ) + if [[ $PRM2 == "" ]]; then + sharetest ubuntu + else + sharetest $PRM2 + fi + ;; +esac + +# ring a bell +printf '\007' diff --git a/menu/functions/emergency.sh b/menu/functions/emergency.sh new file mode 100644 index 00000000..74b91d5e --- /dev/null +++ b/menu/functions/emergency.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# Title: PTS Emergency Log Gen +# org.Author(s): Admin9705 +# Mod: MrDoob MainDev from PTS +# GNU: General Public License v3.0 +################################################################################ +source /opt/plexguide/menu/functions/functions.sh +abc="/var/plexguide" + + mkdir -p /opt/appdata/plexguide/emergency + variable ${abc}/emergency.display "On" + if [[ $(ls /opt/appdata/plexguide/emergency) != "" ]]; then + + # If not on, do not display emergency logs + if [[ $(cat /var/plexguide/emergency.display) == "On" ]]; then + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ Emergency & Warning Log Generator +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +NOTE: This can be turned [On] or Off in Settings! + +EOF + + countmessage=0 + while read p; do + let countmessage++ + echo -n "${countmessage}. " && cat /opt/appdata/plexguide/emergency/$p + done <<<"$(ls /opt/appdata/plexguide/emergency)" + + echo + read -n 1 -s -r -p "Acknowledge Info | Press [ENTER]" + echo + else + touch ${abc}/emergency.log + fi + fi diff --git a/menu/functions/functions.sh b/menu/functions/functions.sh new file mode 100644 index 00000000..802bfa53 --- /dev/null +++ b/menu/functions/functions.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +# BAD INPUT +badinput() { + echo + read -p '⛔️ ERROR - Bad Input! | Press [ENTER] ' typed $1; fi +} + +readrcloneconfig() { + touch /opt/appdata/plexguide/rclone.conf + mkdir -p /var/plexguide/rclone/ + + gdcheck=$(cat /opt/appdata/plexguide/rclone.conf | grep gdrive) + if [ "$gdcheck" != "" ]; then + echo "good" >/var/plexguide/rclone/gdrive.status && gdstatus="good" + else echo "bad" >/var/plexguide/rclone/gdrive.status && gdstatus="bad"; fi + + gccheck=$(cat /opt/appdata/plexguide/rclone.conf | grep "remote = gdrive:/encrypt") + if [ "$gccheck" != "" ]; then + echo "good" >/var/plexguide/rclone/gcrypt.status && gcstatus="good" + else echo "bad" >/var/plexguide/rclone/gcrypt.status && gcstatus="bad"; fi + + tdcheck=$(cat /opt/appdata/plexguide/rclone.conf | grep tdrive) + if [ "$tdcheck" != "" ]; then + echo "good" >/var/plexguide/rclone/tdrive.status && tdstatus="good" + else echo "bad" >/var/plexguide/rclone/tdrive.status && tdstatus="bad"; fi + + tccheck=$(cat /opt/appdata/plexguide/rclone.conf | grep "remote = tdrive:/encrypt") + if [ "$tccheck" != "" ]; then + echo "good" >/var/plexguide/rclone/tcrypt.status && tcstatus="good" + else echo "bad" >/var/plexguide/rclone/tcrypt.status && tcstatus="bad"; fi + +} + +rcloneconfig() { + rclone config --config /opt/appdata/plexguide/rclone.conf +} + +keysprocessed() { + mkdir -p /opt/appdata/plexguide/keys/processed + ls -1 /opt/appdata/plexguide/keys/processed | wc -l >/var/plexguide/project.keycount +} diff --git a/menu/functions/install.sh b/menu/functions/install.sh new file mode 100644 index 00000000..57ce77d1 --- /dev/null +++ b/menu/functions/install.sh @@ -0,0 +1,316 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +source /opt/plexguide/menu/functions/functions.sh +source /opt/plexguide/menu/functions/serverid.sh + +updateprime() { + abc="/var/plexguide" + mkdir -p ${abc} + chmod 0775 ${abc} + chown 1000:1000 ${abc} + + variable ${abc}/pgfork.project "UPDATE ME" + variable ${abc}/pgfork.version "changeme" + variable ${abc}/tld.program "portainer" + variable /opt/appdata/plexguide/plextoken "" + variable ${abc}/server.ht "" + variable ${abc}/server.email "NOT-SET" + variable ${abc}/server.domain "NOT-SET" + variable ${abc}/pg.number "New-Install" + variable ${abc}/emergency.log "" + variable ${abc}/pgbox.running "" + pgnumber=$(cat /var/plexguide/pg.number) + + hostname -I | awk '{print $1}' >${abc}/server.ip + file="${abc}/server.hd.path" + if [ ! -e "$file" ]; then echo "/mnt" >${abc}/server.hd.path; fi + + file="${abc}/new.install" + if [ ! -e "$file" ]; then newinstall; fi + +versioncheck=$(cat /etc/*-release | grep "Ubuntu" | grep -E '19') + if [ "$versioncheck" == "19" ]; then + tee <<-EOF +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔ Argggggg ...... System Warning! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Supported: UBUNTU 16.xx - 18.10 ~ LTS/SERVER and Debian 9.* / 10 + +This server may not be supported due to having the incorrect OS detected! + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + exit 1 + else + echo "18" >${abc}/os.version.check; + fi + +ospgversion=$(cat /etc/*-release | grep Debian | grep -E '9|10') + if [ "$ospgversion" != "" ]; then + echo "debian" >${abc}/os.version + else + echo "ubuntu" >${abc}/os.version; + fi + + echo "3" >${abc}/pg.mergerfsinstall + echo "52" >${abc}/pg.pythonstart + echo "12" >${abc}/pg.aptupdate + echo "150" >${abc}/pg.preinstall + echo "24" >${abc}/pg.folders + echo "16" >${abc}/pg.dockerinstall + echo "15" >${abc}/pg.server + echo "1" >${abc}/pg.serverid + echo "33" >${abc}/pg.dependency + echo "11" >${abc}/pg.docstart + echo "2" >${abc}/pg.motd + echo "115" >${abc}/pg.alias + echo "3" >${abc}/pg.dep + echo "3" >${abc}/pg.cleaner + echo "3" >${abc}/pg.gcloud + echo "12" >${abc}/pg.hetzner + echo "1" >${abc}/pg.amazonaws + echo "8.4" >${abc}/pg.verionid + echo "1" >${abc}/pg.installer + echo "7" >${abc}/pg.prune + echo "21" >${abc}/pg.mountcheck + echo "11" >${abc}/pg.watchtower +} + +pginstall() { + updateprime + bash /opt/plexguide/menu/pggce/gcechecker.sh + core pythonstart + core aptupdate + core alias + core folders + core dependency + core mergerfsinstall + core dockerinstall + core docstart + + touch ${abc}/install.roles + rolenumber=3 + # Roles Ensure that PG Replicates and has once if missing; important for startup, cron and etc + if [[ $(cat /var/plexguide/install.roles) != "$rolenumber" ]]; then + rm -rf /opt/{coreapps,communityapps,pgshield} + + pgcore + pgcommunity + pgshield + echo "$rolenumber" >${abc}/install.roles + fi + rcloneinstall + portainer + core motd &>/dev/null & + core hetzner &>/dev/null & + core gcloud + core cleaner &>/dev/null & + core serverid + core prune + customcontainers &>/dev/null & + pgedition + core mountcheck + emergency + pgdeploy +} + +core() { + touch ${abc}/pg."${1}".stored + start=$(cat /var/plexguide/pg."${1}") + stored=$(cat /var/plexguide/pg."${1}".stored) + if [ "$start" != "$stored" ]; then + $1 + cat ${abc}/pg."${1}" >${abc}/pg."${1}".stored + fi +} + +############################################################ INSTALLER FUNCTIONS +alias() { + ansible-playbook /opt/plexguide/menu/alias/alias.yml +} + +check(){ +file="/opt/plexguide/menu/pg.yml" + if [[ -f $file ]]; then + tee <<-EOF +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅ All files Valid +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + else ansible-playbook opt/plexguide/menu/version/missing_pull.yml; fi +} + +remove(){ + ansible-playbook /opt/plexguide/menu/pg.yml --tag remove 1>/dev/null 2>&1 +} + +templatespart2() { + remove + alias 1>/dev/null 2>&1 + owned 1>/dev/null 2>&1 + check +} + +owned() { + chown -cR 1000:1000 /opt/plexguide 1>/dev/null 2>&1 + chmod -R 775 /opt/plexguide 1>/dev/null 2>&1 +} + +aptupdate() { + ansible-playbook /opt/plexguide/menu/pg.yml --tags update +} + +customcontainers() { + mkdir -p /opt/{coreapps,communityapps/apps,pgshield,mycontainers} +} + +cleaner() { + ansible-playbook /opt/plexguide/menu/pg.yml --tags autodelete,clean,journal &>/dev/null & +} + +dependency() { + ospgversion=$(cat /var/plexguide/os.version) + if [ "$ospgversion" == "debian" ]; then + ansible-playbook /opt/plexguide/menu/dependency/dependencydeb.yml + else + ansible-playbook /opt/plexguide/menu/dependency/dependency.yml + fi +} + +docstart() { + ansible-playbook /opt/plexguide/menu/pg.yml --tags docstart +} + +emergency() { + bash /opt/plexguide/menu/functions/emergency.sh +} + +folders() { + ansible-playbook /opt/plexguide/menu/installer/folders.yml +} + +prune() { + ansible-playbook /opt/plexguide/menu/prune/main.yml +} + +gcloud() { + ansible-playbook /opt/plexguide/menu/pg.yml --tags gcloud_sdk +} + +mergerfsupdate() { +mgversion="$(curl -s https://api.github.com/repos/trapexit/mergerfs/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')" +mgstored="$(mergerfs -v | grep 'mergerfs version:' | awk '{print $3}')" +if [[ "$mgversion" == "$mgstored" ]]; then + echo "✅ mergerfs latest stable version check " + clear +elif [[ "$mgversion" != "$mgstored" ]]; then + ansible-playbook /opt/plexguide/menu/pg.yml --tags mergerfsupdate + bash /opt/plexguide/menu/pgui/templates/check.sh + sleep 2 + clear + tee <<-EOF +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ mergerfs updated to version $mgstored +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF +sleep 3s +fi +} + +mergerfsinstall() { + ansible-playbook /opt/plexguide/menu/pg.yml --tags mergerfsinstall +} + +rcloneinstall() { +# ansible-playbook /opt/plexguide/menu/pg.yml --tags rcloneinstall +rcversion="$(curl -s https://api.github.com/repos/rclone/rclone/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')" +rcstored="$(rclone --version | awk '{print $2}' | tail -n 3 | head -n 1 )" + +if [[ "$rcversion" == "$rcstored" ]]; then + echo "✅ rclone latest stable version check " + clear +elif [[ "$rcversion" != "$rcstored" ]]; then + ansible-playbook /opt/plexguide/menu/pg.yml --tags rcloneinstall + bash /opt/plexguide/menu/pgui/templates/check.sh + sleep 2 + clear + tee <<-EOF +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ rclone updated to version $rcstored +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF +sleep 3s +fi +} + +motd() { + ansible-playbook /opt/plexguide/menu/motd/motd.yml +} + +mountcheck() { + ansible-playbook /opt/plexguide/menu/pgui/mcdeploy.yml +} + +newinstall() { + rm -rf ${abc}/pg.exit 1>/dev/null 2>&1 + file="${abc}/new.install" + if [ ! -e "$file" ]; then + touch ${abc}/pg.number && echo off >/tmp/program_source + bash /opt/plexguide/menu/version/file.sh + file="${abc}/new.install" + if [ ! -e "$file" ]; then exit; fi + fi +} + +pgdeploy() { + touch ${abc}/pg.edition && bash /opt/plexguide/menu/start/start.sh +} + +pgedition() { + file="${abc}/path.check" + if [ ! -e "$file" ]; then touch ${abc}/path.check && bash /opt/plexguide/menu/dlpath/dlpath.sh; fi + # FOR PG-BLITZ + file="${abc}/project.deployed" + if [ ! -e "$file" ]; then echo "no" >${abc}/project.deployed; fi + file="${abc}/project.keycount" + if [ ! -e "$file" ]; then echo "0" >${abc}/project.keycount; fi + file="${abc}/server.id" + if [ ! -e "$file" ]; then echo "[NOT-SET]" -rf >${abc}/rm; fi +} + +portainer() { + dstatus=$(docker ps --format '{{.Names}}' | grep "portainer") + if [ "$dstatus" != "portainer" ]; then + ansible-playbook /opt/coreapps/apps/portainer.yml &>/dev/null & + fi +} + +# Roles Ensure that PG Replicates and has once if missing; important for startup, cron and etc +pgcore() { if [ ! -e "/opt/coreapps/place.holder" ]; then ansible-playbook /opt/plexguide/menu/pgbox/boxcore.yml; fi; } +pgcommunity() { if [ ! -e "/opt/communityapps/place.holder" ]; then ansible-playbook /opt/plexguide/menu/pgbox/boxcommunity.yml; fi; } +pgshield() { if [ ! -e "/opt/pgshield/place.holder" ]; then + echo 'pgshield' >/var/plexguide/pgcloner.rolename + echo 'PTS-Shield' >${abc}/pgcloner.roleproper + echo 'PTS-Shield' >${abc}/pgcloner.projectname + echo 'master' >${abc}/pgcloner.projectversion + echo 'pgshield.sh' >${abc}/pgcloner.startlink + ansible-playbook "/opt/plexguide/menu/pgcloner/corev2/primary.yml" +fi; } + +pythonstart() { + bash /opt/plexguide/menu/roles/pythonstart/pyansible.sh >/dev/null 2>&1 +} + +dockerinstall() { + ansible-playbook /opt/plexguide/menu/pg.yml --tags docker +} + +#serverid() { +# bash /opt/plexguide/menu/functions/serverid.sh +#} diff --git a/menu/functions/network.sh b/menu/functions/network.sh new file mode 100644 index 00000000..827ec557 --- /dev/null +++ b/menu/functions/network.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +source /opt/plexguide/menu/functions/functions.sh +# Menu Interface +question1() { + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +📂 System & Network Auditor +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +[1] System & Network Benchmark - Basic +[2] System & Network Benchmark - Advanced + +[3] Simple SpeedTest + +[Z] Exit + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + # Standby + read -p '↘️ Type Number | Press [ENTER]: ' typed /var/plexguide/project.account + + file="/var/plexguide/project.final" + if [ ! -e "$file" ]; then echo "[NOT SET]" >/var/plexguide/project.final; fi + + file="/var/plexguide/project.processor" + if [ ! -e "$file" ]; then echo "NOT-SET" >/var/plexguide/project.processor; fi + + file="/var/plexguide/project.location" + if [ ! -e "$file" ]; then echo "NOT-SET" >/var/plexguide/project.location; fi + + file="/var/plexguide/project.ipregion" + if [ ! -e "$file" ]; then echo "NOT-SET" >/var/plexguide/project.ipregion; fi + + file="/var/plexguide/project.ipaddress" + if [ ! -e "$file" ]; then echo "IP NOT-SET" >/var/plexguide/project.ipaddress; fi + + file="/var/plexguide/gce.deployed" + if [ -e "$file" ]; then + echo "Server Deployed" >/var/plexguide/gce.deployed.status + else echo "Not Deployed" >/var/plexguide/gce.deployed.status; fi + + project=$(cat /var/plexguide/project.final) + account=$(cat /var/plexguide/project.account) + processor=$(cat /var/plexguide/project.processor) + ipregion=$(cat /var/plexguide/project.ipregion) + ipaddress=$(cat /var/plexguide/project.ipaddress) + serverstatus=$(cat /var/plexguide/gce.deployed.status) +} diff --git a/menu/functions/pgvault.func b/menu/functions/pgvault.func new file mode 100644 index 00000000..838f31c8 --- /dev/null +++ b/menu/functions/pgvault.func @@ -0,0 +1,628 @@ +#!/bin/bash +# +# Title: Backup and Restore +# Author(s): Admin9705 +# GNU: General Public License v3.0 +################################################################################ +runningcheck() { + initial2 + runcheck5=$(docker ps | grep ${program_var}) + if [ "$runcheck5" != "" ]; then running=1; else running=0; fi +} + +initial() { + rm -rf /var/plexguide/pgvault.output 1>/dev/null 2>&1 + rm -rf /var/plexguide/pgvault.buildup 1>/dev/null 2>&1 + rm -rf /var/plexguide/program.temp 1>/dev/null 2>&1 + rm -rf /var/plexguide/app.list 1>/dev/null 2>&1 + rm -rf /var/plexguide/pgvault.output 1>/dev/null 2>&1 + touch /var/plexguide/pgvault.output + touch /var/plexguide/program.temp + touch /var/plexguide/app.list + touch /var/plexguide/pgvault.buildup + touch /var/plexguide/pgvault.output + touch /var/plexguide/rclone.size + space=$(cat /var/plexguide/data.location) + # To Get Used Space + used=$(df -h /opt/appdata/plexguide | tail -n +2 | awk '{print $3}') + # To Get All Space + capacity=$(df -h /opt/appdata/plexguide | tail -n +2 | awk '{print $2}') + # Percentage + percentage=$(df -h /opt/appdata/plexguide | tail -n +2 | awk '{print $5}') +} + +initial2() { + path=$(cat /var/plexguide/server.hd.path) + tarlocation=$(cat /var/plexguide/data.location) + program_size=$(cat /var/plexguide/rclone.size) + program_var=$(cat /tmp/program_var) + server_id=$(cat /var/plexguide/server.id) +} + +final() { + echo + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + read -p '✅ Process Complete! | PRESS [ENTER] ' typed pgvault.serverlist +} + +pgboxrecall() { + ls -p /opt/coreapps/apps | grep -v / >/var/plexguide/pgvault.apprecall + while read p; do + sed -i "/^$p\b/Id" /var/plexguide/pgvault.apprecall + done >/var/plexguide/pgvault.apprecall + done /dev/null 2>&1 + while read p; do + echo -n $p >>/var/plexguide/program.temp + echo -n " " >>/var/plexguide/program.temp + num=$((num + 1)) + if [ "$num" == 7 ]; then + num=0 + echo " " >>/var/plexguide/program.temp + fi + done /var/plexguide/pgvault.apprecall + while read p; do + sed -i "/^$p\b/Id" /var/plexguide/pgvault.apprecall + done >/var/plexguide/pgvault.buildup + sed -i "/^$typed\b/Id" /var/plexguide/pgvault.apprecall + + num=0 + rm -rf /var/plexguide/pgvault.output 1>/dev/null 2>&1 + while read p; do + echo -n $p >>/var/plexguide/pgvault.output + echo -n " " >>/var/plexguide/pgvault.output + if [ "$num" == 7 ]; then + num=0 + echo " " >>/var/plexguide/pgvault.output + fi + done /tmp/server.list + + ### List Out Apps In Readable Order (One's Not Installed) + num=0 + rm -rf /var/plexguide/program.temp 1>/dev/null 2>&1 + while read p; do + echo -n $p >>/var/plexguide/program.temp + echo -n " " >>/var/plexguide/program.temp + num=$((num + 1)) + if [ "$num" == 7 ]; then + num=0 + echo " " >>/var/plexguide/program.temp + fi + done /tmp/server.select + + if [[ "$server" == "exit" || "$server" == "Exit" || "$server" == "EXIT" || "$server" == "z" || "$server" == "Z" ]]; then exit; fi + + current2=$(cat /tmp/server.list | grep "\<$server\>") + if [ "$current2" == "" ]; then + badserver + serverprime + fi + + tempserver=$server + ls -l /mnt/gdrive/plexguide/backup/$tempserver | awk '{print $9}' | tail -n +2 >/var/plexguide/pgvault.restoreapps + + ### Blank Out Temp List + rm -rf /var/plexguide/pgvault.apprecall 1>/dev/null 2>&1 + touch /var/plexguide/pgvault.apprecall + + while read p; do + basename "$p" .tar >>/var/plexguide/pgvault.apprecall + done /dev/null 2>&1 + touch /var/plexguide/program.temp + mathprime +} + +buildup2() { + echo "$typed" >>/var/plexguide/pgvault.buildup + sed -i "/^$typed\b/Id" /var/plexguide/pgvault.apprecall + + num=0 + rm -rf /var/plexguide/pgvault.output 1>/dev/null 2>&1 + while read p; do + echo -n $p >>/var/plexguide/pgvault.output + echo -n " " >>/var/plexguide/pgvault.output + if [ "$num" == 7 ]; then + num=0 + echo " " >>/var/plexguide/pgvault.output + fi + done /tmp/program_var + # Execute Main Program + backup_process + + sleep 2 + done /tmp/program_var + # Execute Main Program + backup_process + + sleep 2 + done /dev/null 2>&1 + fi + + ###### Start the Backup Process - Backup Locally First + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Zipping Data Locally - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + path=$(cat /var/plexguide/server.hd.path) + tarlocation=$(cat /var/plexguide/data.location) + server_id=$(cat /var/plexguide/server.id) + + tar \ + --warning=no-file-changed --ignore-failed-read --absolute-names --warning=no-file-removed \ + --exclude-from=/opt/pgvault/exclude.list \ + -C /opt/appdata/${program_var} -cvf /opt/appdata/plexguide/${program_var}.tar ./ + + ##### Restart Docker Application if was Running Prior + if [ "$running" == "1" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Restarting Docker Application - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + sleep 2 + docker restart $program_var 1>/dev/null 2>&1 + fi + + ###### Backing Up Files to GDrive + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Sending Zipped Data to Google Drive - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + +useragent="$(cat /var/plexguide/uagent)" +bwlimit="$(cat /var/plexguide/blitz.bw)" + +vfs_dcs="$(cat /var/plexguide/vfs_dcs)" +vfs_mt="$(cat /var/plexguide/vfs_mt)" +vfs_t="$(cat /var/plexguide/vfs_t)" +vfs_c="$(cat /var/plexguide/vfs_c)" + + + rclone --config /opt/appdata/plexguide/rclone.conf mkdir gdrive:/plexguide/backup/${server_id} 1>/dev/null 2>&1 + + rclone moveto ${tarlocation}/${program_var}.tar \ + gdrive:/plexguide/backup/${server_id}/${program_var}.tar \ + --config /opt/appdata/plexguide/rclone.conf \ + -v --checksum --stats-one-line --stats 1s --progress \ + --tpslimit=10 \ + --checkers="$vfs_c" \ + --transfers="$vfs_t" \ + --no-traverse \ + --fast-list \ + --bwlimit="$bwlimit" \ + --drive-chunk-size="$vfs_dcs" \ + --user-agent="$useragent" + +##### Remove File Incase +rm -rf ${tarlocation}/${program_var}.tar 1>/dev/null 2>&1 +} +######################################################## END - PG Vault Backup +# +##################################################### START - PG Vault Restore +restore_all_start() { + + while read p; do + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Vault - Restoring: $p +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + sleep 2.5 + + # Store Used Program + echo $p >/tmp/program_var + # Execute Main Program + restore_process + + sleep 2 + done /tmp/program_var + # Execute Main Program + restore_process + + sleep 2 + done /dev/null 2>&1 + fi + + ###### Start the Backup Process - Backup Locally First + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ UnZipping & Restoring Data - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + mkdir -p "/opt/appdata/${program_var}" + rm -rf "/opt/appdata/${program_var}/*" + chown -R 1000:1000 "/opt/appdata/${program_var}" + chmod -R 775 "/opt/appdata/${program_var}" + tar -C /opt/appdata/${program_var} -xvf ${tarlocation}/${program_var}.tar + chown -R 1000:1000 "/opt/appdata/${program_var}" + chmod -R 775 "/opt/appdata/${program_var}" + ##rebuild app after restore + if [ -e "/opt/coreapps/apps/$program_var.yml" ]; then ansible-playbook /opt/coreapps/apps/$program_var.yml; fi + if [ -e "/opt/communityapps/$program_var.yml" ]; then ansible-playbook /opt/communityapps/apps/$program_var.yml; fi + if [ -e "/opt/mycontainers/$program_var.yml" ]; then ansible-playbook /opt/mycontainers/apps/$program_var.yml; fi + + ##### Restart Docker Application if was Running Prior + if [ "$running" == "1" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Restarting Docker Application - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + sleep 2 + docker restart $program_var 1>/dev/null 2>&1 + fi + + ##### Remove File Incase + rm -rf ${tarlocation}/${program_var}.tar 1>/dev/null 2>&1 +} +##################################################### END - PG Vault Restore +# +##################################################### START - Backup Interface +vaultbackup() { + ### List Out Apps In Readable Order (One's Not Installed) + notrun=$(cat /var/plexguide/program.temp) + buildup=$(cat /var/plexguide/pgvault.output) + + if [ "$buildup" == "" ]; then buildup="NONE"; fi + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 Vault ~ Data Storage +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +📂 App Data available to Backup + +$notrun + +💾 Apps Queued for Backup + +$buildup + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +[A] Backup +[Z] Exit +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p '🌍 Type APP for QUEUE | Type all to backup all apps | Press [ENTER]: ' typed ") + if [ "$current2" != "" ]; then + queued + vaultbackup + fi + + cat /var/plexguide/pgvault.buildup >/tmp/appcheck.5 + cat /var/plexguide/pgvault.apprecall >>/tmp/appcheck.5 + current1=$(cat /tmp/appcheck.5 | grep "\<$typed\>") + if [ "$current1" == "" ]; then badinput && vaultbackup; fi + + buildup +} +##################################################### END - Backup Interface +# +##################################################### START - Restore Interface +vaultrestore() { + notrun=$(cat /var/plexguide/program.temp) + buildup=$(cat /var/plexguide/pgvault.output) + + if [ "$buildup" == "" ]; then buildup="NONE"; fi + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 Vault ~ Data Recall +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +📂 App Data available to Restore + +$notrun + +💾 Apps Queued for Restore + +$buildup + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +[A] Restore +[Z] Exit +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p '🌍 Type APP for QUEUE | Type all to restore all apps | Press [ENTER]: ' typed ") + if [ "$current2" != "" ]; then + queued + vaultrestore + fi + cat /var/plexguide/pgvault.buildup >/tmp/appcheck.5 + cat /var/plexguide/pgvault.apprecall >>/tmp/appcheck.5 + current2=$(cat /tmp/appcheck.5 | grep "\<$typed\>") + echo $current2 >/var/plexguide/app_rebuild + #Rebuild Depending on Location + if [ "$current2" == "" ]; then badinput && vaultrestore; fi + buildup2 +} +##################################################### START Primary Interface +primaryinterface() { + initial2 + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +📁 Vault Interface +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +🌵 Disk Used Space: $used of $capacity | $percentage Used Capacity + +[1] Data Backup +[2] Data Restore +[3] Current Server ID : $server_id +[4] Processing Location: $tarlocation + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +[Z] Exit +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p 'Type a Number | Press [ENTER]: ' typed /var/plexguide/server.id.stored + bash /opt/plexguide/menu/interface/serverid.sh + primaryinterface + elif [ "$typed" == "4" ]; then + bash /opt/pgvault/location.sh + primaryinterface + elif [[ "$typed" == "Z" || "$typed" == "z" ]]; then + exit + else + badinput + primaryinterface + fi +} +##################################################### END Primary Interface + +restorecheck() { + if [ "$restoreid" == "[NOT-SET]" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ WARNING! - You Must Set Your Recovery ID First! Restarting Process! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -n 1 -s -r -p "Press [ANY] Key to Continue " + echo + primaryinterface + exit + fi +} diff --git a/menu/functions/serverid.sh b/menu/functions/serverid.sh new file mode 100644 index 00000000..4daaf27e --- /dev/null +++ b/menu/functions/serverid.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# +# Title: PTS ServerID +# org. Author(s): Admin9705 - Deiteq +# Mod from MrDoob for PTS +# GNU: General Public License v3.0 +################################################################################ +touch /var/plexguide/server.id.stored +source /opt/plexguide/menu/functions/functions.sh +#start=$(cat /var/plexguide/server.id) +#stored=$(cat /var/plexguide/server.id.stored) + + +serverid() { + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Establishing Server ID 💬 Use One Word & Keep it Simple +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + read -p '🌏 TYPE Server ID | Press [ENTER]: ' typed ${abc}/server.id + sleep 1 + fi +} diff --git a/menu/functions/start.sh b/menu/functions/start.sh new file mode 100644 index 00000000..be08e2f4 --- /dev/null +++ b/menu/functions/start.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# +# Title: PTS major file +# org.Author(s): Admin9705 - Deiteq +# Mod from MrDoob for PTS +# GNU: General Public License v3.0 +################################################################################ +source /opt/plexguide/menu/functions/functions.sh +source /opt/plexguide/menu/functions/install.sh + +sudocheck() { + if [[ $EUID -ne 0 ]]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ You Must Execute as a SUDO USER (with sudo) or as ROOT! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + exit 1 + fi +} + +downloadpg() { + rm -rf /opt/plexguide + git clone --single-branch https://github.com/PTS-Team/PTS-Team.git /opt/plexguide 1>/dev/null 2>&1 + ansible-playbook /opt/plexguide/menu/version/missing_pull.yml + ansible-playbook /opt/plexguide/menu/alias/alias.yml 1>/dev/null 2>&1 + rm -rf /opt/plexguide/place.holder >/dev/null 2>&1 + rm -rf /opt/plexguide/.git* >/dev/null 2>&1 +} + +missingpull() { + file="/opt/plexguide/menu/functions/install.sh" + if [ ! -e "$file" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ Base folder went missing! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + sleep 2 + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + 🍖 NOM NOM - Re-Downloading PTS +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 2 + downloadpg + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅️ Repair Complete! Standby! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + sleep 2 + fi +} + +exitcheck() { + bash /opt/plexguide/menu/version/file.sh + file="/var/plexguide/exited.upgrade" + if [ ! -e "$file" ]; then + bash /opt/plexguide/menu/interface/ending.sh + else + rm -rf /var/plexguide/exited.upgrade 1>/dev/null 2>&1 + echo "" + bash /opt/plexguide/menu/interface/ending.sh + fi +} diff --git a/menu/functions/tshoot.sh b/menu/functions/tshoot.sh new file mode 100644 index 00000000..bfca0945 --- /dev/null +++ b/menu/functions/tshoot.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# +# Title: PTS (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://PTS.com - http://github.PTS.com +# GNU: General Public License v3.0 +################################################################################ +main(){ +# Menu Interface +tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚥 TroubleShoot Interface +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +[1] Pre-Installer: Force the Entire Process Again +[2] UnInstaller : Docker & Running Containers | Force Pre-Install +[3] UnInstaller : PTS + +[Z] Exit + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + +# Standby + read -p '↘️ Type Number | Press [ENTER]: ' typed /var/plexguide/pg.preinstall.stored + echo "0" >/var/plexguide/pg.ansible.stored + echo "0" >/var/plexguide/pg.rclone.stored + echo "0" >/var/plexguide/pg.python.stored + echo "0" >/var/plexguide/pg.docker.stored + echo "0" >/var/plexguide/pg.docstart.stored + echo "0" >/var/plexguide/pg.watchtower.stored + echo "0" >/var/plexguide/pg.label.stored + echo "0" >/var/plexguide/pg.alias.stored + echo "0" >/var/plexguide/pg.dep.stored + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅️ WOOT WOOT - Process Complete! Exit & Restart PTS Now! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 5 +;; + +2) + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🍖 NOM NOM - Uninstalling Docker & Resetting the Variables! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 3 + + rm -rf /etc/docker + apt-get purge docker-ce && apt-get autoremove -yqq + rm -rf /var/lib/docker + rm -rf /var/plexguide/dep* + echo "0" >/var/plexguide/pg.preinstall.stored + echo "0" >/var/plexguide/pg.ansible.stored + echo "0" >/var/plexguide/pg.rclone.stored + echo "0" >/var/plexguide/pg.python.stored + echo "0" >/var/plexguide/pg.docstart.stored + echo "0" >/var/plexguide/pg.watchtower.stored + echo "0" >/var/plexguide/pg.label.stored + echo "0" >/var/plexguide/pg.alias.stored + echo "0" >/var/plexguide/pg.dep + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅️ WOOT WOOT - Process Complete! Exit & Restart PTS Now! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 5 +;; +3) + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🍖 NOM NOM - Starting the PTS UnInstaller +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 3 + echo "uninstall" >/var/plexguide/type.choice && bash /opt/plexguide/menu/core/scripts/main.sh ;; + z) exit ;; + Z) exit ;; + esac +} + +#### function start + +main diff --git a/menu/functions/watchtower.sh b/menu/functions/watchtower.sh new file mode 100644 index 00000000..6b2138e7 --- /dev/null +++ b/menu/functions/watchtower.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +source /opt/plexguide/menu/functions/functions.sh +abc="/var/plexguide" +echo "11" >${abc}/pg.watchtower + +watchtower() { + + file="/var/plexguide/watchtower.wcheck" + if [ ! -e "$file" ]; then + echo "4" >${abc}/watchtower.wcheck + fi + + wcheck=$(cat "${abc}/watchtower.wcheck") + if [[ "$wcheck" -ge "1" && "$wcheck" -le "3" ]]; then + wexit="1" + else wexit=0; fi + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +📂 Watch Tower +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +💬 WatchTower updates your containers soon as possible! + +[1] Containers: Auto-Update All +[2] Containers: Auto-Update All Except | Plex & Emby +[3] Containers: Never Update + +[4] Remove WatchTower + +[Z] - Exit + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + + # Standby + read -p 'Type a Number | Press [ENTER]: ' typed ${abc}/watchtower.wcheck + elif [ "$typed" == "2" ]; then + watchtowergen + sed -i -e "/plex/d" /tmp/watchtower.set 1>/dev/null 2>&1 + sed -i -e "/emby/d" /tmp/watchtower.set 1>/dev/null 2>&1 + sed -i -e "/jellyfin/d" /tmp/watchtower.set 1>/dev/null 2>&1 + ansible-playbook /opt/coreapps/apps/watchtower.yml + echo "2" >${abc}/watchtower.wcheck + elif [ "$typed" == "3" ]; then + echo null >/tmp/watchtower.set + ansible-playbook /opt/coreapps/apps/watchtower.yml + echo "3" >${abc}/watchtower.wcheck + elif [ "$typed" == "4" ]; then + echo null >/tmp/watchtower.set + docker stop watchtower >/dev/null 2>&1 + docker rm watchtower >/dev/null 2>&1 + echo "Watchtower Removed" + echo "3" >${abc}/watchtower.wcheck + elif [[ "$typed" == "Z" || "$typed" == "z" ]]; then + exit + else + badinput + watchtower + fi +} + +watchtowergen() { + bash /opt/coreapps/apps/_appsgen.sh + bash /opt/communityapps/apps/_appsgen.sh + while read p; do + echo -n $p >>/tmp/watchtower.set + echo -n " " >>/tmp/watchtower.set + done <${abc}/app.list +} diff --git a/menu/gce/blitzgce.sh b/menu/gce/blitzgce.sh new file mode 100644 index 00000000..1dfc0c26 --- /dev/null +++ b/menu/gce/blitzgce.sh @@ -0,0 +1,132 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +source /opt/blitzgce/functions/main.sh +source /opt/blitzgce/functions/interface.sh +source /opt/blitzgce/functions/ip.sh +source /opt/blitzgce/functions/deploy.sh +source /opt/blitzgce/functions/destroy.sh + +### the primary interface for GCE +gcestart() { + + ### call key variables ~ /functions/main.sh + variablepull + + ### For New Installs; hangs because of no account logged in yet; this prevents + othercheck=$(cat /var/plexguide/project.account) + secondcheck=$(cat /var/plexguide/project.id) + if [[ "$othercheck" != "NOT-SET" ]]; then + + if [[ "$secondcheck" != "NOT-SET" ]]; then + servercheck + else + projectid=NOT-SET + gcedeployedcheck=NOT-SET + fi + else + account=NOT-SET + projectid=NOT-SET + gcedeployedcheck=NOT-SET + fi + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 GCE Deployment +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +[ 1 ] Log Into the Account : [ $account ] +[ 2 ] Project Interface : [ $projectid ] +[ 3 } Processor Count : [ $processor ] +[ 4 ] Ram Count : [ $ramcount ] +[ 5 ] NVME Count : [ $nvmecount ] +[ 6 ] Set IP Region / Server: [ $ipaddress ] | [ $ipregion ] +[ 7 ] Deploy GCE Server : [ $gcedeployedcheck ] +[ 8 ] SSH into the GCE Box + +[ A ] Destroy Server + +[ Z ] Exit + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + read -p 'Type Number | Press [ENTER]: ' typed /var/plexguide/project.id + echo "on" >/var/plexguide/project.switch + ### note --no-user-output-enabled | gcloud auth login --enable-gdrive-access --brief + # gcloud config configurations list + gcestart + ;; + 2) + projectinterface + gcestart + ;; + 3) + projectdeny + processorcount + gcestart + ;; + + 4) + projectdeny + ramcount + gcestart + ;; + 5) + projectdeny + nvmecount + gcestart + ;; + 6) + projectdeny + regioncenter + gcestart + ;; + 7) + projectdeny + deployserver + gcestart + ;; + 8) + projectdeny + if [[ "$gcedeployedcheck" == "DEPLOYED" ]]; then + sshdeploy + else + gcestart + fi + ;; + A) + projectdeny + destroyserver + gcestart + ;; + a) + projectdeny + destroyserver + gcestart + ;; + z) + exit + ;; + Z) + exit + ;; + *) + gcestart + ;; + esac +} + +gcestart diff --git a/menu/gce/functions/deploy.sh b/menu/gce/functions/deploy.sh new file mode 100644 index 00000000..334eed29 --- /dev/null +++ b/menu/gce/functions/deploy.sh @@ -0,0 +1,112 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +source /opt/blitzgce/functions/main.sh + +deployserver() { + variablepull + ### checks to make sure common variables are filled out + deployfail + ### prevents deployment if one exists! + servercheck + if [[ "$gcedeployedcheck" == "DEPLOYED" ]]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 ERROR: GCE Instance Already Detected +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +INFORMATION: The prior GCE Server must be deleted prior to deloying a +another one! Exiting! + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p '↘️ Acknowledge Info | Press [ENTER] ' typed /dev/null 2>&1 + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 SYSTEM MESSAGE: Process Complete! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + read -p '↘️ Acknowledge Info | Press [ENTER] ' typed ") == "" ]]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 MESSAGE TYPE: ERROR +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +REASON: Billing Failed + +INSTRUCTIONS: + +Must turn on the billing for first for this project in GCE Panel. + +Exiting! + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p '↘️ Acknowledge Error | Press [ENTER] ' typed /var/plexguide/project.nvme + echo -e "--local-ssd interface=nvme" >$nvmedeploy + elif [[ "$typed" == "2" ]]; then + echo "$typed" >/var/plexguide/project.nvme + echo -e "--local-ssd interface=nvme \\n--local-ssd interface=nvme" >$nvmedeploy + elif [[ "$typed" == "3" ]]; then + echo "$typed" >/var/plexguide/project.nvme + echo -e "--local-ssd interface=nvme \\n--local-ssd interface=nvme \\n--local-ssd interface=nvme" >$nvmedeploy + elif [[ "$typed" == "4" ]]; then + echo "$typed" >/var/plexguide/project.nvme + echo -e "--local-ssd interface=nvme \\n--local-ssd interface=nvme \\n--local-ssd interface=nvme \\n--local-ssd interface=nvme" >$nvmedeploy + elif [[ "$typed" -gt "4" ]]; then + echo "more then 4 NVME's is not possible" && sleep 5 && nvmecount + elif [[ "$typed" == "Z" || "z" || "q" || "Q" || "c" || "C" ]]; then + echo "no changes" #fi + else nvmecount; fi +} +ramcount() { + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 RAM Count +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Most users will only need to utilize 8 Gb Ram. +Then more, the faster the processing, but the faster your credits drain. +If intent is to be in beast mode during the GCEs duration. + +INSTRUCTIONS: Set the RAM Count ~ 8 / 12 / 16 GB +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p 'Type Number | Press [ENTER]: ' typed /var/plexguide/project.ram + elif [[ "$typed" -gt "16" ]]; then + echo "more then 16 Gb Ram is not possible" && sleep 5 && ramcount + elif [[ "$typed" == "Z" || "z" || "q" || "Q" || "c" || "C" ]]; then + echo "no changes" #fi + else ramcount; fi +} + +processorcount() { + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 Processor Count +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +INFORMATION: + +The processor count utilizes can affect how fast your credits drain. +If usage is light, select 4. +If for average use, 4 or 6 is fine. +Only utilize 8 if the GCE will be used heavily! + +INSTRUCTIONS: Set the Processor Count ~ 4 / 6 / 8 + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p 'Type Number | Press [ENTER]: ' typed /var/plexguide/project.processor + elif [[ "$typed" -gt "8" ]]; then + echo "more then 8 CPU's is not possible" && sleep 5 && processorcount + elif [[ "$typed" == "Z" || "z" || "q" || "Q" || "c" || "C" ]]; then + echo "no changes" #fi + else processorcount; fi +} + +projectinterface() { + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 Project Interface +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Project ID: [ $projectid ] + +[ 1 ] Utilize/Change Existing Project +[ 2 ] Build a New Project + +[ 3 ] Destroy Existing Project + +[ Z ] Exit + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p 'Type Number | Press [ENTER]: ' typed /dev/null 2>&1 + + echo "" >/var/plexguide/prolist/final.sh + gcloud projects list | cut -d' ' -f1 | tail -n +2 >/var/plexguide/prolist/prolist.sh + + ### project no exist check + pcheck=$(cat /var/plexguide/prolist/prolist.sh) + if [[ "$pcheck" == "" ]]; then noprojects; fi + + while read p; do + let "pnum++" + echo "$p" >"/var/plexguide/prolist/$pnum" + echo "[$pnum] $p" >>/var/plexguide/prolist/final.sh + done /var/plexguide/project.switch + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 PLEASE WAIT! Enabling Billing ~ Project $typed +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + accountbilling=$(gcloud beta billing accounts list | tail -1 | awk '{print $1}') + gcloud beta billing projects link $typed --billing-account "$accountbilling" --quiet + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 PLEASE WAIT! Enabling Compute API ~ Project $typed +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + gcloud services enable compute.googleapis.com + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 PLEASE WAIT! Enabling Drive API ~ Project $typed +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + echo "" + gcloud services enable drive.googleapis.com --project $typed + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 NOTICE: Project Default Set ~ $typed +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + echo $typed >/var/plexguide/pgclone.project + echo + read -p '↘️ Acknowledge Info | Press [ENTER] ' typed /dev/null 2>&1 + + echo "" >/var/plexguide/prolist/final.sh + gcloud projects list | cut -d' ' -f1 | tail -n +2 >/var/plexguide/prolist/prolist.sh + + ### prevent bonehead from deleting the project that is active! + variablepull + sed -i -e "/${projectid}/d" /var/plexguide/prolist/prolist.sh + + ### project no exist check + pcheck=$(cat /var/plexguide/prolist/prolist.sh) + if [[ "$pcheck" == "" ]]; then noprojects; fi + + while read p; do + let "pnum++" + echo "$p" >"/var/plexguide/prolist/$pnum" + echo "[$pnum] $p" >>/var/plexguide/prolist/final.sh + done /var/plexguide/pgclone.project + echo + read -p '↘️ Acknowledge Info | Press [ENTER] ' typed /var/plexguide/prolist/final.sh + gcloud compute regions list | awk '{print $1}' | tail -n +2 >/var/plexguide/prolist/1.output + awk '{print substr($0, 1, length($0)-1)}' /var/plexguide/prolist/1.output >/var/plexguide/prolist/2.output + sort -u /var/plexguide/prolist/2.output >/var/plexguide/prolist/1.output + + while read p; do + let "pnum++" + echo "$p" >"/var/plexguide/prolist/$pnum" + echo "[$pnum] $p" >>/var/plexguide/prolist/final.sh + done /var/plexguide/project.ipregion + + gcloud compute zones list | grep $typed | head -n1 | awk '{print $2}' >/var/plexguide/project.ipregion + + echo + variablepull + gcloud compute addresses create pg-gce --region $ipregion --project $projectid + gcloud compute zones list | grep $typed | head -n1 | awk '{print $1}' >/var/plexguide/project.ipzone + gcloud compute addresses list | grep pg-gce | awk '{print $2}' >/var/plexguide/project.ipaddress + + echo + read -p '↘️ IP Address & Region Set | Press [ENTER] ' typed $1; fi +} + +### key variable pull +variablepull() { + + ### sets variables if they do not exist + variable /var/plexguide/project.account NOT-SET + variable /var/plexguide/project.ipaddress NOT-SET + variable /var/plexguide/project.ipregion NOT-SET + variable /var/plexguide/project.ipzone NOT-SET + variable /var/plexguide/project.processor 2 + variable /var/plexguide/project.ram 8 + variable /var/plexguide/project.nvme 1 + variable /var/plexguide/project.id NOT-SET + variable /var/plexguide/project.switch off + + ### variables being called + + #account=$(cat /var/plexguide/project.account) + account=$(gcloud config configurations list | tail -n 1 | awk '{print $3}') + if [[ "$account" != "" ]]; then echo $account >/var/plexguide/project.account; fi + + ipaddress=$(cat /var/plexguide/project.ipaddress) + ipregion=$(cat /var/plexguide/project.ipregion) + ipzone=$(cat /var/plexguide/project.ipzone) + nvmecount=$(cat /var/plexguide/project.nvme) + ramcount=$(cat /var/plexguide/project.ram) + processor=$(cat /var/plexguide/project.processor) + + # if user switches usernames, this turns on. turns of when user sets project again + switchcheck=$(cat /var/plexguide/project.switch) + if [[ "$switchcheck" != "on" ]]; then + projectid=$(gcloud config configurations list | tail -n 1 | awk '{print $4}') + if [[ "$projectid" != "" ]]; then echo $projectid >/var/plexguide/project.id; fi + fi + + serverstatus=serverstatus + sshstatus=notready +} + +servercheck() { + + gcedeployedcheck="NOT DEPLOYED" + minicheck=$(cat /var/plexguide/project.id) + if [[ "$minicheck" != "NOT-SET" ]]; then + + temp55=$(gcloud compute instances list | grep pg-gce) + if [[ "$temp55" != "" ]]; then gcedeployedcheck="DEPLOYED"; fi + + fi +} diff --git a/menu/gce/gcechecker.sh b/menu/gce/gcechecker.sh new file mode 100644 index 00000000..36782f2b --- /dev/null +++ b/menu/gce/gcechecker.sh @@ -0,0 +1,154 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +### NOTE THIS IS JUST A COPY - MAIN ONE SITE IN MAIN REPO - THIS IS JUST FOR INFO +#file1="/dev/nvme0n1" +#file2="/var/plexguide/gce.check" +gcheck=$(dnsdomainname | tail -c 10) + +file3="$(tail -n 1 /var/plexguide/gce.done)" +file3b="/var/plexguide/gce.done" + +if [[ "$file3" == "1" ]]; then + exit +elif [[ -e "$file3b" ]]; then + + ###if [ -e "$file1" ] && [ ! -e "$file2" ] && + if [ "$gcheck" == ".internal" ]; then + tee <<-EOF + + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + 📂 Google Cloud Feeder Edition SET! + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ⚡ Google Cloud Instance Detected! + + ⚠️ NOTE: Setting Up the NVME Drive For You! Please Wait! + ⚠️ NOTE: Please don't close it ! + + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + EOF + apt-get install mdadm --no-install-recommends -yqq 2>&1 >>/dev/null + export DEBIAN_FRONTEND=noninteractive + #Check for NVME + lsblk | grep nvme | awk '{print $1}' >/var/plexguide/nvme.log + lsblk | grep nvme | awk '{print $1}' >/var/plexguide/nvmeraid.log + sed -i 's/nvme0n//g' /var/plexguide/nvmeraid.log + #Check for NVME + nvme="$(tail -n1 /var/plexguide/nvmeraid.log)" + + if [[ "$nvme" == "2" ]]; then + mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/nvme0n1 /dev/nvme0n2 + mkfs.ext4 -F /dev/md0 + mkdir -p /mnt + mount /dev/md0 /mnt + sed -i '$ a\/dev/md0 /mnt ext4 discard,defaults,nobarrier,nofail 0 0' /etc/fstab + chown -cR 1000:1000 /mnt + tune2fs -m 0 /dev/md0 + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo "✅ PASSED ! NVME RAID0 Creator with 2 NVMEs as RAID0 - finish" + echo "✅ PASSED ! HDD Space now :" $(df -h /mnt/ --total --local -x tmpfs | grep 'total' | awk '{print $2}') + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo -e "1" >/var/plexguide/gce.done + sleep 2 + elif [[ "$nvme" == "3" ]]; then + mdadm --create /dev/md0 --level=0 --raid-devices=3 /dev/nvme0n1 /dev/nvme0n2 /dev/nvme0n3 + mkfs.ext4 -F /dev/md0 + mkdir -p /mnt + mount /dev/md0 /mnt + sed -i '$ a\/dev/md0 /mnt ext4 discard,defaults,nobarrier,nofail 0 0' /etc/fstab + chown -cR 1000:1000 /mnt + tune2fs -m 0 /dev/md0 + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo "✅ PASSED ! NVME RAID0 Creator with 3 NVMEs as RAID0 - finish" + echo "✅ PASSED ! HDD Space now :" $(df -h /mnt/ --total --local -x tmpfs | grep 'total' | awk '{print $2}') + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo -e "1" >/var/plexguide/gce.done + sleep 2 + elif [[ "$nvme" == "4" ]]; then + mdadm --create /dev/md0 --level=5 --raid-devices=4 /dev/nvme0n1 /dev/nvme0n2 /dev/nvme0n3 /dev/nvme0n4 + mkfs.ext4 -F /dev/md0 + mkdir -p /mnt + mount /dev/md0 /mnt + sed -i '$ a\/dev/md0 /mnt ext4 discard,defaults,nobarrier,nofail 0 0' /etc/fstab + chown -cR 1000:1000 /mnt + tune2fs -m 0 /dev/md0 + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo "✅ PASSED ! NVME RAID0 Creator with 4 NVMEs as RAID5 - finish" + echo "✅ PASSED ! HDD Space now :" "$(df -h /mnt/ --total --local -x tmpfs | grep 'total' | awk '{print $2}')" + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + sleep 2 + echo -e "1" >/var/plexguide/gce.done + elif [[ "$nvme" == "1" ]]; then + sleep 3 + mkfs.ext4 -F /dev/nvme0n1 1>/dev/null 2>&1 + mount -o discard,defaults,nobarrier /dev/nvme0n1 /mnt + chmod a+w /mnt 1>/dev/null 2>&1 + echo UUID=$(blkid | grep nvme0n1 | cut -f2 -d'"') /mnt ext4 discard,defaults,nobarrier,nofail 0 2 | tee -a /etc/fstab + + mkdir -p /nvme1 1>/dev/null 2>&1 + mkfs.ext4 -F /dev/nvme0n1 + mount -o discard,defaults,nobarrier /dev/nvme0n1 /nvme1 + chmod a+w /nvme1 1>/dev/null 2>&1 + echo UUID=$(blkid | grep nvme0n1 | cut -f2 -d'"') /nvme1 ext4 discard,defaults,nobarrier,nofail 0 2 | tee -a /etc/fstab + else + echo "nothing to do" + fi + + touch /var/plexguide/gce.check + rm -rf /var/plexguide/gce.failed 1>/dev/null 2>&1 + rm -rf /var/plexguide/gce.false 1>/dev/null 2>&1 + rm -rf /var/plexguide/nvme.log 1>/dev/null 2>&1 + rm -rf /var/plexguide/nvmeraid.log 1>/dev/null 2>&1 + + echo "feeder" >/var/plexguide/pg.server.deploy + cat /var/plexguide/pg.edition >/var/plexguide/pg.edition.stored + + tee <<-EOF + + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + 📂 GCE Harddrive Deployed! + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ⚡ Automatically Setting Google Feeder Edition (GCE) + + ⚠️ Please Wait! + + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + EOF + + sleep 6 + elif [ ! -e "$file1" ] && [ ! -e "$file2" ] && [ "$gcheck" == ".internal" ]; then + tee <<-EOF + + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + 📂 Google Cloud Feeder Edition Failed! + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ⚡ Google Cloud Instance Detected, but you Failed to setup an NVME + drive per the wiki! This mistake only occurs on manual GCE + deployments. Most likely you setup an SSD instead! The install will + continue, but this will fail! Wipe the box and setup again with an + NVME Drive! + + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + EOF + read -p 'Press [ENTER] to Continue! ' typed /dev/null 2>&1 + rm -rf /var/plexguide/gce.false 1>/dev/null 2>&1 + rm -rf /var/plexguide/nvme.log 1>/dev/null 2>&1 + rm -rf /var/plexguide/nvmeraid.log1 >/dev/null 2>&1 + else + touch /var/plexguide/gce.false + fi +else +echo "beware of this stupid lines" +fi diff --git a/menu/gce/place.holder b/menu/gce/place.holder new file mode 100644 index 00000000..11df8e2e --- /dev/null +++ b/menu/gce/place.holder @@ -0,0 +1 @@ +hi :D diff --git a/menu/hcloud/hcloud.sh b/menu/hcloud/hcloud.sh new file mode 100644 index 00000000..ea304ed8 --- /dev/null +++ b/menu/hcloud/hcloud.sh @@ -0,0 +1,284 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +source /opt/plexguide/menu/functions/install.sh + +installtest(){ +file="/bin/hcloud" + if [[ -f $file ]]; then + tee <<-EOF +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Hetzner's Cloud install check +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + else + version="$(curl -s https://api.github.com/repos/hetznercloud/cli/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')" + wget -P /tmp "https://github.com/hetznercloud/cli/releases/download/$version/hcloud-linux-amd64-$version.tar.gz" + tar -xvf "/tmp/hcloud-linux-amd64-$version.tar.gz" -C /tmp + mv "/tmp/hcloud-linux-amd64-$version/bin/hcloud" /bin/ + rm -rf /tmp/hcloud-linux-amd64-$version.tar.gz + rm -rf /tmp/hcloud-linux-amd64-$version; fi +} + +testhcloud(){ +test=$(hcloud server list) +if [ "$test" == "" ]; then + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ WARNING! - You Must Input an API Token from Hetzner First! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +[ 1 } Activate a Hetzner Cloud Account +[ 2 ] Create a Project +[ 3 ] Click Access (left hand side) +[ 4 ] click API Tokens +[ 5 ] Create a Token and Save It (and paste below here) + +* Not Ready? Just type something & Press [ENTER] +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + hcloud context create plexguide + + test=$(hcloud server list) + if [ "$test" == "" ]; then + hcloud context delete plexguide + exit + fi + +fi +} +#-------------------------------------------------------------------- +main(){ +# Start Process +tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Hetzner's Cloud Generator +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +[ 1 ] Deploy a New Server +[ 2 ] Destory a Server + +[ A ] List Server Info +[ B ] Display Inital Server Passwords + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +[Z] Exit +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p '↘️ Type Number | Press [ENTER]: ' typed /opt/appdata/plexguide/server.info + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ New Server Information - [$name] +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + cat /opt/appdata/plexguide/server.info + + # Creates Log + touch /opt/appdata/plexguide/server.store + cat /opt/appdata/plexguide/server.info >>/opt/appdata/plexguide/server.store + echo "Server Name: $name" >>/opt/appdata/plexguide/server.store + echo "" >>/opt/appdata/plexguide/server.store + + # Variable Info + serverip=$(cat /opt/appdata/plexguide/server.info | tail -n +3 | head -n 1 | cut -d " " -f2-) + initialpw=$(cat /opt/appdata/plexguide/server.info | tail -n +4 | cut -d " " -f3-) + + tee <<-EOF + +⚠️ To Reach Your Server >>> Exit PTS >>> TYPE: pg-$name ⚠️ + +✅️ [IMPORTANT NOTE] + +Wait for one minute for the server to boot! Typing pg-$name will +display your initial password! Also can manually by typing: + +Command: ssh root@$serverip +FIRST TIME LOGIN - Initial Password: $initialpw + +EOF + read -p 'Press [ENTER] to Exit ' fill >/bin/pg-$name + echo "echo ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" >/bin/pg-$name + echo "echo '↘️ Server - $name | Initial Password $initialpw'" >>/bin/pg-$name + echo "echo ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" >>/bin/pg-$name + echo "echo ''" >>/bin/pg-$name + echo "ssh root@$serverip" >>/bin/pg-$name + chmod -R 777 /bin/pg-$name + chown -R 1000:1000 /bin/pg-$name +} + +#------------------------------------ + +list(){ + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Hetzner Server Cloud List +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Server Name +━━━━━━━━━━━ + +EOF + hcloud server list | tail -n +2 | cut -d " " -f2- | cut -d " " -f2- | cut -d " " -f2- + echo + read -p 'Press [ENTER] to Continue! ' typed ") + if [ "$next" == "0" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ Server: $destroy - Does Not Exist! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p 'Press [ENTER] to Continue! ' typed old) +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + touch /opt/appdata/plexguide/server.store + tac -r /opt/appdata/plexguide/server.store + echo "" & + echo "" + read -p 'Press [ENTER] to Continue! ' corn /var/plexguide/logs/pg.log && bash /opt/plexguide/menu/log/log.sh" + + ############ GCrypt + - name: GCrypt Check + stat: + path: '{{path.stdout}}/gcrypt' + register: gcrypt + + - name: Create GCrypt Folders + file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000' + with_items: + - '{{path.stdout}}/gcrypt/tv' + - '{{path.stdout}}/gcrypt/movies' + - '{{path.stdout}}/gcrypt/music' + - '{{path.stdout}}/gcrypt/ebooks' + - '{{path.stdout}}/gcrypt/abooks' + when: gcrypt.stat.exists == False + ignore_errors: yes + ############ TCrypt + - name: TCrypt Check + stat: + path: '{{path.stdout}}/tcrypt' + register: tcrypt + + - name: Create TCrypt Folders + file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000' + with_items: + - '{{path.stdout}}/tcrypt/tv' + - '{{path.stdout}}/tcrypt/movies' + - '{{path.stdout}}/tcrypt/music' + - '{{path.stdout}}/tcrypt/ebooks' + - '{{path.stdout}}/tcrypt/abooks' + when: tcrypt.stat.exists == False + ignore_errors: yes + + ############ Personal Containers Folder + - name: MyContainers Check + stat: + path: /opt/mycontainers + register: mycontainers + + - name: Create MyContainers Folders + file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000' + with_items: + - /opt/mycontainers + when: mycontainers.stat.exists == False + ignore_errors: yes + + ############ PGUnion + - name: Union Check + stat: + path: '{{path.stdout}}/unionfs' + register: pgunion + + - name: Create Union Folders + file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000' + with_items: + - '{{path.stdout}}/unionfs' + when: pgunion.stat.exists == False + ignore_errors: yes + + ############ TMP + - name: TMP Check + stat: + path: '{{path.stdout}}/tmp' + register: tmp + + - name: Create Temp Folder + file: 'path={{item}} state=directory' + with_items: + - '{{path.stdout}}/tmp' + when: tmp.stat.exists == False + ignore_errors: yes + + ############ GDrive + - name: GDrive Check + stat: + path: '{{path.stdout}}/gdrive' + register: gdrive + + - name: Create GDrive Folders + file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000' + with_items: + - '{{path.stdout}}/gdrive' + - '{{path.stdout}}/gdrive/tv' + - '{{path.stdout}}/gdrive/movies' + - '{{path.stdout}}/gdrive/music' + - '{{path.stdout}}/gdrive/ebooks' + - '{{path.stdout}}/gdrive/abooks' + when: gdrive.stat.exists == False + ignore_errors: yes + ############ TCrypt + - name: Create TCrypt Folders + file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000' + with_items: + - '{{path.stdout}}/tcrypt' + - '{{path.stdout}}/tcrypt/tv' + - '{{path.stdout}}/tcrypt/movies' + - '{{path.stdout}}/tcrypt/music' + - '{{path.stdout}}/tcrypt/ebooks' + - '{{path.stdout}}/tcrypt/abooks' + when: gdrive.stat.exists == False + ignore_errors: yes + + ############ TDrive + - name: TDrive Check + stat: + path: '{{path.stdout}}/tdrive' + register: tdrive + + - name: Create TDrive Folders + file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000' + with_items: + - '{{path.stdout}}/tdrive' + - '{{path.stdout}}/tdrive/tv' + - '{{path.stdout}}/tdrive/movies' + - '{{path.stdout}}/tdrive/music' + - '{{path.stdout}}/tdrive/ebooks' + - '{{path.stdout}}/tdrive/abooks' + when: tdrive.stat.exists == False + ignore_errors: yes + + ############ Encrypt + - name: Encrypt Check + stat: + path: '{{path.stdout}}/encrypt' + register: encrypt + + - name: Create Encrypt Folders + file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000' + with_items: + - '{{path.stdout}}/encrypt/tv' + - '{{path.stdout}}/encrypt/movies' + - '{{path.stdout}}/encrypt/music' + - '{{path.stdout}}/encrypt/ebooks' + - '{{path.stdout}}/encrypt/abooks' + when: encrypt.stat.exists == False + ignore_errors: yes + + - name: Create Basic Directories + file: 'path={{item}} state=directory mode=0775 owner=1000 group=1000 recurse=true' + with_items: + - '/opt/appdata/plexguide' + - '/opt/appdata/plexguide/emergency' + - '/opt/communityapps' + - '/opt/coreapps' + - '/var/plexguide' + - '{{path.stdout}}/move' + - '/var/plexguide/logs' + - '/opt/appdata/plexguide/keys/unprocessed' + - '/opt/appdata/plexguide/keys/processed' + - '/opt/appdata/plexguide/keys/badjson' + - '{{path.stdout}}/pgops' + - '{{path.stdout}}/downloads' + - '{{path.stdout}}/nzb' + - '{{path.stdout}}/torrent' + - '{{path.stdout}}/torrent/watch' + - '{{path.stdout}}/move' + - '/opt/var' + ignore_errors: yes diff --git a/menu/interface/cloudselect.sh b/menu/interface/cloudselect.sh new file mode 100644 index 00000000..ea8ef87d --- /dev/null +++ b/menu/interface/cloudselect.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +# Menu Interface +question1(){ +tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +📂 Cloud Service Installer +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +[ 1 ] Cloud Instance: Google [ Blitz ~ GCE Edition ] +[ 2 ] Cloud Instance: Hetzner + +[ Z ] - Exit + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + + read -p '↘️ Type Number | Press [ENTER]: ' typed /var/plexguide/type.choice && bash /opt/plexguide/menu/pgcloner/blitzgce.sh ;; + 2) bash /opt/plexguide/menu/hcloud/hcloud.sh ;; + z) exit ;; + Z) exit ;; + *) question1 ;; + esac +} +##### layout build + +question1 diff --git a/menu/interface/ending.sh b/menu/interface/ending.sh new file mode 100644 index 00000000..de6dfef6 --- /dev/null +++ b/menu/interface/ending.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# +# Title: pts (Reference Title File) +# Author(s): Admin9705 - FlickerRate +# URL: https://pts.com - http://github.pts.com +# GNU: General Public License v3.0 +################################################################################ +source /opt/plexguide/menu/functions/install.sh +emergency + +# +clear +echo "" + +cat <<"EOF" +┌─────────────────────────────────────┐ +│ -== Team PTS ==- │ +│ ————————————————————————————————————│ +│ Restart PTS: pts │ +│ Update PTS: ptsupdate │ +│ View the PTS Logs: blitz │ +│ Download Your PTS Fork: pgfork │ +│ │ +│ ————————————————————————————————————│ +│ Thanks For Being Part of the Team │ +│ │ +│ Thanks to: │ +│ │ +│ Davaz, Deiteq, FlickerRate, │ +│ ClownFused, MrDoob, Sub7Seven, │ +│ TimeKills, The_Creator, Desimaniac, │ +│ l3uddz, RXWatcher,Calmcacil, Porkie │ +└─────────────────────────────────────┘ + +EOF + +if [[ ! -e "/bin/pts" ]]; then + cp /opt/plexguide/menu/alias/templates/pts /bin +fi + +chown 1000:1000 /bin/pts &>/dev/null & +chmod 0755 /bin/pts &>/dev/null & diff --git a/menu/interface/gce/choice.yml b/menu/interface/gce/choice.yml new file mode 100644 index 00000000..3f3270d7 --- /dev/null +++ b/menu/interface/gce/choice.yml @@ -0,0 +1,44 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +- name: Register Project + shell: 'cat /var/plexguide/project.final' + register: project + +- name: Register Account + shell: 'cat /var/plexguide/project.account' + register: account + +- name: Register Processor Count + shell: 'cat /var/plexguide/project.processor' + register: processor + +- name: Register IP region + shell: 'cat /var/plexguide/project.ipregion' + register: ipregion + +- name: Register IP region + shell: 'cat /var/plexguide/project.ipaddress' + register: ipaddress + +- name: Register Deployment Status + shell: 'cat /var/plexguide/gce.deployed.status' + register: deployment + +- name: 'Key Menu Facts' + set_fact: + head1: "\nPGBlitz GCE Deployment Interface - Make a Selection" + head2: '' + info2: "\n2. Log-In to Your Account: {{account.stdout}}" + info3: "\n3. Build a New Project" + info4: "\n4. Establish Project ID : [{{project.stdout}}]" + info5: "\n5. Set Processor Count : [{{processor.stdout}}]" + info6: "\n6. Set IP Region / Server: [{{ipaddress.stdout}}] - [{{ipregion.stdout}}]" + info7: "\n7. Deploy PG GCE Server : [{{deployment.stdout}}]" + info8: "\n8. SSH Securely into your GCE Feeder Box" + info9: "\n9. Destroy Server" diff --git a/menu/interface/gce/file.sh b/menu/interface/gce/file.sh new file mode 100644 index 00000000..29f67e1d --- /dev/null +++ b/menu/interface/gce/file.sh @@ -0,0 +1,826 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +menu=$(cat /var/plexguide/final.choice) + +if [ "$menu" == "2" ]; then + ########## Server Must Not Be Deployed - START + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Checking Existing Deployment" + echo "--------------------------------------------------------" + echo "" + inslist=$(gcloud compute instances list | grep pg-gce) + if [ "$inslist" != "" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Failed! Must Delete Current Server!" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Prevents Conflicts with Changes!" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + exit + fi + ########## Server Must Not Be Deployed - END + + gcloud auth login + echo "[NOT SET]" >/var/plexguide/project.final +fi + +if [ "$menu" == "3" ]; then + ############################## BILLING CHECKS - START + billing=$(gcloud beta billing accounts list | grep "\") + if [ "$billing" == "" ]; then + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Google Cloud Billing is Not Turned On!" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: You Must Turn On Your Billing! PG is checking for the word >>> True" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + exit + fi + ############################## BILLING CHECKS - END + + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Creating Project ID" + echo "--------------------------------------------------------" + echo "" + date=$(date +%m%d) + rand=$(echo $((1 + RANDOM + RANDOM + RANDOM + RANDOM + RANDOM + RANDOM + RANDOM + RANDOM + RANDOM + RANDOM))) + projectid="pg-$date-$rand" + gcloud projects create $projectid + sleep 1 + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Linking Project to the Billing Account" + echo "--------------------------------------------------------" + echo "" + + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Created - Project $projectid" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: If using this project, ENSURE to SET this project!" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " +fi + +if [ "$menu" == "4" ]; then + ############################## BILLING CHECKS - START + billing=$(gcloud beta billing accounts list | grep "\") + if [ "$billing" == "" ]; then + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Google Cloud Billing is Not Turned On!" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: You Must Turn On Your Billing! PG is checking for the word >>> True" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + exit + fi + ############################## BILLING CHECKS - END + ########## Server Must Not Be Deployed - START + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Checking Existing Deployment" + echo "--------------------------------------------------------" + echo "" + + inslist=$(gcloud compute instances list | grep pg-gce) + if [ "$inslist" != "" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Failed! Must Delete Current Server!" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Prevents Conflicts with Changes!" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + exit + fi + ########## Server Must Not Be Deployed - END + + gcloud projects list && gcloud projects list >/var/plexguide/projects.list + echo "" + echo "------------------------------------------------------------------------------" + echo "SYSTEM MESSAGE: GCloud Project Interface" + echo "------------------------------------------------------------------------------" + echo "" + echo "NOTE: If no project is listed, please visit https://project.pgblitz.com and" + echo " review the wiki on how to build a project! Without one, this will fail!" + echo "" + read -p "Set or Change the Project ID (y/n)? " -n 1 -r + echo # move cursor to a new line + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: [Y] Key was NOT Selected - Exiting!" + echo "--------------------------------------------------------" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + exit 1 + else + echo "" # leave if statement and continue. + fi + + typed=nullstart + while [ "$typed" != "$list" ]; do + echo "------------------------------------------------------------------------------" + echo "SYSTEM MESSAGE: Project Selection Interface" + echo "------------------------------------------------------------------------------" + echo "" + cat /var/plexguide/projects.list | cut -d' ' -f1 | tail -n +2 + cat /var/plexguide/projects.list | cut -d' ' -f1 | tail -n +2 >/var/plexguide/project.cut + echo "" + echo "NOTE: Type the Name of the Project you want to utilize!" + read -p 'Type the Name of the Project to Utlize & Press [ENTER]: ' typed + list=$(cat /var/plexguide/project.cut | grep $typed) + echo "" + + if [ "$typed" != "$list" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Failed! Please type the exact name!" + echo "--------------------------------------------------------" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + else + echo "----------------------------------------------" + echo "SYSTEM MESSAGE: Passed the Validation Checks!" + echo "----------------------------------------------" + echo "" + echo "Set Project is: $list" + gcloud config set project $typed + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + echo "" + echo "----------------------------------------------" + echo "SYSTEM MESSAGE: Enabling Your API!" + echo "----------------------------------------------" + echo "" + echo "NOTE: Enabling Compute API - Please Standby!" + gcloud services enable compute.googleapis.com + echo "" + echo "NOTE: Enabling GDrive API for Project - $typed" + gcloud services enable drive.googleapis.com --project $typed + echo "" + sleep 1 + echo "----------------------------------------------" + echo "SYSTEM MESSAGE: Finished!" + echo "----------------------------------------------" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + fi + done + + echo $typed >/var/plexguide/project.final + echo 'INFO - Selected: Exiting Application Suite Interface' >/var/plexguide/logs/pg.log && bash /opt/plexguide/menu/log/log.sh + exit +fi + +if [ "$menu" == "5" ]; then + ############################## BILLING CHECKS - START + billing=$(gcloud beta billing accounts list | grep "\") + if [ "$billing" == "" ]; then + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Google Cloud Billing is Not Turned On!" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: You Must Turn On Your Billing! PG is checking for the word >>> True" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + exit + fi + ############################## BILLING CHECKS - END + ############################## PROJECT BILLING CHECKS - START + project=$(cat /var/plexguide/project.final) + projectlink=$(gcloud beta billing accounts list | grep "\" | awk '{ print $1 }') + billingcheck=$(gcloud beta billing projects link $project --billing-account $projectlink | grep "billingEnabled: true") + if [ "$billingcheck" == "" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Billing Failed - Turn It On Or Check" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Common Billing Issue for GCE Credits" + echo "NOTE: Cannot Continue with GCE" + echo "" + echo "1. Too Many Projects - Delete Unused Ones!" + echo "2. Ran Out of Credits & Must Turn On (Warning - Expensive)" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + exit + fi + ############################## PROJECT BILLING CHECKS - END + + ########## Server Must Not Be Deployed - START + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Checking Existing Deployment" + echo "--------------------------------------------------------" + echo "" + + inslist=$(gcloud compute instances list | grep pg-gce) + if [ "$inslist" != "" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Failed! Must Delete Current Server!" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Prevents Conflicts with Changes!" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + exit + fi + ########## Server Must Not Be Deployed - END + + ### Part 1 + pcount=$(cat /var/plexguide/project.processor) + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Current Processor Count Interface" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Processor Count: [$pcount]" + echo "" + read -p "Set or Change the Processor Count (y/n)? " -n 1 -r + echo # move cursor to a new line + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: [Y] Key was NOT Selected - Exiting!" + echo "--------------------------------------------------------" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + exit 1 + else + echo "" + fi + + ### part 2 + typed=nullstart + prange="2 4 6" + tcheck="" + break=off + while [ "$break" == "off" ]; do + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Processor Count Interface" + echo "--------------------------------------------------------" + echo "" + echo "Ideal Processor Usage = 4" + echo "Set Your Processor Count | Range 2, 4 or 6" + echo "" + echo "NOTE: More Processors = Faster Credit Drain" + echo "" + read -p 'Type a Number 2, 4 or 6 | PRESS [ENTER]: ' typed + tcheck=$(echo $prange | grep $typed) + echo "" + + if [ "$tcheck" == "" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Failed! Type a Number from 2, 4, or 6" + echo "--------------------------------------------------------" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + echo "" + else + echo "----------------------------------------------" + echo "SYSTEM MESSAGE: Passed! Process Count $typed Set" + echo "----------------------------------------------" + echo "" + echo $typed >/var/plexguide/project.processor + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + break=on + fi + done + +fi + +if [ "$menu" == "6" ]; then + ############################## BILLING CHECKS - START + billing=$(gcloud beta billing accounts list | grep "\") + if [ "$billing" == "" ]; then + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Google Cloud Billing is Not Turned On!" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: You Must Turn On Your Billing! PG is checking for the word >>> True" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + exit + fi + ############################## BILLING CHECKS - END + ############################## PROJECT BILLING CHECKS - START + project=$(cat /var/plexguide/project.final) + projectlink=$(gcloud beta billing accounts list | grep "\" | awk '{ print $1 }') + billingcheck=$(gcloud beta billing projects link $project --billing-account $projectlink | grep "billingEnabled: true") + if [ "$billingcheck" == "" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Billing Failed - Turn It On Or Check" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Common Billing Issue for GCE Credits" + echo "NOTE: Cannot Continue with GCE" + echo "" + echo "1. Too Many Projects - Delete Unused Ones!" + echo "2. Ran Out of Credits & Must Turn On (Warning - Expensive)" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + exit + fi + ############################## PROJECT BILLING CHECKS - END + + ########## Server Must Not Be Deployed - START + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Checking Existing Deployment" + echo "--------------------------------------------------------" + echo "" + + inslist=$(gcloud compute instances list | grep pg-gce) + if [ "$inslist" != "" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Failed! Must Delete Current Server!" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Prevents Conflicts with Changes!" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + exit + fi + ########## Server Must Not Be Deployed - END + + gcloud compute regions list | awk '{print $1}' | tail -n +2 >/tmp/regions.list + num=0 + echo " " >/tmp/regions.print + + while read p; do + echo -n $p >>/tmp/regions.print + echo -n " " >>/tmp/regions.print + + num=$((num + 1)) + if [ $num == 5 ]; then + num=0 + echo " " >>/tmp/regions.print + fi + done /var/plexguide/project.region + + typed=nullstart + prange=$(cat /tmp/regions.print) + tcheck="" + break=off + while [ "$break" == "off" ]; do + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Google Cloud IP Regions List" + echo "--------------------------------------------------------" + cat /tmp/regions.print + echo "" && echo "" + read -p 'Type the Name of an IP Region | PRESS [ENTER]: ' typed + echo "" + tcheck=$(echo $prange | grep $typed) + + if [ "$tcheck" == "" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Failed! Type an IP Region Name" + echo "--------------------------------------------------------" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + echo "" + else + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Passed! IP Region $typed Set" + echo "--------------------------------------------------------" + echo "" + echo $typed >/var/plexguide/project.ipregion + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + echo "" + break=on + fi + done + + ############## IP Address - Part 2 + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Deleting Any Prior GCE IP Addresses" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Please Standby" + + break=off + while [ "$break" == off ]; do + + gcloud compute addresses list | grep pg-gce | tail -n +1 >/tmp/ip.delete + ipdelete=$(cat /tmp/ip.delete) + if [ "$ipdelete" != "" ]; then + regdelete=$(gcloud compute addresses list | grep pg-gce | head -n +1 | awk '{print $2}') + addprint=$(gcloud compute addresses list | grep pg-gce | head -n +1 | awk '{print $3}') + gcloud compute addresses delete pg-gce --region=$regdelete --quiet + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Deleted $regdelete - $addprint" + echo "--------------------------------------------------------" + else + break=on + fi + done + + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Creating New IP Address" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Please Standby" + echo "" + projectname=$(cat /var/plexguide/project.final) + region=$(cat /var/plexguide/project.ipregion) + gcloud compute addresses create pg-gce --region $region --project $projectname + gcloud compute addresses list | grep pg-gce | awk '{print $3}' >/var/plexguide/project.ipaddress + ipaddress=$(cat /var/plexguide/project.ipaddress) + sleep 1.5 + echo "" & + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Passed! GCE IP: $ipaddress" + echo "--------------------------------------------------------" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + + ########## Server Must Not Be Deployed - START + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Checking Existing Deployment" + echo "--------------------------------------------------------" + echo "" + + inslist=$(gcloud compute instances list | grep pg-gce) + if [ "$inslist" != "" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Failed! Must Delete Current Server!" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Prevents Conflicts with Changes!" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + exit + fi + ########## Server Must Not Be Deployed - END + + ### Part 1 + ipregion=$(cat /var/plexguide/project.ipregion) + gcloud compute zones list | awk '{print $1}' | tail -n +2 | grep $ipregion >/tmp/zones.list + num=0 + echo " " >/tmp/zones.print + + while read p; do + echo -n $p >>/tmp/zones.print + echo -n " " >>/tmp/zones.print + + num=$((num + 1)) + if [ $num == 4 ]; then + num=0 + echo " " >>/tmp/zones.print + fi + done /var/plexguide/project.location + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + break=on + fi + done + +fi + +################################################################################ DEPLOY END + +if [ "$menu" == "7" ]; then + ############################## BILLING CHECKS - START + billing=$(gcloud beta billing accounts list | grep "\") + if [ "$billing" == "" ]; then + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Google Cloud Billing is Not Turned On!" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: You Must Turn On Your Billing! PG is checking for the word >>> True" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + exit + fi + ############################## BILLING CHECKS - END + ############################## PROJECT BILLING CHECKS - START + project=$(cat /var/plexguide/project.final) + projectlink=$(gcloud beta billing accounts list | grep "\" | awk '{ print $1 }') + billingcheck=$(gcloud beta billing projects link $project --billing-account $projectlink | grep "billingEnabled: true") + if [ "$billingcheck" == "" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Billing Failed - Turn It On Or Check" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Common Billing Issue for GCE Credits" + echo "NOTE: Cannot Continue with GCE" + echo "" + echo "1. Too Many Projects - Delete Unused Ones!" + echo "2. Ran Out of Credits & Must Turn On (Warning - Expensive)" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + exit + fi + ############################## PROJECT BILLING CHECKS - END + + ########## Server Must Not Be Deployed - START + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Checking Existing Deployment" + echo "--------------------------------------------------------" + echo "" + ########## + project=$(cat /var/plexguide/project.final) + ipaddress=$(cat /var/plexguide/project.ipaddress) + location=$(cat /var/plexguide/project.location) + region=$(cat /var/plexguide/project.ipregion) + cpu=$(cat /var/plexguide/project.processor) + + inslist=$(gcloud compute instances list | grep pg-gce) + if [ "$inslist" != "" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Failed! Must Delete Current Server!" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Prevents Conflicts with Changes!" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + exit + fi + ########## Server Must Not Be Deployed - END + + ############ FireWall + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Checking PG GCE Firewall Rules" + echo "--------------------------------------------------------" + echo "" + + inslist=$(gcloud compute firewall-rules list | grep plexguide) + if [ "$inslist" == "" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: FireWall Rules Do Not Exist!" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Building Firewall Rules! Please Wait" + echo "" + gcloud compute firewall-rules create plexguide --allow all + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + fi + + ########### Deployment + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Building PG GCE Template" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Please Standby!" + echo "" + + blueprint=$(gcloud compute instance-templates list | grep pg-gce-blueprint) + if [ "$blueprint" != "" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Deleting Old Templates" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Please Standby!" + echo "" + gcloud compute instance-templates delete pg-gce-blueprint --quiet + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Building New Template" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Please Standby!" + echo "" + fi + + gcloud compute instance-templates create pg-gce-blueprint \ + --custom-cpu $cpu --custom-memory 8GB \ + --image-family ubuntu-1804-lts --image-project ubuntu-os-cloud \ + --boot-disk-auto-delete --boot-disk-size 100GB \ + --local-ssd interface=nvme + + sleep .5 + + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Deploying PG GCE Server" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Please Standby!" + echo "" + gcloud compute instances create pg-gce --source-instance-template pg-gce-blueprint --zone $location + echo "" + + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Assigning the IP Address to the GCE" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Please Standby" + echo "" + + gcloud compute instances delete-access-config pg-gce --access-config-name "external-nat" --zone $location --quiet + echo "" + gcloud compute instances add-access-config pg-gce --access-config-name "external-nat" --address $ipaddress + echo "" + + ######## Final Checks + finalchecks=$(gcloud compute instances list | grep pg-gce) + if [ "finalchecks" != "" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Deployment Complete" + echo "--------------------------------------------------------" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + touch /var/plexguide/gce.deployed + else + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Deployment Failed" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Unable to detect a running PG-GCE Server!" + echo "Please check your configs, billings, and permissions" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + fi +fi + +################################################################################ DEPLOY END +if [ "$menu" == "8" ]; then + ############################## BILLING CHECKS - START + billing=$(gcloud beta billing accounts list | grep "\") + if [ "$billing" == "" ]; then + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Google Cloud Billing is Not Turned On!" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: You Must Turn On Your Billing! PG is checking for the word >>> True" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + exit + fi + ############################## BILLING CHECKS - END + ############################## PROJECT BILLING CHECKS - START + project=$(cat /var/plexguide/project.final) + projectlink=$(gcloud beta billing accounts list | grep "\" | awk '{ print $1 }') + billingcheck=$(gcloud beta billing projects link $project --billing-account $projectlink | grep "billingEnabled: true") + if [ "$billingcheck" == "" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Billing Failed - Turn It On Or Check" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Common Billing Issue for GCE Credits" + echo "NOTE: Cannot Continue with GCE" + echo "" + echo "1. Too Many Projects - Delete Unused Ones!" + echo "2. Ran Out of Credits & Must Turn On (Warning - Expensive)" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + exit + fi + ############################## PROJECT BILLING CHECKS - END + + ######## Final Message + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Securely Entering Your GCE Feeder Box" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: If asked to create keys, remember the passcodes!" + echo "1. To exit the GCE, type exit!" + echo "2. Install PG on your GCE and Select Feeder Edition!" + echo "3. Problems? Try rm -rf /root/.ssh/google_compute_engine" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + echo "" + ipproject=$(cat /var/plexguide/project.location) + gcloud compute ssh pg-gce --zone "$ipproject" + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Welcome Back To Your Main Server" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Sanity Check - You Exited Your GCE Feeder Box" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " +fi + +if [ "$menu" == "9" ]; then + ############################## BILLING CHECKS - START + billing=$(gcloud beta billing accounts list | grep "\") + if [ "$billing" == "" ]; then + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Google Cloud Billing is Not Turned On!" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: You Must Turn On Your Billing! PG is checking for the word >>> True" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + exit + fi + ############################## BILLING CHECKS - END + ############################## PROJECT BILLING CHECKS - START + project=$(cat /var/plexguide/project.final) + projectlink=$(gcloud beta billing accounts list | grep "\" | awk '{ print $1 }') + billingcheck=$(gcloud beta billing projects link $project --billing-account $projectlink | grep "billingEnabled: true") + if [ "$billingcheck" == "" ]; then + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Billing Failed - Turn It On Or Check" + echo "--------------------------------------------------------" + echo "" + echo "NOTE: Common Billing Issue for GCE Credits" + echo "NOTE: Cannot Continue with GCE" + echo "" + echo "1. Too Many Projects - Delete Unused Ones!" + echo "2. Ran Out of Credits & Must Turn On (Warning - Expensive)" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + exit + fi + ############################## PROJECT BILLING CHECKS - END + + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: Destroying GCE Server" + echo "--------------------------------------------------------" + echo "" + location=$(cat /var/plexguide/project.location) + echo "NOTE: Please Standby" + echo "" + gcloud compute instances delete pg-gce --quiet --zone "$location" + rm -rf /root/.ssh/google_compute_engine 1>/dev/null 2>&1 + rm -rf /var/plexguide/gce.deployed 1>/dev/null 2>&1 + echo "" + echo "--------------------------------------------------------" + echo "SYSTEM MESSAGE: PG GCE Server Destroyed!" + echo "--------------------------------------------------------" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " +fi diff --git a/menu/interface/gce/var.sh b/menu/interface/gce/var.sh new file mode 100644 index 00000000..088c171c --- /dev/null +++ b/menu/interface/gce/var.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +echo 9 >/var/plexguide/menu.number + +gcloud info | grep Account: | cut -c 10- >/var/plexguide/project.account + +file="/var/plexguide/project.final" +if [ ! -e "$file" ]; then + echo "[NOT SET]" >/var/plexguide/project.final +fi + +file="/var/plexguide/project.processor" +if [ ! -e "$file" ]; then + echo "NOT-SET" >/var/plexguide/project.processor +fi + +file="/var/plexguide/project.location" +if [ ! -e "$file" ]; then + echo "NOT-SET" >/var/plexguide/project.location +fi + +file="/var/plexguide/project.ipregion" +if [ ! -e "$file" ]; then + echo "NOT-SET" >/var/plexguide/project.ipregion +fi + +file="/var/plexguide/project.ipaddress" +if [ ! -e "$file" ]; then + echo "IP NOT-SET" >/var/plexguide/project.ipaddress +fi + +file="/var/plexguide/gce.deployed" +if [ -e "$file" ]; then + echo "Server Deployed" >/var/plexguide/gce.deployed.status +else + echo "Not Deployed" >/var/plexguide/gce.deployed.status +fi diff --git a/menu/interface/install/scripts/ansible.sh b/menu/interface/install/scripts/ansible.sh new file mode 100644 index 00000000..7cb91e5f --- /dev/null +++ b/menu/interface/install/scripts/ansible.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +######################################################## Declare Variables +sname="Ansible - Install" +pg_ansible=$(cat /var/plexguide/pg.ansible) +pg_ansible_stored=$(cat /var/plexguide/pg.ansible.stored) +######################################################## START: PG Log +sudo echo "INFO - Start of Script: $sname" >/var/plexguide/logs/pg.log +sudo bash /opt/plexguide/menu/log/log.sh +######################################################## START: Main Script +if [ "$pg_ansible" == "$pg_ansible_stored" ]; then + echo "" 1>/dev/null 2>&1 +else + echo "Installing / Upgrading Ansible" >/var/plexguide/message.phase + bash /opt/plexguide/menu/interface/install/scripts/message.sh + echo "" + #sudo apt-get remove ansible -y + #sudo apt-add-repository --remove ppa:ansible/ansible -y && sudo add-apt-repository ppa:ansible/ansible-2.5 -y && sudo apt install ansible -y + #apt-get update -y + #apt-get install ansible 2.5.5 -y + #apt-mark hold ansible + #yes | apt-get update + python -m pip install --disable-pip-version-check --upgrade --force-reinstall ansible==${1-2.5.11} + ############# FOR ANSIBLE + mkdir -p /etc/ansible/inventories/ 1>/dev/null 2>&1 + echo "[local]" >/etc/ansible/inventories/local + echo "127.0.0.1 ansible_connection=local" >>/etc/ansible/inventories/local + + ### Reference: https://docs.ansible.com/ansible/2.4/intro_configuration.html + echo "[defaults]" >/etc/ansible/ansible.cfg + echo "deprecation_warnings=False" >>/etc/ansible/ansible.cfg + echo "command_warnings = False" >>/etc/ansible/ansible.cfg + echo "callback_whitelist = profile_tasks" >>/etc/ansible/ansible.cfg + echo "inventory = /etc/ansible/inventories/local" >>/etc/ansible/ansible.cfg + + ### Disabling cows for people that have cowsay installed + echo "nocows = 1" >>/etc/ansible/ansible.cfg + + cat /var/plexguide/pg.ansible >/var/plexguide/pg.ansible.stored +fi +######################################################## END: Main Script +# +# +######################################################## END: PG Log +sudo echo "INFO - END of Script: $sname" >/var/plexguide/logs/pg.log +sudo bash /opt/plexguide/menu/log/log.sh diff --git a/menu/interface/install/scripts/edition.sh b/menu/interface/install/scripts/edition.sh new file mode 100644 index 00000000..a50cfddc --- /dev/null +++ b/menu/interface/install/scripts/edition.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +######################################################## Declare Variables +sname="PG Installer: Set PG Edition" +pg_edition=$(cat /var/plexguide/pg.edition) +pg_edition_stored=$(cat /var/plexguide/pg.edition.stored) +######################################################## START: PG Log +sudo echo "INFO - Start of Script: $sname" >/var/plexguide/logs/pg.log +sudo bash /opt/plexguide/menu/log/log.sh +######################################################## START: Main Script +if [ "$pg_edition" == "$pg_edition_stored" ]; then + echo "" 1>/dev/null 2>&1 +else + bash /opt/plexguide/menu/editions/editions.sh +fi +######################################################## END: Main Script +# +# +######################################################## END: PG Log +sudo echo "INFO - END of Script: $sname" >/var/plexguide/logs/pg.log +sudo bash /opt/plexguide/menu/log/log.sh diff --git a/menu/interface/install/scripts/message.sh b/menu/interface/install/scripts/message.sh new file mode 100644 index 00000000..84c38f51 --- /dev/null +++ b/menu/interface/install/scripts/message.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +message=$(cat /var/plexguide/message.phase) + +echo "" +echo "----------------------------------------------------" +echo "PLEASE STANDBY" +echo "System Message: $message" +echo "----------------------------------------------------" +sleep 2 diff --git a/menu/interface/serverid.sh b/menu/interface/serverid.sh new file mode 100644 index 00000000..8197b36d --- /dev/null +++ b/menu/interface/serverid.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Title: PTS ServerID +# org. Author(s): Admin9705 - Deiteq +# Mod from MrDoob for PTS +# GNU: General Public License v3.0 +################################################################################ +touch /var/plexguide/server.id.stored +source /opt/plexguide/menu/functions/functions.sh +start=$(cat /var/plexguide/server.id) +stored=$(cat /var/plexguide/server.id.stored) + + +serverid() { + +if [ "$start" != "$stored" ]; then + + tee <<-EOF +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Establishing New Server ID 💬 Use One Word & Keep it Simple +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + read -p '🌏 TYPE Server ID | Press [ENTER]: ' typed ${abc}/server.id + cat ${abc}/server.id >${abc}/server.id.stored + sleep 3 + fi + +fi +} +#### +serverid diff --git a/menu/interface/serverid/choice.yml b/menu/interface/serverid/choice.yml new file mode 100644 index 00000000..917c6dc2 --- /dev/null +++ b/menu/interface/serverid/choice.yml @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +- name: Register Project + shell: 'cat /var/plexguide/server.id' + register: tempid + +- name: 'Set Server ID' + set_fact: + serverid: '{{tempid.stdout}}' + +- name: 'Key Menu Facts' + set_fact: + head1: "\nPG Server Identification Interface" + head2: "\nServer ID: {{serverid}}" + info2: "\n2. Server ID: Change It" diff --git a/menu/interface/serverid/file.sh b/menu/interface/serverid/file.sh new file mode 100644 index 00000000..0e948221 --- /dev/null +++ b/menu/interface/serverid/file.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +menu=$(cat /var/plexguide/final.choice) + +if [ "$menu" == "2" ]; then + echo "" + echo "-----------------------------------------------------" + echo "SYSTEM MESSAGE: Please Read the Following Information" + echo "-----------------------------------------------------" + echo "" + echo "NOTE: Setting the Server ID enables the Server to have" + echo "a unique name for backup and setup purposes." + echo "" + echo "Remember KISS: Keep-It-Simple Stupid! Create a simple" + echo "one word server ID such as hetzner1 or myserver" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue" + echo "" + echo "" + read -p "Set or Change the Server ID (y/n)? " -n 1 -r + echo # move cursor to a new line + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo "" + echo "---------------------------------------------------" + echo "SYSTEM MESSAGE: [Y] Key was NOT Selected - Exiting!" + echo "---------------------------------------------------" + echo "" + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + exit 1 + fi + + break=no + while [ "$break" == "no" ]; do + echo "" + read -p 'Type a Sever ID & Then Press [ENTER]: ' typed + #typed=typed+0 + echo "" + echo "-------------------------------------------------" + echo "SYSTEM MESSAGE: Server ID - $typed" + echo "-------------------------------------------------" + echo "" + read -p "Continue with the Set Server ID (y/n)? " -n 1 -r + + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo "" + echo "---------------------------------------------------" + echo "SYSTEM MESSAGE: [Y] Key was NOT Selected" + echo "---------------------------------------------------" + echo "" + echo "You will be able to set the Server ID Again!" + echo + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + else + echo "" + echo "---------------------------------------------------" + echo "SYSTEM MESSAGE: Server ID - $typed" + echo "---------------------------------------------------" + echo "" + echo "Your Server ID is Now Set! Thank you!" + echo "" + echo $typed >/var/plexguide/server.id + break=yes + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo "" + fi + done + +#### Final fi +fi + +idtest=$(cat /var/plexguide/server.id) +if [ "$idtest" == "NOT-SET" ]; then + echo "" + echo "---------------------------------------------------" + echo "SYSTEM MESSAGE: You Must Create a SERVER ID!" + echo "---------------------------------------------------" + echo "" + echo "Restarting the Process" + echo + read -n 1 -s -r -p "Press [ANY KEY] to Continue " + echo serverid >/var/plexguide/type.choice && bash /opt/plexguide/menu/core/scripts/main.sh + exit +fi diff --git a/menu/interface/serverid/var.sh b/menu/interface/serverid/var.sh new file mode 100644 index 00000000..562eab07 --- /dev/null +++ b/menu/interface/serverid/var.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +echo 2 >/var/plexguide/menu.number + +file="/var/plexguide/server.id" +if [ ! -e "$file" ]; then + echo NOT-SET >/var/plexguide/server.id +fi diff --git a/menu/interface/settings.sh b/menu/interface/settings.sh new file mode 100644 index 00000000..1fa3f683 --- /dev/null +++ b/menu/interface/settings.sh @@ -0,0 +1,116 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +source /opt/plexguide/menu/functions/functions.sh +source /opt/plexguide/menu/functions/watchtower.sh +source /opt/plexguide/menu/functions/install.sh +#source /opt/plexguide/menu/functions/serverid.sh + +# Menu Interface +setstart() { +### executed parts +touch /var/plexguide/pgui.switch + dstatus=$(docker ps --format '{{.Names}}' | grep "pgui") + if [ "pgui" != "$dstatus" ]; then + echo "Off" >/var/plexguide/pgui.switch + elif [ "pgui" == "$dstatus" ]; then + echo "On" >/var/plexguide/pgui.switch + else echo "" + fi + + # Declare Ports State + udisplay=$(cat /var/plexguide/emergency.display) + + if [[ "$udisplay" == "On" ]]; then + echo "CLOSED" >/var/plexguide/http.ports + else echo "8555" >/var/plexguide/http.ports; fi + +### read Variables + emdisplay=$(cat /var/plexguide/emergency.display) + switchcheck=$(cat /var/plexguide/pgui.switch) + domain=$(cat /var/plexguide/server.domain) + ports=$(cat /var/plexguide/http.ports) + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 Settings Interface Menu +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +[1] Download Path : Change the Processing Location +[2] MultiHD : Add Multiple HDs and/or Mount Points to MergerFS +[3] WatchTower : Auto-Update Application Manager +[4] Comm UI : [ $switchcheck ] | Port [ $ports ] | pgui.$domain +[5] Emergency Display : [ $emdisplay ] +[6] System & Network Auditor +[7] Server ID change : Change your ServerID + +[99] TroubleShoot : PreInstaller + +[Z] Exit + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + # Standby + read -p '↘️ Type Number | Press [ENTER]: ' typed /var/plexguide/pgui.switch + docker stop pgui &>/dev/null & + docker rm pgui &>/dev/null & + service localspace stop + systemctl daemon-reload + rm -f /etc/systemd/system/localspace.servive + rm -f /etc/systemd/system/mountcheck.service + clear + tee <<-EOF +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅️ WOOT WOOT: Process Complete! +✅️ WOOT WOOT: UI Removed +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + else + echo "On" >/var/plexguide/pgui.switch + ansible-playbook /opt/coreapps/apps/pgui.yml + systemctl daemon-reload + service localspace start + clear + tee <<-EOF +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅️ WOOT WOOT: Process Complete! +✅️ WOOT WOOT: UI installed +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + fi + setstart + ;; + 5) + if [[ "$emdisplay" == "On" ]]; then + echo "Off" >/var/plexguide/emergency.display + else echo "On" >/var/plexguide/emergency.display; fi + setstart ;; + 6) bash /opt/plexguide/menu/functions/network.sh && clear && setstart ;; + 7) serverid && clear && setstart ;; + + 99) bash /opt/plexguide/menu/functions/tshoot.sh && clear && setstart ;; + z) exit ;; + Z) exit ;; + *) setstart ;; + esac +} + +setstart diff --git a/menu/interface/uninstall/choice.yml b/menu/interface/uninstall/choice.yml new file mode 100644 index 00000000..d7d2d47c --- /dev/null +++ b/menu/interface/uninstall/choice.yml @@ -0,0 +1,13 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +- name: 'Key Menu Facts' + set_fact: + head1: "\nPGBlitz UnInstaller Interface" + head2: "\nWARNING! Ensure to Backup any Data!" + info2: "\n2. I want to UnInstall PGBlitz!" diff --git a/menu/interface/uninstall/file.sh b/menu/interface/uninstall/file.sh new file mode 100644 index 00000000..570a86e0 --- /dev/null +++ b/menu/interface/uninstall/file.sh @@ -0,0 +1,110 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +menu=$(cat /var/plexguide/final.choice) + +if [ "$menu" == "2" ]; then + #read -n 1 -s -r -p "Press [ANY KEY] to Continue " + + echo "" + echo "-----------------------------------------------------------" + echo "SYSTEM MESSAGE: WARNING! PGBlitz Uninstall Interface!" + echo "-----------------------------------------------------------" + echo "" + sleep 3 + + while true; do + read -p "Pay Attention! Do YOU WANT to Continue Uninstalling PG (y or n)!? " yn + case $yn in + [Yy]*) + echo "" + echo "Ok... we are just double checking!" + sleep 2 + break + ;; + [Nn]*) echo "Ok! Exiting the Interface!" && echo "" && sleep 3 && exit ;; + *) echo "Please answer y or n (for yes or no)" ;; + esac + done + + echo "" + echo "-----------------------------------------------------------" + echo "SYSTEM MESSAGE: Uninstalling PG! May the Force Be With You!" + echo "-----------------------------------------------------------" + echo "" + sleep 3 + + echo "0" >/var/plexguide/pg.preinstall.stored + echo "0" >/var/plexguide/pg.ansible.stored + echo "0" >/var/plexguide/pg.rclone.stored + echo "0" >/var/plexguide/pg.python.stored + echo "0" >/var/plexguide/pg.docker.stored + echo "0" >/var/plexguide/pg.docstart.stored + echo "0" >/var/plexguide/pg.watchtower.stored + echo "0" >/var/plexguide/pg.label.stored + echo "0" >/var/plexguide/pg.alias.stored + echo "0" >/var/plexguide/pg.dep + rm -rf /var/plexguide/dep* 1>/dev/null 2>&1 + + echo "" + echo "-----------------------------------------------------------" + echo "SYSTEM MESSAGE: Removing All PGBlitz Dependent Services" + echo "-----------------------------------------------------------" + echo "" + sleep 2 + ansible-playbook /opt/plexguide/menu/interface/uninstall/remove-service.yml + + echo "" + echo "-----------------------------------------------------------" + echo "SYSTEM MESSAGE: Removing All PGBlitz File Directories" + echo "-----------------------------------------------------------" + echo "" + sleep 2 + rm -rf /var/plexguide + + echo "" + echo "-----------------------------------------------------------" + echo "SYSTEM MESSAGE: Uninstalling Docker & Generated Containers" + echo "-----------------------------------------------------------" + echo "" + sleep 2 + rm -rf /etc/docker + apt-get purge docker-ce -y --allow-change-held-packages + rm -rf /var/lib/docker + + while true; do + read -p "Pay Attention! Do you want to DELETE /opt/appdata (y or n)? " yn + case $yn in + [Yy]*) + echo "" + echo "Deleting Your Data Forever - Please Wait!" + rm -rf /opt/appdata + sleep 3 + echo "I'm here, I'm there, wait...I'm your DATA! Poof! I'm gone!" + sleep 3 + break + ;; + [Nn]*) echo "Data Will NOT be deleted!" && break ;; + *) echo "Please answer y or n (for yes or no)" ;; + esac + done + + echo "" + echo "---------------------------------------------------" + echo "SYSTEM MESSAGE: Success! PG Uninstalled! Rebooting!" + echo "---------------------------------------------------" + echo "" + sleep 3 + echo "" + echo "----------------------------------------------------" + echo "SYSTEM MESSAGE: PGBlitz Will Never Die! GoodBye!" + echo "----------------------------------------------------" + echo "" + sleep 2 + reboot + +fi diff --git a/menu/interface/uninstall/remove-service.yml b/menu/interface/uninstall/remove-service.yml new file mode 100644 index 00000000..ce8f8ccc --- /dev/null +++ b/menu/interface/uninstall/remove-service.yml @@ -0,0 +1,44 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + vars: + service_vars: + - { name: crypt.service } + - { name: pgdrive.service } + - { name: gdrive.service } + - { name: gcrypt.service } + - { name: tdrive.service } + - { name: tcrypt.service } + - { name: supertransfer2.service } + - { name: unionfs.service } + - { name: pgmove.service } + - { name: pgunion.service } + - { name: move.service } + - { name: pgblitz.service } + - { name: plexdrive.service } + - { name: st2monitor.service } + tasks: + - name: Checking Existing Service Name + stat: + path: '/etc/systemd/system/{{ item.name }}' + with_items: '{{ service_vars }}' + register: check_service_name + + - name: Stop If Service Is Running + systemd: state=stopped name={{ item.item.name }} daemon_reload=yes enabled=no + with_items: '{{ check_service_name.results }}' + when: item.stat.exists + + - name: Remove Services + file: + path: '/etc/systemd/system/{{ item.item.name }}' + state: absent + with_items: '{{ check_service_name.results }}' + when: item.stat.exists diff --git a/menu/interface/uninstall/unfiles.yml b/menu/interface/uninstall/unfiles.yml new file mode 100644 index 00000000..0ed0eaee --- /dev/null +++ b/menu/interface/uninstall/unfiles.yml @@ -0,0 +1,20 @@ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: Removing File Directories + file: + state: absent + path: "{{ item }}" + with_items: + - /var/plexguide + - /opt/appdata/plexguide + - {{path.stdout}}/nzbget + - {{path.stdout}}/sab + - {{path.stdout}}/rutorrent + - {{path.stdout}}/move + - {{path.stdout}}/gcrypt + - {{path.stdout}}/deluge + - {{path.stdout}}/torrentvpn + - {{path.stdout}}/qbittorrent + ignore_errors: yes diff --git a/menu/interface/uninstall/var.sh b/menu/interface/uninstall/var.sh new file mode 100644 index 00000000..7c78d74f --- /dev/null +++ b/menu/interface/uninstall/var.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +echo 2 >/var/plexguide/menu.number diff --git a/menu/interface/version/choice.yml b/menu/interface/version/choice.yml new file mode 100644 index 00000000..d164d013 --- /dev/null +++ b/menu/interface/version/choice.yml @@ -0,0 +1,35 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: Register Project + shell: 'cat /var/plexguide/pg.number' + register: serverid + + - name: Installing EDGE + git: + repo: 'https://github.com/PGBlitz/PGBlitz.com' + dest: '/opt/plexguide' + version: Edge + force: yes + when: serverid.stdout == "edge" + + - name: 'Installing Version {{serverid.stdout}}' + git: + repo: 'https://github.com/PGBlitz/PGBlitz.com' + dest: '/opt/plexguide' + version: '{{serverid.stdout}}' + force: yes + when: not serverid.stdout == "edge" + ignore_errors: True + + - name: 'Stops First Time Run' + shell: 'touch /var/plexguide/ask.yes' + register: program diff --git a/menu/interface/version/file.sh b/menu/interface/version/file.sh new file mode 100644 index 00000000..740927ae --- /dev/null +++ b/menu/interface/version/file.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +rm -rf /var/plexguide/ver.temp 1>/dev/null 2>&1 +touch /var/plexguide/ver.temp + +sleep 4 +## Builds Version List for Display +while read p; do + echo $p >>/var/plexguide/ver.temp +done /var/plexguide/pg.number + ansible-playbook /opt/plexguide/menu/interface/version/choice.yml + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅️ SYSTEM MESSAGE: Installed Verison - $storage - Standby! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 4 + else + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ SYSTEM MESSAGE: Version $storage does not exist! - Standby! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 4 + cat /var/plexguide/ver.temp + echo "" + fi + +done diff --git a/menu/journal/tasks/main.yml b/menu/journal/tasks/main.yml new file mode 100644 index 00000000..92ca150e --- /dev/null +++ b/menu/journal/tasks/main.yml @@ -0,0 +1,16 @@ +--- +- name: Install Journald Fix + template: + dest: /etc/systemd/journald.conf + force: true + src: /opt/plexguide/menu/journal/templates/journald.conf.j2 + +- name: systemd reloading + systemd: + daemon_reload: true + +- name: restart journald + systemd: + daemon_reload: true + name: systemd-journald + state: restarted diff --git a/menu/journal/templates/journald.conf.j2 b/menu/journal/templates/journald.conf.j2 new file mode 100644 index 00000000..d12309a0 --- /dev/null +++ b/menu/journal/templates/journald.conf.j2 @@ -0,0 +1,34 @@ +# Journald.conf MOD +# Title: PTS ( journald.conf Mod ) +# Author(s): MrDoobPG +################################################################################ + +[Journal] +Storage=volatile +Compress=yes +#Seal=yes +#SplitMode=uid +#SyncIntervalSec=5m +#RateLimitIntervalSec= +#RateLimitBurst=10M +SystemMaxUse=100M +#SystemKeepFree= +SystemMaxFileSize=10M +SystemMaxFiles=10 +#RuntimeMaxUse=100M +#RuntimeKeepFree= +#RuntimeMaxFileSize= +#RuntimeMaxFiles=100 +#MaxRetentionSec= +#MaxFileSec=1day +#ForwardToSyslog=yes +#ForwardToKMsg=no +#ForwardToConsole=no +#ForwardToWall=yes +#TTYPath=/dev/console +MaxLevelStore=crit +#MaxLevelSyslog=debug +#MaxLevelKMsg=notice +#MaxLevelConsole=info +#MaxLevelWall=emerg +#LineMax=48K diff --git a/menu/log/kill_log.sh b/menu/log/kill_log.sh new file mode 100644 index 00000000..4722e578 --- /dev/null +++ b/menu/log/kill_log.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# file names to filter + +UNWANTED_FILES=( +'vsftpd.log' +'syslog' +'daemon.log' +'kern.log' +'messages' +'kern.log' +'vsftpd.log' +'syslog' +'access.log' +'error.log' +'lastlog' +'php5-fpm-log' +'user.log' +'faillog' +'fontconfig.log' +'debug' +'dpkg.log' +'*.log.*' +'*tallylog*' +'*.tar.*.gz' +'wtmp' +'btmp' +'alternatives.log' +'bootstrap.log' +'unattended-*' + +) +# advanced settings +FIND=$(which find) +FIND_BASE_CONDITION='-type f' +FIND_ADD_NAME='-o -name' +FIND_ACTION=' -delete' + +#Folder Setting +TARGET_FOLDER=$1'/var/log/' + +if [ ! -d "${TARGET_FOLDER}" ]; then + echo 'Target directory does not exist.' + exit 1 +fi + +condition="-name '${UNWANTED_FILES[0]}'" +for ((i = 1; i < ${#UNWANTED_FILES[@]}; i++)) +do + condition="${condition} ${FIND_ADD_NAME} '${UNWANTED_FILES[i]}'" +done + +command="${FIND} '${TARGET_FOLDER}' ${FIND_BASE_CONDITION} \( ${condition} \) ${FIND_ACTION}" +echo "Executing ${command}" +eval ${command} + +exit 0 diff --git a/menu/log/log.sh b/menu/log/log.sh new file mode 100644 index 00000000..fc0be0df --- /dev/null +++ b/menu/log/log.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +dt=$(date '+%d/%m/%Y %H:%M:%S') +log=$(cat /var/plexguide/logs/pg.log) +echo "$dt $log" >>"/var/plexguide/logs/pg.log" diff --git a/menu/motd/00-header b/menu/motd/00-header new file mode 100644 index 00000000..9be30b23 --- /dev/null +++ b/menu/motd/00-header @@ -0,0 +1,2 @@ +#!/bin/sh +figlet $(hostname) | lolcat \ No newline at end of file diff --git a/menu/motd/10-sysinfo b/menu/motd/10-sysinfo new file mode 100644 index 00000000..84cfe39b --- /dev/null +++ b/menu/motd/10-sysinfo @@ -0,0 +1,88 @@ +#!/bin/bash + +# get load averages +IFS=" " read LOAD1 LOAD5 LOAD15 <<<$(cat /proc/loadavg | awk '{ print $1,$2,$3 }') +# get free memory +IFS=" " read USED FREE TOTAL <<<$(free -htm | grep "Mem" | awk {'print $3,$6,$2'}) +# get processes +PROCESS=$(ps -eo user= | sort | uniq -c | awk '{ print $2 " " $1 }') +PROCESS_ALL=$(echo "$PROCESS" | awk {'print $2'} | awk '{ SUM += $1} END { print SUM }') +PROCESS_ROOT=$(echo "$PROCESS" | grep root | awk {'print $2'}) +PROCESS_USER=$(echo "$PROCESS" | grep -v root | awk {'print $2'} | awk '{ SUM += $1} END { print SUM }') +# get processors +PROCESSOR_NAME=$(grep "model name" /proc/cpuinfo | cut -d ' ' -f3- | awk {'print $0'} | head -1) +PROCESSOR_COUNT=$(grep -ioP 'processor\t:' /proc/cpuinfo | wc -l) +IP_ADDRESS=$(ip a | grep glo | awk '{print $2}' | head -1 | cut -f1 -d/) + +NTCARD=$(ifconfig | grep -E 'eno1|enp|ens5' | awk '{print $1}' | sed -e 's/://g') +DOCKER=$(systemctl is-active docker) +DOCKER2=$(docker --version | awk '{print $3}') +UNIONFS=$(systemctl is-active pgunion) + +PTS=$(cat /var/plexguide/pg.number) +HSTNAME=$(cat /etc/hostname) + +###storage local part +mntused=$(df -h /mnt | awk '{ a = $3 } END { print a }') +mntavi=$(df -h /mnt | awk '{ a = $4 } END { print a }') +mntpercent=$(df -h | awk '{if($(NF) == "/mnt") {print $(NF-1); exit;}}') + +baseused=$(df -h / | awk '{ a = $3 } END { print a }') +baseavi=$(df -h / | awk '{ a = $4 } END { print a }') +basepercent=$(df -h | awk '{if($(NF) == "/") {print $(NF-1); exit;}}') + +#google hack for loginshell + +tdrive=$(tail -n 1 /var/plexguide/tduncrypt.log) +gdrive=$(tail -n 1 /var/plexguide/gduncrypt.log) +tcrypt=$(tail -n 1 /var/plexguide/tdcrypt.log) +gcrypt=$(tail -n 1 /var/plexguide/gdcrypt.log) + +wisword=$(/usr/games/fortune -as | sed "s/^/ /") + +##security part +failledssh=$(cat /var/log/auth.log | grep -i "fail" | wc -l) +failledsshacc=$(head -n1 /var/log/auth.log | awk '{print $1, $2 ,$3 }') + +W="\e[0;39m" +G="\e[1;32m" + +echo -e " +${W}System information as of $(date) : + +$W Hostname.......: $W$HSTNAME +$W Distro.........: $W$(lsb_release -s -d) +$W PTS-Version....: $G$PTS +$W Kernel.........: $W$(uname -sr) + +$W Uptime.........: $W$(uptime -p) +$W Load...........: $G$LOAD1$W (1m) , $G$LOAD5$W (5m) , $G$LOAD15$W (15m) +$W Processes......: $W$G$PROCESS_ROOT$W (root) , $G$PROCESS_USER$W (user) , $G$PROCESS_ALL$W (total) + +$W CPU............: $W$PROCESSOR_NAME +$W CPU-Cores......: $G$PROCESSOR_COUNT$W vCPU +$W Memory.........: $G$USED$W used , $G$FREE$W free, $G$TOTAL$W total $W +$W Network........: $G$IP_ADDRESS$W +$W Network-Card...: $G$NTCARD + +$W Fail2ban +$W SSH.fails......: $G$failledssh +$W SSH.fails.since: $G$failledsshacc + +$W Service Status +$W Docker..........: $W$DOCKER , v$G$DOCKER2 +$W unionfs.........: $W$UNIONFS + +$W Storage - Local +$W /...............: $W$baseused USED, $W$baseavi Avail, $W$basepercent +$W /mnt........... : $W$mntused USED, $W$mntavi Avail, $W$mntpercent + +$W Storage - Cloud +$W GDrive | uncrypted : $G$gdrive +$W TDrive | uncrypted : $G$tdrive +$W GDrive | crypted : $G$gcrypt +$W TDrive | crypted : $G$tcrypt + +$W %++++++++++ WISE WORD OF THE DAY ++++++++++% +$W $W$wisword +$W %++++++++++ WISE WORD OF THE DAY ++++++++++%" \ No newline at end of file diff --git a/menu/motd/20-motd-news b/menu/motd/20-motd-news new file mode 100644 index 00000000..e031cdf1 --- /dev/null +++ b/menu/motd/20-motd-news @@ -0,0 +1,123 @@ +#!/bin/sh +# +# 50-motd-news - print the live news from the Ubuntu wire +# Copyright (C) 2016-2017 Canonical Ltd. +# Copyright (C) 2016-2017 Dustin Kirkland +# +# Authors: Dustin Kirkland +# +# 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 2 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, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +############################################################################## +# This program could be rewritten in C or Golang for faster performance. +# Or it could be rewritten in Python or another higher level language +# for more modularity. +# However, I've insisted on shell here for transparency! +# - Dustin +############################################################################## + +# Source the local configuration +[ -r /etc/default/motd-news ] && . /etc/default/motd-news + +# Exit immediately, unless we're enabled +# This makes this script very easy to disable in /etc/default/motd-news configuration +[ "$ENABLED" = "1" ] || exit 0 + +# Ensure sane defaults +[ -n "$URLS" ] || URLS="https://motd.ubuntu.com" +[ -n "$WAIT" ] || WAIT=5 +[ -n "$CACHE" ] || CACHE="/var/cache/motd-news" +[ "$1" = "--force" ] && FORCED=1 + +# Ensure we print safely, maximum of the first 10 lines, +# maximum of the first 80 chars per line, no control chars +safe_print() { + cat "$1" | head -n 10 | tr -d '\000-\011\013\014\016-\037' | cut -c -80 +} + + +# If we're not forcing an update, and we have a cached motd-news file, +# then just print it and exit as quickly as possible, for login performance. +# Note that systemd should keep this cache file up to date, asynchronously +if [ "$FORCED" != "1" ]; then + if [ -r $CACHE ]; then + echo + safe_print $CACHE + else + : > $CACHE + fi + exit 0 +fi + +# If we've made it here, we've been given the --force argument, +# probably from the systemd motd-news.service. Let's update... + +# Generate our temp files, clean up when done +NEWS=$(mktemp) || exit 1 +ERR=$(mktemp) || exit 1 +trap "rm -f $NEWS $ERR" HUP INT QUIT ILL TRAP KILL BUS TERM + +# Construct a user agent, similar to Firefox/Chrome/Safari/IE to +# ensure a proper, tailored, accurate message of the day + +# Curl browser version, for debug purposes +curl_ver="$(dpkg -l curl | awk '$1 == "ii" { print($3); exit(0); }')" + +# Distribution version, for messages releated to this Ubuntu release +. /etc/lsb-release +lsb=$(echo "$DISTRIB_DESCRIPTION" | sed -e "s/ /\//g") +codename="$DISTRIB_CODENAME" + +# Kernel version and CPU type, for messages related to a particular revision or hardware +platform="$(uname -o)/$(uname -r)/$(uname -m)" +arch="$(uname -m)" +cpu="$(grep -m1 "^model name" /proc/cpuinfo | sed -e "s/.*: //" -e "s:\s\+:/:g")" + +# Some messages may only be pertinent before or after some amount of uptime +read up idle < /proc/uptime +uptime="uptime/$up/$idle" + +# Piece together the user agent +USER_AGENT="curl/$curl_ver $lsb $platform $cpu $uptime" + +# Loop over any configured URLs +for u in $URLS; do + # Ensure https:// protocol, for security reasons + case $u in + https://*) + true + ;; + https://motd.ubuntu.com) + u="$u/$codename/$arch" + ;; + *) + continue + ;; + esac + # If we're forced, set the wait to much higher (1 minute) + [ "$FORCED" = "1" ] && WAIT=60 + # Fetch and print the news motd + if curl --connect-timeout "$WAIT" --max-time "$WAIT" -A "$USER_AGENT" -o- "$u" >"$NEWS" 2>"$ERR"; then + echo + # At most, 10 lines of text, remove control characters, print at most 80 characters per line + safe_print "$NEWS" + # Try to update the cache + safe_print "$NEWS" 2>/dev/null >$CACHE || true + else + : > "$CACHE" + fi +done +rm -f "$NEWS" "$ERR" +exit 0 diff --git a/menu/motd/30-diskinfo b/menu/motd/30-diskinfo new file mode 100644 index 00000000..9bc8b7af --- /dev/null +++ b/menu/motd/30-diskinfo @@ -0,0 +1,59 @@ +#!/bin/bash + +# config +drives="sda sdb sdc" +max_usage=90 +bar_width=50 +target_temp=22 +# colors +white="\e[39m" +green="\e[1;32m" +red="\e[1;31m" +dim="\e[2m" +undim="\e[0m" + +# disk usage: ignore zfs, squashfs & tmpfs +mapfile -t dfs < <(df -H -x fuse.rclone -x fuse.unionfs -x proc -x sys -x dev -x zfs -x squashfs -x tmpfs -x devtmpfs --output=target,pcent,size,avail,used | tail -n+2) +printf "\n Storage:\n" + +for line in "${dfs[@]}"; do + + if [[ $line =~ .*docker.* ]]; then + continue + fi + + # get disk usage + usage=$(echo "$line" | awk '{print $2}' | sed 's/%//') + path=$(echo "$line" | awk '{print $1}' | sed 's/%//') + total=$(echo "$line" | awk '{print $3}' | sed 's/%//') + free=$(echo "$line" | awk '{print $4}' | sed 's/%//') + used=$(echo "$line" | awk '{print $5}' | sed 's/%//') + # color is green if usage < max_usage, else red + if [ "${usage}" -ge "${max_usage}" ]; then + color=$red + else + color=$green + fi + + output+=$(echo " ${path} ${color}${used}${undim} used, ${color}${free}${undim} free, ${color}${total}${undim} total\n") + +#google hack for loginshell + +tdrive=$(tail -n 1 /var/plexguide/tduncrypt.log) +gdrive=$(tail -n 1 /var/plexguide/gduncrypt.log) +tcrypt=$(tail -n 1 /var/plexguide/tdcrypt.log) +gcrypt=$(tail -n 1 /var/plexguide/gdcrypt.log) + +done +printf "${output}" | + awk '{printf " %.15s %s\n", $1 "............:", $2 " " $3 " " $4 " " $5 " " $6 " " $7}' + +echo "" + +echo "Google Cloud Used Space:" + echo"" + echo " GDrive | uncrypted : " $gdrive + echo " TDrive | uncrypted : " $tdrive + echo "" + echo " GDrive | crypted : " $gcrypt + echo " TDrive | crypted : " $tcrypt diff --git a/menu/motd/80-esm b/menu/motd/80-esm new file mode 100644 index 00000000..08576213 --- /dev/null +++ b/menu/motd/80-esm @@ -0,0 +1,24 @@ +#!/bin/sh + +SERIES=$(lsb_release -cs) +DESCRIPTION=$(lsb_release -ds) + +[ "$SERIES" = "precise" ] || exit 0 + +[ -x /usr/bin/ubuntu-advantage ] || exit 0 + +if ubuntu-advantage is-esm-enabled; then + cat </dev/null | sort -r) || true +echo diff --git a/menu/motd/98-fsck-at-reboot b/menu/motd/98-fsck-at-reboot new file mode 100644 index 00000000..e5ec39e5 --- /dev/null +++ b/menu/motd/98-fsck-at-reboot @@ -0,0 +1,5 @@ +#!/bin/sh + +if [ -x /usr/lib/update-notifier/update-motd-fsck-at-reboot ]; then + exec /usr/lib/update-notifier/update-motd-fsck-at-reboot +fi \ No newline at end of file diff --git a/menu/motd/98-reboot-required b/menu/motd/98-reboot-required new file mode 100644 index 00000000..e86de0ba --- /dev/null +++ b/menu/motd/98-reboot-required @@ -0,0 +1,5 @@ +#!/bin/sh + +if [ -x /usr/lib/update-notifier/update-motd-reboot-required ]; then + exec /usr/lib/update-notifier/update-motd-reboot-required +fi \ No newline at end of file diff --git a/menu/motd/motd.yml b/menu/motd/motd.yml new file mode 100644 index 00000000..d1cf5be5 --- /dev/null +++ b/menu/motd/motd.yml @@ -0,0 +1,39 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: Disable existing MOTD + shell: chmod -x /etc/update-motd.d/* + + - name: Deploy Dynamic MOTD + file: + path: /etc/update-motd.d + state: directory + mode: 0775 + + - name: Import MOTD Files + copy: 'src={{item}} dest=/etc/update-motd.d/{{item}} force=yes mode=0775' + with_items: + - 00-header + - 10-sysinfo + + - name: Install lolcat pip module + pip: + name: lolcat + state: latest + ignore_errors: yes + + - cron: + name: 'Update MOTD' + user: 'root' + minute: '10' + job: 'update-motd' + state: absent + become_user: root diff --git a/menu/multihd/functions/addpoint.sh b/menu/multihd/functions/addpoint.sh new file mode 100644 index 00000000..d7a828b4 --- /dev/null +++ b/menu/multihd/functions/addpoint.sh @@ -0,0 +1,122 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +addpoint() { + rolevars + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +💪 Add HD or MountPoint +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +NOTE1: This point must EXIST! PTS does not format drives, nor mount +the secondary HDs for the user. Visit the URL to learn about the basics! +Feel free to add/change the wiki in ordeer to help us all! + +NOTE2: Formatting Examples + +/hd2/mystuff +/mystash/media +/nas/XXYZY/hiddenvideos +/media-NAS/storage/media +/secondhd/user/ + +Quitting? Type >>> q or exit +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -rp '↘️ Input Selection | Press [ENTER]: ' addpath &1) + checkcheck2=$(echo $checkcheck1 | grep "cannot access") + + # Checks to Make Sure the Path Is Valid + if [[ "$checkcheck2" != "" ]]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +💪 ERROR NOTICE +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +PATH: $addpath + +NOTE: We are unable to verify that the following path above exists! +Type "ls -la $addpath" + +Utilizing the above command may help determine what the problem is! + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -rp '↘️ Acknowledge Info | Press [ENTER] ' typed >/var/plexguide/multihd.paths + read -rp '↘️ Acknowledge Info | Press [ENTER] ' typed /dev/null 2>&1 + + # Starting Process + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +💪 Remove an HD/MountPoint +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +NOTE: Type a number selection in order to remove one of the HD/Mountpoints + +EOF + num=0 + while read p; do + ((num++)) + echo "[$num] $p" + echo "[$num] $p" >>/var/plexguide/.tmp.removepointmenu + done >> exit +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -rp '↘️ Type Number | Press [ENTER]: ' typed /var/plexguide/.tmp.removepointmenu.select + removestore=$(cat /var/plexguide/.tmp.removepointmenu.select | awk '{print $2}') + + rm -rf /var/plexguide/.tmp.removebuild 1>/dev/null 2>&1 + num=0 + while read p; do + if [[ "$removestore" != "$p" ]]; then echo "$p" >>/var/plexguide/.tmp.removebuild; fi + done $1; fi + } + + variablet() { + file="$1" + if [ ! -e "$file" ]; then touch "$1"; fi + } + + # set variables if they do not exist + variable /var/plexguide/vfs_rcsl "2048M" + vfs_rcsl=$(cat /var/plexguide/vfs_rcsl) + variable /var/plexguide/multihd.paths "" + +} diff --git a/menu/multihd/multihd.sh b/menu/multihd/multihd.sh new file mode 100644 index 00000000..3f4a448d --- /dev/null +++ b/menu/multihd/multihd.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# +# Title: PGBlitz.com (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +source /opt/plexguide/menu/multihd/functions/variables.sh +source /opt/plexguide/menu/multihd/functions/outputstart.sh +source /opt/plexguide/menu/multihd/functions/addpoint.sh +source /opt/plexguide/menu/multihd/functions/removepoint.sh +################################################################################ +rolevars + +# multihdstart +multihdstart diff --git a/menu/pg.yml b/menu/pg.yml new file mode 100644 index 00000000..f6323e2c --- /dev/null +++ b/menu/pg.yml @@ -0,0 +1,22 @@ +--- +- hosts: localhost + vars: + extra: '' + + roles: + - { role: docker, tags: ['docker'] } + - { role: docstart, tags: ['docstart'] } + - { role: autodelete, tags: ['autodelete'] } + - { role: clean, tags: ['clean'] } + - { role: update, tags: ['update'] } + - { role: rcloneinstall, tags: ['rcloneinstall'] } + - { role: mergerfsinstall, tags: ['mergerfsinstall'] } + - { role: gcloud_sdk, tags: ['gcloud_sdk'] } + - { role: system, tags: ['system'] } + - { role: mergerfsupdate, tags: ['mergerfsupdate'] } + - { role: journal, tags: ['journal'] } + - { role: plex_autoscan, tags: ['plex_autoscan'] } + - { role: plex_dupefinder, tags: ['plex_dupefinder'] } + - { role: plexpatrol, tags: ['plexpatrol'] } + - { role: remove, tags: ['remove'] } + - { role: traktarr, tags: ['traktarr'] } \ No newline at end of file diff --git a/menu/pgbox/cname.sh b/menu/pgbox/cname.sh new file mode 100644 index 00000000..0a63a838 --- /dev/null +++ b/menu/pgbox/cname.sh @@ -0,0 +1,99 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): LooseSeal2 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +source /opt/plexguide/menu/functions/functions.sh + +# vars +program=$(cat /tmp/program_var) +domain=$(cat /var/plexguide/server.domain) + +variable /var/plexguide/"$program".cname "$program" + +variable /var/plexguide/"$program".port "" + +# FIRST QUESTION +question1() { + cname=$(cat /var/plexguide/$program.cname) + port=$(cat /var/plexguide/$program.port) + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⌛ $program - Set subdomains & ports +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + if [[ $port != "" ]]; then + tee <<-EOF +External Url: https://$cname.$domain:$port +EOF + else + tee <<-EOF +External Url: https://$cname.$domain +EOF + fi + + tee <<-EOF + +[1] Change subdomain +[2] Change external port + +EOF + + if [[ $port != "" ]]; then + tee <<-EOF +[A] Use https://$cname.$domain:$port +EOF + else + tee <<-EOF +[A] Use https://$cname.$domain +EOF + fi + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + read -p '↘️ Type Number | Press [ENTER]: ' typed "/var/plexguide/$program.cname" + question1 + fi + fi + elif [ "$typed" == "2" ]; then + read -p "🌍 Type port 1025-65535 to use for $program | blank for default | Press [ENTER]: " typed "/var/plexguide/$program.port" + else + if ! [[ "$typed" =~ ^[0-9]+$ && "$typed" -ge 1025 && "$typed" -le 65535 ]]; then + badinput1 + else + echo "$typed" >"/var/plexguide/$program.port" + fi + fi + question1 + else badinput1; fi +} + +question1 + +manualuser() { + while read p; do + echo "$p" >"/var/plexguide/$program.cname" + done ") + if [ "$croncheck" == "0" ]; then bash /opt/plexguide/menu/cron/cron.sh; fi +} + +cronmass() { + croncheck=$(cat /opt/communityapps/apps/_cron.list | grep -c "\<$p\>") + if [ "$croncheck" == "0" ]; then bash /opt/plexguide/menu/cron/cron.sh; fi +} + +initial() { + rm -rf /var/plexguide/pgbox.output 1>/dev/null 2>&1 + rm -rf /var/plexguide/pgbox.buildup 1>/dev/null 2>&1 + rm -rf /var/plexguide/program.temp 1>/dev/null 2>&1 + rm -rf /var/plexguide/app.list 1>/dev/null 2>&1 + touch /var/plexguide/pgbox.output + touch /var/plexguide/program.temp + touch /var/plexguide/app.list + touch /var/plexguide/pgbox.buildup + + mkdir -p /opt/communityapps + + if [ "$boxversion" == "official" ]; then + ansible-playbook /opt/plexguide/menu/pgbox/community/community.yml >/dev/null 2>&1 + else question1; fi + + echo "" + echo "💬 Pulling Update Files - Please Wait" + file="/opt/communityapps/place.holder" + waitvar=0 + while [ "$waitvar" == "0" ]; do + sleep .5 + if [ -e "$file" ]; then waitvar=1; fi + done + customcontainers +} + +question1() { + + ### Remove Running Apps + while read p; do + sed -i "/^$p\b/Id" /var/plexguide/app.list + done /var/plexguide/app.list + while read p; do + echo "" >>/opt/communityapps/apps/$p.yml + echo "##PG-Community" >>/opt/communityapps/apps/$p.yml + + mkdir -p /opt/mycontainers + touch /opt/appdata/plexguide/rclone.conf + done /var/plexguide/pgbox.running + + ### Remove Official Apps + while read p; do + # reminder, need one for custom apps + baseline=$(cat /opt/communityapps/apps/$p.yml | grep "##PG-Community") + if [ "$baseline" == "" ]; then sed -i -e "/$p/d" /var/plexguide/app.list; fi + done >/var/plexguide/program.temp + echo -n " " >>/var/plexguide/program.temp + num=$((num + 1)) + if [[ "$num" == "7" ]]; then + num=0 + echo " " >>/var/plexguide/program.temp + fi + done ") + if [ "$current" != "" ]; then queued && question1; fi + + current=$(cat /var/plexguide/pgbox.running | grep "\<$typed\>") + if [ "$current" != "" ]; then exists && question1; fi + + current=$(cat /var/plexguide/program.temp | grep "\<$typed\>") + if [ "$current" == "" ]; then badinput1 && question1; fi + + part1 +} + +part1() { + echo "$typed" >>/var/plexguide/pgbox.buildup + num=0 + + touch /var/plexguide/pgbox.output && rm -rf /var/plexguide/pgbox.output + + while read p; do + echo -n $p >>/var/plexguide/pgbox.output + echo -n " " >>/var/plexguide/pgbox.output + if [[ "$num" == 7 ]]; then + num=0 + echo " " >>/var/plexguide/pgbox.output + fi + done /tmp/program_var + + bash /opt/communityapps/apps/image/_image.sh + done ") + if [ "$croncheck" == "0" ]; then bash /opt/plexguide/menu/cron/cron.sh; fi +} + +cronmass() { + croncheck=$(cat /opt/coreapps/apps/_cron.list | grep -c "\<$p\>") + if [ "$croncheck" == "0" ]; then bash /opt/plexguide/menu/cron/cron.sh; fi +} + +initial() { + rm -rf /var/plexguide/pgbox.output 1>/dev/null 2>&1 + rm -rf /var/plexguide/pgbox.buildup 1>/dev/null 2>&1 + rm -rf /var/plexguide/program.temp 1>/dev/null 2>&1 + rm -rf /var/plexguide/app.list 1>/dev/null 2>&1 + touch /var/plexguide/pgbox.output + touch /var/plexguide/program.temp + touch /var/plexguide/app.list + touch /var/plexguide/pgbox.buildup + + mkdir -p /opt/coreapps + + if [ "$boxversion" == "official" ]; then + ansible-playbook /opt/plexguide/menu/pgbox/core/core.yml >/dev/null 2>&1 + else question1; fi + + echo "" + echo "💬 Pulling Update Files - Please Wait" + file="/opt/coreapps/place.holder" + waitvar=0 + while [ "$waitvar" == "0" ]; do + sleep .5 + if [ -e "$file" ]; then waitvar=1; fi + done + +} + +question1() { + + ### Remove Running Apps + while read p; do + sed -i "/^$p\b/Id" /var/plexguide/app.list + done /var/plexguide/app.list + while read p; do + echo "" >>/opt/coreapps/apps/$p.yml + echo "##PG-Core" >>/opt/coreapps/apps/$p.yml + + mkdir -p /opt/mycontainers + touch /opt/appdata/plexguide/rclone.conf + done /var/plexguide/pgbox.running + + ### Remove Official Apps + while read p; do + # reminder, need one for custom apps + baseline=$(cat /opt/coreapps/apps/$p.yml | grep "##PG-Core") + if [ "$baseline" == "" ]; then sed -i -e "/$p/d" /var/plexguide/app.list; fi + done >/var/plexguide/program.temp + echo -n " " >>/var/plexguide/program.temp + num=$((num + 1)) + if [[ "$num" == "7" ]]; then + num=0 + echo " " >>/var/plexguide/program.temp + fi + done ") + if [ "$current" != "" ]; then queued && question1; fi + + current=$(cat /var/plexguide/pgbox.running | grep "\<$typed\>") + if [ "$current" != "" ]; then exists && question1; fi + + current=$(cat /var/plexguide/program.temp | grep "\<$typed\>") + if [ "$current" == "" ]; then badinput1 && question1; fi + + part1 +} + +part1() { + echo "$typed" >>/var/plexguide/pgbox.buildup + num=0 + + touch /var/plexguide/pgbox.output && rm -rf /var/plexguide/pgbox.output + + while read p; do + echo -n $p >>/var/plexguide/pgbox.output + echo -n " " >>/var/plexguide/pgbox.output + if [[ "$num" == 7 ]]; then + num=0 + echo " " >>/var/plexguide/pgbox.output + fi + done /tmp/program_var + + bash /opt/coreapps/apps/image/_image.sh + + # CName & Port Execution + bash /opt/plexguide/menu/pgbox/cname.sh + done ") + if [ "$croncheck" == "0" ]; then bash /opt/plexguide/menu/cron/cron.sh; fi +} + +cronmass() { + croncheck=$(cat /opt/coreapps/apps/_cron.list | grep -c "\<$p\>") + if [ "$croncheck" == "0" ]; then bash /opt/plexguide/menu/cron/cron.sh; fi +} + +initial() { + rm -rf /var/plexguide/pgbox.output 1>/dev/null 2>&1 + rm -rf /var/plexguide/pgbox.buildup 1>/dev/null 2>&1 + rm -rf /var/plexguide/program.temp 1>/dev/null 2>&1 + rm -rf /var/plexguide/app.list 1>/dev/null 2>&1 + touch /var/plexguide/pgbox.output + touch /var/plexguide/program.temp + touch /var/plexguide/app.list + touch /var/plexguide/pgbox.buildup + + mkdir -p /opt/coreapps + + if [ "$boxversion" == "official" ]; then + ansible-playbook /opt/plexguide/menu/pgbox/gce/gcecore.yml >/dev/null 2>&1 + else question1; fi + + echo "" + echo "💬 Pulling Update Files - Please Wait" + file="/opt/coreapps/place.holder" + waitvar=0 + while [ "$waitvar" == "0" ]; do + sleep .5 + if [ -e "$file" ]; then waitvar=1; fi + done + +} + +question1() { + + ### Remove Running Apps + while read p; do + sed -i "/^$p\b/Id" /var/plexguide/app.list + done /var/plexguide/app.list + while read p; do + echo "" >>/opt/coreapps/apps/$p.yml + echo "##PG-Core" >>/opt/coreapps/apps/$p.yml + + mkdir -p /opt/mycontainers + touch /opt/appdata/plexguide/rclone.conf + done /var/plexguide/pgbox.running + + ### Remove Official Apps + while read p; do + # reminder, need one for custom apps + baseline=$(cat /opt/coreapps/apps/$p.yml | grep "##PG-Core") + if [ "$baseline" == "" ]; then sed -i -e "/$p/d" /var/plexguide/app.list; fi + done >/var/plexguide/program.temp + echo -n " " >>/var/plexguide/program.temp + num=$((num + 1)) + if [[ "$num" == "7" ]]; then + num=0 + echo " " >>/var/plexguide/program.temp + fi + done ") + if [ "$current" != "" ]; then queued && question1; fi + + current=$(cat /var/plexguide/pgbox.running | grep "\<$typed\>") + if [ "$current" != "" ]; then exists && question1; fi + + current=$(cat /var/plexguide/program.temp | grep "\<$typed\>") + if [ "$current" == "" ]; then badinput1 && question1; fi + + part1 +} + +part1() { + echo "$typed" >>/var/plexguide/pgbox.buildup + num=0 + + touch /var/plexguide/pgbox.output && rm -rf /var/plexguide/pgbox.output + + while read p; do + echo -n $p >>/var/plexguide/pgbox.output + echo -n " " >>/var/plexguide/pgbox.output + if [[ "$num" == 7 ]]; then + num=0 + echo " " >>/var/plexguide/pgbox.output + fi + done /tmp/program_var + + bash /opt/coreapps/apps/image/_image.sh + + # CName & Port Execution + bash /opt/plexguide/menu/pgbox/cname.sh + done ") + if [ "$croncheck" == "0" ]; then bash /opt/plexguide/menu/cron/cron.sh; fi +} + +cronmass() { + croncheck=$(cat /opt/mycontainers/apps/_cron.list | grep -c "\<$p\>") + if [ "$croncheck" == "0" ]; then bash /opt/plexguide/menu/cron/cron.sh; fi +} + +initial() { + rm -rf /var/plexguide/pgbox.output 1>/dev/null 2>&1 + rm -rf /var/plexguide/pgbox.buildup 1>/dev/null 2>&1 + rm -rf /var/plexguide/program.temp 1>/dev/null 2>&1 + rm -rf /var/plexguide/app.list 1>/dev/null 2>&1 + touch /var/plexguide/pgbox.output + touch /var/plexguide/program.temp + touch /var/plexguide/app.list + touch /var/plexguide/pgbox.buildup + + mkdir -p /opt/mycontainers + + if [ "$boxversion" == "personal" ]; then + ansible-playbook /opt/plexguide/menu/pgbox/personal.yml >/dev/null 2>&1 + else question1; fi + + echo "" + echo "💬 Pulling Update Files - Please Wait" + file="/opt/mycontainers/place.holder" + waitvar=0 + while [ "$waitvar" == "0" ]; do + sleep .5 + if [ -e "$file" ]; then waitvar=1; fi + done + +} + +question1() { + + ### Remove Running Apps + while read p; do + sed -i "/^$p\b/Id" /var/plexguide/app.list + done /var/plexguide/app.list + while read p; do + echo "" >>/opt/mycontainers/apps/$p.yml + echo "##PG-personal" >>/opt/mycontainers/apps/$p.yml + + mkdir -p /opt/mycontainers + touch /opt/appdata/plexguide/rclone.conf + done /var/plexguide/pgbox.running + + ### Remove Official Apps + while read p; do + # reminder, need one for custom apps + baseline=$(cat /opt/mycontainers/apps/$p.yml | grep "##PG-personal") + if [ "$baseline" == "" ]; then sed -i -e "/$p/d" /var/plexguide/app.list; fi + done >/var/plexguide/program.temp + echo -n " " >>/var/plexguide/program.temp + num=$((num + 1)) + if [[ "$num" == "7" ]]; then + num=0 + echo " " >>/var/plexguide/program.temp + fi + done ") + if [ "$current" != "" ]; then queued && question1; fi + + current=$(cat /var/plexguide/pgbox.running | grep "\<$typed\>") + if [ "$current" != "" ]; then exists && question1; fi + + current=$(cat /var/plexguide/program.temp | grep "\<$typed\>") + if [ "$current" == "" ]; then badinput1 && question1; fi + + part1 +} + +part1() { + echo "$typed" >>/var/plexguide/pgbox.buildup + num=0 + + touch /var/plexguide/pgbox.output && rm -rf /var/plexguide/pgbox.output + + while read p; do + echo -n $p >>/var/plexguide/pgbox.output + echo -n " " >>/var/plexguide/pgbox.output + if [[ "$num" == 7 ]]; then + num=0 + echo " " >>/var/plexguide/pgbox.output + fi + done /tmp/program_var + + bash /opt/mycontainers/apps/image/_image.sh + + # CName & Port Execution + bash /opt/plexguide/menu/pgbox/cname.sh + done /var/plexguide/boxpersonal.user + echo "$boxrepo" >/var/plexguide/boxpersonal.repo + echo "$boxbranch" >/var/plexguide/boxpersonal.branch + pinterface + ;; + 2) + existcheck=$(git ls-remote --exit-code -h "https://github.com/$boxuser/$boxrepo" | grep "$boxbranch") + if [ "$existcheck" == "" ]; then + echo + read -p '💬 Exiting! Forked Version Does Not Exist! | Press [ENTER]: ' typed /tmp/output.info +mainbanner diff --git a/menu/pgbox/personal/personal.yml b/menu/pgbox/personal/personal.yml new file mode 100644 index 00000000..dcc7e9bf --- /dev/null +++ b/menu/pgbox/personal/personal.yml @@ -0,0 +1,32 @@ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: Check if Image Variable Exists + stat: + path: '/opt/mycontainers' + register: pathcheck + + - name: 'Transfer Image Variable' + shell: 'rm -rf /opt/mycontainers' + when: pathcheck.stat.exists + + - name: Register User for Personal Repo + shell: 'cat /var/plexguide/boxpersonal.user' + register: boxuser + + - name: Register Personal Repo + shell: 'cat /var/plexguide/boxpersonal.repo' + register: boxrepo + + - name: Register Personal Branch + shell: 'cat /var/plexguide/boxpersonal.branch' + register: boxbranch + + - name: 'Cloning {{boxuser.stdout}} Apps' + git: + repo: 'https://github.com/{{boxuser.stdout}}/{{boxrepo.stdout}}' + dest: '/opt/mycontainers' + clone: yes + version: '{{boxbranch.stdout}}' + force: yes diff --git a/menu/pgbox/remove/removal.sh b/menu/pgbox/remove/removal.sh new file mode 100644 index 00000000..1e7f191a --- /dev/null +++ b/menu/pgbox/remove/removal.sh @@ -0,0 +1,136 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +rm -rf /tmp/backup.build 1>/dev/null 2>&1 +rm -rf /tmp/backup.list 1>/dev/null 2>&1 +rm -rf /tmp/backup.final 1>/dev/null 2>&1 + +docker ps --format '{{.Names}}' >/tmp/backup.list +sed -i -e "/traefik/d" /tmp/backup.list +sed -i -e "/watchtower/d" /tmp/backup.list +sed -i -e "/wp-*/d" /tmp/backup.list +sed -i -e "/x2go*/d" /tmp/backup.list +sed -i -e "/plexguide/d" /tmp/backup.list +sed -i -e "/cloudplow/d" /tmp/backup.list +sed -i -e "/phlex/d" /tmp/backup.list + +#### Commenting Out To Let User See +num=0 +while read p; do + let "num++" + echo -n $p >>/tmp/backup.final + echo -n " " >>/tmp/backup.final + if [ "$num" == 7 ]; then + num=0 + echo " " >>/tmp/backup.final + fi +done ") +if [ "$tcheck" == "" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ WARNING! - Type an Application Name! Case Senstive! Restarting! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 3 + bash /opt/plexguide/menu/removal/removal.sh + exit +fi + +if [ "$typed" == "" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ WARNING! - The App Name Cannot Be Blank! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 3 + bash /opt/traefik/tld.sh + exit +fi + +tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +💎 PASS: Uninstalling - $typed +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF +sleep 1.5 + +tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🍖 NOM NOM - Stopping | Removing > $typed Docker Container +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF +sleep .5 + +docker stop $typed 1>/dev/null 2>&1 +docker rm $typed 1>/dev/null 2>&1 + +tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🍖 NOM NOM - Removing /opt/appdata/$typed +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF +sleep 1 +rm -rf /opt/appdata/$typed + +file="/opt/coreapps/apps/$typed.yml" +if [ -e "$file" ]; then + check=$(cat /opt/coreapps/apps/$typed.yml | grep '##PG-Community') + if [ "$check" == "##PG-Community" ]; then rm -r /opt/communityapps/apps/$typed.yml; fi + rm -rf /var/plexguide/community.app +fi + +sleep 1.5 + +tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅️ PASS: Uninstalled - $typed - Exiting! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF +sleep 2 diff --git a/menu/pgbox/select.sh b/menu/pgbox/select.sh new file mode 100644 index 00000000..1a048905 --- /dev/null +++ b/menu/pgbox/select.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +GCEtest(){ +gce=$(cat /var/plexguide/pg.server.deploy) + +if [[ $gce == "feeder" ]]; then +mainstart2 +else mainstart1; fi +} + +mainstart1() { + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 Box Apps Interface Selection +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +💬 PTS Box installs a series of Core and Community applications! + +[1] PTS : Core +[2] PTS : Community +-------------------------------- +[3] Apps : Personal Forks +[4] Apps : Removal + +[Z] Exit + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + + # Standby + read -p '↘️ Type Number | Press [ENTER]: ' typed /var/plexguide/pgcloner.rolename +echo 'BlitzGCE' >/var/plexguide/pgcloner.roleproper +echo 'BlitzGCE' >/var/plexguide/pgcloner.projectname +echo 'master' >/var/plexguide/pgcloner.projectversion +echo 'blitzgce.sh' >/var/plexguide/pgcloner.startlink + +#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +echo "💬 Blitz GCE scripts are setup so that users can deploy any +Google Cloud Edition container to act as as feeder between two to +three months!" >/var/plexguide/pgcloner.info +#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +### START PROCESS +bash /opt/plexguide/menu/pgcloner/corev2/main.sh diff --git a/menu/pgcloner/core/main.sh b/menu/pgcloner/core/main.sh new file mode 100644 index 00000000..41241c20 --- /dev/null +++ b/menu/pgcloner/core/main.sh @@ -0,0 +1,150 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +# FUNCTIONS START ############################################################## +source /opt/plexguide/menu/functions/functions.sh + +rolename=$(cat /var/plexguide/pgcloner.rolename) +roleproper=$(cat /var/plexguide/pgcloner.roleproper) +projectname=$(cat /var/plexguide/pgcloner.projectname) +projectversion=$(cat /var/plexguide/pgcloner.projectversion) + +mkdir -p "/opt/$rolename" + +initial() { + ansible-playbook "/opt/plexguide/menu/pgcloner/core/primary.yml" + echo "" + echo "💬 Pulling Update Files - Please Wait" + file="/opt/$rolename/place.holder" + waitvar=0 + while [ "$waitvar" == "0" ]; do + sleep .5 + if [ -e "$file" ]; then waitvar=1; fi + done +} + +custom() { + mkdir -p "/opt/$rolename" + ansible-playbook "/opt/plexguide/menu/pgcloner/core/personal.yml" + + echo "" + echo "💬 Pulling Update Files - Please Wait" + file="/opt/$rolename/place.holder" + waitvar=0 + while [ "$waitvar" == "0" ]; do + sleep .5 + if [ -e "$file" ]; then waitvar=1; fi + done +} + +mainbanner() { + clonerinfo=$(cat /var/plexguide/pgcloner.info) + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 $roleproper +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +$clonerinfo + +[1] Utilize $roleproper - PGBlitz's +[2] Utilize $roleproper - Personal (Forked) + +[Z] Exit + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + + read -p 'Type a Selection | Press [ENTER]: ' typed /var/plexguide/$rolename.user + echo "$branch" >/var/plexguide/$rolename.branch + pinterface + ;; + 2) + existcheck=$(git ls-remote --exit-code -h "https://github.com/$user/$projectname" | grep "$branch") + if [ "$existcheck" == "" ]; then + echo + read -p '💬 Exiting! Forked Version Does Not Exist! | Press [ENTER]: ' typed /tmp/output.info +mainbanner diff --git a/menu/pgcloner/core/personal.yml b/menu/pgcloner/core/personal.yml new file mode 100644 index 00000000..d447c4cc --- /dev/null +++ b/menu/pgcloner/core/personal.yml @@ -0,0 +1,26 @@ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: Register Role + shell: 'cat /var/plexguide/pgcloner.projectname' + register: pname + + - name: Register Role + shell: 'cat /var/plexguide/pgcloner.rolename' + register: prole + + - name: Register User - Personal + shell: 'cat /var/plexguide/{{prole.stdout}}.user' + register: user + + - name: Register Branch - Personal + shell: 'cat /var/plexguide/{{prole.stdout}}.branch' + register: branch + + - name: 'Cloning Personal Forked Role' + git: + repo: 'https://github.com/{{user.stdout}}/{{pname.stdout}}' + dest: '/opt/{{prole.stdout}}' + version: '{{branch.stdout}}' + force: yes diff --git a/menu/pgcloner/core/primary.yml b/menu/pgcloner/core/primary.yml new file mode 100644 index 00000000..df0bb771 --- /dev/null +++ b/menu/pgcloner/core/primary.yml @@ -0,0 +1,31 @@ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: Register Project Name + shell: 'cat /var/plexguide/pgcloner.projectname' + register: pname + + - name: Register Role + shell: 'cat /var/plexguide/pgcloner.rolename' + register: prole + + - name: Register Project Version + shell: 'cat /var/plexguide/pgcloner.projectversion' + register: pversion + + - name: Check if Path Exists + stat: + path: '/opt/{{prole.stdout}}' + register: pathcheck + + - name: 'Transfer Image Variable' + shell: 'rm -rf /opt/{{prole.stdout}}' + when: pathcheck.stat.exists + + - name: Clone Role + git: + repo: 'https://github.com/PTS-Team/{{pname.stdout}}' + dest: '/opt/{{prole.stdout}}' + version: '{{pversion.stdout}}' + force: yes diff --git a/menu/pgcloner/corev2/main.sh b/menu/pgcloner/corev2/main.sh new file mode 100644 index 00000000..ea7d948b --- /dev/null +++ b/menu/pgcloner/corev2/main.sh @@ -0,0 +1,158 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +# FUNCTIONS START ############################################################## +source /opt/plexguide/menu/functions/functions.sh + +rolename=$(cat /var/plexguide/pgcloner.rolename) +roleproper=$(cat /var/plexguide/pgcloner.roleproper) +projectname=$(cat /var/plexguide/pgcloner.projectname) +projectversion=$(cat /var/plexguide/pgcloner.projectversion) +startlink=$(cat /var/plexguide/pgcloner.startlink) + +mkdir -p "/opt/$rolename" + +initial() { + ansible-playbook "/opt/plexguide/menu/pgcloner/corev2/primary.yml" + echo "" + echo "💬 Pulling Update Files - Please Wait" + file="/opt/$rolename/place.holder" + waitvar=0 + while [ "$waitvar" == "0" ]; do + sleep .5 + if [ -e "$file" ]; then waitvar=1; fi + done + bash /opt/${rolename}/${startlink} +} + +custom() { + mkdir -p "/opt/$rolename" + ansible-playbook "/opt/plexguide/menu/pgcloner/corev2/personal.yml" + + echo "" + echo "💬 Pulling Update Files - Please Wait" + file="/opt/$rolename/place.holder" + waitvar=0 + while [ "$waitvar" == "0" ]; do + sleep .5 + if [ -e "$file" ]; then waitvar=1; fi + done + bash /opt/${rolename}/${startlink} +} + +mainbanner() { + clonerinfo=$(cat /var/plexguide/pgcloner.info) + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 $roleproper +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +$clonerinfo + +[1] Utilize $roleproper +[2] Utilize $roleproper - Personal (Forked) + +[Z] Exit + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + read -p 'Type a Selection | Press [ENTER]: ' typed /var/plexguide/$rolename.user + echo "$branch" >/var/plexguide/$rolename.branch + pinterface + ;; + 2) + existcheck=$(git ls-remote --exit-code -h "https://github.com/$user/$projectname" | grep "$branch") + if [ "$existcheck" == "" ]; then + echo + read -p '💬 Exiting! Forked Version Does Not Exist! | Press [ENTER]: ' typed /tmp/output.info +mainbanner diff --git a/menu/pgcloner/corev2/personal.yml b/menu/pgcloner/corev2/personal.yml new file mode 100644 index 00000000..d447c4cc --- /dev/null +++ b/menu/pgcloner/corev2/personal.yml @@ -0,0 +1,26 @@ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: Register Role + shell: 'cat /var/plexguide/pgcloner.projectname' + register: pname + + - name: Register Role + shell: 'cat /var/plexguide/pgcloner.rolename' + register: prole + + - name: Register User - Personal + shell: 'cat /var/plexguide/{{prole.stdout}}.user' + register: user + + - name: Register Branch - Personal + shell: 'cat /var/plexguide/{{prole.stdout}}.branch' + register: branch + + - name: 'Cloning Personal Forked Role' + git: + repo: 'https://github.com/{{user.stdout}}/{{pname.stdout}}' + dest: '/opt/{{prole.stdout}}' + version: '{{branch.stdout}}' + force: yes diff --git a/menu/pgcloner/corev2/primary.yml b/menu/pgcloner/corev2/primary.yml new file mode 100644 index 00000000..df0bb771 --- /dev/null +++ b/menu/pgcloner/corev2/primary.yml @@ -0,0 +1,31 @@ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: Register Project Name + shell: 'cat /var/plexguide/pgcloner.projectname' + register: pname + + - name: Register Role + shell: 'cat /var/plexguide/pgcloner.rolename' + register: prole + + - name: Register Project Version + shell: 'cat /var/plexguide/pgcloner.projectversion' + register: pversion + + - name: Check if Path Exists + stat: + path: '/opt/{{prole.stdout}}' + register: pathcheck + + - name: 'Transfer Image Variable' + shell: 'rm -rf /opt/{{prole.stdout}}' + when: pathcheck.stat.exists + + - name: Clone Role + git: + repo: 'https://github.com/PTS-Team/{{pname.stdout}}' + dest: '/opt/{{prole.stdout}}' + version: '{{pversion.stdout}}' + force: yes diff --git a/menu/pgcloner/pgclone.sh b/menu/pgcloner/pgclone.sh new file mode 100644 index 00000000..4a98c847 --- /dev/null +++ b/menu/pgcloner/pgclone.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +### FILL OUT THIS AREA ### +echo 'pgclone' >/var/plexguide/pgcloner.rolename +echo 'PTS-Clone' >/var/plexguide/pgcloner.roleproper +echo 'PTS-Clone' >/var/plexguide/pgcloner.projectname +echo 'final' >/var/plexguide/pgcloner.projectversion +echo 'pgclone.sh' >/var/plexguide/pgcloner.startlink + +#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +echo "💬 rClone utilizes RClone's Mounts + MergerFS's Union" >/var/plexguide/pgcloner.info +#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +### START PROCESS +bash /opt/plexguide/menu/pgcloner/corev2/main.sh diff --git a/menu/pgcloner/pgpress.sh b/menu/pgcloner/pgpress.sh new file mode 100644 index 00000000..7193ca9f --- /dev/null +++ b/menu/pgcloner/pgpress.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +### FILL OUT THIS AREA ### +echo 'pgpress' >/var/plexguide/pgcloner.rolename +echo 'PTS-WordPress' >/var/plexguide/pgcloner.roleproper +echo 'PTS-WordPress' >/var/plexguide/pgcloner.projectname +echo 'master' >/var/plexguide/pgcloner.projectversion +echo 'pressmain.sh' >/var/plexguide/pgcloner.startlink + +#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +echo "💬 PGPress is a combined group of services that enables the user to +deploy their own wordpress websites; including the use of other multiple +instances!" >/var/plexguide/pgcloner.info +#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +### START PROCESS +bash /opt/plexguide/menu/pgcloner/corev2/main.sh diff --git a/menu/pgcloner/pgshield.sh b/menu/pgcloner/pgshield.sh new file mode 100644 index 00000000..dc01e8df --- /dev/null +++ b/menu/pgcloner/pgshield.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +### FILL OUT THIS AREA ### +echo 'pgshield' >/var/plexguide/pgcloner.rolename +echo 'PTS-Shield' >/var/plexguide/pgcloner.roleproper +echo 'PTS-Shield' >/var/plexguide/pgcloner.projectname +echo 'master' >/var/plexguide/pgcloner.projectversion +echo 'pgshield.sh' >/var/plexguide/pgcloner.startlink + +#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +echo "💬 Shield protects users by deploying adding Google +Authentication to all the containers for protection!" >/var/plexguide/pgcloner.info +#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +### START PROCESS +bash /opt/plexguide/menu/pgcloner/corev2/main.sh diff --git a/menu/pgcloner/pgvault-protected.sh b/menu/pgcloner/pgvault-protected.sh new file mode 100644 index 00000000..aa3079e0 --- /dev/null +++ b/menu/pgcloner/pgvault-protected.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +### FILL OUT THIS AREA ### +echo 'pgvault' >/var/plexguide/pgcloner.rolename +echo 'PTS-Vault' >/var/plexguide/pgcloner.roleproper +echo 'PTS-Vault' >/var/plexguide/pgcloner.projectname +echo 'master' >/var/plexguide/pgcloner.projectversion +echo 'pgvault-protected.sh' >/var/plexguide/pgcloner.startlink + +#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +echo "💬 Backup & Resrore is a combined group of services that utilizes the backup +and restore processes, which enables the safe storage and transport through +the use of Google Drive in a hasty and efficient manner!" >/var/plexguide/pgcloner.info +#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +### START PROCESS +bash /opt/plexguide/menu/pgcloner/corev2/main.sh diff --git a/menu/pgcloner/pgvault.sh b/menu/pgcloner/pgvault.sh new file mode 100644 index 00000000..d7fb71b0 --- /dev/null +++ b/menu/pgcloner/pgvault.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +### FILL OUT THIS AREA ### +echo 'pgvault' >/var/plexguide/pgcloner.rolename +echo 'PTS-Vault' >/var/plexguide/pgcloner.roleproper +echo 'PTS-Vault' >/var/plexguide/pgcloner.projectname +echo 'master' >/var/plexguide/pgcloner.projectversion +echo 'pgvault.sh' >/var/plexguide/pgcloner.startlink + +#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +echo "💬 Vault is a combined group of services that utilizes the backup +and restore processes, which enables the safe storage and transport through +the use of Google Drive in a hasty and efficient manner!" >/var/plexguide/pgcloner.info +#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +### START PROCESS +bash /opt/plexguide/menu/pgcloner/corev2/main.sh diff --git a/menu/pgcloner/solo/pgui.sh b/menu/pgcloner/solo/pgui.sh new file mode 100644 index 00000000..62a658a6 --- /dev/null +++ b/menu/pgcloner/solo/pgui.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +### FILL OUT THIS AREA ### +echo 'pgui' >/var/plexguide/pgcloner.rolename +echo 'UI' >/var/plexguide/pgcloner.roleproper +echo 'BlitzUI' >/var/plexguide/pgcloner.projectname +echo 'v8.6' >/var/plexguide/pgcloner.projectversion + +### START PROCESS +ansible-playbook /opt/plexguide/menu/pgcloner/core/primary.yml diff --git a/menu/pgcloner/traefik.sh b/menu/pgcloner/traefik.sh new file mode 100644 index 00000000..6396d9ed --- /dev/null +++ b/menu/pgcloner/traefik.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +### FILL OUT THIS AREA ### +echo 'traefik' >/var/plexguide/pgcloner.rolename +echo 'Traefik' >/var/plexguide/pgcloner.roleproper +echo 'Traefik' >/var/plexguide/pgcloner.projectname +echo 'master' >/var/plexguide/pgcloner.projectversion +echo 'traefik.sh' >/var/plexguide/pgcloner.startlink + +#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +echo "💬 Traefik is a modern HTTP reverse proxy and load balancer that makes +deploying microservices easy. It serves as a reverse proxy that enables a +user to mass obtain https (secure) certificates for all their containers" >/var/plexguide/pgcloner.info +#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +### START PROCESS +bash /opt/plexguide/menu/pgcloner/corev2/main.sh diff --git a/menu/pggce/gcechecker.sh b/menu/pggce/gcechecker.sh new file mode 100644 index 00000000..1c491fd5 --- /dev/null +++ b/menu/pggce/gcechecker.sh @@ -0,0 +1,173 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +touch /var/plexguide/gce.done +### NOTE THIS IS JUST A COPY - MAIN ONE SITE IN MAIN REPO - THIS IS JUST FOR INFO +gcheck=$(dnsdomainname | tail -c 10) +file1="/dev/nvme0n1" +file2="/var/plexguide/gce.check" + + if [[ $EUID -ne 0 ]]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ You Must Execute as a SUDO USER (with sudo) or as ROOT! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + exit 1 + fi + +file3="$(tail -n 1 /var/plexguide/gce.done)" +file3b="/var/plexguide/gce.done" + +if [[ "$file3" == "1" ]]; then + tee <<-EOF + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + 📂 Google Cloud Feeder Edition SET! + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + NVME already mounted on /mnt with size $(df -h /mnt/ --total --local -x tmpfs | grep 'total' | awk '{print $2}') + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + EOF + exit + +elif [[ "$file3b" != "1" ]]; then + + if [ "$gcheck" == ".internal" ]; then + tee <<-EOF + + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + 📂 Google Cloud Feeder Edition SET! + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ⚡ Google Cloud Instance Detected! + + ⚠️ NOTE: Setting Up the NVME Drive For You! Please Wait! + ⚠️ NOTE: Please don't close it ! + + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + EOF + apt-get install mdadm --no-install-recommends -yqq 2>&1 >>/dev/null + export DEBIAN_FRONTEND=noninteractive + #Check for NVME + lsblk | grep nvme | awk '{print $1}' >/var/plexguide/nvme.log + lsblk | grep nvme | awk '{print $1}' >/var/plexguide/nvmeraid.log + sed -i 's/nvme0n//g' /var/plexguide/nvmeraid.log + #Check for NVME + nvme="$(tail -n1 /var/plexguide/nvmeraid.log)" + + if [[ "$nvme" == "2" ]]; then + mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/nvme0n1 /dev/nvme0n2 + mkfs.ext4 -F /dev/md0 + mkdir -p /mnt + mount /dev/md0 /mnt + sed -i '$ a\/dev/md0 /mnt ext4 discard,defaults,nobarrier,nofail 0 0' /etc/fstab + chown -cR 1000:1000 /mnt + tune2fs -m 0 /dev/md0 + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo "✅ PASSED ! NVME RAID0 Creator with 2 NVMEs as RAID0 - finish" + echo "✅ PASSED ! HDD Space now :" $(df -h /mnt/ --total --local -x tmpfs | grep 'total' | awk '{print $2}') + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo -e "1" >/var/plexguide/gce.done + sleep 2 + elif [[ "$nvme" == "3" ]]; then + mdadm --create /dev/md0 --level=0 --raid-devices=3 /dev/nvme0n1 /dev/nvme0n2 /dev/nvme0n3 + mkfs.ext4 -F /dev/md0 + mkdir -p /mnt + mount /dev/md0 /mnt + sed -i '$ a\/dev/md0 /mnt ext4 discard,defaults,nobarrier,nofail 0 0' /etc/fstab + chown -cR 1000:1000 /mnt + tune2fs -m 0 /dev/md0 + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo "✅ PASSED ! NVME RAID0 Creator with 3 NVMEs as RAID0 - finish" + echo "✅ PASSED ! HDD Space now :" $(df -h /mnt/ --total --local -x tmpfs | grep 'total' | awk '{print $2}') + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo -e "1" >/var/plexguide/gce.done + sleep 2 + elif [[ "$nvme" == "4" ]]; then + mdadm --create /dev/md0 --level=5 --raid-devices=4 /dev/nvme0n1 /dev/nvme0n2 /dev/nvme0n3 /dev/nvme0n4 + mkfs.ext4 -F /dev/md0 + mkdir -p /mnt + mount /dev/md0 /mnt + sed -i '$ a\/dev/md0 /mnt ext4 discard,defaults,nobarrier,nofail 0 0' /etc/fstab + chown -cR 1000:1000 /mnt + tune2fs -m 0 /dev/md0 + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo "✅ PASSED ! NVME RAID0 Creator with 4 NVMEs as RAID5 - finish" + echo "✅ PASSED ! HDD Space now :" "$(df -h /mnt/ --total --local -x tmpfs | grep 'total' | awk '{print $2}')" + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + sleep 2 + echo -e "1" >/var/plexguide/gce.done + elif [[ "$nvme" == "1" ]]; then + sleep 3 + mkfs.ext4 -F /dev/nvme0n1 1>/dev/null 2>&1 + mount -o discard,defaults,nobarrier /dev/nvme0n1 /mnt + chmod a+w /mnt 1>/dev/null 2>&1 + echo UUID=$(blkid | grep nvme0n1 | cut -f2 -d'"') /mnt ext4 discard,defaults,nobarrier,nofail 0 2 | tee -a /etc/fstab + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo "✅ PASSED ! NVME formated and setup is done" + echo "✅ PASSED ! HDD Space now :" $(df -h /mnt/ --total --local -x tmpfs | grep 'total' | awk '{print $2}') + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo -e "1" >/var/plexguide/gce.done + else + echo "nothing to do" + fi + + touch /var/plexguide/gce.check + rm -rf /var/plexguide/gce.failed 1>/dev/null 2>&1 + rm -rf /var/plexguide/gce.false 1>/dev/null 2>&1 + rm -rf /var/plexguide/nvme.log 1>/dev/null 2>&1 + rm -rf /var/plexguide/nvmeraid.log 1>/dev/null 2>&1 + + echo "feeder" >/var/plexguide/pg.server.deploy + cat /var/plexguide/pg.edition >/var/plexguide/pg.edition.stored + + tee <<-EOF + + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + 📂 GCE Harddrive Deployed! + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ⚡ Automatically Setting Google Feeder Edition (GCE) + + ⚠️ Please Wait! + + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + EOF + + sleep 6 + elif [ ! -e "$file1" ] && [ ! -e "$file2" ] && [ "$gcheck" == ".internal" ]; then + tee <<-EOF + + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + 📂 Google Cloud Feeder Edition Failed! + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ⚡ Google Cloud Instance Detected, but you Failed to setup an NVME + drive per the wiki! This mistake only occurs on manual GCE + deployments. Most likely you setup an SSD instead! The install will + continue, but this will fail! Wipe the box and setup again with an + NVME Drive! + + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + EOF + read -p 'Press [ENTER] to Continue! ' typed /dev/null 2>&1 + rm -rf /var/plexguide/gce.false 1>/dev/null 2>&1 + rm -rf /var/plexguide/nvme.log 1>/dev/null 2>&1 + rm -rf /var/plexguide/nvmeraid.log >/dev/null 2>&1 + else + touch /var/plexguide/gce.false + fi +else +echo "beware of this stupid lines" + +fi diff --git a/menu/pgscan/pgscan.sh b/menu/pgscan/pgscan.sh new file mode 100644 index 00000000..89f15e50 --- /dev/null +++ b/menu/pgscan/pgscan.sh @@ -0,0 +1,228 @@ +# KEY VARIABLE RECALL & EXECUTION +mkdir -p /var/plexguide/pgscan +touch /var/plexguide/pgscan/plex.token +touch /var/plexguide/pgscan/plex.pw +touch /var/plexguide/pgscan/plex.user +# FUNCTIONS START ############################################################## +# FIRST FUNCTION +variable() { + file="$1" + if [ ! -e "$file" ]; then echo "$2" >$1; fi +} + +deploycheck() { + dcheck=$(systemctl is-active plex_autoscan.service) + if [ "$dcheck" == "active" ]; then + dstatus="✅ DEPLOYED" + else dstatus="⚠️ NOT DEPLOYED"; fi +} +userstatus() { + userdep=$(cat /var/plexguide/pgscan/plex.pw) + if [ "$userdep" != "" ]; then + ustatus="✅ DEPLOYED" + else ustatus="⚠️ NOT DEPLOYED"; fi +} + +tokenstatus() { + ptokendep=$(cat /var/plexguide/pgscan/plex.token) + if [ "$ptokendep" != "" ]; then + if [[ ! -f "/opt/plex_autoscan/config/config.json" ]]; then + pstatus="❌ DEPLOYED BUT PAS CONFIG MISSING"; + else + PGSELFTEST=$(curl -LI "http://localhost:32400/system?X-Plex-Token=$(cat /opt/plex_autoscan/config/config.json | jq .PLEX_TOKEN | sed 's/"//g')" -o /dev/null -w '%{http_code}\n' -s) + if [[ $PGSELFTEST -ge 200 && $PGSELFTEST -le 299 ]]; then pstatus="✅ DEPLOYED" + else pstatus="❌ DEPLOYED BUT PAS TOKEN FAILED"; fi + fi + else pstatus="⚠️ NOT DEPLOYED"; fi +} + +plexcheck() { + pcheck=$(docker ps --format {{.Names}} | grep "plex") + if [ "$pcheck" == "" ]; then + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ WARNING! - Plex is Not Installed or Running! Exiting! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p 'Confirm Info | PRESS [ENTER] ' typed /dev/null 2>&1 + sleep 2 + ptoken=$(cat /var/plexguide/pgscan/plex.token) + if [ "$ptoken" == "" ]; then + tee <<-EOF +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ WARNING! - Failed to Generate a Valid Plex Token! Exiting Deployment! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p 'Confirm Info | PRESS [ENTER] ' typed /var/plexguide/pgscan/plex.pw + echo "$user" >/var/plexguide/pgscan/plex.user + bash /opt/plexguide/menu/pgscan/scripts/plex_token.sh + token=$(cat /var/plexguide/pgscan/plex.token) + if [ "$token" != "" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅️ Details stored Succeeded! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 4 + else + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ Details Failed! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +NOTE: Process will repeat until you succeed or exit! + +EOF + read -p 'Confirm Info | Press [ENTER] ' typed /tmp/plex_sign_in +X_PLEX_TOKEN=$(sed -n 's/.*\(.*\)<\/authentication-token>.*/\1/p' /tmp/plex_sign_in) +if [ -z "$X_PLEX_TOKEN" ]; then + cat /tmp/plex_sign_in + rm -f /tmp/plex_sign_in + >&2 echo 'Failed to retrieve the X-Plex-Token.' + exit 1 +fi +cp -r $template $templatebackup +echo $X_PLEX_TOKEN >/var/plexguide/pgscan/plex.token + +RAN=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) +echo $RAN >/var/plexguide/pgscan/pgscan.serverpass diff --git a/menu/pgstage/pgstage.yml b/menu/pgstage/pgstage.yml new file mode 100644 index 00000000..b806ba5f --- /dev/null +++ b/menu/pgstage/pgstage.yml @@ -0,0 +1,36 @@ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: 'Check folder exist' + stat: + path: /opt/pgstage + register: stat_result + - debug: + msg: "PTS Check for missing pull" + + - name: 'Cloning PTS Install files' + git: + repo: 'https://github.com/PTS-Team/Install' + dest: '/opt/pgstage' + clone: yes + version: 'master' + force: yes + update: yes + become: yes + + - stat: + path: /opt/pgstage + register: p + - debug: + msg: "Path exists and PTS folder are pulled" + when: p.stat.isdir is defined and p.stat.isdir + + - name: Remove .githube folder and .git files + file: 'path={{item}} state=absent mode=0775 owner=1000 group=1000' + with_items: + - '/opt/pgstage/.git' + - '/opt/pgstage/.github' + - '/opt/pgstage/.gitignore' + - '/opt/pgstage/LICENSE' + - '/opt/pgstage/README.md' \ No newline at end of file diff --git a/menu/pgui/dynamic.yml b/menu/pgui/dynamic.yml new file mode 100644 index 00000000..6397d88e --- /dev/null +++ b/menu/pgui/dynamic.yml @@ -0,0 +1,21 @@ + - name: Update APT package cache + apt: update_cache=yes cache_valid_time=600 + + - name: Upgrade APT to the latest packages + apt: upgrade=dist + register: apt_result + + - name: Install a list of packages + command: apt-get install -y jq dnsutils ctop + register: apt_result + changed_when: "'packages will be installed' in apt_result.stdout" + + - name: Autoremove unused packages + command: apt-get -y autoremove + register: apt_result + changed_when: "'packages will be REMOVED' in apt_result.stdout" + + - name: Purge residual kernel packages + shell: apt-get remove -y --purge $(dpkg -l | grep "^rc\s*linux-image-" | awk '{print $2}' | tr '\n' ' ') + register: apt_result + changed_when: "'packages will be REMOVED' in apt_result.stdout" diff --git a/menu/pgui/gtused.yml b/menu/pgui/gtused.yml new file mode 100644 index 00000000..f182a1a6 --- /dev/null +++ b/menu/pgui/gtused.yml @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Title: PTS Community +# Author: MrDoob +# URL: WTFH >-!-< why you need this ^^ +# GNU: General Public License v3.0 +# +################################################################################ +--- +- cron: + name: Daily G/TDrive used space check | file checker + special_time: 'daily' + job: 'bash /opt/appdata/pgui/gtused.sh' + state: absent + ignore_errors: yes + +- cron: + name: Daily check for mgerfs / rclone new version + special_time: 'daily' + job: 'bash /opt/appdata/pgui/check.sh' + state: present + +- cron: + name: Daily G/TDrive used space checker | file & folder + special_time: 'daily' + job: 'bash /opt/appdata/pgui/gtused.sh' + state: present diff --git a/menu/pgui/localspace.service b/menu/pgui/localspace.service new file mode 100644 index 00000000..35c76b51 --- /dev/null +++ b/menu/pgui/localspace.service @@ -0,0 +1,24 @@ +#!/bin/bash +# +# Title: PGBlitz (G/TDrive used space) +# Author(s): Admin9705 +# Coder: MrDoob +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +[Unit] +Description=Used space | localspace +After=multi-user.target + +[Service] +Type=simple +User=0 +Group=0 +ExecStart=/bin/bash /opt/plexguide/menu/pgui/templates/localspace.sh +TimeoutStopSec=20 +KillMode=process +RemainAfterExit=yes +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/menu/pgui/localspace.yml b/menu/pgui/localspace.yml new file mode 100644 index 00000000..bf61e242 --- /dev/null +++ b/menu/pgui/localspace.yml @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Title: PGBlitz (local space used service) +# YML Author: Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: Check Service's Existance + stat: + path: '/etc/systemd/systemd/localspace.service' + register: pgp + + - name: Stop service + service: + name: localspace + state: stopped + when: pgp.stat.exists + + - name: localspace Service + template: + src: /opt/plexguide/menu/pgui/localspace.service + dest: /etc/systemd/system/localspace.service + force: yes + + - name: Daemon-Reload + systemd: state=stopped name=localspace daemon_reload=yes enabled=no + - name: Start pgscan + systemd: state=started name=localspace enabled=yes diff --git a/menu/pgui/mcdeploy.yml b/menu/pgui/mcdeploy.yml new file mode 100644 index 00000000..962575b8 --- /dev/null +++ b/menu/pgui/mcdeploy.yml @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# YML Author: Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: Check Service's Existance + stat: + path: '/etc/systemd/systemd/mountcheck.service' + register: pgp + + - name: Stop service + service: + name: mountcheck + state: stopped + when: pgp.stat.exists + + - name: MountCheck Service + template: + src: /opt/plexguide/menu/pgui/mountcheck.service + dest: /etc/systemd/system/mountcheck.service + force: yes + + - name: Daemon-Reload + systemd: state=stopped name=mountcheck daemon_reload=yes enabled=no + + - name: Start pgscan + systemd: state=started name=mountcheck enabled=yes diff --git a/menu/pgui/mountcheck.service b/menu/pgui/mountcheck.service new file mode 100644 index 00000000..5e103519 --- /dev/null +++ b/menu/pgui/mountcheck.service @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +[Unit] +Description=MountCheck Service Daemon +After=multi-user.target + +[Service] +Type=simple +User=0 +Group=0 +ExecStart=/bin/bash /opt/plexguide/menu/pgui/mountcheck.sh +TimeoutStopSec=20 +KillMode=process +RemainAfterExit=yes +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/menu/pgui/pgui.yml b/menu/pgui/pgui.yml new file mode 100644 index 00000000..28ec6a2c --- /dev/null +++ b/menu/pgui/pgui.yml @@ -0,0 +1,153 @@ +#!/bin/bash +# +# Title: Community UI +# original Author(s): Admin9705 +# moded from MrDoob for ptSCOMM +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + # FACTS ####################################################################### + - name: 'Set Known Facts' + set_fact: + pgrole: 'pgui' + intport: '80' + extport: '8555' + image: 'mrdoob/dngele:latest' + + # CORE (MANDATORY) ############################################################ + - name: 'Including cron job' + include_tasks: '/opt/plexguide/menu/pgui/templates/_core.yml' + + - name: 'Including cron job' + include_tasks: '/opt/plexguide/menu/pgui/templates/_cron.yml' + + - name: 'Including Tasks' + include_tasks: '/opt/plexguide/menu/pgui/tasks/dynamic.yml' + + # refix the UI ############################################################ + + - name: 'Install File new UI' + template: + src: /opt/plexguide/menu/pgui/templates/index.php + dest: /opt/appdata/pgui/index.php + force: yes + owner: '1000' + group: '1000' + + - name: 'Install File Check mergerfs / rClone' + template: + src: /opt/plexguide/menu/pgui/templates/check.sh + dest: /opt/appdata/pgui/check.sh + force: yes + owner: '1000' + group: '1000' + + - name: 'Install File GTused' + template: + src: /opt/plexguide/menu/pgui/templates/gtused.sh + dest: /opt/appdata/pgui/gtused.sh + force: yes + owner: '1000' + group: '1000' + + - name: 'Install File Mountcheck file' + copy: + src: /opt/plexguide/menu/pgui/templates/mountcheck.sh + dest: /opt/plexguide/menu/pgui/mountcheck.sh + force: yes + + - name: 'Install File Check mergerfs / rClone' + template: + src: /opt/plexguide/menu/pgui/templates/check.sh + dest: /opt/appdata/pgui/check.sh + force: yes + owner: '1000' + group: '1000' + + - name: 'Install File GTused' + template: + src: /opt/plexguide/menu/pgui/templates/gtused.sh + dest: /opt/appdata/pgui/gtused.sh + force: yes + owner: '1000' + group: '1000' + + ### mountcheck replace + + - name: replacing MountCheck Service + template: + src: /opt/plexguide/menu/pgui/templates/mountcheck.service + dest: /etc/systemd/system/mountcheck.service + force: yes + + - name: Daemon-Reload + systemd: state=stopped name=mountcheck daemon_reload=yes enabled=no + + - name: Start pgscan + systemd: state=started name=mountcheck enabled=yes + + ### localspace replace + + - name: replacing localspace Service + template: + src: /opt/plexguide/menu/pgui/templates/localspace.service + dest: /etc/systemd/system/localspace.service + force: yes + + - name: Daemon-Reload + systemd: state=stopped name=localspace daemon_reload=yes enabled=no + + - name: Start pgscan + systemd: state=started name=localspace enabled=yes + + # LABELS ###################################################################### + - name: 'Adding Traefik' + set_fact: + pg_labels: + traefik.enable: 'true' + traefik.port: '{{intport}}' + traefik.frontend.auth.forward.address: '{{gauth}}' + traefik.frontend.rule: 'Host:{{pgrole}}.{{domain.stdout}}{{tldset}}{{cname}}' + traefik.frontend.headers.SSLHost: '{{domain.stdout}}' + traefik.frontend.headers.SSLRedirect: 'true' + traefik.frontend.headers.STSIncludeSubdomains: 'true' + traefik.frontend.headers.STSPreload: 'true' + traefik.frontend.headers.STSSeconds: '315360000' + traefik.frontend.headers.browserXSSFilter: 'true' + traefik.frontend.headers.contentTypeNosniff: 'true' + traefik.frontend.headers.customResponseHeaders: 'X-Robots-Tag:noindex,nofollow,nosnippet,noarchive,notranslate,noimageindex' + traefik.frontend.headers.forceSTSHeader: 'true' + + - name: 'Setting PG Volumes' + set_fact: + pg_volumes: + - '/opt/appdata/pgui/index.php:/var/www/html/index.php' + - '/var/plexguide:/plexguide' + - '/opt/appdata/plexguide:/log' + + - name: 'Setting PG ENV' + set_fact: + pg_env: + PUID: '1000' + PGID: '1000' + + # MAIN DEPLOYMENT ############################################################# + - name: 'Deploying {{pgrole}}' + docker_container: + name: '{{pgrole}}' + image: '{{image}}' + pull: yes + published_ports: + - '{{ports.stdout}}{{extport}}:{{intport}}' + volumes: '{{pg_volumes}}' + env: '{{pg_env}}' + restart_policy: unless-stopped + networks: + - name: plexguide + aliases: + - '{{pgrole}}' + state: started + labels: '{{pg_labels}}' diff --git a/menu/pgui/tasks/dynamic.yml b/menu/pgui/tasks/dynamic.yml new file mode 100644 index 00000000..6397d88e --- /dev/null +++ b/menu/pgui/tasks/dynamic.yml @@ -0,0 +1,21 @@ + - name: Update APT package cache + apt: update_cache=yes cache_valid_time=600 + + - name: Upgrade APT to the latest packages + apt: upgrade=dist + register: apt_result + + - name: Install a list of packages + command: apt-get install -y jq dnsutils ctop + register: apt_result + changed_when: "'packages will be installed' in apt_result.stdout" + + - name: Autoremove unused packages + command: apt-get -y autoremove + register: apt_result + changed_when: "'packages will be REMOVED' in apt_result.stdout" + + - name: Purge residual kernel packages + shell: apt-get remove -y --purge $(dpkg -l | grep "^rc\s*linux-image-" | awk '{print $2}' | tr '\n' ' ') + register: apt_result + changed_when: "'packages will be REMOVED' in apt_result.stdout" diff --git a/menu/pgui/templates/_core.yml b/menu/pgui/templates/_core.yml new file mode 100644 index 00000000..9806f498 --- /dev/null +++ b/menu/pgui/templates/_core.yml @@ -0,0 +1,189 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +# RECALL KEY VARIABLES ######################################################### + +- name: 'Register TLD' + shell: 'cat /var/plexguide/tld.program' + register: toplevel + ignore_errors: True + +- name: Register Domain + shell: 'cat /var/plexguide/server.domain' + register: domain + ignore_errors: True + +- name: Register IP + shell: 'cat /var/plexguide/server.ip' + register: ipaddress + ignore_errors: True + +- name: Register Ports + shell: 'cat /var/plexguide/server.ports' + register: ports + ignore_errors: True + +- name: Register HD Path + shell: 'cat /var/plexguide/server.hd.path' + register: path + ignore_errors: True + +- name: Register Auth Path + shell: 'cat /var/plexguide/server.ht' + register: auth + ignore_errors: True + +- name: Register Program Name + shell: 'cat /tmp/program_var' + register: program + ignore_errors: True + +- name: check if user cname file exists + stat: + path: /var/plexguide/{{pgrole}}.cname + register: ucname_check + +- name: Register user cname + shell: 'cat /var/plexguide/{{pgrole}}.cname' + register: ucname + ignore_errors: True + when: ucname_check.stat.exists == true + +- name: Register CName + set_fact: + cname: "" + +- name: Set cname + set_fact: + cname: ",{{ucname.stdout}}.{{domain.stdout}}" + when: ucname_check.stat.exists == true and ucname.stdout != "" + +- name: check if user port file exists + stat: + path: /var/plexguide/{{pgrole}}.port + register: ueport_check + +- name: Register External Port + shell: 'cat /var/plexguide/{{pgrole}}.port' + register: ueport + ignore_errors: True + when: ueport_check.stat.exists == true + +- name: Change extport + set_fact: + extport: "{{ueport.stdout}}" + when: ueport_check.stat.exists and ueport.stdout != "" + +- name: Remove {{pgrole}} Container + docker_container: + name: '{{pgrole}}' + state: absent + ignore_errors: True + +- name: Storing Role Name + shell: "echo '{{pgrole}}' > /tmp/program_var" + ignore_errors: True + + # APPDATA +- name: 'Creating appdata folder if it does not exist.' + shell: 'mkdir -p /opt/appdata/{{pgrole}}' + +- name: 'Setting ownership on appdata' + shell: 'chown 1000:1000 /opt/appdata/{{pgrole}}' + when: '"plex" in pgrole' + +- name: 'Setting permissions on appdata' + shell: 'chmod 775 /opt/appdata/{{pgrole}}' + when: '"plex" in pgrole' + +- name: 'Setting ownership on appdata recursivley (this can take a while!)' + shell: 'chown -R 1000:1000 /opt/appdata/{{pgrole}}' + when: '"plex" not in pgrole' + +- name: 'Setting permissions on appdata recursivley (this can take a while!)' + shell: 'chmod -R 775 /opt/appdata/{{pgrole}}' + when: '"plex" not in pgrole' + +# OVERWRITE IMAGES ############################################################# +- name: Check if Image Variable Exists + stat: + path: '/var/plexguide/image/{{pgrole}}' + register: imagecheck + +- name: 'Transfer Image Variable' + shell: 'cat /var/plexguide/image/{{pgrole}}' + register: imagetemp + when: imagecheck.stat.exists + +- name: 'If Fact Does Not Match - Disable TLD' + set_fact: + image: '{{imagetemp.stdout}}' + when: imagecheck.stat.exists + +# TOP LEVEL DOMAIN INFO SET #################################################### + +- debug: msg="Stored TLD - {{pgrole}} must match {{toplevel.stdout}} for TLD" + +- name: 'If Fact Matches - Enable TLD' + set_fact: + tldset: ',{{domain.stdout}},www.{{domain.stdout}}' + when: 'toplevel.stdout == pgrole' + +- debug: msg="TLDSET is now for {{toplevel.stdout}}" + when: 'toplevel.stdout == pgrole' + +- name: 'If Fact Does Not Match - Disable TLD' + set_fact: + tldset: '' + when: 'not toplevel.stdout == pgrole' + +- debug: msg="TLD does not apply" + when: 'not toplevel.stdout == pgrole' + +# EXTERNAL PORT FOR END BANNER +- name: Export Internal Port + shell: 'echo {{extport}} > /tmp/program_port' + ignore_errors: True + +# FOR AUTHENTICATION +- name: 'Script Execute Part I' + shell: 'bash /opt/pgshield/drop.sh' + +- name: 'Script Execute Part II' + shell: 'cat /var/plexguide/auth.var' + register: oauth + +- name: 'OAuth Exe' + block: + - name: Check if Anti Auth Variable Exists + stat: + path: '/var/plexguide/auth/{{pgrole}}' + register: authcheck + + - name: 'Auth Check 1' + set_fact: + gauth: 'http://oauth:4181' + when: not authcheck.stat.exists + + - name: 'Auth Check 2' + set_fact: + gauth: '' + when: authcheck.stat.exists + + when: oauth.stdout == 'good' + +- name: 'OAuth Exe' + set_fact: + gauth: '' + when: not oauth.stdout == 'good' + +- debug: msg="OAuth - {{oauth.stdout}}" + +##PG-Core + +##PG-Core diff --git a/menu/pgui/templates/_cron.yml b/menu/pgui/templates/_cron.yml new file mode 100644 index 00000000..68262b47 --- /dev/null +++ b/menu/pgui/templates/_cron.yml @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Authors: Admin9705, Deiteq, and many PGBlitz Contributors +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +- cron: + name: Daily G/TDrive used space check | file checker + special_time: 'daily' + job: 'bash /opt/appdata/pgui/gtused.sh' + state: absent + ignore_errors: yes + +- cron: + name: Daily G/TDrive used space check | file checker + special_time: 'daily' + job: 'bash /opt/appdata/pgui/check.sh' + state: absent + ignore_errors: yes + +- cron: + name: Daily check for mgerfs / rclone new version + special_time: 'daily' + job: 'bash /opt/appdata/pgui/check.sh >/dev/null 2>&1' + state: present + +- cron: + name: Daily G/TDrive used space checker | file & folder + special_time: 'daily' + job: 'bash /opt/appdata/pgui/gtused.sh >/dev/null 2>&1' + state: present diff --git a/menu/pgui/templates/check.sh b/menu/pgui/templates/check.sh new file mode 100644 index 00000000..2a94bac5 --- /dev/null +++ b/menu/pgui/templates/check.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# +# Title: PTS Community +# Author: MrDoob +# URL: WTFH >-!-< why you need this ^^ +# GNU: General Public License v3.0 +# +################################################################################ +mkdir -p /var/plexguide/checkers +rm -rf /var/plexguide/checkers/*.log +#mkdir -p /var/plexguide/checkers + +###mergerfs part +mgversion="$(curl -s https://api.github.com/repos/trapexit/mergerfs/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')" +touch /var/plexguide/checkers/mgfs.log +touch /var/plexguide/checkers/mergerfs.log + +mergfs="$(mergerfs -v | grep 'mergerfs version:' | awk '{print $3}')" +echo "$mergfs" >> /var/plexguide/checkers/mgfs.log + +mgstored="$(tail -n 1 /var/plexguide/checkers/mgfs.log)" + +if [[ "$mgversion" == "$mgstored" ]];then + echo " ✅ No update needed !" >/var/plexguide/checkers/mergerfs.log +elif [[ "$mgversion" != "$mgstored" ]]; then + echo " ⛔ Update possible !" >/var/plexguide/checkers/mergerfs.log +else echo "stupid line" + +fi +##### rclpone part +rcversion="$(curl -s https://api.github.com/repos/rclone/rclone/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')" +touch /var/plexguide/checkers/rclonestored.log +touch /var/plexguide/checkers/rclone.log +rcstored="$(rclone --version | awk '{print $2}' | tail -n 3 | head -n 1 )" +echo "$rcstored" >> /var/plexguide/checkers/rclonestored.log + +rcstored="$(tail -n 1 /var/plexguide/checkers/rclonestored.log)" + +if [[ "$rcversion" == "$rcstored" ]]; then + echo " ✅ No update needed !" >/var/plexguide/checkers/rclone.log +elif [[ "rcversion" != "rcstored" ]]; then + echo " ⛔ Update possible !" >/var/plexguide/checkers/rclone.log +else echo "stupid line" + +fi diff --git a/menu/pgui/templates/dynamic.yml b/menu/pgui/templates/dynamic.yml new file mode 100644 index 00000000..6397d88e --- /dev/null +++ b/menu/pgui/templates/dynamic.yml @@ -0,0 +1,21 @@ + - name: Update APT package cache + apt: update_cache=yes cache_valid_time=600 + + - name: Upgrade APT to the latest packages + apt: upgrade=dist + register: apt_result + + - name: Install a list of packages + command: apt-get install -y jq dnsutils ctop + register: apt_result + changed_when: "'packages will be installed' in apt_result.stdout" + + - name: Autoremove unused packages + command: apt-get -y autoremove + register: apt_result + changed_when: "'packages will be REMOVED' in apt_result.stdout" + + - name: Purge residual kernel packages + shell: apt-get remove -y --purge $(dpkg -l | grep "^rc\s*linux-image-" | awk '{print $2}' | tr '\n' ' ') + register: apt_result + changed_when: "'packages will be REMOVED' in apt_result.stdout" diff --git a/menu/pgui/templates/gtused.sh b/menu/pgui/templates/gtused.sh new file mode 100644 index 00000000..068f36df --- /dev/null +++ b/menu/pgui/templates/gtused.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# +# Title: PGBlitz (G/TDrive used space) +# Author(s): Admin9705 +# Coder: MrDoob +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +#functions +config="/opt/appdata/plexguide/rclone.conf" +log="/var/plexguide" +useragent="$(cat /var/plexguide/uagent)" + +#if else loop for checking what is running + +if grep -q "gdrive:" $config; then + rclone size gdrive: \ + --verbose=1 \ + --fast-list \ + --retries 3 \ + --no-update-modtime \ + --user-agent="$useragent" \ + --timeout=30m \ + --exclude="**encrypt**" \ + --config /opt/appdata/plexguide/rclone.conf | awk '{print $3,$4}' >>$log/gduncrypt.log + sed -i 's/Total size: / /g' $log/gduncrypt.log +fi +sleep 2 +if grep -q "tdrive:" $config; then + rclone size tdrive: \ + --verbose=1 \ + --fast-list \ + --retries 3 \ + --no-update-modtime \ + --user-agent="$useragent" \ + --timeout=30m \ + --exclude="**encrypt**" \ + --config /opt/appdata/plexguide/rclone.conf | awk '{print $3,$4}' >>$log/tduncrypt.log + sed -i 's/Total size: / /g' $log/tduncrypt.log +fi +sleep 2 +if grep -q "gcrypt:" $config; then + rclone size gcrypt: \ + --verbose=1 \ + --fast-list \ + --retries 3 \ + --user-agent="$useragent" \ + --no-update-modtime \ + --timeout=30m \ + --config /opt/appdata/plexguide/rclone.conf | awk '{print $3,$4}' >>$log/gdcrypt.log + sed -i 's/Total size: / /g' $log/gdcrypt.log +fi +sleep 2 +if grep -q "tcrypt:" $config; then + rclone size tcrypt: \ + --verbose=1 \ + --fast-list \ + --retries 3 \ + --user-agent="$useragent" \ + --no-update-modtime \ + --timeout=30m \ + --config /opt/appdata/plexguide/rclone.conf | awk '{print $3,$4}' >>$log/tdcrypt.log + sed -i 's/Total size: / /g' $log/tdcrypt.log +fi diff --git a/menu/pgui/templates/gtused.yml b/menu/pgui/templates/gtused.yml new file mode 100644 index 00000000..419893ef --- /dev/null +++ b/menu/pgui/templates/gtused.yml @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Title: PTS Community +# Author: MrDoob +# URL: WTFH >-!-< why you need this ^^ +# GNU: General Public License v3.0 +# +################################################################################ +--- +- cron: + name: Daily G/TDrive used space check | file checker + special_time: 'daily' + job: 'bash /opt/appdata/pgui/gtused.sh' + state: absent + ignore_errors: yes + +- cron: + name: Daily check for mgerfs / rclone new version + special_time: 'daily' + job: 'bash /opt/appdata/pgui/ckeck.sh' + state: present + +- cron: + name: Daily G/TDrive used space checker | file & folder + special_time: 'daily' + job: 'bash /opt/appdata/pgui/gtused.sh' + state: present \ No newline at end of file diff --git a/menu/pgui/templates/index.php b/menu/pgui/templates/index.php new file mode 100644 index 00000000..e009561c --- /dev/null +++ b/menu/pgui/templates/index.php @@ -0,0 +1,344 @@ + + + + + + + + +Com-UI + + + + + + +
+ + + + + + +
+

+ Community UI
+ Auto-Refreshes Every 10 Seconds +
+
+

+
+
+ + + + + + + + + + + + +
+ + + + + + +
Upload via rClone
+ + + + + + +
+ $output"; +?> +
+
+ + + + + + +
rClone Logs
+ + + + + + +
+ + $output"; +?> +
+ + + + + + +

+ WARNING LOG
+ + + + + + +
+ + $output";?> +
+
+ + + + + + +
RClone | Transport & Checks
+ + + + + + + + + + + + + + + + + + + + + +
  Union - RClone | Mount + $output";?>   Blitz | Move + $output";?>
  /mnt/downloads + $output";?> +   /mnt/move + $output";?>
   mergerfs + $output";?> +   rClone + $output";?>
+
+ + +
+ Basic Information +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  Edition + $output" ?>  Version + $output";?>  ServerID + $output" ?>
  Traefik + $output";?>  GOAuth + $output";?>  PortGuard + $output";?>
  OS + $output";?> +   Ansible + $output";?>   Used Space + $output" ?>
  GCE + $output";?> +   Docker + $output";?>  Disk Space + $output";?>
+
+ + +
+ + + + + + +
GDrive Section
+ + + + + + +
  GDrive - RClone | Mount + $output";?>  GCrypt - RClone | Mount + $output";?>
+
+ + + + + + +
  GDrive /wo Encryption + $output";?>  GDrive /w Encyption + $output";?>
+ + + + + + +
  GDrive /wo Encryption files/folder + $output";?>  GDrive /w Encyption file/folders + $output";?>
+
+ + + + + + +
TDrive Section
+ + + + + + + + + +
  TDrive - RClone | Mount + $output";?>  TCrypt - RClone | Mount + $output";?>
+
+ + + + + + +
  TDrive /wo Encryption + $output";?>   TDrive /w Encryption + $output";?>
+ + + + + + +
  TDrive /wo Encryption files/folders + $output";?>   TDrive /w Encryption files/folders + $output";?>
+
+ + diff --git a/menu/pgui/templates/localspace.service b/menu/pgui/templates/localspace.service new file mode 100644 index 00000000..35c76b51 --- /dev/null +++ b/menu/pgui/templates/localspace.service @@ -0,0 +1,24 @@ +#!/bin/bash +# +# Title: PGBlitz (G/TDrive used space) +# Author(s): Admin9705 +# Coder: MrDoob +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +[Unit] +Description=Used space | localspace +After=multi-user.target + +[Service] +Type=simple +User=0 +Group=0 +ExecStart=/bin/bash /opt/plexguide/menu/pgui/templates/localspace.sh +TimeoutStopSec=20 +KillMode=process +RemainAfterExit=yes +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/menu/pgui/templates/localspace.sh b/menu/pgui/templates/localspace.sh new file mode 100644 index 00000000..edb3a76c --- /dev/null +++ b/menu/pgui/templates/localspace.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# +# Title: PTS Community +# Author: MrDoob +# URL: WTFH >-!-< why you need this ^^ +# GNU: General Public License v3.0 +# +################################################################################ + +# Starting Actions + +startscript() { + + while [ 1 ]; do + + rm -rf /var/plexguide/spaceused.log + + # move and downloads for the UI + + du -sh /mnt/move | awk '{print $1}' >>/var/plexguide/spaceused.log + du -sh /mnt/downloads | awk '{print $1}' >>/var/plexguide/spaceused.log + + sleep 60 + done + +} + +# keeps the function in a loop +cheeseballs=0 +while [[ "$cheeseballs" == "0" ]]; do startscript; done diff --git a/menu/pgui/templates/localspace.yml b/menu/pgui/templates/localspace.yml new file mode 100644 index 00000000..e4ba2aad --- /dev/null +++ b/menu/pgui/templates/localspace.yml @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Title: PGBlitz (local space used service) +# YML Author: Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: Check Service's Existance + stat: + path: '/etc/systemd/systemd/localspace.service' + register: pgp + + - name: Stop service + service: + name: localspace + state: stopped + when: pgp.stat.exists + + - name: localspace Service + template: + src: /opt/plexguide/menu/pgui/templates/localspace.service + dest: /etc/systemd/system/localspace.service + force: yes + + - name: Daemon-Reload + systemd: state=stopped name=localspace daemon_reload=yes enabled=no + - name: Start pgscan + systemd: state=started name=localspace enabled=yes diff --git a/menu/pgui/templates/mcdeploy.yml b/menu/pgui/templates/mcdeploy.yml new file mode 100644 index 00000000..962575b8 --- /dev/null +++ b/menu/pgui/templates/mcdeploy.yml @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# YML Author: Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: Check Service's Existance + stat: + path: '/etc/systemd/systemd/mountcheck.service' + register: pgp + + - name: Stop service + service: + name: mountcheck + state: stopped + when: pgp.stat.exists + + - name: MountCheck Service + template: + src: /opt/plexguide/menu/pgui/mountcheck.service + dest: /etc/systemd/system/mountcheck.service + force: yes + + - name: Daemon-Reload + systemd: state=stopped name=mountcheck daemon_reload=yes enabled=no + + - name: Start pgscan + systemd: state=started name=mountcheck enabled=yes diff --git a/menu/pgui/templates/mountcheck.service b/menu/pgui/templates/mountcheck.service new file mode 100644 index 00000000..5e103519 --- /dev/null +++ b/menu/pgui/templates/mountcheck.service @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +[Unit] +Description=MountCheck Service Daemon +After=multi-user.target + +[Service] +Type=simple +User=0 +Group=0 +ExecStart=/bin/bash /opt/plexguide/menu/pgui/mountcheck.sh +TimeoutStopSec=20 +KillMode=process +RemainAfterExit=yes +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/menu/pgui/templates/mountcheck.sh b/menu/pgui/templates/mountcheck.sh new file mode 100644 index 00000000..b4132d8b --- /dev/null +++ b/menu/pgui/templates/mountcheck.sh @@ -0,0 +1,168 @@ +#!/bin/bash +# +# Title: PTS Community +# Author: MrDoob +# URL: WTFH >-!-< why you need this ^^ +# GNU: General Public License v3.0 +# +################################################################################ +mkdir -p /opt/appdata/plexguide/emergency +mkdir -p /opt/appdata/plexguide +rm -rf /opt/appdata/plexguide/emergency/* +sleep 15 +diskspace27=0 +rm -rf /var/plexguide/status.mounts +while true; do + + gdrivecheck=$(systemctl is-active gdrive) + gcryptcheck=$(systemctl is-active gcrypt) + tdrivecheck=$(systemctl is-active tdrive) + tcryptcheck=$(systemctl is-active tcrypt) + pgunioncheck=$(systemctl is-active pgunion) + + pgblitzcheck=$(systemctl is-active pgblitz) + pgmovecheck=$(systemctl is-active pgmove) + + pgblitz=$(systemctl list-unit-files | grep pgblitz.service | awk '{ print $2 }') + pgmove=$(systemctl list-unit-files | grep pgmove.service | awk '{ print $2 }') + + touch /var/plexguide/status.mounts + + status=$(tail -n 1 /var/plexguide/status.mounts) + + if [[ "$pgmove" == "enabled" ]]; then + echo "1" >> /var/plexguide/status.mounts + elif [[ "$pgblitz" == "enabled" ]]; then + echo "2" >> /var/plexguide/status.mounts + else + echo "3" >> /var/plexguide/status.mounts + fi + + if [[ "$status" == "1" ]] ; then + if [[ "$pgmovecheck" != "active" ]]; then + echo " 🔴 Not Operational MOVE" >>/var/plexguide/pg.blitz + else + echo " ✅ Operational MOVE" >>/var/plexguide/pg.blitz + fi + fi + if [[ "$status" == "2" ]] ; then + if [[ "$pgblitzcheck" != "active" ]]; then + echo " 🔴 Not Operational BLITZ" >>/var/plexguide/pg.blitz + else + echo " ✅ Operational BLITZ" >>/var/plexguide/pg.blitz + fi + fi + + if [[ "$status" == "3" ]] ; then + echo " 🔴 Not Operational UPLOADER" >>/var/plexguide/pg.blitz + fi + + # Todo remove the dupes or change to crypt once PGUI is updated + + if [[ "$gdrivecheck" != "active" ]]; then + echo " 🔴 Not Operational" >/var/plexguide/pg.gdrive + else echo " ✅ Operational" >/var/plexguide/pg.gdrive; fi + + if [[ "$gcryptcheck" != "active" ]]; then + echo " 🔴 Not Operational" >/var/plexguide/pg.gcrypt + else echo " ✅ Operational" >/var/plexguide/pg.gcrypt; fi + + if [[ "$tdrivecheck" != "active" ]]; then + echo " 🔴 Not Operational " >/var/plexguide/pg.tdrive + else echo " ✅ Operational" >/var/plexguide/pg.tdrive; fi + + if [[ "$tcryptcheck" != "active" ]]; then + echo " 🔴 Not Operational " >/var/plexguide/pg.tcrypt + else echo " ✅ Operational" >/var/plexguide/pg.tcrypt; fi + + if [[ "$pgunioncheck" != "active" ]]; then + echo " 🔴 Not Operational " >/var/plexguide/pg.union + else echo " ✅ Operational " >/var/plexguide/pg.union; fi + + + # Disk Calculations - 5000000 = 5GB + + leftover=$(df /opt/appdata/plexguide | tail -n +2 | awk '{print $4}') + + if [[ "$leftover" -lt "5000000" ]]; then + diskspace27=1 + echo "Emergency: Primary DiskSpace Under 5GB - Stopped Downloading Programs (i.e. NZBGET, RuTorrent)" >/opt/appdata/plexguide/emergency/message.1 + docker stop nzbget 1>/dev/null 2>&1 + docker stop sabnzbd 1>/dev/null 2>&1 + docker stop rutorrent 1>/dev/null 2>&1 + docker stop deluge 1>/dev/null 2>&1 + docker stop qbittorrent 1>/dev/null 2>&1 + docker stop deluge-vpn 1>/dev/null 2>&1 + docker stop transmission 1>/dev/null 2>&1 + docker stop rflood-vpn 1>/dev/null 2>&1 + docker stop rutorrent-vpn 1>/dev/null 2>&1 + docker stop transmission-vpn 1>/dev/null 2>&1 + docker stop jdownloader2 1>/dev/null 2>&1 + docker stop jd2-openvpn 1>/dev/null 2>&1 + elif [[ "$leftover" -gt "3000000" && "$diskspace27" == "1" ]]; then + docker start nzbget 1>/dev/null 2>&1 + docker start sabnzbd 1>/dev/null 2>&1 + docker start rutorrent 1>/dev/null 2>&1 + docker start deluge 1>/dev/null 2>&1 + docker start qbittorrent 1>/dev/null 2>&1 + docker start deluge-vpn 1>/dev/null 2>&1 + docker start transmission 1>/dev/null 2>&1 + docker start rflood-vpn 1>/dev/null 2>&1 + docker start rutorrent-vpn 1>/dev/null 2>&1 + docker start transmission-vpn 1>/dev/null 2>&1 + docker start jdownloader2 1>/dev/null 2>&1 + docker start jd2-openvpn 1>/dev/null 2>&1 + rm -rf /opt/appdata/plexguide/emergency/message.1 + diskspace27=0 + fi + + ##### Warning for Ports Open with Traefik Deployed + if [[ $(cat /var/plexguide/pg.ports) != "Closed" && $(docker ps --format '{{.Names}}' | grep "traefik") == "traefik" ]]; then + echo "Warning: Traefik deployed with ports open! Server at risk for explotation!" >/opt/appdata/plexguide/emergency/message.a + elif [ -e "/opt/appdata/plexguide/emergency/message.a" ]; then rm -rf /opt/appdata/plexguide/emergency/message.a; fi + + if [[ $(cat /var/plexguide/pg.ports) == "Closed" && $(docker ps --format '{{.Names}}' | grep "traefik") == "" ]]; then + echo "Warning: Apps Cannot Be Accessed! Ports are Closed & Traefik is not enabled! Either deploy traefik or open your ports (which is worst for security)" >/opt/appdata/plexguide/emergency/message.b + elif [ -e "/opt/appdata/plexguide/emergency/message.b" ]; then rm -rf /opt/appdata/plexguide/emergency/message.b; fi + ##### Warning for Bad Traefik Deployment - message.c is tied to traefik showing a status! Do not change unless you know what your doing + touch /opt/appdata/plexguide/traefik.check + domain=$(cat /var/plexguide/server.domain) + + cname="portainer" + if [[ -f "/var/plexguide/portainer.cname" ]]; then + cname=$(cat "/var/plexguide/portainer.cname") + fi + + wget -q "https://${cname}.${domain}" -O "/opt/appdata/plexguide/traefik.check" + if [[ $(cat /opt/appdata/plexguide/traefik.check) == "" && $(docker ps --format '{{.Names}}' | grep traefik) == "traefik" ]]; then + echo "Traefik is Not Deployed Properly! Cannot Reach the Portainer SubDomain!" >/opt/appdata/plexguide/emergency/message.c + else + if [ -e "/opt/appdata/plexguide/emergency/message.c" ]; then + rm -rf /opt/appdata/plexguide/emergency/message.c + fi + fi + ##### Warning for Traefik Rate Limit Exceeded + if [[ $(cat /opt/appdata/plexguide/traefik.check) == "" && $(docker logs traefik | grep "rateLimited") != "" ]]; then + echo "$domain's rated limited exceed | Traefik (LetsEncrypt)! Takes upto one week to clear up (or use a new domain)" >/opt/appdata/plexguide/emergency/message.d + else + if [ -e "/opt/appdata/plexguide/emergency/message.d" ]; then + rm -rf /opt/appdata/plexguide/emergency/message.d + fi + fi + + ################# Generate Output + echo "" >/var/plexguide/emergency.log + + if [[ $(ls /opt/appdata/plexguide/emergency) != "" ]]; then + countmessage=0 + while read p; do + let countmessage++ + echo -n "${countmessage}. " >>/var/plexguide/emergency.log + echo "$(cat /opt/appdata/plexguide/emergency/$p)" >>/var/plexguide/emergency.log + done <<<"$(ls /opt/appdata/plexguide/emergency)" + else + echo "NONE" >/var/plexguide/emergency.log + fi + + sleep 5 +done diff --git a/menu/pgui/templates/pgui.yml b/menu/pgui/templates/pgui.yml new file mode 100644 index 00000000..28ec6a2c --- /dev/null +++ b/menu/pgui/templates/pgui.yml @@ -0,0 +1,153 @@ +#!/bin/bash +# +# Title: Community UI +# original Author(s): Admin9705 +# moded from MrDoob for ptSCOMM +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + # FACTS ####################################################################### + - name: 'Set Known Facts' + set_fact: + pgrole: 'pgui' + intport: '80' + extport: '8555' + image: 'mrdoob/dngele:latest' + + # CORE (MANDATORY) ############################################################ + - name: 'Including cron job' + include_tasks: '/opt/plexguide/menu/pgui/templates/_core.yml' + + - name: 'Including cron job' + include_tasks: '/opt/plexguide/menu/pgui/templates/_cron.yml' + + - name: 'Including Tasks' + include_tasks: '/opt/plexguide/menu/pgui/tasks/dynamic.yml' + + # refix the UI ############################################################ + + - name: 'Install File new UI' + template: + src: /opt/plexguide/menu/pgui/templates/index.php + dest: /opt/appdata/pgui/index.php + force: yes + owner: '1000' + group: '1000' + + - name: 'Install File Check mergerfs / rClone' + template: + src: /opt/plexguide/menu/pgui/templates/check.sh + dest: /opt/appdata/pgui/check.sh + force: yes + owner: '1000' + group: '1000' + + - name: 'Install File GTused' + template: + src: /opt/plexguide/menu/pgui/templates/gtused.sh + dest: /opt/appdata/pgui/gtused.sh + force: yes + owner: '1000' + group: '1000' + + - name: 'Install File Mountcheck file' + copy: + src: /opt/plexguide/menu/pgui/templates/mountcheck.sh + dest: /opt/plexguide/menu/pgui/mountcheck.sh + force: yes + + - name: 'Install File Check mergerfs / rClone' + template: + src: /opt/plexguide/menu/pgui/templates/check.sh + dest: /opt/appdata/pgui/check.sh + force: yes + owner: '1000' + group: '1000' + + - name: 'Install File GTused' + template: + src: /opt/plexguide/menu/pgui/templates/gtused.sh + dest: /opt/appdata/pgui/gtused.sh + force: yes + owner: '1000' + group: '1000' + + ### mountcheck replace + + - name: replacing MountCheck Service + template: + src: /opt/plexguide/menu/pgui/templates/mountcheck.service + dest: /etc/systemd/system/mountcheck.service + force: yes + + - name: Daemon-Reload + systemd: state=stopped name=mountcheck daemon_reload=yes enabled=no + + - name: Start pgscan + systemd: state=started name=mountcheck enabled=yes + + ### localspace replace + + - name: replacing localspace Service + template: + src: /opt/plexguide/menu/pgui/templates/localspace.service + dest: /etc/systemd/system/localspace.service + force: yes + + - name: Daemon-Reload + systemd: state=stopped name=localspace daemon_reload=yes enabled=no + + - name: Start pgscan + systemd: state=started name=localspace enabled=yes + + # LABELS ###################################################################### + - name: 'Adding Traefik' + set_fact: + pg_labels: + traefik.enable: 'true' + traefik.port: '{{intport}}' + traefik.frontend.auth.forward.address: '{{gauth}}' + traefik.frontend.rule: 'Host:{{pgrole}}.{{domain.stdout}}{{tldset}}{{cname}}' + traefik.frontend.headers.SSLHost: '{{domain.stdout}}' + traefik.frontend.headers.SSLRedirect: 'true' + traefik.frontend.headers.STSIncludeSubdomains: 'true' + traefik.frontend.headers.STSPreload: 'true' + traefik.frontend.headers.STSSeconds: '315360000' + traefik.frontend.headers.browserXSSFilter: 'true' + traefik.frontend.headers.contentTypeNosniff: 'true' + traefik.frontend.headers.customResponseHeaders: 'X-Robots-Tag:noindex,nofollow,nosnippet,noarchive,notranslate,noimageindex' + traefik.frontend.headers.forceSTSHeader: 'true' + + - name: 'Setting PG Volumes' + set_fact: + pg_volumes: + - '/opt/appdata/pgui/index.php:/var/www/html/index.php' + - '/var/plexguide:/plexguide' + - '/opt/appdata/plexguide:/log' + + - name: 'Setting PG ENV' + set_fact: + pg_env: + PUID: '1000' + PGID: '1000' + + # MAIN DEPLOYMENT ############################################################# + - name: 'Deploying {{pgrole}}' + docker_container: + name: '{{pgrole}}' + image: '{{image}}' + pull: yes + published_ports: + - '{{ports.stdout}}{{extport}}:{{intport}}' + volumes: '{{pg_volumes}}' + env: '{{pg_env}}' + restart_policy: unless-stopped + networks: + - name: plexguide + aliases: + - '{{pgrole}}' + state: started + labels: '{{pg_labels}}' diff --git a/menu/pgvault/LICENSE b/menu/pgvault/LICENSE new file mode 100644 index 00000000..f288702d --- /dev/null +++ b/menu/pgvault/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/menu/pgvault/autobackup b/menu/pgvault/autobackup new file mode 100644 index 00000000..0ce0b3b5 --- /dev/null +++ b/menu/pgvault/autobackup @@ -0,0 +1,5 @@ +#!/bin/bash + +#### automatic backup apps + +bash / opt/pgvault/autobackup.sh \ No newline at end of file diff --git a/menu/pgvault/autobackup.func b/menu/pgvault/autobackup.func new file mode 100644 index 00000000..fcbac609 --- /dev/null +++ b/menu/pgvault/autobackup.func @@ -0,0 +1,333 @@ +#!/bin/bash +# +# Title: Backup and Restore +# Author(s): Admin9705 +# GNU: General Public License v3.0 +################################################################################ + +runningcheck() { + initial2 + runcheck5=$(docker ps | grep ${program_var}) + if [ "$runcheck5" != "" ]; then running=1; else running=0; fi +} + +initial() { + rm -rf /var/plexguide/pgvault.output 1>/dev/null 2>&1 + rm -rf /var/plexguide/pgvault.buildup 1>/dev/null 2>&1 + rm -rf /var/plexguide/program.temp 1>/dev/null 2>&1 + rm -rf /var/plexguide/app.list 1>/dev/null 2>&1 + rm -rf /var/plexguide/pgvault.output 1>/dev/null 2>&1 + touch /var/plexguide/pgvault.output + touch /var/plexguide/program.temp + touch /var/plexguide/app.list + touch /var/plexguide/pgvault.buildup + touch /var/plexguide/pgvault.output + touch /var/plexguide/rclone.size + space=$(cat /var/plexguide/data.location) + # To Get Used Space + used=$(df -h /opt/appdata/plexguide | tail -n +2 | awk '{print $3}') + # To Get All Space + capacity=$(df -h /opt/appdata/plexguide | tail -n +2 | awk '{print $2}') + # Percentage + percentage=$(df -h /opt/appdata/plexguide | tail -n +2 | awk '{print $5}') +} + +initial2() { + path=$(cat /var/plexguide/server.hd.path) + tarlocation=$(cat /var/plexguide/data.location) + program_size=$(cat /var/plexguide/rclone.size) + program_var=$(cat /tmp/program_var) + server_id=$(cat /var/plexguide/server.id) +} + +final() { + exit +} + +queued() { + echo + read -p "⛔️ ERROR - $typed Already Queued! | Press [ENTER] " typed pgvault.serverlist +} + +pgboxrecall() { + ls -p /opt/coreapps/apps | grep -v / >/var/plexguide/pgvault.apprecall + while read p; do + sed -i "/^$p\b/Id" /var/plexguide/pgvault.apprecall + done >/var/plexguide/pgvault.apprecall + done /dev/null 2>&1 + while read p; do + echo -n $p >>/var/plexguide/program.temp + echo -n " " >>/var/plexguide/program.temp + num=$((num + 1)) + if [ "$num" == 7 ]; then + num=0 + echo " " >>/var/plexguide/program.temp + fi + done /var/plexguide/pgvault.apprecall + while read p; do + sed -i "/^$p\b/Id" /var/plexguide/pgvault.apprecall + done >/var/plexguide/pgvault.buildup + sed -i "/^$typed\b/Id" /var/plexguide/pgvault.apprecall + + num=0 + rm -rf /var/plexguide/pgvault.output 1>/dev/null 2>&1 + while read p; do + echo -n $p >>/var/plexguide/pgvault.output + echo -n " " >>/var/plexguide/pgvault.output + if [ "$num" == 7 ]; then + num=0 + echo " " >>/var/plexguide/pgvault.output + fi + done /tmp/server.list + + ### List Out Apps In Readable Order (One's Not Installed) + num=0 + rm -rf /var/plexguide/program.temp 1>/dev/null 2>&1 + while read p; do + echo -n $p >>/var/plexguide/program.temp + echo -n " " >>/var/plexguide/program.temp + num=$((num + 1)) + if [ "$num" == 7 ]; then + num=0 + echo " " >>/var/plexguide/program.temp + fi + done /tmp/server.select + + if [[ "$server" == "exit" || "$server" == "Exit" || "$server" == "EXIT" || "$server" == "z" || "$server" == "Z" ]]; then exit; fi + + current2=$(cat /tmp/server.list | grep "\<$server\>") + if [ "$current2" == "" ]; then + badserver + serverprime + fi + + tempserver=$server + ls -l /mnt/gdrive/plexguide/backup/$tempserver | awk '{print $9}' | tail -n +2 >/var/plexguide/pgvault.restoreapps + + ### Blank Out Temp List + rm -rf /var/plexguide/pgvault.apprecall 1>/dev/null 2>&1 + touch /var/plexguide/pgvault.apprecall + + while read p; do + basename "$p" .tar >>/var/plexguide/pgvault.apprecall + done /dev/null 2>&1 + touch /var/plexguide/program.temp + mathprime +} + +buildup2() { + echo "$typed" >>/var/plexguide/pgvault.buildup + sed -i "/^$typed\b/Id" /var/plexguide/pgvault.apprecall + + num=0 + rm -rf /var/plexguide/pgvault.output 1>/dev/null 2>&1 + while read p; do + echo -n $p >>/var/plexguide/pgvault.output + echo -n " " >>/var/plexguide/pgvault.output + if [ "$num" == 7 ]; then + num=0 + echo " " >>/var/plexguide/pgvault.output + fi + done /tmp/program_var + # Execute Main Program + backup_process + + sleep 2 + done /tmp/program_var + # Execute Main Program + backup_process + + sleep 2 + done /dev/null 2>&1 + fi + + ###### Start the Backup Process - Backup Locally First + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Zipping Data Locally - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + path=$(cat /var/plexguide/server.hd.path) + tarlocation=$(cat /var/plexguide/data.location) + server_id=$(cat /var/plexguide/server.id) + + tar \ + --warning=no-file-changed --ignore-failed-read --absolute-names --warning=no-file-removed \ + --exclude-from=/opt/plexguide/menu/pgvault/exclude.list \ + -C /opt/appdata/${program_var} -cvf /opt/appdata/plexguide/${program_var}.tar ./ + + ##### Restart Docker Application if was Running Prior + if [ "$running" == "1" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Restarting Docker Application - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + sleep 2 + docker restart $program_var 1>/dev/null 2>&1 + fi + + ###### Backing Up Files to GDrive + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Sending Zipped Data to Google Drive - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + +useragent="$(cat /var/plexguide/uagent)" +bwlimit="$(cat /var/plexguide/blitz.bw)" + +vfs_dcs="$(cat /var/plexguide/vfs_dcs)" +vfs_mt="$(cat /var/plexguide/vfs_mt)" +vfs_t="$(cat /var/plexguide/vfs_t)" +vfs_c="$(cat /var/plexguide/vfs_c)" + + + rclone --config /opt/appdata/plexguide/rclone.conf mkdir gdrive:/plexguide/backup/${server_id} 1>/dev/null 2>&1 + + rclone moveto ${tarlocation}/${program_var}.tar \ + gdrive:/plexguide/backup/${server_id}/${program_var}.tar \ + --config /opt/appdata/plexguide/rclone.conf \ + -v --checksum --stats-one-line --stats 1s --progress \ + --tpslimit=10 \ + --checkers="$vfs_c" \ + --transfers="$vfs_t" \ + --no-traverse \ + --fast-list \ + --bwlimit="$bwlimit" \ + --drive-chunk-size="$vfs_dcs" \ + --user-agent="$useragent" + +##### Remove File Incase +rm -rf ${tarlocation}/${program_var}.tar 1>/dev/null 2>&1 +} \ No newline at end of file diff --git a/menu/pgvault/autobackup.sh b/menu/pgvault/autobackup.sh new file mode 100644 index 00000000..59581522 --- /dev/null +++ b/menu/pgvault/autobackup.sh @@ -0,0 +1,7 @@ +source /opt/plexguide/menu/pgvault/autobackup.func +file="/var/plexguide/restore.id" +if [ ! -e "$file" ]; then + echo "[NOT-SET]" >/var/plexguide/restore.id +fi + +backup_all_start \ No newline at end of file diff --git a/menu/pgvault/exclude.list b/menu/pgvault/exclude.list new file mode 100644 index 00000000..5dbeae2a --- /dev/null +++ b/menu/pgvault/exclude.list @@ -0,0 +1,25 @@ +./database/Library/Application Support/Plex Media Server/Cache/PhotoTranscoder +./database/Library/Application Support/Plex Media Server/Cache/Transcode +./database/Library/Application Support/Plex Media Server/Logs +./database/Library/Application Support/Plex Media Server/Crash Reports +./database/Library/Application Support/Plex Media Server/Metadata/*.bif +./database/Library/Application Support/Plex Media Server/Media/*.bif +./database/Library/Logs/Plex Media Server/ +./database/Library/Application Support/Plex Media Server/Plug-ins +./transcoding-temp +./nzbget/*.log +./radarr/logs +./sonarr/logs +./lidarr/logs +./log +./logs +./Log +./Logs +./backup +./backups +./Backup +./Backups +./transcodes +./Transcodes +*.bif + diff --git a/menu/pgvault/exempt.list b/menu/pgvault/exempt.list new file mode 100644 index 00000000..77c427b2 --- /dev/null +++ b/menu/pgvault/exempt.list @@ -0,0 +1,12 @@ +alltube +netdata +speedtest +dockergc +cloudplow +pgblitz +plexguide +pgrole +oauth +traefik +pgui +watchtower diff --git a/menu/pgvault/functions.sh b/menu/pgvault/functions.sh new file mode 100644 index 00000000..8f320864 --- /dev/null +++ b/menu/pgvault/functions.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +# BAD INPUT +badinput() { + echo + read -p '⛔️ ERROR - Bad Input! | Press [ENTER] ' typed $1; fi +} + +removemounts() { + ansible-playbook /opt/plexguide/menu/remove/mounts.yml +} + +readrcloneconfig() { + touch /opt/appdata/plexguide/rclone.conf + mkdir -p /var/plexguide/rclone/ + + gdcheck=$(cat /opt/appdata/plexguide/rclone.conf | grep gdrive) + if [ "$gdcheck" != "" ]; then + echo "good" >/var/plexguide/rclone/gdrive.status && gdstatus="good" + else echo "bad" >/var/plexguide/rclone/gdrive.status && gdstatus="bad"; fi + + gccheck=$(cat /opt/appdata/plexguide/rclone.conf | grep "remote = gdrive:/encrypt") + if [ "$gccheck" != "" ]; then + echo "good" >/var/plexguide/rclone/gcrypt.status && gcstatus="good" + else echo "bad" >/var/plexguide/rclone/gcrypt.status && gcstatus="bad"; fi + + tdcheck=$(cat /opt/appdata/plexguide/rclone.conf | grep tdrive) + if [ "$tdcheck" != "" ]; then + echo "good" >/var/plexguide/rclone/tdrive.status && tdstatus="good" + else echo "bad" >/var/plexguide/rclone/tdrive.status && tdstatus="bad"; fi + +} + +rcloneconfig() { + rclone config --config /opt/appdata/plexguide/rclone.conf +} + +keysprocessed() { + mkdir -p /opt/appdata/plexguide/keys/processed + ls -1 /opt/appdata/plexguide/keys/processed | wc -l >/var/plexguide/project.keycount +} diff --git a/menu/pgvault/location.sh b/menu/pgvault/location.sh new file mode 100644 index 00000000..1c59eb02 --- /dev/null +++ b/menu/pgvault/location.sh @@ -0,0 +1,120 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ SETTING: Backup Download Location +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Paying attention to your disk space is important! Type the name of your +location is very important! Keep in mind PG does not format the +location for you! + +Examples: +1. /opt/appdata/plexguide +2. /hd2/spongebob + +NOTE: Start with a / and end with no trailing slash! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + +# Standby +read -p 'TYPE the Location & Press [ENTER]: ' typed /dev/null + # Recalls for to check existance + rcheck=$(ls -la $typed | grep "\") + if [ "$rcheck" == "" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ WARNING! - This Location Does Not Exist! Exiting! (Case Senstive) +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + sleep 4 + exit + fi + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅️ PASS: Location! Storing the Name of the Location! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + # Prevents From Repeating + rm -rf $typed/pgcheck + sleep 3 + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌇 PASS: Process Complete! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + echo "$typed" >/var/plexguide/data.location + read -n 1 -s -r -p "Press [ANY] Key to Continue " + +fi diff --git a/menu/pgvault/pgcron b/menu/pgvault/pgcron new file mode 100644 index 00000000..e8166219 --- /dev/null +++ b/menu/pgvault/pgcron @@ -0,0 +1,11 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +source /opt/pgvault/functions.sh +source /opt/pgvault/pgvault.func +initial2 +backup_process diff --git a/menu/pgvault/pgvault.func b/menu/pgvault/pgvault.func new file mode 100644 index 00000000..67ee101f --- /dev/null +++ b/menu/pgvault/pgvault.func @@ -0,0 +1,648 @@ +#!/bin/bash +# +# Title: Backup and Restore +# Author(s): Admin9705 +# GNU: General Public License v3.0 +################################################################################ +runningcheck() { + initial2 + runcheck5=$(docker ps | grep ${program_var}) + if [ "$runcheck5" != "" ]; then running=1; else running=0; fi +} + +initial() { + rm -rf /var/plexguide/pgvault.output 1>/dev/null 2>&1 + rm -rf /var/plexguide/pgvault.buildup 1>/dev/null 2>&1 + rm -rf /var/plexguide/program.temp 1>/dev/null 2>&1 + rm -rf /var/plexguide/app.list 1>/dev/null 2>&1 + rm -rf /var/plexguide/pgvault.output 1>/dev/null 2>&1 + touch /var/plexguide/pgvault.output + touch /var/plexguide/program.temp + touch /var/plexguide/app.list + touch /var/plexguide/pgvault.buildup + touch /var/plexguide/pgvault.output + touch /var/plexguide/rclone.size + space=$(cat /var/plexguide/data.location) + # To Get Used Space + used=$(df -h /opt/appdata/plexguide | tail -n +2 | awk '{print $3}') + # To Get All Space + capacity=$(df -h /opt/appdata/plexguide | tail -n +2 | awk '{print $2}') + # Percentage + percentage=$(df -h /opt/appdata/plexguide | tail -n +2 | awk '{print $5}') +} + +initial2() { + path=$(cat /var/plexguide/server.hd.path) + tarlocation=$(cat /var/plexguide/data.location) + program_size=$(cat /var/plexguide/rclone.size) + program_var=$(cat /tmp/program_var) + server_id=$(cat /var/plexguide/server.id) +} + +final() { + echo + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + read -p '✅ Process Complete! | PRESS [ENTER] ' typed pgvault.serverlist +} + +pgboxrecall() { + ls -p /opt/coreapps/apps | grep -v / >/var/plexguide/pgvault.apprecall + while read p; do + sed -i "/^$p\b/Id" /var/plexguide/pgvault.apprecall + done >/var/plexguide/pgvault.apprecall + done /dev/null 2>&1 + while read p; do + echo -n $p >>/var/plexguide/program.temp + echo -n " " >>/var/plexguide/program.temp + num=$((num + 1)) + if [ "$num" == 7 ]; then + num=0 + echo " " >>/var/plexguide/program.temp + fi + done /var/plexguide/pgvault.apprecall + while read p; do + sed -i "/^$p\b/Id" /var/plexguide/pgvault.apprecall + done >/var/plexguide/pgvault.buildup + sed -i "/^$typed\b/Id" /var/plexguide/pgvault.apprecall + + num=0 + rm -rf /var/plexguide/pgvault.output 1>/dev/null 2>&1 + while read p; do + echo -n $p >>/var/plexguide/pgvault.output + echo -n " " >>/var/plexguide/pgvault.output + if [ "$num" == 7 ]; then + num=0 + echo " " >>/var/plexguide/pgvault.output + fi + done /tmp/server.list + + ### List Out Apps In Readable Order (One's Not Installed) + num=0 + rm -rf /var/plexguide/program.temp 1>/dev/null 2>&1 + while read p; do + echo -n $p >>/var/plexguide/program.temp + echo -n " " >>/var/plexguide/program.temp + num=$((num + 1)) + if [ "$num" == 7 ]; then + num=0 + echo " " >>/var/plexguide/program.temp + fi + done /tmp/server.select + + if [[ "$server" == "exit" || "$server" == "Exit" || "$server" == "EXIT" || "$server" == "z" || "$server" == "Z" ]]; then exit; fi + + current2=$(cat /tmp/server.list | grep "\<$server\>") + if [ "$current2" == "" ]; then + badserver + serverprime + fi + + tempserver=$server + ls -l /mnt/gdrive/plexguide/backup/$tempserver | awk '{print $9}' | tail -n +2 >/var/plexguide/pgvault.restoreapps + + ### Blank Out Temp List + rm -rf /var/plexguide/pgvault.apprecall 1>/dev/null 2>&1 + touch /var/plexguide/pgvault.apprecall + + while read p; do + basename "$p" .tar >>/var/plexguide/pgvault.apprecall + done /dev/null 2>&1 + touch /var/plexguide/program.temp + mathprime +} + +buildup2() { + echo "$typed" >>/var/plexguide/pgvault.buildup + sed -i "/^$typed\b/Id" /var/plexguide/pgvault.apprecall + + num=0 + rm -rf /var/plexguide/pgvault.output 1>/dev/null 2>&1 + while read p; do + echo -n $p >>/var/plexguide/pgvault.output + echo -n " " >>/var/plexguide/pgvault.output + if [ "$num" == 7 ]; then + num=0 + echo " " >>/var/plexguide/pgvault.output + fi + done /tmp/program_var + # Execute Main Program + backup_process + + sleep 2 + done /tmp/program_var + # Execute Main Program + backup_process + + sleep 2 + done /dev/null 2>&1 + fi + + ###### Start the Backup Process - Backup Locally First + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Zipping Data Locally - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + path=$(cat /var/plexguide/server.hd.path) + tarlocation=$(cat /var/plexguide/data.location) + server_id=$(cat /var/plexguide/server.id) + + tar \ + --warning=no-file-changed --ignore-failed-read --absolute-names --warning=no-file-removed \ + --exclude-from=/opt/pgvault/exclude.list \ + -C /opt/appdata/${program_var} -cvf /opt/appdata/plexguide/${program_var}.tar ./ + + ##### Restart Docker Application if was Running Prior + if [ "$running" == "1" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Restarting Docker Application - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + sleep 2 + docker restart $program_var 1>/dev/null 2>&1 + fi + + ###### Backing Up Files to GDrive + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Sending Zipped Data to Google Drive - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + +useragent="$(cat /var/plexguide/uagent)" +bwlimit="$(cat /var/plexguide/blitz.bw)" + +vfs_dcs="$(cat /var/plexguide/vfs_dcs)" +vfs_mt="$(cat /var/plexguide/vfs_mt)" +vfs_t="$(cat /var/plexguide/vfs_t)" +vfs_c="$(cat /var/plexguide/vfs_c)" + + + rclone --config /opt/appdata/plexguide/rclone.conf mkdir gdrive:/plexguide/backup/${server_id} 1>/dev/null 2>&1 + + rclone moveto ${tarlocation}/${program_var}.tar \ + gdrive:/plexguide/backup/${server_id}/${program_var}.tar \ + --config /opt/appdata/plexguide/rclone.conf \ + -v --checksum --stats-one-line --stats 1s --progress \ + --tpslimit=10 \ + --checkers="$vfs_c" \ + --transfers="$vfs_t" \ + --no-traverse \ + --fast-list \ + --bwlimit="$bwlimit" \ + --drive-chunk-size="$vfs_dcs" \ + --user-agent="$useragent" + +##### Remove File Incase +rm -rf ${tarlocation}/${program_var}.tar 1>/dev/null 2>&1 +} +######################################################## END - PG Vault Backup +# +##################################################### START - PG Vault Restore +restore_all_start() { + + while read p; do + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Vault - Restoring: $p +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + sleep 2.5 + + # Store Used Program + echo $p >/tmp/program_var + # Execute Main Program + restore_process + redeploy + sleep 2 + done /tmp/program_var + # Execute Main Program + restore_process + redeploy + sleep 2 + done /dev/null 2>&1; fi + if [ ! -e "/opt/communityapps/"$app".yml" ]; then ansible-playbook /opt/communityapps/apps/$app.yml >/dev/null 2>&1; fi + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Redeploy for $program_var | done +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF +} + +restore_process() { + initial2 + srecall=$(cat /tmp/server.select) + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Determining Initial File Size - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + size=$(du -sh --apparent-size /mnt/gdrive/plexguide/backup/${srecall}/${program_var}.tar | /usr/bin/awk '{print $1}') + sleep 2 + echo "Initial File Size: $size" + sleep 2 + + ###### Backing Up Files to GDrive + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Downloading Data From Google Drive - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + rclone --config /opt/appdata/plexguide/rclone.conf --stats-one-line \ + --stats 1s --progress \ + copy gdrive:/plexguide/backup/${srecall}/${program_var}.tar \ + ${tarlocation} \ + -v --checksum --drive-chunk-size=64M --transfers=8 + + ##### Stop Docker Container if Running + redeploy + runningcheck + if [ "$running" == "1" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Stopping Docker Container - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + sleep 1 + docker stop $program_var 1>/dev/null 2>&1 + fi + + ###### Start the Backup Process - Backup Locally First + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ UnZipping & Restoring Data - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + mkdir -p "/opt/appdata/${program_var}" + rm -rf "/opt/appdata/${program_var}/*" + chown -R 1000:1000 "/opt/appdata/${program_var}" + chmod -R 775 "/opt/appdata/${program_var}" + tar -C /opt/appdata/${program_var} -xvf ${tarlocation}/${program_var}.tar + chown -R 1000:1000 "/opt/appdata/${program_var}" + chmod -R 775 "/opt/appdata/${program_var}" + + ##### Restart Docker Application if was Running Prior + if [ "$running" == "1" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Restarting Docker Application - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + sleep 2 + docker restart $program_var 1>/dev/null 2>&1 + fi + + ##### Remove File Incase + rm -rf ${tarlocation}/${program_var}.tar 1>/dev/null 2>&1 +} +##################################################### END - PG Vault Restore +# +##################################################### START - Backup Interface +vaultbackup() { + ### List Out Apps In Readable Order (One's Not Installed) + notrun=$(cat /var/plexguide/program.temp) + buildup=$(cat /var/plexguide/pgvault.output) + + if [ "$buildup" == "" ]; then buildup="NONE"; fi + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 Vault ~ Data Storage +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +📂 App Data available to Backup + +$notrun + +💾 Apps Queued for Backup + +$buildup + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +[A] Backup +[Z] Exit +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p '🌍 Type APP for QUEUE | Type all to backup all apps | Press [ENTER]: ' typed ") + if [ "$current2" != "" ]; then + queued + vaultbackup + fi + + cat /var/plexguide/pgvault.buildup >/tmp/appcheck.5 + cat /var/plexguide/pgvault.apprecall >>/tmp/appcheck.5 + current1=$(cat /tmp/appcheck.5 | grep "\<$typed\>") + if [ "$current1" == "" ]; then badinput && vaultbackup; fi + + buildup +} +##################################################### END - Backup Interface +# +##################################################### START - Restore Interface +vaultrestore() { + notrun=$(cat /var/plexguide/program.temp) + buildup=$(cat /var/plexguide/pgvault.output) + + if [ "$buildup" == "" ]; then buildup="NONE"; fi + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 Vault ~ Data Recall +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +📂 App Data available to Restore + +$notrun + +💾 Apps Queued for Restore + +$buildup + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +[A] Restore +[Z] Exit +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p '🌍 Type APP for QUEUE | Type all to restore all apps | Press [ENTER]: ' typed ") + if [ "$current2" != "" ]; then + queued + vaultrestore + fi + cat /var/plexguide/pgvault.buildup >/tmp/appcheck.5 + cat /var/plexguide/pgvault.apprecall >>/tmp/appcheck.5 + current2=$(cat /tmp/appcheck.5 | grep "\<$typed\>") + echo $current2 >/var/plexguide/app_rebuild + #Rebuild Depending on Location + if [ "$current2" == "" ]; then badinput && vaultrestore; fi + buildup2 +} +##################################################### START Primary Interface +primaryinterface() { + initial2 + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +📁 Vault Interface +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +🌵 Disk Used Space: $used of $capacity | $percentage Used Capacity + +[1] Data Backup +[2] Data Restore +[3] Current Server ID : $server_id +[4] Processing Location: $tarlocation + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +[Z] Exit +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p 'Type a Number | Press [ENTER]: ' typed /var/plexguide/server.id.stored + bash /opt/plexguide/menu/interface/serverid.sh + primaryinterface + elif [ "$typed" == "4" ]; then + bash /opt/pgvault/location.sh + primaryinterface + elif [[ "$typed" == "Z" || "$typed" == "z" ]]; then + exit + else + badinput + primaryinterface + fi +} +##################################################### END Primary Interface + +restorecheck() { + if [ "$restoreid" == "[NOT-SET]" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ WARNING! - You Must Set Your Recovery ID First! Restarting Process! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -n 1 -s -r -p "Press [ANY] Key to Continue " + echo + primaryinterface + exit + fi +} diff --git a/menu/pgvault/pgvault.sh b/menu/pgvault/pgvault.sh new file mode 100644 index 00000000..8122dd17 --- /dev/null +++ b/menu/pgvault/pgvault.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +source /opt/pgvault/functions.sh +source /opt/pgvault/pgvault.func +file="/var/plexguide/restore.id" +if [ ! -e "$file" ]; then + echo "[NOT-SET]" >/var/plexguide/restore.id +fi + +initial +apprecall +primaryinterface diff --git a/menu/pgvault/pgvaultprotectet.func b/menu/pgvault/pgvaultprotectet.func new file mode 100644 index 00000000..2dbd5309 --- /dev/null +++ b/menu/pgvault/pgvaultprotectet.func @@ -0,0 +1,642 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +runningcheck() { + initial2 + runcheck5=$(docker ps | grep ${program_var}) + if [ "$runcheck5" != "" ]; then running=1; else running=0; fi +} + +initial() { + rm -rf /var/plexguide/pgvault.output 1>/dev/null 2>&1 + rm -rf /var/plexguide/pgvault.buildup 1>/dev/null 2>&1 + rm -rf /var/plexguide/program.temp 1>/dev/null 2>&1 + rm -rf /var/plexguide/app.list 1>/dev/null 2>&1 + rm -rf /var/plexguide/pgvault.output 1>/dev/null 2>&1 + touch /var/plexguide/pgvault.output + touch /var/plexguide/program.temp + touch /var/plexguide/app.list + touch /var/plexguide/pgvault.buildup + touch /var/plexguide/pgvault.output + touch /var/plexguide/rclone.size + space=$(cat /var/plexguide/data.location) + # To Get Used Space + used=$(df -h /opt/appdata/plexguide | tail -n +2 | awk '{print $3}') + # To Get All Space + capacity=$(df -h /opt/appdata/plexguide | tail -n +2 | awk '{print $2}') + # Percentage + percentage=$(df -h /opt/appdata/plexguide | tail -n +2 | awk '{print $5}') +} + +initial2() { + path=$(cat /var/plexguide/server.hd.path) + tarlocation=$(cat /var/plexguide/data.location) + program_size=$(cat /var/plexguide/rclone.size) + program_var=$(cat /tmp/program_var) + server_id=$(cat /var/plexguide/server.id) +} + +final() { + echo + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + read -p '✅ Process Complete! | PRESS [ENTER] ' typed pgvault.serverlist +} + +pgboxrecall() { + ls -p /opt/coreapps/apps | grep -v / >/var/plexguide/pgvault.apprecall + while read p; do + sed -i "/^$p\b/Id" /var/plexguide/pgvault.apprecall + done >/var/plexguide/pgvault.apprecall + done /dev/null 2>&1 + while read p; do + echo -n $p >>/var/plexguide/program.temp + echo -n " " >>/var/plexguide/program.temp + num=$((num + 1)) + if [ "$num" == 7 ]; then + num=0 + echo " " >>/var/plexguide/program.temp + fi + done /var/plexguide/pgvault.apprecall + while read p; do + sed -i "/^$p\b/Id" /var/plexguide/pgvault.apprecall + done >/var/plexguide/pgvault.buildup + sed -i "/^$typed\b/Id" /var/plexguide/pgvault.apprecall + + num=0 + rm -rf /var/plexguide/pgvault.output 1>/dev/null 2>&1 + while read p; do + echo -n $p >>/var/plexguide/pgvault.output + echo -n " " >>/var/plexguide/pgvault.output + if [ "$num" == 7 ]; then + num=0 + echo " " >>/var/plexguide/pgvault.output + fi + done /tmp/server.list + + ### List Out Apps In Readable Order (One's Not Installed) + num=0 + rm -rf /var/plexguide/program.temp 1>/dev/null 2>&1 + while read p; do + echo -n $p >>/var/plexguide/program.temp + echo -n " " >>/var/plexguide/program.temp + num=$((num + 1)) + if [ "$num" == 7 ]; then + num=0 + echo " " >>/var/plexguide/program.temp + fi + done /tmp/server.select + + if [[ "$server" == "exit" || "$server" == "Exit" || "$server" == "EXIT" || "$server" == "z" || "$server" == "Z" ]]; then exit; fi + + current2=$(cat /tmp/server.list | grep "\<$server\>") + if [ "$current2" == "" ]; then + badserver + serverprime + fi + + tempserver=$server + ls -l /mnt/gdrive/plexguide/backup/$tempserver/protected/ | awk '{print $9}' | tail -n +2 >/var/plexguide/pgvault.restoreapps + + ### Blank Out Temp List + rm -rf /var/plexguide/pgvault.apprecall 1>/dev/null 2>&1 + touch /var/plexguide/pgvault.apprecall + + while read p; do + basename "$p" .tar >>/var/plexguide/pgvault.apprecall + done /dev/null 2>&1 + touch /var/plexguide/program.temp + mathprime +} + +buildup2() { + echo "$typed" >>/var/plexguide/pgvault.buildup + sed -i "/^$typed\b/Id" /var/plexguide/pgvault.apprecall + + num=0 + rm -rf /var/plexguide/pgvault.output 1>/dev/null 2>&1 + while read p; do + echo -n $p >>/var/plexguide/pgvault.output + echo -n " " >>/var/plexguide/pgvault.output + if [ "$num" == 7 ]; then + num=0 + echo " " >>/var/plexguide/pgvault.output + fi + done /tmp/program_var + # Execute Main Program + backup_process + + sleep 2 + done /tmp/program_var + # Execute Main Program + backup_process + + sleep 2 + done /dev/null 2>&1 + fi + + ###### Start the Backup Process - Backup Locally First + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Zipping Data Locally - $program_var [ Protected APPS ] +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + path=$(cat /var/plexguide/server.hd.path) + tarlocation=$(cat /var/plexguide/data.location) + server_id=$(cat /var/plexguide/server.id) + + tar \ + --warning=no-file-changed --ignore-failed-read --absolute-names --warning=no-file-removed \ + --exclude-from=/opt/pgvault/exclude.list \ + -czf - /opt/appdata/${program_var} | openssl enc -e -aes256 -out /opt/appdata/plexguide/${program_var}.tar.gz ./ + + ##### Restart Docker Application if was Running Prior + if [ "$running" == "1" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Restarting Docker Application - $program_var [ Protected APPS ] +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + sleep 2 + docker restart $program_var 1>/dev/null 2>&1 + fi + + ###### Backing Up Files to GDrive + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Sending Zipped Data to Google Drive - $program_var [ Protected APPS ] +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + +# User specifying VARS +useragent="$(cat /var/plexguide/uagent)" +bwlimit="$(cat /var/plexguide/blitz.bw)" + +vfs_dcs="$(cat /var/plexguide/vfs_dcs)" +vfs_mt="$(cat /var/plexguide/vfs_mt)" +vfs_t="$(cat /var/plexguide/vfs_t)" +vfs_c="$(cat /var/plexguide/vfs_c)" + + + rclone --config /opt/appdata/plexguide/rclone.conf mkdir gdrive:/plexguide/backup/${server_id}/protected/ 1>/dev/null 2>&1 + + rclone moveto ${tarlocation}/${program_var}.tar.gz \ + gdrive:/plexguide/backup/${server_id}/protected/${program_var}.tar.gz \ + --config /opt/appdata/plexguide/rclone.conf \ + -v --checksum --stats-one-line --stats 1s --progress \ + --tpslimit=10 \ + --checkers="$vfs_c" \ + --transfers="$vfs_t" \ + --no-traverse \ + --fast-list \ + --bwlimit="$bwlimit" \ + --drive-chunk-size="$vfs_dcs" \ + --user-agent="$useragent" + + ##### Remove File Incase + rm -rf ${tarlocation}/${program_var}.tar.gz 1>/dev/null 2>&1 +} +######################################################## END - PG Vault Backup +# +##################################################### START - PG Vault Restore +restore_all_start() { + + while read p; do + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Restoring: $p +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + sleep 2.5 + + # Store Used Program + echo $p >/tmp/program_var + # Execute Main Program + restore_process + + sleep 2 + done /tmp/program_var + # Execute Main Program + restore_process + + sleep 2 + done /dev/null 2>&1 + fi + + ###### Start the Backup Process - Backup Locally First + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ UnZipping & Restoring Data - $program_var [ Protected APPS ] +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + mkdir -p "/opt/appdata/${program_var}" + rm -rf "/opt/appdata/${program_var}/*" + chown -R 1000:1000 "/opt/appdata/${program_var}" + chmod -R 775 "/opt/appdata/${program_var}" + openssl enc -d -aes256 -in /opt/appdata/${program_var} | tar xz -C ${tarlocation}/${program_var}.tar.gz + chown -R 1000:1000 "/opt/appdata/${program_var}" + chmod -R 775 "/opt/appdata/${program_var}" + + ##### Restart Docker Application if was Running Prior + if [ "$running" == "1" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ Restarting Docker Application - $program_var +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + sleep 2 + docker restart $program_var 1>/dev/null 2>&1 + fi + + ##### Remove File Incase + rm -rf ${tarlocation}/${program_var}.tar 1>/dev/null 2>&1 +} +##################################################### END - PG Vault Restore +# +##################################################### START - Backup Interface +vaultbackup() { + ### List Out Apps In Readable Order (One's Not Installed) + notrun=$(cat /var/plexguide/program.temp) + buildup=$(cat /var/plexguide/pgvault.output) + + if [ "$buildup" == "" ]; then buildup="NONE"; fi + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 Backup & Restore ~ Data Storage [ Protected APPS ] +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +📂 App Data available to Backup + +$notrun + +💾 Apps Queued for Backup + +$buildup + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +[A] Backup +[Z] Exit +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p '🌍 Type APP for QUEUE | Type all to backup all apps | Press [ENTER]: ' typed ") + if [ "$current2" != "" ]; then + queued + vaultbackup + fi + + cat /var/plexguide/pgvault.buildup >/tmp/appcheck.5 + cat /var/plexguide/pgvault.apprecall >>/tmp/appcheck.5 + current1=$(cat /tmp/appcheck.5 | grep "\<$typed\>") + if [ "$current1" == "" ]; then badinput && vaultbackup; fi + + buildup +} +##################################################### END - Backup Interface +# +##################################################### START - Restore Interface +vaultrestore() { + notrun=$(cat /var/plexguide/program.temp) + buildup=$(cat /var/plexguide/pgvault.output) + + if [ "$buildup" == "" ]; then buildup="NONE"; fi + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 Backup & Restore ~ Data Recall [ Protected APPS ] +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +📂 App Data available to Restore + +$notrun + +💾 Apps Queued for Restore + +$buildup + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +[A] Restore +[Z] Exit +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p '🌍 Type APP for QUEUE | Type all to restore all apps | Press [ENTER]: ' typed ") + if [ "$current2" != "" ]; then + queued + vaultrestore + fi + + cat /var/plexguide/pgvault.buildup >/tmp/appcheck.5 + cat /var/plexguide/pgvault.apprecall >>/tmp/appcheck.5 + current1=$(cat /tmp/appcheck.5 | grep "\<$typed\>") + if [ "$current1" == "" ]; then badinput && vaultrestore; fi + + buildup2 +} +##################################################### START Primary Interface +primaryinterface() { + initial2 + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +📁 Backup & Restore Interface [ Protected APPS ] +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +🌵 Disk Used Space: $used of $capacity | $percentage Used Capacity + +[1] Data Backup +[2] Data Restore +[3] Current Server ID : $server_id +[4] Processing Location: $tarlocation + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +[Z] Exit +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p 'Type a Number | Press [ENTER]: ' typed /var/plexguide/server.id.stored + bash /opt/plexguide/menu/interface/serverid.sh + primaryinterface + elif [ "$typed" == "4" ]; then + bash /opt/pgvault/location.sh + primaryinterface + elif [[ "$typed" == "Z" || "$typed" == "z" ]]; then + exit + else + badinput + primaryinterface + fi +} +##################################################### END Primary Interface + +restorecheck() { + if [ "$restoreid" == "[NOT-SET]" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ WARNING! - You Must Set Your Recovery ID First! Restarting Process! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -n 1 -s -r -p "Press [ANY] Key to Continue " + echo + primaryinterface + exit + fi +} diff --git a/menu/pgvault/place.holder b/menu/pgvault/place.holder new file mode 100644 index 00000000..45b983be --- /dev/null +++ b/menu/pgvault/place.holder @@ -0,0 +1 @@ +hi diff --git a/menu/pgvault/restoreid.sh b/menu/pgvault/restoreid.sh new file mode 100644 index 00000000..6a09decd --- /dev/null +++ b/menu/pgvault/restoreid.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +↘️ ESTABLISHING: Restore ID +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +The Restore ID is an ID of an OLD SERVER! If you are unsure of your +prior server names, visit https://drive.google.com - From here, goto +/plexguide/backup and you should see the list there! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + +# Standby +read -p 'TYPE the Restore ID Name & Press [ENTER]: ' typed /var/plexguide/restore.id + + sleep 3 + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌇 PASS: Process Complete! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -n 1 -s -r -p "Press [ANY] Key to Continue " + +fi diff --git a/menu/plex/lsio-plex-claim.sh b/menu/plex/lsio-plex-claim.sh new file mode 100644 index 00000000..c162c49c --- /dev/null +++ b/menu/plex/lsio-plex-claim.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +# If we are debugging, enable trace +if [ "${DEBUG,,}" = "true" ]; then + set -x +fi + +function getPref { + local key="$1" + sed -n -E "s/^.*${key}=\"([^\"]*)\".*$/\1/p" "${prefFile}" +} + +function setPref { + local key="$1" + local value="$2" + + count="$(grep -c "${key}" "${prefFile}")" + count=$(($count + 0)) + if [[ $count > 0 ]]; then + sed -i -E "s/${key}=\"([^\"]*)\"/${key}=\"$value\"/" "${prefFile}" + else + sed -i -E "s/\/>/ ${key}=\"$value\"\/>/" "${prefFile}" + fi +} +PMSdir="/opt/appdata/plex/database/Library/Application Support/Plex Media Server" +prefFile="/opt/appdata/plex/database/Library/Application Support/Plex Media Server/Preferences.xml" + +PLEX_CLAIM="$1" + +# Create empty shell pref file if it doesn't exist already +if [ ! -e "${prefFile}" ]; then + echo "Creating pref shell" + mkdir -p "${PMSdir}" + cat > "${prefFile}" <<-EOF + + +EOF + chown -R 1000:1000 "/opt/appdata/plex" +fi + +# Setup Server's client identifier +serial="$(getPref "MachineIdentifier")" +if [ -z "${serial}" ]; then + serial="$(uuidgen)" + setPref "MachineIdentifier" "${serial}" +fi +clientId="$(getPref "ProcessedMachineIdentifier")" +if [ -z "${clientId}" ]; then + clientId="$(echo -n "${serial}- Plex Media Server" | sha1sum | cut -b 1-40)" + setPref "ProcessedMachineIdentifier" "${clientId}" +fi + +# Get server token and only turn claim token into server token if we have former but not latter. +token="$(getPref "PlexOnlineToken")" +if [ ! -z "${PLEX_CLAIM}" ] && [ -z "${token}" ]; then + echo "Attempting to obtain server token from claim token" + loginInfo="$(curl -X POST \ + -H 'X-Plex-Client-Identifier: '${clientId} \ + -H 'X-Plex-Product: Plex Media Server'\ + -H 'X-Plex-Version: 1.1' \ + -H 'X-Plex-Provides: server' \ + -H 'X-Plex-Platform: Linux' \ + -H 'X-Plex-Platform-Version: 1.0' \ + -H 'X-Plex-Device-Name: PlexMediaServer' \ + -H 'X-Plex-Device: Linux' \ + "https://plex.tv/api/claim/exchange?token=${PLEX_CLAIM}")" + token="$(echo "$loginInfo" | sed -n 's/.*\(.*\)<\/authentication-token>.*/\1/p')" + + if [ "$token" ]; then + setPref "PlexOnlineToken" "${token}" + echo "Plex Media Server successfully claimed" + fi +fi diff --git a/menu/plex/plex.sh b/menu/plex/plex.sh new file mode 100644 index 00000000..b26154dc --- /dev/null +++ b/menu/plex/plex.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +# FUNCTIONS START ############################################################## + +# BAD INPUT +badinput() { + echo + read -p '⛔️ ERROR - BAD INPUT! | PRESS [ENTER] ' typed /var/plexguide/plex.server && question3 + elif [ "$typed" == "2" ]; then + echo local >/var/plexguide/plex.server + elif [[ "$typed" == "z" || "$typed" == "Z" ]]; then + exit + else badinput2; fi +} + +# THIRD QUESTION +question3() { + tee <<-EOF +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 Remote Plex Server - Claim the Plex Server +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +To Claim the Plex Server, visit https://www.plex.tv/claim/ and input the +code below! You have 5 minutes to do so! + +If you are reinstalling plex with existing appdata press enter to skip +this step as you won't need to claim it again. +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + + read -p 'Plex Server Claim Number | Press [ENTER]: ' typed /var/plexguide/plex.claim + if [ $(cat /var/plexguide/image/plex) == linuxserver/plex ];then + bash /opt/plexguide/menu/plex/lsio-plex-claim.sh $(cat /var/plexguide/plex.claim) + fi +} + +# FUNCTIONS END ############################################################## + +question1 +#ansible-playbook /opt/coreapps/apps/plex.yml diff --git a/menu/plex/token.sh b/menu/plex/token.sh new file mode 100644 index 00000000..9f2d771b --- /dev/null +++ b/menu/plex/token.sh @@ -0,0 +1,189 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +# FUNCTIONS START ############################################################## + +# BAD INPUT +badinput() { + echo + read -p '⛔️ ERROR - BAD INPUT! | PRESS [ENTER] ' typed /var/plexguide/plex.pw + echo "$user" >/var/plexguide/plex.user + ansible-playbook /opt/plexguide/menu/plex/token.yml + token=$(cat /var/plexguide/plex.token) + if [ "$token" != "" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅️ PlexToken Generation Succeeded! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 4 + else + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ PlexToken Generation Failed! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +NOTE: Process will repeat until you succeed or exit! + +EOF + read -p 'Confirm Info | Press [ENTER] ' typed /var/plexguide/plex.token" + ignore_errors: yes + + - name: Token Generation + uri: + url: https://plex.tv/users/sign_in.json + method: POST + status_code: 201 + headers: + X-Plex-Product: 'plexguide' + X-Plex-Version: '1.0.0' + X-Plex-Client-Identifier: 'XXX' + Content-Type: 'application/x-www-form-urlencoded; charset=utf-8' + password: '{{pw.stdout}}' + user: '{{user.stdout}}' + register: plextoken + + - name: Set Token + set_fact: + plexauth: "{{plextoken.json.user.authToken | regex_replace('\n', '') }}" + + - name: Save Token + shell: 'echo {{plexauth}} > /var/plexguide/plex.token' + ignore_errors: yes diff --git a/menu/plex_dupe/plex_dupe.sh b/menu/plex_dupe/plex_dupe.sh new file mode 100644 index 00000000..0a1eda2b --- /dev/null +++ b/menu/plex_dupe/plex_dupe.sh @@ -0,0 +1,268 @@ +#!/bin/bash +# +# Title: PTS Plex Dupefinder +# Author(s): MrDoob +# GNU: General Public License v3.0 +################################################################################ + +# KEY VARIABLE RECALL & EXECUTION +mkdir -p /var/plex_dupe +touch /var/plex_dupe/plex.pw +touch /var/plex_dupe/plex.user +touch /var/plex_dupe/plex.token +touch /var/plex_dupe/plex.authdel + +# FUNCTIONS START ############################################################## +variable() { + file="$1" + if [ ! -e "$file" ]; then echo "$2" >$1; fi +} + +deploycheck() { +file="/opt/plex_dupefinder/config.json" + if [[ -f $file ]]; then + dstatus="✅ DEPLOYED" + else dstatus="⚠️ NOT DEPLOYED"; fi +} + +userstatus() { + userdep=$(cat /var/plex_dupe/plex.pw) + if [ "$userdep" != "" ]; then + ustatus="✅ DEPLOYED" + else ustatus="⚠️ NOT DEPLOYED"; fi +} + +tokenstatus() { + ptokendep=$(cat /var/plex_dupe/plex.token) + if [ "$ptokendep" != "" ]; then + PGSELFTEST=$(curl -LI "http://localhost:32400/system?X-Plex-Token=$(cat /var/plex_dupe/plex.token)" -o /dev/null -w '%{http_code}\n' -s) + if [[ $PGSELFTEST -ge 200 && $PGSELFTEST -le 299 ]]; then + pstatus="✅ DEPLOYED" + else + pstatus="❌ DEPLOYED BUT Plex_Dupefinder FAILED" + fi + else pstatus="⚠️ NOT DEPLOYED"; fi +} + +automodestatus() { + adep=$(cat /var/plex_dupe/plex.authdel) + if [ "$adep" == "true" ]; then + astatus="✅ AUTO_DELETE = true" + elif [ "$adep" == "false" ]; then + astatus="✅ AUTO_DELETE = false" + else astatus="⚠️ NOT DEPLOYED"; fi +} + +plexcheck() { + pcheck=$(docker ps | grep "\") + if [ "$pcheck" == "" ]; then + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ WARNING! - Plex is Not Installed or Running! Exiting! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p 'Confirm Info | PRESS [ENTER] ' typed /var/plex_dupe/plex.authdel + ansible-playbook /opt/plexguide/menu/pg.yml --tags plex_dupefinder >/dev/null 2>&1 + else echo -e "true" >/var/plex_dupe/plex.authdel ; fi && clear && question1 ;; + 2) + file="/opt/plex_dupefinder/config.json" + if [[ -f $file ]]; then + echo -e "false" >/var/plex_dupe/plex.authdel + ansible-playbook /opt/plexguide/menu/pg.yml --tags plex_dupefinder >/dev/null 2>&1 + else echo -e "false" >/var/plex_dupe/plex.authdel ; fi && clear && question1 ;; + z) + exit + ;; + Z) + exit + ;; + *) + question1 + ;; + esac +} + +# FIRST QUESTION +question1() { +userstatus +automodestatus +tokenstatus +deploycheck + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 Plex Dupefinder Interface || l3uddz/plex_dupefinder +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +NOTE : Plex Dupefinder are located in /opt/plex_dupefinder + +[1] Deploy Plex Username & Plex Passwort [ $ustatus ] +[2] Deploy Plex Token [ $pstatus ] +[3] Deploy AUTO_DELETE [ $astatus ] + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +[A] Deploy Plex Dupefinder [ $dstatus ] + +[C] Credits + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +[Z] - Exit + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + + read -p '↘️ Type Number | Press [ENTER]: ' typed Server -> Library. +Set the following: --> +Allow media deletion: enabled +Click SAVE CHANGES. + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +These edits must be made by the user! We will not do this for you, so you have to do it yourself! + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + fi + diff --git a/menu/plex_dupe/scripts/plex_pw.sh b/menu/plex_dupe/scripts/plex_pw.sh new file mode 100644 index 00000000..9d2a3341 --- /dev/null +++ b/menu/plex_dupe/scripts/plex_pw.sh @@ -0,0 +1,143 @@ +#!/bin/bash +# +# Title: PTS Plex Password +# Author(s): MrDoob +# GNU: General Public License v3.0 +################################################################################ + +# FUNCTIONS START ############################################################## + +# BAD INPUT +badinput() { + echo + read -p '⛔️ ERROR - BAD INPUT! | PRESS [ENTER] ' typed /var/plex_dupe/plex.pw + echo "$user" >/var/plex_dupe/plex.user + +bash /opt/plexguide/menu/plex_dupe/scripts/plex_token.sh + + token=$(cat /var/plex_dupe/plex.token) + if [ "$token" != "" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅️ Details stored Succeeded! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 4 + else + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ Details Failed! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +NOTE: Process will repeat until you succeed or exit! + +EOF + read -p 'Confirm Info | Press [ENTER] ' typed /tmp/plex_sign_in +X_PLEX_TOKEN=$(sed -n 's/.*\(.*\)<\/authentication-token>.*/\1/p' /tmp/plex_sign_in) +if [ -z "$X_PLEX_TOKEN" ]; then + cat /tmp/plex_sign_in + rm -f /tmp/plex_sign_in + >&2 echo 'Failed to retrieve the X-Plex-Token.' + exit 1 +fi +echo $X_PLEX_TOKEN >/var/plex_dupe/plex.token \ No newline at end of file diff --git a/menu/plex_dupe/scripts/token.yml b/menu/plex_dupe/scripts/token.yml new file mode 100644 index 00000000..f6b2213a --- /dev/null +++ b/menu/plex_dupe/scripts/token.yml @@ -0,0 +1,43 @@ +#!/bin/bash +# +# Title: PTS Plex Token +# Author(s): MrDoob +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: Recall User | Plex Username + shell: 'cat /var/plex_dupe/plex.user' + register: user + + - name: Recall PW | Plex Password + shell: 'cat /var/plex_dupe/plex.pw' + register: pw + + - name: Blank Out Token + shell: "echo '' >/var/plex_dupe/plex.token" + ignore_errors: yes + + - name: Token Generation | Plex Token + uri: + url: https://plex.tv/users/sign_in.json + method: POST + status_code: 201 + headers: + X-Plex-Product: 'plexguide' + X-Plex-Version: '1.0.0' + X-Plex-Client-Identifier: 'XXX' + Content-Type: 'application/x-www-form-urlencoded; charset=utf-8' + password: '{{pw.stdout}}' + user: '{{user.stdout}}' + register: plextoken + + - name: Set Token | Plex Token + set_fact: + plexauth: "{{plextoken.json.user.authToken | regex_replace('\n', '') }}" + + - name: Save Token | Plex Token + shell: 'echo {{plexauth}} > /var/plex_dupe/plex.token' + ignore_errors: yes diff --git a/menu/plexpatrol/plexpatrol.sh b/menu/plexpatrol/plexpatrol.sh new file mode 100644 index 00000000..fb0f96d6 --- /dev/null +++ b/menu/plexpatrol/plexpatrol.sh @@ -0,0 +1,312 @@ +#!/bin/bash +# +# Title: Plex Patrol +# org.Author(s): Admin9705 +# Mod from MrDoob for PTS over role based installs +# GNU: General Public License v3.0 +################################################################################ +source /opt/plexguide/menu/functions/functions.sh +source /opt/plexguide/menu/functions/install.sh +# KEY VARIABLE RECALL & EXECUTION +mkdir -p /var/plexguide/plexpatrol + +# FUNCTIONS START ############################################################## +oldvalue(){ +value="/var/plexguide/pgpatrol" +if [[ ! -f $value ]]; then +rm -rf /var/plexguide/pgpatrol; fi +} + +# FIRST FUNCTION +variable() { + file="$1" + if [ ! -e "$file" ]; then echo "$2" >$1; fi +} + +doneenter(){ + echo + read -p 'All done | PRESS [ENTER] ' typed /var/plexguide/plexpatrol/video.transcodes && question1 ;; + 2) echo -e "true" >/var/plexguide/plexpatrol/video.transcodes && question1 ;; + *) badinput ;; + esac +} +selection2() { + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 Instantly Kick 4k - Video Transcodes? +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +[1] False +[2] True + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + read -p '↘️ Type Number | Press [ENTER]: ' typed /var/plexguide/plexpatrol/video.transcodes4k && question1 ;; + 2) echo -e "true" >/var/plexguide/plexpatrol/video.transcodes4k && question1 ;; + *) badinput ;; + esac +} +selection3() { + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 Instantly Kick Audio Transcodes? +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +[1] False +[2] True + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + read -p '↘️ Type Number | Press [ENTER]: ' typed /var/plexguide/plexpatrol/audio.transcodes && question1 ;; + 2) echo -e "true" >/var/plexguide/plexpatrol/audio.transcodes && question1 ;; + *) badinput ;; + esac +} +selection4() { + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 Limit Amount of Different IPs a User Can Make? +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Set a Number from [ 1 ] - [ 10 ] + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + read -p '↘️ Type Number | Press [ENTER]: ' typed /var/plexguide/plexpatrol/multiple.ips && question1 + else badinput; fi +} +selection5() { + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 Limit How Long a User Can Pause For! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Set a Number from [ 5 ] - [ 250 ] Mintues + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + read -p '↘️ Type Number | Press [ENTER]: ' typed /var/plexguide/plexpatrol/kick.minutes && question1 + else badinput; fi +} +selection6() { + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 Check Interval # how often to check the active streams in seconds +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Set a Number from [ 60 ] - [ 240 ] seconds + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + read -p '↘️ Type Number | Press [ENTER]: ' typed /var/plexguide/plexpatrol/check.interval && question1 + else badinput; fi +} +selection7() { + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 Remove Plex Patrol || l3uddz/plex_patrol +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +[ 1 ] - NO + +[ 2 ] - YES + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + read -p '↘️ Type Number | Press [ENTER]: ' typed /var/plexguide/plexpatrol/plex.pw + echo "$user" >/var/plexguide/plexpatrol/plex.user +PLEX_LOGIN=$(cat /var/plexguide/plexpatrol/plex.user) +PLEX_PASSWORD=$(cat /var/plexguide/plexpatrol/plex.pw) + +curl -qu "${PLEX_LOGIN}":"${PLEX_PASSWORD}" 'https://plex.tv/users/sign_in.xml' \ + -X POST -H 'X-Plex-Device-Name: PlexMediaServer' \ + -H 'X-Plex-Provides: server' \ + -H 'X-Plex-Version: 0.9' \ + -H 'X-Plex-Platform-Version: 0.9' \ + -H 'X-Plex-Platform: xcid' \ + -H 'X-Plex-Product: Plex Media Server'\ + -H 'X-Plex-Device: Linux'\ + -H 'X-Plex-Client-Identifier: XXXX' --compressed >/tmp/plex_sign_in +X_PLEX_TOKEN=$(sed -n 's/.*\(.*\)<\/authentication-token>.*/\1/p' /tmp/plex_sign_in) +if [ -z "$X_PLEX_TOKEN" ]; then + cat /tmp/plex_sign_in + rm -f /tmp/plex_sign_in + >&2 echo 'Failed to retrieve the X-Plex-Token.' + exit 1 +fi +echo $X_PLEX_TOKEN >/var/plexguide/plexpatrol/plex.token + + token=$(cat /var/plexguide/plexpatrol/plex.token) + if [ "$token" != "" ]; then + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅️ PlexToken Generation Succeeded! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 4 + else + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ PlexToken Generation Failed! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +NOTE: Process will repeat until you succeed or exit! + +EOF + read -p 'Confirm Info | Press [ENTER] ' typed /var/plexguide/server.ports + else echo "127.0.0.1:" >/var/plexguide/server.ports; fi + bash /opt/plexguide/menu/portguard/rebuild.sh + question1 + ;; + z) + exit + ;; + Z) + exit + ;; + *) + question1 + ;; + esac +} + +# FUNCTIONS END ############################################################## + +break=off && while [ "$break" == "off" ]; do question1; done \ No newline at end of file diff --git a/menu/portguard/rebuild.sh b/menu/portguard/rebuild.sh new file mode 100644 index 00000000..dcae1217 --- /dev/null +++ b/menu/portguard/rebuild.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +docker ps -a --format "{{.Names}}" >/var/plexguide/container.running + +sed -i -e "/traefik/d" /var/plexguide/container.running +sed -i -e "/watchtower/d" /var/plexguide/container.running +sed -i -e "/wp-*/d" /var/plexguide/container.running +sed -i -e "/x2go*/d" /var/plexguide/container.running +sed -i -e "/authclient/d" /var/plexguide/container.running +sed -i -e "/dockergc/d" /var/plexguide/container.running +sed -i -e "/oauth/d" /var/plexguide/container.running + +count=$(wc -l /tmp/program_var + sleep 1 + + if [ -e "/opt/coreapps/apps/$app.yml" ]; then ansible-playbook /opt/coreapps/apps/$app.yml; fi + if [ -e "/opt/communityapps/$app.yml" ]; then ansible-playbook /opt/communityapps/apps/$app.yml; fi + if [ -e "/opt/mxcontainers/$app.yml" ]; then ansible-playbook /opt/mycontainers/apps/$app.yml; fi +done + +echo "" +tee <<-EOF + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + ✅️ PortGuard - All Containers Rebuilt! + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF +read -p 'Continue? | Press [ENTER] ' name /dev/null 2>&1' + state: present + ignore_errors: yes + + - cron: + name: Build a Cron Job - Journal Purge + special_time: 'daily' + job: 'jpurge 1>/dev/null 2>&1' + state: present + ignore_errors: yes + + - cron: + name: Build a Cron Job - Update Weekly + special_time: 'weekly' + job: 'update 1>/dev/null 2>&1' + state: present + ignore_errors: yes + + - cron: + name: Build a Cron Job - remove logs after reboot + special_time: 'reboot' + job: 'kill_logs 1>/dev/null 2>&1' + state: present + ignore_errors: yes + + - cron: + name: Build a Cron Job - remove logs daily + special_time: 'daily' + job: 'kill_logs 1>/dev/null 2>&1' + state: present + ignore_errors: yes + + diff --git a/menu/roles/autodelete/tasks/main.yml b/menu/roles/autodelete/tasks/main.yml new file mode 100644 index 00000000..1371693c --- /dev/null +++ b/menu/roles/autodelete/tasks/main.yml @@ -0,0 +1,37 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +- name: Remove old NZBGET job + cron: + name: Build a Cron Job - NZBGET + state: absent + ignore_errors: yes + +- name: Remove old SABNZBD job + cron: + name: Build a Cron Job - SABNZBD + state: absent + ignore_errors: yes + +- name: Remove old DELUGE job + cron: + name: Build a Cron Job - DELUGE + state: absent + ignore_errors: yes + +- name: Remove old RUTORRENT job + cron: + name: Build a Cron Job - RUTORRENT + state: absent + ignore_errors: yes + +- name: Remove old QBITTORRENT job + cron: + name: Build a Cron Job - QBITTORRENT + state: absent + ignore_errors: yes diff --git a/menu/roles/clean/tasks/main.yml b/menu/roles/clean/tasks/main.yml new file mode 100644 index 00000000..01079e0f --- /dev/null +++ b/menu/roles/clean/tasks/main.yml @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +# Credit to ENZTV for the basis of this script https://enztv.wordpress.com/2017/03/09/unionfs-cleanup/ +############################################### +--- +- name: Install gdriveclean; remove old cronjob + cron: + name: 'gdriveclean' + user: 'root' + state: absent + ignore_errors: yes + +- name: Install gdriveclean; remove existing unionfs-fuse whiteout files + file: + state: absent + path: '/mnt/move/.unionfs-fuse' + +- name: remove gdriveclean; cronjob + cron: + name: 'gdriveclean' + state: absent + ignore_errors: yes diff --git a/menu/roles/docker/files/daemon.json b/menu/roles/docker/files/daemon.json new file mode 100644 index 00000000..5a7b4c68 --- /dev/null +++ b/menu/roles/docker/files/daemon.json @@ -0,0 +1,6 @@ +{ + "storage-driver": "overlay2", + "userland-proxy": false, + "log-driver": "json-file", + "log-opts": {"max-size": "12m", "max-file": "4"} +} diff --git a/menu/roles/docker/files/docker.root.conf b/menu/roles/docker/files/docker.root.conf new file mode 100644 index 00000000..d15a5264 --- /dev/null +++ b/menu/roles/docker/files/docker.root.conf @@ -0,0 +1,3 @@ +[Service] +ExecStart= +ExecStart=/usr/bin/dockerd -g /opt/docker -H fd:// diff --git a/menu/roles/docker/files/override.conf b/menu/roles/docker/files/override.conf new file mode 100644 index 00000000..312eb7f6 --- /dev/null +++ b/menu/roles/docker/files/override.conf @@ -0,0 +1,5 @@ +[Unit] +After=pgunion.service + +[Service] +ExecStartPre=/bin/sleep 2 diff --git a/menu/roles/docker/tasks/main.yml b/menu/roles/docker/tasks/main.yml new file mode 100644 index 00000000..3cba9d33 --- /dev/null +++ b/menu/roles/docker/tasks/main.yml @@ -0,0 +1,232 @@ +#!/bin/bash +# +# Title: Docker Install +############################################################### +--- +- name: 'Establish Facts' + set_fact: + switch: 'on' + updatecheck: 'default' + +- name: 'Docker Check' + stat: + path: '/usr/bin/docker' + register: check + +- name: 'Docker Version Check - True' + shell: "docker --version | awk '{print $3}'" + register: updatecheck + +- name: 'Switch - On' + set_fact: + switch: 'off' + when: updatecheck.stdout == "18.09.8," + +- name: 'Stop All Containers' + shell: 'docker stop $(docker ps -a -q)' + ignore_errors: yes + when: + - check.stat.exists == True + - switch == "on" + +#########update part +- name: Update APT package cache + apt: update_cache=yes cache_valid_time=600 + +- name: Upgrade APT to the latest packages + apt: upgrade=dist + register: apt_result + +- name: Autoremove unused packages + command: apt-get -y autoremove + register: apt_result + changed_when: "'packages will be REMOVED' in apt_result.stdout" + +- name: Purge residual kernel packages + shell: apt-get remove -y --purge $(dpkg -l | grep "^rc\s*linux-image-" | awk '{print $2}' | tr '\n' ' ') + register: apt_result + changed_when: "'packages will be REMOVED' in apt_result.stdout" + +###Debian part +- name: "Install packages for apt add repository over HTTPS for Debian" + apt: + name: "{{ packagesdeb }}" + state: latest + update_cache: yes + vars: + packagesdeb: + - git + - apt-transport-https + - ca-certificates + - wget + - software-properties-common + - gnupg2 + - curl + - python3-pip + - virtualenv + - python3-setuptools + when: ansible_distribution == 'Debian' + +##Ubuntu part + +- name: "Install packages for apt add repository over HTTPS for Ubuntu" + apt: + name: "{{ packagesubu }}" + state: latest + update_cache: yes + vars: + packagesubu: + - software-properties-common + - apt-transport-https + - ca-certificates + - curl + - gnupg-agent + - software-properties-common + - python3-pip + - virtualenv + - python3-setuptools + when: ansible_distribution == 'Ubuntu' + +##Ubuntu and Debian repo adds + +- name: Add Apt signing key from official docker repo + apt_key: + url: https://download.docker.com/linux/{{ ansible_distribution|lower }}/gpg + state: present + +- name: Add docker official repository for {{ ansible_distribution|lower }} - {{ ansible_distribution_release }} + apt_repository: + repo: deb [arch=amd64] https://download.docker.com/linux/{{ansible_distribution|lower}} {{ansible_distribution_release}} edge + state: present + +#install part + +- name: Update APT package cache + apt: update_cache=yes cache_valid_time=3600 + +- name: Upgrade APT to the latest packages + apt: upgrade=dist + +- name: Update apt and install docker-ce + apt: update_cache=yes name=docker-ce state=latest + +- name: Update apt and install docker-ce-cli + apt: update_cache=yes name=docker-ce-cli state=latest + +- name: Update apt and install containerd.io + apt: update_cache=yes name=containerd.io state=latest + +- name: Install Docker Module for Python + pip: + name: docker + +- name: Install Docker-compose + get_url: + url: "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-{{ansible_system}}-{{ansible_architecture}}" + dest: /usr/local/bin/docker-compose + force: yes + mode: 0775 + +- name: Debian install Fix + shell: systemctl disable docker + when: ansible_distribution == 'Debian' + +- name: Check docker daemon.json exists + stat: + path: /etc/docker/daemon.json + register: docker_daemon + +- name: Stop docker to enable overlay2 + systemd: + state: stopped + name: docker + enabled: yes + when: + - docker_daemon.stat.exists == False + - switch == "on" + +- name: Import daemon.json + copy: + src: daemon.json + dest: /etc/docker/daemon.json + force: yes + mode: 0775 + when: + - docker_daemon.stat.exists == False + - switch == "on" + +- name: Start docker (Please Wait) + systemd: + state: started + name: docker + enabled: yes + when: + - docker_daemon.stat.exists == False + - switch == "on" + +- name: 'Wait for 20 seconds before commencing' + wait_for: + timeout: 20 + when: switch == "on" + +- name: Check override folder exists + stat: + path: /etc/systemd/system/docker.service.d + register: docker_override + +- name: Create override folder + file: + path: /etc/systemd/system/docker.service.d + state: directory + mode: 0775 + when: + - docker_override.stat.exists == False + - switch == "on" + tags: docker_standard + +- name: Import override file + copy: + src: override.conf + dest: /etc/systemd/system/docker.service.d/override.conf + force: yes + mode: 0775 + tags: docker_standard + when: switch == "on" + +#need check too +- name: systemctl deamon-reload + systemd: + daemon_reload: yes + notify: + - systemd daemon-reload + +- name: create plexguide network + docker_network: + name: 'plexguide' + state: present + tags: docker_standard + when: switch == "on" + +- name: 'Start All Containers' + shell: 'docker start $(docker ps -a -q)' + ignore_errors: yes + when: + - switch == "on" + - check.stat.exists == True + +- name: Check if docker is running and works + command: systemctl status "{{ item }}" + with_items: + - docker + ignore_errors: yes + changed_when: false + register: service_docker_status + +- name: Report status of docker + fail: + msg: | + Service docker is not running. + Output of `systemctl status docker`: + {{ service_docker_status.stdout }} + {{ service_docker_status.stderr }} + when: service_docker_status | failed diff --git a/menu/roles/docker/vars/Debian.yml b/menu/roles/docker/vars/Debian.yml new file mode 100644 index 00000000..f8969ec6 --- /dev/null +++ b/menu/roles/docker/vars/Debian.yml @@ -0,0 +1,51 @@ +- name: Update APT package cache + apt: update_cache=yes cache_valid_time=600 + +- name: Upgrade APT to the latest packages + apt: upgrade=dist + register: apt_result + +- name: Autoremove unused packages + command: apt-get -y autoremove + register: apt_result + changed_when: "'packages will be REMOVED' in apt_result.stdout" + +- name: Purge residual kernel packages + shell: apt-get remove -y --purge $(dpkg -l | grep "^rc\s*linux-image-" | awk '{print $2}' | tr '\n' ' ') + register: apt_result + changed_when: "'packages will be REMOVED' in apt_result.stdout" + +- name: Install packages for apt add repository over HTTPS + apt: + name: "{{ packages }}" + update_cache: yes + vars: + packagesdep: + - git + - apt-transport-https + - ca-certificates + - wget + - software-properties-common + - gnupg2 + - curl + +- name: Add Apt signing key from official docker repo + apt_key: + url: https://download.docker.com/linux/debian/gpg + state: present + +- name: add docker official repository for {{ ansible_distribution|lower }} - {{ ansible_distribution_release }} + apt_repository: + repo: deb [arch=amd64] https://download.docker.com/linux/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} stable + state: present + +- name: Update APT package cache + apt: update_cache=yes cache_valid_time=600 + +- name: Upgrade APT to the latest packages + apt: upgrade=dist + +- name: actually install docker + apt: + name: "docker-ce" + state: latest diff --git a/menu/roles/docker/vars/Ubuntu.yml b/menu/roles/docker/vars/Ubuntu.yml new file mode 100644 index 00000000..5bbaf2de --- /dev/null +++ b/menu/roles/docker/vars/Ubuntu.yml @@ -0,0 +1,50 @@ +- name: Update APT package cache + apt: update_cache=yes cache_valid_time=600 + +- name: Upgrade APT to the latest packages + apt: upgrade=dist + register: apt_result + +- name: Autoremove unused packages + command: apt-get -y autoremove + register: apt_result + changed_when: "'packages will be REMOVED' in apt_result.stdout" + +- name: Purge residual kernel packages + shell: apt-get remove -y --purge $(dpkg -l | grep "^rc\s*linux-image-" | awk '{print $2}' | tr '\n' ' ') + register: apt_result + changed_when: "'packages will be REMOVED' in apt_result.stdout" + +- name: Install packages for apt add repository over HTTPS + apt: + name: "{{ packages }}" + update_cache: yes + vars: + packages: + - software-properties-common + - apt-transport-https + - ca-certificates + - curl + - gnupg-agent + - software-properties-common + +- name: Add Apt signing key from official docker repo + apt_key: + url: https://download.docker.com/linux/ubuntu/gpg + state: present + +- name: add docker official repository for {{ ansible_distribution|lower }} - {{ ansible_distribution_release }} + apt_repository: + repo: deb [arch=amd64] https://download.docker.com/linux/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} stable + state: present + +- name: Update APT package cache + apt: update_cache=yes cache_valid_time=600 + +- name: Upgrade APT to the latest packages + apt: upgrade=dist + +- name: actually install docker + apt: + name: "docker-ce" + state: latest diff --git a/menu/roles/dockerdeb/files/dockerdeb.sh b/menu/roles/dockerdeb/files/dockerdeb.sh new file mode 100644 index 00000000..a026116f --- /dev/null +++ b/menu/roles/dockerdeb/files/dockerdeb.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +echo "Update System" +sudo apt-get update -yqq + +echo "Install common packages" +sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common -yqq + +echo "Add Docker’s official GPG key:" +sudo curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - + +echo "Verify GPG key" +sudo apt-key fingerprint 0EBFCD88 -yqq + +echo "Docker Install Base packages" +sudo add-apt-repository \ + "deb [arch=amd64] https://download.docker.com/linux/debian \ + $(lsb_release -cs) \ + stable" + +echo "Update again" +sudo apt-get update -yqq + +echo "Docker install full packages" + sudo apt-get install docker-ce docker-ce-cli containerd.io -yqq + +exit 0 diff --git a/menu/roles/docstart/tasks/main.yml b/menu/roles/docstart/tasks/main.yml new file mode 100644 index 00000000..b0fe59b1 --- /dev/null +++ b/menu/roles/docstart/tasks/main.yml @@ -0,0 +1,48 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq - Sub7Seven +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +########################################## Scripts +- name: Check DockerFix Service + stat: + path: '/etc/systemd/system/v2docstart.service' + register: v2docstart + +- name: Install Docker Reboot + template: + src: v2dockerscript.js2 + dest: /opt/appdata/plexguide/v2dockerscript.sh + force: yes +########################################## Remove Old Services + +- name: Remove Old Docker Fix + file: + state: absent + path: /etc/systemd/system/docstart.service + +- name: Remove Old Docker File + file: + state: absent + path: /opt/appdata/plexguide/docstart.sh + +########################################## New Service + +- name: Stop If DockerFix Service Running + systemd: state=stopped name=v2docstart + when: v2docstart.stat.exists + +- name: Install DockerFix Service + template: + src: v2docstart.js2 + dest: /etc/systemd/system/v2docstart.service + force: yes + +- name: Daemon-Reload + systemd: state=stopped name=v2docstart daemon_reload=yes enabled=no + +- name: Start DockerFix + systemd: state=started name=v2docstart enabled=yes diff --git a/menu/roles/docstart/templates/v2dockerscript.js2 b/menu/roles/docstart/templates/v2dockerscript.js2 new file mode 100644 index 00000000..9916e1f8 --- /dev/null +++ b/menu/roles/docstart/templates/v2dockerscript.js2 @@ -0,0 +1,31 @@ + +# Regular color(s) +NORMAL="\033[0;39m" +GREEN="\033[32m" + +echo -e " +$GREEN + ┌───────────────────────────────────────────────────────────────────────────────────┐ + │ Title: Restart Running Containers Script │ + │ Author(s): desimaniac │ + │ Description: Stop running containers and start them back up. │ + ├───────────────────────────────────────────────────────────────────────────────────┤ + │ GNU General Public License v3.0 │ + └───────────────────────────────────────────────────────────────────────────────────┘ +$NORMAL +" + +containers=$(comm -12 <(docker ps -a -q | sort) <(docker ps -q | sort)) +for container in $containers; +do + echo Stopping $container + docker=$(docker stop $container) +done + +sleep 10 + +for container in $containers; +do + echo Starting $container + docker=$(docker start $container) +done diff --git a/menu/roles/docstart/templates/v2docstart.js2 b/menu/roles/docstart/templates/v2docstart.js2 new file mode 100644 index 00000000..c34ed5a3 --- /dev/null +++ b/menu/roles/docstart/templates/v2docstart.js2 @@ -0,0 +1,16 @@ + [Unit] + Description=Move Service Daemon + After=multi-user.target + + [Service] + Type=simple + User=root + Group=root + ExecStart=/bin/bash /opt/appdata/plexguide/v2dockerscript.sh + TimeoutStopSec=20 + KillMode=process + RemainAfterExit=yes + Restart=always + + [Install] + WantedBy=multi-user.target diff --git a/menu/roles/gcloud_sdk/.gitignore b/menu/roles/gcloud_sdk/.gitignore new file mode 100644 index 00000000..b25c15b8 --- /dev/null +++ b/menu/roles/gcloud_sdk/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/menu/roles/gcloud_sdk/.travis.yml b/menu/roles/gcloud_sdk/.travis.yml new file mode 100644 index 00000000..beff2d3d --- /dev/null +++ b/menu/roles/gcloud_sdk/.travis.yml @@ -0,0 +1,31 @@ +language: ruby +rvm: +- 2.2 +- 1.9.3 +env: +- DOCKER_IMAGES=centos:7 ANSIBLE_VERSIONS=1.6.1 +- DOCKER_IMAGES=centos:7 ANSIBLE_VERSIONS=2.1.0.0 +- DOCKER_IMAGES=debian:8 ANSIBLE_VERSIONS=1.6.1 +- DOCKER_IMAGES=debian:8 ANSIBLE_VERSIONS=2.1.0.0 +- DOCKER_IMAGES=debian:stretch ANSIBLE_VERSIONS=1.6.1 +- DOCKER_IMAGES=debian:stretch ANSIBLE_VERSIONS=2.1.0.0 +- DOCKER_IMAGES=ubuntu:12.04 ANSIBLE_VERSIONS=1.6.1 +- DOCKER_IMAGES=ubuntu:12.04 ANSIBLE_VERSIONS=2.1.0.0 +- DOCKER_IMAGES=ubuntu:14.04 ANSIBLE_VERSIONS=1.6.1 +- DOCKER_IMAGES=ubuntu:14.04 ANSIBLE_VERSIONS=2.1.0.0 +- DOCKER_IMAGES=ubuntu:16.04 ANSIBLE_VERSIONS=1.6.1 +- DOCKER_IMAGES=ubuntu:16.04 ANSIBLE_VERSIONS=2.1.0.0 +- DOCKER_IMAGES=ubuntu:18.04 ANSIBLE_VERSIONS=2.5.1 +services: +- docker +script: +- wget -O- bit.ly/ansibletest | sh -x +after_failure: +- cat role-tester-ansible-master/.kitchen/logs/*.log | grep -v '^I, ' +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ + slack: + secure: HGI0oBCXlH+g+FgpfE1iTXZ1oLSU46CqMatC9tTCltjiW4kETX0AgPSdHnvd8Yfv835HYov57dTe8uSy3KRePf2Kizrg1fukyvDN0cjXhjMUglKGiBkGZ3MFF5QasxS7hdHpqTtjV/VJYj4i0lsGkQbYFHb+rpkwp4pNTwGlWfUaRpOXOV+icCjZuJlniPguA44BQJdpKaH0wcfEPO/y5wzIQpS98aW5ESeaxcUfNFxjd5U2K/mhdpCICigXeDON1Lnzn11lNuvZ/obK6LAR0uD9VYzCZcJBCGDPY8oNVrW4QiN9im4mbHeC1hUnRTr8JYEQtWJ/SlnnzCq4FrIL7oA/p5tgDIPYfJBIgpMSKA7JHcNBdNUahoQ7+r6jHMdOL03spSlNKbOW+lw1/+ypKYCr1C3fsuoSUyUpa4gTRt6E9q4TRMNGa/zucRYZxCAG3yGv3CrtebZ8BDTqyMP+o3nyj0WzraCtdPUu5hn5ZcFI3eGcsYNqMDvps9uUG+ZJpH0h7XZSbkZseFiWvjhC13So9h5We4D+1WDMv0CgSa6Xdx2ViTpCNF01gF0nmWo0BBtW+KtwK4JurT37xq34qWz/+bjJTf4SuYyXgh3CzcN92ffup1M1LuFj86uoSB5pVNgJ9QSlQizzzC7dxn/2NVr4F5vvn12XJFRusbp5E9U= + email: + recipients: + secure: ilGXa+I7Gai3AubxxQO6ffq5nLgEgeSoVDqvLz/cETY+mTdqKri3tJFOi3aJeaT7eWbYT7TXdAuUzWTytBNtA1/WvqYB/SFilEjpAiQk6hrjdfkeJyOTCzbKM3k2usQmIO4TbULniOt/yWr2EMtwXTga/s5HBa97z2Nqp0n9qnoGm/daJ4I8ss1akpRPakPOc3/j0kuTwOjT1Vsia1M2bErss+AFkK6aeop7jZBkY5cjSRr/r9DPVqavi5Tkagsc1yl53kqJiMg3rJ+JfP0kZt7Z4tEoeCVbGGlsRza3jjtu9EFNKJuQP5bt+R/BTGS9W9pv+D7aiNHl37Wrk2Ei49B85AfUoN0zzuyLrw8DVxdfMdhD0JNZji5uesq0b3scLik5xchs9mrjsynlYxhsnuNe8459+xkkHazs9+lG4ZrRU6/2tPOwtzMzqYBrHlg867AkdCDAWuJPz4Id4Ez81Q//xFyBeTlqGOUHX5tHVqkcARQHLzDFD67jJivVPXavz9WPCpV3t5qDcLQ3TrTId+vIMbJHvJoeHc+HoMxElrC5V63wssuF4SxTdfDiX08xWKlBV2CZH3V8/16dTDKuCrT+qSjYuzJLo8szSMsTAgQgr1NuSsTMDxjN9NHLCeJJ34oWQ1v5fkH3BedCBu47eOWfd7rEEF4WkeJSmTGjaqU= diff --git a/menu/roles/gcloud_sdk/README.md b/menu/roles/gcloud_sdk/README.md new file mode 100644 index 00000000..1fe8f438 --- /dev/null +++ b/menu/roles/gcloud_sdk/README.md @@ -0,0 +1,43 @@ +[![Build Status](https://travis-ci.org/wtanaka/ansible-role-gcloud-sdk.svg?branch=master)](https://travis-ci.org/wtanaka/ansible-role-gcloud-sdk) +[![CircleCI](https://circleci.com/gh/wtanaka/ansible-role-gcloud-sdk.svg?style=svg)](https://circleci.com/gh/wtanaka/ansible-role-gcloud-sdk) + +wtanaka.gcloud-sdk +================== + +Ansible role to install Google Cloud SDK + +Example Playbook +---------------- + + - hosts: all + roles: + - role: wtanaka.gcloud-sdk + +Variables +--------- + +The full set of configuration options available are visible in +[defaults/main.yml](defaults/main.yml) + +### `gcloud_sdk_additional_package_names` + +Default: `[]` + +list of package name strings to additionally install. Available examples: + +* `google-cloud-sdk-app-engine-python` +* `google-cloud-sdk-app-engine-java` +* `google-cloud-sdk-datastore-emulator` +* `google-cloud-sdk-pubsub-emulator` +* `google-cloud-sdk-bigtable-emulator` +* `kubectl` + +License +------- + +GPLv2 + +Author Information +------------------ + +http://wtanaka.com/ diff --git a/menu/roles/gcloud_sdk/defaults/main.yml b/menu/roles/gcloud_sdk/defaults/main.yml new file mode 100644 index 00000000..cce7dd8c --- /dev/null +++ b/menu/roles/gcloud_sdk/defaults/main.yml @@ -0,0 +1,3 @@ +--- +gcloud_sdk_additional_package_names: [google-cloud-sdk-app-engine-python] +#gcloud_sdk_should_shortcircuit: False diff --git a/menu/roles/gcloud_sdk/files/rpm-package-key.gpg b/menu/roles/gcloud_sdk/files/rpm-package-key.gpg new file mode 100644 index 00000000..dc3ada26 --- /dev/null +++ b/menu/roles/gcloud_sdk/files/rpm-package-key.gpg @@ -0,0 +1,19 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1 + +mQENBFWKtqgBCADmKQWYQF9YoPxLEQZ5XA6DFVg9ZHG4HIuehsSJETMPQ+W9K5c5 +Us5assCZBjG/k5i62SmWb09eHtWsbbEgexURBWJ7IxA8kM3kpTo7bx+LqySDsSC3 +/8JRkiyibVV0dDNv/EzRQsGDxmk5Xl8SbQJ/C2ECSUT2ok225f079m2VJsUGHG+5 +RpyHHgoMaRNedYP8ksYBPSD6sA3Xqpsh/0cF4sm8QtmsxkBmCCIjBa0B0LybDtdX +XIq5kPJsIrC2zvERIPm1ez/9FyGmZKEFnBGeFC45z5U//pHdB1z03dYKGrKdDpID +17kNbC5wl24k/IeYyTY9IutMXvuNbVSXaVtRABEBAAG0Okdvb2dsZSBDbG91ZCBQ +YWNrYWdlcyBSUE0gU2lnbmluZyBLZXkgPGdjLXRlYW1AZ29vZ2xlLmNvbT6JATgE +EwECACIFAlWKtqgCGy8GCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEPCcOUw+ +G6jV+QwH/0wRH+XovIwLGfkg6kYLEvNPvOIYNQWnrT6zZ+XcV47WkJ+i5SR+QpUI +udMSWVf4nkv+XVHruxydafRIeocaXY0E8EuIHGBSB2KR3HxG6JbgUiWlCVRNt4Qd +6udC6Ep7maKEIpO40M8UHRuKrp4iLGIhPm3ELGO6uc8rks8qOBMH4ozU+3PB9a0b +GnPBEsZdOBI1phyftLyyuEvG8PeUYD+uzSx8jp9xbMg66gQRMP9XGzcCkD+b8w1o +7v3J3juKKpgvx5Lqwvwv2ywqn/Wr5d5OBCHEw8KtU/tfxycz/oo6XUIshgEbS/+P +6yKDuYhRp6qxrYXjmAszIT25cftb4d4= +=/PbX +-----END PGP PUBLIC KEY BLOCK----- diff --git a/menu/roles/gcloud_sdk/files/yum-key.gpg b/menu/roles/gcloud_sdk/files/yum-key.gpg new file mode 100644 index 00000000..00aff637 --- /dev/null +++ b/menu/roles/gcloud_sdk/files/yum-key.gpg @@ -0,0 +1,19 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1 + +mQENBFUd6rIBCAD6mhKRHDn3UrCeLDp7U5IE7AhhrOCPpqGF7mfTemZYHf/5Jdjx +cOxoSFlK7zwmFr3lVqJ+tJ9L1wd1K6P7RrtaNwCiZyeNPf/Y86AJ5NJwBe0VD0xH +TXzPNTqRSByVYtdN94NoltXUYFAAPZYQls0x0nUD1hLMlOlC2HdTPrD1PMCnYq/N +uL/Vk8sWrcUt4DIS+0RDQ8tKKe5PSV0+PnmaJvdF5CKawhh0qGTklS2MXTyKFoqj +XgYDfY2EodI9ogT/LGr9Lm/+u4OFPvmN9VN6UG+s0DgJjWvpbmuHL/ZIRwMEn/tp +uneaLTO7h1dCrXC849PiJ8wSkGzBnuJQUbXnABEBAAG0QEdvb2dsZSBDbG91ZCBQ +YWNrYWdlcyBBdXRvbWF0aWMgU2lnbmluZyBLZXkgPGdjLXRlYW1AZ29vZ2xlLmNv +bT6JAT4EEwECACgFAlUd6rICGy8FCQWjmoAGCwkIBwMCBhUIAgkKCwQWAgMBAh4B +AheAAAoJEDdGwginMXsPcLcIAKi2yNhJMbu4zWQ2tM/rJFovazcY28MF2rDWGOnc +9giHXOH0/BoMBcd8rw0lgjmOosBdM2JT0HWZIxC/Gdt7NSRA0WOlJe04u82/o3OH +WDgTdm9MS42noSP0mvNzNALBbQnlZHU0kvt3sV1YsnrxljoIuvxKWLLwren/GVsh +FLPwONjw3f9Fan6GWxJyn/dkX3OSUGaduzcygw51vksBQiUZLCD2Tlxyr9NvkZYT +qiaWW78L6regvATsLc9L/dQUiSMQZIK6NglmHE+cuSaoK0H4ruNKeTiQUw/EGFaL +ecay6Qy/s3Hk7K0QLd+gl0hZ1w1VzIeXLo2BRlqnjOYFX4A= +=HVTm +-----END PGP PUBLIC KEY BLOCK----- diff --git a/menu/roles/gcloud_sdk/meta/.galaxy_install_info b/menu/roles/gcloud_sdk/meta/.galaxy_install_info new file mode 100644 index 00000000..07cbfd99 --- /dev/null +++ b/menu/roles/gcloud_sdk/meta/.galaxy_install_info @@ -0,0 +1 @@ +{install_date: 'Sun Sep 15 10:22:19 2019', version: v2.1.0} diff --git a/menu/roles/gcloud_sdk/meta/main.yml b/menu/roles/gcloud_sdk/meta/main.yml new file mode 100644 index 00000000..d3fe1eb5 --- /dev/null +++ b/menu/roles/gcloud_sdk/meta/main.yml @@ -0,0 +1,200 @@ +--- +galaxy_info: + author: Wesley Tanaka + description: Install Google Cloud SDK + company: http://wtanaka.com/ + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: GPLv2 + + min_ansible_version: 1.4 + + # Optionally specify the branch Galaxy will use when accessing the GitHub + # repo for this role. During role install, if no tags are available, + # Galaxy will use this branch. During import Galaxy will access files on + # this branch. If travis integration is cofigured, only notification for this + # branch will be accepted. Otherwise, in all cases, the repo's default branch + # (usually master) will be used. + #github_branch: + + # + # Below are all platforms currently available. Just uncomment + # the ones that apply to your role. If you don't see your + # platform on this list, let us know and we'll get it added! + # + platforms: + - name: EL + versions: + # - all + # - 5 + # - 6 + - 7 + #- name: GenericUNIX + # versions: + # - all + # - any + #- name: OpenBSD + # versions: + # - all + # - 5.6 + # - 5.7 + # - 5.8 + # - 5.9 + # - 6.0 + #- name: Fedora + # versions: + # - all + # - 16 + # - 17 + # - 18 + # - 19 + # - 20 + # - 21 + # - 22 + # - 23 + #- name: opensuse + # versions: + # - all + # - 12.1 + # - 12.2 + # - 12.3 + # - 13.1 + # - 13.2 + #- name: MacOSX + # versions: + # - all + # - 10.10 + # - 10.11 + # - 10.12 + # - 10.7 + # - 10.8 + # - 10.9 + #- name: IOS + # versions: + # - all + # - any + #- name: Solaris + # versions: + # - all + # - 10 + # - 11.0 + # - 11.1 + # - 11.2 + # - 11.3 + #- name: SmartOS + # versions: + # - all + # - any + #- name: eos + # versions: + # - all + # - Any + #- name: Windows + # versions: + # - all + # - 2012R2 + #- name: Amazon + # versions: + # - all + # - 2013.03 + # - 2013.09 + #- name: GenericBSD + # versions: + # - all + # - any + #- name: Junos + # versions: + # - all + # - any + #- name: FreeBSD + # versions: + # - all + # - 10.0 + # - 10.1 + # - 10.2 + # - 10.3 + # - 8.0 + # - 8.1 + # - 8.2 + # - 8.3 + # - 8.4 + # - 9.0 + # - 9.1 + # - 9.1 + # - 9.2 + # - 9.3 + - name: Ubuntu + versions: + # - all + # - lucid + # - maverick + # - natty + # - oneiric + - precise + - quantal + - raring + - saucy + - trusty + - utopic + - vivid + - wily + - xenial + #- name: SLES + # versions: + # - all + # - 10SP3 + # - 10SP4 + # - 11 + # - 11SP1 + # - 11SP2 + # - 11SP3 + # - 11SP4 + # - 12 + # - 12SP1 + #- name: GenericLinux + # versions: + # - all + # - any + #- name: NXOS + # versions: + # - all + # - any + - name: Debian + versions: + # - all + # - etch + - jessie + # - lenny + # - sid + # - squeeze + - stretch + - wheezy + + galaxy_tags: + # List tags for your role here, one per line. A tag is + # a keyword that describes and categorizes the role. + # Users find roles by searching for tags. Be sure to + # remove the '[]' above if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of + # alphanumeric characters. Maximum 20 tags per role. + - cloud + - api + - sdk + - google + - gcloud + +dependencies: [] + # List your role dependencies here, one per line. + # Be sure to remove the '[]' above if you add dependencies + # to this list. diff --git a/menu/roles/gcloud_sdk/tasks/Debian.yml b/menu/roles/gcloud_sdk/tasks/Debian.yml new file mode 100644 index 00000000..ce27d63b --- /dev/null +++ b/menu/roles/gcloud_sdk/tasks/Debian.yml @@ -0,0 +1,36 @@ +--- +- include_tasks: get_key.yml + +- name: add google cloud key to apt-key + apt_key: file=/root/A7317B0F.gpg + become: yes + +- name: sources.list + template: > + src=google-cloud-sdk.list.j2 + dest=/etc/apt/sources.list.d/google-cloud-sdk.list + force=no + register: sources_list_result + become: yes + +# Install apt-transport-https +- name: install apt-transport-https + action: "{{backcompat_pkg_mgr}} name=apt-transport-https" + register: result_install_transport_https + until: result_install_transport_https is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + become: yes + +- name: apt-get update + apt: update_cache=true cache_valid_time=0 + when: sources_list_result.changed + register: result_apt_update + until: result_apt_update is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + become: yes diff --git a/menu/roles/gcloud_sdk/tasks/Debian_sudo.yml b/menu/roles/gcloud_sdk/tasks/Debian_sudo.yml new file mode 100644 index 00000000..76a050ee --- /dev/null +++ b/menu/roles/gcloud_sdk/tasks/Debian_sudo.yml @@ -0,0 +1,36 @@ +--- +- include_tasks: get_key_sudo.yml + +- name: add google cloud key to apt-key + apt_key: file=/root/A7317B0F.gpg + sudo: yes + +- name: sources.list + template: > + src=google-cloud-sdk.list.j2 + dest=/etc/apt/sources.list.d/google-cloud-sdk.list + force=no + register: sources_list_result + sudo: yes + +# Install apt-transport-https +- name: install apt-transport-https + action: "{{backcompat_pkg_mgr}} name=apt-transport-https" + sudo: yes + register: result_install_transport_https + until: result_install_transport_https is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + +- name: apt-get update + apt: update_cache=true cache_valid_time=0 + when: sources_list_result.changed + sudo: yes + register: result_apt_update + until: result_apt_update is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 diff --git a/menu/roles/gcloud_sdk/tasks/become.yml b/menu/roles/gcloud_sdk/tasks/become.yml new file mode 100644 index 00000000..9cfaf8b3 --- /dev/null +++ b/menu/roles/gcloud_sdk/tasks/become.yml @@ -0,0 +1,6 @@ +--- +- include_tasks: compat.yml +- include_tasks: Debian.yml + when: ansible_os_family == 'Debian' +- include_tasks: install_package_names.yml +- include_tasks: install_additional_packages.yml diff --git a/menu/roles/gcloud_sdk/tasks/compat.yml b/menu/roles/gcloud_sdk/tasks/compat.yml new file mode 100644 index 00000000..6a32c7ed --- /dev/null +++ b/menu/roles/gcloud_sdk/tasks/compat.yml @@ -0,0 +1,138 @@ +--- +- name: install python-apt on ansible < 1.6.0 and ubuntu et al + raw: > + if > /dev/null command -v apt-get; then + python -c "import apt" || + (> /dev/null command -v apt-get && + (apt-get install -y python-apt || + (apt-get update -qq && apt-get install -y python-apt))); + fi + register: result_python_apt + until: result_python_apt is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: should_run and ansible_os_family == 'Debian' + changed_when: False + become: yes + +- name: install python-pycurl on ansible < 1.6.0 and ubuntu et al + raw: > + if > /dev/null command -v apt-get; then + python -c "import pycurl" || + (> /dev/null command -v apt-get && + (apt-get install -y python-pycurl || + (apt-get update -qq && apt-get install -y python-pycurl))); + fi + register: result_python_pycurl + until: result_python_pycurl is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: should_run and ansible_os_family == 'Debian' + changed_when: False + become: yes + +- name: install python2-yum on ansible <=1.9.2/fedora 24 + raw: > + if > /dev/null command -v yum && ! > /dev/null command -v dnf; then + python -c "import yum" || + (> /dev/null command -v yum && ! > /dev/null command -v dnf && yum install -y python2-yum); + fi + register: result_python_yum + until: result_python_yum is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: should_run and ansible_os_family == 'RedHat' + changed_when: False + become: yes + +- name: install python2-dnf on ansible 2.1/fedora 24 + raw: > + if > /dev/null command -v dnf; then + python -c "import dnf" || + (> /dev/null command -v dnf && dnf install -y python2-dnf); + fi + register: result_python_dnf + until: result_python_dnf is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: should_run and ansible_os_family == 'RedHat' + changed_when: False + become: yes + +# Set backcompat_pkg_mgr for versions of ansible that set +# ansible_pkg_mgr to yum instead of dnf +- name: check for dnf + raw: "> /dev/null command -v dnf" + register: dnf_result + ignore_errors: True + when: should_run and ansible_os_family == 'RedHat' + changed_when: False + become: yes + +- set_fact: + backcompat_pkg_mgr: 'dnf' + when: should_run and ansible_os_family == 'RedHat' and dnf_result is success + +- set_fact: + backcompat_pkg_mgr: '{{ansible_pkg_mgr}}' + when: should_run and ansible_os_family == 'RedHat' and dnf_result is failed + +- set_fact: + backcompat_pkg_mgr: '{{ansible_pkg_mgr}}' + when: should_run and ansible_os_family == 'Debian' + +- set_fact: + ansible_distribution_major_version: > + {{ansible_distribution_version|truncate(2,true,'',0)|replace(".", " ")|trim|float|int|string}} + when: should_run and ansible_distribution_major_version is not defined + +- set_fact: + ansible_distribution_major_version: > + {{ansible_distribution_version|truncate(4,true,'',0)|replace("."," ")|trim|float|int|string}} + when: should_run and ansible_distribution_major_version is not defined or not ansible_distribution_major_version + +- name: check for wget + raw: "> /dev/null command -v wget" + register: wget_result + ignore_errors: True + changed_when: False + when: should_run + become: yes + +# Install wget due to https://github.com/ansible/ansible/issues/12161 +- name: install wget with non-dnf + action: "{{backcompat_pkg_mgr}} name=wget" + register: result_wget + until: result_wget is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: > + should_run and + (backcompat_pkg_mgr == "yum" or backcompat_pkg_mgr == "apt") + and wget_result is failed + become: yes + +# Install wget due to https://github.com/ansible/ansible/issues/12161 +# Use command since dnf was only added as a module in ansible 1.9.0 +- name: install wget with dnf + command: dnf install -y wget + register: result_wget_dnf + until: result_wget_dnf is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + args: + creates: /usr/bin/wget + when: should_run and backcompat_pkg_mgr == "dnf" and wget_result is failed + become: yes diff --git a/menu/roles/gcloud_sdk/tasks/compat_sudo.yml b/menu/roles/gcloud_sdk/tasks/compat_sudo.yml new file mode 100644 index 00000000..94347371 --- /dev/null +++ b/menu/roles/gcloud_sdk/tasks/compat_sudo.yml @@ -0,0 +1,136 @@ +--- +- name: install python-apt on ansible < 1.6.0 and ubuntu et al + sudo: yes + raw: > + if > /dev/null command -v apt-get; then + python -c "import apt" || + (> /dev/null command -v apt-get && + (apt-get install -y python-apt || + (apt-get update -qq && apt-get install -y python-apt))); + fi + register: result_python_apt + until: result_python_apt is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: should_run and ansible_os_family == 'Debian' + changed_when: False + +- name: install python-pycurl on ansible < 1.6.0 and ubuntu et al + sudo: yes + raw: > + if > /dev/null command -v apt-get; then + python -c "import pycurl" || + (> /dev/null command -v apt-get && + (apt-get install -y python-pycurl || + (apt-get update -qq && apt-get install -y python-pycurl))); + fi + register: result_python_pycurl + until: result_python_pycurl is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: should_run and ansible_os_family == 'Debian' + changed_when: False + +- name: install python2-yum on ansible <=1.9.2/fedora 24 + sudo: yes + raw: > + if > /dev/null command -v yum && ! > /dev/null command -v dnf; then + python -c "import yum" || + (> /dev/null command -v yum && ! > /dev/null command -v dnf && yum install -y python2-yum); + fi + register: result_python_yum + until: result_python_yum is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: should_run and ansible_os_family == 'RedHat' + changed_when: False + +- name: install python2-dnf on ansible 2.1/fedora 24 + sudo: yes + raw: > + if > /dev/null command -v dnf; then + python -c "import dnf" || + (> /dev/null command -v dnf && dnf install -y python2-dnf); + fi + register: result_python_dnf + until: result_python_dnf is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: should_run and ansible_os_family == 'RedHat' + changed_when: False + +# Set backcompat_pkg_mgr for versions of ansible that set +# ansible_pkg_mgr to yum instead of dnf +- name: check for dnf + raw: "> /dev/null command -v dnf" + register: dnf_result + ignore_errors: True + when: should_run and ansible_os_family == 'RedHat' + changed_when: False + +- set_fact: + backcompat_pkg_mgr: 'dnf' + when: should_run and ansible_os_family == 'RedHat' and dnf_result is success + +- set_fact: + backcompat_pkg_mgr: '{{ansible_pkg_mgr}}' + when: should_run and ansible_os_family == 'RedHat' and dnf_result is failed + +- set_fact: + backcompat_pkg_mgr: '{{ansible_pkg_mgr}}' + when: should_run and ansible_os_family == 'Debian' + +- set_fact: + ansible_distribution_major_version: > + {{ansible_distribution_version|truncate(2,true,'',0)|replace(".", " ")|trim|float|int|string}} + when: should_run and ansible_distribution_major_version is not defined + +- set_fact: + ansible_distribution_major_version: > + {{ansible_distribution_version|truncate(4,true,'',0)|replace("."," ")|trim|float|int|string}} + when: should_run and ansible_distribution_major_version is not defined or not ansible_distribution_major_version + +- name: check for wget + raw: "> /dev/null command -v wget" + register: wget_result + ignore_errors: True + changed_when: False + when: should_run + +# Install wget due to https://github.com/ansible/ansible/issues/12161 +- name: install wget with non-dnf + action: "{{backcompat_pkg_mgr}} name=wget" + register: result_wget + until: result_wget is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + sudo: yes + when: > + should_run and + (backcompat_pkg_mgr == "yum" or backcompat_pkg_mgr == "apt") + and wget_result is failed + +# Install wget due to https://github.com/ansible/ansible/issues/12161 +# Use command since dnf was only added as a module in ansible 1.9.0 +- name: install wget with dnf + command: dnf install -y wget + register: result_wget_dnf + until: result_wget_dnf is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + args: + creates: /usr/bin/wget + sudo: yes + when: should_run and backcompat_pkg_mgr == "dnf" and wget_result is failed diff --git a/menu/roles/gcloud_sdk/tasks/get_key.yml b/menu/roles/gcloud_sdk/tasks/get_key.yml new file mode 100644 index 00000000..9ccc5b5d --- /dev/null +++ b/menu/roles/gcloud_sdk/tasks/get_key.yml @@ -0,0 +1,15 @@ +--- +- name: download gcloud key + # https does not work on centos-5 + command: > + wget -O /root/A7317B0F.gpg + https://packages.cloud.google.com/apt/doc/apt-key.gpg + args: + creates: /root/A7317B0F.gpg + register: result_download + until: result_download is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + become: yes diff --git a/menu/roles/gcloud_sdk/tasks/get_key_sudo.yml b/menu/roles/gcloud_sdk/tasks/get_key_sudo.yml new file mode 100644 index 00000000..7ed16c4b --- /dev/null +++ b/menu/roles/gcloud_sdk/tasks/get_key_sudo.yml @@ -0,0 +1,15 @@ +--- +- name: download gcloud key + # https does not work on centos-5 + command: > + wget -O /root/A7317B0F.gpg + https://packages.cloud.google.com/apt/doc/apt-key.gpg + args: + creates: /root/A7317B0F.gpg + sudo: yes + register: result_download + until: result_download is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 diff --git a/menu/roles/gcloud_sdk/tasks/include_vars.yml b/menu/roles/gcloud_sdk/tasks/include_vars.yml new file mode 100644 index 00000000..5801199f --- /dev/null +++ b/menu/roles/gcloud_sdk/tasks/include_vars.yml @@ -0,0 +1,8 @@ +--- +- include_vars: "{{item}}" + with_first_found: + - "../vars/{{ansible_distribution}}-{{ansible_distribution_version}}.yml" + - "../vars/{{ansible_distribution}}-{{ansible_distribution_major_version}}.yml" + - "../vars/{{ansible_distribution}}.yml" + - "../vars/{{ansible_os_family}}.yml" + - "../vars/default.yml" diff --git a/menu/roles/gcloud_sdk/tasks/install_additional_packages.yml b/menu/roles/gcloud_sdk/tasks/install_additional_packages.yml new file mode 100644 index 00000000..169ba905 --- /dev/null +++ b/menu/roles/gcloud_sdk/tasks/install_additional_packages.yml @@ -0,0 +1,37 @@ +--- +- name: install {{gcloud_sdk_additional_package_names | join(' ')}} with default package manager + action: "{{backcompat_pkg_mgr}} name={{item}}" + register: result_install_additional + until: result_install_additional is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: > + gcloud_sdk_additional_package_names is defined and + (backcompat_pkg_mgr == "yum" or backcompat_pkg_mgr == "apt") + with_items: "{{ gcloud_sdk_additional_package_names }}" + become: yes + +# Handle dnf case for Fedora +- name: "check if {{gcloud_sdk_additional_package_names | join(' ')}} exists" + command: "rpm -q {{gcloud_sdk_additional_package_names | join(' ')}}" + changed_when: False + ignore_errors: True + register: package_exists_result + when: gcloud_sdk_additional_package_names is defined and backcompat_pkg_mgr == "dnf" + become: yes + +# Use command since dnf was only added as a module in ansible 1.9.0 +- name: install {{gcloud_sdk_additional_package_names | join (' ')}} with dnf + command: dnf install -y {{gcloud_sdk_additional_package_names | join(' ')}} + register: result_install_additional_dnf + until: result_install_additional_dnf is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: > + gcloud_sdk_additional_package_names is defined and backcompat_pkg_mgr == "dnf" and + package_exists_result is failed + become: yes diff --git a/menu/roles/gcloud_sdk/tasks/install_additional_packages_sudo.yml b/menu/roles/gcloud_sdk/tasks/install_additional_packages_sudo.yml new file mode 100644 index 00000000..33421f33 --- /dev/null +++ b/menu/roles/gcloud_sdk/tasks/install_additional_packages_sudo.yml @@ -0,0 +1,36 @@ +--- +- name: install {{gcloud_sdk_additional_package_names | join(' ')}} with default package manager + action: "{{backcompat_pkg_mgr}} name={{item}}" + sudo: yes + register: result_install_additional + until: result_install_additional is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: > + gcloud_sdk_additional_package_names is defined and + (backcompat_pkg_mgr == "yum" or backcompat_pkg_mgr == "apt") + with_items: "{{ gcloud_sdk_additional_package_names }}" + +# Handle dnf case for Fedora +- name: "check if {{gcloud_sdk_additional_package_names | join(' ')}} exists" + command: "rpm -q {{gcloud_sdk_additional_package_names | join(' ')}}" + changed_when: False + ignore_errors: True + register: package_exists_result + when: gcloud_sdk_additional_package_names is defined and backcompat_pkg_mgr == "dnf" + +# Use command since dnf was only added as a module in ansible 1.9.0 +- name: install {{gcloud_sdk_additional_package_names | join (' ')}} with dnf + command: dnf install -y {{gcloud_sdk_additional_package_names | join(' ')}} + sudo: yes + register: result_install_additional_dnf + until: result_install_additional_dnf is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: > + gcloud_sdk_additional_package_names is defined and backcompat_pkg_mgr == "dnf" and + package_exists_result is failed diff --git a/menu/roles/gcloud_sdk/tasks/install_package_names.yml b/menu/roles/gcloud_sdk/tasks/install_package_names.yml new file mode 100644 index 00000000..dea6f60e --- /dev/null +++ b/menu/roles/gcloud_sdk/tasks/install_package_names.yml @@ -0,0 +1,46 @@ +--- +- name: install {{package_names | join(' ')}} with default package manager + action: "{{backcompat_pkg_mgr}} name={{item}}" + register: result_default + until: result_default is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: > + should_run and + package_names is defined and + package_names and + (backcompat_pkg_mgr == "yum" or backcompat_pkg_mgr == "apt") + with_items: "{{ package_names }}" + become: yes + +# Handle dnf case for Fedora +- name: "check if {{package_names | join(' ')}} exists" + command: "rpm -q {{package_names | join(' ')}}" + changed_when: False + ignore_errors: True + register: package_exists_result + when: > + should_run and + package_names is defined and + package_names and + backcompat_pkg_mgr == "dnf" + become: yes + +# Use command since dnf was only added as a module in ansible 1.9.0 +- name: install {{package_names | join (' ')}} with dnf + command: dnf install -y {{package_names | join(' ')}} + register: result_dnf + until: result_dnf is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: > + should_run and + package_names is defined and + package_names and + backcompat_pkg_mgr == "dnf" and + package_exists_result is failed + become: yes diff --git a/menu/roles/gcloud_sdk/tasks/install_package_names_sudo.yml b/menu/roles/gcloud_sdk/tasks/install_package_names_sudo.yml new file mode 100644 index 00000000..6e5b71c6 --- /dev/null +++ b/menu/roles/gcloud_sdk/tasks/install_package_names_sudo.yml @@ -0,0 +1,45 @@ +--- +- name: install {{package_names | join(' ')}} with default package manager + action: "{{backcompat_pkg_mgr}} name={{item}}" + sudo: yes + register: result_default + until: result_default is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: > + should_run and + package_names is defined and + package_names and + (backcompat_pkg_mgr == "yum" or backcompat_pkg_mgr == "apt") + with_items: "{{ package_names }}" + +# Handle dnf case for Fedora +- name: "check if {{package_names | join(' ')}} exists" + command: "rpm -q {{package_names | join(' ')}}" + changed_when: False + ignore_errors: True + register: package_exists_result + when: > + should_run and + package_names is defined and + package_names and + backcompat_pkg_mgr == "dnf" + +# Use command since dnf was only added as a module in ansible 1.9.0 +- name: install {{package_names | join (' ')}} with dnf + command: dnf install -y {{package_names | join(' ')}} + sudo: yes + register: result_dnf + until: result_dnf is success + # Workaround https://github.com/ansible/ansible/issues/16868 and + # increase default retry count + retries: 20 + delay: 10 + when: > + should_run and + package_names is defined and + package_names and + backcompat_pkg_mgr == "dnf" and + package_exists_result is failed diff --git a/menu/roles/gcloud_sdk/tasks/main.yml b/menu/roles/gcloud_sdk/tasks/main.yml new file mode 100644 index 00000000..dde09dae --- /dev/null +++ b/menu/roles/gcloud_sdk/tasks/main.yml @@ -0,0 +1,26 @@ +--- +# - name: check for short-circuit + # raw: "> /dev/null command -v todo_fixme;" + # register: installed + # ignore_errors: True + # changed_when: False + +- name: set should_run fact + set_fact: + should_run: True + # when: installed is failed or not gcloud_sdk_should_shortcircuit + +- include_vars: "{{item}}" + with_first_found: + - "../vars/{{ansible_distribution}}-{{ansible_distribution_version}}.yml" + - "../vars/{{ansible_distribution}}-{{ansible_distribution_major_version}}.yml" + - "../vars/{{ansible_distribution}}.yml" + - "../vars/{{ansible_os_family}}.yml" + - "../vars/default.yml" + +- include_tasks: sudo.yml + when: ansible_version is defined and ansible_version.major < 2 + +- include_tasks: become.yml + when: ansible_version is defined and ansible_version.major >= 2 + diff --git a/menu/roles/gcloud_sdk/tasks/sudo.yml b/menu/roles/gcloud_sdk/tasks/sudo.yml new file mode 100644 index 00000000..559aeda6 --- /dev/null +++ b/menu/roles/gcloud_sdk/tasks/sudo.yml @@ -0,0 +1,8 @@ +--- +- include_tasks: compat_sudo.yml +- include_tasks: Debian_sudo.yml + when: ansible_os_family == 'Debian' +- include_tasks: RedHat_sudo.yml + when: ansible_os_family == 'RedHat' +- include_tasks: install_package_names_sudo.yml +- include_tasks: install_additional_packages_sudo.yml diff --git a/menu/roles/gcloud_sdk/tasks/sudoorbecome.yml b/menu/roles/gcloud_sdk/tasks/sudoorbecome.yml new file mode 100644 index 00000000..139f4201 --- /dev/null +++ b/menu/roles/gcloud_sdk/tasks/sudoorbecome.yml @@ -0,0 +1,6 @@ +--- +- include: sudo.yml + when: ansible_version is not defined or ansible_version.major < 2 + +- include: become.yml + when: ansible_version is defined and ansible_version.major >= 2 diff --git a/menu/roles/gcloud_sdk/templates/google-cloud-sdk.list.j2 b/menu/roles/gcloud_sdk/templates/google-cloud-sdk.list.j2 new file mode 100644 index 00000000..1b84e5b7 --- /dev/null +++ b/menu/roles/gcloud_sdk/templates/google-cloud-sdk.list.j2 @@ -0,0 +1 @@ +deb https://packages.cloud.google.com/apt cloud-sdk-{{ansible_lsb.codename|lower}} main diff --git a/menu/roles/gcloud_sdk/templates/google-cloud-sdk.repo.j2 b/menu/roles/gcloud_sdk/templates/google-cloud-sdk.repo.j2 new file mode 100644 index 00000000..c2942ad8 --- /dev/null +++ b/menu/roles/gcloud_sdk/templates/google-cloud-sdk.repo.j2 @@ -0,0 +1,10 @@ +[google-cloud-sdk] +name=Google Cloud SDK +baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el{{ansible_distribution_major_version}}-{{ansible_architecture}} +enabled=1 +# TODO: Enable this after +# https://github.com/ansible/ansible/issues/20711 is resolved +gpgcheck=0 +repo_gpgcheck=0 +gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg + https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg diff --git a/menu/roles/gcloud_sdk/vars/default.yml b/menu/roles/gcloud_sdk/vars/default.yml new file mode 100644 index 00000000..5a1c7ac2 --- /dev/null +++ b/menu/roles/gcloud_sdk/vars/default.yml @@ -0,0 +1,3 @@ +--- +package_names: +- google-cloud-sdk diff --git a/menu/roles/gcloud_sdk/vars/main.yml b/menu/roles/gcloud_sdk/vars/main.yml new file mode 100644 index 00000000..ed97d539 --- /dev/null +++ b/menu/roles/gcloud_sdk/vars/main.yml @@ -0,0 +1 @@ +--- diff --git a/menu/roles/mergerfsinstall/tasks/main.yml b/menu/roles/mergerfsinstall/tasks/main.yml new file mode 100644 index 00000000..9d14924c --- /dev/null +++ b/menu/roles/mergerfsinstall/tasks/main.yml @@ -0,0 +1,67 @@ +###################################################################### +## +## some of this parts are cloned from Cloudbox +## many thanks to all the devs from Cloudbox +## +## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +## +## Credits fly to l3uddz and the CBox Boys "!" +## Mod from MrDoob ( main dev of PTS ) +## based of PGblitz v8.7.5 +####################################################################### + +--- +- name: "MergerFS | Install prerequisite build tools for Debian" + apt: + name: "{{ packages }}" + vars: + packages: + - build-essential + - g++ + - pkg-config + - git + - git-buildpackage + - pandoc + - debhelper + - libfuse-dev + - libattr1-dev + - jq + when: ansible_distribution == 'Debian' + +- name: "MergerFS | Install prerequisite build tools for UBUNTU" + apt: + name: "{{ packages }}" + vars: + packages: + - build-essential + - g++ + - pkg-config + - git + - git-buildpackage + - pandoc + - debhelper + - libfuse-dev + - libattr1-dev + - jq + when: ansible_distribution == 'Ubuntu' + +- name: "MergerFS | Get URL for latest mergerfs release" + shell: | + curl -s https://api.github.com/repos/trapexit/mergerfs/releases/latest \ + | jq -r ".assets[] | select(.name | test(\"{{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }}_amd64\")) \ + | .browser_download_url" + args: + executable: /bin/bash + warn: no + register: mergerfs_download_url + ignore_errors: yes + +- name: "MergerFS | Set 'mergerfs_download_url_backup' variable" + set_fact: + mergerfs_download_url_backup: https://github.com/trapexit/mergerfs/releases/download/2.28.1/mergerfs_2.28.1.{{ ansible_distribution|lower + }}-{{ ansible_distribution_release|lower }}_amd64.deb + +- name: "MergerFS | Install mergerfs" + apt: + deb: "{{ mergerfs_download_url.stdout | default('{{ mergerfs_download_url_backup }}') }}" + state: present \ No newline at end of file diff --git a/menu/roles/mergerfsinstall/tasks/setup-Debian.yml b/menu/roles/mergerfsinstall/tasks/setup-Debian.yml new file mode 100644 index 00000000..0f858883 --- /dev/null +++ b/menu/roles/mergerfsinstall/tasks/setup-Debian.yml @@ -0,0 +1,21 @@ +--- +- name: "Install prerequisite build tools" + become: true + apt: + name: "{{ item }}" + loop: + - build-essential + - g++ + - pkg-config + - git + - git-buildpackage + - pandoc + - debhelper + - libfuse-dev + - libattr1-dev + +- name: "Install mergerfs from package URL" + become: true + apt: + deb: "{{ mergerfs_package_url }}" + state: present diff --git a/menu/roles/mergerfsinstall/tasks/setup-Ubuntu.yml b/menu/roles/mergerfsinstall/tasks/setup-Ubuntu.yml new file mode 100644 index 00000000..0f858883 --- /dev/null +++ b/menu/roles/mergerfsinstall/tasks/setup-Ubuntu.yml @@ -0,0 +1,21 @@ +--- +- name: "Install prerequisite build tools" + become: true + apt: + name: "{{ item }}" + loop: + - build-essential + - g++ + - pkg-config + - git + - git-buildpackage + - pandoc + - debhelper + - libfuse-dev + - libattr1-dev + +- name: "Install mergerfs from package URL" + become: true + apt: + deb: "{{ mergerfs_package_url }}" + state: present diff --git a/menu/roles/mergerfsupdate/tasks/main.yml b/menu/roles/mergerfsupdate/tasks/main.yml new file mode 100644 index 00000000..655c3953 --- /dev/null +++ b/menu/roles/mergerfsupdate/tasks/main.yml @@ -0,0 +1,95 @@ +###################################################################### +## +## some of this parts are cloned from Cloudbox +## many thanks to all the devs from Cloudbox +## +## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +## +## Credits fly to l3uddz and the CBox Boys "!" +## Mod from MrDoob ( main dev of PTS ) +## based of PGblitz v8.7.5 +####################################################################### + +--- +- name: "MergerFS | Install prerequisite build tools for Debian" + apt: + name: "{{ packages }}" + vars: + packages: + - build-essential + - g++ + - pkg-config + - git + - git-buildpackage + - pandoc + - debhelper + - libfuse-dev + - libattr1-dev + - jq + when: ansible_distribution == 'Debian' + +- name: "MergerFS | Install prerequisite build tools for UBUNTU" + apt: + name: "{{ packages }}" + vars: + packages: + - build-essential + - g++ + - pkg-config + - git + - git-buildpackage + - pandoc + - debhelper + - libfuse-dev + - libattr1-dev + - jq + when: ansible_distribution == 'Ubuntu' + +- name: "MergerFS | Get URL for latest mergerfs release" + shell: | + curl -s https://api.github.com/repos/trapexit/mergerfs/releases/latest \ + | jq -r ".assets[] | select(.name | test(\"{{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }}_amd64\")) \ + | .browser_download_url" + args: + executable: /bin/bash + warn: no + register: mergerfs_download_url + ignore_errors: yes + +- name: "MergerFS | Set 'mergerfs_download_url_backup' variable" + set_fact: + mergerfs_download_url_backup: https://github.com/trapexit/mergerfs/releases/download/2.28.1/mergerfs_2.28.1.{{ ansible_distribution|lower + }}-{{ ansible_distribution_release|lower }}_amd64.deb + +- name: "MergerFS | Install mergerfs" + apt: + deb: "{{ mergerfs_download_url.stdout | default('{{ mergerfs_download_url_backup }}') }}" + state: present + +- name: Check if unionfs is running and works + command: systemctl status "{{ item }}" + with_items: + - pgunion + ignore_errors: yes + changed_when: false + +- name: unionfs restart + systemd: + state: restarted + daemon_reload: yes + name: pgunion + +- name: 'Restart Containers' + shell: 'docker restart $(docker ps -a -q)' + ignore_errors: yes + +- name: 'Restart check.sh' + shell: 'bash /opt/plexguide/menu/pgui/templates/check.sh >/dev/null 2>&1' + ignore_errors: yes + +- name: Check if docker is running and works + command: systemctl status "{{ item }}" + with_items: + - docker + ignore_errors: yes + changed_when: false diff --git a/menu/roles/mergerfsupdate/tasks/setup-Debian.yml b/menu/roles/mergerfsupdate/tasks/setup-Debian.yml new file mode 100644 index 00000000..0f858883 --- /dev/null +++ b/menu/roles/mergerfsupdate/tasks/setup-Debian.yml @@ -0,0 +1,21 @@ +--- +- name: "Install prerequisite build tools" + become: true + apt: + name: "{{ item }}" + loop: + - build-essential + - g++ + - pkg-config + - git + - git-buildpackage + - pandoc + - debhelper + - libfuse-dev + - libattr1-dev + +- name: "Install mergerfs from package URL" + become: true + apt: + deb: "{{ mergerfs_package_url }}" + state: present diff --git a/menu/roles/mergerfsupdate/tasks/setup-Ubuntu.yml b/menu/roles/mergerfsupdate/tasks/setup-Ubuntu.yml new file mode 100644 index 00000000..0f858883 --- /dev/null +++ b/menu/roles/mergerfsupdate/tasks/setup-Ubuntu.yml @@ -0,0 +1,21 @@ +--- +- name: "Install prerequisite build tools" + become: true + apt: + name: "{{ item }}" + loop: + - build-essential + - g++ + - pkg-config + - git + - git-buildpackage + - pandoc + - debhelper + - libfuse-dev + - libattr1-dev + +- name: "Install mergerfs from package URL" + become: true + apt: + deb: "{{ mergerfs_package_url }}" + state: present diff --git a/menu/roles/plex_autoscan/tasks/main.yml b/menu/roles/plex_autoscan/tasks/main.yml new file mode 100644 index 00000000..81a7726c --- /dev/null +++ b/menu/roles/plex_autoscan/tasks/main.yml @@ -0,0 +1,90 @@ +######################################################################### +# Title: Cloudbox: Plex Autoscan Role # +# Author(s): l3uddz, desimaniac # +# URL: https://github.com/cloudbox/cloudbox # +# -- # +# Part of the Cloudbox project: https://cloudbox.works # +######################################################################### +# GNU General Public License v3.0 # +######################################################################### +--- +- name: Set plex.user fact | username + shell: 'cat /var/plexguide/pgscan/plex.user' + register: plexuser + +- name: Set plex.user fact | passwort + shell: 'cat /var/plexguide/pgscan/plex.pw' + register: plexpass + +- name: Set plex.user fact | token + shell: 'cat /var/plexguide/pgscan/plex.token' + register: plex_auth_token + +- name: Register IP + shell: 'cat /var/plexguide/server.ip' + register: ipaddress + +- name: Register ServerPass + shell: 'cat /var/plexguide/pgscan/pgscan.serverpass' + register: plex_autoscan_server_pass + +- name: Register mounted.bin for trash + shell: 'touch /mnt/unionfs/mounted.bin' + +- name: Display Plex Auth Token + debug: + msg: "Plex Auth Token: {{ plex_auth_token }}" + +- name: Import Services Task + import_tasks: "subtasks/services.yml" + +- name: Remove old Install + shell: 'sudo rm -rf /opt/plex_autoscan' + +- name: Create plex_autoscan directories + file: "path={{ item }} state=directory mode=0775 owner=1000 group=1000 recurse=yes" + with_items: + - /opt/plex_autoscan + +- name: Clone plex_autoscan repo 'HEAD' + git: + repo: https://github.com/l3uddz/plex_autoscan.git + dest: /opt/plex_autoscan + clone: yes + version: HEAD + force: yes + ignore_errors: yes + register: plex_autoscan_clone_status + +- name: Clone plex_autoscan repo 'master' + git: + repo: https://github.com/l3uddz/plex_autoscan.git + dest: /opt/plex_autoscan + clone: yes + version: master + force: yes + become: yes + become_user: "1000" + when: plex_autoscan_clone_status is failed + +- name: Install pip requirements + pip: + requirements: /opt/plex_autoscan/requirements.txt + executable: pip2 + +- name: Set 'scan.py' as executable + file: + path: /opt/plex_autoscan/scan.py + owner: "1000" + group: "1000" + mode: a+x + +- name: Import Settings Task + import_tasks: "subtasks/settings.yml" + +- name: Start 'plex_autoscan.service' + systemd: + name: plex_autoscan + state: started + enabled: yes + daemon_reload: yes diff --git a/menu/roles/plex_autoscan/tasks/subtasks/services.yml b/menu/roles/plex_autoscan/tasks/subtasks/services.yml new file mode 100644 index 00000000..c7d45377 --- /dev/null +++ b/menu/roles/plex_autoscan/tasks/subtasks/services.yml @@ -0,0 +1,49 @@ +######################################################################### +# Title: Cloudbox: Plex Autoscan | Services Task # +# Author(s): desimaniac # +# URL: https://github.com/cloudbox/cloudbox # +# -- # +# Part of the Cloudbox project: https://cloudbox.works # +######################################################################### +# GNU General Public License v3.0 # +######################################################################### +--- +- name: Services | Check if 'plex_autoscan.service' exists + stat: + path: "/etc/systemd/system/plex_autoscan.service" + register: plex_autoscan_service + +- name: Services | Existing 'plex_autoscan.service' Tasks + block: + + - name: Services | Populate Service Facts + service_facts: + + - name: Services | Get 'plex_autoscan.service' state + set_fact: + plex_autoscan_service_running: "{{ (services['plex_autoscan.service'] is defined) and (services['plex_autoscan.service']['state'] == 'running') }}" + + - name: Services | Stop 'plex_autoscan.service' + systemd: + name: plex_autoscan + state: stopped + when: plex_autoscan_service_running + + - name: Import 'plex_autoscan.service' + template: + src: plex_autoscan.service.j2 + dest: /etc/systemd/system/plex_autoscan.service + force: yes + + when: plex_autoscan_service.stat.exists + +- name: Services | New 'plex_autoscan.service' Tasks + block: + + - name: Import 'plex_autoscan.service' + template: + src: plex_autoscan.service.j2 + dest: /etc/systemd/system/plex_autoscan.service + force: yes + + when: not plex_autoscan_service.stat.exists diff --git a/menu/roles/plex_autoscan/tasks/subtasks/settings.yml b/menu/roles/plex_autoscan/tasks/subtasks/settings.yml new file mode 100644 index 00000000..8952ef7f --- /dev/null +++ b/menu/roles/plex_autoscan/tasks/subtasks/settings.yml @@ -0,0 +1,65 @@ +######################################################################### +# Title: Cloudbox: Plex Autoscan | Settings Task # +# Author(s): desimaniac # +# URL: https://github.com/cloudbox/cloudbox # +# -- # +# Part of the Cloudbox project: https://cloudbox.works # +######################################################################### +# GNU General Public License v3.0 # +######################################################################### +--- +- name: Settings | Install required packages + apt: + state: present + name: + - jq + - moreutils + +- name: Settings | Check if 'config.json' exists + stat: + path: "/opt/plex_autoscan/config/config.json" + register: plex_autoscan_config + +- name: Settings | New 'config.json' tasks + block: + + - name: Settings | Import default 'config.json' + template: + src: /opt/plexguide/menu/roles/plex_autoscan/templates/config.json.j2 + dest: /opt/plex_autoscan/config/config.json + owner: '1000' + group: '1000' + mode: 0775 + force: yes + + - name: Token Recall + shell: 'cat /var/plexguide/pgscan/plex.token' + register: plex_auth_token + + - name: Register IP + shell: 'cat /var/plexguide/server.ip' + register: ipaddress + + - name: plex_auto_scan server pass + shell: 'cat /var/plexguide/pgscan/pgscan.serverpass' + register: plex_autoscan_server_pass + + when: not plex_autoscan_config.stat.exists + +- name: Settings | Existing 'config.json' tasks + block: + + - name: Settings | Update 'PLEX_LD_LIBRARY_PATH' in 'config.json' + shell: | + CONFIG_PATH="/opt/plex_autoscan/config/config.json" + jq '.PLEX_LD_LIBRARY_PATH = "/usr/lib/plexmediaserver/lib"' ${CONFIG_PATH} | sponge ${CONFIG_PATH} + become: yes + + when: plex_autoscan_config.stat.exists + +# Update 'config.json' for new and existing setups + +- name: Settings | Upgrade 'config.json' + shell: "/opt/plex_autoscan/scan.py update_config" + ignore_errors: yes + tags: plex-autoscan-update-sections \ No newline at end of file diff --git a/menu/roles/plex_autoscan/tasks/vars/plex_autoscan.service b/menu/roles/plex_autoscan/tasks/vars/plex_autoscan.service new file mode 100644 index 00000000..209cf288 --- /dev/null +++ b/menu/roles/plex_autoscan/tasks/vars/plex_autoscan.service @@ -0,0 +1,22 @@ +#!/bin/bash +# +# Title: PTS - Plex Auto Scan - PLEX +# Authors: l3uddz +# URL: https://github.com/l3uddz/plex_autoscan +# GNU: General Public License v3.0 +################################################################################ +[Unit] +Description='Plex Autoscan' +After=multi-user.target network-online.target + +[Service] +User=0 +Group=0 +Type=simple +WorkingDirectory=/opt/plex_autoscan/ +ExecStart=/opt/plex_autoscan/scan.py server --loglevel=INFO +Restart=always +RestartSec=10 + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/menu/roles/plex_autoscan/templates/config.json.j2 b/menu/roles/plex_autoscan/templates/config.json.j2 new file mode 100644 index 00000000..66288a3b --- /dev/null +++ b/menu/roles/plex_autoscan/templates/config.json.j2 @@ -0,0 +1,104 @@ +{ + "DOCKER_NAME":"plex", + "GOOGLE": { + "ENABLED": false, + "CLIENT_ID": "", + "CLIENT_SECRET": "", + "ALLOWED": { + "FILE_PATHS": [ + "My Drive/Media/Movies/", + "My Drive/Media/TV/", + "My Drive/Media/Music/" + ], + "FILE_EXTENSIONS": true, + "FILE_EXTENSIONS_LIST": [ + "webm","mkv","flv","vob","ogv","ogg","drc","gif", + "gifv","mng","avi","mov","qt","wmv","yuv","rm", + "rmvb","asf","amv","mp4","m4p","m4v","mpg","mp2", + "mpeg","mpe","mpv","m2v","m4v","svi","3gp","3g2", + "mxf","roq","nsv","f4v","f4p","f4a","f4b","mp3", + "flac","ts" + ], + "MIME_TYPES": true, + "MIME_TYPES_LIST": [ + "video" + ] + }, + "TEAMDRIVE": false, + "TEAMDRIVES": [], + "POLL_INTERVAL": 120, + "SHOW_CACHE_LOGS": false + }, + "PLEX_ANALYZE_DIRECTORY":true, + "PLEX_ANALYZE_TYPE":"basic", + "PLEX_FIX_MISMATCHED":false, + "PLEX_DATABASE_PATH": "/opt/appdata/plex/database/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db", + "PLEX_EMPTY_TRASH":true, + "PLEX_EMPTY_TRASH_CONTROL_FILES":[ + "/mnt/unionfs/mounted.bin" + ], + "PLEX_EMPTY_TRASH_MAX_FILES":50, + "PLEX_EMPTY_TRASH_ZERO_DELETED":false, + "PLEX_LD_LIBRARY_PATH":"/usr/lib/plexmediaserver/lib", + "PLEX_LOCAL_URL": "http://localhost:32400", + "PLEX_SCANNER":"/usr/lib/plexmediaserver/Plex\\ Media\\ Scanner", + "PLEX_SUPPORT_DIR":"/var/lib/plexmediaserver/Library/Application\\ Support", + "PLEX_USER":"plex", + "PLEX_TOKEN":"{{plex_auth_token.stdout}}", + "PLEX_CHECK_BEFORE_SCAN":true, + "PLEX_WAIT_FOR_EXTERNAL_SCANNERS":false, + "RCLONE": { + "BINARY": "/usr/bin/rclone", + "CONFIG": "/opt/appdata/plexguide/rclone.conf", + "CRYPT_MAPPINGS": { + }, + "RC_CACHE_REFRESH": { + "ENABLED": false, + "FILE_EXISTS_TO_REMOTE_MAPPINGS": { + "Media/": [ + "/mnt/unionfs/" + ] + }, + "RC_URL": "http://localhost:5572" + } + }, + "RUN_COMMAND_BEFORE_SCAN":"", + "RUN_COMMAND_AFTER_SCAN": "", + "SERVER_ALLOW_MANUAL_SCAN":true, + "SERVER_FILE_CHECK_DELAY":60, + "SERVER_MAX_FILE_CHECKS":10, + "SERVER_FILE_EXIST_PATH_MAPPINGS":{ + "/mnt/":[ + "/mnt/" + ] + }, + "SERVER_IGNORE_LIST":[ + "/.grab/", + ".DS_Store", + "Thumbs.db" + ], + "SERVER_IP":"{{ipaddress.stdout}}", + "SERVER_PASS":"{{plex_autoscan_server_pass.stdout}}", + "SERVER_PATH_MAPPINGS":{ + "/mnt/":[ + "/mnt/" + ] + }, + "SERVER_PORT":3468, + "SERVER_SCAN_DELAY":60, + "SERVER_SCAN_FOLDER_ON_FILE_EXISTS_EXHAUSTION":true, + "SERVER_SCAN_PRIORITIES":{ + "0":[ + "/tv/" + ], + "1":[ + "/Movies/" + ], + "2":[ + "/Music/" + ] + }, + "SERVER_USE_SQLITE":false, + "USE_DOCKER":true, + "USE_SUDO":true +} diff --git a/menu/roles/plex_autoscan/templates/plex_autoscan.service.j2 b/menu/roles/plex_autoscan/templates/plex_autoscan.service.j2 new file mode 100644 index 00000000..0737af15 --- /dev/null +++ b/menu/roles/plex_autoscan/templates/plex_autoscan.service.j2 @@ -0,0 +1,29 @@ +# /etc/systemd/system/plex_autoscan.service +######################################################################### +# Title: Cloudbox: Plex Autoscan Service # +# MOD: MrDoobPG # +# Author(s): l3uddz # +# URL: https://github.com/cloudbox/cloudbox # +# -- # +# Part of the Cloudbox project: https://cloudbox.works # +######################################################################### +# GNU General Public License v3.0 # +######################################################################### + +[Unit] +Description=Plex Autoscan +After=network-online.target + +[Service] +User=0 +Group=0 +Type=simple +Environment=LC_ALL=C.UTF-8 +Environment=LANG=C.UTF-8 +WorkingDirectory=/opt/plex_autoscan/ +ExecStart=/opt/plex_autoscan/scan.py server --loglevel=INFO +Restart=always +RestartSec=10 + +[Install] +WantedBy=default.target diff --git a/menu/roles/plex_dupefinder/tasks/main.yml b/menu/roles/plex_dupefinder/tasks/main.yml new file mode 100644 index 00000000..fda04a87 --- /dev/null +++ b/menu/roles/plex_dupefinder/tasks/main.yml @@ -0,0 +1,109 @@ +######################################################################### +# Title: Cloudbox: Plex Dupefinder Role # +# Author(s): l3uddz # +# URL: https://github.com/cloudbox/cloudbox # +# -- # +# Part of the Cloudbox project: https://cloudbox.works # +######################################################################### +# GNU General Public License v3.0 # +######################################################################### +--- +- name: Set plex.user fact | username + shell: 'cat /var/plex_dupe/plex.user' + register: plexuser + +- name: Set plex.user fact | passwort + shell: 'cat /var/plex_dupe/plex.pw' + register: plexpass + +- name: Set plex.user fact | token + shell: 'cat /var/plex_dupe/plex.token' + register: plex_auth_token + +- name: Set plex_dupe in automode + shell: 'cat /var/plex_dupe/plex.authdel' + register: authdel + +- name: Display Plex Auth Token + debug: + msg: "Plex Auth Token: {{ plex_auth_token.stdout }}" + +- name: Create plex_dupefinder directories + file: "path={{ item }} state=directory mode=0775 owner=1000 group=1000 recurse=yes" + with_items: + - /opt/plex_dupefinder + +- name: Remove old Install + shell: 'sudo rm -rf /opt/plex_dupefinder' + +- name: Create plex_dupefinder directories + file: "path={{ item }} state=directory mode=0775 owner=1000 group=1000 recurse=yes" + with_items: + - /opt/plex_dupefinder + +- name: Clone plex_dupefinder == HEAD + git: + repo: https://github.com/l3uddz/plex_dupefinder.git + dest: /opt/plex_dupefinder + clone: yes + version: HEAD + force: yes + ignore_errors: yes + +- name: Clone plex_dupefinder repo == master + git: + repo: https://github.com/l3uddz/plex_dupefinder.git + dest: /opt/plex_dupefinder + clone: yes + version: master + force: yes + ignore_errors: yes + +- name: Install pip requirements + pip: + requirements: /opt/plex_dupefinder/requirements.txt + executable: pip3 + +- name: Check config exists + stat: + path: "/opt/plex_dupefinder/config.json" + register: plex_dupefinder_config + +- name: Import default config + template: + src: config.json.j2 + dest: /opt/plex_dupefinder/config.json + owner: '1000' + group: '1000' + mode: 0775 + force: no + when: not plex_dupefinder_config.stat.exists + +- name: Set plexdupes.py as executable + file: + path: /opt/plex_dupefinder/plex_dupefinder.py + owner: '1000' + group: '1000' + mode: a+x + +- name: "Create /usr/local/bin symlink" + file: + src: "/opt/plex_dupefinder/plex_dupefinder.py" + dest: "/usr/local/bin/plex_dupefinder" + state: link + +# scripts permissions +- name: 'Setting permissions on scripts' + shell: 'chown -cR 1000:1000 /opt/plex_dupefinder' + +# scripts permissions +- name: 'Setting permissions on scripts' + shell: 'chmod -cR 775 /opt/plex_dupefinder' + +- name: Remove .githube folder and .git files + file: "path={{ item }} state=absent" + with_items: + - '/opt/plex_dupefinder/.git' + - '/opt/plex_dupefinder/.github' + - '/opt/plex_dupefinder/assets' + - '/opt/plex_dupefinder/.gitignore' \ No newline at end of file diff --git a/menu/roles/plex_dupefinder/templates/config.json.j2 b/menu/roles/plex_dupefinder/templates/config.json.j2 new file mode 100644 index 00000000..cdeabafb --- /dev/null +++ b/menu/roles/plex_dupefinder/templates/config.json.j2 @@ -0,0 +1,78 @@ +{ + "AUDIO_CODEC_SCORES": { + "aac": 1000, + "ac3": 1000, + "dca": 2000, + "dca-ma": 4000, + "eac3": 1250, + "flac": 2500, + "mp2": 500, + "mp3": 1000, + "pcm": 2500, + "truehd": 4500, + "wmapro": 200, + "Unknown": 0 + }, + "AUTO_DELETE": {{authdel.stdout}}, + "FIND_DUPLICATE_FILEPATHS_ONLY": false, + "FILENAME_SCORES": { + "*Remux*": 20000, + "*1080p*BluRay*": 15000, + "*720p*BluRay*": 10000, + "*WEB*NTB*": 5000, + "*WEB*VISUM*": 5000, + "*WEB*KINGS*": 5000, + "*WEB*CasStudio*": 5000, + "*WEB*SiGMA*": 5000, + "*WEB*QOQ*": 5000, + "*WEB*TROLLHD*": 2500, + "*REPACK*": 1500, + "*PROPER*": 1500, + "*WEB*TBS*": -1000, + "*HDTV*": -1000, + "*dvd*": -1000, + "*.avi": -1000, + "*.ts": -1000, + "*.vob": -5000 + }, + "PLEX_LIBRARIES": { + "LIBRARY_NAME_1": #, + "LIBRARY_NAME_2": #, + "LIBRARY_NAME_3": #, + "LIBRARY_NAME_4": #, + "LIBRARY_NAME_5": #, + "LIBRARY_NAME_6": #, + "LIBRARY_NAME_7": #, + "LIBRARY_NAME_8": # + }, + "PLEX_SERVER": "http://localhost:32400", + "PLEX_TOKEN": "{{plex_auth_token.stdout}}", + "SCORE_FILESIZE": true, + "SKIP_LIST": [ + "/Plex Versions/" + ], + "VIDEO_CODEC_SCORES": { + "h264": 10000, + "h265": 5000, + "hevc": 5000, + "mpeg1video": 250, + "mpeg2video": 250, + "mpeg4": 500, + "msmpeg4": 100, + "msmpeg4v2": 100, + "msmpeg4v3": 100, + "vc1": 3000, + "vp9": 1000, + "wmv2": 250, + "wmv3": 250, + "Unknown": 0 + }, + "VIDEO_RESOLUTION_SCORES": { + "4k": 20000, + "1080": 10000, + "720": 5000, + "480": 3000, + "sd": 1000, + "Unknown": 0 + } +} diff --git a/menu/roles/plexpatrol/tasks/main.yml b/menu/roles/plexpatrol/tasks/main.yml new file mode 100644 index 00000000..b8860d3f --- /dev/null +++ b/menu/roles/plexpatrol/tasks/main.yml @@ -0,0 +1,179 @@ +######################################################################### +# Title: Cloudbox: plexpatrol Role # +# Author(s): l3uddz # +# URL: https://github.com/cloudbox/cloudbox # +# YML creator : MrDoob for PTS # +# -- # +# Part of the Cloudbox project: https://cloudbox.works # +######################################################################### +# GNU General Public License v3.0 # +######################################################################### +--- +- name: Check old Service's Existance + stat: + path: '/etc/systemd/system/pgpatrol.service' + register: pgp + +- name: Stop service + service: + name: pgpatrol + state: stopped + when: pgp.stat.exists + ignore_errors: yes + +- name: Daemon-PTS-Patrol stop + systemd: state=stopped name=pgpatrol daemon_reload=yes enabled=no + ignore_errors: yes + +- name: Remove old Basic Directories + file: 'path={{item}} state=absent mode=0775 owner=1000 group=1000' + with_items: + - '/opt/appdata/pgpatrol/' + - '/var/plexguide/pgpatrol' + - '/etc/systemd/system/pgpatrol.service' + when: pgp.stat.exists == true + ignore_errors: yes + +- name: Check Folder Existance + stat: + path: '/opt/appdata/pgpatrol/' + register: pgpatrol + +- debug: msg="Final Notes PG/PTSPatrol is now removed" + when: pgpatrol.stat.exists == False + +- name: Server ID + shell: 'cat /var/plexguide/pg.serverid' + register: serverid + +- name: Set plex.user fact | token + shell: 'cat /var/plexguide/plexpatrol/plex.token' + register: plex_auth_token + +- name: Recall User + shell: 'cat /var/plexguide/plexpatrol/plex.user' + register: user + +- name: Register IP + shell: 'cat /var/plexguide/server.ip' + register: ipaddress + +- name: Multiple IPs Info + shell: 'cat /var/plexguide/plexpatrol/multiple.ips' + register: multipleips + +- name: Kick Video Transcodes + shell: 'cat /var/plexguide/plexpatrol/video.transcodes' + register: videotranscodes + +- name: Kick 4k Transcodes + shell: 'cat /var/plexguide/plexpatrol/video.transcodes4k' + register: video4k + +- name: Kick Audio Transcodes + shell: 'cat /var/plexguide/plexpatrol/audio.transcodes' + register: audiotranscodes + +- name: check interval + shell: 'cat /var/plexguide/plexpatrol/check.interval' + register: checkinterval + +- name: Paused Info + shell: 'cat /var/plexguide/plexpatrol/kick.minutes' + register: kickminutes + +- name: Display Plex Auth Token + debug: + msg: "Plex Auth Token: {{ plex_auth_token.stdout }}" + +- name: Remove old Install + shell: 'sudo rm -rf /opt/appdata/plexpatrol' + +- name: Create plexpatrol directories + file: "path={{ item }} state=directory mode=0775 owner=1000 group=1000 recurse=yes" + with_items: + - /opt/appdata/plexpatrol + +- name: Clone plexpatrol == HEAD + git: + repo: https://github.com/l3uddz/plex_patrol.git + dest: /opt/appdata/plexpatrol + clone: yes + version: HEAD + force: yes + ignore_errors: yes + +- name: Clone plexpatrol repo == master + git: + repo: https://github.com/l3uddz/plex_patrol.git + dest: /opt/appdata/plexpatrol + clone: yes + version: master + force: yes + ignore_errors: yes + +- name: Install pip requirements + pip: + requirements: /opt/appdata/plexpatrol/requirements.txt + executable: pip3 + +- name: Check config exists + stat: + path: "/opt/appdata/plexpatrol/settings.ini" + register: plexpatrol_config + +- name: Import default config + template: + src: settings.ini.j2 + dest: /opt/appdata/plexpatrol/settings.ini + owner: '1000' + group: '1000' + mode: 0775 + force: no + when: not plexpatrol_config.stat.exists + +- name: Set patrol.py as executable + file: + path: /opt/appdata/plexpatrol/patrol.py + owner: '1000' + group: '1000' + mode: a+x + +- name: Check Service's Existance + stat: + path: '/etc/systemd/system/plexpatrol.service' + register: pgp + +- name: Stop service + service: + name: plexpatrol + state: stopped + when: pgp.stat.exists + +- name: Plex Patrol Service + template: + src: plexpatrol.service.j2 + dest: /etc/systemd/system/plexpatrol.service + force: yes + +- name: Daemon-Reload + systemd: state=stopped name=plexpatrol daemon_reload=yes enabled=no + +- name: Start Plex Patrol + systemd: state=started name=plexpatrol enabled=yes + +# scripts permissions +- name: 'Setting permissions on scripts' + shell: 'chown -cR 1000:1000 /opt/appdata/plexpatrol' + +# scripts permissions +- name: 'Setting permissions on scripts' + shell: 'chmod -cR 775 /opt/appdata/plexpatrol' + +- name: Remove .githube folder and .git files + file: "path={{ item }} state=absent" + with_items: + - '/opt/appdata/plexpatrol/.git' + - '/opt/appdata/plexpatrol/.github' + - '/opt/appdata/plexpatrol/assets' + - '/opt/appdata/plexpatrol/.gitignore' \ No newline at end of file diff --git a/menu/roles/plexpatrol/templates/plexpatrol.service.j2 b/menu/roles/plexpatrol/templates/plexpatrol.service.j2 new file mode 100644 index 00000000..6985c9c6 --- /dev/null +++ b/menu/roles/plexpatrol/templates/plexpatrol.service.j2 @@ -0,0 +1,15 @@ +[Unit] +Description=Plex Patrol +After=network-online.target + +[Service] +User=0 +Group=0 +Type=simple +WorkingDirectory=/opt/appdata/plexpatrol +ExecStart=/opt/appdata/plexpatrol/patrol.py +Restart=always +RestartSec=10 + +[Install] +WantedBy=default.target diff --git a/menu/roles/plexpatrol/templates/settings.ini.j2 b/menu/roles/plexpatrol/templates/settings.ini.j2 new file mode 100644 index 00000000..c8af312a --- /dev/null +++ b/menu/roles/plexpatrol/templates/settings.ini.j2 @@ -0,0 +1,37 @@ +[settings] +# show debug messages +DEBUG = false +# plex server url (e.g. http://ip:32400 or https://plex.reverse-proxy.com) +SERVER_URL = http://{{ipaddress.stdout}}:32400 +# plex token for server +SERVER_TOKEN = {{plex_auth_token.stdout}} +# name of server (does not matter, its used in the logs) +SERVER_NAME = {{serverid.stdout}} +# how often to check the active streams in seconds +CHECK_INTERVAL = {{checkinterval.stdout}} +# instantly kick 4K transcodes? +KICK_4K_TRANSCODE = {{video4k.stdout}} +# instantly kick video transcodes? true or false +KICK_VIDEO_TRANSCODES = {{videotranscodes.stdout}} +# instantly kick audio transcodes +KICK_AUDIO_TRANSCODES = {{audiotranscodes.stdout}} +# instantly kick any players from this , seperated list? +KICK_CLIENT_PLAYERS = Plex Web +# instantly kick streams from users with multiple ips +KICK_MULTIPLE_IP = true +# how many streams from unique ips before kicking extra user streams if above is true +KICK_MULTIPLE_IP_MAX = {{multipleips.stdout}} +# delay kick paused transcodes? (direct streams count too) +KICK_PAUSED_TRANSCODES = true +# delay kick paused direct plays? +KICK_PAUSED_DIRECTPLAY = false +# when the KICK_PAUSED* options above are true, the user has this many minutes to resume, otherwise kick +KICK_PAUSED_GRACE_MINS = {{kickminutes.stdout}} +# messages to be displayed for different kick types +KICK_PAUSED_MESSAGE = User can pause a stream for only {{kickminutes.stdout}} minutes! Booted! +KICK_4K_TRANSCODE_MESSAGE = You are not allowed to transcode 4K content, fix your settings! +KICK_TRANSCODE_MESSAGE = You are not allowed to transcode streams, use a better client! +KICK_PLAYER_MESSAGE = You are not allowed to use this trash player. Use the official software from www.plex.tv/downloads -> Get An App!!! +KICK_MULTI_IP_MESSAGE = You are not allowed to stream from more than {{multipleips.stdout}} IP address! +# user list seperated by a , who are immune from all kicks +WHITELISTED_USERS = {{user.stdout}} \ No newline at end of file diff --git a/menu/roles/pythonstart/pyansible.sh b/menu/roles/pythonstart/pyansible.sh new file mode 100644 index 00000000..0a6ca70c --- /dev/null +++ b/menu/roles/pythonstart/pyansible.sh @@ -0,0 +1,50 @@ + ansible="2.8.2" + pip="19.1.1" + + apt-get install -y --reinstall \ + nano \ + git \ + build-essential \ + libssl-dev \ + libffi-dev \ + python3-dev \ + python3-testresources \ + python3-pip \ + python3-testresources \ + python-dev \ + python-pip + python3 -m pip install --disable-pip-version-check --upgrade --force-reinstall pip==${pip} + python3 -m pip install --disable-pip-version-check --upgrade --force-reinstall setuptools + python3 -m pip install --disable-pip-version-check --upgrade --force-reinstall \ + pyOpenSSL \ + requests \ + netaddr \ + pipenv + python -m pip install --disable-pip-version-check --upgrade --force-reinstall pip==${pip} + python -m pip install --disable-pip-version-check --upgrade --force-reinstall setuptools + python -m pip install --disable-pip-version-check --upgrade --force-reinstall ansible==${1-$ansible} + + pip install -U --force-reinstall pip==9.0.3 + pip3 install -U --force-reinstall pip==9.0.3 + pip install --upgrade --force-reinstall pip==9.0.3 + pip install PyYAML --disable-pip-version-check + pip install --upgrade pip + pip install docker-py --ignore-installed PyYAML + + ## Copy pip to /usr/bin + cp /usr/local/bin/pip /usr/bin/pip + cp /usr/local/bin/pip3 /usr/bin/pip3 + + mkdir -p /etc/ansible/inventories/ 1>/dev/null 2>&1 + echo "[local]" >/etc/ansible/inventories/local + echo "127.0.0.1 ansible_connection=local" >>/etc/ansible/inventories/local + + ### Reference: https://docs.ansible.com/ansible/2.4/intro_configuration.html + echo "[defaults]" >/etc/ansible/ansible.cfg + echo "deprecation_warnings=False" >>/etc/ansible/ansible.cfg + echo "command_warnings = False" >>/etc/ansible/ansible.cfg + echo "callback_whitelist = profile_tasks" >>/etc/ansible/ansible.cfg + echo "inventory = /etc/ansible/inventories/local" >>/etc/ansible/ansible.cfg + + # Variables Need to Line Up with pg.sh (start) + touch /var/plexguide/background.1 \ No newline at end of file diff --git a/menu/roles/rcloneinstall/.travis.yml b/menu/roles/rcloneinstall/.travis.yml new file mode 100644 index 00000000..750093e1 --- /dev/null +++ b/menu/roles/rcloneinstall/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +services: docker + +env: + global: + - ROLE_NAME: ansible-rclone + matrix: + - MOLECULE_DISTRO: centos7 + - MOLECULE_DISTRO: fedora30 + - MOLECULE_DISTRO: fedora29 + - MOLECULE_DISTRO: fedora27 + - MOLECULE_DISTRO: ubuntu1804 + - MOLECULE_DISTRO: ubuntu1604 + - MOLECULE_DISTRO: ubuntu1404 + - MOLECULE_DISTRO: debian10 + - MOLECULE_DISTRO: debian9 + - MOLECULE_DISTRO: debian8 + +install: + # Install test dependencies. + - pip install molecule docker + +script: + # Run tests. + - molecule test -s travis + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/menu/roles/rcloneinstall/README.md b/menu/roles/rcloneinstall/README.md new file mode 100644 index 00000000..892e8c92 --- /dev/null +++ b/menu/roles/rcloneinstall/README.md @@ -0,0 +1,57 @@ +# ansible-rclone + +[![Build Status](https://travis-ci.org/stefangweichinger/ansible-rclone.svg?branch=master)](https://travis-ci.org/stefangweichinger/ansible-rclone) + +[![GitHub Open Issues](https://img.shields.io/github/issues/stefangweichinger/ansible-rclone.svg)](https://github.com/stefangweichinger/ansible-rclone/issues) +[![GitHub Stars](https://img.shields.io/github/stars/stefangweichinger/ansible-rclone.svg)](https://github.com/stefangweichinger/ansible-rclone) +[![GitHub Forks](https://img.shields.io/github/forks/stefangweichinger/ansible-rclone.svg)](https://github.com/stefangweichinger/ansible-rclone) + +[![Ansible Role](https://img.shields.io/ansible/role/15522.svg)](https://galaxy.ansible.com/stefangweichinger/rclone) +[![Ansible Role Downloads](https://img.shields.io/ansible/role/d/15522.svg)](https://galaxy.ansible.com/stefangweichinger/rclone) + + +ansible role to install [rclone](https://github.com/ncw/rclone) + +## Usage + +1. Clone this repo into your local roles-directory or install via `ansible-galaxy install stefangweichinger.rclone`. +2. Add role to the hosts you want rclone installed to. + +## Role Variables + +Available variables are listed below, along with default values (see `defaults/main.yml`): + + install_manpages: "true" + +This can be used to toggle the installation of manpages. + + rclone_arch: "amd64" + +This variable chooses the target architecture (for example 'amd64'). + + rclone_version: "" + +The version of rclone to install. `rclone_version` is no longer set as a default, but if provided as a variable, can be set to a specific version number or "beta" to install the latest beta version. + +## Dependencies + +None. + +## Example Playbook + + - hosts: rclone-hosts + roles: + - rclone + +## Tests + +New tests using [molecule](https://molecule.readthedocs.io/en/latest/index.html) + +pls feel free to review my first steps into testing the role with molecule +additional distros might be added/tested soon + +Currently there are two scenarios defined for running [molecule](https://molecule.readthedocs.io/en/latest/index.html): + +* default: runs tests over all defined distros at once, I use this for a local and overall test +* travis: this one runs one travis-test-job per distro and is called via .travis.yml + diff --git a/menu/roles/rcloneinstall/defaults/main.yml b/menu/roles/rcloneinstall/defaults/main.yml new file mode 100644 index 00000000..9a0e404b --- /dev/null +++ b/menu/roles/rcloneinstall/defaults/main.yml @@ -0,0 +1,15 @@ +--- +# rclone_arch can be defined as an architecture (e.g. arm, mips, 386) listed at https://github.com/ncw/rclone/releases +rclone_arch: amd64 + +install_manpages: true + +# Defaults in case no variables for OS are chosen +rclone_setup_tmp_dir: "/tmp/rclone_setup" + +PACKAGES: + - unzip + +MAN_PAGES: + OWNER: root + GROUP: root diff --git a/menu/roles/rcloneinstall/meta/main.yml b/menu/roles/rcloneinstall/meta/main.yml new file mode 100644 index 00000000..fc3ecafb --- /dev/null +++ b/menu/roles/rcloneinstall/meta/main.yml @@ -0,0 +1,29 @@ +--- + +dependencies: [] + +galaxy_info: + author: 'Stefan G. Weichinger' + description: 'Install rclone' + company: 'oops' + license: 'GNU General Public License v3' + min_ansible_version: '2.0' + platforms: + - name: Debian + versions: + - buster + - stretch + - jessie + - name: Fedora + versions: + - 30 + - 29 + - 27 + - name: Ubuntu + versions: + - bionic + - xenial + - trusty + galaxy_tags: + - networking + - system diff --git a/menu/roles/rcloneinstall/molecule/default/molecule.yml b/menu/roles/rcloneinstall/molecule/default/molecule.yml new file mode 100644 index 00000000..66ad58e5 --- /dev/null +++ b/menu/roles/rcloneinstall/molecule/default/molecule.yml @@ -0,0 +1,116 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint + options: + config-file: molecule/yaml-lint.yml +platforms: + + - name: centos7 + image: "geerlingguy/docker-centos7-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: false + pre_build_image: true + + - name: debian8 + image: "geerlingguy/docker-debian8-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: false + pre_build_image: true + + - name: debian9 + image: "geerlingguy/docker-debian9-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: false + pre_build_image: true + + - name: debian10 + image: "geerlingguy/docker-debian10-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: false + pre_build_image: true + + - name: fedora27 + image: "geerlingguy/docker-fedora27-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: false + pre_build_image: true + + - name: fedora29 + image: "geerlingguy/docker-fedora29-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: false + pre_build_image: true + + - name: fedora30 + image: "geerlingguy/docker-fedora30-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: false + pre_build_image: true + + - name: ubuntu1404 + image: "geerlingguy/docker-ubuntu1404-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: false + pre_build_image: true + + - name: ubuntu1604 + image: "geerlingguy/docker-ubuntu1604-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: false + pre_build_image: true + + - name: ubuntu1804 + image: "geerlingguy/docker-ubuntu1804-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: false + pre_build_image: true + +provisioner: + name: ansible + playbooks: + converge: ../playbook.yml + lint: + name: ansible-lint +scenario: + name: default + test_sequence: + - lint + - destroy + # - dependency + - syntax + - create + # - prepare + - converge + - idempotence + # - side_effect + - verify + - destroy +verifier: + name: testinfra + directory: ../tests/ + lint: + name: flake8 diff --git a/menu/roles/rcloneinstall/molecule/playbook.yml b/menu/roles/rcloneinstall/molecule/playbook.yml new file mode 100644 index 00000000..30fe2165 --- /dev/null +++ b/menu/roles/rcloneinstall/molecule/playbook.yml @@ -0,0 +1,5 @@ +--- +- name: Converge + hosts: all + roles: + - role: ansible-rclone diff --git a/menu/roles/rcloneinstall/molecule/tests/__pycache__/test_default.cpython-37-PYTEST.pyc b/menu/roles/rcloneinstall/molecule/tests/__pycache__/test_default.cpython-37-PYTEST.pyc new file mode 100644 index 00000000..4fcc9a54 Binary files /dev/null and b/menu/roles/rcloneinstall/molecule/tests/__pycache__/test_default.cpython-37-PYTEST.pyc differ diff --git a/menu/roles/rcloneinstall/molecule/tests/__pycache__/test_default.cpython-37.pyc b/menu/roles/rcloneinstall/molecule/tests/__pycache__/test_default.cpython-37.pyc new file mode 100644 index 00000000..855617b0 Binary files /dev/null and b/menu/roles/rcloneinstall/molecule/tests/__pycache__/test_default.cpython-37.pyc differ diff --git a/menu/roles/rcloneinstall/molecule/tests/test_default.py b/menu/roles/rcloneinstall/molecule/tests/test_default.py new file mode 100644 index 00000000..f328ddcc --- /dev/null +++ b/menu/roles/rcloneinstall/molecule/tests/test_default.py @@ -0,0 +1,14 @@ +import os + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +def test_hosts_file(host): + f = host.file('/usr/bin/rclone') + + assert f.exists + assert f.user == 'root' + assert f.group == 'root' diff --git a/menu/roles/rcloneinstall/molecule/travis/molecule.yml b/menu/roles/rcloneinstall/molecule/travis/molecule.yml new file mode 100644 index 00000000..8fb24317 --- /dev/null +++ b/menu/roles/rcloneinstall/molecule/travis/molecule.yml @@ -0,0 +1,42 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint + options: + config-file: molecule/yaml-lint.yml +platforms: + - name: instance + image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: false + pre_build_image: true +provisioner: + name: ansible + playbooks: + converge: ../playbook.yml + lint: + name: ansible-lint +scenario: + name: travis + test_sequence: + - lint + - destroy + # - dependency + - syntax + - create + # - prepare + - converge + - idempotence + # - side_effect + - verify + - destroy +verifier: + name: testinfra + directory: ../tests/ + lint: + name: flake8 diff --git a/menu/roles/rcloneinstall/molecule/yaml-lint.yml b/menu/roles/rcloneinstall/molecule/yaml-lint.yml new file mode 100644 index 00000000..55be306b --- /dev/null +++ b/menu/roles/rcloneinstall/molecule/yaml-lint.yml @@ -0,0 +1,8 @@ +--- + +extends: default + +rules: + line-length: + max: 140 + level: warning diff --git a/menu/roles/rcloneinstall/tasks/beta.yml b/menu/roles/rcloneinstall/tasks/beta.yml new file mode 100644 index 00000000..1de1f35b --- /dev/null +++ b/menu/roles/rcloneinstall/tasks/beta.yml @@ -0,0 +1,18 @@ +--- +- block: + - name: Check latest beta rclone version number + uri: + url: https://beta.rclone.org/version.txt + return_content: true + register: + rclone_latest_beta_version + - name: Set variable for beta version + set_fact: + rclone_version: "{{ rclone_latest_beta_version.content | replace ('rclone v', '', 1) | trim }}" + +- name: Get rclone latest beta version + unarchive: + src: https://beta.rclone.org/rclone-beta-latest-linux-{{ rclone_arch }}.zip + dest: "{{ rclone_setup_tmp_dir }}" + remote_src: true + creates: "{{ rclone_setup_tmp_dir }}/rclone-v{{ rclone_version }}-linux-{{ rclone_arch }}" diff --git a/menu/roles/rcloneinstall/tasks/main.yml b/menu/roles/rcloneinstall/tasks/main.yml new file mode 100644 index 00000000..c5c3e400 --- /dev/null +++ b/menu/roles/rcloneinstall/tasks/main.yml @@ -0,0 +1,72 @@ +--- +- name: Gather OS specific variables + include_vars: "{{ item }}" + with_first_found: + - '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml' + - '{{ ansible_distribution }}.yml' + - '{{ ansible_os_family }}.yml' + tags: + - vars + +- name: Update repositories cache on Ubuntu Xenial + apt: + update_cache: true + when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '16.04' + +- name: Install required packages + package: + name: '{{ item }}' + state: present + become: true + with_items: '{{ PACKAGES }}' + +- name: Create temporary working directory + file: + path: "{{ rclone_setup_tmp_dir }}" + state: directory + mode: '0775' + +- name: Do stable install + include_tasks: stable.yml + when: rclone_version is undefined or rclone_version != 'beta' + +- name: Do beta install + include_tasks: beta.yml + when: rclone_version == 'beta' + +- name: Copy rclone binary + copy: + src: "{{ rclone_setup_tmp_dir }}/rclone-v{{ rclone_version }}-linux-{{ rclone_arch }}/rclone" + dest: "/usr/bin/rclone" + mode: '0755' + owner: root + group: root + remote_src: true + become: true + +- name: Make dir for local manpages + file: + path: '{{ MAN_PAGES.PATH }}' + state: directory + mode: '0775' + owner: '{{ MAN_PAGES.OWNER }}' + group: '{{ MAN_PAGES.GROUP }}' + become: true + when: install_manpages + +- name: Copy rclone manpage + copy: + src: "{{ rclone_setup_tmp_dir }}/rclone-v{{ rclone_version }}-linux-{{ rclone_arch }}/rclone.1" + dest: "{{ MAN_PAGES.PATH }}/rclone.1" + mode: '0644' + owner: root + group: root + remote_src: true + become: true + when: install_manpages + +- name: Update mandb + command: mandb + become: true + changed_when: false + when: install_manpages diff --git a/menu/roles/rcloneinstall/tasks/stable.yml b/menu/roles/rcloneinstall/tasks/stable.yml new file mode 100644 index 00000000..0a42ba37 --- /dev/null +++ b/menu/roles/rcloneinstall/tasks/stable.yml @@ -0,0 +1,20 @@ +--- +- block: + - name: Check latest stable rclone version number + uri: + url: https://downloads.rclone.org/version.txt + return_content: true + register: + rclone_latest_version + check_mode: false + - name: Set variable to latest stable version number + set_fact: + rclone_version: "{{ rclone_latest_version.content | replace ('rclone v', '', 1) | trim }}" + when: rclone_version is undefined + +- name: Get rclone stable version {{ rclone_version }} + unarchive: + src: https://downloads.rclone.org/v{{ rclone_version }}/rclone-v{{ rclone_version }}-linux-{{ rclone_arch }}.zip + dest: "{{ rclone_setup_tmp_dir }}" + remote_src: true + creates: "{{ rclone_setup_tmp_dir }}/rclone-v{{ rclone_version }}-linux-{{ rclone_arch }}" diff --git a/menu/roles/rcloneinstall/tests/inventory b/menu/roles/rcloneinstall/tests/inventory new file mode 100644 index 00000000..d18580b3 --- /dev/null +++ b/menu/roles/rcloneinstall/tests/inventory @@ -0,0 +1 @@ +localhost \ No newline at end of file diff --git a/menu/roles/rcloneinstall/tests/test.yml b/menu/roles/rcloneinstall/tests/test.yml new file mode 100644 index 00000000..b890747e --- /dev/null +++ b/menu/roles/rcloneinstall/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - ansible-rclone diff --git a/menu/roles/rcloneinstall/vars/CentOS-6.yml b/menu/roles/rcloneinstall/vars/CentOS-6.yml new file mode 100644 index 00000000..caec5f56 --- /dev/null +++ b/menu/roles/rcloneinstall/vars/CentOS-6.yml @@ -0,0 +1,10 @@ +--- + +PACKAGES: + - unzip + - man + +MAN_PAGES: + OWNER: root + GROUP: root + PATH: '/usr/local/share/man/man1' diff --git a/menu/roles/rcloneinstall/vars/CentOS-7.yml b/menu/roles/rcloneinstall/vars/CentOS-7.yml new file mode 100644 index 00000000..bd057be7 --- /dev/null +++ b/menu/roles/rcloneinstall/vars/CentOS-7.yml @@ -0,0 +1,10 @@ +--- + +PACKAGES: + - unzip + - man-db + +MAN_PAGES: + OWNER: root + GROUP: root + PATH: '/usr/local/share/man/man1' diff --git a/menu/roles/rcloneinstall/vars/Debian.yml b/menu/roles/rcloneinstall/vars/Debian.yml new file mode 100644 index 00000000..7c0a33b7 --- /dev/null +++ b/menu/roles/rcloneinstall/vars/Debian.yml @@ -0,0 +1,10 @@ +--- + +PACKAGES: + - unzip + - man-db + +MAN_PAGES: + OWNER: root + GROUP: root + PATH: '/usr/share/man/man1' diff --git a/menu/roles/rcloneinstall/vars/Fedora.yml b/menu/roles/rcloneinstall/vars/Fedora.yml new file mode 100644 index 00000000..6949be28 --- /dev/null +++ b/menu/roles/rcloneinstall/vars/Fedora.yml @@ -0,0 +1,11 @@ +--- + +PACKAGES: + - unzip + - man + - file + +MAN_PAGES: + OWNER: root + GROUP: root + PATH: '/usr/local/share/man/man1' diff --git a/menu/roles/rcloneinstall/vars/Linuxmint.yml b/menu/roles/rcloneinstall/vars/Linuxmint.yml new file mode 100644 index 00000000..bd057be7 --- /dev/null +++ b/menu/roles/rcloneinstall/vars/Linuxmint.yml @@ -0,0 +1,10 @@ +--- + +PACKAGES: + - unzip + - man-db + +MAN_PAGES: + OWNER: root + GROUP: root + PATH: '/usr/local/share/man/man1' diff --git a/menu/roles/rcloneinstall/vars/RedHat.yml b/menu/roles/rcloneinstall/vars/RedHat.yml new file mode 100644 index 00000000..6949be28 --- /dev/null +++ b/menu/roles/rcloneinstall/vars/RedHat.yml @@ -0,0 +1,11 @@ +--- + +PACKAGES: + - unzip + - man + - file + +MAN_PAGES: + OWNER: root + GROUP: root + PATH: '/usr/local/share/man/man1' diff --git a/menu/roles/rcloneinstall/vars/Ubuntu.yml b/menu/roles/rcloneinstall/vars/Ubuntu.yml new file mode 100644 index 00000000..bd057be7 --- /dev/null +++ b/menu/roles/rcloneinstall/vars/Ubuntu.yml @@ -0,0 +1,10 @@ +--- + +PACKAGES: + - unzip + - man-db + +MAN_PAGES: + OWNER: root + GROUP: root + PATH: '/usr/local/share/man/man1' diff --git a/menu/roles/remove/tasks/main.yml b/menu/roles/remove/tasks/main.yml new file mode 100644 index 00000000..d26084a3 --- /dev/null +++ b/menu/roles/remove/tasks/main.yml @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Title: PTS remove old garbage +# YML Author: MrDoob for PTS +# GNU: General Public License v3.0 +################################################################################ +--- +- name: Remove Cloudplow | remove old cronjob + cron: + name: 'Cloudplow Clean' + user: 'root' + state: absent + +- name: Remove Cloudplow | directory + file: + state: absent + path: '/opt/appdata/cloudplow' + +- name: Remove Cloudplow | unused cronjob + cron: + state: absent + name: 'Cloudplow Clean' + user: 'root' + minute: '0' + hour: '0' + job: 'cd /opt/appdata/cloudplow && /usr/bin/python3 cloudplow.py clean' + +- name: Remove pgfork | not needed | never worked + file: + state: absent + path: '/bin/pgfork' + + diff --git a/menu/roles/system/files/etc/rc.local b/menu/roles/system/files/etc/rc.local new file mode 100644 index 00000000..65634dfa --- /dev/null +++ b/menu/roles/system/files/etc/rc.local @@ -0,0 +1,14 @@ +#!/bin/sh -e +# +# rc.local +# +# This script is executed at the end of each multiuser runlevel. +# Make sure that the script will "exit 0" on success or any other +# value on error. +# +# In order to enable or disable this script just change the execution +# bits. +# +# By default this script does nothing. + +exit 0 diff --git a/menu/roles/system/handlers/main.yml b/menu/roles/system/handlers/main.yml new file mode 100644 index 00000000..00d8fa75 --- /dev/null +++ b/menu/roles/system/handlers/main.yml @@ -0,0 +1,15 @@ +######################################################################### +# Title: Cloudbox: System Handler # +# Author(s): desimaniac # +# URL: https://github.com/cloudbox/cloudbox # +# -- # +# Part of the Cloudbox project: https://cloudbox.works # +######################################################################### +# GNU General Public License v3.0 # +######################################################################### +--- +- name: update locales + command: dpkg-reconfigure --frontend noninteractive locales + +- name: update tzdata + command: dpkg-reconfigure --frontend noninteractive tzdata diff --git a/menu/roles/system/tasks/main.yml b/menu/roles/system/tasks/main.yml new file mode 100644 index 00000000..e2cde541 --- /dev/null +++ b/menu/roles/system/tasks/main.yml @@ -0,0 +1,36 @@ +######################################################################### +# Title: Cloudbox: System Role # +# Author(s): l3uddz, desimaniac, EnorMOZ # +# URL: https://github.com/cloudbox/cloudbox # +# -- # +# Part of the Cloudbox project: https://cloudbox.works # +######################################################################### +# GNU General Public License v3.0 # +######################################################################### +--- +- name: APT tasks + include_tasks: "subtasks/apt.yml" + +- name: Network tasks + import_tasks: "subtasks/network.yml" + +- name: SYSCTL tasks + include_tasks: "subtasks/sysctl.yml" + +- name: Check if intel_pstate directory exists. + stat: + path: /sys/devices/system/cpu/intel_pstate + register: p + +- name: CPU Frequency tasks + include_tasks: "subtasks/cpufrequency.yml" + when: p.stat.isdir is defined and p.stat.isdir + +- name: Remove CPU Power task + include_tasks: "subtasks/remove_cpupower.yml" + +- name: Set Locale task + import_tasks: "subtasks/locale.yml" + tags: set-locale + +- meta: flush_handlers diff --git a/menu/roles/system/tasks/subtasks/apt.yml b/menu/roles/system/tasks/subtasks/apt.yml new file mode 100644 index 00000000..73fd83d9 --- /dev/null +++ b/menu/roles/system/tasks/subtasks/apt.yml @@ -0,0 +1,57 @@ +######################################################################### +# Title: System: APT Tasks # +# Author(s): l3uddz, desimaniac # +# URL: https://github.com/cloudbox/cloudbox # +# -- # +# Part of the Cloudbox project: https://cloudbox.works # +# -- # +# Mod: MrDoob # +######################################################################### +# GNU General Public License v3.0 # +######################################################################### +--- +- name: Set env variables + set_fact: + env_vars: + DEBIAN_FRONTEND: noninteractive + DEBIAN_PRIORITY: critical + +- name: Fix any potential dpkg issues + shell: dpkg --configure --pending + +- name: Kill existing apt and apt-get + shell: "killall apt apt-get >/dev/null 2>&1 || :" + ignore_errors: yes + +- name: Fix any potential apt issues + shell: apt-get install --fix-broken --quiet --yes + environment: "{{ env_vars }}" + ignore_errors: yes + +- name: Install required packages + apt: + state: latest + update_cache: yes + allow_unauthenticated: yes + force_apt_get: yes + force: yes + name: + - apt-utils + - byobu + +- name: Update APT package cache + apt: update_cache=yes cache_valid_time=600 + +- name: Upgrade APT to the latest packages + apt: upgrade=dist + register: apt_result + +- name: Autoremove unused packages + command: apt-get -y autoremove + register: apt_result + changed_when: "'packages will be REMOVED' in apt_result.stdout" + +- name: Purge residual kernel packages + shell: apt-get remove -y --purge $(dpkg -l | grep "^rc\s*linux-image-" | awk '{print $2}' | tr '\n' ' ') + register: apt_result + changed_when: "'packages will be REMOVED' in apt_result.stdout" \ No newline at end of file diff --git a/menu/roles/system/tasks/subtasks/cpufrequency.yml b/menu/roles/system/tasks/subtasks/cpufrequency.yml new file mode 100644 index 00000000..2137eb4c --- /dev/null +++ b/menu/roles/system/tasks/subtasks/cpufrequency.yml @@ -0,0 +1,68 @@ +######################################################################### +# Title: System: CPU Frequency Tasks # +# Author(s): l3uddz, EnorMOZ, desimaniac # +# URL: https://github.com/cloudbox/cloudbox # +# -- # +# Part of the Cloudbox project: https://cloudbox.works # +######################################################################### +# GNU General Public License v3.0 # +######################################################################### +--- +- name: Install 'cpufrequtils' + apt: + name: cpufrequtils + state: present + +- name: Install 'linux-tools' for Ubuntu + apt: + state: present + name: + - linux-tools-common + - linux-tools-generic + when: ansible_distribution == 'Ubuntu' + +- name: Install 'linux-tools' for Debian + apt: + name: linux-tools + state: present + when: ansible_distribution == 'Debian' + +- name: "Install linux-tools-{{ ansible_kernel }}" + shell: "apt-get install -qq $(apt-cache search -n linux-tools-{{ ansible_kernel }} | awk '{print $1}' | tail -n 1)" + ignore_errors: yes + +- name: Check /etc/default/cpufrequtils exists + stat: + path: /etc/default/cpufrequtils + register: cpufrequtils_file + +- name: Create /etc/default/cpufrequtils + file: + path: /etc/default/cpufrequtils + state: touch + when: not cpufrequtils_file.stat.exists + +- name: Set CPU frequency scaling governor to performance + lineinfile: + path: "/etc/default/cpufrequtils" + regexp: '^GOVENOR\s?=' + line: 'GOVENOR="performance"' + state: present + +- name: Set CPU frequency scaling governor to performance + lineinfile: + path: "/etc/default/cpufrequtils" + regexp: '^GOVERNOR\s?=' + line: 'GOVERNOR="performance"' + state: present + +- name: Ensure governor is enabled + lineinfile: + path: "/etc/default/cpufrequtils" + regexp: '^ENABLE\s?=' + line: 'ENABLE="true"' + state: present + +- name: Disable ondemand CPU frequency scaling daemon + shell: "update-rc.d ondemand disable" + when: ansible_distribution_version == "16.04" diff --git a/menu/roles/system/tasks/subtasks/locale.yml b/menu/roles/system/tasks/subtasks/locale.yml new file mode 100644 index 00000000..f35ba660 --- /dev/null +++ b/menu/roles/system/tasks/subtasks/locale.yml @@ -0,0 +1,36 @@ +######################################################################### +# Title: System: Locale Tasks # +# Author(s): desimaniac # +# URL: https://github.com/cloudbox/cloudbox # +# -- # +# Part of the Cloudbox project: https://cloudbox.works # +######################################################################### +# GNU General Public License v3.0 # +######################################################################### +--- +- name: "Install 'locales'" + apt: + name: locales + state: present + +- name: "Generate 'locales'" + locale_gen: + name: "en_US.UTF-8" + state: present + notify: update locales + +- name: "Uncomment 'LANG='" + replace: + path: "/etc/default/locale" + regexp: '^#(LANG=.*)' + replace: '\1' + +- name: "Set Default 'locale'" + ini_file: + path: "/etc/default/locale" + section: null + option: "LANG" + value: "en_US.UTF-8" + state: present + no_extra_spaces: yes + notify: update locales diff --git a/menu/roles/system/tasks/subtasks/network.yml b/menu/roles/system/tasks/subtasks/network.yml new file mode 100644 index 00000000..4d2de488 --- /dev/null +++ b/menu/roles/system/tasks/subtasks/network.yml @@ -0,0 +1,63 @@ +######################################################################### +# Title: System: Network Tasks # +# Author(s): desimaniac # +# URL: https://github.com/cloudbox/cloudbox # +# -- # +# Part of the Cloudbox project: https://cloudbox.works # +######################################################################### +# GNU General Public License v3.0 # +######################################################################### +--- +- name: Install common packages + apt: + state: present + name: + - vnstat + - pciutils + +- block: + + - name: Check for '/etc/vnstat.conf' + stat: + path: "/etc/vnstat.conf" + register: vnstat_conf + + - name: Set vnstat to proper default interface + lineinfile: + path: "/etc/vnstat.conf" + regexp: '(Interface)\s?.*' + line: '\1 "{{ ansible_default_ipv4.interface }}"' + state: present + backrefs: yes + when: (vnstat_conf.stat.exists) + + - name: Import rc.local if missing + copy: + src: "etc/rc.local" + dest: "/etc/rc.local" + owner: "root" + group: "root" + mode: 0755 + force: no + + - name: Get nic info + shell: lspci + register: nic + + - name: Disable TSO / TX + blockinfile: + path: "/etc/rc.local" + state: present + create: no + marker: "### {mark} CLOUDBOX MANAGED BLOCK ###" + block: | + /sbin/ifconfig {{ ansible_default_ipv4.interface }} txqueuelen 10000 + ethtool -G {{ ansible_default_ipv4.interface }} rx 4096 tx 4096 + ethtool -K {{ ansible_default_ipv4.interface }} tso off tx off + insertbefore: "^exit 0" + owner: "root" + group: "root" + mode: 0755 + when: ('I218' in nic.stdout) or ('I219' in nic.stdout) + + when: (ansible_default_ipv4 is defined) and (ansible_default_ipv4.type == "ether") diff --git a/menu/roles/system/tasks/subtasks/remove_cpupower.yml b/menu/roles/system/tasks/subtasks/remove_cpupower.yml new file mode 100644 index 00000000..6dbc92c4 --- /dev/null +++ b/menu/roles/system/tasks/subtasks/remove_cpupower.yml @@ -0,0 +1,29 @@ +######################################################################### +# Title: System: Remove CPU Power Tasks # +# Author(s): desimaniac # +# URL: https://github.com/cloudbox/cloudbox # +# -- # +# Part of the Cloudbox project: https://cloudbox.works # +######################################################################### +# GNU General Public License v3.0 # +######################################################################### +--- +- name: Check if cpupower.service exists + stat: + path: "/etc/systemd/system/cpupower.service" + register: cpupower_service + +- name: Stop and disable cpupower.service + systemd: + state: stopped + name: cpupower + daemon_reload: yes + enabled: no + ignore_errors: yes + when: cpupower_service.stat.exists + +- name: Delete cpupower.service + file: + path: /etc/systemd/system/cpupower.service + state: absent + when: cpupower_service.stat.exists diff --git a/menu/roles/system/tasks/subtasks/sysctl.yml b/menu/roles/system/tasks/subtasks/sysctl.yml new file mode 100644 index 00000000..d4c938e8 --- /dev/null +++ b/menu/roles/system/tasks/subtasks/sysctl.yml @@ -0,0 +1,92 @@ +######################################################################### +# Title: System: SYSCTL Tasks # +# Author(s): l3uddz, desimaniac # +# URL: https://github.com/cloudbox/cloudbox # +# -- # +# Part of the Cloudbox project: https://cloudbox.works # +######################################################################### +# GNU General Public License v3.0 # +######################################################################### +--- +- name: SYSCTL Tuning + ignore_errors: yes + sysctl: + name: "{{ item.name }}" + value: "{{ item.value }}" + state: present + loop: + # Enable tcp_window_scaling + - { name: net.ipv4.tcp_window_scaling, value: 1 } + # Increase rmem_max test buffer limit to 64 MB + - { name: net.core.rmem_max, value: 67108864 } + # Increase wmem_max test buffer limit to 64 MB + - { name: net.core.wmem_max, value: 67108864 } + # Increase tcp_rmem autotune buffer limit to 32 MB + - { name: net.ipv4.tcp_rmem, value: "4096 87380 33554432" } + # Increase tcp_wmem autotune buffer limit to 32 MB + - { name: net.ipv4.tcp_wmem, value: "4096 87380 33554432" } + # Set tcp_congestion_control to bbr + - { name: net.ipv4.tcp_congestion_control, value: bbr } + # Increase system file descriptor limit + - { name: fs.file-max, value: 100000 } + # Reduce swappiness + - { name: vm.swappiness, value: 10 } + # Set dirty_ratio + - { name: vm.dirty_ratio, value: 15 } + # Set dirty_background_ratio + - { name: vm.dirty_background_ratio, value: 10 } + # Set somaxconn to 1024 + - { name: net.core.somaxconn, value: 1024 } + # Increase netdev_max_backlog + - { name: net.core.netdev_max_backlog, value: 100000 } + # Increase tcp_max_syn_backlog + - { name: net.ipv4.tcp_max_syn_backlog, value: 30000 } + # Increase tcp_max_tw_buckets + - { name: net.ipv4.tcp_max_tw_buckets, value: 2000000 } + # Enable tcp_tw_reuse + - { name: net.ipv4.tcp_tw_reuse, value: 1 } + # Enable tcp_mtu_probing + - { name: net.ipv4.tcp_mtu_probing, value: 1 } + # Enable tcp_sack + - { name: net.ipv4.tcp_sack, value: 1 } + # Increase tcp_adv_win_scale + - { name: net.ipv4.tcp_adv_win_scale, value: 2 } + # Enable tcp_rfc1337 + - { name: net.ipv4.tcp_rfc1337, value: 1 } + # Increase tcp_fin_timeout + - { name: net.ipv4.tcp_fin_timeout, value: 10 } + # Disable tcp_slow_start_after_idle + - { name: net.ipv4.tcp_slow_start_after_idle, value: 0 } + # Increase udp_rmem_min + - { name: net.ipv4.udp_rmem_min, value: 8192 } + # Increase udp_wmem_min + - { name: net.ipv4.udp_wmem_min, value: 8192 } + # Disable accept_source_route + - { name: net.ipv4.conf.all.accept_source_route, value: 0 } + # Disable accept_redirects + - { name: net.ipv4.conf.all.accept_redirects, value: 0 } + # Disable secure_redirects + - { name: net.ipv4.conf.all.secure_redirects, value: 0 } + # Set default_qdisc to fq + - { name: net.core.default_qdisc, value: fq } + # Set max_user_watches for plex inotify + - { name: fs.inotify.max_user_watches, value: 131072 } + # Set net.core.netdev_budget + - { name: net.core.netdev_budget, value: 50000 } + + +- name: Check to see if '/proc/sys/net/core/netdev_budget_usecs' exists + stat: + path: "/proc/sys/net/core/netdev_budget_usecs" + register: netdev_budget_usecs + +- name: "SYSCTL Tuning - 'netdev_budget_usecs'" + ignore_errors: yes + sysctl: + name: "{{ item.name }}" + value: "{{ item.value }}" + state: present + loop: + # Set netdev_budget_usecs + - { name: net.core.netdev_budget_usecs, value: 5000 } + when: netdev_budget_usecs.stat.exists diff --git a/menu/roles/traktarr/tasks/main.yml b/menu/roles/traktarr/tasks/main.yml new file mode 100644 index 00000000..a133812f --- /dev/null +++ b/menu/roles/traktarr/tasks/main.yml @@ -0,0 +1,185 @@ +######################################################################### +# Title: Cloudbox: traktarr Role # +# Author(s): l3uddz # +# URL: https://github.com/cloudbox/cloudbox # +# YML creator : MrDoob for PTS # +# -- # +# Part of the Cloudbox project: https://cloudbox.works # +######################################################################### +# GNU General Public License v3.0 # +######################################################################### +--- +- name: Check old Service's Existance + stat: + path: '/etc/systemd/system/traktarr.service' + register: pgp + +- name: Stop old service + service: + name: traktarr + state: stopped + when: pgp.stat.exists + ignore_errors: yes + +- name: Daemon - Traktarr stop + systemd: state=stopped name=traktarr daemon_reload=yes enabled=no + ignore_errors: yes + +- name: Remove old Basic Directories + file: 'path={{item}} state=absent mode=0775 owner=1000 group=1000' + with_items: + - '/opt/appdata/traktarr/' + - '/etc/systemd/system/traktarr.service' + when: pgp.stat.exists == true + ignore_errors: yes + +- name: Check Folder Existance + stat: + path: '/opt/appdata/traktarr/' + register: traktarr + +- debug: msg="Final Notes Traktarr is now removed" + when: traktarr.stat.exists == False + +- name: Remove old symlink /usr/local/bin/traktarr + shell: 'rm -rf /usr/local/bin/traktarr' + ignore_errors: True + +- name: Remove old symlink /bin/traktarr + shell: 'rm -rf /bin/traktarr' + ignore_errors: True + +- name: Server ID + shell: 'cat /var/plexguide/pg.serverid' + register: serverid + +- name: Sonarr API + shell: 'cat /var/plexguide/traktarr/pgtrak.sapi' + register: sapi + ignore_errors: True + +- name: Radarr API + shell: 'cat /var/plexguide/traktarr/pgtrak.rapi' + register: rapi + ignore_errors: True + +- name: Sonarr Profile + shell: 'cat /var/plexguide/traktarr/pgtrak.sprofile' + register: sprofile + ignore_errors: True + +- name: Radarr Profile + shell: 'cat /var/plexguide/traktarr/pgtrak.rprofile' + register: rprofile + ignore_errors: True + +- name: Trakt.tv Client + shell: 'cat /var/plexguide/traktarr/pgtrak.client' + register: client + ignore_errors: True + +- name: Trakt.tv Secret + shell: 'cat /var/plexguide/traktarr/pgtrak.secret' + register: secret + ignore_errors: True + +- name: Radarr Path + shell: 'cat /var/plexguide/traktarr/pgtrak.rpath' + register: rpath + ignore_errors: True + +- name: Sonnar Path + shell: 'cat /var/plexguide/traktarr/pgtrak.spath' + register: spath + ignore_errors: True + +- name: Max allowed Year + shell: 'cat /var/plexguide/traktarr/pgtrakyear.max' + register: year + ignore_errors: True + +- name: Remove old Install + shell: 'sudo rm -rf /opt/appdata/traktarr' + +- name: Create traktarr directories + file: "path={{ item }} state=directory mode=0775 owner=1000 group=1000 recurse=yes" + with_items: + - /opt/appdata/traktarr + +- name: Clone l3uddz/traktarr == HEAD + git: + repo: https://github.com/l3uddz/traktarr.git + dest: /opt/appdata/traktarr + clone: yes + version: HEAD + force: yes + ignore_errors: yes + +- name: Clone l3uddz/traktarr repo == master + git: + repo: https://github.com/l3uddz/traktarr.git + dest: /opt/appdata/traktarr + clone: yes + version: master + force: yes + ignore_errors: yes + +- name: Install pip requirements + pip: + requirements: /opt/appdata/traktarr/requirements.txt + executable: pip3 + +- name: Check config exists + stat: + path: "/opt/appdata/traktarr/config.json" + register: traktarr_config + +- name: Import default config + template: + src: config.json.j2 + dest: /opt/appdata/traktarr/config.json + owner: '1000' + group: '1000' + mode: 0775 + force: yes + +- name: Set traktarr.py as executable + file: + path: /opt/appdata/traktarr/traktarr.py + owner: '1000' + group: '1000' + mode: a+x + +- name: Set directory permissions + file: "path=/opt/appdata/traktarr state=directory owner=1000 group=1000 recurse=yes" + +- name: "Create /usr/local/bin symlink" + shell: 'sudo ln -s /opt/appdata/traktarr/traktarr.py /usr/local/bin/traktarr' + +- name: Traktarr Service + template: + src: traktarr.service.j2 + dest: /etc/systemd/system/traktarr.service + force: yes + +- name: Daemon-Reload for Traktarr + systemd: state=stopped name=traktarr daemon_reload=yes enabled=no + +- name: Start Traktarr Service + systemd: state=started name=traktarr enabled=yes + +# scripts permissions +- name: 'Setting permissions on scripts' + shell: 'chown -cR 1000:1000 /opt/appdata/traktarr' + +# scripts permissions +- name: 'Setting permissions on scripts' + shell: 'chmod -cR 775 /opt/appdata/traktarr' + +- name: Remove .githube folder and .git files + file: "path={{ item }} state=absent" + with_items: + - '/opt/appdata/traktarr/.git' + - '/opt/appdata/traktarr/.github' + - '/opt/appdata/traktarr/assets' + - '/opt/appdata/traktarr/.gitignore' \ No newline at end of file diff --git a/menu/roles/traktarr/templates/config.json.j2 b/menu/roles/traktarr/templates/config.json.j2 new file mode 100644 index 00000000..2e5dd880 --- /dev/null +++ b/menu/roles/traktarr/templates/config.json.j2 @@ -0,0 +1,136 @@ +{ + "automatic": { + "movies": { + "anticipated": 12, + "boxoffice": 20, + "interval": 12, + "popular": 15, + "trending": 30, + "watched": 10, + "played_all": 10 + }, + "shows": { + "anticipated": 20, + "interval": 12, + "popular": 4, + "trending": 5, + "played": 10, + "watched_monthly": 3 + } + }, + "core": { + "debug": false + }, + "filters": { + "movies": { + "disabled_for": [], + "allowed_countries": [ + "en", + "us", + "gb", + "ca", + "de", + "es", + "fr" + ], + "allowed_languages": [ + "en", + "us", + "gb", + "ca", + "de" + ], + "blacklisted_genres": [ + "documentary", + "music" + ], + "blacklisted_max_runtime": 0, + "blacklisted_max_year": {{year.stdout}}, + "blacklisted_min_runtime": 10, + "blacklisted_min_year": 1980, + "blacklisted_title_keywords": [ + "untitled", + "barbie", + "ufc" + ], + "blacklisted_tmdb_ids": [], + "disabled_for": [], + "rotten_tomatoes": "" + }, + "shows": { + "disabled_for": [], + "allowed_countries": [ + "en", + "us", + "gb", + "ca", + "de", + "es", + "fr" + ], + "allowed_languages": [ + "en", + "us", + "gb", + "ca", + "de" + ], + "blacklisted_genres": [ + "game-show", + "talk-show", + "home-and-garden", + "children", + "reality", + "news", + "special-interest" + ], + "blacklisted_networks": [ + "twitch", + "youtube", + "nickelodeon", + "hallmark", + "reelzchannel", + "disney", + "cnn", + "cbbc", + "the movie network", + "teletoon", + "cartoon network", + "espn", + "yahoo!", + "fox sports" + ], + "blacklisted_max_runtime": 0, + "blacklisted_min_runtime": 10, + "blacklisted_min_year": 1980, + "blacklisted_max_year": {{year.stdout}}, + "blacklisted_title_keywords": [], + "blacklisted_tvdb_ids": [] + } + }, + "notifications": { + "verbose": true + }, + "omdb": { + "api_key": "" + }, + "radarr": { + "api_key": "{{rapi.stdout}}", + "minimum_availability": "announced", + "quality": "{{rprofile.stdout}}", + "root_folder": "{{rpath.stdout}}", + "url": "http://localhost:7878/" + }, + "sonarr": { + "api_key": "{{sapi.stdout}}", + "language": "English", + "quality": "{{sprofile.stdout}}", + "root_folder":"{{spath.stdout}}", + "tags": {}, + "url": "http://localhost:8989/" + }, + "trakt": { + "client_id": "{{client.stdout}}", + "client_secret": "{{secret.stdout}}" + } +} diff --git a/menu/roles/traktarr/templates/traktarr.service.j2 b/menu/roles/traktarr/templates/traktarr.service.j2 new file mode 100644 index 00000000..bde2b46b --- /dev/null +++ b/menu/roles/traktarr/templates/traktarr.service.j2 @@ -0,0 +1,17 @@ +[Unit] +Description='Traktarr' +After=multi-user.target network-online.target + +[Service] +User=0 +Group=0 +Type=simple +Environment="LC_ALL=C.UTF-8" +Environment="LANG=C.UTF-8" +WorkingDirectory=/opt/appdata/traktarr/ +ExecStart=/usr/bin/python3 /opt/appdata/traktarr/traktarr.py run +Restart=always +RestartSec=10 + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/menu/roles/update/tasks/main.yml b/menu/roles/update/tasks/main.yml new file mode 100644 index 00000000..286ccdcd --- /dev/null +++ b/menu/roles/update/tasks/main.yml @@ -0,0 +1,83 @@ +--- +- name : Update APT to latest packages + apt: + update_cache: yes + autoclean: yes + autoremove: yes + cache_valid_time: 86400 + force_apt_get: yes + register: apt_result + +- name: Upgrade Distrubution to the latest stable version + apt: + upgrade: full + state: present + force_apt_get: yes + register: apt_result + +- name: Install a list of packages + apt: + name: "{{ packages }}" + state: latest + update_cache: yes + allow_unauthenticated: yes + force_apt_get: yes + force: yes + vars: + packages: + - ctop + - dnsutils + - software-properties-common + - sysstat + - nmon + - fortune + - fortune-mod + - fortunes-bofh-excuses + - figlet + - lolcat + +- name: Replace false to true in systat + lineinfile: + path: /etc/default/sysstat + regexp: '^ENABLED=' + line: ENABLED=true + +- name: remove | cowsay + apt: + name: "{{ packages }}" + state: absent + force_apt_get: yes + force: yes + vars: + packages: + - cowsay + - nodejs + +- name: Ensure systat is ENABLED=true + lineinfile: + path: /etc/default/sysstat + regexp: '^ENABLED=' + line: ENABLED=true + +- name: Remove useless packages from the cache + apt: + autoclean: yes + autoremove: yes + force_apt_get: yes + +- name: Fix filled /boot + #shell: apt-get remove `dpkg --list 'linux-image*' | grep ^ii | awk '{print $2}'\ | grep -v \`uname -r\`` + shell: dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge + +- name: Update APT package cache + apt: update_cache=yes cache_valid_time=600 force_apt_get=yes + +- name: Autoremove unused packages + command: apt-get -y autoremove + register: apt_result + changed_when: "'packages will be REMOVED' in apt_result.stdout" + +- name: Purge residual kernel packages + shell: apt-get remove -y --purge $(dpkg -l | grep "^rc\s*linux-image-" | awk '{print $2}' | tr '\n' ' ') + register: apt_result + changed_when: "'packages will be REMOVED' in apt_result.stdout" diff --git a/menu/start/start.sh b/menu/start/start.sh new file mode 100644 index 00000000..c42d7ce2 --- /dev/null +++ b/menu/start/start.sh @@ -0,0 +1,315 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +# Create Variables (If New) & Recall +pcloadletter() { + filevg="/var/plexguide" + touch $filevg/pgclone.transport + temp=$(cat /var/plexguide/pgclone.transport) + if [ "$temp" == "mu" ]; then + transport="Move" + elif [ "$temp" == "me" ]; then + transport="Move: Encrypted" + elif [ "$temp" == "bu" ]; then + transport="Blitz" + elif [ "$temp" == "be" ]; then + transport="Blitz: Encrypted" + elif [ "$temp" == "le" ]; then + transport="Local" + else transport="NOT-SET"; fi + echo "$transport" >$filevg/pg.transport +} + +variable() { + file="$1" + if [ ! -e "$file" ]; then echo "$2" >$1; fi +} + +# What Loads the Order of Execution +primestart() { + pcloadletter + varstart + gcetest +} +wisword=$(/usr/games/fortune -as | sed "s/^/ /") + +varstart() { + ###################### FOR VARIABLS ROLE SO DOESNT CREATE RED - START + filevg="/var/plexguide" + if [ ! -e "$filevg" ]; then + mkdir -p $filevg/logs 1>/dev/null 2>&1 + chown -R 1000:1000 $file 1>/dev/null 2>&1 + chmod -R 775 $file 1>/dev/null 2>&1 + fi + fileag="/opt/appdata/plexguide" + if [ ! -e "$fileag" ]; then + mkdir -p $fileag 1>/dev/null 2>&1 + chown -R 1000:1000 $fileag 1>/dev/null 2>&1 + chmod -R 775 $fileag 1>/dev/null 2>&1 + fi + + ###################### FOR VARIABLS ROLE SO DOESNT CREATE RED - START + variable $filevg/pgfork.project "NOT-SET" + variable $filevg/pgfork.version "NOT-SET" + variable $filevg/tld.program "NOT-SET" + variable $fileag/plextoken "NOT-SET" + variable $filevg/server.ht "" + variable $filevg/server.ports "127.0.0.1:" + variable $filevg/server.email "NOT-SET" + variable $filevg/server.domain "NOT-SET" + variable $filevg/tld.type "standard" + variable $filevg/transcode.path "standard" + variable $filevg/pgclone.transport "NOT-SET" + variable $filevg/plex.claim "" + + #### Temp Fix - Fixes Bugged AppGuard + serverht=$(cat /var/plexguide/server.ht) + if [ "$serverht" == "NOT-SET" ]; then + rm $filevg/server.ht + touch $filevg/server.ht + fi + + hostname -I | awk '{print $1}' >$filevg/server.ip + ###################### FOR VARIABLS ROLE SO DOESNT CREATE RED - END + value="/etc/bash.bashrc.local" + rm -rf $value && echo -e "export NCURSES_NO_UTF8_ACS=1" >>$value + + # run pg main + file="/var/plexguide/update.failed" + if [ -e "$file" ]; then + rm -rf /var/plexguide/update.failed + exit + fi + ################################################################################# + + # Touch Variables Incase They Do Not Exist + touch $filevg/pg.edition + touch $filevg/server.id + touch $filevg/pg.number + touch $filevg/traefik.deployed + touch $filevg/server.ht + touch $filevg/server.ports + touch $filevg/pg.server.deploy + + # For PG UI - Force Variable to Set + ports=$(cat /var/plexguide/server.ports) + if [ "$ports" == "" ]; then + echo "Open" >$filevg/pg.ports + else echo "Closed" >$filevg/pg.ports; fi + + ansible --version | head -n +1 | awk '{print $2'} >$filevg/pg.ansible + docker --version | head -n +1 | awk '{print $3'} | sed 's/,$//' >$filevg/pg.docker + lsb_release -si >$filevg/pg.os + + file="/var/plexguide/gce.false" + if [ -e "$file" ]; then echo "No" >$filevg/pg.gce; else echo "Yes" >$filevg/pg.gce; fi + + # Call Variables + edition=$(cat /var/plexguide/pg.edition) + serverid=$(cat /var/plexguide/server.id) + pgnumber=$(cat /var/plexguide/pg.number) + + # Declare Traefik Deployed Docker State + if [[ $(docker ps --format {{.Names}}| grep "traefik") != "traefik" ]]; then + traefik="NOT DEPLOYED" + echo "Not Deployed" >$filevg/pg.traefik + else + traefik="DEPLOYED" + echo "Deployed" >$filevg/pg.traefik + fi + + if [[ $(docker ps --format {{.Names}}| grep "oauth") != "oauth" ]]; then + oauth="NOT DEPLOYED" + echo "Not Deployed" >$filevg/pg.auth + else + oauth="DEPLOYED" + echo "Deployed" >$filevg/pg.oauth + fi + + # For ZipLocations + file="/var/plexguide/data.location" + if [ ! -e "$file" ]; then echo "/opt/appdata/plexguide" >$filevg/data.location; fi + + space=$(cat /var/plexguide/data.location) + used=$(df -h / --local | tail -n +2 | awk '{print $3}' ) + capacity=$(df -h / --local | tail -n +2 | awk '{print $2}') + percentage=$(df -h / --local | tail -n +2 | awk '{print $5}') + + # For the PGBlitz UI + echo "$used" >$filevg/pg.used + echo "$capacity" >$filevg/pg.capacity +} + +gcetest(){ +gce=$(cat /var/plexguide/pg.server.deploy) + +if [[ $gce == "feeder" ]]; then +menuprime1 +else menuprime2; fi +} + +menuprime1() { + transport=$(cat /var/plexguide/pg.transport) + + # Menu Interface + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🌎 $transport | Version: $pgnumber | ID: $serverid +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +🌵 Disk Used Space: $used of $capacity | $percentage Used Capacity +EOF + + # Displays Second Drive If GCE + edition=$(cat /var/plexguide/pg.server.deploy) + if [ "$edition" == "feeder" ]; then + used_gce=$(df -h /mnt --local | tail -n +2 | awk '{print $3}') + capacity_gce=$(df -h /mnt --local | tail -n +2 | awk '{print $2}') + percentage_gce=$(df -h /mnt --local | tail -n +2 | awk '{print $5}') + echo " GCE Disk Used Space: $used_gce of $capacity_gce | $percentage_gce Used Capacity" + fi + + disktwo=$(cat "/var/plexguide/server.hd.path") + if [ "$edition" != "feeder" ]; then + used_gce2=$(df -h "$disktwo" --local | tail -n +2 | awk '{print $3}') + capacity_gce2=$(df -h "$disktwo" --local | tail -n +2 | awk '{print $2}') + percentage_gce2=$(df -h "$disktwo" --local | tail -n +2 | awk '{print $5}') + + if [[ "$disktwo" != "/mnt" ]]; then + echo " 2nd Disk Used Space: $used_gce2 of $capacity_gce2 | $percentage_gce2 Used Capacity" + fi + fi + + # Declare Ports State + ports=$(cat /var/plexguide/server.ports) + + if [ "$ports" == "" ]; then + ports="OPEN" + else ports="CLOSED"; fi + + tee <<-EOF + -- GCE optimized surface -- + +[1] PTS-Traefik : Reverse Proxy +[2] Port Guard : [$ports] Protects the Server App Ports +[3] PTS-Shield : Enable Google's OAuthentication Protection +[4] PTS-Clone : Mount Transport +[5] PTS-Apps : Apps +[6] PTS-Vault : Backup & Restore +[7] Traktarr : Fill Sonarr/Radarr over Trakt lists. +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +[Z] Exit + +"$wisword" +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + # Standby + read -p '↘️ Type Number | Press [ENTER]: ' typed /dev/null 2>&1' + state: present + diff --git a/menu/traktarr/traktarr-list/prefillremove.yml b/menu/traktarr/traktarr-list/prefillremove.yml new file mode 100644 index 00000000..26409a63 --- /dev/null +++ b/menu/traktarr/traktarr-list/prefillremove.yml @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Title: Traktarr auto deploy +# Mod from MrDoobPG for PTS +# GNU: General Public License v3.0 +# Origin: https://github.com/l3uddz/plex_patrol +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + + - name: Remove Traktarr prefilling list @ daily + cron: + name: "Traktarr prefilling list @ daily" + special_time: 'daily' + job: 'bash /opt/plexguide/menu/traktarr/traktarr-list/traktarr.sh >/dev/null 2>&1' + state: absent diff --git a/menu/traktarr/traktarr-list/traktarr.sh b/menu/traktarr/traktarr-list/traktarr.sh new file mode 100644 index 00000000..616109b9 --- /dev/null +++ b/menu/traktarr/traktarr-list/traktarr.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +traktarr movies -t https://trakt.tv/users/porkie16/lists/docu-movies +sleep 30s +traktarr movies -t https://trakt.tv/users/porkie16/lists/thriller-movies-rating-65 +sleep 30s +traktarr movies -t https://trakt.tv/users/porkie16/lists/horror-movies-rating-65 +sleep 30s +traktarr movies -t https://trakt.tv/users/porkie16/lists/sci-fi-movies-65-rating +sleep 30s +traktarr movies -t https://trakt.tv/users/porkie16/lists/comedy-movies-65-rating +sleep 30s +traktarr movies -t https://trakt.tv/users/porkie16/lists/animation-movies-kids-only-rating-65 +sleep 30s +traktarr movies -t https://trakt.tv/users/porkie16/lists/action-movies-rating-65-rating +sleep 30s +traktarr shows -t https://trakt.tv/users/porkie16/lists/disney-tv-shows-65-rating +sleep 30s +traktarr movies -t https://trakt.tv/users/enormoz/lists/netflix-movies +sleep 30s +traktarr movies -t https://trakt.tv/users/theultimatec0der/lists/all-movies-2019 +sleep 30s +traktarr movies -t https://trakt.tv/users/theultimatec0der/lists/all-movies-2018 +sleep 30s +traktarr shows -t https://trakt.tv/users/theultimatec0der/lists/all-shows-2019 +sleep 30s +traktarr shows -t https://trakt.tv/users/theultimatec0der/lists/all-shows-2018 +sleep 30s +traktarr shows -t https://trakt.tv/users/theultimatec0der/lists/all-netflix-series +sleep 30s +traktarr shows -t https://trakt.tv/users/theultimatec0der/lists/all-hulu-series +sleep 30s +traktarr shows -t https://trakt.tv/users/theultimatec0der/lists/all-amazon-series +sleep 30s +traktarr movies -t https://trakt.tv/users/pntjr/lists/upcoming-movies +sleep 30s +traktarr shows -t https://trakt.tv/users/porkie16/lists/german-tv-shows +sleep 30s +traktarr movies -t https://trakt.tv/users/mrdoob/lists/mylist +sleep 30s + +exit 0 \ No newline at end of file diff --git a/menu/traktarr/traktarr.sh b/menu/traktarr/traktarr.sh new file mode 100644 index 00000000..6af5d23d --- /dev/null +++ b/menu/traktarr/traktarr.sh @@ -0,0 +1,660 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ + +# KEY VARIABLE RECALL & EXECUTION +mkdir -p /var/plexguide/traktarr/ + +# FUNCTIONS START ############################################################## + +# FIRST FUNCTION +variable() { + file="$1" + if [ ! -e "$file" ]; then echo "$2" >$1; fi +} + +deploycheck() { + dcheck=$(systemctl is-active traktarr.service) + if [ "$dcheck" == "active" ]; then + dstatus="✅ DEPLOYED" + else dstatus="⚠️ NOT DEPLOYED"; fi +} + +sonarrcheck() { + pcheck=$(docker ps --format '{{.Names}}' | grep "sonarr") + if [ "$pcheck" == "" ]; then + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ WARNING! - Sonarr is not Installed/Running! Cannot Proceed! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p 'Confirm Info | PRESS [ENTER] ' typed exit + +EOF + read -p '↘️ Type Sonarr Location | Press [ENTER]: ' typed /var/plexguide/traktarr/pgtrak.sprofile + read -p '🌎 Acknowledge Info | Press [ENTER] ' typed exit + +EOF + read -p '↘️ Type Radarr Location | Press [ENTER]: ' typed /var/plexguide/traktarr/pgtrak.rprofile + read -p '🌎 Acknowledge Info | Press [ENTER] ' typed exit + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + read -p '↘️ Type API Client | Press [ENTER]: ' typed /var/plexguide/traktarr/pgtrak.client + read -p '↘️ Type API Secret | Press [ENTER]: ' typed /var/plexguide/traktarr/pgtrak.secret + + if [[ "$typed" == "exit" || "$typed" == "Exit" || "$typed" == "EXIT" || "$typed" == "z" || "$typed" == "Z" ]]; then + question1 + else + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅ SYSTEM MESSAGE: Traktarr API Notice +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +NOTE: The API Client and Secret is set! Ensure to setup your and + prior to deploying Traktarr. + +INFO: Messed up? Rerun this API Interface to update the information! + +EOF + + read -p '🌎 Acknowledge Info | Press [ENTER] ' typed exit + +EOF + read -p '↘️ Type Sonarr Location | Press [ENTER]: ' typed /dev/null 2>&1 + + file="$typed/test" + if [ -e "$file" ]; then + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅ SYSTEM MESSAGE: Sonarr Path Completed! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + ### Removes /mnt if /mnt/unionfs exists + #check=$(echo $typed | head -c 12) + #if [ "$check" == "/mnt/unionfs" ]; then + #typed=${typed:4} + #fi + + echo "$typed" >/var/plexguide/traktarr/pgtrak.spath + read -p '🌎 Acknowledge Info | Press [ENTER] ' typed >> mkdir $typed/testfolder + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + read -p '🌎 Acknowledge Info | Press [ENTER] ' typed exit + +EOF + read -p '↘️ Type Radarr Location | Press [ENTER]: ' typed /dev/null 2>&1 + + file="$typed/test" + if [ -e "$file" ]; then + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅ SYSTEM MESSAGE: Radarr Path Completed! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + echo "$typed" >/var/plexguide/traktarr/pgtrak.rpath + read -p '🌎 Acknowledge Info | Press [ENTER] ' typed >> mkdir $typed/testfolder + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + read -p '🌎 Acknowledge Info | Press [ENTER] ' typed /var/plexguide/traktarr/pgtrakyear.max && question1 + else badinput; fi +} + +credits(){ +clear +chk=$(figlet traktarr | lolcat ) + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🚀 traktarr Credits +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +$chk + +######################################################################### +# Author: l3uddz # +# URL: https://github.com/l3uddz/traktarr # +# Coder of l3uddz/traktarr # +# -- # +# Author(s): l3uddz, desimaniac # +# URL: https://github.com/cloudbox/cloudbox # +# Coder of l3uddz/traktarr role # +# -- # +# Part of the Cloudbox project: https://cloudbox.works # +######################################################################### +# GNU General Public License v3.0 # +######################################################################### +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + + echo + read -p 'Confirm Info | PRESS [ENTER] ' typed } 1>/dev/null 2>&1 + info1=$(echo ${info:0:32}) 1>/dev/null 2>&1 + echo "$info1" >/var/plexguide/traktarr/pgtrak.rapi + fi + + file="/opt/appdata/sonarr/config.xml" + if [ -e "$file" ]; then + info=$(cat /opt/appdata/sonarr/config.xml) + info=${info#*} 1>/dev/null 2>&1 + info2=$(echo ${info:0:32}) 1>/dev/null 2>&1 + echo "$info2" >/var/plexguide/traktarr/pgtrak.sapi + fi + fi + ansible-playbook /opt/plexguide/menu/pg.yml --tags traktarr && question1 ;; + + 8) prefill && clear && question1 ;; + 9) endbanner && clear && question1 ;; + C) credits && clear && question1 ;; + c) credits && clear && question1 ;; + z) exit ;; + Z) exit ;; + *) question1 ;; + esac +} + +# FUNCTIONS END ############################################################## + +variable /var/plexguide/traktarr/pgtrak.client "NOT-SET" +variable /var/plexguide/traktarr/pgtrak.secret "NOT-SET" +variable /var/plexguide/traktarr/pgtrak.rpath "NOT-SET" +variable /var/plexguide/traktarr/pgtrak.spath "NOT-SET" +variable /var/plexguide/traktarr/pgtrak.sprofile "NOT-SET" +variable /var/plexguide/traktarr/pgtrak.rprofile "NOT-SET" +variable /var/plexguide/traktarr/pgtrak.rprofile "NOT-SET" +variable /var/plexguide/traktarr/pgtrakyear.max "NOT-SET" + +deploycheck +question1 diff --git a/menu/version/choice.yml b/menu/version/choice.yml new file mode 100644 index 00000000..4ce3dfbb --- /dev/null +++ b/menu/version/choice.yml @@ -0,0 +1,46 @@ +#!/bin/bash +# +# Title: PTS Updater +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: Register Project + shell: 'cat /var/plexguide/pg.number' + register: serverid + + - name: 'Setting ownership on PTS Folder' + shell: 'chown -cR 1000:1000 /opt/plexguide 1>/dev/null 2>&1' + + - name: 'Setting permissions on PTS Folder' + shell: 'chmod -cR 775 /opt/plexguide 1>/dev/null 2>&1' + + - name: 'Installing Version {{serverid.stdout}}' + git: + repo: 'https://github.com/PTS-Team/PTS-Team' + dest: '/opt/plexguide' + version: '{{serverid.stdout}}' + force: yes + when: not serverid.stdout == "edge" + ignore_errors: True + + - stat: + path: /opt/plexguide + register: p + - debug: + msg: "Path exists and PTS folder exists" + when: p.stat.isdir is defined and p.stat.isdir + + - name: 'Setting ownership on PTS Folder' + shell: 'chown -cR 1000:1000 /opt/plexguide 1>/dev/null 2>&1' + + - name: 'Setting permissions on PTS Folder' + shell: 'chmod -cR 775 /opt/plexguide 1>/dev/null 2>&1' + + - name: 'Stops First Time Run' + shell: 'touch /var/plexguide/ask.yes' + register: program \ No newline at end of file diff --git a/menu/version/file.sh b/menu/version/file.sh new file mode 100644 index 00000000..dcff8f46 --- /dev/null +++ b/menu/version/file.sh @@ -0,0 +1,87 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 - Deiteq +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +mainstart() { + echo "" + echo "💬 Pulling Update Files - Please Wait" + file="/opt/pgstage/place.holder" + waitvar=0 + while [ "$waitvar" == "0" ]; do + sleep .5 + if [ -e "$file" ]; then waitvar=1; fi + done + + pgnumber=$(cat /var/plexguide/pg.number) + # latest=$(cat /opt/pgstage/versions.sh | head -n1) + versions=$(cat /opt/pgstage/versions.sh) + # dev=$(cat /opt/pgstage/versions.sh | sed -n 2p) + release="$(curl -s https://api.github.com/repos/PTS-Team/PTS-Team/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')" + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +📂 Update Interface +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +$versions + +Installed : $pgnumber + +[Z] Exit + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +EOF + + break=no + read -p '🌍 TYPE master | dev or preview | PRESS ENTER: ' typed + storage=$(grep $typed /opt/pgstage/versions.sh) + + parttwo +} + +parttwo() { + if [[ "$typed" == "exit" || "$typed" == "Exit" || "$typed" == "EXIT" || "$typed" == "z" || "$typed" == "Z" ]]; then + echo "" + touch /var/plexguide/exited.upgrade + exit + fi + + if [ "$storage" != "" ]; then + break=yes + echo -e $storage >/var/plexguide/pg.number + ansible-playbook /opt/plexguide/menu/version/choice.yml + + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅️ SYSTEM MESSAGE: Installing Version - $typed - Standby! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 2 + touch /var/plexguide/new.install + + file="/var/plexguide/community.app" + if [ -e "$file" ]; then rm -rf /var/plexguide/community.app; fi + + exit + else + tee <<-EOF + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +⛔️ SYSTEM MESSAGE: Version $typed does not exist! - Standby! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +EOF + sleep 2 + mainstart + fi +} + +rm -rf /opt/pgstage +mkdir -p /opt/pgstage +ansible-playbook /opt/plexguide/menu/pgstage/pgstage.yml #&>/de v/null & +mainstart diff --git a/menu/version/missing_pull.yml b/menu/version/missing_pull.yml new file mode 100644 index 00000000..2965b313 --- /dev/null +++ b/menu/version/missing_pull.yml @@ -0,0 +1,49 @@ +#!/bin/bash +# +# Title: Missing Pull Checker +# Author(s): MrDoobPG +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: 'Register Path' + shell: 'cat /var/plexguide/pg.number' + register: serverid + + - name: 'Check folder exist' + stat: + path: /opt/plexguide/menu/pg.yml + register: stat_result + - debug: + msg: "PTS Check for missing pull" + + - name: 'Installing Version {{serverid.stdout}}' + git: + repo: 'https://github.com/PTS-Team/PTS-Team' + dest: '/opt/plexguide' + clone: yes + version: '{{serverid.stdout}}' + force: yes + update: yes + become: yes + when: stat_result.stat.exists == False + ignore_errors: yes + + - stat: + path: /opt/plexguide/menu + register: p + - debug: + msg: "Path exists and PTS folder are pulled" + when: p.stat.isdir is defined and p.stat.isdir + + - name: Remove .githube folder and .git files + file: 'path={{item}} state=absent mode=0775 owner=1000 group=1000' + with_items: + - '/opt/plexguide/LICENSE' + - '/opt/plexguide/README.md' + + - name: 'Stops First Time Run' + shell: 'touch /var/plexguide/ask.yes' + register: program diff --git a/place.holder b/place.holder new file mode 100644 index 00000000..06dac8ff --- /dev/null +++ b/place.holder @@ -0,0 +1 @@ +Fuuuuuu