From c192d97f9f29cbd54ba08021fabb4201a3f185b0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 28 Mar 2023 23:52:01 +0200 Subject: [PATCH 002/969] ignore /.idea --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a09c56d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea From 6a725b0628d05242e50a257c6c40c67383bd20bf Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 28 Mar 2023 23:52:27 +0200 Subject: [PATCH 003/969] init --- __init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 __init__.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 From fed076c305eabd6bf1f28881b7dfe0a3de4a1393 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 28 Mar 2023 23:54:38 +0200 Subject: [PATCH 004/969] main --- __main__.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 __main__.py diff --git a/__main__.py b/__main__.py new file mode 100755 index 0000000..6066054 --- /dev/null +++ b/__main__.py @@ -0,0 +1,5 @@ +#! /usr/bin/env python3 + + +if __name__ == '__main__': + pass From 8e4925ac64a182735da4f42620289ee859ac428e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 28 Mar 2023 23:57:10 +0200 Subject: [PATCH 005/969] license --- license.md | 660 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 660 insertions(+) create mode 100644 license.md diff --git a/license.md b/license.md new file mode 100644 index 0000000..cba6f6a --- /dev/null +++ b/license.md @@ -0,0 +1,660 @@ +### GNU AFFERO GENERAL PUBLIC LICENSE + +Version 3, 19 November 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 Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + +The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are 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. + +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. + +Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + +A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + +The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + +An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing +under this license. + +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 Affero 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. Remote Network Interaction; Use with the GNU General Public License. + +Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your +version supports such interaction) an opportunity to receive the +Corresponding Source of your version by providing access to the +Corresponding Source from a network server at no charge, through some +standard or customary means of facilitating copying of software. This +Corresponding Source shall include the Corresponding Source for any +work covered by version 3 of the GNU General Public License that is +incorporated pursuant to the following paragraph. + +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 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 work with which it is combined will remain governed by version +3 of the GNU General Public License. + +#### 14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions +of the GNU Affero 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 Affero 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 Affero 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 Affero 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 Affero 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper +mail. + +If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for +the specific requirements. + +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 AGPL, see . From a60c78462c74a587a2a5b51f9e38dcba4a536b48 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 30 Mar 2023 20:05:30 +0200 Subject: [PATCH 006/969] readme --- readme.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 readme.md diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..e69de29 From 8d7b4f3a9cc58c4ebbd9cab64c2b1fb4ffe17fbd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 9 May 2023 21:56:16 +0200 Subject: [PATCH 008/969] nbdcs --- nbdcs | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 nbdcs diff --git a/nbdcs b/nbdcs new file mode 100755 index 0000000..8e8d088 --- /dev/null +++ b/nbdcs @@ -0,0 +1,84 @@ +#! /usr/bin/env bash +FILE="$(realpath "${BASH_SOURCE[0]}")" +NAME="$(basename "${FILE}")" + +ACTION_OPEN='open' +ACTION_CLOSE='close' + +DATA_DIRECTORY='/data' +CONTAINERS_DIRECTORY="${DATA_DIRECTORY}/containers" + +CONTAINERS_MAP_DIRECTORY='/dev/mapper' +CONTAINERS_MOUNT_DIRECTORY='/media' + +function main { +local action="${1}" +local pass_phrase +local container +local container_name +local container_file +local container_map_file +local container_mount_directory + +case "${action}" in + "${ACTION_OPEN}"|"${ACTION_CLOSE}") + shift + if [ "${1}" ]; then + if [ "${action}" == "${ACTION_OPEN}" ]; then + echo -n 'PassPhrase: ' + read -s pass_phrase + echo + fi + for container in "${@}"; do + echo + case "${container}" in + 'p') container_name='private' ;; + 's') container_name='sensitive' ;; + 'w') container_name='work' ;; + *) container_name="${container}" ;; + esac + container_file="${CONTAINERS_DIRECTORY}/${container_name}" + if [ -f "${container_file}" ]; then + container_map_file="${CONTAINERS_MAP_DIRECTORY}/${container_name}" + container_mount_directory="${CONTAINERS_MOUNT_DIRECTORY}/${container_name}" + case "${action}" in + "${ACTION_OPEN}") + echo "${container_file} → ${container_map_file}" + echo "${pass_phrase}" \ + | cryptsetup luksOpen "${container_file}" "${container_name}" + if [ ${?} -eq 0 ]; then + mkdir --parents "${container_mount_directory}" + echo "${container_map_file} → ${container_mount_directory}" + mount "${container_map_file}" "${container_mount_directory}" + fi + ;; + "${ACTION_CLOSE}") + echo "${container_map_file} ← ${container_mount_directory}" + umount "${container_map_file}" + if [ ${?} -eq 0 ]; then + rmdir --ignore-fail-on-non-empty "${container_mount_directory}" + echo "${container_file} ← ${container_map_file}" + cryptsetup luksClose "${container_name}" + fi + ;; + esac + else + echo 'This path does not point to a file!' + fi + done + else + echo 'No container name provided!' + fi + ;; + *) + echo 'Usage:' + echo "${NAME} [${ACTION_OPEN}|${ACTION_CLOSE}] [p] [s] [w]" + echo + echo 'p = private' + echo 's = sensitive' + echo 'w = work' + ;; +esac +} + +main "${@}" From e221bf5dfddf03f37d38c7fbb9883e3e6cad7aea Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 9 May 2023 21:56:21 +0200 Subject: [PATCH 009/969] remount --- remount | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 remount diff --git a/remount b/remount new file mode 100755 index 0000000..182dc7b --- /dev/null +++ b/remount @@ -0,0 +1,2 @@ +#! /usr/bin/env bash +mount -o remount,rw /usr/lib/live/mount/medium From 3ed56f64536fc927764adbf9cea6bffc667630c1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 9 May 2023 22:01:32 +0200 Subject: [PATCH 010/969] bash.bashrc --- bash.bashrc | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 bash.bashrc diff --git a/bash.bashrc b/bash.bashrc new file mode 100644 index 0000000..e90030d --- /dev/null +++ b/bash.bashrc @@ -0,0 +1,3 @@ +for file in /etc/bash.d/*.sh ; do + source "${file}" +done From 596e9b86c255fbea1267dcf75ba38684f12c60f5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 9 May 2023 22:02:34 +0200 Subject: [PATCH 011/969] bash.d --- bash.d/apt.sh | 23 +++++ bash.d/bash-commands.sh | 5 + bash.d/bash-completion.sh | 5 + bash.d/bash-history.sh | 5 + bash.d/bash-prompt.sh | 15 +++ bash.d/batcat.sh | 1 + bash.d/byobu.sh | 1 + bash.d/chmod.sh | 5 + bash.d/chown.sh | 5 + bash.d/clear.sh | 2 + bash.d/git.sh | 190 ++++++++++++++++++++++++++++++++++++++ bash.d/gnupg.sh | 3 + bash.d/grep.sh | 2 + bash.d/kill.sh | 5 + bash.d/killall.sh | 5 + bash.d/ls.sh | 2 + bash.d/lsblk.sh | 1 + bash.d/micro.sh | 1 + bash.d/mkdir.sh | 5 + bash.d/mount-lxc.sh | 31 +++++++ bash.d/mount.sh | 76 +++++++++++++++ bash.d/newsboat.sh | 1 + bash.d/otpclient-cli.sh | 5 + bash.d/pass.sh | 5 + bash.d/proxy.sh | 8 ++ bash.d/ps.sh | 2 + bash.d/rsync.sh | 8 ++ bash.d/tar.sh | 3 + 28 files changed, 420 insertions(+) create mode 100644 bash.d/apt.sh create mode 100644 bash.d/bash-commands.sh create mode 100644 bash.d/bash-completion.sh create mode 100644 bash.d/bash-history.sh create mode 100644 bash.d/bash-prompt.sh create mode 100644 bash.d/batcat.sh create mode 100644 bash.d/byobu.sh create mode 100644 bash.d/chmod.sh create mode 100644 bash.d/chown.sh create mode 100644 bash.d/clear.sh create mode 100644 bash.d/git.sh create mode 100644 bash.d/gnupg.sh create mode 100644 bash.d/grep.sh create mode 100644 bash.d/kill.sh create mode 100644 bash.d/killall.sh create mode 100644 bash.d/ls.sh create mode 100644 bash.d/lsblk.sh create mode 100644 bash.d/micro.sh create mode 100644 bash.d/mkdir.sh create mode 100644 bash.d/mount-lxc.sh create mode 100644 bash.d/mount.sh create mode 100644 bash.d/newsboat.sh create mode 100644 bash.d/otpclient-cli.sh create mode 100644 bash.d/pass.sh create mode 100644 bash.d/proxy.sh create mode 100644 bash.d/ps.sh create mode 100644 bash.d/rsync.sh create mode 100644 bash.d/tar.sh diff --git a/bash.d/apt.sh b/bash.d/apt.sh new file mode 100644 index 0000000..5de980c --- /dev/null +++ b/bash.d/apt.sh @@ -0,0 +1,23 @@ +# show package information +alias ac='apt-cache show' + +# search package +alias acs='apt-cache search' + +# package versions policy +alias acp='apt-cache policy' + +# update packages catalog +alias agud='apt-get update' + +# upgrade forbidding package installation or removal +alias agug='apt-get upgrade' + +# upgrade allowing package installation or removal +alias agdu='apt-get dist-upgrade' + +# install packages +alias agi='apt-get install' + +# clean packages cache +alias agc='apt-get clean;apt-get autoremove' diff --git a/bash.d/bash-commands.sh b/bash.d/bash-commands.sh new file mode 100644 index 0000000..211a5cf --- /dev/null +++ b/bash.d/bash-commands.sh @@ -0,0 +1,5 @@ +# change current directory to its parent +alias ..='cd ..' + +# exit terminal +alias x='exit' diff --git a/bash.d/bash-completion.sh b/bash.d/bash-completion.sh new file mode 100644 index 0000000..748a2b9 --- /dev/null +++ b/bash.d/bash-completion.sh @@ -0,0 +1,5 @@ +file='/usr/share/bash-completion/bash_completion' + +if [ -f "${file}" ] ; then + source "${file}" +fi diff --git a/bash.d/bash-history.sh b/bash.d/bash-history.sh new file mode 100644 index 0000000..4a47ba3 --- /dev/null +++ b/bash.d/bash-history.sh @@ -0,0 +1,5 @@ +HISTCONTROL='ignorespace' + +HISTSIZE=-1 + +HISTTIMEFORMAT='%Y%m%d %H%M%S ' diff --git a/bash.d/bash-prompt.sh b/bash.d/bash-prompt.sh new file mode 100644 index 0000000..51b193c --- /dev/null +++ b/bash.d/bash-prompt.sh @@ -0,0 +1,15 @@ +PS1="\ +┌ \t\ + – \e[0;31m\${?}\e[0m\ + – \e[0;32m\u\e[0m\ + @ \e[0;33m\h\e[0m\ +" +if [ "$(type -t __git_ps1)" == 'function' ] ; then + PS1="${PS1} –\e[0;35m\$(__git_ps1)\e[0m" +fi +PS1="${PS1} +│\e[0;36m\${PWD}\e[0m +└ " + +PS2="\ +└ " diff --git a/bash.d/batcat.sh b/bash.d/batcat.sh new file mode 100644 index 0000000..abe0b64 --- /dev/null +++ b/bash.d/batcat.sh @@ -0,0 +1 @@ +alias bat='batcat' diff --git a/bash.d/byobu.sh b/bash.d/byobu.sh new file mode 100644 index 0000000..1eb6d63 --- /dev/null +++ b/bash.d/byobu.sh @@ -0,0 +1 @@ +alias bb='byobu' diff --git a/bash.d/chmod.sh b/bash.d/chmod.sh new file mode 100644 index 0000000..357d4dc --- /dev/null +++ b/bash.d/chmod.sh @@ -0,0 +1,5 @@ +# change mode as directory +alias cmd='chmod 755' + +# change mode as file +alias cmf='chmod 644' diff --git a/bash.d/chown.sh b/bash.d/chown.sh new file mode 100644 index 0000000..4beb36d --- /dev/null +++ b/bash.d/chown.sh @@ -0,0 +1,5 @@ +# change owner as root +alias cor='chown 0:0' + +# change owner as user +alias cou='chown 1000:1000' diff --git a/bash.d/clear.sh b/bash.d/clear.sh new file mode 100644 index 0000000..350a925 --- /dev/null +++ b/bash.d/clear.sh @@ -0,0 +1,2 @@ +# clear terminal +alias c='clear' diff --git a/bash.d/git.sh b/bash.d/git.sh new file mode 100644 index 0000000..7417e4c --- /dev/null +++ b/bash.d/git.sh @@ -0,0 +1,190 @@ +# add to index +alias ga='git add' + +# add all to index +alias gaa='git add --all' + +# create a branch +alias gb='git branch' + +# delete a branch +alias gbd='git branch --delete' + +# force a branch deletion +alias gbdf='git branch --delete --force' + +# list branches +alias gbl='git branch --all --list --verbose --verbose' + +# set the link to a remote branch from a local branch +alias gbu='git branch -u' + +# clone a remote repository +alias gc='git clone' + +# clean untracked files +alias gcf='git clean -d --force' + +# index all and commit +alias gacm='git add --all;git commit -m' + +# commit the index +alias gcm='git commit -m' + +# redo the last commit with a different message +alias gcma='git commit --amend -m' + +# make a root commit +alias gcmr='git commit --allow-empty --allow-empty-message -m ""' + +# commit the index and sign +alias gcms='git commit --gpg-sign -m' + +# switch to a branch or checkout file(s) from a commit +alias gco='git checkout' + +# checkout an orphan branch +alias gcoo='git checkout --orphan' + +# checkout development branch +alias gcod='git checkout dev' + +# checkout feature branch +alias gcof='git checkout f' + +# pick a commit +alias gcp='git cherry-pick' + +# abort the commit pick +alias gcpa='git cherry-pick --abort' + +# continue the commit pick +alias gcpc='git cherry-pick --continue' + +# configure the user name +alias gcun='git config user.name' + +# configure the user email +alias gcue='git config user.email' + +# differences from last or between commits +alias gd='git diff' + +# display what is indexed in cache +alias gdc='git diff --cached' + +# indexed character-level differences +alias gdcw='git diff --cached --word-diff-regex=.' + +# differences via external tool +alias gdt='git difftool --dir-diff' + +# character-level differences +alias gdw='git diff --word-diff-regex=.' + +# fetch from the remote repository +alias gf='git fetch --tags --verbose' + +# fetch from remote repository and prune local orphan branches +alias gfp='git fetch --prune --tags --verbose' + +# garbage collect all orphan commits +alias ggc='git reflog expire --expire=now --all;git gc --prune=now' + +# initialize a new repository +alias gi='git init' + +# initialize a new bare repository +alias gib='git init --bare' + +# log commits history +alias gl='git log --all --graph \ +--format="%C(auto)%h%d %C(red)%ai%C(auto) %an%n%B"' + +# log commits history with patches +alias glp='git log --all --graph \ +--format="%C(auto)%h%d %C(red)%ai%C(auto) %an%n%B" --patch' + +# log medium information +alias glm='git log --all --decorate --graph --pretty=medium' + +# fast-forward to remote branch +alias gmf='git merge --ff-only' + +# do a merge commit +alias gmc='git merge --no-ff -m' + +# abort the current merge commit +alias gma='git merge --abort' + +# squash a branch and index its modifications +alias gms='git merge --squash' + +# merge via external tool +alias gmt='git mergetool' + +# push to the remote repository +alias gp='git push --tags --verbose' + +# delete from the remote repository +alias gpd='git push --delete --verbose' + +# force the push to the remote repository +alias gpf='git push --tags --verbose --force' + +# rebase current branch onto another +alias grb='git rebase' + +# abort current rebase +alias grba='git rebase --abort' + +# continue current rebase +alias grbc='git rebase --continue' + +# force rebase without fast-forward +alias grbf='git rebase --no-ff' + +# rebase interactively +alias grbi='git rebase --interactive' + +# list all remote repositories +alias grm='git remote' + +# add a new remote repository +alias grma='git remote add' + +# list remote repositories +alias grml='git remote --verbose' + +# show a connection to a repository +alias grms='git remote show' + +# set the location of the remote repository +alias grmu='git remote set-url' + +# remove file(s) from index or move current branch pointer +alias grs='git reset' + +# move current branch pointer to the development branch +alias grsd='git reset dev' + +# wipe modifications or reset current branch to another commit +alias grsh='git reset --hard' + +# reset current branch to the development branch +alias grshd='git reset --hard dev' + +# current state of repository +alias gs='git status --untracked-files=all' + +# show a commit +alias gsh='git show' + +# tag a commit +alias gt='git tag' + +# delete a tag +alias gtd='git tag --delete' + +# tag a commit and sign +alias gts='git tag --sign' diff --git a/bash.d/gnupg.sh b/bash.d/gnupg.sh new file mode 100644 index 0000000..715e3ab --- /dev/null +++ b/bash.d/gnupg.sh @@ -0,0 +1,3 @@ +alias gpgoff='gpgconf --kill gpg-agent' + +alias gpgtty='gpg-connect-agent updatestartuptty /bye' diff --git a/bash.d/grep.sh b/bash.d/grep.sh new file mode 100644 index 0000000..6a9c514 --- /dev/null +++ b/bash.d/grep.sh @@ -0,0 +1,2 @@ +# grep from current directory with regex +alias g='grep --directories recurse --line-number --regexp' diff --git a/bash.d/kill.sh b/bash.d/kill.sh new file mode 100644 index 0000000..dbe03d1 --- /dev/null +++ b/bash.d/kill.sh @@ -0,0 +1,5 @@ +# kill a process by id +alias k='kill' + +# force kill a process by id +alias kf='kill -9' diff --git a/bash.d/killall.sh b/bash.d/killall.sh new file mode 100644 index 0000000..76c30a7 --- /dev/null +++ b/bash.d/killall.sh @@ -0,0 +1,5 @@ +# kill all instances of a process by name +alias ka='killall' + +# force kill all instances of a process by name +alias kaf='killall -9' diff --git a/bash.d/ls.sh b/bash.d/ls.sh new file mode 100644 index 0000000..c820fb5 --- /dev/null +++ b/bash.d/ls.sh @@ -0,0 +1,2 @@ +# list current directory entries +alias l='ls --all --color -l -p --time-style="+%Y%m%d-%H%M%S%-:::z"' diff --git a/bash.d/lsblk.sh b/bash.d/lsblk.sh new file mode 100644 index 0000000..fca212a --- /dev/null +++ b/bash.d/lsblk.sh @@ -0,0 +1 @@ +alias lb='lsblk --noempty --output NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS' diff --git a/bash.d/micro.sh b/bash.d/micro.sh new file mode 100644 index 0000000..de78a1d --- /dev/null +++ b/bash.d/micro.sh @@ -0,0 +1 @@ +alias e='micro' diff --git a/bash.d/mkdir.sh b/bash.d/mkdir.sh new file mode 100644 index 0000000..ba8d113 --- /dev/null +++ b/bash.d/mkdir.sh @@ -0,0 +1,5 @@ +# make a directory +alias md='mkdir' + +# make a directory after making its parents +alias mdp='mkdir --parents' diff --git a/bash.d/mount-lxc.sh b/bash.d/mount-lxc.sh new file mode 100644 index 0000000..a0b3ace --- /dev/null +++ b/bash.d/mount-lxc.sh @@ -0,0 +1,31 @@ +function mrc { +local container="${1}" +local f + for f in 'dev' 'dev/pts' 'proc' 'sys' ; do + mount --bind "/${f}" "overlay/mount/var/lib/lxc/${container}/squashfs-root/${f}" + done +} + +function crc { +local container="${1}" + shift + chroot "overlay/mount/var/lib/lxc/${container}/squashfs-root" "${@}" +} + +function urc { +local container="${1}" + for f in 'sys' 'proc' 'dev/pts' 'dev' ; do + umount --lazy "overlay/mount/var/lib/lxc/${container}/squashfs-root/${f}" + done +} + + +function mmc { +local container="${1}" + mount --bind '/deb' "overlay/mount/var/lib/lxc/${container}/squashfs-root/deb" +} + +function umc { +local container="${1}" + umount "overlay/mount/var/lib/lxc/${container}/squashfs-root/deb" +} diff --git a/bash.d/mount.sh b/bash.d/mount.sh new file mode 100644 index 0000000..4e91b62 --- /dev/null +++ b/bash.d/mount.sh @@ -0,0 +1,76 @@ +alias m='mount' + + +function mo { +local directory="${1}" +local file +if [ "${directory}" ] ; then + directory="$(realpath "${directory}")" + file="${directory}/filesystem.squashfs" + if mkdir 'overlay' ; then + cd 'overlay' + mkdir {lower,upper,work,mount} + if mount "${file}" 'lower' ; then + mount -t 'overlay' 'overlay' 'mount' \ +-o lowerdir='lower',upperdir='upper',workdir='work' + fi + cd .. + fi +else + echo 'KO: directory?' +fi +} + +function uo { +cd 'overlay' +if umount 'mount' ; then + rmdir 'mount' + rm --recursive 'upper' 'work' + if umount 'lower' ; then + rmdir 'lower' + fi +fi +cd .. +rmdir 'overlay' +} + + +function mr { +for f in 'dev' 'dev/pts' 'proc' 'sys' ; do + mount --bind "/${f}" "overlay/mount/${f}" +done +} + +alias cr='chroot overlay/mount' + +function ur { +for f in 'dev/pts' 'dev' 'proc' 'sys' ; do + umount --lazy "overlay/mount/${f}" +done +} + + +function mm { +mount --bind '/deb' 'overlay/mount/deb' +} + +function um { +umount 'overlay/mount/deb' +} + + +function ms { +local directory="${1}" +local level="${2}" +if [ "${directory}" ] ; then + if mkdir "${directory}" ; then + [ "${level}" ] || level='18' + cp overlay/mount/{vmlinuz,initrd.img} "${directory}" + mksquashfs \ +'overlay/mount' "${directory}/filesystem.squashfs" \ +-b '1M' \ +-comp 'zstd' -Xcompression-level "${level}" + chown --recursive 1000:1000 "${directory}" + fi +fi +} diff --git a/bash.d/newsboat.sh b/bash.d/newsboat.sh new file mode 100644 index 0000000..b90f01b --- /dev/null +++ b/bash.d/newsboat.sh @@ -0,0 +1 @@ +alias nb='newsboat' diff --git a/bash.d/otpclient-cli.sh b/bash.d/otpclient-cli.sh new file mode 100644 index 0000000..f2fa2ba --- /dev/null +++ b/bash.d/otpclient-cli.sh @@ -0,0 +1,5 @@ +# display otp code +alias pd='otpclient-cli show -a' + +# list otp accounts +alias pl='otpclient-cli list' diff --git a/bash.d/pass.sh b/bash.d/pass.sh new file mode 100644 index 0000000..f90153e --- /dev/null +++ b/bash.d/pass.sh @@ -0,0 +1,5 @@ +# display pass entry's content +alias p='pass' + +# copy passphrase into clipboard +alias pc='pass --clip' diff --git a/bash.d/proxy.sh b/bash.d/proxy.sh new file mode 100644 index 0000000..a5713ad --- /dev/null +++ b/bash.d/proxy.sh @@ -0,0 +1,8 @@ +function socks { +local value + case "${1}" in + 'on') value='manual' ;; + *) value='none' ;; + esac + gsettings set 'org.gnome.system.proxy' 'mode' "${value}" +} diff --git a/bash.d/ps.sh b/bash.d/ps.sh new file mode 100644 index 0000000..791a664 --- /dev/null +++ b/bash.d/ps.sh @@ -0,0 +1,2 @@ +# look for a string in processes names +alias pg='ps -A | grep' diff --git a/bash.d/rsync.sh b/bash.d/rsync.sh new file mode 100644 index 0000000..ddd35b2 --- /dev/null +++ b/bash.d/rsync.sh @@ -0,0 +1,8 @@ +# synchronize +alias rs='rsync --archive --partial --progress --verbose --no-inc-recursive' + +# synchronize and delete after +alias rsda='rsync --archive --partial --progress --verbose --delete-after' + +# synchronize and delete before +alias rsdb='rsync --archive --partial --progress --verbose --delete-before' diff --git a/bash.d/tar.sh b/bash.d/tar.sh new file mode 100644 index 0000000..2c1f18c --- /dev/null +++ b/bash.d/tar.sh @@ -0,0 +1,3 @@ +alias tc='tar --verbose --create --auto-compress --file' + +alias tx='tar --verbose --extract --file' From a4697a41fa6fc644405395a113b4bbf5d7cfef6f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 9 May 2023 22:09:01 +0200 Subject: [PATCH 012/969] source bash relatively --- bash.bashrc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bash.bashrc b/bash.bashrc index e90030d..8fa3fe2 100644 --- a/bash.bashrc +++ b/bash.bashrc @@ -1,3 +1,9 @@ -for file in /etc/bash.d/*.sh ; do +#! /usr/bin/env bash +PATH="$(realpath "${BASH_SOURCE[0]}")" +ROOT="$(dirname "${PATH}")" + +DIRECTORY="${ROOT}/bash.d" + +for file in "${DIRECTORY}"/*.sh ; do source "${file}" done From 247b6a7fed0054f47b1bb7c6afcd788368b99cc7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 9 May 2023 22:10:18 +0200 Subject: [PATCH 013/969] main --- bash.bashrc => bash.d/main.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bash.bashrc => bash.d/main.sh (100%) diff --git a/bash.bashrc b/bash.d/main.sh similarity index 100% rename from bash.bashrc rename to bash.d/main.sh From 98056f2fb62aa0504b540348214ee81220feb15d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 9 May 2023 22:15:40 +0200 Subject: [PATCH 014/969] source directly --- bash.d/main.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bash.d/main.sh b/bash.d/main.sh index 8fa3fe2..732bad3 100644 --- a/bash.d/main.sh +++ b/bash.d/main.sh @@ -2,8 +2,13 @@ PATH="$(realpath "${BASH_SOURCE[0]}")" ROOT="$(dirname "${PATH}")" -DIRECTORY="${ROOT}/bash.d" +function main { +local module + for module in "${ROOT}"/*.sh ; do + if [ "${module}" != "${PATH}" ] ; then + source "${module}" + fi + done +} -for file in "${DIRECTORY}"/*.sh ; do - source "${file}" -done +main From 7bb0eeecf1ad4fff330cbde4c67281f10e92c0db Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 9 May 2023 22:20:42 +0200 Subject: [PATCH 015/969] remount --- bash.d/mount.sh | 3 +++ remount | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) delete mode 100755 remount diff --git a/bash.d/mount.sh b/bash.d/mount.sh index 4e91b62..b33b12c 100644 --- a/bash.d/mount.sh +++ b/bash.d/mount.sh @@ -1,5 +1,8 @@ alias m='mount' +# remount read-only medium in read-write +alias remount='mount -o remount,rw /usr/lib/live/mount/medium' + function mo { local directory="${1}" diff --git a/remount b/remount deleted file mode 100755 index 182dc7b..0000000 --- a/remount +++ /dev/null @@ -1,2 +0,0 @@ -#! /usr/bin/env bash -mount -o remount,rw /usr/lib/live/mount/medium From 3343762acc890e76ec466d27cd8e68b7cc877c10 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 9 May 2023 22:58:36 +0200 Subject: [PATCH 016/969] FILE --- bash.d/main.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bash.d/main.sh b/bash.d/main.sh index 732bad3..71452c3 100644 --- a/bash.d/main.sh +++ b/bash.d/main.sh @@ -1,11 +1,11 @@ #! /usr/bin/env bash -PATH="$(realpath "${BASH_SOURCE[0]}")" -ROOT="$(dirname "${PATH}")" +FILE="$(realpath "${BASH_SOURCE[0]}")" +ROOT="$(dirname "${FILE}")" function main { local module for module in "${ROOT}"/*.sh ; do - if [ "${module}" != "${PATH}" ] ; then + if [ "${module}" != "${FILE}" ] ; then source "${module}" fi done From 06f5191c7c6dd486744103c630294adf457a9459 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 9 May 2023 23:25:21 +0200 Subject: [PATCH 017/969] bash --- {bash.d => bash}/apt.sh | 0 {bash.d => bash}/bash-commands.sh | 0 {bash.d => bash}/bash-completion.sh | 0 {bash.d => bash}/bash-history.sh | 0 {bash.d => bash}/bash-prompt.sh | 0 {bash.d => bash}/batcat.sh | 0 {bash.d => bash}/byobu.sh | 0 {bash.d => bash}/chmod.sh | 0 {bash.d => bash}/chown.sh | 0 {bash.d => bash}/clear.sh | 0 {bash.d => bash}/git.sh | 0 {bash.d => bash}/gnupg.sh | 0 {bash.d => bash}/grep.sh | 0 {bash.d => bash}/kill.sh | 0 {bash.d => bash}/killall.sh | 0 {bash.d => bash}/ls.sh | 0 {bash.d => bash}/lsblk.sh | 0 {bash.d => bash}/main.sh | 0 {bash.d => bash}/micro.sh | 0 {bash.d => bash}/mkdir.sh | 0 {bash.d => bash}/mount-lxc.sh | 0 {bash.d => bash}/mount.sh | 0 {bash.d => bash}/newsboat.sh | 0 {bash.d => bash}/otpclient-cli.sh | 0 {bash.d => bash}/pass.sh | 0 {bash.d => bash}/proxy.sh | 0 {bash.d => bash}/ps.sh | 0 {bash.d => bash}/rsync.sh | 0 {bash.d => bash}/tar.sh | 0 29 files changed, 0 insertions(+), 0 deletions(-) rename {bash.d => bash}/apt.sh (100%) rename {bash.d => bash}/bash-commands.sh (100%) rename {bash.d => bash}/bash-completion.sh (100%) rename {bash.d => bash}/bash-history.sh (100%) rename {bash.d => bash}/bash-prompt.sh (100%) rename {bash.d => bash}/batcat.sh (100%) rename {bash.d => bash}/byobu.sh (100%) rename {bash.d => bash}/chmod.sh (100%) rename {bash.d => bash}/chown.sh (100%) rename {bash.d => bash}/clear.sh (100%) rename {bash.d => bash}/git.sh (100%) rename {bash.d => bash}/gnupg.sh (100%) rename {bash.d => bash}/grep.sh (100%) rename {bash.d => bash}/kill.sh (100%) rename {bash.d => bash}/killall.sh (100%) rename {bash.d => bash}/ls.sh (100%) rename {bash.d => bash}/lsblk.sh (100%) rename {bash.d => bash}/main.sh (100%) rename {bash.d => bash}/micro.sh (100%) rename {bash.d => bash}/mkdir.sh (100%) rename {bash.d => bash}/mount-lxc.sh (100%) rename {bash.d => bash}/mount.sh (100%) rename {bash.d => bash}/newsboat.sh (100%) rename {bash.d => bash}/otpclient-cli.sh (100%) rename {bash.d => bash}/pass.sh (100%) rename {bash.d => bash}/proxy.sh (100%) rename {bash.d => bash}/ps.sh (100%) rename {bash.d => bash}/rsync.sh (100%) rename {bash.d => bash}/tar.sh (100%) diff --git a/bash.d/apt.sh b/bash/apt.sh similarity index 100% rename from bash.d/apt.sh rename to bash/apt.sh diff --git a/bash.d/bash-commands.sh b/bash/bash-commands.sh similarity index 100% rename from bash.d/bash-commands.sh rename to bash/bash-commands.sh diff --git a/bash.d/bash-completion.sh b/bash/bash-completion.sh similarity index 100% rename from bash.d/bash-completion.sh rename to bash/bash-completion.sh diff --git a/bash.d/bash-history.sh b/bash/bash-history.sh similarity index 100% rename from bash.d/bash-history.sh rename to bash/bash-history.sh diff --git a/bash.d/bash-prompt.sh b/bash/bash-prompt.sh similarity index 100% rename from bash.d/bash-prompt.sh rename to bash/bash-prompt.sh diff --git a/bash.d/batcat.sh b/bash/batcat.sh similarity index 100% rename from bash.d/batcat.sh rename to bash/batcat.sh diff --git a/bash.d/byobu.sh b/bash/byobu.sh similarity index 100% rename from bash.d/byobu.sh rename to bash/byobu.sh diff --git a/bash.d/chmod.sh b/bash/chmod.sh similarity index 100% rename from bash.d/chmod.sh rename to bash/chmod.sh diff --git a/bash.d/chown.sh b/bash/chown.sh similarity index 100% rename from bash.d/chown.sh rename to bash/chown.sh diff --git a/bash.d/clear.sh b/bash/clear.sh similarity index 100% rename from bash.d/clear.sh rename to bash/clear.sh diff --git a/bash.d/git.sh b/bash/git.sh similarity index 100% rename from bash.d/git.sh rename to bash/git.sh diff --git a/bash.d/gnupg.sh b/bash/gnupg.sh similarity index 100% rename from bash.d/gnupg.sh rename to bash/gnupg.sh diff --git a/bash.d/grep.sh b/bash/grep.sh similarity index 100% rename from bash.d/grep.sh rename to bash/grep.sh diff --git a/bash.d/kill.sh b/bash/kill.sh similarity index 100% rename from bash.d/kill.sh rename to bash/kill.sh diff --git a/bash.d/killall.sh b/bash/killall.sh similarity index 100% rename from bash.d/killall.sh rename to bash/killall.sh diff --git a/bash.d/ls.sh b/bash/ls.sh similarity index 100% rename from bash.d/ls.sh rename to bash/ls.sh diff --git a/bash.d/lsblk.sh b/bash/lsblk.sh similarity index 100% rename from bash.d/lsblk.sh rename to bash/lsblk.sh diff --git a/bash.d/main.sh b/bash/main.sh similarity index 100% rename from bash.d/main.sh rename to bash/main.sh diff --git a/bash.d/micro.sh b/bash/micro.sh similarity index 100% rename from bash.d/micro.sh rename to bash/micro.sh diff --git a/bash.d/mkdir.sh b/bash/mkdir.sh similarity index 100% rename from bash.d/mkdir.sh rename to bash/mkdir.sh diff --git a/bash.d/mount-lxc.sh b/bash/mount-lxc.sh similarity index 100% rename from bash.d/mount-lxc.sh rename to bash/mount-lxc.sh diff --git a/bash.d/mount.sh b/bash/mount.sh similarity index 100% rename from bash.d/mount.sh rename to bash/mount.sh diff --git a/bash.d/newsboat.sh b/bash/newsboat.sh similarity index 100% rename from bash.d/newsboat.sh rename to bash/newsboat.sh diff --git a/bash.d/otpclient-cli.sh b/bash/otpclient-cli.sh similarity index 100% rename from bash.d/otpclient-cli.sh rename to bash/otpclient-cli.sh diff --git a/bash.d/pass.sh b/bash/pass.sh similarity index 100% rename from bash.d/pass.sh rename to bash/pass.sh diff --git a/bash.d/proxy.sh b/bash/proxy.sh similarity index 100% rename from bash.d/proxy.sh rename to bash/proxy.sh diff --git a/bash.d/ps.sh b/bash/ps.sh similarity index 100% rename from bash.d/ps.sh rename to bash/ps.sh diff --git a/bash.d/rsync.sh b/bash/rsync.sh similarity index 100% rename from bash.d/rsync.sh rename to bash/rsync.sh diff --git a/bash.d/tar.sh b/bash/tar.sh similarity index 100% rename from bash.d/tar.sh rename to bash/tar.sh From b52612afeddcc663d09689a91a9daf6be7206ed9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 9 May 2023 23:32:24 +0200 Subject: [PATCH 018/969] gpg/ssh,tty --- bash/gnupg.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bash/gnupg.sh b/bash/gnupg.sh index 715e3ab..3d259ef 100644 --- a/bash/gnupg.sh +++ b/bash/gnupg.sh @@ -1,3 +1,6 @@ +export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" +gpg-connect-agent updatestartuptty /bye > /dev/null + alias gpgoff='gpgconf --kill gpg-agent' alias gpgtty='gpg-connect-agent updatestartuptty /bye' From 74c01068b4f69149b6a18104e6662cf5f1b8a4e6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 10 May 2023 00:27:50 +0200 Subject: [PATCH 019/969] gnupg/root --- bash/gnupg.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bash/gnupg.sh b/bash/gnupg.sh index 3d259ef..ab29be1 100644 --- a/bash/gnupg.sh +++ b/bash/gnupg.sh @@ -1,5 +1,7 @@ -export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" -gpg-connect-agent updatestartuptty /bye > /dev/null +if [ ${EUID} -ne 0 ] ; then + export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" + gpg-connect-agent updatestartuptty /bye > /dev/null +fi alias gpgoff='gpgconf --kill gpg-agent' From 7f1ade34d09f544af82c2ff669365ad9a34a9f58 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 10 May 2023 09:45:19 +0200 Subject: [PATCH 020/969] bash/tl --- bash/tar.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bash/tar.sh b/bash/tar.sh index 2c1f18c..bd36382 100644 --- a/bash/tar.sh +++ b/bash/tar.sh @@ -1,3 +1,5 @@ alias tc='tar --verbose --create --auto-compress --file' +alias tl='tar --verbose --list --file' + alias tx='tar --verbose --extract --file' From dd1ee57228b1bfa5d01982bc2d8149eccd7a5a44 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 12 May 2023 23:38:42 +0200 Subject: [PATCH 021/969] link bashrc --- bash/main.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index 71452c3..8996b7e 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -1,11 +1,17 @@ #! /usr/bin/env bash -FILE="$(realpath "${BASH_SOURCE[0]}")" -ROOT="$(dirname "${FILE}")" +MAIN_FILE="$(realpath "${BASH_SOURCE[0]}")" +MAIN_ROOT="$(dirname "${MAIN_FILE}")" + +function link_bashrc { + local file='/etc/bash.bashrc' + rm --force "${file}" + ln --symbolic "${MAIN_FILE}" "${file}" +} function main { local module - for module in "${ROOT}"/*.sh ; do - if [ "${module}" != "${FILE}" ] ; then + for module in "${MAIN_ROOT}"/*.sh ; do + if [ "${module}" != "${MAIN_FILE}" ] ; then source "${module}" fi done From a4e9584ae193cfdd45ca4e68b8f19a4577fbb78f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 00:49:39 +0200 Subject: [PATCH 022/969] ovh-rescue --- bash/ovh-rescue.sh | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 bash/ovh-rescue.sh diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh new file mode 100644 index 0000000..6f230ca --- /dev/null +++ b/bash/ovh-rescue.sh @@ -0,0 +1,84 @@ +function ovh-rescue-setup { + local release='buster' + local packages=( + 'byobu' 'mosh' + 'file' + 'grub-efi-amd64-bin' 'grub-pc-bin' + 'htop' 'iotop' + 'exa' 'ncdu' 'nnn' 'ranger' 'tree' + 'squashfs-tools' + 'uuid-runtime' + ) + local backports=( + 'cryptsetup-bin' + 'git' + 'rsync' + ) + # + echo -n "\ +en_US.UTF-8 UTF-8 +fr_FR.UTF-8 UTF-8 +" > '/etc/locale.gen' + rm --force '/usr/share/locale/locale.alias' + ln --symbolic '/etc/locale.alias' '/usr/share/locale/locale.alias' + locale-gen + # + echo -n "\ +Acquire::AllowInsecureRepositories False; +Acquire::AllowWeakRepositories False; +Acquire::AllowDowngradeToInsecureRepositories False; +Acquire::Check-Valid-Until True; +APT::Install-Recommends False; +APT::Install-Suggests False; +APT::Get::Show-Versions True; +Dir::Etc::SourceParts ''; +Dpkg::Progress True; +" > '/etc/apt/apt.conf' + echo -n "\ +deb https://deb.debian.org/debian buster main contrib non-free +deb https://deb.debian.org/debian buster-backports main contrib non-free +deb https://deb.debian.org/debian buster-updates main contrib non-free +deb https://deb.debian.org/debian-security buster/updates main contrib non-free +" > '/etc/apt/sources.list' + # + apt-get update + apt-get update + # + export DEBIAN_FRONTEND='noninteractive' + # + apt-get upgrade --assume-yes + # + apt-get install --assume-yes "${packages[@]}" + apt-get install --assume-yes \ + --target-release "${release}-backports" "${backports[@]}" + # + apt-get clean + # + link_bashrc +} + +function ovh-rescue-upload { +local host="${1}" +if [ "${host}" ] ; then + local user='root' + # + local user_host="${user}@${host}" + # + ssh-keygen -R "${host}" + # + ssh-copy-id \ + -o 'StrictHostKeyChecking=accept-new' \ + "${user_host}" + # upload root + rsync --delete --recursive "${MAIN_ROOT}/" "${user_host}:/etc/bash/" + # call setup + ssh "${user_host}" -- "source '/etc/bash/main.sh' ; ovh-rescue-setup" + # create session + ssh "${user_host}" -- byobu new-session -d + # attach session + mosh "${user_host}" -- byobu attach-session +else + echo 'Host?' + return 1 +fi +} From 1c05cd488e1e2d657ec1420018cd82ffc31b7aad Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 01:59:08 +0200 Subject: [PATCH 023/969] lbo --- bash/lsblk.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bash/lsblk.sh b/bash/lsblk.sh index fca212a..42b6442 100644 --- a/bash/lsblk.sh +++ b/bash/lsblk.sh @@ -1 +1,3 @@ alias lb='lsblk --noempty --output NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS' + +alias lbo='lsblk --output NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT' From 7fc49d3dd0a7b0c8cf10c1d88d3c28c7bf1ace5c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 02:26:42 +0200 Subject: [PATCH 024/969] ovh-rescue-wipe --- bash/ovh-rescue.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 6f230ca..5e943f5 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -82,3 +82,59 @@ else return 1 fi } + +function ovh-rescue-wipe-1-2TB { + local device='/dev/sda' + local unit='mib' + # + echo -n 'WIPE' "${device}" '/?\\ OR CANCEL /!\\' + read + # + parted "${device}" --script mktable gpt + # + parted "${device}" unit "${unit}" mkpart 'crypt' 65795 1907729 + # + parted "${device}" unit "${unit}" mkpart 'boot' 259 65795 + # + parted "${device}" unit "${unit}" mkpart 'esp' 2 259 + parted "${device}" set 3 esp on + # + parted "${device}" unit "${unit}" mkpart bios 1 2 + parted "${device}" set 4 bios_grub on + # wipe bios + dd if='/dev/zero' of='/dev/sda4' + # format esp + mkfs.vfat -F 32 -n 'esp' '/dev/sda3' + # format boot + mkfs.ext4 -L 'boot' '/dev/sda2' + # encrypt + cryptsetup \ + --verbose \ + --type luks2 \ + --pbkdf argon2id \ + --cipher aes-xts-plain64 \ + --iter-time 8192 \ + --key-size 512 \ + --hash sha512 \ + --use-random \ + luksFormat \ + '/dev/sda1' + # open + cryptsetup luksOpen '/dev/sda1' 'crypt' + # pv + pvcreate '/dev/mapper/crypt' + # vg + vgcreate 'crypt' '/dev/mapper/crypt' + # lv swap + lvcreate --name 'swap' --size '68719476736b' 'crypt' + # lv data + lvcreate --name 'data' --extents '100%FREE' 'crypt' + # format swap + mkswap --label 'swap' '/dev/mapper/crypt-swap' + # format data + mkfs.ext4 -L 'data' '/dev/mapper/crypt-data' + # vg off + vgchange --activate n 'crypt' + # close + cryptsetup luksClose 'crypt' +} From df61ae9d8076786c2085f6c88d3e7bd708fc549f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 02:27:29 +0200 Subject: [PATCH 025/969] lshw --- bash/ovh-rescue.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 5e943f5..6cb8608 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -2,6 +2,7 @@ function ovh-rescue-setup { local release='buster' local packages=( 'byobu' 'mosh' + 'lshw' 'file' 'grub-efi-amd64-bin' 'grub-pc-bin' 'htop' 'iotop' From e017d1a5b73a9770d6f7bfb11d89d51daf60a0a5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 02:41:10 +0200 Subject: [PATCH 026/969] parted,mdadm,lvm2,lsof --- bash/ovh-rescue.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 6cb8608..62cb0fc 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -2,10 +2,11 @@ function ovh-rescue-setup { local release='buster' local packages=( 'byobu' 'mosh' + 'parted' 'mdadm' 'lvm2' 'lshw' 'file' 'grub-efi-amd64-bin' 'grub-pc-bin' - 'htop' 'iotop' + 'htop' 'iotop' 'lsof' 'exa' 'ncdu' 'nnn' 'ranger' 'tree' 'squashfs-tools' 'uuid-runtime' From 76f16debb159a13e757f3082461ca7397a335f51 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 02:54:16 +0200 Subject: [PATCH 027/969] install --- bash/ovh-rescue.sh | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 62cb0fc..15142b7 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -1,21 +1,4 @@ function ovh-rescue-setup { - local release='buster' - local packages=( - 'byobu' 'mosh' - 'parted' 'mdadm' 'lvm2' - 'lshw' - 'file' - 'grub-efi-amd64-bin' 'grub-pc-bin' - 'htop' 'iotop' 'lsof' - 'exa' 'ncdu' 'nnn' 'ranger' 'tree' - 'squashfs-tools' - 'uuid-runtime' - ) - local backports=( - 'cryptsetup-bin' - 'git' - 'rsync' - ) # echo -n "\ en_US.UTF-8 UTF-8 @@ -42,9 +25,28 @@ deb https://deb.debian.org/debian buster-backports main contrib non-free deb https://deb.debian.org/debian buster-updates main contrib non-free deb https://deb.debian.org/debian-security buster/updates main contrib non-free " > '/etc/apt/sources.list' +} + +function ovh-rescue-install { + local release='buster' + local packages=( + 'byobu' 'mosh' + 'parted' 'mdadm' 'lvm2' + 'lshw' + 'file' + 'grub-efi-amd64-bin' 'grub-pc-bin' + 'htop' 'iotop' 'lsof' + 'exa' 'ncdu' 'nnn' 'ranger' 'tree' + 'squashfs-tools' + 'uuid-runtime' + ) + local backports=( + 'cryptsetup-bin' + 'git' + 'rsync' + ) # apt-get update - apt-get update # export DEBIAN_FRONTEND='noninteractive' # From 0d11ca4ee423d28cccd07f81a013d04c0dcb7e3a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 02:56:03 +0200 Subject: [PATCH 028/969] setup link --- bash/ovh-rescue.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 15142b7..526d33d 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -25,6 +25,8 @@ deb https://deb.debian.org/debian buster-backports main contrib non-free deb https://deb.debian.org/debian buster-updates main contrib non-free deb https://deb.debian.org/debian-security buster/updates main contrib non-free " > '/etc/apt/sources.list' + # + link_bashrc } function ovh-rescue-install { @@ -57,8 +59,6 @@ function ovh-rescue-install { --target-release "${release}-backports" "${backports[@]}" # apt-get clean - # - link_bashrc } function ovh-rescue-upload { From b5c4c51cedbbe6a06085af3112cb31cf85d622ba Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 02:59:00 +0200 Subject: [PATCH 029/969] hostname --- bash/ovh-rescue.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 526d33d..8823ba1 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -1,4 +1,6 @@ function ovh-rescue-setup { + # + echo -n 'ovh' > '/etc/hostname' # echo -n "\ en_US.UTF-8 UTF-8 From 6786a4ea2f2e2001fb35fa6ab1ee2ca34a5a4401 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 03:05:57 +0200 Subject: [PATCH 030/969] comment,rejigger --- bash/ovh-rescue.sh | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 8823ba1..c374972 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -1,15 +1,5 @@ function ovh-rescue-setup { - # - echo -n 'ovh' > '/etc/hostname' - # - echo -n "\ -en_US.UTF-8 UTF-8 -fr_FR.UTF-8 UTF-8 -" > '/etc/locale.gen' - rm --force '/usr/share/locale/locale.alias' - ln --symbolic '/etc/locale.alias' '/usr/share/locale/locale.alias' - locale-gen - # + # apt / conf echo -n "\ Acquire::AllowInsecureRepositories False; Acquire::AllowWeakRepositories False; @@ -21,14 +11,27 @@ APT::Get::Show-Versions True; Dir::Etc::SourceParts ''; Dpkg::Progress True; " > '/etc/apt/apt.conf' + # apt / sources echo -n "\ deb https://deb.debian.org/debian buster main contrib non-free deb https://deb.debian.org/debian buster-backports main contrib non-free deb https://deb.debian.org/debian buster-updates main contrib non-free deb https://deb.debian.org/debian-security buster/updates main contrib non-free " > '/etc/apt/sources.list' - # + # bash / rc link_bashrc + # host name + echo -n 'ovh' > '/etc/hostname' + # locales + echo -n "\ +en_US.UTF-8 UTF-8 +fr_FR.UTF-8 UTF-8 +" > '/etc/locale.gen' + # fix alias + rm --force '/usr/share/locale/locale.alias' + ln --symbolic '/etc/locale.alias' '/usr/share/locale/locale.alias' + # generate locales + locale-gen } function ovh-rescue-install { @@ -49,17 +52,18 @@ function ovh-rescue-install { 'git' 'rsync' ) - # + # update catalog apt-get update # export DEBIAN_FRONTEND='noninteractive' - # + # upgrade packages apt-get upgrade --assume-yes - # + # install packages apt-get install --assume-yes "${packages[@]}" + # install backports apt-get install --assume-yes \ --target-release "${release}-backports" "${backports[@]}" - # + # clean cache apt-get clean } @@ -69,9 +73,9 @@ if [ "${host}" ] ; then local user='root' # local user_host="${user}@${host}" - # + # remove fingerprints ssh-keygen -R "${host}" - # + # copy ssh id ssh-copy-id \ -o 'StrictHostKeyChecking=accept-new' \ "${user_host}" From 7354deeee2f69673e0066e5687c2e2ca4a93a7f6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 03:06:40 +0200 Subject: [PATCH 031/969] bbl --- bash/byobu.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bash/byobu.sh b/bash/byobu.sh index 1eb6d63..5adf843 100644 --- a/bash/byobu.sh +++ b/bash/byobu.sh @@ -1 +1,3 @@ alias bb='byobu' + +alias bbl='byobu ls' From 1f75f16a73a8264baa28d38f010dc75d35462464 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 03:08:07 +0200 Subject: [PATCH 032/969] bba,bbn --- bash/byobu.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bash/byobu.sh b/bash/byobu.sh index 5adf843..fd5e98d 100644 --- a/bash/byobu.sh +++ b/bash/byobu.sh @@ -1,3 +1,7 @@ alias bb='byobu' +alias bba='byobu attach-session' + alias bbl='byobu ls' + +alias bbn='byobu new-session -d' From 9166e6ff45808e659112104b28aae4a0a07c2c4c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 03:18:59 +0200 Subject: [PATCH 033/969] passphrase --- bash/ovh-rescue.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index c374972..839aee5 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -97,7 +97,7 @@ function ovh-rescue-wipe-1-2TB { local device='/dev/sda' local unit='mib' # - echo -n 'WIPE' "${device}" '/?\\ OR CANCEL /!\\' + echo -n 'WIPE' "${device}" '/?\ OR CANCEL /!\' read # parted "${device}" --script mktable gpt @@ -117,20 +117,26 @@ function ovh-rescue-wipe-1-2TB { mkfs.vfat -F 32 -n 'esp' '/dev/sda3' # format boot mkfs.ext4 -L 'boot' '/dev/sda2' + # read passphrase + local passphrase + read passphrase # encrypt - cryptsetup \ + echo "${passphrase}" \ + | cryptsetup \ --verbose \ - --type luks2 \ - --pbkdf argon2id \ - --cipher aes-xts-plain64 \ + --batch-mode \ + --type 'luks2' \ + --pbkdf 'argon2id' \ + --cipher 'aes-xts-plain64' \ --iter-time 8192 \ --key-size 512 \ - --hash sha512 \ + --hash 'sha512' \ --use-random \ luksFormat \ '/dev/sda1' # open - cryptsetup luksOpen '/dev/sda1' 'crypt' + echo "${passphrase}" \ + | cryptsetup luksOpen '/dev/sda1' 'crypt' # pv pvcreate '/dev/mapper/crypt' # vg From b7b590a97cc04a5a8d110f26751def843906328e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 03:21:41 +0200 Subject: [PATCH 034/969] read secret --- bash/ovh-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 839aee5..d660119 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -119,7 +119,7 @@ function ovh-rescue-wipe-1-2TB { mkfs.ext4 -L 'boot' '/dev/sda2' # read passphrase local passphrase - read passphrase + read -s passphrase # encrypt echo "${passphrase}" \ | cryptsetup \ From 65f9d3b249cb84243a63793bdbe909e6e1959d49 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 03:23:05 +0200 Subject: [PATCH 035/969] read raw --- bash/ovh-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index d660119..0209661 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -119,7 +119,7 @@ function ovh-rescue-wipe-1-2TB { mkfs.ext4 -L 'boot' '/dev/sda2' # read passphrase local passphrase - read -s passphrase + read -r -s passphrase # encrypt echo "${passphrase}" \ | cryptsetup \ From 63bb37330a686a902fedb67a7fa053b072fd8fdd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 03:28:08 +0200 Subject: [PATCH 036/969] wipe-lsblk,hostname --- bash/ovh-rescue.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 0209661..96ecea3 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -21,7 +21,7 @@ deb https://deb.debian.org/debian-security buster/updates main contrib non-free # bash / rc link_bashrc # host name - echo -n 'ovh' > '/etc/hostname' + echo 'ovh' > '/etc/hostname' # locales echo -n "\ en_US.UTF-8 UTF-8 @@ -97,6 +97,7 @@ function ovh-rescue-wipe-1-2TB { local device='/dev/sda' local unit='mib' # + lsblk echo -n 'WIPE' "${device}" '/?\ OR CANCEL /!\' read # From c301758e1ca4878a1d6bc7aadb3a18b0e2263b11 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 03:36:05 +0200 Subject: [PATCH 037/969] read prompt --- bash/ovh-rescue.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 96ecea3..771e940 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -120,6 +120,7 @@ function ovh-rescue-wipe-1-2TB { mkfs.ext4 -L 'boot' '/dev/sda2' # read passphrase local passphrase + echo -n 'PassPhrase: ' read -r -s passphrase # encrypt echo "${passphrase}" \ From e017ce2785444cd9535bc4d1f82c39590129cd78 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 03:42:00 +0200 Subject: [PATCH 038/969] force format boot --- bash/ovh-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 771e940..e53ab66 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -117,7 +117,7 @@ function ovh-rescue-wipe-1-2TB { # format esp mkfs.vfat -F 32 -n 'esp' '/dev/sda3' # format boot - mkfs.ext4 -L 'boot' '/dev/sda2' + mkfs.ext4 -F -L 'boot' '/dev/sda2' # read passphrase local passphrase echo -n 'PassPhrase: ' From 9cfd4aa88929a2bc336f9cd5d7935ef1ff31a33a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 03:44:57 +0200 Subject: [PATCH 039/969] hostname --- bash/ovh-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index e53ab66..d99e2e4 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -21,7 +21,7 @@ deb https://deb.debian.org/debian-security buster/updates main contrib non-free # bash / rc link_bashrc # host name - echo 'ovh' > '/etc/hostname' + hostname 'ovh' # locales echo -n "\ en_US.UTF-8 UTF-8 From 76d233d4f7727dccf8ee0a7024c14e9bb9069428 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 04:08:37 +0200 Subject: [PATCH 040/969] byobu,mosh --- bash/ovh-rescue.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index d99e2e4..9b2efd5 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -1,4 +1,7 @@ function ovh-rescue-setup { + local packages=( + 'byobu' 'mosh' + ) # apt / conf echo -n "\ Acquire::AllowInsecureRepositories False; @@ -32,13 +35,18 @@ fr_FR.UTF-8 UTF-8 ln --symbolic '/etc/locale.alias' '/usr/share/locale/locale.alias' # generate locales locale-gen + # update catalog + apt-get update + # install packages + apt-get install --assume-yes "${packages[@]}" } function ovh-rescue-install { local release='buster' local packages=( - 'byobu' 'mosh' + # installed 'parted' 'mdadm' 'lvm2' + # install 'lshw' 'file' 'grub-efi-amd64-bin' 'grub-pc-bin' @@ -48,9 +56,10 @@ function ovh-rescue-install { 'uuid-runtime' ) local backports=( - 'cryptsetup-bin' + # installed + 'cryptsetup-bin' 'rsync' + # install 'git' - 'rsync' ) # update catalog apt-get update From f4f5eb31c99c2764d94c05d98b0b215a7f2bd145 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 13 May 2023 11:30:41 +0200 Subject: [PATCH 041/969] send keys to install --- bash/ovh-rescue.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 9b2efd5..0e5c909 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -94,6 +94,8 @@ if [ "${host}" ] ; then ssh "${user_host}" -- "source '/etc/bash/main.sh' ; ovh-rescue-setup" # create session ssh "${user_host}" -- byobu new-session -d + # send keys + ssh "${user_host}" -- byobu send-keys 'ovh-rescue-install' 'C-m' # attach session mosh "${user_host}" -- byobu attach-session else From b14f4c2f27f6f7cbdccd46a101277f51d9613e4d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 11:46:49 +0200 Subject: [PATCH 042/969] readme --- readme.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 readme.md diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..8a581a0 --- /dev/null +++ b/readme.md @@ -0,0 +1,2 @@ +* [ ] log +* [ ] apt-file search | grep From 515d64bc2ace6029fd368ae3884492fb77dcd270 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 11:48:35 +0200 Subject: [PATCH 043/969] debian/frontend --- bash/debian.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 bash/debian.sh diff --git a/bash/debian.sh b/bash/debian.sh new file mode 100644 index 0000000..acf628d --- /dev/null +++ b/bash/debian.sh @@ -0,0 +1,3 @@ +function debian_disable_frontend { + export DEBIAN_FRONTEND='noninteractive' +} From b9949d107cc830ef41195cce7430a786f8dff4a0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 11:51:45 +0200 Subject: [PATCH 044/969] debian disable frontend --- bash/ovh-rescue.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 0e5c909..faed2e1 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -37,6 +37,8 @@ fr_FR.UTF-8 UTF-8 locale-gen # update catalog apt-get update + # + debian_disable_frontend # install packages apt-get install --assume-yes "${packages[@]}" } @@ -64,7 +66,7 @@ function ovh-rescue-install { # update catalog apt-get update # - export DEBIAN_FRONTEND='noninteractive' + debian_disable_frontend # upgrade packages apt-get upgrade --assume-yes # install packages From 07961df4c9f3dad230a34decaa6b885b64de7bfc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 11:55:08 +0200 Subject: [PATCH 045/969] todo --- bash/ovh-rescue.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index faed2e1..68b8d23 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -93,6 +93,7 @@ if [ "${host}" ] ; then # upload root rsync --delete --recursive "${MAIN_ROOT}/" "${user_host}:/etc/bash/" # call setup + # TODO variable ssh "${user_host}" -- "source '/etc/bash/main.sh' ; ovh-rescue-setup" # create session ssh "${user_host}" -- byobu new-session -d From 45127eab10a86bde7f7ca08f3215874851213f1d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 12:07:22 +0200 Subject: [PATCH 046/969] readme --- readme.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 8a581a0..2888584 100644 --- a/readme.md +++ b/readme.md @@ -1,2 +1,10 @@ +# Public + +## ToDo + +* [ ] no alias * [ ] log -* [ ] apt-file search | grep +* [ ] ovh + * [ ] clean apt cache after each install/upgrade step +* [ ] apt + * [ ] apt-file search | grep From e25bf7bbfb89a27f712cfe7d6e2a063feed3a8aa Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 13:33:51 +0200 Subject: [PATCH 047/969] l --- bash/ls.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bash/ls.sh b/bash/ls.sh index c820fb5..f9a65e5 100644 --- a/bash/ls.sh +++ b/bash/ls.sh @@ -1,2 +1,9 @@ -# list current directory entries -alias l='ls --all --color -l -p --time-style="+%Y%m%d-%H%M%S%-:::z"' +# list current directory's entries +alias l="\ +ls \ +--all \ +--color \ +-l \ +-p \ +--time-style \"+%Y%m%d-%H%M%S%-:::z\" \ +" From 248bbae91bf053ba12cd4f7febfd6cd7a910f47a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 13:45:02 +0200 Subject: [PATCH 048/969] lsblk --- bash/lsblk.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bash/lsblk.sh b/bash/lsblk.sh index 42b6442..7ae874a 100644 --- a/bash/lsblk.sh +++ b/bash/lsblk.sh @@ -1,3 +1,12 @@ -alias lb='lsblk --noempty --output NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS' +# list block devices +alias lb="\ +lsblk \ +--output \"NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS\" \ +--noempty \ +" -alias lbo='lsblk --output NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT' +# list block devices (old) +alias lbo="\ +lsblk \ +--output \"NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT\" \ +" From b07230a6a17d880061e74eca4beea94dc4765cb8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 13:57:53 +0200 Subject: [PATCH 049/969] recursive --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 2888584..1e8a316 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ ## ToDo -* [ ] no alias +* [ ] import modules recursively * [ ] log * [ ] ovh * [ ] clean apt cache after each install/upgrade step From 1f44f63093ebe76a755b783807cdba36c5733a1c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 13:59:46 +0200 Subject: [PATCH 050/969] import modules --- bash/main.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index 8996b7e..c8d6e1e 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -8,7 +8,7 @@ function link_bashrc { ln --symbolic "${MAIN_FILE}" "${file}" } -function main { +function main_import_modules { local module for module in "${MAIN_ROOT}"/*.sh ; do if [ "${module}" != "${MAIN_FILE}" ] ; then @@ -17,4 +17,4 @@ local module done } -main +main_import_modules From 6818171cbc6707e104e8568abf18a9aff46f9cbc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 14:01:41 +0200 Subject: [PATCH 051/969] bash/commands,completion,history,prompt --- bash/{bash-commands.sh => bash/commands.sh} | 0 bash/{bash-completion.sh => bash/completion.sh} | 0 bash/{bash-history.sh => bash/history.sh} | 0 bash/{bash-prompt.sh => bash/prompt.sh} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename bash/{bash-commands.sh => bash/commands.sh} (100%) rename bash/{bash-completion.sh => bash/completion.sh} (100%) rename bash/{bash-history.sh => bash/history.sh} (100%) rename bash/{bash-prompt.sh => bash/prompt.sh} (100%) diff --git a/bash/bash-commands.sh b/bash/bash/commands.sh similarity index 100% rename from bash/bash-commands.sh rename to bash/bash/commands.sh diff --git a/bash/bash-completion.sh b/bash/bash/completion.sh similarity index 100% rename from bash/bash-completion.sh rename to bash/bash/completion.sh diff --git a/bash/bash-history.sh b/bash/bash/history.sh similarity index 100% rename from bash/bash-history.sh rename to bash/bash/history.sh diff --git a/bash/bash-prompt.sh b/bash/bash/prompt.sh similarity index 100% rename from bash/bash-prompt.sh rename to bash/bash/prompt.sh From 5433ef186ae6c6559c44000364279af845f288b1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 14:46:23 +0200 Subject: [PATCH 052/969] modules --- bash/main.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index c8d6e1e..d858f6d 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -8,13 +8,19 @@ function link_bashrc { ln --symbolic "${MAIN_FILE}" "${file}" } +# import modules function main_import_modules { -local module - for module in "${MAIN_ROOT}"/*.sh ; do + local IFS=$'\n' + local modules=($(find "${MAIN_ROOT}" -type 'f' -name '*.sh')) + local module + for module in "${modules[@]}" ; do if [ "${module}" != "${MAIN_FILE}" ] ; then + echo + echo "${module}" source "${module}" fi done } +# import modules main_import_modules From 2520fbee34b80b4576f2f42375cacd75eea9bab9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 15:51:38 +0200 Subject: [PATCH 053/969] log --- bash/log.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 bash/log.sh diff --git a/bash/log.sh b/bash/log.sh new file mode 100644 index 0000000..1e699b3 --- /dev/null +++ b/bash/log.sh @@ -0,0 +1,20 @@ +LOG_LEVEL_FATAL=0 +LOG_LEVEL_ERROR=1 +LOG_LEVEL_WARN=2 +LOG_LEVEL_INFO=3 +LOG_LEVEL_DEBUG=4 +LOG_LEVEL_TRACE=5 + +LOG_LEVEL=${LOG_LEVEL_WARNING} + +function log_fatal { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_FATAL} ] && echo "${@}" ; } + +function log_error { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_ERROR} ] && echo "${@}" ; } + +function log_warn { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_WARN} ] && echo "${@}" ; } + +function log_info { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_INFO} ] && echo "${@}" ; } + +function log_debug { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_DEBUG} ] && echo "${@}" ; } + +function log_trace { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_TRACE} ] && echo "${@}" ; } From 4ce6077f236e48c0ca1937b2be9f33e18eb20bc0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:00:34 +0200 Subject: [PATCH 054/969] alias --- bash/{ => alias}/apt.sh | 0 bash/{ => alias}/batcat.sh | 0 bash/{ => alias}/byobu.sh | 0 bash/{ => alias}/chmod.sh | 0 bash/{ => alias}/chown.sh | 0 bash/{ => alias}/clear.sh | 0 bash/{ => alias}/git.sh | 0 bash/{ => alias}/grep.sh | 0 bash/{ => alias}/kill.sh | 0 bash/{ => alias}/killall.sh | 0 bash/{ => alias}/ls.sh | 0 bash/{ => alias}/lsblk.sh | 0 bash/{ => alias}/micro.sh | 0 bash/{ => alias}/mkdir.sh | 0 bash/{ => alias}/newsboat.sh | 0 bash/{ => alias}/otpclient-cli.sh | 0 bash/{ => alias}/pass.sh | 0 bash/{ => alias}/ps.sh | 0 bash/{ => alias}/rsync.sh | 0 bash/{ => alias}/tar.sh | 0 20 files changed, 0 insertions(+), 0 deletions(-) rename bash/{ => alias}/apt.sh (100%) rename bash/{ => alias}/batcat.sh (100%) rename bash/{ => alias}/byobu.sh (100%) rename bash/{ => alias}/chmod.sh (100%) rename bash/{ => alias}/chown.sh (100%) rename bash/{ => alias}/clear.sh (100%) rename bash/{ => alias}/git.sh (100%) rename bash/{ => alias}/grep.sh (100%) rename bash/{ => alias}/kill.sh (100%) rename bash/{ => alias}/killall.sh (100%) rename bash/{ => alias}/ls.sh (100%) rename bash/{ => alias}/lsblk.sh (100%) rename bash/{ => alias}/micro.sh (100%) rename bash/{ => alias}/mkdir.sh (100%) rename bash/{ => alias}/newsboat.sh (100%) rename bash/{ => alias}/otpclient-cli.sh (100%) rename bash/{ => alias}/pass.sh (100%) rename bash/{ => alias}/ps.sh (100%) rename bash/{ => alias}/rsync.sh (100%) rename bash/{ => alias}/tar.sh (100%) diff --git a/bash/apt.sh b/bash/alias/apt.sh similarity index 100% rename from bash/apt.sh rename to bash/alias/apt.sh diff --git a/bash/batcat.sh b/bash/alias/batcat.sh similarity index 100% rename from bash/batcat.sh rename to bash/alias/batcat.sh diff --git a/bash/byobu.sh b/bash/alias/byobu.sh similarity index 100% rename from bash/byobu.sh rename to bash/alias/byobu.sh diff --git a/bash/chmod.sh b/bash/alias/chmod.sh similarity index 100% rename from bash/chmod.sh rename to bash/alias/chmod.sh diff --git a/bash/chown.sh b/bash/alias/chown.sh similarity index 100% rename from bash/chown.sh rename to bash/alias/chown.sh diff --git a/bash/clear.sh b/bash/alias/clear.sh similarity index 100% rename from bash/clear.sh rename to bash/alias/clear.sh diff --git a/bash/git.sh b/bash/alias/git.sh similarity index 100% rename from bash/git.sh rename to bash/alias/git.sh diff --git a/bash/grep.sh b/bash/alias/grep.sh similarity index 100% rename from bash/grep.sh rename to bash/alias/grep.sh diff --git a/bash/kill.sh b/bash/alias/kill.sh similarity index 100% rename from bash/kill.sh rename to bash/alias/kill.sh diff --git a/bash/killall.sh b/bash/alias/killall.sh similarity index 100% rename from bash/killall.sh rename to bash/alias/killall.sh diff --git a/bash/ls.sh b/bash/alias/ls.sh similarity index 100% rename from bash/ls.sh rename to bash/alias/ls.sh diff --git a/bash/lsblk.sh b/bash/alias/lsblk.sh similarity index 100% rename from bash/lsblk.sh rename to bash/alias/lsblk.sh diff --git a/bash/micro.sh b/bash/alias/micro.sh similarity index 100% rename from bash/micro.sh rename to bash/alias/micro.sh diff --git a/bash/mkdir.sh b/bash/alias/mkdir.sh similarity index 100% rename from bash/mkdir.sh rename to bash/alias/mkdir.sh diff --git a/bash/newsboat.sh b/bash/alias/newsboat.sh similarity index 100% rename from bash/newsboat.sh rename to bash/alias/newsboat.sh diff --git a/bash/otpclient-cli.sh b/bash/alias/otpclient-cli.sh similarity index 100% rename from bash/otpclient-cli.sh rename to bash/alias/otpclient-cli.sh diff --git a/bash/pass.sh b/bash/alias/pass.sh similarity index 100% rename from bash/pass.sh rename to bash/alias/pass.sh diff --git a/bash/ps.sh b/bash/alias/ps.sh similarity index 100% rename from bash/ps.sh rename to bash/alias/ps.sh diff --git a/bash/rsync.sh b/bash/alias/rsync.sh similarity index 100% rename from bash/rsync.sh rename to bash/alias/rsync.sh diff --git a/bash/tar.sh b/bash/alias/tar.sh similarity index 100% rename from bash/tar.sh rename to bash/alias/tar.sh From b5761c429bd438d48809adc78f9a85197195136a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:01:12 +0200 Subject: [PATCH 055/969] alias/bash --- bash/{bash/commands.sh => alias/bash.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bash/{bash/commands.sh => alias/bash.sh} (100%) diff --git a/bash/bash/commands.sh b/bash/alias/bash.sh similarity index 100% rename from bash/bash/commands.sh rename to bash/alias/bash.sh From 22077fad31f1751003a967f6f4f4d8b2184abb97 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:06:24 +0200 Subject: [PATCH 056/969] tar --- bash/alias/tar.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/bash/alias/tar.sh b/bash/alias/tar.sh index bd36382..74b5020 100644 --- a/bash/alias/tar.sh +++ b/bash/alias/tar.sh @@ -1,5 +1,21 @@ -alias tc='tar --verbose --create --auto-compress --file' +alias tc="\ +tar \ +--verbose \ +--create \ +--auto-compress \ +--file \ +" -alias tl='tar --verbose --list --file' +alias tl="\ +tar \ +--verbose \ +--list \ +--file \ +" -alias tx='tar --verbose --extract --file' +alias tx="\ +tar \ +--verbose \ +--extract \ +--file \ +" From 4930c7bd044ccf6cfb52c7830cb3006d8faa3650 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:09:23 +0200 Subject: [PATCH 057/969] rsync --- bash/alias/rsync.sh | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/bash/alias/rsync.sh b/bash/alias/rsync.sh index ddd35b2..7c08c91 100644 --- a/bash/alias/rsync.sh +++ b/bash/alias/rsync.sh @@ -1,8 +1,29 @@ # synchronize -alias rs='rsync --archive --partial --progress --verbose --no-inc-recursive' +alias rs="\ +rsync \ +--archive \ +--partial \ +--progress \ +--verbose \ +--no-inc-recursive \ +" # synchronize and delete after -alias rsda='rsync --archive --partial --progress --verbose --delete-after' +alias rsda="\ +rsync \ +--archive \ +--partial \ +--progress \ +--verbose \ +--delete-after \ +" # synchronize and delete before -alias rsdb='rsync --archive --partial --progress --verbose --delete-before' +alias rsdb="\ +rsync \ +--archive \ +--partial \ +--progress \ +--verbose \ +--delete-before \ +" From cfc99b0cd74aa8f8d3ab0b8963b14cc7d7c9f3c1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:10:49 +0200 Subject: [PATCH 058/969] ps --- bash/alias/ps.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bash/alias/ps.sh b/bash/alias/ps.sh index 791a664..093944c 100644 --- a/bash/alias/ps.sh +++ b/bash/alias/ps.sh @@ -1,2 +1,5 @@ # look for a string in processes names -alias pg='ps -A | grep' +alias pg="\ +ps -A \ +| grep \ +" From f271a456fd6ba234cd40f3633b87439d17072f44 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:11:50 +0200 Subject: [PATCH 059/969] pass --- bash/alias/pass.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bash/alias/pass.sh b/bash/alias/pass.sh index f90153e..f01c653 100644 --- a/bash/alias/pass.sh +++ b/bash/alias/pass.sh @@ -1,5 +1,10 @@ # display pass entry's content -alias p='pass' +alias p="\ +pass \ +" # copy passphrase into clipboard -alias pc='pass --clip' +alias pc="\ +pass \ +--clip \ +" From 39f7ca123d0167ef8486a0e5aa442ddefc553324 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:17:53 +0200 Subject: [PATCH 060/969] otpclient-cli --- bash/alias/otpclient-cli.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bash/alias/otpclient-cli.sh b/bash/alias/otpclient-cli.sh index f2fa2ba..163fb1d 100644 --- a/bash/alias/otpclient-cli.sh +++ b/bash/alias/otpclient-cli.sh @@ -1,5 +1,12 @@ # display otp code -alias pd='otpclient-cli show -a' +alias pd="\ +otpclient-cli \ +show \ +--account \ +" # list otp accounts -alias pl='otpclient-cli list' +alias pl="\ +otpclient-cli \ +list \ +" From 5d07b3c14ad2f8260c5e7da296d93d431cab0ccb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:18:31 +0200 Subject: [PATCH 061/969] newsboat --- bash/alias/newsboat.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bash/alias/newsboat.sh b/bash/alias/newsboat.sh index b90f01b..971ad9d 100644 --- a/bash/alias/newsboat.sh +++ b/bash/alias/newsboat.sh @@ -1 +1,3 @@ -alias nb='newsboat' +alias nb="\ +newsboat \ +" From 038ee0cbf33900388a9992f140d1d875852e7910 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:19:10 +0200 Subject: [PATCH 062/969] mkdir --- bash/alias/mkdir.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bash/alias/mkdir.sh b/bash/alias/mkdir.sh index ba8d113..52745dd 100644 --- a/bash/alias/mkdir.sh +++ b/bash/alias/mkdir.sh @@ -1,5 +1,10 @@ # make a directory -alias md='mkdir' +alias md="\ +mkdir \ +" # make a directory after making its parents -alias mdp='mkdir --parents' +alias mdp="\ +mkdir \ +--parents \ +" From e6089c162451555f52dd26627936ea5402107d41 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:19:33 +0200 Subject: [PATCH 063/969] micro --- bash/alias/micro.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bash/alias/micro.sh b/bash/alias/micro.sh index de78a1d..97d7174 100644 --- a/bash/alias/micro.sh +++ b/bash/alias/micro.sh @@ -1 +1,3 @@ -alias e='micro' +alias e="\ +micro \ +" From e26343e222677bc668c794462c82d686d0706b05 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:24:24 +0200 Subject: [PATCH 064/969] ovh/micro --- bash/ovh-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 68b8d23..ecc2115 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -50,7 +50,7 @@ function ovh-rescue-install { 'parted' 'mdadm' 'lvm2' # install 'lshw' - 'file' + 'file' 'micro' 'grub-efi-amd64-bin' 'grub-pc-bin' 'htop' 'iotop' 'lsof' 'exa' 'ncdu' 'nnn' 'ranger' 'tree' From 69d9784679113b9178466d45847e321adcaa3da7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:26:24 +0200 Subject: [PATCH 065/969] kill,killall --- bash/alias/kill.sh | 9 +++++++-- bash/alias/killall.sh | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/bash/alias/kill.sh b/bash/alias/kill.sh index dbe03d1..970352d 100644 --- a/bash/alias/kill.sh +++ b/bash/alias/kill.sh @@ -1,5 +1,10 @@ # kill a process by id -alias k='kill' +alias k="\ +kill \ +" # force kill a process by id -alias kf='kill -9' +alias kf="\ +kill \ +-9 \ +" diff --git a/bash/alias/killall.sh b/bash/alias/killall.sh index 76c30a7..43c4cbe 100644 --- a/bash/alias/killall.sh +++ b/bash/alias/killall.sh @@ -1,5 +1,10 @@ # kill all instances of a process by name -alias ka='killall' +alias ka="\ +killall \ +" # force kill all instances of a process by name -alias kaf='killall -9' +alias kaf="\ +killall \ +-9 \ +" From b541f2021d730dc329acf92e05f6d18968e5f1be Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:28:45 +0200 Subject: [PATCH 066/969] grep --- bash/alias/grep.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bash/alias/grep.sh b/bash/alias/grep.sh index 6a9c514..73179dd 100644 --- a/bash/alias/grep.sh +++ b/bash/alias/grep.sh @@ -1,2 +1,7 @@ # grep from current directory with regex -alias g='grep --directories recurse --line-number --regexp' +alias g="\ +grep \ +--directories \"recurse\" \ +--line-number \ +--regexp \ +" From 81dc60be1ce82d72b6db9ecad212c4b0052d65be Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:29:21 +0200 Subject: [PATCH 067/969] clear --- bash/alias/clear.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bash/alias/clear.sh b/bash/alias/clear.sh index 350a925..afa9bb0 100644 --- a/bash/alias/clear.sh +++ b/bash/alias/clear.sh @@ -1,2 +1,4 @@ # clear terminal -alias c='clear' +alias c="\ +clear \ +" From 6f3ed66c062defc05532f32114d5b3736506a67f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:30:24 +0200 Subject: [PATCH 068/969] chown --- bash/alias/chown.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bash/alias/chown.sh b/bash/alias/chown.sh index 4beb36d..9b33024 100644 --- a/bash/alias/chown.sh +++ b/bash/alias/chown.sh @@ -1,5 +1,9 @@ # change owner as root -alias cor='chown 0:0' +alias cor="\ +chown \"0:0\" \ +" # change owner as user -alias cou='chown 1000:1000' +alias cou="\ +chown \"1000:1000\" \ +" From dbd9da9cd813e39b3102b1defeb8ba5d8c978b2b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:31:09 +0200 Subject: [PATCH 069/969] chmod --- bash/alias/chmod.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bash/alias/chmod.sh b/bash/alias/chmod.sh index 357d4dc..ee69091 100644 --- a/bash/alias/chmod.sh +++ b/bash/alias/chmod.sh @@ -1,5 +1,9 @@ # change mode as directory -alias cmd='chmod 755' +alias cmd="\ +chmod \"755\" \ +" # change mode as file -alias cmf='chmod 644' +alias cmf="\ +chmod \"644\" \ +" From 4f362fa0c4a29607661f87e97d701469925a0e89 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:35:32 +0200 Subject: [PATCH 070/969] byobu --- bash/alias/byobu.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/bash/alias/byobu.sh b/bash/alias/byobu.sh index fd5e98d..df37d6f 100644 --- a/bash/alias/byobu.sh +++ b/bash/alias/byobu.sh @@ -1,7 +1,19 @@ -alias bb='byobu' +alias bb="\ +byobu \ +" -alias bba='byobu attach-session' +alias bba="\ +byobu \ +attach-session \ +" -alias bbl='byobu ls' +alias bbl="\ +byobu \ +ls \ +" -alias bbn='byobu new-session -d' +alias bbn="\ +byobu \ +new-session \ +-d \ +" From 42cefc7a4983f8b489e88a0fb865ab86fb99949c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:36:36 +0200 Subject: [PATCH 071/969] batcat --- bash/alias/batcat.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bash/alias/batcat.sh b/bash/alias/batcat.sh index abe0b64..e62f4ac 100644 --- a/bash/alias/batcat.sh +++ b/bash/alias/batcat.sh @@ -1 +1,3 @@ -alias bat='batcat' +alias bat="\ +batcat \ +" From bb55e1f3587a02c9e6f9cb61139b6bd81968edff Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:38:54 +0200 Subject: [PATCH 072/969] bash --- bash/alias/bash.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bash/alias/bash.sh b/bash/alias/bash.sh index 211a5cf..84b628d 100644 --- a/bash/alias/bash.sh +++ b/bash/alias/bash.sh @@ -1,5 +1,14 @@ # change current directory to its parent -alias ..='cd ..' +alias ..="\ +cd .. \ +" + +# import source file +alias src="\ +source \ +" # exit terminal -alias x='exit' +alias x="\ +exit \ +" From 2c8add321a28eb26bfe6ad869a25799a6506afc7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:54:43 +0200 Subject: [PATCH 073/969] apt --- bash/alias/apt.sh | 78 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 15 deletions(-) diff --git a/bash/alias/apt.sh b/bash/alias/apt.sh index 5de980c..c4a0a7a 100644 --- a/bash/alias/apt.sh +++ b/bash/alias/apt.sh @@ -1,23 +1,71 @@ # show package information -alias ac='apt-cache show' - -# search package -alias acs='apt-cache search' +alias ac="\ +apt-cache \ +show \ +" # package versions policy -alias acp='apt-cache policy' +alias acp="\ +apt-cache \ +policy \ +" -# update packages catalog -alias agud='apt-get update' +# search package +alias acs="\ +apt-cache \ +search \ +" -# upgrade forbidding package installation or removal -alias agug='apt-get upgrade' +# +alias agap="\ +apt-get \ +autopurge \ +" -# upgrade allowing package installation or removal -alias agdu='apt-get dist-upgrade' - -# install packages -alias agi='apt-get install' +# +alias agar="\ +apt-get \ +autoremove \ +" # clean packages cache -alias agc='apt-get clean;apt-get autoremove' +alias agc="\ +apt-get \ +clean \ +" + +# upgrade allowing package installation or removal +alias agdu="\ +apt-get \ +dist-upgrade \ +" + +# install packages +alias agi="\ +apt-get \ +install \ +" + +# +alias agp="\ +apt-get \ +purge \ +" + +# +alias agr="\ +apt-get \ +remove \ +" + +# update packages catalog +alias agud="\ +apt-get \ +update \ +" + +# upgrade forbidding package installation or removal +alias agug="\ +apt-get \ +upgrade \ +" From 7557c5b2cc8bff5b7ffc9eb1fab5267b977c6e86 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 16:58:37 +0200 Subject: [PATCH 074/969] ggc --- bash/alias/git.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 7417e4c..85c5902 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -89,7 +89,11 @@ alias gf='git fetch --tags --verbose' alias gfp='git fetch --prune --tags --verbose' # garbage collect all orphan commits -alias ggc='git reflog expire --expire=now --all;git gc --prune=now' +alias ggc="\ +git reflog expire --expire=now --all \ +; \ +git gc --prune=now \ +" # initialize a new repository alias gi='git init' From 9bd2c799a057a68e84b47f0275238f0d4e0f166c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 17:08:10 +0200 Subject: [PATCH 075/969] ggc --- bash/alias/git.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 85c5902..769e5e3 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -90,9 +90,16 @@ alias gfp='git fetch --prune --tags --verbose' # garbage collect all orphan commits alias ggc="\ -git reflog expire --expire=now --all \ +git \ +reflog \ +expire \ +--all \ +--expire \"all\" \ ; \ -git gc --prune=now \ +git \ +gc \ +--aggressive \ +--prune \"now\" \ " # initialize a new repository From c89a269e78806eec3d422e97ef2eab240eb6035e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 17:10:44 +0200 Subject: [PATCH 076/969] prune --- bash/alias/git.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 769e5e3..9ce63bc 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -99,7 +99,7 @@ expire \ git \ gc \ --aggressive \ ---prune \"now\" \ +--prune=\"now\" \ " # initialize a new repository From ac2f69eea8961d92990fb076dc3508bb3df29727 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 17:56:00 +0200 Subject: [PATCH 077/969] ga --- bash/alias/git.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 9ce63bc..6d24bb8 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -1,8 +1,15 @@ # add to index -alias ga='git add' +alias ga="\ +git \ +add \ +" # add all to index -alias gaa='git add --all' +alias gaa="\ +git \ +add \ +--all \ +" # create a branch alias gb='git branch' From 26b40b3bd0ff5482383228d6c6d5e19ee719a94c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 17:59:03 +0200 Subject: [PATCH 078/969] gb --- bash/alias/git.sh | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 6d24bb8..b0edb43 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -12,19 +12,42 @@ add \ " # create a branch -alias gb='git branch' +alias gb="\ +git \ +branch \ +" # delete a branch -alias gbd='git branch --delete' +alias gbd="\ +git \ +branch \ +--delete \ +" # force a branch deletion -alias gbdf='git branch --delete --force' +alias gbdf="\ +git \ +branch \ +--delete \ +--force \ +" # list branches -alias gbl='git branch --all --list --verbose --verbose' +alias gbl="\ +git \ +branch \ +--all \ +--list \ +--verbose \ +--verbose \ +" # set the link to a remote branch from a local branch -alias gbu='git branch -u' +alias gbsu="\ +git \ +branch \ +--set-upstream-to \ +" # clone a remote repository alias gc='git clone' From 9017b8d90558d081ef1e64ffb6e75316aadc50c9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 18:04:13 +0200 Subject: [PATCH 079/969] gc,gcf --- bash/alias/git.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index b0edb43..3a43c68 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -50,10 +50,18 @@ branch \ " # clone a remote repository -alias gc='git clone' +alias gc="\ +git \ +clone \ +" # clean untracked files -alias gcf='git clean -d --force' +alias gcf="\ +git \ +clean \ +-d \ +--force \ +" # index all and commit alias gacm='git add --all;git commit -m' From 6b4410052b8f353c246e07706e3fcdd764c19122 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 18:07:01 +0200 Subject: [PATCH 080/969] gt --- bash/alias/git.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 3a43c68..5d1c42e 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -230,10 +230,21 @@ alias gs='git status --untracked-files=all' alias gsh='git show' # tag a commit -alias gt='git tag' +alias gt="\ +git \ +tag \ +" # delete a tag -alias gtd='git tag --delete' +alias gtd="\ +git \ +tag \ +--delete \ +" # tag a commit and sign -alias gts='git tag --sign' +alias gts="\ +git \ +tag \ +--sign \ +" From e93728cdc5b0a17a54c3f4d1ab1eb4a2cc0d6b71 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 18:11:10 +0200 Subject: [PATCH 081/969] grs --- bash/alias/git.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 5d1c42e..f2f2ec2 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -212,16 +212,17 @@ alias grms='git remote show' alias grmu='git remote set-url' # remove file(s) from index or move current branch pointer -alias grs='git reset' - -# move current branch pointer to the development branch -alias grsd='git reset dev' +alias grs="\ +git \ +reset \ +" # wipe modifications or reset current branch to another commit -alias grsh='git reset --hard' - -# reset current branch to the development branch -alias grshd='git reset --hard dev' +alias grsh="\ +git \ +reset \ +--hard \ +" # current state of repository alias gs='git status --untracked-files=all' From ab2d3d914198cbdedfc21cb790b691ec0e9eb570 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 18:17:18 +0200 Subject: [PATCH 082/969] grm --- bash/alias/git.sh | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index f2f2ec2..d252628 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -196,20 +196,39 @@ alias grbf='git rebase --no-ff' # rebase interactively alias grbi='git rebase --interactive' -# list all remote repositories -alias grm='git remote' +# remove and add to index +alias grm="\ +git \ +rm \ +" # add a new remote repository -alias grma='git remote add' +alias grma="\ +git \ +remote \ +add \ +" # list remote repositories -alias grml='git remote --verbose' +alias grml="\ +git \ +remote \ +--verbose \ +" # show a connection to a repository -alias grms='git remote show' +alias grms="\ +git \ +remote \ +show \ +" # set the location of the remote repository -alias grmu='git remote set-url' +alias grmsu="\ +git \ +remote \ +set-url \ +" # remove file(s) from index or move current branch pointer alias grs="\ From c41c49c30dfeec0f5ca7844b797f70fbc4f50b9d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 18:50:19 +0200 Subject: [PATCH 083/969] grb --- bash/alias/git.sh | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index d252628..1498ef1 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -182,19 +182,38 @@ alias gpd='git push --delete --verbose' alias gpf='git push --tags --verbose --force' # rebase current branch onto another -alias grb='git rebase' +alias grb="\ +git \ +rebase \ +" # abort current rebase -alias grba='git rebase --abort' +alias grba="\ +git \ +rebase \ +--abort \ +" # continue current rebase -alias grbc='git rebase --continue' +alias grbc="\ +git \ +rebase \ +--continue \ +" # force rebase without fast-forward -alias grbf='git rebase --no-ff' +alias grbf="\ +git \ +rebase \ +--force-rebase \ +" # rebase interactively -alias grbi='git rebase --interactive' +alias grbi="\ +git \ +rebase \ +--interactive \ +" # remove and add to index alias grm="\ From 8a99b9e1b7b69c992a40a2f46f7884c816b71c42 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 18:53:19 +0200 Subject: [PATCH 084/969] gp --- bash/alias/git.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 1498ef1..9065dcd 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -173,13 +173,29 @@ alias gms='git merge --squash' alias gmt='git mergetool' # push to the remote repository -alias gp='git push --tags --verbose' +alias gp="\ +git \ +push \ +--verbose \ +--tags \ +" # delete from the remote repository -alias gpd='git push --delete --verbose' +alias gpd="\ +git \ +push \ +--verbose \ +--delete \ +" # force the push to the remote repository -alias gpf='git push --tags --verbose --force' +alias gpf="\ +git \ +push \ +--verbose \ +--tags \ +--force \ +" # rebase current branch onto another alias grb="\ From 81616ae7707ef2d4b279ba2b5e4d76640eb16798 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 18:55:39 +0200 Subject: [PATCH 085/969] gf --- bash/alias/git.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 9065dcd..be3ed61 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -121,10 +121,21 @@ alias gdt='git difftool --dir-diff' alias gdw='git diff --word-diff-regex=.' # fetch from the remote repository -alias gf='git fetch --tags --verbose' +alias gf="\ +git \ +fetch \ +--verbose \ +--tags \ +" # fetch from remote repository and prune local orphan branches -alias gfp='git fetch --prune --tags --verbose' +alias gfp="\ +git \ +fetch \ +--verbose \ +--tags \ +--prune \ +" # garbage collect all orphan commits alias ggc="\ From a8d4d6373e8c062ecd81a26ff3f878694319b723 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 18:57:15 +0200 Subject: [PATCH 086/969] gcp --- bash/alias/git.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index be3ed61..b4ec3a0 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -91,13 +91,24 @@ alias gcod='git checkout dev' alias gcof='git checkout f' # pick a commit -alias gcp='git cherry-pick' +alias gcp="\ +git \ +cherry-pick \ +" # abort the commit pick -alias gcpa='git cherry-pick --abort' +alias gcpa="\ +git \ +cherry-pick \ +--abort \ +" # continue the commit pick -alias gcpc='git cherry-pick --continue' +alias gcpc="\ +git \ +cherry-pick \ +--continue \ +" # configure the user name alias gcun='git config user.name' From 4a500e83aca8c9980ecaa4c2f7d002f572b68238 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 19:49:34 +0200 Subject: [PATCH 087/969] gco --- bash/alias/git.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index b4ec3a0..fd54132 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -79,16 +79,17 @@ alias gcmr='git commit --allow-empty --allow-empty-message -m ""' alias gcms='git commit --gpg-sign -m' # switch to a branch or checkout file(s) from a commit -alias gco='git checkout' +alias gco="\ +git \ +checkout \ +" # checkout an orphan branch -alias gcoo='git checkout --orphan' - -# checkout development branch -alias gcod='git checkout dev' - -# checkout feature branch -alias gcof='git checkout f' +alias gcoo="\ +git \ +checkout \ +--orphan \ +" # pick a commit alias gcp="\ From 64c39902a6a194b42638e44a775e36943636f211 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 22:15:44 +0200 Subject: [PATCH 088/969] gd --- bash/alias/git.sh | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index fd54132..909c2b4 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -63,9 +63,6 @@ clean \ --force \ " -# index all and commit -alias gacm='git add --all;git commit -m' - # commit the index alias gcm='git commit -m' @@ -118,19 +115,39 @@ alias gcun='git config user.name' alias gcue='git config user.email' # differences from last or between commits -alias gd='git diff' +alias gd="\ +git \ +diff \ +" # display what is indexed in cache -alias gdc='git diff --cached' +alias gdc="\ +git \ +diff \ +--cached \ +" # indexed character-level differences -alias gdcw='git diff --cached --word-diff-regex=.' +alias gdcw="\ +git \ +diff \ +--cached \ +--word-diff-regex=. \ +" # differences via external tool -alias gdt='git difftool --dir-diff' +alias gdt="\ +git \ +difftool \ +--dir-diff \ +" # character-level differences -alias gdw='git diff --word-diff-regex=.' +alias gdw="\ +git \ +diff \ +--word-diff-regex=. \ +" # fetch from the remote repository alias gf="\ From db5874722aa126a8a6b9ff98ca0bea257e5eeb99 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 22:16:55 +0200 Subject: [PATCH 089/969] gcu --- bash/alias/git.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 909c2b4..07aaee2 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -109,10 +109,18 @@ cherry-pick \ " # configure the user name -alias gcun='git config user.name' +alias gcun="\ +git \ +config \ +user.name \ +" # configure the user email -alias gcue='git config user.email' +alias gcue="\ +git \ +config \ +user.email \ +" # differences from last or between commits alias gd="\ From ad467c223cb4d2802d6bb34b340c55e2ee95c298 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 22:18:05 +0200 Subject: [PATCH 090/969] gi --- bash/alias/git.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 07aaee2..7db6300 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -189,10 +189,17 @@ gc \ " # initialize a new repository -alias gi='git init' +alias gi="\ +git \ +init \ +" # initialize a new bare repository -alias gib='git init --bare' +alias gib="\ +git \ +init \ +--bare \ +" # log commits history alias gl='git log --all --graph \ From afac1464dc9ca1929a18451f79aaf1107a1414fd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 22:29:47 +0200 Subject: [PATCH 091/969] gm --- bash/alias/git.sh | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 7db6300..94ffd6c 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -212,20 +212,49 @@ alias glp='git log --all --graph \ # log medium information alias glm='git log --all --decorate --graph --pretty=medium' -# fast-forward to remote branch -alias gmf='git merge --ff-only' +# abort the current merge commit +alias gma="\ +git \ +merge \ +--abort \ +" # do a merge commit -alias gmc='git merge --no-ff -m' +alias gmc="\ +git \ +merge \ +--no-ff \ +-m \ +" -# abort the current merge commit -alias gma='git merge --abort' +# do a signed merge commit +alias gmcs="\ +git \ +merge \ +--no-ff \ +--gpg-sign \ +-m \ +" + +# fast-forward to remote branch +alias gmf="\ +git \ +merge \ +--ff-only \ +" # squash a branch and index its modifications -alias gms='git merge --squash' +alias gms="\ +git \ +merge \ +--squash \ +" # merge via external tool -alias gmt='git mergetool' +alias gmt="\ +git \ +mergetool \ +" # push to the remote repository alias gp="\ From e6d67ac56e45cbd6469277a2878616d1ce637ead Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 22:47:03 +0200 Subject: [PATCH 092/969] gl --- bash/alias/git.sh | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 94ffd6c..30fc8a6 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -202,15 +202,33 @@ init \ " # log commits history -alias gl='git log --all --graph \ ---format="%C(auto)%h%d %C(red)%ai%C(auto) %an%n%B"' - -# log commits history with patches -alias glp='git log --all --graph \ ---format="%C(auto)%h%d %C(red)%ai%C(auto) %an%n%B" --patch' +alias gl="\ +git \ +log \ +--all \ +--graph \ +--format=\"%C(auto)%h%d %C(red)%ai%C(auto) %an%n%B\" \ +" # log medium information -alias glm='git log --all --decorate --graph --pretty=medium' +alias glm="\ +git \ +log \ +--all \ +--decorate \ +--graph \ +--pretty=medium \ +" + +# log commits history with patches +alias glp="\ +git \ +log \ +--all \ +--graph \ +--format=\"%C(auto)%h%d %C(red)%ai%C(auto) %an%n%B\" \ +--patch \ +" # abort the current merge commit alias gma="\ From 3911f08261d3464a28017e3f510f8cd2700c8677 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 22:48:39 +0200 Subject: [PATCH 093/969] gap --- bash/alias/git.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 30fc8a6..9917fd7 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -11,6 +11,13 @@ add \ --all \ " +# add parts to index +alias gap="\ +git \ +add \ +--patch \ +" + # create a branch alias gb="\ git \ From ca650057079eee1517ad91469a8cd5920546704f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 22:56:05 +0200 Subject: [PATCH 094/969] gc --- bash/alias/git.sh | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 9917fd7..f2e2750 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -56,12 +56,6 @@ branch \ --set-upstream-to \ " -# clone a remote repository -alias gc="\ -git \ -clone \ -" - # clean untracked files alias gcf="\ git \ @@ -71,16 +65,36 @@ clean \ " # commit the index -alias gcm='git commit -m' +alias gc="\ +git \ +commit \ +-m \ +" # redo the last commit with a different message -alias gcma='git commit --amend -m' +alias gca="\ +git \ +commit \ +--amend \ +-m \ +" # make a root commit -alias gcmr='git commit --allow-empty --allow-empty-message -m ""' +alias gce="\ +git \ +commit \ +--allow-empty \ +--allow-empty-message \ +-m \"\" \ +" # commit the index and sign -alias gcms='git commit --gpg-sign -m' +alias gcs="\ +git \ +commit \ +--gpg-sign \ +-m \ +" # switch to a branch or checkout file(s) from a commit alias gco="\ From e9694b0c17c7166cdc3a4d934cf14171872a0611 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 22:58:58 +0200 Subject: [PATCH 095/969] gs --- bash/alias/git.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index f2e2750..2508360 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -402,10 +402,17 @@ reset \ " # current state of repository -alias gs='git status --untracked-files=all' +alias gs="\ +git \ +status \ +--untracked-files=all \ +" # show a commit -alias gsh='git show' +alias gsc="\ +git \ +show \ +" # tag a commit alias gt="\ From ffdc0c74e13b6c194053a2cf909e15ebb6fae5b4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 23:12:22 +0200 Subject: [PATCH 096/969] mount --- bash/alias/mount.sh | 10 ++++++++++ bash/mount.sh | 19 +++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 bash/alias/mount.sh diff --git a/bash/alias/mount.sh b/bash/alias/mount.sh new file mode 100644 index 0000000..ca11b0e --- /dev/null +++ b/bash/alias/mount.sh @@ -0,0 +1,10 @@ +alias m="\ +mount \ +" + +# remount read-only medium in read-write +alias remount="\ +mount \ +-o \"remount,rw\" \ +\"/usr/lib/live/mount/medium\" \ +" diff --git a/bash/mount.sh b/bash/mount.sh index b33b12c..65131f1 100644 --- a/bash/mount.sh +++ b/bash/mount.sh @@ -1,9 +1,3 @@ -alias m='mount' - -# remount read-only medium in read-write -alias remount='mount -o remount,rw /usr/lib/live/mount/medium' - - function mo { local directory="${1}" local file @@ -44,10 +38,19 @@ for f in 'dev' 'dev/pts' 'proc' 'sys' ; do done } -alias cr='chroot overlay/mount' +alias cr="\ +chroot \ +\"overlay/mount\" \ +" + +alias cru="\ +chroot \ +--userspec \"1000:1000\" \ +\"overlay/mount\" \ +" function ur { -for f in 'dev/pts' 'dev' 'proc' 'sys' ; do +for f in 'sys' 'proc' 'dev/pts' 'dev' ; do umount --lazy "overlay/mount/${f}" done } From 4f043326eee68585c6c0a34bd4cc7b2101e3c99b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 23:24:40 +0200 Subject: [PATCH 097/969] log modules --- bash/log.sh | 2 +- bash/main.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bash/log.sh b/bash/log.sh index 1e699b3..f7d325e 100644 --- a/bash/log.sh +++ b/bash/log.sh @@ -5,7 +5,7 @@ LOG_LEVEL_INFO=3 LOG_LEVEL_DEBUG=4 LOG_LEVEL_TRACE=5 -LOG_LEVEL=${LOG_LEVEL_WARNING} +LOG_LEVEL=${LOG_LEVEL_WARN} function log_fatal { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_FATAL} ] && echo "${@}" ; } diff --git a/bash/main.sh b/bash/main.sh index d858f6d..33a3df5 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -12,11 +12,10 @@ function link_bashrc { function main_import_modules { local IFS=$'\n' local modules=($(find "${MAIN_ROOT}" -type 'f' -name '*.sh')) + log_trace "${modules[@]}" local module for module in "${modules[@]}" ; do if [ "${module}" != "${MAIN_FILE}" ] ; then - echo - echo "${module}" source "${module}" fi done From d2eb5dd0114342d91bd9d811c4ba28d74c076cfe Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 23:31:26 +0200 Subject: [PATCH 098/969] after --- bash/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/main.sh b/bash/main.sh index 33a3df5..90ea527 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -12,13 +12,13 @@ function link_bashrc { function main_import_modules { local IFS=$'\n' local modules=($(find "${MAIN_ROOT}" -type 'f' -name '*.sh')) - log_trace "${modules[@]}" local module for module in "${modules[@]}" ; do if [ "${module}" != "${MAIN_FILE}" ] ; then source "${module}" fi done + log_trace "${modules[@]}" } # import modules From abe546de10e73301c518b49a3d47c6489f0c43e4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 15 May 2023 09:01:00 +0200 Subject: [PATCH 099/969] gpg --- bash/alias/gpg.sh | 12 ++++++++++++ bash/gnupg.sh | 8 -------- bash/gpg.sh | 4 ++++ 3 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 bash/alias/gpg.sh delete mode 100644 bash/gnupg.sh create mode 100644 bash/gpg.sh diff --git a/bash/alias/gpg.sh b/bash/alias/gpg.sh new file mode 100644 index 0000000..80705c5 --- /dev/null +++ b/bash/alias/gpg.sh @@ -0,0 +1,12 @@ +# turn gpg agent off +alias gpgoff="\ +gpgconf \ +--kill \"gpg-agent\" \ +" + +# bind gpg agent to current tty +alias gpgtty="\ +gpg-connect-agent \ +updatestartuptty \ +/bye \ +" diff --git a/bash/gnupg.sh b/bash/gnupg.sh deleted file mode 100644 index ab29be1..0000000 --- a/bash/gnupg.sh +++ /dev/null @@ -1,8 +0,0 @@ -if [ ${EUID} -ne 0 ] ; then - export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" - gpg-connect-agent updatestartuptty /bye > /dev/null -fi - -alias gpgoff='gpgconf --kill gpg-agent' - -alias gpgtty='gpg-connect-agent updatestartuptty /bye' diff --git a/bash/gpg.sh b/bash/gpg.sh new file mode 100644 index 0000000..8025b64 --- /dev/null +++ b/bash/gpg.sh @@ -0,0 +1,4 @@ +if [ ${EUID} -ne 0 ] ; then + export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" + gpg-connect-agent updatestartuptty /bye > '/dev/null' +fi From 04ccbd37c431d0a9c619a3d57c412e5486c834fc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 15 May 2023 09:02:33 +0200 Subject: [PATCH 100/969] gc/message --- bash/alias/git.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 2508360..c0645b1 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -68,7 +68,7 @@ clean \ alias gc="\ git \ commit \ --m \ +--message \ " # redo the last commit with a different message @@ -76,7 +76,7 @@ alias gca="\ git \ commit \ --amend \ --m \ +--message \ " # make a root commit @@ -85,7 +85,7 @@ git \ commit \ --allow-empty \ --allow-empty-message \ --m \"\" \ +--message \"\" \ " # commit the index and sign @@ -93,7 +93,7 @@ alias gcs="\ git \ commit \ --gpg-sign \ --m \ +--message \ " # switch to a branch or checkout file(s) from a commit From 4c7ad425b2796bf1a72962378bcc75161a5519ba Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 15 May 2023 09:19:43 +0200 Subject: [PATCH 101/969] main_bash --- bash/main.sh | 19 +++++++++++++------ bash/ovh-rescue.sh | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index 90ea527..c89870e 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -1,25 +1,32 @@ #! /usr/bin/env bash -MAIN_FILE="$(realpath "${BASH_SOURCE[0]}")" -MAIN_ROOT="$(dirname "${MAIN_FILE}")" + +MAIN_BASH_FILE="$(realpath "${BASH_SOURCE[0]}")" + +MAIN_BASH_ROOT="$(dirname "${MAIN_BASH_FILE}")" function link_bashrc { local file='/etc/bash.bashrc' rm --force "${file}" - ln --symbolic "${MAIN_FILE}" "${file}" + ln --symbolic "${MAIN_BASH_FILE}" "${file}" } # import modules function main_import_modules { +local root="${1}" +if [ -d "${root}" ] ; then local IFS=$'\n' - local modules=($(find "${MAIN_ROOT}" -type 'f' -name '*.sh')) + local modules=($(find "${root}" -type 'f' -name '*.sh')) local module for module in "${modules[@]}" ; do - if [ "${module}" != "${MAIN_FILE}" ] ; then + if [ "${module}" != "${MAIN_BASH_FILE}" ] ; then source "${module}" fi done log_trace "${modules[@]}" +else + log_fatal "No directory: ${root}" +fi } # import modules -main_import_modules +main_import_modules "${MAIN_BASH_ROOT}" diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index ecc2115..295a95f 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -91,7 +91,7 @@ if [ "${host}" ] ; then -o 'StrictHostKeyChecking=accept-new' \ "${user_host}" # upload root - rsync --delete --recursive "${MAIN_ROOT}/" "${user_host}:/etc/bash/" + rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" # call setup # TODO variable ssh "${user_host}" -- "source '/etc/bash/main.sh' ; ovh-rescue-setup" From 3fc442bf709f20fb934f801fe8d0a87768befeea Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 15 May 2023 12:07:16 +0200 Subject: [PATCH 102/969] main_link_bashrc --- bash/main.sh | 2 +- bash/ovh-rescue.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index c89870e..9b7afdd 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -4,7 +4,7 @@ MAIN_BASH_FILE="$(realpath "${BASH_SOURCE[0]}")" MAIN_BASH_ROOT="$(dirname "${MAIN_BASH_FILE}")" -function link_bashrc { +function main_link_bashrc { local file='/etc/bash.bashrc' rm --force "${file}" ln --symbolic "${MAIN_BASH_FILE}" "${file}" diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 295a95f..c52af9f 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -22,7 +22,7 @@ deb https://deb.debian.org/debian buster-updates main contrib non-free deb https://deb.debian.org/debian-security buster/updates main contrib non-free " > '/etc/apt/sources.list' # bash / rc - link_bashrc + main_link_bashrc # host name hostname 'ovh' # locales From b170098755e474412de52c1a2eec1cb6eb7b713b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 15 May 2023 12:20:00 +0200 Subject: [PATCH 103/969] ovh-rescue-configure --- bash/ovh-rescue.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index c52af9f..cd7f899 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -1,4 +1,4 @@ -function ovh-rescue-setup { +function ovh-rescue-configure { local packages=( 'byobu' 'mosh' ) @@ -94,7 +94,7 @@ if [ "${host}" ] ; then rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" # call setup # TODO variable - ssh "${user_host}" -- "source '/etc/bash/main.sh' ; ovh-rescue-setup" + ssh "${user_host}" -- "source '/etc/bash/main.sh' ; ovh-rescue-configure" # create session ssh "${user_host}" -- byobu new-session -d # send keys From 3ffc60e4f16a5ace6c7cdf447342d9285ebcbb85 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 15 May 2023 18:41:02 +0200 Subject: [PATCH 104/969] main/file --- bash/main.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index 9b7afdd..ad08f22 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -12,21 +12,22 @@ function main_link_bashrc { # import modules function main_import_modules { -local root="${1}" -if [ -d "${root}" ] ; then +local file="${1}" +if [ -f "${file}" ] ; then + local root="$(dirname "${file}")" local IFS=$'\n' local modules=($(find "${root}" -type 'f' -name '*.sh')) local module for module in "${modules[@]}" ; do - if [ "${module}" != "${MAIN_BASH_FILE}" ] ; then + if [ "${module}" != "${file}" ] ; then source "${module}" fi done log_trace "${modules[@]}" else - log_fatal "No directory: ${root}" + log_fatal "No file: ${file}" fi } # import modules -main_import_modules "${MAIN_BASH_ROOT}" +main_import_modules "${MAIN_BASH_FILE}" From 80f19583ce4f467e87490ef12fc89fea1c8a265c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 15 May 2023 18:56:12 +0200 Subject: [PATCH 105/969] path --- bash/main.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bash/main.sh b/bash/main.sh index ad08f22..424a2ec 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -14,7 +14,8 @@ function main_link_bashrc { function main_import_modules { local file="${1}" if [ -f "${file}" ] ; then - local root="$(dirname "${file}")" + local path="$(realpath "${file}")" + local root="$(dirname "${path}")" local IFS=$'\n' local modules=($(find "${root}" -type 'f' -name '*.sh')) local module From 9609171ad634c4b1cfdd065e4d3d227e1df9f2f4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 15 May 2023 18:59:04 +0200 Subject: [PATCH 106/969] path --- bash/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/main.sh b/bash/main.sh index 424a2ec..ce04a8a 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -20,7 +20,7 @@ if [ -f "${file}" ] ; then local modules=($(find "${root}" -type 'f' -name '*.sh')) local module for module in "${modules[@]}" ; do - if [ "${module}" != "${file}" ] ; then + if [ "${module}" != "${path}" ] ; then source "${module}" fi done From 3092524d58a6dbebc81565c283f83a0e9626a1d7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 15 May 2023 21:12:20 +0200 Subject: [PATCH 107/969] evince --- bash/alias/evince.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 bash/alias/evince.sh diff --git a/bash/alias/evince.sh b/bash/alias/evince.sh new file mode 100644 index 0000000..0d36d89 --- /dev/null +++ b/bash/alias/evince.sh @@ -0,0 +1,3 @@ +alias ev="\ +evince \ +" From 060287a12725083bdbc9c0a1442236a7a5bb6d5e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 15 May 2023 21:13:48 +0200 Subject: [PATCH 108/969] todo/ffmpeg --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 1e8a316..4021d7f 100644 --- a/readme.md +++ b/readme.md @@ -8,3 +8,4 @@ * [ ] clean apt cache after each install/upgrade step * [ ] apt * [ ] apt-file search | grep +* [ ] ffmpeg From 3b71c87e03ab28510e9a2ef5bab60b2f395479d9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 15 May 2023 21:23:36 +0200 Subject: [PATCH 109/969] apt_clean_cache --- bash/apt.sh | 3 +++ bash/ovh-rescue.sh | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 bash/apt.sh diff --git a/bash/apt.sh b/bash/apt.sh new file mode 100644 index 0000000..e83ccc1 --- /dev/null +++ b/bash/apt.sh @@ -0,0 +1,3 @@ +function apt_clean_cache { + apt-get clean +} diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index cd7f899..bfe0bf2 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -41,6 +41,8 @@ fr_FR.UTF-8 UTF-8 debian_disable_frontend # install packages apt-get install --assume-yes "${packages[@]}" + # + apt_clean_cache } function ovh-rescue-install { @@ -69,13 +71,17 @@ function ovh-rescue-install { debian_disable_frontend # upgrade packages apt-get upgrade --assume-yes + # + apt_clean_cache # install packages apt-get install --assume-yes "${packages[@]}" + # + apt_clean_cache # install backports apt-get install --assume-yes \ --target-release "${release}-backports" "${backports[@]}" - # clean cache - apt-get clean + # + apt_clean_cache } function ovh-rescue-upload { From b54d423f87100918225c19b71b2f89be80a617a8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 16 May 2023 18:26:21 +0200 Subject: [PATCH 110/969] mm/make-rslave,rbind um/recursive --- bash/mount.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/mount.sh b/bash/mount.sh index 65131f1..e92ecef 100644 --- a/bash/mount.sh +++ b/bash/mount.sh @@ -57,11 +57,11 @@ done function mm { -mount --bind '/deb' 'overlay/mount/deb' +mount --make-rslave --rbind '/deb' 'overlay/mount/deb' } function um { -umount 'overlay/mount/deb' +umount --recursive 'overlay/mount/deb' } From 3e924813c84ff45da69243186d8aa1810bca8c74 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 17 May 2023 16:24:01 +0200 Subject: [PATCH 111/969] =?UTF-8?q?account=E2=86=92a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash/alias/otpclient-cli.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/alias/otpclient-cli.sh b/bash/alias/otpclient-cli.sh index 163fb1d..be14c50 100644 --- a/bash/alias/otpclient-cli.sh +++ b/bash/alias/otpclient-cli.sh @@ -2,7 +2,7 @@ alias pd="\ otpclient-cli \ show \ ---account \ +-a \ " # list otp accounts From d7bee96329c93121be7c1f1c038f0ea83766a378 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 18 May 2023 12:34:05 +0200 Subject: [PATCH 112/969] git/clone,commit --- bash/alias/git.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index c0645b1..14e5dfe 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -56,6 +56,12 @@ branch \ --set-upstream-to \ " +# clone a remote repository +alias gc="\ +git \ +clone \ +" + # clean untracked files alias gcf="\ git \ @@ -65,14 +71,14 @@ clean \ " # commit the index -alias gc="\ +alias gcm="\ git \ commit \ --message \ " # redo the last commit with a different message -alias gca="\ +alias gcma="\ git \ commit \ --amend \ @@ -80,7 +86,7 @@ commit \ " # make a root commit -alias gce="\ +alias gcme="\ git \ commit \ --allow-empty \ @@ -89,7 +95,7 @@ commit \ " # commit the index and sign -alias gcs="\ +alias gcms="\ git \ commit \ --gpg-sign \ From 70006908feda611d9fe87f847e023776e7ff011e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 18 May 2023 13:20:30 +0200 Subject: [PATCH 113/969] mvi --- bash/alias/mv.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 bash/alias/mv.sh diff --git a/bash/alias/mv.sh b/bash/alias/mv.sh new file mode 100644 index 0000000..dff7f63 --- /dev/null +++ b/bash/alias/mv.sh @@ -0,0 +1,5 @@ +# move interactively +alias mvi="\ +mv \ +--interactive \ +" From 7358508a9385508f91d5f429536bc452f3b147b9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 18 May 2023 13:23:12 +0200 Subject: [PATCH 114/969] cpi --- bash/alias/cp.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 bash/alias/cp.sh diff --git a/bash/alias/cp.sh b/bash/alias/cp.sh new file mode 100644 index 0000000..946182f --- /dev/null +++ b/bash/alias/cp.sh @@ -0,0 +1,5 @@ +# copy interactively +alias cpi="\ +cp \ +--interactive \ +" From 57c4d5863111b5cc4475defe0c82a12bf3157372 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 18 May 2023 13:24:21 +0200 Subject: [PATCH 115/969] sd --- bash/alias/bash.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bash/alias/bash.sh b/bash/alias/bash.sh index 84b628d..65a7bda 100644 --- a/bash/alias/bash.sh +++ b/bash/alias/bash.sh @@ -1,6 +1,13 @@ # change current directory to its parent alias ..="\ -cd .. \ +cd \ +.. \ +" + +# swap directory (current ↔ previous) +alias sd="\ +cd \ +- \ " # import source file From a35d7da97579e4221336f2da3575496df9d6d5e5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 18 May 2023 13:25:21 +0200 Subject: [PATCH 116/969] \ --- bash/alias/chmod.sh | 6 ++++-- bash/alias/chown.sh | 6 ++++-- bash/alias/ps.sh | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bash/alias/chmod.sh b/bash/alias/chmod.sh index ee69091..4df1df3 100644 --- a/bash/alias/chmod.sh +++ b/bash/alias/chmod.sh @@ -1,9 +1,11 @@ # change mode as directory alias cmd="\ -chmod \"755\" \ +chmod \ +\"755\" \ " # change mode as file alias cmf="\ -chmod \"644\" \ +chmod \ +\"644\" \ " diff --git a/bash/alias/chown.sh b/bash/alias/chown.sh index 9b33024..5a51942 100644 --- a/bash/alias/chown.sh +++ b/bash/alias/chown.sh @@ -1,9 +1,11 @@ # change owner as root alias cor="\ -chown \"0:0\" \ +chown \ +\"0:0\" \ " # change owner as user alias cou="\ -chown \"1000:1000\" \ +chown \ +\"1000:1000\" \ " diff --git a/bash/alias/ps.sh b/bash/alias/ps.sh index 093944c..0e643ae 100644 --- a/bash/alias/ps.sh +++ b/bash/alias/ps.sh @@ -1,5 +1,7 @@ # look for a string in processes names alias pg="\ -ps -A \ -| grep \ +ps \ +-A \ +| \ +grep \ " From 8bc91cc00ba09bfd52746fd8291cbbfb780a911e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 18 May 2023 13:51:20 +0200 Subject: [PATCH 117/969] git/gmc,grm --- bash/alias/git.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/alias/git.sh b/bash/alias/git.sh index 14e5dfe..a639a75 100644 --- a/bash/alias/git.sh +++ b/bash/alias/git.sh @@ -269,7 +269,7 @@ alias gmc="\ git \ merge \ --no-ff \ --m \ +--message \ " # do a signed merge commit @@ -360,7 +360,7 @@ rebase \ --interactive \ " -# remove and add to index +# remove and add removal to index alias grm="\ git \ rm \ From d5e81ff9c3cebae8a7eabcca5771487bfa7c6053 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 18 May 2023 14:19:29 +0200 Subject: [PATCH 118/969] otp --- bash/alias/otpclient-cli.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bash/alias/otpclient-cli.sh b/bash/alias/otpclient-cli.sh index be14c50..4fbe9cd 100644 --- a/bash/alias/otpclient-cli.sh +++ b/bash/alias/otpclient-cli.sh @@ -1,12 +1,12 @@ +# list otp accounts +alias otpl="\ +otpclient-cli \ +list \ +" + # display otp code -alias pd="\ +alias otps="\ otpclient-cli \ show \ -a \ " - -# list otp accounts -alias pl="\ -otpclient-cli \ -list \ -" From 66b925e0a228f023ee97523d26987c32b18426d2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 18 May 2023 14:29:49 +0200 Subject: [PATCH 119/969] pwgen/pwg,pwgs --- bash/alias/pwgen.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 bash/alias/pwgen.sh diff --git a/bash/alias/pwgen.sh b/bash/alias/pwgen.sh new file mode 100644 index 0000000..c462028 --- /dev/null +++ b/bash/alias/pwgen.sh @@ -0,0 +1,16 @@ +# generate passwords +alias pwg="\ +pwgen \ +-1 \ +--num-passwords 1048576 \ +--secure \ +" + +# generate passwords with symbols +alias pwgs="\ +pwgen \ +-1 \ +--num-passwords 1048576 \ +--secure \ +--symbols \ +" From 755e93887640035bf34a93ce87ff6ff315ea5a83 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 18 May 2023 14:48:29 +0200 Subject: [PATCH 120/969] =?UTF-8?q?=C2=B5,n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash/alias/micro.sh | 2 +- bash/alias/nano.sh | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 bash/alias/nano.sh diff --git a/bash/alias/micro.sh b/bash/alias/micro.sh index 97d7174..05102a2 100644 --- a/bash/alias/micro.sh +++ b/bash/alias/micro.sh @@ -1,3 +1,3 @@ -alias e="\ +alias µ="\ micro \ " diff --git a/bash/alias/nano.sh b/bash/alias/nano.sh new file mode 100644 index 0000000..37bd342 --- /dev/null +++ b/bash/alias/nano.sh @@ -0,0 +1,3 @@ +alias n="\ +nano \ +" From 275b8bdf2c4789fac4074bd9c68442d6fb4afe26 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 19 May 2023 20:14:13 +0200 Subject: [PATCH 121/969] hostname --- bash/ovh-rescue.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index bfe0bf2..bcd66c4 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -1,4 +1,5 @@ function ovh-rescue-configure { +local host="${1}" local packages=( 'byobu' 'mosh' ) @@ -24,7 +25,7 @@ deb https://deb.debian.org/debian-security buster/updates main contrib non-free # bash / rc main_link_bashrc # host name - hostname 'ovh' + hostname "${host}" # locales echo -n "\ en_US.UTF-8 UTF-8 @@ -100,7 +101,7 @@ if [ "${host}" ] ; then rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" # call setup # TODO variable - ssh "${user_host}" -- "source '/etc/bash/main.sh' ; ovh-rescue-configure" + ssh "${user_host}" -- "source '/etc/bash/main.sh' ; ovh-rescue-configure '${host}'" # create session ssh "${user_host}" -- byobu new-session -d # send keys From 6455d789aadd222e59dc1412807ad30e1daf204a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 20 May 2023 09:18:21 +0200 Subject: [PATCH 122/969] ... --- bash/alias/bash.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bash/alias/bash.sh b/bash/alias/bash.sh index 65a7bda..40500cc 100644 --- a/bash/alias/bash.sh +++ b/bash/alias/bash.sh @@ -4,6 +4,12 @@ cd \ .. \ " +# change current directory to its parent's parent +alias ...="\ +cd \ +../.. \ +" + # swap directory (current ↔ previous) alias sd="\ cd \ From 25a8c2f30b4af99db7c087e5e7468a340c04921f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Jun 2023 15:08:06 +0200 Subject: [PATCH 123/969] sort bash modules --- bash/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/main.sh b/bash/main.sh index ce04a8a..6a16fc5 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -17,7 +17,7 @@ if [ -f "${file}" ] ; then local path="$(realpath "${file}")" local root="$(dirname "${path}")" local IFS=$'\n' - local modules=($(find "${root}" -type 'f' -name '*.sh')) + local modules=($(find "${root}" -type 'f' -name '*.sh' | sort)) local module for module in "${modules[@]}" ; do if [ "${module}" != "${path}" ] ; then From 53a2299f3466bd2d8f31cd94eeeb6e96ccf81359 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Jun 2023 15:16:05 +0200 Subject: [PATCH 124/969] bash/main/import/exit --- bash/main.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bash/main.sh b/bash/main.sh index 6a16fc5..59788aa 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -25,8 +25,10 @@ if [ -f "${file}" ] ; then fi done log_trace "${modules[@]}" + return 0 else log_fatal "No file: ${file}" + return 1 fi } From 9ae52e134d6bf5508ab717053393ad3748d0e5da Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 1 Jul 2023 10:09:13 +0200 Subject: [PATCH 125/969] ignore pycache --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a09c56d..cd165df 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +__pycache__ /.idea From 7ffcea4b843d243db0f9a3f8f09aa3eb8caedc8e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 11 Jul 2023 09:09:33 +0200 Subject: [PATCH 126/969] mv --- nbdcs => cs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename nbdcs => cs (100%) diff --git a/nbdcs b/cs similarity index 100% rename from nbdcs rename to cs From 97f74cb623d4ba99d9dff7414561678be440aa02 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 11 Jul 2023 09:12:32 +0200 Subject: [PATCH 127/969] cs.old --- cs.old | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 cs.old diff --git a/cs.old b/cs.old new file mode 100755 index 0000000..8e8d088 --- /dev/null +++ b/cs.old @@ -0,0 +1,84 @@ +#! /usr/bin/env bash +FILE="$(realpath "${BASH_SOURCE[0]}")" +NAME="$(basename "${FILE}")" + +ACTION_OPEN='open' +ACTION_CLOSE='close' + +DATA_DIRECTORY='/data' +CONTAINERS_DIRECTORY="${DATA_DIRECTORY}/containers" + +CONTAINERS_MAP_DIRECTORY='/dev/mapper' +CONTAINERS_MOUNT_DIRECTORY='/media' + +function main { +local action="${1}" +local pass_phrase +local container +local container_name +local container_file +local container_map_file +local container_mount_directory + +case "${action}" in + "${ACTION_OPEN}"|"${ACTION_CLOSE}") + shift + if [ "${1}" ]; then + if [ "${action}" == "${ACTION_OPEN}" ]; then + echo -n 'PassPhrase: ' + read -s pass_phrase + echo + fi + for container in "${@}"; do + echo + case "${container}" in + 'p') container_name='private' ;; + 's') container_name='sensitive' ;; + 'w') container_name='work' ;; + *) container_name="${container}" ;; + esac + container_file="${CONTAINERS_DIRECTORY}/${container_name}" + if [ -f "${container_file}" ]; then + container_map_file="${CONTAINERS_MAP_DIRECTORY}/${container_name}" + container_mount_directory="${CONTAINERS_MOUNT_DIRECTORY}/${container_name}" + case "${action}" in + "${ACTION_OPEN}") + echo "${container_file} → ${container_map_file}" + echo "${pass_phrase}" \ + | cryptsetup luksOpen "${container_file}" "${container_name}" + if [ ${?} -eq 0 ]; then + mkdir --parents "${container_mount_directory}" + echo "${container_map_file} → ${container_mount_directory}" + mount "${container_map_file}" "${container_mount_directory}" + fi + ;; + "${ACTION_CLOSE}") + echo "${container_map_file} ← ${container_mount_directory}" + umount "${container_map_file}" + if [ ${?} -eq 0 ]; then + rmdir --ignore-fail-on-non-empty "${container_mount_directory}" + echo "${container_file} ← ${container_map_file}" + cryptsetup luksClose "${container_name}" + fi + ;; + esac + else + echo 'This path does not point to a file!' + fi + done + else + echo 'No container name provided!' + fi + ;; + *) + echo 'Usage:' + echo "${NAME} [${ACTION_OPEN}|${ACTION_CLOSE}] [p] [s] [w]" + echo + echo 'p = private' + echo 's = sensitive' + echo 'w = work' + ;; +esac +} + +main "${@}" From 9a867f54a1032c6a5ad19dce8b40f7b2fd648006 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 17 Jul 2023 19:57:19 +0200 Subject: [PATCH 128/969] ignore tmp --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index cd165df..87f9698 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__ +/tmp /.idea From 53e3d1bcaa735a9f187470aba7105feab7ad6157 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 17 Jul 2023 21:05:06 +0200 Subject: [PATCH 129/969] test --- __main__.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/__main__.py b/__main__.py index 6066054..a0ac1c5 100755 --- a/__main__.py +++ b/__main__.py @@ -1,5 +1,18 @@ #! /usr/bin/env python3 +import os + +import file + if __name__ == '__main__': - pass + file_path = os.path.realpath(__file__) + root_path = os.path.dirname(file_path) + directory_path = os.path.join(root_path, 'tmp') + file_path = os.path.join(directory_path, 'file') + + file.wipe(directory_path) + file.make(directory_path) + file.write(file_path, 'Martine écrit beaucoup.') + file.empty(file_path) + file.write(file_path, 'Martine écrit moins.') From cb48fd3e627d028966d772bd6d146e2cddc6d9d6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 17 Jul 2023 21:05:33 +0200 Subject: [PATCH 130/969] file --- file/__init__.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 file/__init__.py diff --git a/file/__init__.py b/file/__init__.py new file mode 100644 index 0000000..f622b10 --- /dev/null +++ b/file/__init__.py @@ -0,0 +1,35 @@ +import os +import shutil +import subprocess + +CHARSET = 'UTF-8' + + +def create_image(file_path: str, size_bytes: int): + subprocess.call([ + 'qemu-img', + 'create', + '-f', 'qcow2', + file_path, + size_bytes, + ]) + + +def empty(file_path: str): + write(file_path, str()) + + +def make(directory_path: str): + os.makedirs(directory_path, exist_ok=True) + + +def wipe(path: str): + try: + shutil.rmtree(path) + except NotADirectoryError: + os.remove(path) + + +def write(file_path: str, text: str, charset=CHARSET): + with open(file_path, 'bw') as file_object: + file_object.write(text.encode(charset)) From deb709d488b367ac8038cb68def291a347a650f2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 17 Jul 2023 23:07:42 +0200 Subject: [PATCH 131/969] wipe/run --- file/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/file/__init__.py b/file/__init__.py index f622b10..eaf0059 100644 --- a/file/__init__.py +++ b/file/__init__.py @@ -6,7 +6,7 @@ CHARSET = 'UTF-8' def create_image(file_path: str, size_bytes: int): - subprocess.call([ + subprocess.run([ 'qemu-img', 'create', '-f', 'qcow2', @@ -28,6 +28,8 @@ def wipe(path: str): shutil.rmtree(path) except NotADirectoryError: os.remove(path) + except FileNotFoundError: + pass def write(file_path: str, text: str, charset=CHARSET): From fb180e8084546de84c51e431153c880196955de7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 17 Jul 2023 23:07:47 +0200 Subject: [PATCH 132/969] deb --- deb.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 deb.py diff --git a/deb.py b/deb.py new file mode 100644 index 0000000..05e72f0 --- /dev/null +++ b/deb.py @@ -0,0 +1,17 @@ +import subprocess + +BOOTSTRAP_ARCHITECTURE = 'amd64' +BOOTSTRAP_VARIANT = 'minbase' + + +def bootstrap(root_path: str, suite: str, mirror_location: str): + command = [ + 'debootstrap', + '--arch', BOOTSTRAP_ARCHITECTURE, + '--variant', BOOTSTRAP_VARIANT, + suite, + root_path, + mirror_location, + ] + completed_process = subprocess.run(command, capture_output=True) + return completed_process From fde55c7c048f6ace89492e96c284994f9ccb977f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 19 Jul 2023 22:08:40 +0200 Subject: [PATCH 133/969] gpg agent if configuration --- bash/gpg.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bash/gpg.sh b/bash/gpg.sh index 8025b64..abea396 100644 --- a/bash/gpg.sh +++ b/bash/gpg.sh @@ -1,4 +1,6 @@ if [ ${EUID} -ne 0 ] ; then - export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" - gpg-connect-agent updatestartuptty /bye > '/dev/null' + if [ -f "${HOME}/.gnupg/gpg-agent.conf" ] ; then + export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" + gpg-connect-agent updatestartuptty /bye > '/dev/null' + fi fi From 52a93c61cc22b9f83c809ac7f71231bae33eed2b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 18 Aug 2023 21:14:34 +0200 Subject: [PATCH 134/969] bash/prompt --- bash/bash/prompt.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bash/bash/prompt.sh b/bash/bash/prompt.sh index 51b193c..2f08496 100644 --- a/bash/bash/prompt.sh +++ b/bash/bash/prompt.sh @@ -1,5 +1,5 @@ PS1="\ -┌ \t\ +└ \t\ – \e[0;31m\${?}\e[0m\ – \e[0;32m\u\e[0m\ @ \e[0;33m\h\e[0m\ @@ -8,8 +8,8 @@ if [ "$(type -t __git_ps1)" == 'function' ] ; then PS1="${PS1} –\e[0;35m\$(__git_ps1)\e[0m" fi PS1="${PS1} -│\e[0;36m\${PWD}\e[0m -└ " +\e[0;36m\${PWD}\e[0m +┌ " PS2="\ -└ " +│ " From 633f42b6c2b689dabb43d951d51d8795337ccd83 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 20 Aug 2023 13:55:12 +0200 Subject: [PATCH 135/969] bash/prompt --- bash/bash/prompt.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/bash/prompt.sh b/bash/bash/prompt.sh index 2f08496..b68611d 100644 --- a/bash/bash/prompt.sh +++ b/bash/bash/prompt.sh @@ -8,8 +8,8 @@ if [ "$(type -t __git_ps1)" == 'function' ] ; then PS1="${PS1} –\e[0;35m\$(__git_ps1)\e[0m" fi PS1="${PS1} -\e[0;36m\${PWD}\e[0m -┌ " +┌ \e[0;36m\${PWD}\e[0m +│ " PS2="\ │ " From 0b7e362582c8ca989960b2f0878d46c6489569f9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 20 Aug 2023 18:33:26 +0200 Subject: [PATCH 136/969] bash/ps1 --- bash/bash/prompt.sh | 46 ++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/bash/bash/prompt.sh b/bash/bash/prompt.sh index b68611d..a245867 100644 --- a/bash/bash/prompt.sh +++ b/bash/bash/prompt.sh @@ -1,15 +1,35 @@ -PS1="\ -└ \t\ - – \e[0;31m\${?}\e[0m\ - – \e[0;32m\u\e[0m\ - @ \e[0;33m\h\e[0m\ -" -if [ "$(type -t __git_ps1)" == 'function' ] ; then - PS1="${PS1} –\e[0;35m\$(__git_ps1)\e[0m" -fi -PS1="${PS1} -┌ \e[0;36m\${PWD}\e[0m -│ " - PS2="\ │ " + +function ps1 { +local code=${1} +local date="$(date +%H:%M:%S)" +local git +local host="$(hostname)" +local path="${PWD}" +local real="$(realpath "${path}")" +local user="${USER}" +local view="\ +└ ${date}\ + – \e[0;31m${code}\e[0m\ + – \e[0;32m${user}\e[0m\ + @ \e[0;33m${host}\e[0m\ +" + if [ "$(type -t __git_ps1)" == 'function' ] ; then + git="$(__git_ps1)" + if [ "${git}" ] ; then + view="${view} –\e[0;35m${git}\e[0m" + fi + fi + view="${view} +┌ " + if [ "${path}" != "${real}" ] ; then + view="${view}\e[0;36m${real}\e[0m +├ " + fi + view="${view}\e[0;36m${path}\e[0m +${PS2}" + echo -e "${view}" +} + +PS1='$(eval ps1 ${?})' From ffb301e21b95c5677401d9f79ef3e92130df7115 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 20 Aug 2023 18:39:36 +0200 Subject: [PATCH 137/969] bash/ps1/real --- bash/bash/prompt.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bash/bash/prompt.sh b/bash/bash/prompt.sh index a245867..70e8454 100644 --- a/bash/bash/prompt.sh +++ b/bash/bash/prompt.sh @@ -21,13 +21,12 @@ local view="\ view="${view} –\e[0;35m${git}\e[0m" fi fi - view="${view} -┌ " if [ "${path}" != "${real}" ] ; then - view="${view}\e[0;36m${real}\e[0m -├ " + view="${view} +\e[0;36m${real}\e[0m" fi - view="${view}\e[0;36m${path}\e[0m + view="${view} +┌ \e[0;36m${path}\e[0m ${PS2}" echo -e "${view}" } From 0db196a41cf600553a6bc128db285cb5991b5f53 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 20 Aug 2023 18:50:17 +0200 Subject: [PATCH 138/969] =?UTF-8?q?=E2=88=92real?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash/bash/prompt.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/bash/bash/prompt.sh b/bash/bash/prompt.sh index 70e8454..9e02873 100644 --- a/bash/bash/prompt.sh +++ b/bash/bash/prompt.sh @@ -7,7 +7,6 @@ local date="$(date +%H:%M:%S)" local git local host="$(hostname)" local path="${PWD}" -local real="$(realpath "${path}")" local user="${USER}" local view="\ └ ${date}\ @@ -21,10 +20,6 @@ local view="\ view="${view} –\e[0;35m${git}\e[0m" fi fi - if [ "${path}" != "${real}" ] ; then - view="${view} -\e[0;36m${real}\e[0m" - fi view="${view} ┌ \e[0;36m${path}\e[0m ${PS2}" From 8afbad6e4c4eb2b147fc4371ab1806ed3ef92ab9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 20 Aug 2023 19:41:54 +0200 Subject: [PATCH 139/969] bash/ps2 --- bash/bash/prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/bash/prompt.sh b/bash/bash/prompt.sh index 9e02873..9242a84 100644 --- a/bash/bash/prompt.sh +++ b/bash/bash/prompt.sh @@ -1,5 +1,5 @@ PS2="\ -│ " +├ " function ps1 { local code=${1} From e876f37b7d2269fe63dd457193427ac299894ace Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 21 Aug 2023 11:43:50 +0200 Subject: [PATCH 140/969] bash/prompt/enhance --- bash/bash/prompt.sh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/bash/bash/prompt.sh b/bash/bash/prompt.sh index 9242a84..d9361b0 100644 --- a/bash/bash/prompt.sh +++ b/bash/bash/prompt.sh @@ -8,22 +8,28 @@ local git local host="$(hostname)" local path="${PWD}" local user="${USER}" -local view="\ -└ ${date}\ - – \e[0;31m${code}\e[0m\ - – \e[0;32m${user}\e[0m\ - @ \e[0;33m${host}\e[0m\ -" +local view="└ " + if [ ${code} -ne 0 ] ; then + view="${view}\e[0;31m" + else + view="${view}\e[0;32m" + fi + view="${view}${code}\e[0m @ \e[0;33m${date}\e[0m" if [ "$(type -t __git_ps1)" == 'function' ] ; then git="$(__git_ps1)" if [ "${git}" ] ; then view="${view} –\e[0;35m${git}\e[0m" fi fi - view="${view} -┌ \e[0;36m${path}\e[0m -${PS2}" - echo -e "${view}" + view="${view}\n \e[0;36m${path}\e[0m" + view="${view}\n┌ " + if [ ${EUID} -eq 0 ] ; then + view="${view}\e[0;31m" + else + view="${view}\e[0;32m" + fi + view="${view}${user}\e[0m @ \e[0;33m${host}\e[0m" + echo -e "${view}\n${PS2}" } PS1='$(eval ps1 ${?})' From 0b960f7fba9ce2f5820bc383b4c278979d6b5e93 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 21 Aug 2023 11:46:21 +0200 Subject: [PATCH 141/969] space --- bash/bash/prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/bash/prompt.sh b/bash/bash/prompt.sh index d9361b0..da8a978 100644 --- a/bash/bash/prompt.sh +++ b/bash/bash/prompt.sh @@ -21,7 +21,7 @@ local view="└ " view="${view} –\e[0;35m${git}\e[0m" fi fi - view="${view}\n \e[0;36m${path}\e[0m" + view="${view}\n\e[0;36m${path}\e[0m" view="${view}\n┌ " if [ ${EUID} -eq 0 ] ; then view="${view}\e[0;31m" From 003d02f226ea41eb845d86902cba5c6714e45265 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 21 Aug 2023 14:32:38 +0200 Subject: [PATCH 142/969] gsettings/ws --- bash/gsettings.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 bash/gsettings.sh diff --git a/bash/gsettings.sh b/bash/gsettings.sh new file mode 100644 index 0000000..1fd3b72 --- /dev/null +++ b/bash/gsettings.sh @@ -0,0 +1,12 @@ +function ws { +local boolean="${1}" + if [ "${boolean}" == '1' ] ; then + boolean='true' + else + boolean='false' + fi + gsettings 'set' \ + 'org.gnome.mutter' \ + 'workspaces-only-on-primary' \ + "${boolean}" +} From 0daec8e9d410b5530d212f1149b58bbad6b06fab Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 28 Aug 2023 12:41:27 +0200 Subject: [PATCH 143/969] gpg/gak,gau --- bash/alias/gpg.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/alias/gpg.sh b/bash/alias/gpg.sh index 80705c5..549c34e 100644 --- a/bash/alias/gpg.sh +++ b/bash/alias/gpg.sh @@ -1,11 +1,11 @@ # turn gpg agent off -alias gpgoff="\ +alias gak="\ gpgconf \ --kill \"gpg-agent\" \ " # bind gpg agent to current tty -alias gpgtty="\ +alias gau="\ gpg-connect-agent \ updatestartuptty \ /bye \ From 90b5440f138c0d9281e5a47af00e975decc7522d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 17:30:04 +0200 Subject: [PATCH 144/969] hetzner/cp --- bash/hetzner-rescue.sh | 179 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 bash/hetzner-rescue.sh diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh new file mode 100644 index 0000000..bcd66c4 --- /dev/null +++ b/bash/hetzner-rescue.sh @@ -0,0 +1,179 @@ +function ovh-rescue-configure { +local host="${1}" + local packages=( + 'byobu' 'mosh' + ) + # apt / conf + echo -n "\ +Acquire::AllowInsecureRepositories False; +Acquire::AllowWeakRepositories False; +Acquire::AllowDowngradeToInsecureRepositories False; +Acquire::Check-Valid-Until True; +APT::Install-Recommends False; +APT::Install-Suggests False; +APT::Get::Show-Versions True; +Dir::Etc::SourceParts ''; +Dpkg::Progress True; +" > '/etc/apt/apt.conf' + # apt / sources + echo -n "\ +deb https://deb.debian.org/debian buster main contrib non-free +deb https://deb.debian.org/debian buster-backports main contrib non-free +deb https://deb.debian.org/debian buster-updates main contrib non-free +deb https://deb.debian.org/debian-security buster/updates main contrib non-free +" > '/etc/apt/sources.list' + # bash / rc + main_link_bashrc + # host name + hostname "${host}" + # locales + echo -n "\ +en_US.UTF-8 UTF-8 +fr_FR.UTF-8 UTF-8 +" > '/etc/locale.gen' + # fix alias + rm --force '/usr/share/locale/locale.alias' + ln --symbolic '/etc/locale.alias' '/usr/share/locale/locale.alias' + # generate locales + locale-gen + # update catalog + apt-get update + # + debian_disable_frontend + # install packages + apt-get install --assume-yes "${packages[@]}" + # + apt_clean_cache +} + +function ovh-rescue-install { + local release='buster' + local packages=( + # installed + 'parted' 'mdadm' 'lvm2' + # install + 'lshw' + 'file' 'micro' + 'grub-efi-amd64-bin' 'grub-pc-bin' + 'htop' 'iotop' 'lsof' + 'exa' 'ncdu' 'nnn' 'ranger' 'tree' + 'squashfs-tools' + 'uuid-runtime' + ) + local backports=( + # installed + 'cryptsetup-bin' 'rsync' + # install + 'git' + ) + # update catalog + apt-get update + # + debian_disable_frontend + # upgrade packages + apt-get upgrade --assume-yes + # + apt_clean_cache + # install packages + apt-get install --assume-yes "${packages[@]}" + # + apt_clean_cache + # install backports + apt-get install --assume-yes \ + --target-release "${release}-backports" "${backports[@]}" + # + apt_clean_cache +} + +function ovh-rescue-upload { +local host="${1}" +if [ "${host}" ] ; then + local user='root' + # + local user_host="${user}@${host}" + # remove fingerprints + ssh-keygen -R "${host}" + # copy ssh id + ssh-copy-id \ + -o 'StrictHostKeyChecking=accept-new' \ + "${user_host}" + # upload root + rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" + # call setup + # TODO variable + ssh "${user_host}" -- "source '/etc/bash/main.sh' ; ovh-rescue-configure '${host}'" + # create session + ssh "${user_host}" -- byobu new-session -d + # send keys + ssh "${user_host}" -- byobu send-keys 'ovh-rescue-install' 'C-m' + # attach session + mosh "${user_host}" -- byobu attach-session +else + echo 'Host?' + return 1 +fi +} + +function ovh-rescue-wipe-1-2TB { + local device='/dev/sda' + local unit='mib' + # + lsblk + echo -n 'WIPE' "${device}" '/?\ OR CANCEL /!\' + read + # + parted "${device}" --script mktable gpt + # + parted "${device}" unit "${unit}" mkpart 'crypt' 65795 1907729 + # + parted "${device}" unit "${unit}" mkpart 'boot' 259 65795 + # + parted "${device}" unit "${unit}" mkpart 'esp' 2 259 + parted "${device}" set 3 esp on + # + parted "${device}" unit "${unit}" mkpart bios 1 2 + parted "${device}" set 4 bios_grub on + # wipe bios + dd if='/dev/zero' of='/dev/sda4' + # format esp + mkfs.vfat -F 32 -n 'esp' '/dev/sda3' + # format boot + mkfs.ext4 -F -L 'boot' '/dev/sda2' + # read passphrase + local passphrase + echo -n 'PassPhrase: ' + read -r -s passphrase + # encrypt + echo "${passphrase}" \ + | cryptsetup \ + --verbose \ + --batch-mode \ + --type 'luks2' \ + --pbkdf 'argon2id' \ + --cipher 'aes-xts-plain64' \ + --iter-time 8192 \ + --key-size 512 \ + --hash 'sha512' \ + --use-random \ + luksFormat \ + '/dev/sda1' + # open + echo "${passphrase}" \ + | cryptsetup luksOpen '/dev/sda1' 'crypt' + # pv + pvcreate '/dev/mapper/crypt' + # vg + vgcreate 'crypt' '/dev/mapper/crypt' + # lv swap + lvcreate --name 'swap' --size '68719476736b' 'crypt' + # lv data + lvcreate --name 'data' --extents '100%FREE' 'crypt' + # format swap + mkswap --label 'swap' '/dev/mapper/crypt-swap' + # format data + mkfs.ext4 -L 'data' '/dev/mapper/crypt-data' + # vg off + vgchange --activate n 'crypt' + # close + cryptsetup luksClose 'crypt' +} From 0e8ea7af97d7caeb8e82d06054aa1d284652da08 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 18:16:32 +0200 Subject: [PATCH 145/969] hetzner/function --- bash/hetzner-rescue.sh | 74 +++--------------------------------------- 1 file changed, 5 insertions(+), 69 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index bcd66c4..24fc8c4 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -1,4 +1,4 @@ -function ovh-rescue-configure { +function hetzner-rescue-configure { local host="${1}" local packages=( 'byobu' 'mosh' @@ -46,7 +46,7 @@ fr_FR.UTF-8 UTF-8 apt_clean_cache } -function ovh-rescue-install { +function hetzner-rescue-install { local release='buster' local packages=( # installed @@ -85,7 +85,7 @@ function ovh-rescue-install { apt_clean_cache } -function ovh-rescue-upload { +function hetzner-rescue-upload { local host="${1}" if [ "${host}" ] ; then local user='root' @@ -101,11 +101,11 @@ if [ "${host}" ] ; then rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" # call setup # TODO variable - ssh "${user_host}" -- "source '/etc/bash/main.sh' ; ovh-rescue-configure '${host}'" + ssh "${user_host}" -- "source '/etc/bash/main.sh' ; hetzner-rescue-configure '${host}'" # create session ssh "${user_host}" -- byobu new-session -d # send keys - ssh "${user_host}" -- byobu send-keys 'ovh-rescue-install' 'C-m' + ssh "${user_host}" -- byobu send-keys 'hetzner-rescue-install' 'C-m' # attach session mosh "${user_host}" -- byobu attach-session else @@ -113,67 +113,3 @@ else return 1 fi } - -function ovh-rescue-wipe-1-2TB { - local device='/dev/sda' - local unit='mib' - # - lsblk - echo -n 'WIPE' "${device}" '/?\ OR CANCEL /!\' - read - # - parted "${device}" --script mktable gpt - # - parted "${device}" unit "${unit}" mkpart 'crypt' 65795 1907729 - # - parted "${device}" unit "${unit}" mkpart 'boot' 259 65795 - # - parted "${device}" unit "${unit}" mkpart 'esp' 2 259 - parted "${device}" set 3 esp on - # - parted "${device}" unit "${unit}" mkpart bios 1 2 - parted "${device}" set 4 bios_grub on - # wipe bios - dd if='/dev/zero' of='/dev/sda4' - # format esp - mkfs.vfat -F 32 -n 'esp' '/dev/sda3' - # format boot - mkfs.ext4 -F -L 'boot' '/dev/sda2' - # read passphrase - local passphrase - echo -n 'PassPhrase: ' - read -r -s passphrase - # encrypt - echo "${passphrase}" \ - | cryptsetup \ - --verbose \ - --batch-mode \ - --type 'luks2' \ - --pbkdf 'argon2id' \ - --cipher 'aes-xts-plain64' \ - --iter-time 8192 \ - --key-size 512 \ - --hash 'sha512' \ - --use-random \ - luksFormat \ - '/dev/sda1' - # open - echo "${passphrase}" \ - | cryptsetup luksOpen '/dev/sda1' 'crypt' - # pv - pvcreate '/dev/mapper/crypt' - # vg - vgcreate 'crypt' '/dev/mapper/crypt' - # lv swap - lvcreate --name 'swap' --size '68719476736b' 'crypt' - # lv data - lvcreate --name 'data' --extents '100%FREE' 'crypt' - # format swap - mkswap --label 'swap' '/dev/mapper/crypt-swap' - # format data - mkfs.ext4 -L 'data' '/dev/mapper/crypt-data' - # vg off - vgchange --activate n 'crypt' - # close - cryptsetup luksClose 'crypt' -} From dee85aab3beb130c249f1378c241f0c3f0e96b79 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 18:28:25 +0200 Subject: [PATCH 146/969] hetzner/bookworm --- bash/hetzner-rescue.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 24fc8c4..683388a 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -17,10 +17,10 @@ Dpkg::Progress True; " > '/etc/apt/apt.conf' # apt / sources echo -n "\ -deb https://deb.debian.org/debian buster main contrib non-free -deb https://deb.debian.org/debian buster-backports main contrib non-free -deb https://deb.debian.org/debian buster-updates main contrib non-free -deb https://deb.debian.org/debian-security buster/updates main contrib non-free +deb https://deb.debian.org/debian bookworm main non-free-firmware contrib non-free +deb https://deb.debian.org/debian bookworm-backports main non-free-firmware contrib non-free +deb https://deb.debian.org/debian bookworm-updates main non-free-firmware contrib non-free +deb https://deb.debian.org/debian-security bookworm-security main non-free-firmware contrib non-free " > '/etc/apt/sources.list' # bash / rc main_link_bashrc From dcf52827211b20885a9fc4385b24c58e011a2dac Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 18:35:16 +0200 Subject: [PATCH 147/969] =?UTF-8?q?=E2=88=92fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash/hetzner-rescue.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 683388a..e140193 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -31,9 +31,6 @@ deb https://deb.debian.org/debian-security bookworm-security main non-free-firmw en_US.UTF-8 UTF-8 fr_FR.UTF-8 UTF-8 " > '/etc/locale.gen' - # fix alias - rm --force '/usr/share/locale/locale.alias' - ln --symbolic '/etc/locale.alias' '/usr/share/locale/locale.alias' # generate locales locale-gen # update catalog From 9b873d35f211422b8d910a12623a2c29ff8d99fb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 18:42:39 +0200 Subject: [PATCH 148/969] hetzner/bookworm --- bash/hetzner-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index e140193..1e16562 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -44,7 +44,7 @@ fr_FR.UTF-8 UTF-8 } function hetzner-rescue-install { - local release='buster' + local release='bookworm' local packages=( # installed 'parted' 'mdadm' 'lvm2' From 6cf84b81b3a48cc8c10303a80d48e4da103238f7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 18:44:13 +0200 Subject: [PATCH 149/969] file --- bash/hetzner-rescue.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 1e16562..a2f6577 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -47,10 +47,10 @@ function hetzner-rescue-install { local release='bookworm' local packages=( # installed - 'parted' 'mdadm' 'lvm2' + 'file' 'parted' 'mdadm' 'lvm2' # install 'lshw' - 'file' 'micro' + 'micro' 'grub-efi-amd64-bin' 'grub-pc-bin' 'htop' 'iotop' 'lsof' 'exa' 'ncdu' 'nnn' 'ranger' 'tree' From 4415132cfd65d4bd7fbe5f2f00176aaaa3cea071 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 18:45:30 +0200 Subject: [PATCH 150/969] htop --- bash/hetzner-rescue.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index a2f6577..5a2a9ba 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -47,12 +47,12 @@ function hetzner-rescue-install { local release='bookworm' local packages=( # installed - 'file' 'parted' 'mdadm' 'lvm2' + 'file' 'htop' 'parted' 'mdadm' 'lvm2' # install 'lshw' 'micro' 'grub-efi-amd64-bin' 'grub-pc-bin' - 'htop' 'iotop' 'lsof' + 'iotop' 'lsof' 'exa' 'ncdu' 'nnn' 'ranger' 'tree' 'squashfs-tools' 'uuid-runtime' From 8013de8704c05aacaf6b6d4b7e5d9244015c43d3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 18:46:35 +0200 Subject: [PATCH 151/969] lsof --- bash/hetzner-rescue.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 5a2a9ba..f4b9c30 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -47,12 +47,12 @@ function hetzner-rescue-install { local release='bookworm' local packages=( # installed - 'file' 'htop' 'parted' 'mdadm' 'lvm2' + 'file' 'htop' 'lsof' 'parted' 'mdadm' 'lvm2' # install 'lshw' 'micro' 'grub-efi-amd64-bin' 'grub-pc-bin' - 'iotop' 'lsof' + 'iotop' 'exa' 'ncdu' 'nnn' 'ranger' 'tree' 'squashfs-tools' 'uuid-runtime' From 76e8b3af28bf85773aa00875e9bfabad54031474 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 18:49:10 +0200 Subject: [PATCH 152/969] tree --- bash/hetzner-rescue.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index f4b9c30..d5a177a 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -47,13 +47,13 @@ function hetzner-rescue-install { local release='bookworm' local packages=( # installed - 'file' 'htop' 'lsof' 'parted' 'mdadm' 'lvm2' + 'file' 'htop' 'lsof' 'parted' 'mdadm' 'lvm2' 'tree' # install 'lshw' 'micro' 'grub-efi-amd64-bin' 'grub-pc-bin' 'iotop' - 'exa' 'ncdu' 'nnn' 'ranger' 'tree' + 'exa' 'ncdu' 'nnn' 'ranger' 'squashfs-tools' 'uuid-runtime' ) From 5243263397884d7244d617f11de29106b92cf0ed Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 18:49:48 +0200 Subject: [PATCH 153/969] lf --- bash/hetzner-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index d5a177a..9e6dfd6 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -53,7 +53,7 @@ function hetzner-rescue-install { 'micro' 'grub-efi-amd64-bin' 'grub-pc-bin' 'iotop' - 'exa' 'ncdu' 'nnn' 'ranger' + 'exa' 'lf' 'ncdu' 'nnn' 'ranger' 'squashfs-tools' 'uuid-runtime' ) From 3c0a7530490c936f055a320f8b5873f4e50aa99b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 18:51:36 +0200 Subject: [PATCH 154/969] uuid-runtime --- bash/hetzner-rescue.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 9e6dfd6..58d170e 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -47,7 +47,7 @@ function hetzner-rescue-install { local release='bookworm' local packages=( # installed - 'file' 'htop' 'lsof' 'parted' 'mdadm' 'lvm2' 'tree' + 'file' 'htop' 'lsof' 'parted' 'mdadm' 'lvm2' 'tree' 'uuid-runtime' # install 'lshw' 'micro' @@ -55,7 +55,6 @@ function hetzner-rescue-install { 'iotop' 'exa' 'lf' 'ncdu' 'nnn' 'ranger' 'squashfs-tools' - 'uuid-runtime' ) local backports=( # installed From ad4b5f7e6c6efc516486b1b72f1a09ee9e785d08 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 18:53:11 +0200 Subject: [PATCH 155/969] cryptsetup-bin --- bash/hetzner-rescue.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 58d170e..24aaa36 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -47,6 +47,7 @@ function hetzner-rescue-install { local release='bookworm' local packages=( # installed + 'cryptsetup-bin' 'file' 'htop' 'lsof' 'parted' 'mdadm' 'lvm2' 'tree' 'uuid-runtime' # install 'lshw' @@ -58,7 +59,7 @@ function hetzner-rescue-install { ) local backports=( # installed - 'cryptsetup-bin' 'rsync' + 'rsync' # install 'git' ) From b6b923e1dda4283a5be6a79bc4a041da60de6330 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 18:54:34 +0200 Subject: [PATCH 156/969] rsync --- bash/hetzner-rescue.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 24aaa36..d7b9c71 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -47,7 +47,7 @@ function hetzner-rescue-install { local release='bookworm' local packages=( # installed - 'cryptsetup-bin' + 'cryptsetup-bin' 'rsync' 'file' 'htop' 'lsof' 'parted' 'mdadm' 'lvm2' 'tree' 'uuid-runtime' # install 'lshw' @@ -58,8 +58,6 @@ function hetzner-rescue-install { 'squashfs-tools' ) local backports=( - # installed - 'rsync' # install 'git' ) From 67580388fa40263f34f62683040bd85473acb3a1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 18:58:03 +0200 Subject: [PATCH 157/969] git --- bash/hetzner-rescue.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index d7b9c71..fc8e643 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -47,7 +47,8 @@ function hetzner-rescue-install { local release='bookworm' local packages=( # installed - 'cryptsetup-bin' 'rsync' + 'cryptsetup-bin' + 'git' 'rsync' 'file' 'htop' 'lsof' 'parted' 'mdadm' 'lvm2' 'tree' 'uuid-runtime' # install 'lshw' @@ -58,8 +59,6 @@ function hetzner-rescue-install { 'squashfs-tools' ) local backports=( - # install - 'git' ) # update catalog apt-get update From 237953e785f56c1c42bd9a43344270b427b08b1d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 19:05:58 +0200 Subject: [PATCH 158/969] btrfs-progs --- bash/hetzner-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index fc8e643..cc32c42 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -47,7 +47,7 @@ function hetzner-rescue-install { local release='bookworm' local packages=( # installed - 'cryptsetup-bin' + 'btrfs-progs' 'cryptsetup-bin' 'git' 'rsync' 'file' 'htop' 'lsof' 'parted' 'mdadm' 'lvm2' 'tree' 'uuid-runtime' # install From 3ff07ed4612787ac448c27230c761b1cb2cf2f60 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 19:11:39 +0200 Subject: [PATCH 159/969] dosfstools --- bash/hetzner-rescue.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index cc32c42..5feda34 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -47,7 +47,8 @@ function hetzner-rescue-install { local release='bookworm' local packages=( # installed - 'btrfs-progs' 'cryptsetup-bin' + 'cryptsetup-bin' + 'btrfs-progs' 'dosfstools' 'git' 'rsync' 'file' 'htop' 'lsof' 'parted' 'mdadm' 'lvm2' 'tree' 'uuid-runtime' # install From e69255533424184088e608e3397141b9f9a1f665 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 19:13:23 +0200 Subject: [PATCH 160/969] sha3 --- bash/hetzner-rescue.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 5feda34..a583197 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -54,6 +54,7 @@ function hetzner-rescue-install { # install 'lshw' 'micro' + 'libdigest-sha3-perl' 'grub-efi-amd64-bin' 'grub-pc-bin' 'iotop' 'exa' 'lf' 'ncdu' 'nnn' 'ranger' From e458a78afe8e58f5b5fcd4d7d3eb246c084bfb7d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 19:32:50 +0200 Subject: [PATCH 161/969] package --- bash/hetzner-rescue.sh | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index a583197..3543a21 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -1,5 +1,6 @@ function hetzner-rescue-configure { local host="${1}" + local package local packages=( 'byobu' 'mosh' ) @@ -38,12 +39,16 @@ fr_FR.UTF-8 UTF-8 # debian_disable_frontend # install packages - apt-get install --assume-yes "${packages[@]}" - # - apt_clean_cache + for package in "${packages[@]}" ; do + apt-get install \ + --assume-yes \ + "${package}" + apt_clean_cache + done } function hetzner-rescue-install { + local package local release='bookworm' local packages=( # installed @@ -71,14 +76,20 @@ function hetzner-rescue-install { # apt_clean_cache # install packages - apt-get install --assume-yes "${packages[@]}" - # - apt_clean_cache + for package in "${packages[@]}" ; do + apt-get install \ + --assume-yes \ + "${package}" + apt_clean_cache + done # install backports - apt-get install --assume-yes \ - --target-release "${release}-backports" "${backports[@]}" - # - apt_clean_cache + for package in "${backports[@]}" ; do + apt-get install \ + --assume-yes \ + --target-release "${release}-backports" \ + "${package}" + apt_clean_cache + done } function hetzner-rescue-upload { From 23c14ff9667916d3a4081cc3ba132c80c1b48b18 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 19:35:18 +0200 Subject: [PATCH 162/969] apt-file --- bash/hetzner-rescue.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 3543a21..36f24b7 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -2,7 +2,7 @@ function hetzner-rescue-configure { local host="${1}" local package local packages=( - 'byobu' 'mosh' + 'mosh' 'byobu' 'apt-file' ) # apt / conf echo -n "\ @@ -45,6 +45,8 @@ fr_FR.UTF-8 UTF-8 "${package}" apt_clean_cache done + # update catalog + apt-get update } function hetzner-rescue-install { From 7a2d2e3f7e91ace57a8194db945f2c078906449c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 19:39:41 +0200 Subject: [PATCH 163/969] echo --- bash/hetzner-rescue.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 36f24b7..1139eb4 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -40,6 +40,7 @@ fr_FR.UTF-8 UTF-8 debian_disable_frontend # install packages for package in "${packages[@]}" ; do + echo ; echo "${package}" apt-get install \ --assume-yes \ "${package}" @@ -79,6 +80,7 @@ function hetzner-rescue-install { apt_clean_cache # install packages for package in "${packages[@]}" ; do + echo ; echo "${package}" apt-get install \ --assume-yes \ "${package}" @@ -86,6 +88,7 @@ function hetzner-rescue-install { done # install backports for package in "${backports[@]}" ; do + echo ; echo "${package}" apt-get install \ --assume-yes \ --target-release "${release}-backports" \ From ab50c39bbbcba42c28d0c1fd906c3a1a233e9430 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 19:45:03 +0200 Subject: [PATCH 164/969] installed --- bash/hetzner-rescue.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 1139eb4..a61b1e1 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -55,10 +55,10 @@ function hetzner-rescue-install { local release='bookworm' local packages=( # installed - 'cryptsetup-bin' + 'parted' 'mdadm' 'cryptsetup-bin' 'lvm2' 'btrfs-progs' 'dosfstools' 'git' 'rsync' - 'file' 'htop' 'lsof' 'parted' 'mdadm' 'lvm2' 'tree' 'uuid-runtime' + 'file' 'htop' 'lsof' 'tree' 'uuid-runtime' # install 'lshw' 'micro' From 7fe64724c2c5f39e862db1a547c7dec7509c149b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 19:46:19 +0200 Subject: [PATCH 165/969] nano,vim --- bash/hetzner-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index a61b1e1..19ffdc4 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -57,7 +57,7 @@ function hetzner-rescue-install { # installed 'parted' 'mdadm' 'cryptsetup-bin' 'lvm2' 'btrfs-progs' 'dosfstools' - 'git' 'rsync' + 'git' 'nano' 'rsync' 'vim' 'file' 'htop' 'lsof' 'tree' 'uuid-runtime' # install 'lshw' From f6c861e0d9873792cc88feb8e712e24d9356cba5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 19:50:29 +0200 Subject: [PATCH 166/969] install --- bash/hetzner-rescue.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 19ffdc4..64845df 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -61,12 +61,10 @@ function hetzner-rescue-install { 'file' 'htop' 'lsof' 'tree' 'uuid-runtime' # install 'lshw' - 'micro' - 'libdigest-sha3-perl' - 'grub-efi-amd64-bin' 'grub-pc-bin' - 'iotop' - 'exa' 'lf' 'ncdu' 'nnn' 'ranger' 'squashfs-tools' + 'grub-efi-amd64-bin' 'grub-pc-bin' + 'libdigest-sha3-perl' 'micro' + 'exa' 'iotop' 'lf' 'ncdu' 'nnn' 'ranger' ) local backports=( ) From 34640e91832a345f57632d8da9639046515c74ae Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 19:51:47 +0200 Subject: [PATCH 167/969] py3 --- bash/hetzner-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 64845df..8246edf 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -57,7 +57,7 @@ function hetzner-rescue-install { # installed 'parted' 'mdadm' 'cryptsetup-bin' 'lvm2' 'btrfs-progs' 'dosfstools' - 'git' 'nano' 'rsync' 'vim' + 'git' 'nano' 'python3' 'rsync' 'vim' 'file' 'htop' 'lsof' 'tree' 'uuid-runtime' # install 'lshw' From 8dbf6952332a9b8db5187f0def23bb75779db59d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 21:03:30 +0200 Subject: [PATCH 168/969] installed --- bash/hetzner-rescue.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 8246edf..ffc7d96 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -55,10 +55,11 @@ function hetzner-rescue-install { local release='bookworm' local packages=( # installed + 'dmidecode' 'efibootmgr' 'pciutils' 'usbutils' 'parted' 'mdadm' 'cryptsetup-bin' 'lvm2' 'btrfs-progs' 'dosfstools' 'git' 'nano' 'python3' 'rsync' 'vim' - 'file' 'htop' 'lsof' 'tree' 'uuid-runtime' + 'file' 'htop' 'lsof' 'man-db' 'tree' 'uuid-runtime' # install 'lshw' 'squashfs-tools' From 2fde68b230804dd2f0a23466a27e5283c58fb08f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 21:06:25 +0200 Subject: [PATCH 169/969] screen,tmux --- bash/hetzner-rescue.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index ffc7d96..62329ac 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -2,7 +2,9 @@ function hetzner-rescue-configure { local host="${1}" local package local packages=( - 'mosh' 'byobu' 'apt-file' + 'mosh' + 'screen' 'tmux' 'byobu' + 'apt-file' ) # apt / conf echo -n "\ From 0606d172938d5303e6e579d202794e13450c3b40 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 21:07:51 +0200 Subject: [PATCH 170/969] ipcalc --- bash/hetzner-rescue.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 62329ac..df0c553 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -67,7 +67,8 @@ function hetzner-rescue-install { 'squashfs-tools' 'grub-efi-amd64-bin' 'grub-pc-bin' 'libdigest-sha3-perl' 'micro' - 'exa' 'iotop' 'lf' 'ncdu' 'nnn' 'ranger' + 'iotop' + 'exa' 'ipcalc' 'lf' 'ncdu' 'nnn' 'ranger' ) local backports=( ) From 34ead4eb5dd11b4a26c59de5dd979f7c4861e8fc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Oct 2023 21:19:27 +0200 Subject: [PATCH 171/969] .bashrc --- bash/hetzner-rescue.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index df0c553..5b30618 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -27,6 +27,7 @@ deb https://deb.debian.org/debian-security bookworm-security main non-free-firmw " > '/etc/apt/sources.list' # bash / rc main_link_bashrc + mv .bashrc .bashrc.old # host name hostname "${host}" # locales From 63b62a6f09a9150eedbd3a5dbee8987b7b8e4c61 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 04:18:00 +0200 Subject: [PATCH 172/969] wipe --- bash/hetzner-rescue.sh | 64 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 5b30618..7c378df 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -128,3 +128,67 @@ else return 1 fi } + +function hetzner-rescue-wipe-12-10-10 { + local device='/dev/sda' + local unit='mib' + # + lsblk + echo -n 'WIPE' "${device}" '/?\ OR CANCEL /!\' + read + # + parted "${device}" --script mktable gpt + # + parted "${device}" unit "${unit}" mkpart 'crypt' 65795 1907729 + # + parted "${device}" unit "${unit}" mkpart 'boot' 259 65795 + # + parted "${device}" unit "${unit}" mkpart 'esp' 2 259 + parted "${device}" set 3 esp on + # + parted "${device}" unit "${unit}" mkpart bios 1 2 + parted "${device}" set 4 bios_grub on + # wipe bios + dd if='/dev/zero' of='/dev/sda4' + # format esp + mkfs.vfat -F 32 -n 'esp' '/dev/sda3' + # format boot + mkfs.ext4 -F -L 'boot' '/dev/sda2' + # read passphrase + local passphrase + echo -n 'PassPhrase: ' + read -r -s passphrase + # encrypt + echo "${passphrase}" \ + | cryptsetup \ + --verbose \ + --batch-mode \ + --type 'luks2' \ + --pbkdf 'argon2id' \ + --cipher 'aes-xts-plain64' \ + --iter-time 8192 \ + --key-size 512 \ + --hash 'sha512' \ + --use-random \ + luksFormat \ + '/dev/sda1' + # open + echo "${passphrase}" \ + | cryptsetup luksOpen '/dev/sda1' 'crypt' + # pv + pvcreate '/dev/mapper/crypt' + # vg + vgcreate 'crypt' '/dev/mapper/crypt' + # lv swap + lvcreate --name 'swap' --size '68719476736b' 'crypt' + # lv data + lvcreate --name 'data' --extents '100%FREE' 'crypt' + # format swap + mkswap --label 'swap' '/dev/mapper/crypt-swap' + # format data + mkfs.ext4 -L 'data' '/dev/mapper/crypt-data' + # vg off + vgchange --activate n 'crypt' + # close + cryptsetup luksClose 'crypt' +} From 4514296ee479c847877a798456289ff8ba14a498 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 04:20:24 +0200 Subject: [PATCH 173/969] device,devices --- bash/hetzner-rescue.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 7c378df..8182eb9 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -130,7 +130,12 @@ fi } function hetzner-rescue-wipe-12-10-10 { - local device='/dev/sda' + local device + local devices=( + '/dev/sdc' + '/dev/sda' + '/dev/sdb' + ) local unit='mib' # lsblk From 7905892e5966b162272d71c406bb1bfe1955a388 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 04:32:23 +0200 Subject: [PATCH 174/969] number,mktable --- bash/hetzner-rescue.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 8182eb9..e28aeaf 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -136,13 +136,19 @@ function hetzner-rescue-wipe-12-10-10 { '/dev/sda' '/dev/sdb' ) + local number=0 local unit='mib' # lsblk echo -n 'WIPE' "${device}" '/?\ OR CANCEL /!\' read # - parted "${device}" --script mktable gpt + for device in "${devices[@]}" ; do + ((number++)) + echo ; echo "#${number}: ${device}" + # + parted "${device}" --script mktable gpt + done # parted "${device}" unit "${unit}" mkpart 'crypt' 65795 1907729 # From 22f0f463df6274b31f1faa7b58bf04db1046d247 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 05:01:14 +0200 Subject: [PATCH 175/969] crypt --- bash/hetzner-rescue.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index e28aeaf..701263b 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -148,10 +148,11 @@ function hetzner-rescue-wipe-12-10-10 { echo ; echo "#${number}: ${device}" # parted "${device}" --script mktable gpt + # + parted "${device}" unit "${unit}" \ + mkpart "crypt-${number}" 22359 9537535 done # - parted "${device}" unit "${unit}" mkpart 'crypt' 65795 1907729 - # parted "${device}" unit "${unit}" mkpart 'boot' 259 65795 # parted "${device}" unit "${unit}" mkpart 'esp' 2 259 From 6bd52d184e6db6fbd9c5d2a1973b711bd177ba93 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 05:02:34 +0200 Subject: [PATCH 176/969] boot --- bash/hetzner-rescue.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 701263b..4e5c2ae 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -151,10 +151,11 @@ function hetzner-rescue-wipe-12-10-10 { # parted "${device}" unit "${unit}" \ mkpart "crypt-${number}" 22359 9537535 + # + parted "${device}" unit "${unit}" \ + mkpart "boot-${number}" 513 22359 done # - parted "${device}" unit "${unit}" mkpart 'boot' 259 65795 - # parted "${device}" unit "${unit}" mkpart 'esp' 2 259 parted "${device}" set 3 esp on # From e36e590799e57bea2b54b2f6654d60dcc921e0d7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 05:05:05 +0200 Subject: [PATCH 177/969] esp --- bash/hetzner-rescue.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 4e5c2ae..d6f763f 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -154,11 +154,12 @@ function hetzner-rescue-wipe-12-10-10 { # parted "${device}" unit "${unit}" \ mkpart "boot-${number}" 513 22359 + # + parted "${device}" unit "${unit}" \ + mkpart "esp-${number}" 2 513 + parted "${device}" set 3 esp on done # - parted "${device}" unit "${unit}" mkpart 'esp' 2 259 - parted "${device}" set 3 esp on - # parted "${device}" unit "${unit}" mkpart bios 1 2 parted "${device}" set 4 bios_grub on # wipe bios From 0c2df7cb6d0546243bd7bad51f87847903c49bee Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 05:09:15 +0200 Subject: [PATCH 178/969] bios --- bash/hetzner-rescue.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index d6f763f..a5588be 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -158,10 +158,11 @@ function hetzner-rescue-wipe-12-10-10 { parted "${device}" unit "${unit}" \ mkpart "esp-${number}" 2 513 parted "${device}" set 3 esp on + # + parted "${device}" unit "${unit}" \ + mkpart "bios-${number}" 1 2 + parted "${device}" set 4 bios_grub on done - # - parted "${device}" unit "${unit}" mkpart bios 1 2 - parted "${device}" set 4 bios_grub on # wipe bios dd if='/dev/zero' of='/dev/sda4' # format esp From adcc61b37730bd91fe81bb11373fc41bf64a305f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 05:11:55 +0200 Subject: [PATCH 179/969] bios --- bash/hetzner-rescue.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index a5588be..5833bf0 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -162,9 +162,9 @@ function hetzner-rescue-wipe-12-10-10 { parted "${device}" unit "${unit}" \ mkpart "bios-${number}" 1 2 parted "${device}" set 4 bios_grub on + # wipe bios + dd if='/dev/zero' of="${device}4" done - # wipe bios - dd if='/dev/zero' of='/dev/sda4' # format esp mkfs.vfat -F 32 -n 'esp' '/dev/sda3' # format boot From d9c6a67d4005141504f875bf5cc0c7a6f817f910 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 05:15:38 +0200 Subject: [PATCH 180/969] esp --- bash/hetzner-rescue.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 5833bf0..2dc00e3 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -164,9 +164,10 @@ function hetzner-rescue-wipe-12-10-10 { parted "${device}" set 4 bios_grub on # wipe bios dd if='/dev/zero' of="${device}4" + # format esp + dd if='/dev/zero' of="${device}3" + mkfs.vfat -F 32 -n "esp-${number}" "${device}3" done - # format esp - mkfs.vfat -F 32 -n 'esp' '/dev/sda3' # format boot mkfs.ext4 -F -L 'boot' '/dev/sda2' # read passphrase From 74a27a077c7251d74bee488e3bb4d8d0c49c83a3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 05:18:39 +0200 Subject: [PATCH 181/969] number --- bash/hetzner-rescue.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 2dc00e3..7cde848 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -136,13 +136,14 @@ function hetzner-rescue-wipe-12-10-10 { '/dev/sda' '/dev/sdb' ) - local number=0 + local number local unit='mib' # lsblk echo -n 'WIPE' "${device}" '/?\ OR CANCEL /!\' read # + number=0 for device in "${devices[@]}" ; do ((number++)) echo ; echo "#${number}: ${device}" @@ -162,8 +163,20 @@ function hetzner-rescue-wipe-12-10-10 { parted "${device}" unit "${unit}" \ mkpart "bios-${number}" 1 2 parted "${device}" set 4 bios_grub on + done + # + number=0 + for device in "${devices[@]}" ; do + ((number++)) + echo ; echo "#${number}: ${device}" # wipe bios dd if='/dev/zero' of="${device}4" + done + # + number=0 + for device in "${devices[@]}" ; do + ((number++)) + echo ; echo "#${number}: ${device}" # format esp dd if='/dev/zero' of="${device}3" mkfs.vfat -F 32 -n "esp-${number}" "${device}3" From 3ac8efc19d5b749f3414c2eb445afa9f19a74e66 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 05:29:11 +0200 Subject: [PATCH 182/969] boot --- bash/hetzner-rescue.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 7cde848..d14dac2 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -181,6 +181,15 @@ function hetzner-rescue-wipe-12-10-10 { dd if='/dev/zero' of="${device}3" mkfs.vfat -F 32 -n "esp-${number}" "${device}3" done + # + number=0 + for device in "${devices[@]}" ; do + ((number++)) + echo ; echo "#${number}: ${device}" + # wipe boot + dd if='/dev/zero' of="${device}2" bs='1G' status='progress' + done +#### # format boot mkfs.ext4 -F -L 'boot' '/dev/sda2' # read passphrase From 1624f18fc8d53ee59d9d5fbd019f28fa43bf9d4b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 05:38:26 +0200 Subject: [PATCH 183/969] cut --- bash/hetzner-rescue.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index d14dac2..aaa240c 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -189,7 +189,9 @@ function hetzner-rescue-wipe-12-10-10 { # wipe boot dd if='/dev/zero' of="${device}2" bs='1G' status='progress' done -#### +} + +function hetzner-rescue-wipe-12-10-10-extra { # format boot mkfs.ext4 -F -L 'boot' '/dev/sda2' # read passphrase From a5cf152c80c6b3525688a516250cabc620536303 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 05:44:42 +0200 Subject: [PATCH 184/969] extra --- bash/hetzner-rescue.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index aaa240c..619bc91 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -165,6 +165,9 @@ function hetzner-rescue-wipe-12-10-10 { parted "${device}" set 4 bios_grub on done # + parted "${device}" unit "${unit}" \ + mkpart 'extra' 9537535 11444223 + # number=0 for device in "${devices[@]}" ; do ((number++)) From f71653e290743d6dda84536bf545f9dc74bd14c2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 09:44:16 +0200 Subject: [PATCH 185/969] members --- bash/hetzner-rescue.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 619bc91..ee47d11 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -136,6 +136,7 @@ function hetzner-rescue-wipe-12-10-10 { '/dev/sda' '/dev/sdb' ) + local members local number local unit='mib' # @@ -192,6 +193,32 @@ function hetzner-rescue-wipe-12-10-10 { # wipe boot dd if='/dev/zero' of="${device}2" bs='1G' status='progress' done + # + members=() + for device in "${devices[@]}" ; do + members+=("${device}2") + done + mdadm \ + --create '/dev/md/boot' \ + --name 'boot' \ + --uuid '6234a0eb:29a3a847:1dbd5ec4:bada5579' \ + --metadata 1 \ + --level 0 \ + --raid-devices ${#devices[@]} \ + "${members[@]}" + # + members=() + for device in "${devices[@]}" ; do + members+=("${device}1") + done + mdadm \ + --create '/dev/md/crypt' \ + --name 'crypt' \ + --uuid '006234a0:eb29a3a8:471dbd5e:c4bada55' \ + --metadata 1 \ + --level 0 \ + --raid-devices ${#devices[@]} \ + "${members[@]}" } function hetzner-rescue-wipe-12-10-10-extra { From f4cda4c0960da90e83005789a1f66366fcb463b0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 09:46:44 +0200 Subject: [PATCH 186/969] boot --- bash/hetzner-rescue.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index ee47d11..1dd40d1 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -219,11 +219,15 @@ function hetzner-rescue-wipe-12-10-10 { --level 0 \ --raid-devices ${#devices[@]} \ "${members[@]}" + # format boot + mkfs.ext4 \ + -F \ + -L 'boot' \ + -U '6234a0eb-29a3-a847-1dbd-5ec4bada5579' \ + '/dev/md/boot' } function hetzner-rescue-wipe-12-10-10-extra { - # format boot - mkfs.ext4 -F -L 'boot' '/dev/sda2' # read passphrase local passphrase echo -n 'PassPhrase: ' From 8fbfabb388ec21b3c8b2ba3e4276224743fd0768 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 09:50:47 +0200 Subject: [PATCH 187/969] passphrase --- bash/hetzner-rescue.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 1dd40d1..10557aa 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -138,10 +138,14 @@ function hetzner-rescue-wipe-12-10-10 { ) local members local number + local passphrase local unit='mib' + # read passphrase + echo -n 'PassPhrase: ' + read -r -s passphrase # lsblk - echo -n 'WIPE' "${device}" '/?\ OR CANCEL /!\' + echo -n 'WIPE' "${devices[@]}" '/?\ OR CANCEL /!\' read # number=0 @@ -228,10 +232,6 @@ function hetzner-rescue-wipe-12-10-10 { } function hetzner-rescue-wipe-12-10-10-extra { - # read passphrase - local passphrase - echo -n 'PassPhrase: ' - read -r -s passphrase # encrypt echo "${passphrase}" \ | cryptsetup \ From eeda17878a8ac1468f5835928de99ea07f8367b5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 09:52:33 +0200 Subject: [PATCH 188/969] cryptsetup --- bash/hetzner-rescue.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 10557aa..f19ab4a 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -229,9 +229,6 @@ function hetzner-rescue-wipe-12-10-10 { -L 'boot' \ -U '6234a0eb-29a3-a847-1dbd-5ec4bada5579' \ '/dev/md/boot' -} - -function hetzner-rescue-wipe-12-10-10-extra { # encrypt echo "${passphrase}" \ | cryptsetup \ @@ -245,7 +242,10 @@ function hetzner-rescue-wipe-12-10-10-extra { --hash 'sha512' \ --use-random \ luksFormat \ - '/dev/sda1' + '/dev/md/crypt' +} + +function hetzner-rescue-wipe-12-10-10-extra { # open echo "${passphrase}" \ | cryptsetup luksOpen '/dev/sda1' 'crypt' From d58afc82266630fb4533cdce5bf31d37005c6119 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 09:54:01 +0200 Subject: [PATCH 189/969] open,close --- bash/hetzner-rescue.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index f19ab4a..929c262 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -243,12 +243,15 @@ function hetzner-rescue-wipe-12-10-10 { --use-random \ luksFormat \ '/dev/md/crypt' + # open + echo "${passphrase}" \ + | cryptsetup luksOpen '/dev/md/crypt' 'crypt' +#### + # close + cryptsetup luksClose 'crypt' } function hetzner-rescue-wipe-12-10-10-extra { - # open - echo "${passphrase}" \ - | cryptsetup luksOpen '/dev/sda1' 'crypt' # pv pvcreate '/dev/mapper/crypt' # vg @@ -263,6 +266,4 @@ function hetzner-rescue-wipe-12-10-10-extra { mkfs.ext4 -L 'data' '/dev/mapper/crypt-data' # vg off vgchange --activate n 'crypt' - # close - cryptsetup luksClose 'crypt' } From d969810396fa4f5f79b5d9371c974e9f68e5bb95 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 09:55:08 +0200 Subject: [PATCH 190/969] pv,vg --- bash/hetzner-rescue.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 929c262..c2431ff 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -246,16 +246,18 @@ function hetzner-rescue-wipe-12-10-10 { # open echo "${passphrase}" \ | cryptsetup luksOpen '/dev/md/crypt' 'crypt' + # pv + pvcreate '/dev/mapper/crypt' + # vg + vgcreate 'crypt' '/dev/mapper/crypt' #### + # vg off + vgchange --activate n 'crypt' # close cryptsetup luksClose 'crypt' } function hetzner-rescue-wipe-12-10-10-extra { - # pv - pvcreate '/dev/mapper/crypt' - # vg - vgcreate 'crypt' '/dev/mapper/crypt' # lv swap lvcreate --name 'swap' --size '68719476736b' 'crypt' # lv data @@ -264,6 +266,4 @@ function hetzner-rescue-wipe-12-10-10-extra { mkswap --label 'swap' '/dev/mapper/crypt-swap' # format data mkfs.ext4 -L 'data' '/dev/mapper/crypt-data' - # vg off - vgchange --activate n 'crypt' } From 969734c4cd2f83c15a77d751fe0919125a7f3546 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 09:57:39 +0200 Subject: [PATCH 191/969] lv --- bash/hetzner-rescue.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index c2431ff..ad04071 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -250,6 +250,10 @@ function hetzner-rescue-wipe-12-10-10 { pvcreate '/dev/mapper/crypt' # vg vgcreate 'crypt' '/dev/mapper/crypt' + # lv swap + lvcreate --name 'swap' --size '68719476736b' 'crypt' + # lv data + lvcreate --name 'data' --extents '100%FREE' 'crypt' #### # vg off vgchange --activate n 'crypt' @@ -258,10 +262,6 @@ function hetzner-rescue-wipe-12-10-10 { } function hetzner-rescue-wipe-12-10-10-extra { - # lv swap - lvcreate --name 'swap' --size '68719476736b' 'crypt' - # lv data - lvcreate --name 'data' --extents '100%FREE' 'crypt' # format swap mkswap --label 'swap' '/dev/mapper/crypt-swap' # format data From cf4d94535036bf022c6713272613e5805025dff8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 09:58:47 +0200 Subject: [PATCH 192/969] swap --- bash/hetzner-rescue.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index ad04071..da3514b 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -254,6 +254,11 @@ function hetzner-rescue-wipe-12-10-10 { lvcreate --name 'swap' --size '68719476736b' 'crypt' # lv data lvcreate --name 'data' --extents '100%FREE' 'crypt' + # format swap + mkswap \ + --label 'swap' \ + -U '06234a0e-b29a-3a84-71db-d5ec4bada557' \ + '/dev/mapper/crypt-swap' #### # vg off vgchange --activate n 'crypt' @@ -262,8 +267,6 @@ function hetzner-rescue-wipe-12-10-10 { } function hetzner-rescue-wipe-12-10-10-extra { - # format swap - mkswap --label 'swap' '/dev/mapper/crypt-swap' # format data mkfs.ext4 -L 'data' '/dev/mapper/crypt-data' } From 7cbe78dbc62adf9d2ce07697d34a72a2b296cc80 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 09:59:55 +0200 Subject: [PATCH 193/969] data --- bash/hetzner-rescue.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index da3514b..e5b18fa 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -259,14 +259,13 @@ function hetzner-rescue-wipe-12-10-10 { --label 'swap' \ -U '06234a0e-b29a-3a84-71db-d5ec4bada557' \ '/dev/mapper/crypt-swap' -#### + # format data + mkfs.ext4 \ + -L 'data' \ + -U '006234a0-eb29-a3a8-471d-bd5ec4bada55' \ + '/dev/mapper/crypt-data' # vg off vgchange --activate n 'crypt' # close cryptsetup luksClose 'crypt' } - -function hetzner-rescue-wipe-12-10-10-extra { - # format data - mkfs.ext4 -L 'data' '/dev/mapper/crypt-data' -} From 3972d3ce394278cfca3b10b971973db5648d279c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 10:05:29 +0200 Subject: [PATCH 194/969] split --- bash/hetzner-rescue.sh | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index e5b18fa..c710da4 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -129,7 +129,7 @@ else fi } -function hetzner-rescue-wipe-12-10-10 { +function hetzner-rescue-wipe-12-10-10-0 { local device local devices=( '/dev/sdc' @@ -246,6 +246,33 @@ function hetzner-rescue-wipe-12-10-10 { # open echo "${passphrase}" \ | cryptsetup luksOpen '/dev/md/crypt' 'crypt' +#### + # close + cryptsetup luksClose 'crypt' +} + +function hetzner-rescue-wipe-12-10-10-1 { + local passphrase + # read passphrase + echo -n 'PassPhrase: ' + read -r -s passphrase + # encrypt + echo "${passphrase}" \ + | cryptsetup \ + --verbose \ + --batch-mode \ + --type 'luks2' \ + --pbkdf 'argon2id' \ + --cipher 'aes-xts-plain64' \ + --iter-time 8192 \ + --key-size 512 \ + --hash 'sha512' \ + --use-random \ + luksFormat \ + '/dev/md/crypt' + # open + echo "${passphrase}" \ + | cryptsetup luksOpen '/dev/md/crypt' 'crypt' # pv pvcreate '/dev/mapper/crypt' # vg From 71f0ef08567add6312feec1921027b7eff9b2d44 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 10:11:41 +0200 Subject: [PATCH 195/969] crypt --- bash/hetzner-rescue.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index c710da4..8aae4d3 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -178,7 +178,8 @@ function hetzner-rescue-wipe-12-10-10-0 { ((number++)) echo ; echo "#${number}: ${device}" # wipe bios - dd if='/dev/zero' of="${device}4" + dd \ + if='/dev/zero' of="${device}4" done # number=0 @@ -186,7 +187,8 @@ function hetzner-rescue-wipe-12-10-10-0 { ((number++)) echo ; echo "#${number}: ${device}" # format esp - dd if='/dev/zero' of="${device}3" + dd \ + if='/dev/zero' of="${device}3" mkfs.vfat -F 32 -n "esp-${number}" "${device}3" done # @@ -195,7 +197,8 @@ function hetzner-rescue-wipe-12-10-10-0 { ((number++)) echo ; echo "#${number}: ${device}" # wipe boot - dd if='/dev/zero' of="${device}2" bs='1G' status='progress' + dd status='progress' \ + if='/dev/zero' of="${device}2" bs='1G' done # members=() @@ -246,7 +249,9 @@ function hetzner-rescue-wipe-12-10-10-0 { # open echo "${passphrase}" \ | cryptsetup luksOpen '/dev/md/crypt' 'crypt' -#### + # wipe crypt + dd status='progress' \ + if='/dev/zero' of='/dev/mapper/crypt' bs='16G' # close cryptsetup luksClose 'crypt' } From afc8c6c83365beea4d530eca1a0162170fc97e23 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 11:07:38 +0200 Subject: [PATCH 196/969] hostname --- bash/hetzner-rescue.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 8aae4d3..261c7e5 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -1,5 +1,5 @@ function hetzner-rescue-configure { -local host="${1}" +local hostname="${1}" local package local packages=( 'mosh' @@ -29,7 +29,7 @@ deb https://deb.debian.org/debian-security bookworm-security main non-free-firmw main_link_bashrc mv .bashrc .bashrc.old # host name - hostname "${host}" + hostname "${hostname}" # locales echo -n "\ en_US.UTF-8 UTF-8 @@ -102,7 +102,8 @@ function hetzner-rescue-install { function hetzner-rescue-upload { local host="${1}" -if [ "${host}" ] ; then +local hostname="${2}" +if [ "${hostname}" ] ; then local user='root' # local user_host="${user}@${host}" @@ -116,7 +117,7 @@ if [ "${host}" ] ; then rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" # call setup # TODO variable - ssh "${user_host}" -- "source '/etc/bash/main.sh' ; hetzner-rescue-configure '${host}'" + ssh "${user_host}" -- "source '/etc/bash/main.sh' ; hetzner-rescue-configure '${hostname}'" # create session ssh "${user_host}" -- byobu new-session -d # send keys From 6f752c3afc8901d20bd62d2be2a5c5cc8c354b7d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 11:39:34 +0200 Subject: [PATCH 197/969] esp/bs --- bash/hetzner-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 261c7e5..2182e15 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -189,7 +189,7 @@ function hetzner-rescue-wipe-12-10-10-0 { echo ; echo "#${number}: ${device}" # format esp dd \ - if='/dev/zero' of="${device}3" + if='/dev/zero' of="${device}3" bs='1M' mkfs.vfat -F 32 -n "esp-${number}" "${device}3" done # From 10aa0b80b5c23f994e250bc8e54ab7e32edbd573 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 11:43:10 +0200 Subject: [PATCH 198/969] 4,3,2 --- bash/hetzner-rescue.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 2182e15..dcaf24f 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -177,7 +177,7 @@ function hetzner-rescue-wipe-12-10-10-0 { number=0 for device in "${devices[@]}" ; do ((number++)) - echo ; echo "#${number}: ${device}" + echo ; echo "#${number}: ${device}4" # wipe bios dd \ if='/dev/zero' of="${device}4" @@ -186,7 +186,7 @@ function hetzner-rescue-wipe-12-10-10-0 { number=0 for device in "${devices[@]}" ; do ((number++)) - echo ; echo "#${number}: ${device}" + echo ; echo "#${number}: ${device}3" # format esp dd \ if='/dev/zero' of="${device}3" bs='1M' @@ -196,7 +196,7 @@ function hetzner-rescue-wipe-12-10-10-0 { number=0 for device in "${devices[@]}" ; do ((number++)) - echo ; echo "#${number}: ${device}" + echo ; echo "#${number}: ${device}2" # wipe boot dd status='progress' \ if='/dev/zero' of="${device}2" bs='1G' From f796532025782f4f1bffa848f8f23fcf50237da9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 3 Oct 2023 11:46:51 +0200 Subject: [PATCH 199/969] head --- bash/hetzner-rescue.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index dcaf24f..d7b6bd0 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -215,6 +215,15 @@ function hetzner-rescue-wipe-12-10-10-0 { --raid-devices ${#devices[@]} \ "${members[@]}" # + number=0 + for device in "${devices[@]}" ; do + ((number++)) + echo ; echo "#${number}: ${device}1" + # wipe crypt head + dd status='progress' \ + if='/dev/zero' of="${device}1" bs='1G' count=1 + done + # members=() for device in "${devices[@]}" ; do members+=("${device}1") From abc7186d573d660795a81c62878aa03241de076f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 4 Oct 2023 08:24:22 +0200 Subject: [PATCH 200/969] close --- bash/hetzner-rescue.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index d7b6bd0..4254130 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -262,12 +262,12 @@ function hetzner-rescue-wipe-12-10-10-0 { # wipe crypt dd status='progress' \ if='/dev/zero' of='/dev/mapper/crypt' bs='16G' - # close - cryptsetup luksClose 'crypt' } function hetzner-rescue-wipe-12-10-10-1 { local passphrase + # close + cryptsetup luksClose 'crypt' # read passphrase echo -n 'PassPhrase: ' read -r -s passphrase From a98be0588f690a2eaec0bcb0235b1440f1591095 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 4 Oct 2023 08:36:02 +0200 Subject: [PATCH 201/969] swap/128 --- bash/hetzner-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 4254130..58808aa 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -293,7 +293,7 @@ function hetzner-rescue-wipe-12-10-10-1 { # vg vgcreate 'crypt' '/dev/mapper/crypt' # lv swap - lvcreate --name 'swap' --size '68719476736b' 'crypt' + lvcreate --name 'swap' --size '137438953472b' 'crypt' # lv data lvcreate --name 'data' --extents '100%FREE' 'crypt' # format swap From 16d3f72a6dbdef0a6969f79769234e13aa8be46e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 10 Oct 2023 22:11:57 +0200 Subject: [PATCH 202/969] modules --- __main__.py | 12 ++++---- arg/__init__.py | 5 ++++ file/__init__.py | 37 ----------------------- fs/__init__.py | 71 +++++++++++++++++++++++++++++++++++++++++++++ grub/__init__.py | 30 +++++++++++++++++++ project/__init__.py | 13 +++++++++ ps/__init__.py | 28 ++++++++++++++++++ txt/__init__.py | 1 + 8 files changed, 154 insertions(+), 43 deletions(-) create mode 100644 arg/__init__.py delete mode 100644 file/__init__.py create mode 100644 fs/__init__.py create mode 100644 grub/__init__.py create mode 100644 project/__init__.py create mode 100644 ps/__init__.py create mode 100644 txt/__init__.py diff --git a/__main__.py b/__main__.py index a0ac1c5..0f73041 100755 --- a/__main__.py +++ b/__main__.py @@ -2,7 +2,7 @@ import os -import file +import fs if __name__ == '__main__': @@ -11,8 +11,8 @@ if __name__ == '__main__': directory_path = os.path.join(root_path, 'tmp') file_path = os.path.join(directory_path, 'file') - file.wipe(directory_path) - file.make(directory_path) - file.write(file_path, 'Martine écrit beaucoup.') - file.empty(file_path) - file.write(file_path, 'Martine écrit moins.') + fs.wipe(directory_path) + fs.make_directory(directory_path) + fs.write(file_path, 'Martine écrit beaucoup.') + fs.empty_file(file_path) + fs.write(file_path, 'Martine écrit moins.') diff --git a/arg/__init__.py b/arg/__init__.py new file mode 100644 index 0000000..5db26ae --- /dev/null +++ b/arg/__init__.py @@ -0,0 +1,5 @@ +import sys + + +def split() -> tuple[str, list[str]]: + return sys.argv[0], sys.argv[1:] diff --git a/file/__init__.py b/file/__init__.py deleted file mode 100644 index eaf0059..0000000 --- a/file/__init__.py +++ /dev/null @@ -1,37 +0,0 @@ -import os -import shutil -import subprocess - -CHARSET = 'UTF-8' - - -def create_image(file_path: str, size_bytes: int): - subprocess.run([ - 'qemu-img', - 'create', - '-f', 'qcow2', - file_path, - size_bytes, - ]) - - -def empty(file_path: str): - write(file_path, str()) - - -def make(directory_path: str): - os.makedirs(directory_path, exist_ok=True) - - -def wipe(path: str): - try: - shutil.rmtree(path) - except NotADirectoryError: - os.remove(path) - except FileNotFoundError: - pass - - -def write(file_path: str, text: str, charset=CHARSET): - with open(file_path, 'bw') as file_object: - file_object.write(text.encode(charset)) diff --git a/fs/__init__.py b/fs/__init__.py new file mode 100644 index 0000000..73dd8f0 --- /dev/null +++ b/fs/__init__.py @@ -0,0 +1,71 @@ +import os +import shutil +import subprocess + +from .. import ps + +CHARSET = 'UTF-8' + + +def create_image(file_path: str, size_bytes: int): + ps.run( + ('qemu-img', 'create'), + ('-f', 'qcow2'), + (file_path, size_bytes), + ) + + +def empty_file(path: str): + write(path, str()) + + +def get_mount_uuid(path: str): + return ps.run_line( + ('findmnt'), + ('--noheadings'), + ('--output', 'UUID'), + (path), + ) + + +def get_path_mount(path: str): + return ps.run_line( + ('stat'), + ('--format', '%m'), + (path), + ) + + +def get_path_uuid(path: str): + return get_mount_uuid(get_path_mount(path)) + + +def make_directory(path: str): + os.makedirs(path, exist_ok=True) + + +def read_file(file_path: str): + with open(file_path, 'br') as file_object: + return file_object.read() + + +def read_file_lines(file_path: str, charset=CHARSET): + return read_file_text(file_path).split(os.linesep) + + +def read_file_text(file_path: str, charset=CHARSET): + return read_file(file_path).decode(charset) + + +def wipe(path: str): + try: + shutil.rmtree(path) + except NotADirectoryError: + os.remove(path) + except FileNotFoundError: + pass + + +def write(file_path: str, text: str, charset=CHARSET): + with open(file_path, 'bw') as file_object: + file_object.write(text.encode(charset)) diff --git a/grub/__init__.py b/grub/__init__.py new file mode 100644 index 0000000..5c5f977 --- /dev/null +++ b/grub/__init__.py @@ -0,0 +1,30 @@ +from .. import ps + +COMPRESSION = 'xz' +ENV_BYTES = 1024 +ENV_COMMENT = '#' +ENV_HEADER = f'''{ENV_COMMENT} GRUB Environment Block +''' +MODULES = { + 'i386-pc': [ + ('biosdisk'), + ('ntldr'), + ] +} + + +def make_image(image_format: str, image_path: str, modules: list[str], + memdisk_path: str, pubkey_path: str=None) -> None: + args = [ + ('grub-mkimage'), + ('--compress', COMPRESSION), + ('--format', image_format), + ('--output', image_path), + ('--memdisk', memdisk_path), + ] + if pubkey_path: + args.append(('--pubkey', pubkey_path)) + args.extend(modules) + if modules := MODULES.get(image_format, None): + args.extend(modules) + ps.run(*args) diff --git a/project/__init__.py b/project/__init__.py new file mode 100644 index 0000000..b03f2c4 --- /dev/null +++ b/project/__init__.py @@ -0,0 +1,13 @@ +import os + + +class Project: + + def __init__(self, root_path: str): + self.root = root_path + + +def from_root_file(file_path: str): + project_file = os.path.realpath(file_path) + project_root = os.path.dirname(project_file) + return Project(real_file) diff --git a/ps/__init__.py b/ps/__init__.py new file mode 100644 index 0000000..ddbfb72 --- /dev/null +++ b/ps/__init__.py @@ -0,0 +1,28 @@ +import subprocess + +from .. import txt + + +def get_tuples_args(tuples) -> list[str]: + args = [] + for item in tuples: + if type(item) is tuple: + args.extend(item) + else: + args.append(item) + return args + + +def run(*tuples) -> subprocess.CompletedProcess: + return subprocess.run(get_tuples_args(tuples), capture_output=False) + + +def run_line(*tuples, charset:str=txt.CHARSET) -> str: + lines = run_lines(*get_tuples_args(tuples), charset=charset) + return lines[0] + + +def run_lines(*tuples, charset:str=txt.CHARSET) -> list[str]: + process = subprocess.run(get_tuples_args(tuples), capture_output=True) + string = process.stdout.decode(charset) + return string.rstrip().splitlines() diff --git a/txt/__init__.py b/txt/__init__.py new file mode 100644 index 0000000..81903f4 --- /dev/null +++ b/txt/__init__.py @@ -0,0 +1 @@ +CHARSET='UTF-8' From a31d85f16a0f91026fe9fb1b551eaefec3133f72 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Dec 2023 12:31:13 +0100 Subject: [PATCH 203/969] emacs --- bash/alias/emacs.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 bash/alias/emacs.sh diff --git a/bash/alias/emacs.sh b/bash/alias/emacs.sh new file mode 100644 index 0000000..7984a4a --- /dev/null +++ b/bash/alias/emacs.sh @@ -0,0 +1,4 @@ +# short +alias em="\ +emacs \ +" From 9e9434e8e0ec0c2b4e8827aaa3f06457a5b1e655 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 28 Dec 2023 08:36:46 +0100 Subject: [PATCH 204/969] 8-8-0,8-8-1 --- bash/hetzner-rescue.sh | 182 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 58808aa..7e79b7f 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -130,6 +130,188 @@ else fi } +function hetzner-rescue-wipe-8-8-0 { + local device + local devices=( + '/dev/sdc' + '/dev/sda' + '/dev/sdb' + ) + local members + local number + local passphrase + local unit='mib' + # read passphrase + echo -n 'PassPhrase: ' + read -r -s passphrase + # + lsblk + echo -n 'WIPE' "${devices[@]}" '/?\ OR CANCEL /!\' + read + # + number=0 + for device in "${devices[@]}" ; do + ((number++)) + echo ; echo "#${number}: ${device}" + # + parted "${device}" --script mktable gpt + # + parted "${device}" unit "${unit}" \ + mkpart "crypt-${number}" 22359 9537535 + # + parted "${device}" unit "${unit}" \ + mkpart "boot-${number}" 513 22359 + # + parted "${device}" unit "${unit}" \ + mkpart "esp-${number}" 2 513 + parted "${device}" set 3 esp on + # + parted "${device}" unit "${unit}" \ + mkpart "bios-${number}" 1 2 + parted "${device}" set 4 bios_grub on + done + # + parted "${device}" unit "${unit}" \ + mkpart 'extra' 9537535 11444223 + # + number=0 + for device in "${devices[@]}" ; do + ((number++)) + echo ; echo "#${number}: ${device}4" + # wipe bios + dd \ + if='/dev/zero' of="${device}4" + done + # + number=0 + for device in "${devices[@]}" ; do + ((number++)) + echo ; echo "#${number}: ${device}3" + # format esp + dd \ + if='/dev/zero' of="${device}3" bs='1M' + mkfs.vfat -F 32 -n "esp-${number}" "${device}3" + done + # + number=0 + for device in "${devices[@]}" ; do + ((number++)) + echo ; echo "#${number}: ${device}2" + # wipe boot + dd status='progress' \ + if='/dev/zero' of="${device}2" bs='1G' + done + # + members=() + for device in "${devices[@]}" ; do + members+=("${device}2") + done + mdadm \ + --create '/dev/md/boot' \ + --name 'boot' \ + --uuid '6234a0eb:29a3a847:1dbd5ec4:bada5579' \ + --metadata 1 \ + --level 0 \ + --raid-devices ${#devices[@]} \ + "${members[@]}" + # + number=0 + for device in "${devices[@]}" ; do + ((number++)) + echo ; echo "#${number}: ${device}1" + # wipe crypt head + dd status='progress' \ + if='/dev/zero' of="${device}1" bs='1G' count=1 + done + # + members=() + for device in "${devices[@]}" ; do + members+=("${device}1") + done + mdadm \ + --create '/dev/md/crypt' \ + --name 'crypt' \ + --uuid '006234a0:eb29a3a8:471dbd5e:c4bada55' \ + --metadata 1 \ + --level 0 \ + --raid-devices ${#devices[@]} \ + "${members[@]}" + # format boot + mkfs.ext4 \ + -F \ + -L 'boot' \ + -U '6234a0eb-29a3-a847-1dbd-5ec4bada5579' \ + '/dev/md/boot' + # encrypt + echo "${passphrase}" \ + | cryptsetup \ + --verbose \ + --batch-mode \ + --type 'luks2' \ + --pbkdf 'argon2id' \ + --cipher 'aes-xts-plain64' \ + --iter-time 8192 \ + --key-size 512 \ + --hash 'sha512' \ + --use-random \ + luksFormat \ + '/dev/md/crypt' + # open + echo "${passphrase}" \ + | cryptsetup luksOpen '/dev/md/crypt' 'crypt' + # wipe crypt + dd status='progress' \ + if='/dev/zero' of='/dev/mapper/crypt' bs='16G' +} + +function hetzner-rescue-wipe-8-8-1 { + local passphrase + # close + cryptsetup luksClose 'crypt' + # read passphrase + echo -n 'PassPhrase: ' + read -r -s passphrase + # encrypt + echo "${passphrase}" \ + | cryptsetup \ + --verbose \ + --batch-mode \ + --type 'luks2' \ + --pbkdf 'argon2id' \ + --cipher 'aes-xts-plain64' \ + --iter-time 8192 \ + --key-size 512 \ + --hash 'sha512' \ + --use-random \ + luksFormat \ + '/dev/md/crypt' + # open + echo "${passphrase}" \ + | cryptsetup luksOpen '/dev/md/crypt' 'crypt' + # pv + pvcreate '/dev/mapper/crypt' + # vg + vgcreate 'crypt' '/dev/mapper/crypt' + # lv swap + lvcreate --name 'swap' --size '137438953472b' 'crypt' + # lv data + lvcreate --name 'data' --extents '100%FREE' 'crypt' + # format swap + mkswap \ + --label 'swap' \ + -U '06234a0e-b29a-3a84-71db-d5ec4bada557' \ + '/dev/mapper/crypt-swap' + # format data + mkfs.ext4 \ + -L 'data' \ + -U '006234a0-eb29-a3a8-471d-bd5ec4bada55' \ + '/dev/mapper/crypt-data' + # vg off + vgchange --activate n 'crypt' + # close + cryptsetup luksClose 'crypt' +} + function hetzner-rescue-wipe-12-10-10-0 { local device local devices=( From c00ceaacaf2bde8a045461a27446bd57278adc66 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 28 Dec 2023 09:23:03 +0100 Subject: [PATCH 205/969] parted --- bash/hetzner-rescue.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 7e79b7f..22ac7c2 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -133,7 +133,6 @@ fi function hetzner-rescue-wipe-8-8-0 { local device local devices=( - '/dev/sdc' '/dev/sda' '/dev/sdb' ) @@ -157,13 +156,13 @@ function hetzner-rescue-wipe-8-8-0 { parted "${device}" --script mktable gpt # parted "${device}" unit "${unit}" \ - mkpart "crypt-${number}" 22359 9537535 + mkpart "crypt-${number}" 33282 7630885 # parted "${device}" unit "${unit}" \ - mkpart "boot-${number}" 513 22359 + mkpart "boot-${number}" 514 33282 # parted "${device}" unit "${unit}" \ - mkpart "esp-${number}" 2 513 + mkpart "esp-${number}" 2 514 parted "${device}" set 3 esp on # parted "${device}" unit "${unit}" \ @@ -171,9 +170,6 @@ function hetzner-rescue-wipe-8-8-0 { parted "${device}" set 4 bios_grub on done # - parted "${device}" unit "${unit}" \ - mkpart 'extra' 9537535 11444223 - # number=0 for device in "${devices[@]}" ; do ((number++)) From 874dd04672c4b96b73e6705a680b3a45666efa9d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 28 Dec 2023 10:01:15 +0100 Subject: [PATCH 206/969] mkfs --- bash/hetzner-rescue.sh | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 22ac7c2..bd15e93 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -186,7 +186,11 @@ function hetzner-rescue-wipe-8-8-0 { # format esp dd \ if='/dev/zero' of="${device}3" bs='1M' - mkfs.vfat -F 32 -n "esp-${number}" "${device}3" + mkfs.vfat \ + -F 32 \ + -S 4096 \ + -n "esp-${number}" \ + "${device}3" done # number=0 @@ -195,20 +199,17 @@ function hetzner-rescue-wipe-8-8-0 { echo ; echo "#${number}: ${device}2" # wipe boot dd status='progress' \ - if='/dev/zero' of="${device}2" bs='1G' + if='/dev/zero' of="${device}2" bs='1G' count=1 done # members=() for device in "${devices[@]}" ; do members+=("${device}2") done - mdadm \ - --create '/dev/md/boot' \ - --name 'boot' \ - --uuid '6234a0eb:29a3a847:1dbd5ec4:bada5579' \ - --metadata 1 \ - --level 0 \ - --raid-devices ${#devices[@]} \ + mkfs.btrfs --force \ + --label 'boot' \ + --checksum 'sha256' \ + --data 'raid0' \ "${members[@]}" # number=0 @@ -232,12 +233,6 @@ function hetzner-rescue-wipe-8-8-0 { --level 0 \ --raid-devices ${#devices[@]} \ "${members[@]}" - # format boot - mkfs.ext4 \ - -F \ - -L 'boot' \ - -U '6234a0eb-29a3-a847-1dbd-5ec4bada5579' \ - '/dev/md/boot' # encrypt echo "${passphrase}" \ | cryptsetup \ From b053c65680d0fd89618cd40def476ab2da619837 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 28 Dec 2023 11:26:30 +0100 Subject: [PATCH 207/969] esp/uuid --- bash/hetzner-rescue.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index bd15e93..57ebb04 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -189,6 +189,7 @@ function hetzner-rescue-wipe-8-8-0 { mkfs.vfat \ -F 32 \ -S 4096 \ + -i "b007000${number}" \ -n "esp-${number}" \ "${device}3" done From 58829f7045be5446a9f98edad3ca19440c515771 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 28 Dec 2023 11:58:29 +0100 Subject: [PATCH 208/969] uuid --- bash/hetzner-rescue.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 57ebb04..47d3a73 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -189,7 +189,7 @@ function hetzner-rescue-wipe-8-8-0 { mkfs.vfat \ -F 32 \ -S 4096 \ - -i "b007000${number}" \ + -i "000000b${number}" \ -n "esp-${number}" \ "${device}3" done @@ -209,6 +209,7 @@ function hetzner-rescue-wipe-8-8-0 { done mkfs.btrfs --force \ --label 'boot' \ + --uuid '00000000-0000-0000-0000-0000000000b0' \ --checksum 'sha256' \ --data 'raid0' \ "${members[@]}" @@ -229,7 +230,7 @@ function hetzner-rescue-wipe-8-8-0 { mdadm \ --create '/dev/md/crypt' \ --name 'crypt' \ - --uuid '006234a0:eb29a3a8:471dbd5e:c4bada55' \ + --uuid '00000000:00000000:00000000:000000cc' \ --metadata 1 \ --level 0 \ --raid-devices ${#devices[@]} \ From cbabed20177434796e85c0dea49cae28fc422496 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 28 Dec 2023 11:58:57 +0100 Subject: [PATCH 209/969] dd/bs --- bash/hetzner-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 47d3a73..16b5410 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -254,7 +254,7 @@ function hetzner-rescue-wipe-8-8-0 { | cryptsetup luksOpen '/dev/md/crypt' 'crypt' # wipe crypt dd status='progress' \ - if='/dev/zero' of='/dev/mapper/crypt' bs='16G' + if='/dev/zero' of='/dev/mapper/crypt' bs='8G' } function hetzner-rescue-wipe-8-8-1 { From 02f2f5323c6a1822cde4ec2c36501073b8b0081a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 28 Dec 2023 12:00:25 +0100 Subject: [PATCH 210/969] standalone wipe --- bash/hetzner-rescue.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 16b5410..163589f 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -252,12 +252,15 @@ function hetzner-rescue-wipe-8-8-0 { # open echo "${passphrase}" \ | cryptsetup luksOpen '/dev/md/crypt' 'crypt' +} + +function hetzner-rescue-wipe-8-8-1 { # wipe crypt dd status='progress' \ if='/dev/zero' of='/dev/mapper/crypt' bs='8G' } -function hetzner-rescue-wipe-8-8-1 { +function hetzner-rescue-wipe-8-8-2 { local passphrase # close cryptsetup luksClose 'crypt' From f571ad33079fcd676e4b61f1c88d23124336d7b3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 28 Dec 2023 12:04:51 +0100 Subject: [PATCH 211/969] =?UTF-8?q?=E2=88=92=20lvm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash/hetzner-rescue.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 163589f..682c300 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -284,14 +284,6 @@ function hetzner-rescue-wipe-8-8-2 { # open echo "${passphrase}" \ | cryptsetup luksOpen '/dev/md/crypt' 'crypt' - # pv - pvcreate '/dev/mapper/crypt' - # vg - vgcreate 'crypt' '/dev/mapper/crypt' - # lv swap - lvcreate --name 'swap' --size '137438953472b' 'crypt' - # lv data - lvcreate --name 'data' --extents '100%FREE' 'crypt' # format swap mkswap \ --label 'swap' \ @@ -302,8 +294,6 @@ function hetzner-rescue-wipe-8-8-2 { -L 'data' \ -U '006234a0-eb29-a3a8-471d-bd5ec4bada55' \ '/dev/mapper/crypt-data' - # vg off - vgchange --activate n 'crypt' # close cryptsetup luksClose 'crypt' } From 5ab4a0054a02f79fc85907d0ed2b889902f33b3c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 28 Dec 2023 12:06:27 +0100 Subject: [PATCH 212/969] swap --- bash/hetzner-rescue.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 682c300..2c9ad54 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -284,16 +284,16 @@ function hetzner-rescue-wipe-8-8-2 { # open echo "${passphrase}" \ | cryptsetup luksOpen '/dev/md/crypt' 'crypt' - # format swap - mkswap \ - --label 'swap' \ - -U '06234a0e-b29a-3a84-71db-d5ec4bada557' \ - '/dev/mapper/crypt-swap' # format data mkfs.ext4 \ -L 'data' \ -U '006234a0-eb29-a3a8-471d-bd5ec4bada55' \ '/dev/mapper/crypt-data' + # format swap + mkswap \ + --label 'swap' \ + -U '06234a0e-b29a-3a84-71db-d5ec4bada557' \ + '/dev/mapper/crypt-swap' # close cryptsetup luksClose 'crypt' } From 2b1610bbe69b9b58938a1233e97374da3d17d98a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 28 Dec 2023 12:40:43 +0100 Subject: [PATCH 213/969] crypt/btrfs --- bash/hetzner-rescue.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 2c9ad54..903b0d9 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -189,7 +189,7 @@ function hetzner-rescue-wipe-8-8-0 { mkfs.vfat \ -F 32 \ -S 4096 \ - -i "000000b${number}" \ + -i "0000000${number}" \ -n "esp-${number}" \ "${device}3" done @@ -209,7 +209,7 @@ function hetzner-rescue-wipe-8-8-0 { done mkfs.btrfs --force \ --label 'boot' \ - --uuid '00000000-0000-0000-0000-0000000000b0' \ + --uuid '00000000-0000-0000-0000-00000000000b' \ --checksum 'sha256' \ --data 'raid0' \ "${members[@]}" @@ -230,7 +230,7 @@ function hetzner-rescue-wipe-8-8-0 { mdadm \ --create '/dev/md/crypt' \ --name 'crypt' \ - --uuid '00000000:00000000:00000000:000000cc' \ + --uuid '00000000:00000000:00000000:00000000' \ --metadata 1 \ --level 0 \ --raid-devices ${#devices[@]} \ @@ -285,10 +285,11 @@ function hetzner-rescue-wipe-8-8-2 { echo "${passphrase}" \ | cryptsetup luksOpen '/dev/md/crypt' 'crypt' # format data - mkfs.ext4 \ - -L 'data' \ - -U '006234a0-eb29-a3a8-471d-bd5ec4bada55' \ - '/dev/mapper/crypt-data' + mkfs.btrfs --force \ + --label 'crypt' \ + --uuid '00000000-0000-0000-0000-00000000000c' \ + --checksum 'sha256' \ + '/dev/mapper/crypt' # format swap mkswap \ --label 'swap' \ From ac69623ed3a916b14b70bf31d8048ac7d7d55404 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 28 Dec 2023 12:44:00 +0100 Subject: [PATCH 214/969] crypt/mount --- bash/hetzner-rescue.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 903b0d9..52e9e1f 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -284,12 +284,17 @@ function hetzner-rescue-wipe-8-8-2 { # open echo "${passphrase}" \ | cryptsetup luksOpen '/dev/md/crypt' 'crypt' - # format data + # format crypt mkfs.btrfs --force \ --label 'crypt' \ --uuid '00000000-0000-0000-0000-00000000000c' \ --checksum 'sha256' \ '/dev/mapper/crypt' + # mount crypt + mkdir --parents '/media/crypt' + mount \ + --options 'autodefrag,compress=zstd' \ + '/dev/mapper/crypt' '/media/crypt' # format swap mkswap \ --label 'swap' \ From f8f5bb623dcc818f8b29b93b0c43d32d4a192672 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 28 Dec 2023 12:49:44 +0100 Subject: [PATCH 215/969] crypt/mkswapfile --- bash/hetzner-rescue.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 52e9e1f..e08cba2 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -295,11 +295,11 @@ function hetzner-rescue-wipe-8-8-2 { mount \ --options 'autodefrag,compress=zstd' \ '/dev/mapper/crypt' '/media/crypt' - # format swap - mkswap \ - --label 'swap' \ - -U '06234a0e-b29a-3a84-71db-d5ec4bada557' \ - '/dev/mapper/crypt-swap' + # make swap file + btrfs filesystem mkswapfile \ + --size '64g' \ + --uuid '00000000-0000-0000-0000-000000000005' \ + '/media/crypt/swap' # close cryptsetup luksClose 'crypt' } From d8f56b869c520f6c289de722ca2d877cd0295ab8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 28 Dec 2023 12:56:24 +0100 Subject: [PATCH 216/969] boot/mount --- bash/hetzner-rescue.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index e08cba2..ee50748 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -213,6 +213,11 @@ function hetzner-rescue-wipe-8-8-0 { --checksum 'sha256' \ --data 'raid0' \ "${members[@]}" + # mount boot + mkdir --parents '/media/boot' + mount \ + --options 'autodefrag,compress=zstd' \ + "${members}" '/media/boot' # number=0 for device in "${devices[@]}" ; do From c31db13ebf337c4153206762d843dc3d47867484 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 28 Dec 2023 13:00:10 +0100 Subject: [PATCH 217/969] close --- bash/hetzner-rescue.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index ee50748..3c5b287 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -305,8 +305,13 @@ function hetzner-rescue-wipe-8-8-2 { --size '64g' \ --uuid '00000000-0000-0000-0000-000000000005' \ '/media/crypt/swap' - # close - cryptsetup luksClose 'crypt' +} + +function hetzner-rescue-wipe-8-8-3-close { + umount '/media/boot' + # + umount '/media/crypt' \ + && cryptsetup luksClose 'crypt' } function hetzner-rescue-wipe-12-10-10-0 { From 5a76c09cb127aec1d15dcbed5b411ff99ce99772 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 28 Dec 2023 17:18:17 +0100 Subject: [PATCH 218/969] functions --- bash/hetzner-rescue.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 3c5b287..2f24ca5 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -130,7 +130,7 @@ else fi } -function hetzner-rescue-wipe-8-8-0 { +function hetzner-rescue-wipe-8-8-0-init { local device local devices=( '/dev/sda' @@ -259,13 +259,13 @@ function hetzner-rescue-wipe-8-8-0 { | cryptsetup luksOpen '/dev/md/crypt' 'crypt' } -function hetzner-rescue-wipe-8-8-1 { +function hetzner-rescue-wipe-8-8-1-zero { # wipe crypt dd status='progress' \ if='/dev/zero' of='/dev/mapper/crypt' bs='8G' } -function hetzner-rescue-wipe-8-8-2 { +function hetzner-rescue-wipe-8-8-2-make { local passphrase # close cryptsetup luksClose 'crypt' From ca3dc0c2a8b7d2b977fd6ed7546ea45f9a3b2341 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Dec 2023 08:10:41 +0100 Subject: [PATCH 219/969] duperemove --- bash/hetzner-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 2f24ca5..502610e 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -65,7 +65,7 @@ function hetzner-rescue-install { 'file' 'htop' 'lsof' 'man-db' 'tree' 'uuid-runtime' # install 'lshw' - 'squashfs-tools' + 'duperemove' 'squashfs-tools' 'grub-efi-amd64-bin' 'grub-pc-bin' 'libdigest-sha3-perl' 'micro' 'iotop' From 382d0489d9017899bb506a957ca0888e04af3bda Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Dec 2023 09:39:42 +0100 Subject: [PATCH 220/969] esp/mount --- bash/hetzner-rescue.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 502610e..55d04c9 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -192,6 +192,9 @@ function hetzner-rescue-wipe-8-8-0-init { -i "0000000${number}" \ -n "esp-${number}" \ "${device}3" + # mount esp + mkdir --parents "/media/esp-${number}" + mount "${device}3" "/media/esp-${number}" done # number=0 From f8060698450915329ee1c77bdf44d6f4dd6bc63a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Dec 2023 09:48:24 +0100 Subject: [PATCH 221/969] / --- bash/hetzner-rescue.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 55d04c9..c1e6af8 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -193,8 +193,8 @@ function hetzner-rescue-wipe-8-8-0-init { -n "esp-${number}" \ "${device}3" # mount esp - mkdir --parents "/media/esp-${number}" - mount "${device}3" "/media/esp-${number}" + mkdir --parents "/media/esp/${number}" + mount "${device}3" "/media/esp/${number}" done # number=0 From e6d6487010c3f835ae4ea3f0b9371a652855d579 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Dec 2023 14:11:56 +0100 Subject: [PATCH 222/969] btrfs/compress-force --- bash/hetzner-rescue.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index c1e6af8..58b695e 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -219,7 +219,7 @@ function hetzner-rescue-wipe-8-8-0-init { # mount boot mkdir --parents '/media/boot' mount \ - --options 'autodefrag,compress=zstd' \ + --options 'autodefrag,compress-force=zstd' \ "${members}" '/media/boot' # number=0 @@ -301,7 +301,7 @@ function hetzner-rescue-wipe-8-8-2-make { # mount crypt mkdir --parents '/media/crypt' mount \ - --options 'autodefrag,compress=zstd' \ + --options 'autodefrag,compress-force=zstd' \ '/dev/mapper/crypt' '/media/crypt' # make swap file btrfs filesystem mkswapfile \ From 18fa2453eacea3b7964d1385abdd1b8b2840addf Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Dec 2023 16:12:58 +0100 Subject: [PATCH 223/969] =?UTF-8?q?=E2=88=92=2012-10-10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash/hetzner-rescue.sh | 182 ----------------------------------------- 1 file changed, 182 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 58b695e..c6c4fe5 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -316,185 +316,3 @@ function hetzner-rescue-wipe-8-8-3-close { umount '/media/crypt' \ && cryptsetup luksClose 'crypt' } - -function hetzner-rescue-wipe-12-10-10-0 { - local device - local devices=( - '/dev/sdc' - '/dev/sda' - '/dev/sdb' - ) - local members - local number - local passphrase - local unit='mib' - # read passphrase - echo -n 'PassPhrase: ' - read -r -s passphrase - # - lsblk - echo -n 'WIPE' "${devices[@]}" '/?\ OR CANCEL /!\' - read - # - number=0 - for device in "${devices[@]}" ; do - ((number++)) - echo ; echo "#${number}: ${device}" - # - parted "${device}" --script mktable gpt - # - parted "${device}" unit "${unit}" \ - mkpart "crypt-${number}" 22359 9537535 - # - parted "${device}" unit "${unit}" \ - mkpart "boot-${number}" 513 22359 - # - parted "${device}" unit "${unit}" \ - mkpart "esp-${number}" 2 513 - parted "${device}" set 3 esp on - # - parted "${device}" unit "${unit}" \ - mkpart "bios-${number}" 1 2 - parted "${device}" set 4 bios_grub on - done - # - parted "${device}" unit "${unit}" \ - mkpart 'extra' 9537535 11444223 - # - number=0 - for device in "${devices[@]}" ; do - ((number++)) - echo ; echo "#${number}: ${device}4" - # wipe bios - dd \ - if='/dev/zero' of="${device}4" - done - # - number=0 - for device in "${devices[@]}" ; do - ((number++)) - echo ; echo "#${number}: ${device}3" - # format esp - dd \ - if='/dev/zero' of="${device}3" bs='1M' - mkfs.vfat -F 32 -n "esp-${number}" "${device}3" - done - # - number=0 - for device in "${devices[@]}" ; do - ((number++)) - echo ; echo "#${number}: ${device}2" - # wipe boot - dd status='progress' \ - if='/dev/zero' of="${device}2" bs='1G' - done - # - members=() - for device in "${devices[@]}" ; do - members+=("${device}2") - done - mdadm \ - --create '/dev/md/boot' \ - --name 'boot' \ - --uuid '6234a0eb:29a3a847:1dbd5ec4:bada5579' \ - --metadata 1 \ - --level 0 \ - --raid-devices ${#devices[@]} \ - "${members[@]}" - # - number=0 - for device in "${devices[@]}" ; do - ((number++)) - echo ; echo "#${number}: ${device}1" - # wipe crypt head - dd status='progress' \ - if='/dev/zero' of="${device}1" bs='1G' count=1 - done - # - members=() - for device in "${devices[@]}" ; do - members+=("${device}1") - done - mdadm \ - --create '/dev/md/crypt' \ - --name 'crypt' \ - --uuid '006234a0:eb29a3a8:471dbd5e:c4bada55' \ - --metadata 1 \ - --level 0 \ - --raid-devices ${#devices[@]} \ - "${members[@]}" - # format boot - mkfs.ext4 \ - -F \ - -L 'boot' \ - -U '6234a0eb-29a3-a847-1dbd-5ec4bada5579' \ - '/dev/md/boot' - # encrypt - echo "${passphrase}" \ - | cryptsetup \ - --verbose \ - --batch-mode \ - --type 'luks2' \ - --pbkdf 'argon2id' \ - --cipher 'aes-xts-plain64' \ - --iter-time 8192 \ - --key-size 512 \ - --hash 'sha512' \ - --use-random \ - luksFormat \ - '/dev/md/crypt' - # open - echo "${passphrase}" \ - | cryptsetup luksOpen '/dev/md/crypt' 'crypt' - # wipe crypt - dd status='progress' \ - if='/dev/zero' of='/dev/mapper/crypt' bs='16G' -} - -function hetzner-rescue-wipe-12-10-10-1 { - local passphrase - # close - cryptsetup luksClose 'crypt' - # read passphrase - echo -n 'PassPhrase: ' - read -r -s passphrase - # encrypt - echo "${passphrase}" \ - | cryptsetup \ - --verbose \ - --batch-mode \ - --type 'luks2' \ - --pbkdf 'argon2id' \ - --cipher 'aes-xts-plain64' \ - --iter-time 8192 \ - --key-size 512 \ - --hash 'sha512' \ - --use-random \ - luksFormat \ - '/dev/md/crypt' - # open - echo "${passphrase}" \ - | cryptsetup luksOpen '/dev/md/crypt' 'crypt' - # pv - pvcreate '/dev/mapper/crypt' - # vg - vgcreate 'crypt' '/dev/mapper/crypt' - # lv swap - lvcreate --name 'swap' --size '137438953472b' 'crypt' - # lv data - lvcreate --name 'data' --extents '100%FREE' 'crypt' - # format swap - mkswap \ - --label 'swap' \ - -U '06234a0e-b29a-3a84-71db-d5ec4bada557' \ - '/dev/mapper/crypt-swap' - # format data - mkfs.ext4 \ - -L 'data' \ - -U '006234a0-eb29-a3a8-471d-bd5ec4bada55' \ - '/dev/mapper/crypt-data' - # vg off - vgchange --activate n 'crypt' - # close - cryptsetup luksClose 'crypt' -} From fb02c729768cb1e3044090923e10082997783a1d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 1 Jan 2024 11:37:44 +0100 Subject: [PATCH 224/969] md/boot --- bash/hetzner-rescue.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index c6c4fe5..d437a8b 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -210,17 +210,25 @@ function hetzner-rescue-wipe-8-8-0-init { for device in "${devices[@]}" ; do members+=("${device}2") done + mdadm \ + --create '/dev/md/boot' \ + --name 'boot' \ + --uuid '00000000:00000000:00000000:00000002' \ + --metadata 1 \ + --level 0 \ + --raid-devices ${#devices[@]} \ + "${members[@]}" + # mkfs.btrfs --force \ + --checksum 'sha256' \ --label 'boot' \ --uuid '00000000-0000-0000-0000-00000000000b' \ - --checksum 'sha256' \ - --data 'raid0' \ - "${members[@]}" + '/dev/md/boot' # mount boot mkdir --parents '/media/boot' mount \ --options 'autodefrag,compress-force=zstd' \ - "${members}" '/media/boot' + '/dev/md/boot' '/media/boot' # number=0 for device in "${devices[@]}" ; do @@ -238,7 +246,7 @@ function hetzner-rescue-wipe-8-8-0-init { mdadm \ --create '/dev/md/crypt' \ --name 'crypt' \ - --uuid '00000000:00000000:00000000:00000000' \ + --uuid '00000000:00000000:00000000:00000001' \ --metadata 1 \ --level 0 \ --raid-devices ${#devices[@]} \ @@ -294,9 +302,9 @@ function hetzner-rescue-wipe-8-8-2-make { | cryptsetup luksOpen '/dev/md/crypt' 'crypt' # format crypt mkfs.btrfs --force \ + --checksum 'sha256' \ --label 'crypt' \ --uuid '00000000-0000-0000-0000-00000000000c' \ - --checksum 'sha256' \ '/dev/mapper/crypt' # mount crypt mkdir --parents '/media/crypt' From b272ea2181bc6efa550f33aba5a89f07a8e8c250 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 1 Jan 2024 11:51:31 +0100 Subject: [PATCH 225/969] md/sort --- bash/hetzner-rescue.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index d437a8b..1263588 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -212,11 +212,11 @@ function hetzner-rescue-wipe-8-8-0-init { done mdadm \ --create '/dev/md/boot' \ - --name 'boot' \ - --uuid '00000000:00000000:00000000:00000002' \ - --metadata 1 \ --level 0 \ + --metadata 1 \ + --name 'boot' \ --raid-devices ${#devices[@]} \ + --uuid '00000000:00000000:00000000:00000002' \ "${members[@]}" # mkfs.btrfs --force \ @@ -245,11 +245,11 @@ function hetzner-rescue-wipe-8-8-0-init { done mdadm \ --create '/dev/md/crypt' \ - --name 'crypt' \ - --uuid '00000000:00000000:00000000:00000001' \ - --metadata 1 \ --level 0 \ + --metadata 1 \ + --name 'crypt' \ --raid-devices ${#devices[@]} \ + --uuid '00000000:00000000:00000000:00000001' \ "${members[@]}" # encrypt echo "${passphrase}" \ From 2b654b58f3cc8b47617647fb543b587bee5c78d3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 5 Jan 2024 09:38:25 +0100 Subject: [PATCH 226/969] dhu/crypt --- cs | 3 +-- cs.old | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cs b/cs index 8e8d088..85a53f9 100755 --- a/cs +++ b/cs @@ -5,8 +5,7 @@ NAME="$(basename "${FILE}")" ACTION_OPEN='open' ACTION_CLOSE='close' -DATA_DIRECTORY='/data' -CONTAINERS_DIRECTORY="${DATA_DIRECTORY}/containers" +CONTAINERS_DIRECTORY="/data/home/user/crypt" CONTAINERS_MAP_DIRECTORY='/dev/mapper' CONTAINERS_MOUNT_DIRECTORY='/media' diff --git a/cs.old b/cs.old index 8e8d088..85a53f9 100755 --- a/cs.old +++ b/cs.old @@ -5,8 +5,7 @@ NAME="$(basename "${FILE}")" ACTION_OPEN='open' ACTION_CLOSE='close' -DATA_DIRECTORY='/data' -CONTAINERS_DIRECTORY="${DATA_DIRECTORY}/containers" +CONTAINERS_DIRECTORY="/data/home/user/crypt" CONTAINERS_MAP_DIRECTORY='/dev/mapper' CONTAINERS_MOUNT_DIRECTORY='/media' From 500977a716841d25fabee93be1e5fd031af12c0a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 5 Jan 2024 09:49:18 +0100 Subject: [PATCH 227/969] alias/btrfs --- bash/alias/btrfs.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 bash/alias/btrfs.sh diff --git a/bash/alias/btrfs.sh b/bash/alias/btrfs.sh new file mode 100644 index 0000000..cb3878d --- /dev/null +++ b/bash/alias/btrfs.sh @@ -0,0 +1,42 @@ +alias bfdf="\ +btrfs \ +filesystem \ +df \ +" + +alias bfdu="\ +btrfs \ +filesystem \ +du \ +--summarize \ +" + +alias bfu="\ +btrfs \ +filesystem \ +usage \ +" + +alias bpg="\ +btrfs \ +property \ +get \ +" + +alias bsc="\ +btrfs \ +subvolume \ +create \ +" + +alias bss="\ +btrfs \ +subvolume \ +snapshot \ +" + +alias bssr="\ +btrfs \ +subvolume \ +snapshot -r \ +" From 67e7b951bdad46554bf7a1ee5652abd396f21567 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 5 Jan 2024 16:19:16 +0100 Subject: [PATCH 228/969] default squashfs block size --- bash/mount.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/bash/mount.sh b/bash/mount.sh index e92ecef..250e2b7 100644 --- a/bash/mount.sh +++ b/bash/mount.sh @@ -74,7 +74,6 @@ if [ "${directory}" ] ; then cp overlay/mount/{vmlinuz,initrd.img} "${directory}" mksquashfs \ 'overlay/mount' "${directory}/filesystem.squashfs" \ --b '1M' \ -comp 'zstd' -Xcompression-level "${level}" chown --recursive 1000:1000 "${directory}" fi From 807d4b480da324ea34daf5fdd84363b00e0c923b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 5 Jan 2024 16:22:23 +0100 Subject: [PATCH 229/969] ms/noappend --- bash/mount.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bash/mount.sh b/bash/mount.sh index 250e2b7..c3ee8a3 100644 --- a/bash/mount.sh +++ b/bash/mount.sh @@ -74,6 +74,7 @@ if [ "${directory}" ] ; then cp overlay/mount/{vmlinuz,initrd.img} "${directory}" mksquashfs \ 'overlay/mount' "${directory}/filesystem.squashfs" \ +-noappend \ -comp 'zstd' -Xcompression-level "${level}" chown --recursive 1000:1000 "${directory}" fi From fad8ddc7e2196eea8c96b00870aeb73965547897 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 20 Jan 2024 23:40:49 +0100 Subject: [PATCH 230/969] btrfs/bsd --- bash/alias/btrfs.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bash/alias/btrfs.sh b/bash/alias/btrfs.sh index cb3878d..6b4392c 100644 --- a/bash/alias/btrfs.sh +++ b/bash/alias/btrfs.sh @@ -29,6 +29,12 @@ subvolume \ create \ " +alias bsd="\ +btrfs \ +subvolume \ +delete \ +" + alias bss="\ btrfs \ subvolume \ From 7cb8f7421434c71cac8ac9692479f88d61c163db Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 21 Jan 2024 11:47:18 +0100 Subject: [PATCH 231/969] lsblk/label --- bash/alias/lsblk.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/alias/lsblk.sh b/bash/alias/lsblk.sh index 7ae874a..4d63193 100644 --- a/bash/alias/lsblk.sh +++ b/bash/alias/lsblk.sh @@ -1,12 +1,12 @@ # list block devices alias lb="\ lsblk \ ---output \"NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS\" \ +--output \"NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINTS\" \ --noempty \ " # list block devices (old) alias lbo="\ lsblk \ ---output \"NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT\" \ +--output \"NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINT\" \ " From 5b750c894bb849cc230c91b55052a966b269d7e5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 11 Feb 2024 21:52:22 +0100 Subject: [PATCH 232/969] hetzner mdadm md: --- bash/hetzner-rescue.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/hetzner-rescue.sh b/bash/hetzner-rescue.sh index 1263588..852346f 100644 --- a/bash/hetzner-rescue.sh +++ b/bash/hetzner-rescue.sh @@ -214,7 +214,7 @@ function hetzner-rescue-wipe-8-8-0-init { --create '/dev/md/boot' \ --level 0 \ --metadata 1 \ - --name 'boot' \ + --name 'md:boot' \ --raid-devices ${#devices[@]} \ --uuid '00000000:00000000:00000000:00000002' \ "${members[@]}" @@ -247,7 +247,7 @@ function hetzner-rescue-wipe-8-8-0-init { --create '/dev/md/crypt' \ --level 0 \ --metadata 1 \ - --name 'crypt' \ + --name 'md:crypt' \ --raid-devices ${#devices[@]} \ --uuid '00000000:00000000:00000000:00000001' \ "${members[@]}" From 80a1b907591395df5391d7c1f411973e308a41e4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 16 Feb 2024 16:07:10 +0100 Subject: [PATCH 233/969] log.get_logger --- log/__init__.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 log/__init__.py diff --git a/log/__init__.py b/log/__init__.py new file mode 100644 index 0000000..51454a9 --- /dev/null +++ b/log/__init__.py @@ -0,0 +1,22 @@ +import logging +import sys + + +def get_logger(name: str) -> logging.Logger: + formatter = logging.Formatter( + "%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s" + ) + + # file_handler = logging.FileHandler('log.txt') + # file_handler.setFormatter(formatter) + # file_handler.setLevel(logging.INFO) + + out_handler = logging.StreamHandler(stream=sys.stdout) + out_handler.setFormatter(formatter) + out_handler.setLevel(logging.INFO) + + logger = logging.getLogger(name) + # logger.addHandler(file_handler) + logger.addHandler(out_handler) + logger.setLevel(logging.INFO) + return logger From 51b0f7d662dd67afa78404fd78b1bc099f928bc3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 16 Feb 2024 16:07:36 +0100 Subject: [PATCH 234/969] arg.split --- arg/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arg/__init__.py b/arg/__init__.py index 5db26ae..aa6e4b8 100644 --- a/arg/__init__.py +++ b/arg/__init__.py @@ -2,4 +2,5 @@ import sys def split() -> tuple[str, list[str]]: - return sys.argv[0], sys.argv[1:] + command, *arguments = sys.argv + return command, arguments From 74ef74574573803fc90755fd216c265aeac8bd1c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 16 Feb 2024 19:47:41 +0100 Subject: [PATCH 235/969] pyproject --- pyproject.toml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..2acc2f5 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,30 @@ +[build-system] +requires = ['hatchling'] +build-backend = 'hatchling.build' + +[project] +authors = [ + { name = 'Marc Beninca', email = 'git@marc.beninca.link' }, +] +maintainers = [ + { name = 'Marc Beninca', email = 'git@marc.beninca.link' }, +] +classifiers = [ + 'Programming Language :: Python :: 3', + 'License :: OSI Approved :: GNU Affero General Public License v3', + 'Operating System :: OS Independent', +] +dependencies = [] +description = 'Read Write eXecute' +dynamic = [] +keywords = [] +license = { file = 'license.md' } +name = 'rwx' +readme = 'readme.md' +requires-python = '>=3.9' +version = '0.0.0' + +[project.scripts] +# command = 'module:function' + +[project.urls] From 07a596711d24d558ffb3a428fbde836e9ca85d24 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 16 Feb 2024 19:49:37 +0100 Subject: [PATCH 236/969] lint --- grub/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub/__init__.py b/grub/__init__.py index 5c5f977..3cd293d 100644 --- a/grub/__init__.py +++ b/grub/__init__.py @@ -14,7 +14,7 @@ MODULES = { def make_image(image_format: str, image_path: str, modules: list[str], - memdisk_path: str, pubkey_path: str=None) -> None: + memdisk_path: str, pubkey_path: str = None) -> None: args = [ ('grub-mkimage'), ('--compress', COMPRESSION), From ba03b50992ea4d8c6762955e3e531634a6a03cd3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 16 Feb 2024 21:11:28 +0100 Subject: [PATCH 237/969] cmd --- cmd/__init__.py | 15 +++++++++++++++ cmd/debootstrap/__init__.py | 10 ++++++++++ cmd/squashfs/__init__.py | 14 ++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 cmd/__init__.py create mode 100644 cmd/debootstrap/__init__.py create mode 100644 cmd/squashfs/__init__.py diff --git a/cmd/__init__.py b/cmd/__init__.py new file mode 100644 index 0000000..9403d24 --- /dev/null +++ b/cmd/__init__.py @@ -0,0 +1,15 @@ +commands: list[str] = [] +packages: list[str] = [] + + +def need(command: str) -> None: + match command: + case 'debootstrap': + package = 'debootstrap' + case 'mksquashfs' | 'unsquashfs': + package = 'squashfs-tools' + case _: + package = None + if package: + if package not in packages: + packages.append(package) diff --git a/cmd/debootstrap/__init__.py b/cmd/debootstrap/__init__.py new file mode 100644 index 0000000..f716a3e --- /dev/null +++ b/cmd/debootstrap/__init__.py @@ -0,0 +1,10 @@ +from ... import cmd +from ... import ps + +cmd.need('debootstrap') + + +def debootstrap(input_mirror: str, output_root: str): + ps.run([ + 'debootstrap', + ]) diff --git a/cmd/squashfs/__init__.py b/cmd/squashfs/__init__.py new file mode 100644 index 0000000..8f4b788 --- /dev/null +++ b/cmd/squashfs/__init__.py @@ -0,0 +1,14 @@ +from ... import cmd +from ... import ps + +cmd.need('mksquashfs') + + +def mksquashfs(input_root: str, output_file: str): + ps.run([ + 'mksquashfs', + input_root, + output_file, + '-comp', 'zstd', + '-Xcompression-level', str(18), + ]) From ee53cf87db1312482060d1a4cf8ee803f5ff5ddb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 16 Feb 2024 21:17:02 +0100 Subject: [PATCH 238/969] 3.10 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2acc2f5..28be713 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ keywords = [] license = { file = 'license.md' } name = 'rwx' readme = 'readme.md' -requires-python = '>=3.9' +requires-python = '>=3.10' version = '0.0.0' [project.scripts] From 5112761af5b451bb369f1b89c35049bc6c67c387 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 16 Feb 2024 21:31:38 +0100 Subject: [PATCH 239/969] lint --- cmd/debootstrap/__init__.py | 4 ++-- cmd/squashfs/__init__.py | 4 ++-- fs/__init__.py | 2 +- grub/__init__.py | 5 ++++- project/__init__.py | 2 +- ps/__init__.py | 6 +++--- txt/__init__.py | 2 +- 7 files changed, 14 insertions(+), 11 deletions(-) diff --git a/cmd/debootstrap/__init__.py b/cmd/debootstrap/__init__.py index f716a3e..a2ac674 100644 --- a/cmd/debootstrap/__init__.py +++ b/cmd/debootstrap/__init__.py @@ -1,5 +1,5 @@ -from ... import cmd -from ... import ps +import cmd +import ps cmd.need('debootstrap') diff --git a/cmd/squashfs/__init__.py b/cmd/squashfs/__init__.py index 8f4b788..2d878e9 100644 --- a/cmd/squashfs/__init__.py +++ b/cmd/squashfs/__init__.py @@ -1,5 +1,5 @@ -from ... import cmd -from ... import ps +import cmd +import ps cmd.need('mksquashfs') diff --git a/fs/__init__.py b/fs/__init__.py index 73dd8f0..c222320 100644 --- a/fs/__init__.py +++ b/fs/__init__.py @@ -2,7 +2,7 @@ import os import shutil import subprocess -from .. import ps +import ps CHARSET = 'UTF-8' diff --git a/grub/__init__.py b/grub/__init__.py index 3cd293d..1d5cf4a 100644 --- a/grub/__init__.py +++ b/grub/__init__.py @@ -1,4 +1,7 @@ -from .. import ps +import cmd +import ps + +cmd.need('grub-mkimage') COMPRESSION = 'xz' ENV_BYTES = 1024 diff --git a/project/__init__.py b/project/__init__.py index b03f2c4..4fadc71 100644 --- a/project/__init__.py +++ b/project/__init__.py @@ -10,4 +10,4 @@ class Project: def from_root_file(file_path: str): project_file = os.path.realpath(file_path) project_root = os.path.dirname(project_file) - return Project(real_file) + return Project(project_root) diff --git a/ps/__init__.py b/ps/__init__.py index ddbfb72..c656369 100644 --- a/ps/__init__.py +++ b/ps/__init__.py @@ -1,6 +1,6 @@ import subprocess -from .. import txt +import txt def get_tuples_args(tuples) -> list[str]: @@ -17,12 +17,12 @@ def run(*tuples) -> subprocess.CompletedProcess: return subprocess.run(get_tuples_args(tuples), capture_output=False) -def run_line(*tuples, charset:str=txt.CHARSET) -> str: +def run_line(*tuples, charset:str = txt.CHARSET) -> str: lines = run_lines(*get_tuples_args(tuples), charset=charset) return lines[0] -def run_lines(*tuples, charset:str=txt.CHARSET) -> list[str]: +def run_lines(*tuples, charset:str = txt.CHARSET) -> list[str]: process = subprocess.run(get_tuples_args(tuples), capture_output=True) string = process.stdout.decode(charset) return string.rstrip().splitlines() diff --git a/txt/__init__.py b/txt/__init__.py index 81903f4..edb0624 100644 --- a/txt/__init__.py +++ b/txt/__init__.py @@ -1 +1 @@ -CHARSET='UTF-8' +CHARSET = 'UTF-8' From e11b92e57b7080f86cbf0f0842e1a3857d6eb228 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 16 Feb 2024 21:42:48 +0100 Subject: [PATCH 240/969] dbs --- cmd/debootstrap/__init__.py | 10 ---------- deb.py | 17 ----------------- deb/__init__.py | 20 ++++++++++++++++++++ ps/__init__.py | 4 ++-- 4 files changed, 22 insertions(+), 29 deletions(-) delete mode 100644 cmd/debootstrap/__init__.py delete mode 100644 deb.py create mode 100644 deb/__init__.py diff --git a/cmd/debootstrap/__init__.py b/cmd/debootstrap/__init__.py deleted file mode 100644 index a2ac674..0000000 --- a/cmd/debootstrap/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -import cmd -import ps - -cmd.need('debootstrap') - - -def debootstrap(input_mirror: str, output_root: str): - ps.run([ - 'debootstrap', - ]) diff --git a/deb.py b/deb.py deleted file mode 100644 index 05e72f0..0000000 --- a/deb.py +++ /dev/null @@ -1,17 +0,0 @@ -import subprocess - -BOOTSTRAP_ARCHITECTURE = 'amd64' -BOOTSTRAP_VARIANT = 'minbase' - - -def bootstrap(root_path: str, suite: str, mirror_location: str): - command = [ - 'debootstrap', - '--arch', BOOTSTRAP_ARCHITECTURE, - '--variant', BOOTSTRAP_VARIANT, - suite, - root_path, - mirror_location, - ] - completed_process = subprocess.run(command, capture_output=True) - return completed_process diff --git a/deb/__init__.py b/deb/__init__.py new file mode 100644 index 0000000..a773123 --- /dev/null +++ b/deb/__init__.py @@ -0,0 +1,20 @@ +import cmd +import ps + +cmd.need('debootstrap') + +BOOTSTRAP_ARCHITECTURE = 'amd64' +BOOTSTRAP_VARIANT = 'minbase' + + +def bootstrap(root_path: str, suite: str, mirror_location: str): + command = [ + ('debootstrap',), + ('--arch', BOOTSTRAP_ARCHITECTURE), + ('--variant', BOOTSTRAP_VARIANT), + (suite,), + (root_path,), + (mirror_location,), + ] + completed_process = ps.run(command) + return completed_process diff --git a/ps/__init__.py b/ps/__init__.py index c656369..2290983 100644 --- a/ps/__init__.py +++ b/ps/__init__.py @@ -17,12 +17,12 @@ def run(*tuples) -> subprocess.CompletedProcess: return subprocess.run(get_tuples_args(tuples), capture_output=False) -def run_line(*tuples, charset:str = txt.CHARSET) -> str: +def run_line(*tuples, charset: str = txt.CHARSET) -> str: lines = run_lines(*get_tuples_args(tuples), charset=charset) return lines[0] -def run_lines(*tuples, charset:str = txt.CHARSET) -> list[str]: +def run_lines(*tuples, charset: str = txt.CHARSET) -> list[str]: process = subprocess.run(get_tuples_args(tuples), capture_output=True) string = process.stdout.decode(charset) return string.rstrip().splitlines() From 4961209719b7b05d919b3888ba856bfcbe04deea Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 16 Feb 2024 21:55:09 +0100 Subject: [PATCH 241/969] lint --- fs/__init__.py | 11 +++++------ grub/__init__.py | 6 +++--- log/__init__.py | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/fs/__init__.py b/fs/__init__.py index c222320..56f34db 100644 --- a/fs/__init__.py +++ b/fs/__init__.py @@ -1,6 +1,5 @@ import os import shutil -import subprocess import ps @@ -21,18 +20,18 @@ def empty_file(path: str): def get_mount_uuid(path: str): return ps.run_line( - ('findmnt'), - ('--noheadings'), + ('findmnt',), + ('--noheadings',), ('--output', 'UUID'), - (path), + (path,), ) def get_path_mount(path: str): return ps.run_line( - ('stat'), + ('stat',), ('--format', '%m'), - (path), + (path,), ) diff --git a/grub/__init__.py b/grub/__init__.py index 1d5cf4a..b931ee3 100644 --- a/grub/__init__.py +++ b/grub/__init__.py @@ -10,8 +10,8 @@ ENV_HEADER = f'''{ENV_COMMENT} GRUB Environment Block ''' MODULES = { 'i386-pc': [ - ('biosdisk'), - ('ntldr'), + ('biosdisk',), + ('ntldr',), ] } @@ -19,7 +19,7 @@ MODULES = { def make_image(image_format: str, image_path: str, modules: list[str], memdisk_path: str, pubkey_path: str = None) -> None: args = [ - ('grub-mkimage'), + ('grub-mkimage',), ('--compress', COMPRESSION), ('--format', image_format), ('--output', image_path), diff --git a/log/__init__.py b/log/__init__.py index 51454a9..2cf0b09 100644 --- a/log/__init__.py +++ b/log/__init__.py @@ -4,7 +4,7 @@ import sys def get_logger(name: str) -> logging.Logger: formatter = logging.Formatter( - "%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s" + "%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s" ) # file_handler = logging.FileHandler('log.txt') From 38c00322246d8b285e2aec43a0297c084d6f399f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 16 Feb 2024 22:21:23 +0100 Subject: [PATCH 242/969] args --- ps/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ps/__init__.py b/ps/__init__.py index 2290983..6502b21 100644 --- a/ps/__init__.py +++ b/ps/__init__.py @@ -4,7 +4,7 @@ import txt def get_tuples_args(tuples) -> list[str]: - args = [] + args: list[str] = [] for item in tuples: if type(item) is tuple: args.extend(item) From c3adc9b2ce459e1ea5dfa75a536062d52c31bfbc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 16 Feb 2024 23:25:17 +0100 Subject: [PATCH 243/969] version --- __init__.py | 1 + pyproject.toml | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/__init__.py b/__init__.py index e69de29..c57bfd5 100644 --- a/__init__.py +++ b/__init__.py @@ -0,0 +1 @@ +__version__ = '0.0.0' diff --git a/pyproject.toml b/pyproject.toml index 28be713..207691a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,15 +16,17 @@ classifiers = [ ] dependencies = [] description = 'Read Write eXecute' -dynamic = [] +dynamic = ['version'] keywords = [] license = { file = 'license.md' } name = 'rwx' readme = 'readme.md' requires-python = '>=3.10' -version = '0.0.0' [project.scripts] -# command = 'module:function' +# command = 'package.module:function' [project.urls] + +[tool.hatch.version] +path = '__init__.py' From 97b61209f9b70dccc9da27e500ad6d5507931c72 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 17 Feb 2024 00:12:46 +0100 Subject: [PATCH 244/969] ignore dist --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 87f9698..90c0433 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ __pycache__ /tmp /.idea +/dist From 7702392007354888c6caefa624023fe4a1b8bcd5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 17 Feb 2024 00:13:20 +0100 Subject: [PATCH 245/969] wheel --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 207691a..c95941e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,5 +28,8 @@ requires-python = '>=3.10' [project.urls] +[tool.hatch.build.targets.wheel] +packages = ['.'] + [tool.hatch.version] path = '__init__.py' From ed97c5336b8d12d8f640b854392c3307d2121379 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 17 Feb 2024 00:34:09 +0100 Subject: [PATCH 246/969] source --- pyproject.toml | 4 ++-- __init__.py => src/__init__.py | 0 __main__.py => src/__main__.py | 0 {arg => src/arg}/__init__.py | 0 {cmd => src/cmd}/__init__.py | 0 {cmd => src/cmd}/squashfs/__init__.py | 0 {deb => src/deb}/__init__.py | 0 {fs => src/fs}/__init__.py | 0 {grub => src/grub}/__init__.py | 0 {log => src/log}/__init__.py | 0 {project => src/project}/__init__.py | 0 {ps => src/ps}/__init__.py | 0 {txt => src/txt}/__init__.py | 0 13 files changed, 2 insertions(+), 2 deletions(-) rename __init__.py => src/__init__.py (100%) rename __main__.py => src/__main__.py (100%) rename {arg => src/arg}/__init__.py (100%) rename {cmd => src/cmd}/__init__.py (100%) rename {cmd => src/cmd}/squashfs/__init__.py (100%) rename {deb => src/deb}/__init__.py (100%) rename {fs => src/fs}/__init__.py (100%) rename {grub => src/grub}/__init__.py (100%) rename {log => src/log}/__init__.py (100%) rename {project => src/project}/__init__.py (100%) rename {ps => src/ps}/__init__.py (100%) rename {txt => src/txt}/__init__.py (100%) diff --git a/pyproject.toml b/pyproject.toml index c95941e..ed1cfc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ requires-python = '>=3.10' [project.urls] [tool.hatch.build.targets.wheel] -packages = ['.'] +packages = ['src'] [tool.hatch.version] -path = '__init__.py' +path = 'src/__init__.py' diff --git a/__init__.py b/src/__init__.py similarity index 100% rename from __init__.py rename to src/__init__.py diff --git a/__main__.py b/src/__main__.py similarity index 100% rename from __main__.py rename to src/__main__.py diff --git a/arg/__init__.py b/src/arg/__init__.py similarity index 100% rename from arg/__init__.py rename to src/arg/__init__.py diff --git a/cmd/__init__.py b/src/cmd/__init__.py similarity index 100% rename from cmd/__init__.py rename to src/cmd/__init__.py diff --git a/cmd/squashfs/__init__.py b/src/cmd/squashfs/__init__.py similarity index 100% rename from cmd/squashfs/__init__.py rename to src/cmd/squashfs/__init__.py diff --git a/deb/__init__.py b/src/deb/__init__.py similarity index 100% rename from deb/__init__.py rename to src/deb/__init__.py diff --git a/fs/__init__.py b/src/fs/__init__.py similarity index 100% rename from fs/__init__.py rename to src/fs/__init__.py diff --git a/grub/__init__.py b/src/grub/__init__.py similarity index 100% rename from grub/__init__.py rename to src/grub/__init__.py diff --git a/log/__init__.py b/src/log/__init__.py similarity index 100% rename from log/__init__.py rename to src/log/__init__.py diff --git a/project/__init__.py b/src/project/__init__.py similarity index 100% rename from project/__init__.py rename to src/project/__init__.py diff --git a/ps/__init__.py b/src/ps/__init__.py similarity index 100% rename from ps/__init__.py rename to src/ps/__init__.py diff --git a/txt/__init__.py b/src/txt/__init__.py similarity index 100% rename from txt/__init__.py rename to src/txt/__init__.py From 778f43dadc2cd72860c9b4a5af05d0933eccbd24 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 17 Feb 2024 00:59:37 +0100 Subject: [PATCH 247/969] license-files --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ed1cfc3..0224d2b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ dependencies = [] description = 'Read Write eXecute' dynamic = ['version'] keywords = [] -license = { file = 'license.md' } +license-files = { paths = ['license.md'] } name = 'rwx' readme = 'readme.md' requires-python = '>=3.10' From 508872059ac0154bc8fdfa9e15af1b056bd79154 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 17 Feb 2024 01:35:53 +0100 Subject: [PATCH 248/969] rwx --- pyproject.toml | 5 +---- {src => rwx}/__init__.py | 0 {src => rwx}/__main__.py | 0 {src => rwx}/arg/__init__.py | 0 {src => rwx}/cmd/__init__.py | 0 {src => rwx}/cmd/squashfs/__init__.py | 0 {src => rwx}/deb/__init__.py | 0 {src => rwx}/fs/__init__.py | 0 {src => rwx}/grub/__init__.py | 0 {src => rwx}/log/__init__.py | 0 {src => rwx}/project/__init__.py | 0 {src => rwx}/ps/__init__.py | 0 {src => rwx}/txt/__init__.py | 0 13 files changed, 1 insertion(+), 4 deletions(-) rename {src => rwx}/__init__.py (100%) rename {src => rwx}/__main__.py (100%) rename {src => rwx}/arg/__init__.py (100%) rename {src => rwx}/cmd/__init__.py (100%) rename {src => rwx}/cmd/squashfs/__init__.py (100%) rename {src => rwx}/deb/__init__.py (100%) rename {src => rwx}/fs/__init__.py (100%) rename {src => rwx}/grub/__init__.py (100%) rename {src => rwx}/log/__init__.py (100%) rename {src => rwx}/project/__init__.py (100%) rename {src => rwx}/ps/__init__.py (100%) rename {src => rwx}/txt/__init__.py (100%) diff --git a/pyproject.toml b/pyproject.toml index 0224d2b..139b7eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,8 +28,5 @@ requires-python = '>=3.10' [project.urls] -[tool.hatch.build.targets.wheel] -packages = ['src'] - [tool.hatch.version] -path = 'src/__init__.py' +path = 'rwx/__init__.py' diff --git a/src/__init__.py b/rwx/__init__.py similarity index 100% rename from src/__init__.py rename to rwx/__init__.py diff --git a/src/__main__.py b/rwx/__main__.py similarity index 100% rename from src/__main__.py rename to rwx/__main__.py diff --git a/src/arg/__init__.py b/rwx/arg/__init__.py similarity index 100% rename from src/arg/__init__.py rename to rwx/arg/__init__.py diff --git a/src/cmd/__init__.py b/rwx/cmd/__init__.py similarity index 100% rename from src/cmd/__init__.py rename to rwx/cmd/__init__.py diff --git a/src/cmd/squashfs/__init__.py b/rwx/cmd/squashfs/__init__.py similarity index 100% rename from src/cmd/squashfs/__init__.py rename to rwx/cmd/squashfs/__init__.py diff --git a/src/deb/__init__.py b/rwx/deb/__init__.py similarity index 100% rename from src/deb/__init__.py rename to rwx/deb/__init__.py diff --git a/src/fs/__init__.py b/rwx/fs/__init__.py similarity index 100% rename from src/fs/__init__.py rename to rwx/fs/__init__.py diff --git a/src/grub/__init__.py b/rwx/grub/__init__.py similarity index 100% rename from src/grub/__init__.py rename to rwx/grub/__init__.py diff --git a/src/log/__init__.py b/rwx/log/__init__.py similarity index 100% rename from src/log/__init__.py rename to rwx/log/__init__.py diff --git a/src/project/__init__.py b/rwx/project/__init__.py similarity index 100% rename from src/project/__init__.py rename to rwx/project/__init__.py diff --git a/src/ps/__init__.py b/rwx/ps/__init__.py similarity index 100% rename from src/ps/__init__.py rename to rwx/ps/__init__.py diff --git a/src/txt/__init__.py b/rwx/txt/__init__.py similarity index 100% rename from src/txt/__init__.py rename to rwx/txt/__init__.py From e31a93c8092bedea18fe86096518809c5c221de7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 17 Feb 2024 10:24:41 +0100 Subject: [PATCH 249/969] requires --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 139b7eb..ac386d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ keywords = [] license-files = { paths = ['license.md'] } name = 'rwx' readme = 'readme.md' -requires-python = '>=3.10' +requires-python = '>= 3.10' [project.scripts] # command = 'package.module:function' From b76d7511619e4b518cb72b5e9f03cbf7c9f57997 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Feb 2024 21:57:32 +0100 Subject: [PATCH 250/969] fix license --- license.md | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/license.md b/license.md index cba6f6a..c6f01c6 100644 --- a/license.md +++ b/license.md @@ -1,4 +1,4 @@ -### GNU AFFERO GENERAL PUBLIC LICENSE +# GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 @@ -8,7 +8,7 @@ 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 +## Preamble The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure @@ -59,9 +59,9 @@ under this license. The precise terms and conditions for copying, distribution and modification follow. -### TERMS AND CONDITIONS +## TERMS AND CONDITIONS -#### 0. Definitions. +### 0. Definitions. "This License" refers to version 3 of the GNU Affero General Public License. @@ -102,7 +102,7 @@ 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. +### 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 @@ -143,7 +143,7 @@ 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. +### 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 @@ -168,7 +168,7 @@ 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. +### 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 @@ -184,7 +184,7 @@ 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. +### 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 @@ -197,7 +197,7 @@ 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. +### 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 @@ -232,7 +232,7 @@ 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. +### 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 @@ -328,7 +328,7 @@ 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. +### 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. @@ -387,7 +387,7 @@ 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. +### 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or @@ -415,7 +415,7 @@ 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. +### 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 @@ -426,7 +426,7 @@ 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. +### 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 @@ -451,7 +451,7 @@ rights granted under this License, and you may not initiate litigation any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. -#### 11. Patents. +### 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 @@ -520,7 +520,7 @@ 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. +### 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 @@ -533,7 +533,7 @@ 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. Remote Network Interaction; Use with the GNU General Public License. +### 13. Remote Network Interaction; Use with the GNU General Public License. Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users @@ -554,7 +554,7 @@ License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. -#### 14. Revised Versions of this License. +### 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new @@ -580,7 +580,7 @@ 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. +### 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 @@ -592,7 +592,7 @@ 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. +### 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 @@ -604,7 +604,7 @@ 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. +### 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, @@ -615,7 +615,7 @@ copy of the Program in return for a fee. END OF TERMS AND CONDITIONS -### How to Apply These Terms to Your New Programs +## 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 From 183163bbef55e7a07024ffd59bcfeb59e5a13580 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 27 Feb 2024 21:41:49 +0100 Subject: [PATCH 251/969] squashfs/rwx.cmd --- rwx/cmd/squashfs/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rwx/cmd/squashfs/__init__.py b/rwx/cmd/squashfs/__init__.py index 2d878e9..637890a 100644 --- a/rwx/cmd/squashfs/__init__.py +++ b/rwx/cmd/squashfs/__init__.py @@ -1,7 +1,7 @@ -import cmd import ps +import rwx.cmd -cmd.need('mksquashfs') +rwx.cmd.need('mksquashfs') def mksquashfs(input_root: str, output_file: str): From 2abac376d652d0048b29c7537cbd968d6cbd72fd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 27 Feb 2024 21:59:28 +0100 Subject: [PATCH 252/969] 0.0.1 --- rwx/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rwx/__init__.py b/rwx/__init__.py index c57bfd5..b8023d8 100644 --- a/rwx/__init__.py +++ b/rwx/__init__.py @@ -1 +1 @@ -__version__ = '0.0.0' +__version__ = '0.0.1' From 8e7f6b291df45d9538603961a999b91ffb67531f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 28 Feb 2024 10:58:41 +0100 Subject: [PATCH 253/969] bash/alias --- bash/alias/bash.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bash/alias/bash.sh b/bash/alias/bash.sh index 40500cc..f363670 100644 --- a/bash/alias/bash.sh +++ b/bash/alias/bash.sh @@ -10,6 +10,11 @@ cd \ ../.. \ " +# shorten alias +alias a="\ +alias \ +" + # swap directory (current ↔ previous) alias sd="\ cd \ From 7e55db12177e4237f9aacdf3d4a21a4115cc78ce Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 3 Mar 2024 21:38:04 +0100 Subject: [PATCH 254/969] project,sphinx --- rwx/fs/__init__.py | 2 +- rwx/prj/__init__.py | 8 ++++++++ rwx/prj/sphinx.py | 27 +++++++++++++++++++++++++++ rwx/project/__init__.py | 13 ------------- rwx/ps/__init__.py | 2 +- 5 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 rwx/prj/__init__.py create mode 100644 rwx/prj/sphinx.py delete mode 100644 rwx/project/__init__.py diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 56f34db..ecaebf0 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -1,7 +1,7 @@ import os import shutil -import ps +from rwx import ps CHARSET = 'UTF-8' diff --git a/rwx/prj/__init__.py b/rwx/prj/__init__.py new file mode 100644 index 0000000..f0a2fe5 --- /dev/null +++ b/rwx/prj/__init__.py @@ -0,0 +1,8 @@ +from os import path + + +class Project: + def __init__(self, file_path: str): + self.file: str = path.realpath(file_path) + self.root: str = path.dirname(self.file) + self.name: str = path.basename(self.root) diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py new file mode 100644 index 0000000..290c5d9 --- /dev/null +++ b/rwx/prj/sphinx.py @@ -0,0 +1,27 @@ +from os import path +from sphinx.cmd.build import build_main + +from rwx.fs import wipe +from rwx.prj import Project + + +class SphinxProject(Project): + def __init__(self, file_path: str): + super().__init__(file_path) + + def build(self): + output_root: str = path.join(self.root, 'out') + wipe(output_root) + arguments: list[str] = [ + "-E", + "-j", "2", + "-b", "html", + "-D", "project={}".format(self.name), + "-D", "master_doc={}".format("index"), + "-D", "html_theme={}".format("sphinx_rtd_theme"), + "-c", self.root, + # "-C", + path.join(self.root, self.name), + path.join(output_root, self.name), + ] + build_main(arguments) diff --git a/rwx/project/__init__.py b/rwx/project/__init__.py deleted file mode 100644 index 4fadc71..0000000 --- a/rwx/project/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -import os - - -class Project: - - def __init__(self, root_path: str): - self.root = root_path - - -def from_root_file(file_path: str): - project_file = os.path.realpath(file_path) - project_root = os.path.dirname(project_file) - return Project(project_root) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 6502b21..5b50456 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -1,6 +1,6 @@ import subprocess -import txt +from rwx import txt def get_tuples_args(tuples) -> list[str]: From 865e2cfd916c4a381e96bd64a785f8e7634fc3d8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 4 Mar 2024 11:45:38 +0100 Subject: [PATCH 255/969] f --- rwx/prj/sphinx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py index 290c5d9..4da1ebf 100644 --- a/rwx/prj/sphinx.py +++ b/rwx/prj/sphinx.py @@ -16,7 +16,7 @@ class SphinxProject(Project): "-E", "-j", "2", "-b", "html", - "-D", "project={}".format(self.name), + "-D", f"project={self.name}", "-D", "master_doc={}".format("index"), "-D", "html_theme={}".format("sphinx_rtd_theme"), "-c", self.root, From 850642ac2bb0e4ef28b8f7523175e4ba6b4037bb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Mar 2024 21:14:37 +0100 Subject: [PATCH 256/969] readme --- readme.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/readme.md b/readme.md index e69de29..62420d2 100644 --- a/readme.md +++ b/readme.md @@ -0,0 +1,5 @@ +# Read Write eXecute + +## [English](readme/en.md) + +## [Français](readme/fr.md) From ac9b84fd8a16bee366a8c0b61042663c86f741b0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Mar 2024 21:35:24 +0100 Subject: [PATCH 257/969] rst --- readme.md | 2 +- readme/en.rst | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 readme/en.rst diff --git a/readme.md b/readme.md index 62420d2..58e6958 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ # Read Write eXecute -## [English](readme/en.md) +## [English](readme/en.rst) ## [Français](readme/fr.md) diff --git a/readme/en.rst b/readme/en.rst new file mode 100644 index 0000000..1bd4df6 --- /dev/null +++ b/readme/en.rst @@ -0,0 +1,9 @@ +****************** +Read Write eXecute +****************** + +Why? +==== + +How? +==== From f3ed77372bd1687c02d49261f091cf2463cce82c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Mar 2024 21:43:27 +0100 Subject: [PATCH 258/969] rst --- readme.md | 5 ----- readme.rst | 9 +++++++++ readme/fr.rst | 0 3 files changed, 9 insertions(+), 5 deletions(-) delete mode 100644 readme.md create mode 100644 readme.rst create mode 100644 readme/fr.rst diff --git a/readme.md b/readme.md deleted file mode 100644 index 58e6958..0000000 --- a/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Read Write eXecute - -## [English](readme/en.rst) - -## [Français](readme/fr.md) diff --git a/readme.rst b/readme.rst new file mode 100644 index 0000000..9e15730 --- /dev/null +++ b/readme.rst @@ -0,0 +1,9 @@ +****************** +Read Write eXecute +****************** + +`English `_ +========================== + +`Français `_ +=========================== diff --git a/readme/fr.rst b/readme/fr.rst new file mode 100644 index 0000000..e69de29 From 6e2e0f02559ed7335139d30cb8cb6e83945e7976 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 14 Mar 2024 09:34:04 +0100 Subject: [PATCH 259/969] _ --- readme_en.rst | 5 +++++ readme_fr.rst | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 readme_en.rst create mode 100644 readme_fr.rst diff --git a/readme_en.rst b/readme_en.rst new file mode 100644 index 0000000..c76c511 --- /dev/null +++ b/readme_en.rst @@ -0,0 +1,5 @@ +****************** +Read Write eXecute +****************** + +English diff --git a/readme_fr.rst b/readme_fr.rst new file mode 100644 index 0000000..724f7fe --- /dev/null +++ b/readme_fr.rst @@ -0,0 +1,5 @@ +****************** +Read Write eXecute +****************** + +Français From 0f9a578a02e2f637e0a05cb5329d4db5b4799979 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 14 Mar 2024 10:05:33 +0100 Subject: [PATCH 260/969] /readme --- readme.rst | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 readme.rst diff --git a/readme.rst b/readme.rst deleted file mode 100644 index 9e15730..0000000 --- a/readme.rst +++ /dev/null @@ -1,9 +0,0 @@ -****************** -Read Write eXecute -****************** - -`English `_ -========================== - -`Français `_ -=========================== From f68c8e543b8d2bdecc875fd38f615f06df4b85cf Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 14 Mar 2024 12:31:17 +0100 Subject: [PATCH 261/969] link --- readme.rst | 1 + readme/en.rst | 6 ++---- readme/fr.rst | 7 +++++++ 3 files changed, 10 insertions(+), 4 deletions(-) create mode 120000 readme.rst diff --git a/readme.rst b/readme.rst new file mode 120000 index 0000000..85f011b --- /dev/null +++ b/readme.rst @@ -0,0 +1 @@ +readme/en.rst \ No newline at end of file diff --git a/readme/en.rst b/readme/en.rst index 1bd4df6..21dedd5 100644 --- a/readme/en.rst +++ b/readme/en.rst @@ -2,8 +2,6 @@ Read Write eXecute ****************** -Why? -==== +[English](en.rst) | [Français](fr.rst) -How? -==== +English diff --git a/readme/fr.rst b/readme/fr.rst index e69de29..c19fe26 100644 --- a/readme/fr.rst +++ b/readme/fr.rst @@ -0,0 +1,7 @@ +****************** +Read Write eXecute +****************** + +[English](en.rst) | [Français](fr.rst) + +Français From df54c6ff591018e96867913a3de4f286579c4359 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 14 Mar 2024 12:31:45 +0100 Subject: [PATCH 262/969] nope --- readme_en.rst | 5 ----- readme_fr.rst | 5 ----- 2 files changed, 10 deletions(-) delete mode 100644 readme_en.rst delete mode 100644 readme_fr.rst diff --git a/readme_en.rst b/readme_en.rst deleted file mode 100644 index c76c511..0000000 --- a/readme_en.rst +++ /dev/null @@ -1,5 +0,0 @@ -****************** -Read Write eXecute -****************** - -English diff --git a/readme_fr.rst b/readme_fr.rst deleted file mode 100644 index 724f7fe..0000000 --- a/readme_fr.rst +++ /dev/null @@ -1,5 +0,0 @@ -****************** -Read Write eXecute -****************** - -Français From 07d20f174df414aa999de948af0b5e50d7bc8f25 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 14 Mar 2024 12:35:45 +0100 Subject: [PATCH 263/969] links --- readme/en.rst | 2 +- readme/fr.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/readme/en.rst b/readme/en.rst index 21dedd5..324669d 100644 --- a/readme/en.rst +++ b/readme/en.rst @@ -2,6 +2,6 @@ Read Write eXecute ****************** -[English](en.rst) | [Français](fr.rst) +`English `_ | `Français `_ English diff --git a/readme/fr.rst b/readme/fr.rst index c19fe26..b63edeb 100644 --- a/readme/fr.rst +++ b/readme/fr.rst @@ -2,6 +2,6 @@ Read Write eXecute ****************** -[English](en.rst) | [Français](fr.rst) +`English `_ | `Français `_ Français From 7da521f621dff034fd9ecdbfa44a14e99945939f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 14 Mar 2024 12:37:02 +0100 Subject: [PATCH 264/969] readme/ --- readme/en.rst | 2 +- readme/fr.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/readme/en.rst b/readme/en.rst index 324669d..a3c15d8 100644 --- a/readme/en.rst +++ b/readme/en.rst @@ -2,6 +2,6 @@ Read Write eXecute ****************** -`English `_ | `Français `_ +`English `_ | `Français `_ English diff --git a/readme/fr.rst b/readme/fr.rst index b63edeb..49e50e1 100644 --- a/readme/fr.rst +++ b/readme/fr.rst @@ -2,6 +2,6 @@ Read Write eXecute ****************** -`English `_ | `Français `_ +`English `_ | `Français `_ Français From e43e46ee55fe4e9747a6f9389ce61f284c0e16ee Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 14 Mar 2024 13:52:00 +0100 Subject: [PATCH 265/969] .fr --- readme/fr.rst => readme.fr.rst | 2 +- readme.rst | 8 +++++++- readme/en.rst | 7 ------- 3 files changed, 8 insertions(+), 9 deletions(-) rename readme/fr.rst => readme.fr.rst (54%) mode change 120000 => 100644 readme.rst delete mode 100644 readme/en.rst diff --git a/readme/fr.rst b/readme.fr.rst similarity index 54% rename from readme/fr.rst rename to readme.fr.rst index 49e50e1..c8e6491 100644 --- a/readme/fr.rst +++ b/readme.fr.rst @@ -2,6 +2,6 @@ Read Write eXecute ****************** -`English `_ | `Français `_ +`English `_ | `Français `_ Français diff --git a/readme.rst b/readme.rst deleted file mode 120000 index 85f011b..0000000 --- a/readme.rst +++ /dev/null @@ -1 +0,0 @@ -readme/en.rst \ No newline at end of file diff --git a/readme.rst b/readme.rst new file mode 100644 index 0000000..d13febb --- /dev/null +++ b/readme.rst @@ -0,0 +1,7 @@ +****************** +Read Write eXecute +****************** + +`English `_ | `Français `_ + +English diff --git a/readme/en.rst b/readme/en.rst deleted file mode 100644 index a3c15d8..0000000 --- a/readme/en.rst +++ /dev/null @@ -1,7 +0,0 @@ -****************** -Read Write eXecute -****************** - -`English `_ | `Français `_ - -English From 5776c490599e423df5b2d969fed73465b28e5330 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 14 Mar 2024 15:26:56 +0100 Subject: [PATCH 266/969] ext --- readme.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/readme.rst b/readme.rst index d13febb..954b375 100644 --- a/readme.rst +++ b/readme.rst @@ -1,7 +1,8 @@ -****************** Read Write eXecute -****************** +================== -`English `_ | `Français `_ +`English `_ +--------------------------------- -English +`Français `_ +---------------------------------- From 2765d8738619557948dd14e8e99c3b89c68720ab Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Mar 2024 12:15:57 +0100 Subject: [PATCH 267/969] ls/di --- bash/alias/ls.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bash/alias/ls.sh b/bash/alias/ls.sh index f9a65e5..952bc85 100644 --- a/bash/alias/ls.sh +++ b/bash/alias/ls.sh @@ -1,3 +1,7 @@ +export LS_COLORS="\ +di=0;94\ +" + # list current directory's entries alias l="\ ls \ From 75ff6492914c5bfd10b7438b2835d11635733388 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Mar 2024 12:24:07 +0100 Subject: [PATCH 268/969] tree/t,ta --- bash/alias/tree.sh | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 bash/alias/tree.sh diff --git a/bash/alias/tree.sh b/bash/alias/tree.sh new file mode 100644 index 0000000..2252fc1 --- /dev/null +++ b/bash/alias/tree.sh @@ -0,0 +1,8 @@ +alias t="\ +tree \ +" + +alias ta="\ +tree \ +-a \ +" From 074d9d5a7303d5cb1b21ea4713f5f1e35926d682 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 31 Mar 2024 23:35:16 +0200 Subject: [PATCH 269/969] no gpg agent --- bash/gpg.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/bash/gpg.sh b/bash/gpg.sh index abea396..358b4ca 100644 --- a/bash/gpg.sh +++ b/bash/gpg.sh @@ -1,6 +1,5 @@ if [ ${EUID} -ne 0 ] ; then if [ -f "${HOME}/.gnupg/gpg-agent.conf" ] ; then export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" - gpg-connect-agent updatestartuptty /bye > '/dev/null' fi fi From d2ba729c13813d4fd3180df0e90c4054f40038ac Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 1 Apr 2024 13:52:51 +0200 Subject: [PATCH 270/969] btrfs/bsl --- bash/btrfs.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 bash/btrfs.sh diff --git a/bash/btrfs.sh b/bash/btrfs.sh new file mode 100644 index 0000000..2513eda --- /dev/null +++ b/bash/btrfs.sh @@ -0,0 +1,7 @@ +function bsl { + if [ "${1}" ] ; then + btrfs subvolume list "${1}" \ + | cut -d ' ' -f 9 \ + | sort + fi +} From b969aa886e6d83ce815e36381f0b7d60b3d49057 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 09:34:45 +0200 Subject: [PATCH 271/969] ignore /.vscode --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 90c0433..0800ae8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ __pycache__ /tmp -/.idea +/.vscode /dist From 4ab0a575b7b9439c219e60d3768424d2dc6af40a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 09:35:12 +0200 Subject: [PATCH 272/969] pyproject/ruff --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index ac386d1..2c1938b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,3 +30,6 @@ requires-python = '>= 3.10' [tool.hatch.version] path = 'rwx/__init__.py' + +[tool.ruff] +select = ["ALL"] From 566617758228ea575e0f518f0388e7ae15ec9d16 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 09:37:23 +0200 Subject: [PATCH 273/969] pyproject/" --- pyproject.toml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2c1938b..ccd0aa1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,35 +1,35 @@ [build-system] -requires = ['hatchling'] -build-backend = 'hatchling.build' +requires = ["hatchling"] +build-backend = "hatchling.build" [project] authors = [ - { name = 'Marc Beninca', email = 'git@marc.beninca.link' }, + { name = "Marc Beninca", email = "git@marc.beninca.link" }, ] maintainers = [ - { name = 'Marc Beninca', email = 'git@marc.beninca.link' }, + { name = "Marc Beninca", email = "git@marc.beninca.link" }, ] classifiers = [ - 'Programming Language :: Python :: 3', - 'License :: OSI Approved :: GNU Affero General Public License v3', - 'Operating System :: OS Independent', + "Programming Language :: Python :: 3", + "License :: OSI Approved :: GNU Affero General Public License v3", + "Operating System :: OS Independent", ] dependencies = [] -description = 'Read Write eXecute' -dynamic = ['version'] +description = "Read Write eXecute" +dynamic = ["version"] keywords = [] -license-files = { paths = ['license.md'] } -name = 'rwx' -readme = 'readme.md' -requires-python = '>= 3.10' +license-files = { paths = ["license.md"] } +name = "rwx" +readme = "readme.md" +requires-python = ">= 3.10" [project.scripts] -# command = 'package.module:function' +# command = "package.module:function" [project.urls] [tool.hatch.version] -path = 'rwx/__init__.py' +path = "rwx/__init__.py" [tool.ruff] select = ["ALL"] From b197a156896d0e8cae8869122e05a1f4d5434027 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 09:38:08 +0200 Subject: [PATCH 274/969] linting --- rwx/prj/sphinx.py | 2 +- rwx/txt/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py index 4da1ebf..392e7c2 100644 --- a/rwx/prj/sphinx.py +++ b/rwx/prj/sphinx.py @@ -10,7 +10,7 @@ class SphinxProject(Project): super().__init__(file_path) def build(self): - output_root: str = path.join(self.root, 'out') + output_root: str = path.join(self.root, "out") wipe(output_root) arguments: list[str] = [ "-E", diff --git a/rwx/txt/__init__.py b/rwx/txt/__init__.py index edb0624..369202c 100644 --- a/rwx/txt/__init__.py +++ b/rwx/txt/__init__.py @@ -1 +1 @@ -CHARSET = 'UTF-8' +CHARSET = "UTF-8" From fdbd850d231104fc6264536e2ef7d082152adf9e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 09:41:34 +0200 Subject: [PATCH 275/969] lint rwx --- rwx/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rwx/__init__.py b/rwx/__init__.py index b8023d8..a721b9a 100644 --- a/rwx/__init__.py +++ b/rwx/__init__.py @@ -1 +1,2 @@ -__version__ = '0.0.1' +"""Read Write eXecute.""" +__version__ = "0.0.1" From a4f49d6ac09549d958588b3eec84cedcaaa0c412 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 09:43:22 +0200 Subject: [PATCH 276/969] exception --- rwx/err/__init__.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 rwx/err/__init__.py diff --git a/rwx/err/__init__.py b/rwx/err/__init__.py new file mode 100644 index 0000000..b996913 --- /dev/null +++ b/rwx/err/__init__.py @@ -0,0 +1,2 @@ +class Exception(Exception): + pass From c7db231dc2a5e6244e06dea770a4cb3f6a6ce430 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 09:50:13 +0200 Subject: [PATCH 277/969] lint grub --- rwx/grub/__init__.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/rwx/grub/__init__.py b/rwx/grub/__init__.py index b931ee3..a11cf7d 100644 --- a/rwx/grub/__init__.py +++ b/rwx/grub/__init__.py @@ -1,17 +1,17 @@ import cmd import ps -cmd.need('grub-mkimage') +cmd.need("grub-mkimage") -COMPRESSION = 'xz' +COMPRESSION = "xz" ENV_BYTES = 1024 -ENV_COMMENT = '#' -ENV_HEADER = f'''{ENV_COMMENT} GRUB Environment Block -''' +ENV_COMMENT = "#" +ENV_HEADER = f"""{ENV_COMMENT} GRUB Environment Block +""" MODULES = { - 'i386-pc': [ - ('biosdisk',), - ('ntldr',), + "i386-pc": [ + ("biosdisk",), + ("ntldr",), ] } @@ -19,14 +19,14 @@ MODULES = { def make_image(image_format: str, image_path: str, modules: list[str], memdisk_path: str, pubkey_path: str = None) -> None: args = [ - ('grub-mkimage',), - ('--compress', COMPRESSION), - ('--format', image_format), - ('--output', image_path), - ('--memdisk', memdisk_path), + ("grub-mkimage",), + ("--compress", COMPRESSION), + ("--format", image_format), + ("--output", image_path), + ("--memdisk", memdisk_path), ] if pubkey_path: - args.append(('--pubkey', pubkey_path)) + args.append(("--pubkey", pubkey_path)) args.extend(modules) if modules := MODULES.get(image_format, None): args.extend(modules) From 592023d2140ea11b5b854072a6893bbe8d8973f6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 09:51:59 +0200 Subject: [PATCH 278/969] lint fs --- rwx/fs/__init__.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index ecaebf0..2a6af2c 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -3,13 +3,13 @@ import shutil from rwx import ps -CHARSET = 'UTF-8' +CHARSET = "UTF-8" def create_image(file_path: str, size_bytes: int): ps.run( - ('qemu-img', 'create'), - ('-f', 'qcow2'), + ("qemu-img", "create"), + ("-f", "qcow2"), (file_path, size_bytes), ) @@ -20,17 +20,17 @@ def empty_file(path: str): def get_mount_uuid(path: str): return ps.run_line( - ('findmnt',), - ('--noheadings',), - ('--output', 'UUID'), + ("findmnt",), + ("--noheadings",), + ("--output", "UUID"), (path,), ) def get_path_mount(path: str): return ps.run_line( - ('stat',), - ('--format', '%m'), + ("stat",), + ("--format", "%m"), (path,), ) @@ -44,7 +44,7 @@ def make_directory(path: str): def read_file(file_path: str): - with open(file_path, 'br') as file_object: + with open(file_path, "br") as file_object: return file_object.read() @@ -66,5 +66,5 @@ def wipe(path: str): def write(file_path: str, text: str, charset=CHARSET): - with open(file_path, 'bw') as file_object: + with open(file_path, "bw") as file_object: file_object.write(text.encode(charset)) From 470d7aa1e92480ff9e9fa8ccfeb6a2bbd5b4b2e3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 09:52:56 +0200 Subject: [PATCH 279/969] lint deb --- rwx/deb/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rwx/deb/__init__.py b/rwx/deb/__init__.py index a773123..7059e93 100644 --- a/rwx/deb/__init__.py +++ b/rwx/deb/__init__.py @@ -1,17 +1,17 @@ import cmd import ps -cmd.need('debootstrap') +cmd.need("debootstrap") -BOOTSTRAP_ARCHITECTURE = 'amd64' -BOOTSTRAP_VARIANT = 'minbase' +BOOTSTRAP_ARCHITECTURE = "amd64" +BOOTSTRAP_VARIANT = "minbase" def bootstrap(root_path: str, suite: str, mirror_location: str): command = [ - ('debootstrap',), - ('--arch', BOOTSTRAP_ARCHITECTURE), - ('--variant', BOOTSTRAP_VARIANT), + ("debootstrap",), + ("--arch", BOOTSTRAP_ARCHITECTURE), + ("--variant", BOOTSTRAP_VARIANT), (suite,), (root_path,), (mirror_location,), From 67b8d4c9819ad3f1f6f2166b4d757f03e656e16e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 09:53:51 +0200 Subject: [PATCH 280/969] lint squashfs --- rwx/cmd/squashfs/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rwx/cmd/squashfs/__init__.py b/rwx/cmd/squashfs/__init__.py index 637890a..4f793ca 100644 --- a/rwx/cmd/squashfs/__init__.py +++ b/rwx/cmd/squashfs/__init__.py @@ -1,14 +1,14 @@ import ps import rwx.cmd -rwx.cmd.need('mksquashfs') +rwx.cmd.need("mksquashfs") def mksquashfs(input_root: str, output_file: str): ps.run([ - 'mksquashfs', + "mksquashfs", input_root, output_file, - '-comp', 'zstd', - '-Xcompression-level', str(18), + "-comp", "zstd", + "-Xcompression-level", str(18), ]) From bf5a8a65d781c416aba5f6684150421bf8176893 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 09:55:13 +0200 Subject: [PATCH 281/969] lint cmd --- rwx/cmd/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rwx/cmd/__init__.py b/rwx/cmd/__init__.py index 9403d24..6ecb47c 100644 --- a/rwx/cmd/__init__.py +++ b/rwx/cmd/__init__.py @@ -4,10 +4,10 @@ packages: list[str] = [] def need(command: str) -> None: match command: - case 'debootstrap': - package = 'debootstrap' - case 'mksquashfs' | 'unsquashfs': - package = 'squashfs-tools' + case "debootstrap": + package = "debootstrap" + case "mksquashfs" | "unsquashfs": + package = "squashfs-tools" case _: package = None if package: From 517da87ffb51c2577a388a42c9627f8775516317 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 09:56:59 +0200 Subject: [PATCH 282/969] lint main --- rwx/__main__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rwx/__main__.py b/rwx/__main__.py index 0f73041..0f15b2e 100755 --- a/rwx/__main__.py +++ b/rwx/__main__.py @@ -5,14 +5,14 @@ import os import fs -if __name__ == '__main__': +if __name__ == "__main__": file_path = os.path.realpath(__file__) root_path = os.path.dirname(file_path) - directory_path = os.path.join(root_path, 'tmp') - file_path = os.path.join(directory_path, 'file') + directory_path = os.path.join(root_path, "tmp") + file_path = os.path.join(directory_path, "file") fs.wipe(directory_path) fs.make_directory(directory_path) - fs.write(file_path, 'Martine écrit beaucoup.') + fs.write(file_path, "Martine écrit beaucoup.") fs.empty_file(file_path) - fs.write(file_path, 'Martine écrit moins.') + fs.write(file_path, "Martine écrit moins.") From e84417c077d0bdd489a93c4703bf5bd3738e09a1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 10:01:24 +0200 Subject: [PATCH 283/969] lint fs --- rwx/fs/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 2a6af2c..e769358 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -15,7 +15,7 @@ def create_image(file_path: str, size_bytes: int): def empty_file(path: str): - write(path, str()) + write(path, "") def get_mount_uuid(path: str): From fc3e191dc1aacd97f974836b8584cccae8572153 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 10:04:54 +0200 Subject: [PATCH 284/969] lint prj --- rwx/prj/__init__.py | 2 +- rwx/prj/sphinx.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rwx/prj/__init__.py b/rwx/prj/__init__.py index f0a2fe5..227a686 100644 --- a/rwx/prj/__init__.py +++ b/rwx/prj/__init__.py @@ -2,7 +2,7 @@ from os import path class Project: - def __init__(self, file_path: str): + def __init__(self, file_path: str) -> None: self.file: str = path.realpath(file_path) self.root: str = path.dirname(self.file) self.name: str = path.basename(self.root) diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py index 392e7c2..a71bc35 100644 --- a/rwx/prj/sphinx.py +++ b/rwx/prj/sphinx.py @@ -6,7 +6,7 @@ from rwx.prj import Project class SphinxProject(Project): - def __init__(self, file_path: str): + def __init__(self, file_path: str) -> None: super().__init__(file_path) def build(self): From b44b6bd4d4e2c39d545e6314b5019c59755fcaa0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 10:06:25 +0200 Subject: [PATCH 285/969] lint deb --- rwx/deb/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rwx/deb/__init__.py b/rwx/deb/__init__.py index 7059e93..bfb8a2f 100644 --- a/rwx/deb/__init__.py +++ b/rwx/deb/__init__.py @@ -16,5 +16,4 @@ def bootstrap(root_path: str, suite: str, mirror_location: str): (root_path,), (mirror_location,), ] - completed_process = ps.run(command) - return completed_process + return ps.run(command) From c7022836966379a640d007c2d8db8fd03d9f7d73 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 12:49:49 +0200 Subject: [PATCH 286/969] lint commas --- rwx/grub/__init__.py | 2 +- rwx/log/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rwx/grub/__init__.py b/rwx/grub/__init__.py index a11cf7d..3a70ad4 100644 --- a/rwx/grub/__init__.py +++ b/rwx/grub/__init__.py @@ -12,7 +12,7 @@ MODULES = { "i386-pc": [ ("biosdisk",), ("ntldr",), - ] + ], } diff --git a/rwx/log/__init__.py b/rwx/log/__init__.py index 2cf0b09..4d28f82 100644 --- a/rwx/log/__init__.py +++ b/rwx/log/__init__.py @@ -4,7 +4,7 @@ import sys def get_logger(name: str) -> logging.Logger: formatter = logging.Formatter( - "%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s" + "%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s", ) # file_handler = logging.FileHandler('log.txt') From aad5c140ddec8c365e3cd3f86a8cff14e50fb758 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 12:52:19 +0200 Subject: [PATCH 287/969] =?UTF-8?q?=E2=88=92#?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rwx/log/__init__.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/rwx/log/__init__.py b/rwx/log/__init__.py index 4d28f82..b951ac9 100644 --- a/rwx/log/__init__.py +++ b/rwx/log/__init__.py @@ -1,22 +1,16 @@ import logging import sys - - def get_logger(name: str) -> logging.Logger: formatter = logging.Formatter( "%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s", ) - - # file_handler = logging.FileHandler('log.txt') - # file_handler.setFormatter(formatter) - # file_handler.setLevel(logging.INFO) - + # out_handler = logging.StreamHandler(stream=sys.stdout) out_handler.setFormatter(formatter) out_handler.setLevel(logging.INFO) - + # logger = logging.getLogger(name) - # logger.addHandler(file_handler) logger.addHandler(out_handler) logger.setLevel(logging.INFO) + # return logger From 9349775193ac5f90364ce8287eb95748cd75fc19 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 15:23:05 +0200 Subject: [PATCH 288/969] log/stream --- rwx/log/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rwx/log/__init__.py b/rwx/log/__init__.py index b951ac9..a567492 100644 --- a/rwx/log/__init__.py +++ b/rwx/log/__init__.py @@ -1,6 +1,6 @@ import logging import sys -def get_logger(name: str) -> logging.Logger: +def get_file_logger(name: str) -> logging.Logger: formatter = logging.Formatter( "%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s", ) @@ -14,3 +14,13 @@ def get_logger(name: str) -> logging.Logger: logger.setLevel(logging.INFO) # return logger +def get_stream_logger() -> logging.Logger: + out_handler = logging.StreamHandler(stream=sys.stdout) + out_handler.setLevel(logging.INFO) + # + logger = logging.getLogger() + logger.addHandler(out_handler) + logger.setLevel(logging.INFO) + # + return logger +stream = get_stream_logger() From adbdf47ef49c5963cea2c4a38fe1c26e603205b7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 15:27:33 +0200 Subject: [PATCH 289/969] lint |None --- rwx/grub/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rwx/grub/__init__.py b/rwx/grub/__init__.py index 3a70ad4..7690a49 100644 --- a/rwx/grub/__init__.py +++ b/rwx/grub/__init__.py @@ -17,7 +17,7 @@ MODULES = { def make_image(image_format: str, image_path: str, modules: list[str], - memdisk_path: str, pubkey_path: str = None) -> None: + memdisk_path: str, pubkey_path: str | None = None) -> None: args = [ ("grub-mkimage",), ("--compress", COMPRESSION), From 88434db29aa09c7175cece250bb39d4df75e4035 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 15:31:15 +0200 Subject: [PATCH 290/969] lint fix --- rwx/__main__.py | 1 - rwx/cmd/__init__.py | 5 ++--- rwx/cmd/squashfs/__init__.py | 1 + rwx/deb/__init__.py | 1 + rwx/grub/__init__.py | 1 + rwx/log/__init__.py | 2 ++ rwx/prj/sphinx.py | 1 + 7 files changed, 8 insertions(+), 4 deletions(-) diff --git a/rwx/__main__.py b/rwx/__main__.py index 0f15b2e..a857803 100755 --- a/rwx/__main__.py +++ b/rwx/__main__.py @@ -4,7 +4,6 @@ import os import fs - if __name__ == "__main__": file_path = os.path.realpath(__file__) root_path = os.path.dirname(file_path) diff --git a/rwx/cmd/__init__.py b/rwx/cmd/__init__.py index 6ecb47c..de764fa 100644 --- a/rwx/cmd/__init__.py +++ b/rwx/cmd/__init__.py @@ -10,6 +10,5 @@ def need(command: str) -> None: package = "squashfs-tools" case _: package = None - if package: - if package not in packages: - packages.append(package) + if package and package not in packages: + packages.append(package) diff --git a/rwx/cmd/squashfs/__init__.py b/rwx/cmd/squashfs/__init__.py index 4f793ca..343461e 100644 --- a/rwx/cmd/squashfs/__init__.py +++ b/rwx/cmd/squashfs/__init__.py @@ -1,4 +1,5 @@ import ps + import rwx.cmd rwx.cmd.need("mksquashfs") diff --git a/rwx/deb/__init__.py b/rwx/deb/__init__.py index bfb8a2f..e9c6a9e 100644 --- a/rwx/deb/__init__.py +++ b/rwx/deb/__init__.py @@ -1,4 +1,5 @@ import cmd + import ps cmd.need("debootstrap") diff --git a/rwx/grub/__init__.py b/rwx/grub/__init__.py index 7690a49..57e313c 100644 --- a/rwx/grub/__init__.py +++ b/rwx/grub/__init__.py @@ -1,4 +1,5 @@ import cmd + import ps cmd.need("grub-mkimage") diff --git a/rwx/log/__init__.py b/rwx/log/__init__.py index a567492..3502ab5 100644 --- a/rwx/log/__init__.py +++ b/rwx/log/__init__.py @@ -1,5 +1,7 @@ import logging import sys + + def get_file_logger(name: str) -> logging.Logger: formatter = logging.Formatter( "%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s", diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py index a71bc35..ccb8d0f 100644 --- a/rwx/prj/sphinx.py +++ b/rwx/prj/sphinx.py @@ -1,4 +1,5 @@ from os import path + from sphinx.cmd.build import build_main from rwx.fs import wipe From a5ca3a60440d740a4d6b67e255c2d6c777a027c0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 15:39:39 +0200 Subject: [PATCH 291/969] lint main --- rwx/__main__.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/rwx/__main__.py b/rwx/__main__.py index a857803..519fb8e 100755 --- a/rwx/__main__.py +++ b/rwx/__main__.py @@ -1,14 +1,11 @@ #! /usr/bin/env python3 - -import os - +from pathlib import Path import fs - if __name__ == "__main__": - file_path = os.path.realpath(__file__) - root_path = os.path.dirname(file_path) - directory_path = os.path.join(root_path, "tmp") - file_path = os.path.join(directory_path, "file") + file_path = Path(__file__).resolve() + root_path = file_path.parent + directory_path = root_path / "tmp" + file_path = directory_path / "file" fs.wipe(directory_path) fs.make_directory(directory_path) From df2537dd6dfcb50e58679e49f77a13113c664d81 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 15:43:59 +0200 Subject: [PATCH 292/969] main/imports --- rwx/__main__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rwx/__main__.py b/rwx/__main__.py index 519fb8e..ddeeba8 100755 --- a/rwx/__main__.py +++ b/rwx/__main__.py @@ -1,6 +1,8 @@ #! /usr/bin/env python3 from pathlib import Path + import fs + if __name__ == "__main__": file_path = Path(__file__).resolve() root_path = file_path.parent From d23bbdd7c91ca1ed463b95a7d597af755771dabe Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 18:02:49 +0200 Subject: [PATCH 293/969] entry point --- rwx/__main__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rwx/__main__.py b/rwx/__main__.py index ddeeba8..f6276e4 100755 --- a/rwx/__main__.py +++ b/rwx/__main__.py @@ -1,4 +1,7 @@ #! /usr/bin/env python3 + +"""Entry point.""" + from pathlib import Path import fs From 2648c2e6ba21172942e7503f2001f15a27f17f35 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 12 Jun 2024 14:43:26 +0200 Subject: [PATCH 294/969] /.venv --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0800ae8..4909e08 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ __pycache__ /tmp +/.venv /.vscode /dist From 7d0ffb8a656260c229607d3df197344293ab3630 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 12 Jun 2024 14:45:30 +0200 Subject: [PATCH 295/969] ruff/lint --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ccd0aa1..a9f4af7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,5 +31,6 @@ requires-python = ">= 3.10" [tool.hatch.version] path = "rwx/__init__.py" -[tool.ruff] +[tool.ruff.lint] +ignore = ["COM812", "D203", "D213", "ISC001"] select = ["ALL"] From 0a035f2cd67855ccffb83bbd3ebf0a14a1cac52c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 12 Jun 2024 14:46:34 +0200 Subject: [PATCH 296/969] ruff/format --- rwx/__init__.py | 1 + rwx/cmd/squashfs/__init__.py | 18 +++++++++++------- rwx/grub/__init__.py | 9 +++++++-- rwx/log/__init__.py | 4 ++++ rwx/prj/sphinx.py | 18 ++++++++++++------ 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/rwx/__init__.py b/rwx/__init__.py index a721b9a..a1c5ee6 100644 --- a/rwx/__init__.py +++ b/rwx/__init__.py @@ -1,2 +1,3 @@ """Read Write eXecute.""" + __version__ = "0.0.1" diff --git a/rwx/cmd/squashfs/__init__.py b/rwx/cmd/squashfs/__init__.py index 343461e..322186c 100644 --- a/rwx/cmd/squashfs/__init__.py +++ b/rwx/cmd/squashfs/__init__.py @@ -6,10 +6,14 @@ rwx.cmd.need("mksquashfs") def mksquashfs(input_root: str, output_file: str): - ps.run([ - "mksquashfs", - input_root, - output_file, - "-comp", "zstd", - "-Xcompression-level", str(18), - ]) + ps.run( + [ + "mksquashfs", + input_root, + output_file, + "-comp", + "zstd", + "-Xcompression-level", + str(18), + ] + ) diff --git a/rwx/grub/__init__.py b/rwx/grub/__init__.py index 57e313c..2b44e57 100644 --- a/rwx/grub/__init__.py +++ b/rwx/grub/__init__.py @@ -17,8 +17,13 @@ MODULES = { } -def make_image(image_format: str, image_path: str, modules: list[str], - memdisk_path: str, pubkey_path: str | None = None) -> None: +def make_image( + image_format: str, + image_path: str, + modules: list[str], + memdisk_path: str, + pubkey_path: str | None = None, +) -> None: args = [ ("grub-mkimage",), ("--compress", COMPRESSION), diff --git a/rwx/log/__init__.py b/rwx/log/__init__.py index 3502ab5..fcf01aa 100644 --- a/rwx/log/__init__.py +++ b/rwx/log/__init__.py @@ -16,6 +16,8 @@ def get_file_logger(name: str) -> logging.Logger: logger.setLevel(logging.INFO) # return logger + + def get_stream_logger() -> logging.Logger: out_handler = logging.StreamHandler(stream=sys.stdout) out_handler.setLevel(logging.INFO) @@ -25,4 +27,6 @@ def get_stream_logger() -> logging.Logger: logger.setLevel(logging.INFO) # return logger + + stream = get_stream_logger() diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py index ccb8d0f..b09d8ee 100644 --- a/rwx/prj/sphinx.py +++ b/rwx/prj/sphinx.py @@ -15,12 +15,18 @@ class SphinxProject(Project): wipe(output_root) arguments: list[str] = [ "-E", - "-j", "2", - "-b", "html", - "-D", f"project={self.name}", - "-D", "master_doc={}".format("index"), - "-D", "html_theme={}".format("sphinx_rtd_theme"), - "-c", self.root, + "-j", + "2", + "-b", + "html", + "-D", + f"project={self.name}", + "-D", + "master_doc={}".format("index"), + "-D", + "html_theme={}".format("sphinx_rtd_theme"), + "-c", + self.root, # "-C", path.join(self.root, self.name), path.join(output_root, self.name), From 73dc9598b78436df12ff069da1063a285be412d4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 12 Jun 2024 14:48:37 +0200 Subject: [PATCH 297/969] useless --- rwx/grub/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rwx/grub/__init__.py b/rwx/grub/__init__.py index 2b44e57..cd016ab 100644 --- a/rwx/grub/__init__.py +++ b/rwx/grub/__init__.py @@ -34,6 +34,6 @@ def make_image( if pubkey_path: args.append(("--pubkey", pubkey_path)) args.extend(modules) - if modules := MODULES.get(image_format, None): + if modules := MODULES.get(image_format): args.extend(modules) ps.run(*args) From 959107c245f3ede7ea0f728d7c6af6ae028cecaf Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 12 Jun 2024 14:52:55 +0200 Subject: [PATCH 298/969] run/check --- rwx/ps/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 5b50456..6471fff 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -14,7 +14,7 @@ def get_tuples_args(tuples) -> list[str]: def run(*tuples) -> subprocess.CompletedProcess: - return subprocess.run(get_tuples_args(tuples), capture_output=False) + return subprocess.run(get_tuples_args(tuples), capture_output=False, check=True) def run_line(*tuples, charset: str = txt.CHARSET) -> str: @@ -23,6 +23,6 @@ def run_line(*tuples, charset: str = txt.CHARSET) -> str: def run_lines(*tuples, charset: str = txt.CHARSET) -> list[str]: - process = subprocess.run(get_tuples_args(tuples), capture_output=True) + process = subprocess.run(get_tuples_args(tuples), capture_output=True, check=True) string = process.stdout.decode(charset) return string.rstrip().splitlines() From 4414a9a7120c1a9c4a5af211c082b181c65696b6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 12 Jun 2024 14:54:59 +0200 Subject: [PATCH 299/969] ruff/line-length --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index a9f4af7..66a3933 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,9 @@ requires-python = ">= 3.10" [tool.hatch.version] path = "rwx/__init__.py" +[tool.ruff] +line-length = 80 + [tool.ruff.lint] ignore = ["COM812", "D203", "D213", "ISC001"] select = ["ALL"] From 3ce03d17c14161fb04c53fb0cae89b256db8debc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 12 Jun 2024 14:55:37 +0200 Subject: [PATCH 300/969] fix --- rwx/ps/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 6471fff..b66c21b 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -14,7 +14,9 @@ def get_tuples_args(tuples) -> list[str]: def run(*tuples) -> subprocess.CompletedProcess: - return subprocess.run(get_tuples_args(tuples), capture_output=False, check=True) + return subprocess.run( + get_tuples_args(tuples), capture_output=False, check=True + ) def run_line(*tuples, charset: str = txt.CHARSET) -> str: @@ -23,6 +25,8 @@ def run_line(*tuples, charset: str = txt.CHARSET) -> str: def run_lines(*tuples, charset: str = txt.CHARSET) -> list[str]: - process = subprocess.run(get_tuples_args(tuples), capture_output=True, check=True) + process = subprocess.run( + get_tuples_args(tuples), capture_output=True, check=True + ) string = process.stdout.decode(charset) return string.rstrip().splitlines() From 282e2ac7a1490bcdf748d6c66580c555f584bc0b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 13 Jun 2024 10:16:53 +0200 Subject: [PATCH 301/969] log/level --- rwx/log/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rwx/log/__init__.py b/rwx/log/__init__.py index fcf01aa..50048e5 100644 --- a/rwx/log/__init__.py +++ b/rwx/log/__init__.py @@ -18,15 +18,15 @@ def get_file_logger(name: str) -> logging.Logger: return logger -def get_stream_logger() -> logging.Logger: +def get_stream_logger(level: int) -> logging.Logger: out_handler = logging.StreamHandler(stream=sys.stdout) - out_handler.setLevel(logging.INFO) + out_handler.setLevel(level) # logger = logging.getLogger() logger.addHandler(out_handler) - logger.setLevel(logging.INFO) + logger.setLevel(level) # return logger -stream = get_stream_logger() +stream = get_stream_logger(logging.INFO) From 519613eeeb0d2715f41165a2c6d74c125e5f4856 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 17 Jul 2024 19:10:36 +0200 Subject: [PATCH 302/969] sphinx/web --- rwx/prj/sphinx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py index b09d8ee..3cef334 100644 --- a/rwx/prj/sphinx.py +++ b/rwx/prj/sphinx.py @@ -29,6 +29,6 @@ class SphinxProject(Project): self.root, # "-C", path.join(self.root, self.name), - path.join(output_root, self.name), + path.join(output_root, "web"), ] build_main(arguments) From 5361fbd9a06f6d97e880893a39dee8f6af20ea27 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 20 Aug 2024 14:14:03 +0200 Subject: [PATCH 303/969] 3.11 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 66a3933..756a434 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ keywords = [] license-files = { paths = ["license.md"] } name = "rwx" readme = "readme.md" -requires-python = ">= 3.10" +requires-python = ">= 3.11" [project.scripts] # command = "package.module:function" From 2dfdabed260bfd92de3e0cdbbac86e55aa9b70c8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 15:40:19 +0200 Subject: [PATCH 304/969] lint/sphinx --- rwx/prj/sphinx.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py index 3cef334..afa0901 100644 --- a/rwx/prj/sphinx.py +++ b/rwx/prj/sphinx.py @@ -1,3 +1,5 @@ +"""Project consisting only of a Sphinx documentation.""" + from os import path from sphinx.cmd.build import build_main @@ -10,7 +12,7 @@ class SphinxProject(Project): def __init__(self, file_path: str) -> None: super().__init__(file_path) - def build(self): + def build(self) -> None: output_root: str = path.join(self.root, "out") wipe(output_root) arguments: list[str] = [ From e306971534f4fee794356db5d08d18d52a484fdc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 15:45:17 +0200 Subject: [PATCH 305/969] lint/cmd --- rwx/cmd/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rwx/cmd/__init__.py b/rwx/cmd/__init__.py index de764fa..e3b75bc 100644 --- a/rwx/cmd/__init__.py +++ b/rwx/cmd/__init__.py @@ -1,8 +1,11 @@ +"""Handle system commands & packages.""" + commands: list[str] = [] packages: list[str] = [] def need(command: str) -> None: + """Assert package dependency for a command.""" match command: case "debootstrap": package = "debootstrap" From 63d30013a335389503e7e382f2bed1debfa595eb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 15:53:20 +0200 Subject: [PATCH 306/969] lint/fs --- rwx/fs/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index e769358..c91e0b8 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -1,3 +1,5 @@ +"""Operations involving FileSystems.""" + import os import shutil @@ -6,7 +8,8 @@ from rwx import ps CHARSET = "UTF-8" -def create_image(file_path: str, size_bytes: int): +def create_image(file_path: str, size_bytes: int) -> None: + """Create a virtual device image file.""" ps.run( ("qemu-img", "create"), ("-f", "qcow2"), @@ -14,11 +17,13 @@ def create_image(file_path: str, size_bytes: int): ) -def empty_file(path: str): +def empty_file(path: str) -> None: + """Empty the file at provided path.""" write(path, "") -def get_mount_uuid(path: str): +def get_mount_uuid(path: str) -> str: + """Return the UUID of provided mountpoint path.""" return ps.run_line( ("findmnt",), ("--noheadings",), From 076f654a2dc66cfbc07853e40bb330a61ddc540f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 15:55:46 +0200 Subject: [PATCH 307/969] lint/arg --- rwx/arg/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rwx/arg/__init__.py b/rwx/arg/__init__.py index aa6e4b8..71ce0a7 100644 --- a/rwx/arg/__init__.py +++ b/rwx/arg/__init__.py @@ -1,6 +1,9 @@ +"""Handle system arguments.""" + import sys def split() -> tuple[str, list[str]]: + """Split command & actual arguments.""" command, *arguments = sys.argv return command, arguments From 12a2a82cfeb328468ed47620e7bba019df0bff39 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:27:04 +0200 Subject: [PATCH 308/969] lint/log --- rwx/log/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rwx/log/__init__.py b/rwx/log/__init__.py index 50048e5..5470e67 100644 --- a/rwx/log/__init__.py +++ b/rwx/log/__init__.py @@ -3,29 +3,29 @@ import sys def get_file_logger(name: str) -> logging.Logger: + # formatter formatter = logging.Formatter( "%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s", ) - # + # handler out_handler = logging.StreamHandler(stream=sys.stdout) out_handler.setFormatter(formatter) out_handler.setLevel(logging.INFO) - # + # logger logger = logging.getLogger(name) logger.addHandler(out_handler) logger.setLevel(logging.INFO) - # return logger def get_stream_logger(level: int) -> logging.Logger: + # handler out_handler = logging.StreamHandler(stream=sys.stdout) out_handler.setLevel(level) - # + # logger logger = logging.getLogger() logger.addHandler(out_handler) logger.setLevel(level) - # return logger From 26632881275443890e02694934231523e874c336 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:36:29 +0200 Subject: [PATCH 309/969] lint/log --- rwx/log/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rwx/log/__init__.py b/rwx/log/__init__.py index 5470e67..12fb781 100644 --- a/rwx/log/__init__.py +++ b/rwx/log/__init__.py @@ -1,8 +1,11 @@ +"""Handle logging.""" + import logging import sys def get_file_logger(name: str) -> logging.Logger: + """Return a file logger.""" # formatter formatter = logging.Formatter( "%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s", @@ -19,6 +22,7 @@ def get_file_logger(name: str) -> logging.Logger: def get_stream_logger(level: int) -> logging.Logger: + """Return a stream logger.""" # handler out_handler = logging.StreamHandler(stream=sys.stdout) out_handler.setLevel(level) From eb5a386e02e2ebfa19762b355cd7826090bde3e3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:45:07 +0200 Subject: [PATCH 310/969] lint/ps --- rwx/ps/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index b66c21b..b2eca55 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -1,9 +1,12 @@ +"""Handle processes.""" + import subprocess from rwx import txt -def get_tuples_args(tuples) -> list[str]: +def get_tuples_args(*tuples: tuple[str]) -> list[str]: + """Turn arguments tuples into an arguments list.""" args: list[str] = [] for item in tuples: if type(item) is tuple: @@ -13,18 +16,21 @@ def get_tuples_args(tuples) -> list[str]: return args -def run(*tuples) -> subprocess.CompletedProcess: +def run(*tuples: tuple[str]) -> subprocess.CompletedProcess: + """Run from a list of arguments tuples.""" return subprocess.run( get_tuples_args(tuples), capture_output=False, check=True ) -def run_line(*tuples, charset: str = txt.CHARSET) -> str: +def run_line(*tuples: tuple[str], charset: str = txt.CHARSET) -> str: + """Run and return output line.""" lines = run_lines(*get_tuples_args(tuples), charset=charset) return lines[0] -def run_lines(*tuples, charset: str = txt.CHARSET) -> list[str]: +def run_lines(*tuples: tuple[str], charset: str = txt.CHARSET) -> list[str]: + """Run and return output lines.""" process = subprocess.run( get_tuples_args(tuples), capture_output=True, check=True ) From 8c896c9074f1a9b1f17f4ed56092d6d3fbd1c127 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:45:56 +0200 Subject: [PATCH 311/969] lint/txt --- rwx/txt/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rwx/txt/__init__.py b/rwx/txt/__init__.py index 369202c..be2f273 100644 --- a/rwx/txt/__init__.py +++ b/rwx/txt/__init__.py @@ -1 +1,3 @@ +"""Handle text.""" + CHARSET = "UTF-8" From 88311cb55c1af0df40e4d1ea1486b655bafd9fb6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:50:20 +0200 Subject: [PATCH 312/969] lint/prj --- rwx/prj/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rwx/prj/__init__.py b/rwx/prj/__init__.py index 227a686..6a3e059 100644 --- a/rwx/prj/__init__.py +++ b/rwx/prj/__init__.py @@ -1,8 +1,13 @@ +"""Handle projects.""" + from os import path class Project: + """Parent class for any type of project.""" + def __init__(self, file_path: str) -> None: + """Set file, root & name.""" self.file: str = path.realpath(file_path) self.root: str = path.dirname(self.file) self.name: str = path.basename(self.root) From f46d5a97656a4ed6bbfcf8c4a6d595fabcfba3ed Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:52:01 +0200 Subject: [PATCH 313/969] lint/grub --- rwx/grub/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rwx/grub/__init__.py b/rwx/grub/__init__.py index cd016ab..dde847a 100644 --- a/rwx/grub/__init__.py +++ b/rwx/grub/__init__.py @@ -1,3 +1,5 @@ +"""Wrap GRUB commands.""" + import cmd import ps @@ -24,6 +26,7 @@ def make_image( memdisk_path: str, pubkey_path: str | None = None, ) -> None: + """Make a binary bootable image.""" args = [ ("grub-mkimage",), ("--compress", COMPRESSION), From 9bb800381249b4b7d3f4fb165dd8131c4618f8bb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:54:22 +0200 Subject: [PATCH 314/969] lint/sphinx --- rwx/prj/sphinx.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py index afa0901..13252f8 100644 --- a/rwx/prj/sphinx.py +++ b/rwx/prj/sphinx.py @@ -9,10 +9,14 @@ from rwx.prj import Project class SphinxProject(Project): + """Child class for a project based on Sphinx.""" + def __init__(self, file_path: str) -> None: + """Call the parent constructor.""" super().__init__(file_path) def build(self) -> None: + """Build the project.""" output_root: str = path.join(self.root, "out") wipe(output_root) arguments: list[str] = [ From ce3629a77601141735c9423246824bd3c3300fb4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:56:01 +0200 Subject: [PATCH 315/969] lint/deb --- rwx/deb/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rwx/deb/__init__.py b/rwx/deb/__init__.py index e9c6a9e..f022ca5 100644 --- a/rwx/deb/__init__.py +++ b/rwx/deb/__init__.py @@ -1,3 +1,5 @@ +"""Wrap Debian commands.""" + import cmd import ps @@ -8,7 +10,8 @@ BOOTSTRAP_ARCHITECTURE = "amd64" BOOTSTRAP_VARIANT = "minbase" -def bootstrap(root_path: str, suite: str, mirror_location: str): +def bootstrap(root_path: str, suite: str, mirror_location: str) -> None: + """Boostrap a base operating filesystem.""" command = [ ("debootstrap",), ("--arch", BOOTSTRAP_ARCHITECTURE), From f7c1d90dfdcd562ffb3f3b3459e237dc7040e0c9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:58:01 +0200 Subject: [PATCH 316/969] lint/squashfs --- rwx/cmd/squashfs/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rwx/cmd/squashfs/__init__.py b/rwx/cmd/squashfs/__init__.py index 322186c..85e20b2 100644 --- a/rwx/cmd/squashfs/__init__.py +++ b/rwx/cmd/squashfs/__init__.py @@ -1,3 +1,5 @@ +"""Wrap SquashFS commands.""" + import ps import rwx.cmd @@ -5,7 +7,8 @@ import rwx.cmd rwx.cmd.need("mksquashfs") -def mksquashfs(input_root: str, output_file: str): +def mksquashfs(input_root: str, output_file: str) -> None: + """Make a SquashFS bootable image file.""" ps.run( [ "mksquashfs", From 08b6364d9b8f1098983478731ade680b0cf7ace6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 17:00:39 +0200 Subject: [PATCH 317/969] lint/err --- rwx/err/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rwx/err/__init__.py b/rwx/err/__init__.py index b996913..5df6b97 100644 --- a/rwx/err/__init__.py +++ b/rwx/err/__init__.py @@ -1,2 +1,4 @@ -class Exception(Exception): - pass +"""Handle errors.""" + +class Error(Exception): + """Parent class for all errors.""" From 3e0d5bf2bcd403d991fd149ab77ef1e6189bcfa4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 17:07:27 +0200 Subject: [PATCH 318/969] lint/fs --- rwx/fs/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index c91e0b8..9189778 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -23,7 +23,7 @@ def empty_file(path: str) -> None: def get_mount_uuid(path: str) -> str: - """Return the UUID of provided mountpoint path.""" + """Return the filesystem UUID of a mountpoint path.""" return ps.run_line( ("findmnt",), ("--noheadings",), @@ -32,7 +32,8 @@ def get_mount_uuid(path: str) -> str: ) -def get_path_mount(path: str): +def get_path_mount(path: str) -> str: + """Return the mountpoint path of an arbitrary path.""" return ps.run_line( ("stat",), ("--format", "%m"), @@ -40,11 +41,13 @@ def get_path_mount(path: str): ) -def get_path_uuid(path: str): +def get_path_uuid(path: str) -> str: + """Return the filesystem UUID of an arbitrary path.""" return get_mount_uuid(get_path_mount(path)) -def make_directory(path: str): +def make_directory(path: str) -> None: + """Make a directory (and its parents) from a path.""" os.makedirs(path, exist_ok=True) From aa1f06c20fc756227b18459c6d1883fd700df140 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 17:13:16 +0200 Subject: [PATCH 319/969] lint/fs --- rwx/fs/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 9189778..64a8483 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -56,15 +56,16 @@ def read_file(file_path: str): return file_object.read() -def read_file_lines(file_path: str, charset=CHARSET): +def read_file_lines(file_path: str, charset:str=CHARSET): return read_file_text(file_path).split(os.linesep) -def read_file_text(file_path: str, charset=CHARSET): +def read_file_text(file_path: str, charset:str=CHARSET): return read_file(file_path).decode(charset) -def wipe(path: str): +def wipe(path: str) -> None: + """Wipe provided path, whether directory or file.""" try: shutil.rmtree(path) except NotADirectoryError: @@ -73,6 +74,7 @@ def wipe(path: str): pass -def write(file_path: str, text: str, charset=CHARSET): +def write(file_path: str, text: str, charset:str=CHARSET) -> None: + """Write text into a file.""" with open(file_path, "bw") as file_object: file_object.write(text.encode(charset)) From 3393f0990742dda006ded747dae2e50319356af2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 17:13:37 +0200 Subject: [PATCH 320/969] format --- rwx/err/__init__.py | 1 + rwx/fs/__init__.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rwx/err/__init__.py b/rwx/err/__init__.py index 5df6b97..294d8d8 100644 --- a/rwx/err/__init__.py +++ b/rwx/err/__init__.py @@ -1,4 +1,5 @@ """Handle errors.""" + class Error(Exception): """Parent class for all errors.""" diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 64a8483..514fcec 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -56,11 +56,11 @@ def read_file(file_path: str): return file_object.read() -def read_file_lines(file_path: str, charset:str=CHARSET): +def read_file_lines(file_path: str, charset: str = CHARSET): return read_file_text(file_path).split(os.linesep) -def read_file_text(file_path: str, charset:str=CHARSET): +def read_file_text(file_path: str, charset: str = CHARSET): return read_file(file_path).decode(charset) @@ -74,7 +74,7 @@ def wipe(path: str) -> None: pass -def write(file_path: str, text: str, charset:str=CHARSET) -> None: +def write(file_path: str, text: str, charset: str = CHARSET) -> None: """Write text into a file.""" with open(file_path, "bw") as file_object: file_object.write(text.encode(charset)) From 0a9404fb2f6a908e9469179433e78eb2ec9c3e61 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 17:19:33 +0200 Subject: [PATCH 321/969] fs/unlink --- rwx/fs/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 514fcec..a7cc5b0 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -2,6 +2,7 @@ import os import shutil +from pathlib import Path from rwx import ps @@ -69,7 +70,7 @@ def wipe(path: str) -> None: try: shutil.rmtree(path) except NotADirectoryError: - os.remove(path) + Path(path).unlink(missing_ok=True) except FileNotFoundError: pass From ef45fc9d810000da64ab8ad9f309906ff8c5db86 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 17:22:36 +0200 Subject: [PATCH 322/969] fs/open --- rwx/fs/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index a7cc5b0..cb97ceb 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -77,5 +77,5 @@ def wipe(path: str) -> None: def write(file_path: str, text: str, charset: str = CHARSET) -> None: """Write text into a file.""" - with open(file_path, "bw") as file_object: - file_object.write(text.encode(charset)) + with Path(file_path).open(mode="w", encoding=charset) as file_object: + file_object.write(text) From de80d7ecff21069f2a0c5bfd960fbb17e35eefa3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 17:24:37 +0200 Subject: [PATCH 323/969] fs/mkdir --- rwx/fs/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index cb97ceb..1037fd0 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -49,7 +49,7 @@ def get_path_uuid(path: str) -> str: def make_directory(path: str) -> None: """Make a directory (and its parents) from a path.""" - os.makedirs(path, exist_ok=True) + Path(path).mkdir(exist_ok=True, parents=True) def read_file(file_path: str): @@ -77,5 +77,5 @@ def wipe(path: str) -> None: def write(file_path: str, text: str, charset: str = CHARSET) -> None: """Write text into a file.""" - with Path(file_path).open(mode="w", encoding=charset) as file_object: + with Path(file_path).open(encoding=charset, mode="w") as file_object: file_object.write(text) From cfa9ca9e3c15e33114c051b20d52ead57dd17d17 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 17:39:39 +0200 Subject: [PATCH 324/969] prj/Path --- rwx/prj/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rwx/prj/__init__.py b/rwx/prj/__init__.py index 6a3e059..8b70a4a 100644 --- a/rwx/prj/__init__.py +++ b/rwx/prj/__init__.py @@ -1,6 +1,7 @@ """Handle projects.""" -from os import path +from os.path import realpath +from pathlib import Path class Project: @@ -8,6 +9,6 @@ class Project: def __init__(self, file_path: str) -> None: """Set file, root & name.""" - self.file: str = path.realpath(file_path) - self.root: str = path.dirname(self.file) - self.name: str = path.basename(self.root) + self.file: str = realpath(file_path) + self.root: str = Path(self.file).parent + self.name: str = self.root.name From 5e3c8e93ff9705afce27a06a1083c565466b219b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 17:41:49 +0200 Subject: [PATCH 325/969] sphinx/ --- rwx/prj/sphinx.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py index 13252f8..b85cfa5 100644 --- a/rwx/prj/sphinx.py +++ b/rwx/prj/sphinx.py @@ -1,7 +1,5 @@ """Project consisting only of a Sphinx documentation.""" -from os import path - from sphinx.cmd.build import build_main from rwx.fs import wipe @@ -17,7 +15,7 @@ class SphinxProject(Project): def build(self) -> None: """Build the project.""" - output_root: str = path.join(self.root, "out") + output_root: str = self.root / "out" wipe(output_root) arguments: list[str] = [ "-E", @@ -34,7 +32,7 @@ class SphinxProject(Project): "-c", self.root, # "-C", - path.join(self.root, self.name), - path.join(output_root, "web"), + self.root / self.name, + output_root / "web", ] build_main(arguments) From 065d647e517135cf82fa8ee3c48076b5643d11ef Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 18:55:31 +0200 Subject: [PATCH 326/969] read/bytes --- rwx/fs/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 1037fd0..b1da3a2 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -52,8 +52,9 @@ def make_directory(path: str) -> None: Path(path).mkdir(exist_ok=True, parents=True) -def read_file(file_path: str): - with open(file_path, "br") as file_object: +def read_file_bytes(file_path: str) -> bytes: + """Read whole file bytes.""" + with Path(file_path).open("br") as file_object: return file_object.read() @@ -62,7 +63,7 @@ def read_file_lines(file_path: str, charset: str = CHARSET): def read_file_text(file_path: str, charset: str = CHARSET): - return read_file(file_path).decode(charset) + return read_file_bytes(file_path).decode(charset) def wipe(path: str) -> None: From b3e66ec1c3f21b672cc26ddd540e1343f3b57cda Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 18:57:49 +0200 Subject: [PATCH 327/969] read/text --- rwx/fs/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index b1da3a2..82b7c16 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -62,7 +62,8 @@ def read_file_lines(file_path: str, charset: str = CHARSET): return read_file_text(file_path).split(os.linesep) -def read_file_text(file_path: str, charset: str = CHARSET): +def read_file_text(file_path: str, charset: str = CHARSET) -> str: + """Read whole file text.""" return read_file_bytes(file_path).decode(charset) From 78dd431ca5fd969841774f9deb4129d9eb299c7f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 18:58:57 +0200 Subject: [PATCH 328/969] read/lines --- rwx/fs/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 82b7c16..a8865e7 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -58,8 +58,9 @@ def read_file_bytes(file_path: str) -> bytes: return file_object.read() -def read_file_lines(file_path: str, charset: str = CHARSET): - return read_file_text(file_path).split(os.linesep) +def read_file_lines(file_path: str, charset: str = CHARSET) -> list[str]: + """Read whole file lines.""" + return read_file_text(file_path, charset).split(os.linesep) def read_file_text(file_path: str, charset: str = CHARSET) -> str: From bf1b3402ae58e9f0bb97259e8e016c5c8d7841aa Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 19:24:11 +0200 Subject: [PATCH 329/969] log/template --- rwx/log/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rwx/log/__init__.py b/rwx/log/__init__.py index 12fb781..3b245ae 100644 --- a/rwx/log/__init__.py +++ b/rwx/log/__init__.py @@ -7,9 +7,14 @@ import sys def get_file_logger(name: str) -> logging.Logger: """Return a file logger.""" # formatter - formatter = logging.Formatter( - "%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s", - ) + items = [ + "%(name)s: %(asctime)s", + "%(levelname)s", + "%(filename)s:%(lineno)s", + "%(process)d >>> %(message)s", + ] + template = " | ".join(items) + formatter = logging.Formatter(template) # handler out_handler = logging.StreamHandler(stream=sys.stdout) out_handler.setFormatter(formatter) From 07699b08eb6a89e0e14455c443e2c8408d40c0c6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 20:47:49 +0200 Subject: [PATCH 330/969] ps/items --- rwx/ps/__init__.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index b2eca55..1bb552d 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -5,10 +5,10 @@ import subprocess from rwx import txt -def get_tuples_args(*tuples: tuple[str]) -> list[str]: +def get_tuples_args(*items: str | tuple[str]) -> list[str]: """Turn arguments tuples into an arguments list.""" args: list[str] = [] - for item in tuples: + for item in items: if type(item) is tuple: args.extend(item) else: @@ -16,23 +16,25 @@ def get_tuples_args(*tuples: tuple[str]) -> list[str]: return args -def run(*tuples: tuple[str]) -> subprocess.CompletedProcess: +def run(*items: str | tuple[str]) -> subprocess.CompletedProcess: """Run from a list of arguments tuples.""" return subprocess.run( - get_tuples_args(tuples), capture_output=False, check=True + get_tuples_args(*items), capture_output=False, check=True ) -def run_line(*tuples: tuple[str], charset: str = txt.CHARSET) -> str: +def run_line(*items: str | tuple[str], charset: str = txt.CHARSET) -> str: """Run and return output line.""" - lines = run_lines(*get_tuples_args(tuples), charset=charset) + lines = run_lines(get_tuples_args(*items), charset=charset) return lines[0] -def run_lines(*tuples: tuple[str], charset: str = txt.CHARSET) -> list[str]: +def run_lines( + *items: str | tuple[str], charset: str = txt.CHARSET +) -> list[str]: """Run and return output lines.""" process = subprocess.run( - get_tuples_args(tuples), capture_output=True, check=True + get_tuples_args(*items), capture_output=True, check=True ) string = process.stdout.decode(charset) return string.rstrip().splitlines() From c024c553b0df3c7f1ea0f2c248b95c407d9ac46c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 20:52:33 +0200 Subject: [PATCH 331/969] fix --- rwx/ps/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 1bb552d..67dd2bc 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -25,7 +25,7 @@ def run(*items: str | tuple[str]) -> subprocess.CompletedProcess: def run_line(*items: str | tuple[str], charset: str = txt.CHARSET) -> str: """Run and return output line.""" - lines = run_lines(get_tuples_args(*items), charset=charset) + lines = run_lines(*items, charset=charset) return lines[0] From 0e2b638bbbf6efe4cdf23bc1f6bd86059e23abd5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 21:11:24 +0200 Subject: [PATCH 332/969] run/line --- rwx/ps/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 67dd2bc..e45672e 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -25,8 +25,8 @@ def run(*items: str | tuple[str]) -> subprocess.CompletedProcess: def run_line(*items: str | tuple[str], charset: str = txt.CHARSET) -> str: """Run and return output line.""" - lines = run_lines(*items, charset=charset) - return lines[0] + line, *_ = run_lines(*items, charset=charset) + return line def run_lines( From b1970c1f783b6b2d81220ec7c2881684bd012755 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 22:55:45 +0200 Subject: [PATCH 333/969] main/rwx --- rwx/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rwx/__main__.py b/rwx/__main__.py index f6276e4..ee4a31b 100755 --- a/rwx/__main__.py +++ b/rwx/__main__.py @@ -4,7 +4,7 @@ from pathlib import Path -import fs +from rwx import fs if __name__ == "__main__": file_path = Path(__file__).resolve() From 17b16ec9d041fe2bafb60651b57aed92928fdab8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 23:02:29 +0200 Subject: [PATCH 334/969] mypy/prj --- rwx/prj/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rwx/prj/__init__.py b/rwx/prj/__init__.py index 8b70a4a..36dab99 100644 --- a/rwx/prj/__init__.py +++ b/rwx/prj/__init__.py @@ -1,6 +1,5 @@ """Handle projects.""" -from os.path import realpath from pathlib import Path @@ -9,6 +8,6 @@ class Project: def __init__(self, file_path: str) -> None: """Set file, root & name.""" - self.file: str = realpath(file_path) - self.root: str = Path(self.file).parent + self.file: Path = Path(file_path).resolve() + self.root: Path = self.file.parent self.name: str = self.root.name From 3a8b239b9f1c963be421947c6976ac4e37ce9ffb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 23:07:39 +0200 Subject: [PATCH 335/969] mypy/cmd --- rwx/cmd/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rwx/cmd/__init__.py b/rwx/cmd/__init__.py index e3b75bc..ca4dced 100644 --- a/rwx/cmd/__init__.py +++ b/rwx/cmd/__init__.py @@ -6,6 +6,7 @@ packages: list[str] = [] def need(command: str) -> None: """Assert package dependency for a command.""" + package: str | None match command: case "debootstrap": package = "debootstrap" From e2132859879f25f79ece247908a63b267e5baa6c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 23:17:09 +0200 Subject: [PATCH 336/969] mypy/fs,sphinx --- rwx/fs/__init__.py | 4 ++-- rwx/prj/sphinx.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index a8865e7..d1c2732 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -68,12 +68,12 @@ def read_file_text(file_path: str, charset: str = CHARSET) -> str: return read_file_bytes(file_path).decode(charset) -def wipe(path: str) -> None: +def wipe(path: Path) -> None: """Wipe provided path, whether directory or file.""" try: shutil.rmtree(path) except NotADirectoryError: - Path(path).unlink(missing_ok=True) + path.unlink(missing_ok=True) except FileNotFoundError: pass diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py index b85cfa5..be207ef 100644 --- a/rwx/prj/sphinx.py +++ b/rwx/prj/sphinx.py @@ -1,5 +1,10 @@ """Project consisting only of a Sphinx documentation.""" +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from pathlib import Path + from sphinx.cmd.build import build_main from rwx.fs import wipe @@ -15,7 +20,7 @@ class SphinxProject(Project): def build(self) -> None: """Build the project.""" - output_root: str = self.root / "out" + output_root: Path = self.root / "out" wipe(output_root) arguments: list[str] = [ "-E", @@ -30,9 +35,9 @@ class SphinxProject(Project): "-D", "html_theme={}".format("sphinx_rtd_theme"), "-c", - self.root, + str(self.root), # "-C", - self.root / self.name, - output_root / "web", + str(self.root / self.name), + str(output_root / "web"), ] build_main(arguments) From 114ee6110208710cdfcb2ed57d9525167daad2fd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 23:22:12 +0200 Subject: [PATCH 337/969] mypy/fs,main --- rwx/__main__.py | 6 +++--- rwx/fs/__init__.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rwx/__main__.py b/rwx/__main__.py index ee4a31b..e19dea1 100755 --- a/rwx/__main__.py +++ b/rwx/__main__.py @@ -7,9 +7,9 @@ from pathlib import Path from rwx import fs if __name__ == "__main__": - file_path = Path(__file__).resolve() - root_path = file_path.parent - directory_path = root_path / "tmp" + file_path: Path = Path(__file__).resolve() + root_path: Path = file_path.parent + directory_path: Path = root_path / "tmp" file_path = directory_path / "file" fs.wipe(directory_path) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index d1c2732..3902b5a 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -18,7 +18,7 @@ def create_image(file_path: str, size_bytes: int) -> None: ) -def empty_file(path: str) -> None: +def empty_file(path: Path) -> None: """Empty the file at provided path.""" write(path, "") @@ -47,9 +47,9 @@ def get_path_uuid(path: str) -> str: return get_mount_uuid(get_path_mount(path)) -def make_directory(path: str) -> None: +def make_directory(path: Path) -> None: """Make a directory (and its parents) from a path.""" - Path(path).mkdir(exist_ok=True, parents=True) + path.mkdir(exist_ok=True, parents=True) def read_file_bytes(file_path: str) -> bytes: @@ -78,7 +78,7 @@ def wipe(path: Path) -> None: pass -def write(file_path: str, text: str, charset: str = CHARSET) -> None: +def write(file_path: Path, text: str, charset: str = CHARSET) -> None: """Write text into a file.""" - with Path(file_path).open(encoding=charset, mode="w") as file_object: + with file_path.open(encoding=charset, mode="w") as file_object: file_object.write(text) From 56404078f7e8933324d05e490726a61d52113dcb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 23:38:08 +0200 Subject: [PATCH 338/969] rwx/deb,grub --- rwx/deb/__init__.py | 2 +- rwx/grub/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rwx/deb/__init__.py b/rwx/deb/__init__.py index f022ca5..d205222 100644 --- a/rwx/deb/__init__.py +++ b/rwx/deb/__init__.py @@ -2,7 +2,7 @@ import cmd -import ps +from rwx import ps cmd.need("debootstrap") diff --git a/rwx/grub/__init__.py b/rwx/grub/__init__.py index dde847a..f4ceaea 100644 --- a/rwx/grub/__init__.py +++ b/rwx/grub/__init__.py @@ -2,7 +2,7 @@ import cmd -import ps +from rwx import ps cmd.need("grub-mkimage") From 4fac21da0807cedccdf29a1a5d49bb52892cd30f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 23:40:53 +0200 Subject: [PATCH 339/969] rwx/squashfs --- rwx/cmd/squashfs/__init__.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rwx/cmd/squashfs/__init__.py b/rwx/cmd/squashfs/__init__.py index 85e20b2..3162b88 100644 --- a/rwx/cmd/squashfs/__init__.py +++ b/rwx/cmd/squashfs/__init__.py @@ -1,10 +1,8 @@ """Wrap SquashFS commands.""" -import ps +from rwx import cmd, ps -import rwx.cmd - -rwx.cmd.need("mksquashfs") +cmd.need("mksquashfs") def mksquashfs(input_root: str, output_file: str) -> None: From 521884102e01e6e0d4005eb0404a72f01a363b1d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 23:41:19 +0200 Subject: [PATCH 340/969] os --- rwx/os/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 rwx/os/__init__.py diff --git a/rwx/os/__init__.py b/rwx/os/__init__.py new file mode 100644 index 0000000..70ca05c --- /dev/null +++ b/rwx/os/__init__.py @@ -0,0 +1,11 @@ +"""Control Operating Systems.""" + +from pathlib import Path + + +class OS: + """Operating System.""" + + def __init__(self, path: str) -> None: + """Set root.""" + self.root = Path(path) From cd4e7403ae6142273b929c024d38b1df0c225f98 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 23:54:32 +0200 Subject: [PATCH 341/969] ps/str,... --- rwx/ps/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index e45672e..e18e250 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -5,7 +5,7 @@ import subprocess from rwx import txt -def get_tuples_args(*items: str | tuple[str]) -> list[str]: +def get_tuples_args(*items: str | tuple[str, ...]) -> list[str]: """Turn arguments tuples into an arguments list.""" args: list[str] = [] for item in items: @@ -16,21 +16,21 @@ def get_tuples_args(*items: str | tuple[str]) -> list[str]: return args -def run(*items: str | tuple[str]) -> subprocess.CompletedProcess: +def run(*items: str | tuple[str, ...]) -> subprocess.CompletedProcess: """Run from a list of arguments tuples.""" return subprocess.run( get_tuples_args(*items), capture_output=False, check=True ) -def run_line(*items: str | tuple[str], charset: str = txt.CHARSET) -> str: +def run_line(*items: str | tuple[str, ...], charset: str = txt.CHARSET) -> str: """Run and return output line.""" line, *_ = run_lines(*items, charset=charset) return line def run_lines( - *items: str | tuple[str], charset: str = txt.CHARSET + *items: str | tuple[str, ...], charset: str = txt.CHARSET ) -> list[str]: """Run and return output lines.""" process = subprocess.run( From 378a2127862b63d0c43e86e495c351c79c2ff220 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 23:55:02 +0200 Subject: [PATCH 342/969] mypy/deb,fs,grub --- rwx/deb/__init__.py | 6 ++---- rwx/fs/__init__.py | 6 +++--- rwx/grub/__init__.py | 4 +--- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/rwx/deb/__init__.py b/rwx/deb/__init__.py index d205222..fcd4198 100644 --- a/rwx/deb/__init__.py +++ b/rwx/deb/__init__.py @@ -1,8 +1,6 @@ """Wrap Debian commands.""" -import cmd - -from rwx import ps +from rwx import cmd, ps cmd.need("debootstrap") @@ -20,4 +18,4 @@ def bootstrap(root_path: str, suite: str, mirror_location: str) -> None: (root_path,), (mirror_location,), ] - return ps.run(command) + ps.run(*command) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 3902b5a..0685c44 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -14,7 +14,7 @@ def create_image(file_path: str, size_bytes: int) -> None: ps.run( ("qemu-img", "create"), ("-f", "qcow2"), - (file_path, size_bytes), + (file_path, str(size_bytes)), ) @@ -36,9 +36,9 @@ def get_mount_uuid(path: str) -> str: def get_path_mount(path: str) -> str: """Return the mountpoint path of an arbitrary path.""" return ps.run_line( - ("stat",), + "stat", ("--format", "%m"), - (path,), + path, ) diff --git a/rwx/grub/__init__.py b/rwx/grub/__init__.py index f4ceaea..accec9f 100644 --- a/rwx/grub/__init__.py +++ b/rwx/grub/__init__.py @@ -1,8 +1,6 @@ """Wrap GRUB commands.""" -import cmd - -from rwx import ps +from rwx import cmd, ps cmd.need("grub-mkimage") From 51b4f0f5f29ef0af7e523eae026f19793fac8941 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 23:57:35 +0200 Subject: [PATCH 343/969] mypy/squashfs --- rwx/cmd/squashfs/__init__.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/rwx/cmd/squashfs/__init__.py b/rwx/cmd/squashfs/__init__.py index 3162b88..db603da 100644 --- a/rwx/cmd/squashfs/__init__.py +++ b/rwx/cmd/squashfs/__init__.py @@ -8,13 +8,11 @@ cmd.need("mksquashfs") def mksquashfs(input_root: str, output_file: str) -> None: """Make a SquashFS bootable image file.""" ps.run( - [ - "mksquashfs", - input_root, - output_file, - "-comp", - "zstd", - "-Xcompression-level", - str(18), - ] + "mksquashfs", + input_root, + output_file, + "-comp", + "zstd", + "-Xcompression-level", + str(18), ) From 2ad223fa834645974806ddc663fe98a69849342f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 14 Sep 2024 00:07:34 +0200 Subject: [PATCH 344/969] grub/extra --- rwx/grub/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rwx/grub/__init__.py b/rwx/grub/__init__.py index accec9f..21b2bf5 100644 --- a/rwx/grub/__init__.py +++ b/rwx/grub/__init__.py @@ -35,6 +35,6 @@ def make_image( if pubkey_path: args.append(("--pubkey", pubkey_path)) args.extend(modules) - if modules := MODULES.get(image_format): - args.extend(modules) + if extra_modules := MODULES.get(image_format): + args.extend(extra_modules) ps.run(*args) From 68cbe3cd88db3d39652a831e277c12a1bdb342e7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 14 Sep 2024 00:13:59 +0200 Subject: [PATCH 345/969] mypy/ps --- rwx/ps/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index e18e250..0bbab9c 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -9,10 +9,11 @@ def get_tuples_args(*items: str | tuple[str, ...]) -> list[str]: """Turn arguments tuples into an arguments list.""" args: list[str] = [] for item in items: - if type(item) is tuple: - args.extend(item) - else: - args.append(item) + match item: + case str(): + args.append(item) + case tuple(): + args.extend(item) return args From d4d60982415d69ab5e4759c6cd62e5db27866d02 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 14 Sep 2024 00:17:17 +0200 Subject: [PATCH 346/969] mypy/grub --- rwx/grub/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rwx/grub/__init__.py b/rwx/grub/__init__.py index 21b2bf5..7c0cccc 100644 --- a/rwx/grub/__init__.py +++ b/rwx/grub/__init__.py @@ -25,8 +25,8 @@ def make_image( pubkey_path: str | None = None, ) -> None: """Make a binary bootable image.""" - args = [ - ("grub-mkimage",), + args: list[str | tuple[str, ...]] = [ + "grub-mkimage", ("--compress", COMPRESSION), ("--format", image_format), ("--output", image_path), From cc0b131a564dec9a4a8219debf423ed0afc274f0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 14 Sep 2024 02:39:52 +0200 Subject: [PATCH 347/969] py.typed --- rwx/py.typed | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 rwx/py.typed diff --git a/rwx/py.typed b/rwx/py.typed new file mode 100644 index 0000000..e69de29 From 4e369df232f527dc9640e1a55373453d70f0feb6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 14 Sep 2024 02:47:52 +0200 Subject: [PATCH 348/969] mypy/fs --- rwx/fs/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 0685c44..ee1925d 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -52,18 +52,18 @@ def make_directory(path: Path) -> None: path.mkdir(exist_ok=True, parents=True) -def read_file_bytes(file_path: str) -> bytes: +def read_file_bytes(file_path: Path) -> bytes: """Read whole file bytes.""" - with Path(file_path).open("br") as file_object: + with file_path.open("br") as file_object: return file_object.read() -def read_file_lines(file_path: str, charset: str = CHARSET) -> list[str]: +def read_file_lines(file_path: Path, charset: str = CHARSET) -> list[str]: """Read whole file lines.""" return read_file_text(file_path, charset).split(os.linesep) -def read_file_text(file_path: str, charset: str = CHARSET) -> str: +def read_file_text(file_path: Path, charset: str = CHARSET) -> str: """Read whole file text.""" return read_file_bytes(file_path).decode(charset) From 909e652f0d5d915231fffa2f6a9b47a18a012cad Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 14 Sep 2024 15:23:06 +0200 Subject: [PATCH 349/969] os/debian --- rwx/os/__init__.py | 17 +++++++++++++++-- rwx/os/debian.py | 17 +++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 rwx/os/debian.py diff --git a/rwx/os/__init__.py b/rwx/os/__init__.py index 70ca05c..3bd3c15 100644 --- a/rwx/os/__init__.py +++ b/rwx/os/__init__.py @@ -2,10 +2,23 @@ from pathlib import Path +from rwx.err import Error +from rwx.os.debian import Debian + class OS: """Operating System.""" - def __init__(self, path: str) -> None: + def __init__(self, path: Path) -> None: """Set root.""" - self.root = Path(path) + self.root = path + self.name = self.get_name() + + def get_name(self) -> str: + """Return mandatory name.""" + raise Error + + +def from_path(path: Path) -> OS: + """Initialize from an already existing path.""" + return Debian(path) diff --git a/rwx/os/debian.py b/rwx/os/debian.py new file mode 100644 index 0000000..f8b5fdd --- /dev/null +++ b/rwx/os/debian.py @@ -0,0 +1,17 @@ +"""Debian operating system.""" + +from pathlib import Path + +from . import OS + + +class Debian(OS): + """Debian operating system.""" + + def __init__(self, path: Path) -> None: + """Initialize.""" + super().__init__(path) + + def get_name(self) -> str: + """Return name.""" + return "Debian" From 9c1136cfa0b978c9ed85311209dcdc6518f7bef6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 14 Sep 2024 15:41:56 +0200 Subject: [PATCH 350/969] staticmethod --- rwx/os/__init__.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/rwx/os/__init__.py b/rwx/os/__init__.py index 3bd3c15..d13857c 100644 --- a/rwx/os/__init__.py +++ b/rwx/os/__init__.py @@ -1,10 +1,15 @@ """Control Operating Systems.""" -from pathlib import Path +from __future__ import annotations + +from typing import TYPE_CHECKING from rwx.err import Error from rwx.os.debian import Debian +if TYPE_CHECKING: + from pathlib import Path + class OS: """Operating System.""" @@ -18,7 +23,7 @@ class OS: """Return mandatory name.""" raise Error - -def from_path(path: Path) -> OS: - """Initialize from an already existing path.""" - return Debian(path) + @staticmethod + def from_path(path: Path) -> OS: + """Initialize from an already existing path.""" + return Debian(path) From e75a624c466b77d05b781f760dd3d9536483892e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 14 Sep 2024 15:45:44 +0200 Subject: [PATCH 351/969] abc --- rwx/os/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rwx/os/__init__.py b/rwx/os/__init__.py index d13857c..1594cbb 100644 --- a/rwx/os/__init__.py +++ b/rwx/os/__init__.py @@ -2,16 +2,16 @@ from __future__ import annotations +from abc import ABC, abstractmethod from typing import TYPE_CHECKING -from rwx.err import Error from rwx.os.debian import Debian if TYPE_CHECKING: from pathlib import Path -class OS: +class OS(ABC): """Operating System.""" def __init__(self, path: Path) -> None: @@ -19,9 +19,9 @@ class OS: self.root = path self.name = self.get_name() + @abstractmethod def get_name(self) -> str: """Return mandatory name.""" - raise Error @staticmethod def from_path(path: Path) -> OS: From c5930b4107c212dc652f958728e343f366179691 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 14 Sep 2024 16:24:10 +0200 Subject: [PATCH 352/969] os.os --- rwx/os/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rwx/os/__init__.py b/rwx/os/__init__.py index 1594cbb..3dfa782 100644 --- a/rwx/os/__init__.py +++ b/rwx/os/__init__.py @@ -3,12 +3,10 @@ from __future__ import annotations from abc import ABC, abstractmethod -from typing import TYPE_CHECKING +from os import sep +from pathlib import Path -from rwx.os.debian import Debian - -if TYPE_CHECKING: - from pathlib import Path +from .debian import Debian class OS(ABC): @@ -27,3 +25,6 @@ class OS(ABC): def from_path(path: Path) -> OS: """Initialize from an already existing path.""" return Debian(path) + + +os = OS.from_path(Path(sep)) From f4498f691c9bd03d44898ff91f239f6f65209a7d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 14 Sep 2024 17:43:37 +0200 Subject: [PATCH 353/969] pm,ps --- rwx/os/pm/__init__.py | 17 +++++++++++++++++ rwx/os/pm/apt.py | 16 ++++++++++++++++ rwx/ps/__init__.py | 4 ++++ 3 files changed, 37 insertions(+) create mode 100644 rwx/os/pm/__init__.py create mode 100644 rwx/os/pm/apt.py diff --git a/rwx/os/pm/__init__.py b/rwx/os/pm/__init__.py new file mode 100644 index 0000000..0bcf1e6 --- /dev/null +++ b/rwx/os/pm/__init__.py @@ -0,0 +1,17 @@ +"""Package Manager.""" + +from abc import ABC, abstractmethod + +from rwx.ps import Command + + +class PM(ABC): + """Package Manager.""" + + def __init__(self) -> None: + """Set commands.""" + self.install = self.get_install_command() + + @abstractmethod + def get_install_command(self) -> Command: + """Command to install package(s).""" diff --git a/rwx/os/pm/apt.py b/rwx/os/pm/apt.py new file mode 100644 index 0000000..17caac3 --- /dev/null +++ b/rwx/os/pm/apt.py @@ -0,0 +1,16 @@ +"""Advanced Package Tool.""" + +from rwx.os.pm import PM +from rwx.ps import Command + + +class APT(PM): + """Advanced Package Tool.""" + + def __init__(self) -> None: + """Initialize.""" + super().__init__() + + def get_install_command(self) -> Command: + """Return install command.""" + return Command() diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 0bbab9c..07ccce8 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -5,6 +5,10 @@ import subprocess from rwx import txt +class Command: + """Command to run.""" + + def get_tuples_args(*items: str | tuple[str, ...]) -> list[str]: """Turn arguments tuples into an arguments list.""" args: list[str] = [] From 148f757d5dbafe09a0bada3bad3daea8ae56cd6b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 14 Sep 2024 18:07:01 +0200 Subject: [PATCH 354/969] command/wip --- rwx/ps/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 07ccce8..3ea9702 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -8,6 +8,11 @@ from rwx import txt class Command: """Command to run.""" + def __init__(self, *arguments: str | tuple[str, ...]) -> None: + """Set raw & flat arguments.""" + self.raw = arguments + self.flat: list[str] = [] + def get_tuples_args(*items: str | tuple[str, ...]) -> list[str]: """Turn arguments tuples into an arguments list.""" From 4d8c1d7aabb764bca4f9c2c9bf5df7626b97abdf Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 14 Sep 2024 18:15:42 +0200 Subject: [PATCH 355/969] lint --- rwx/os/debian.py | 6 ------ rwx/os/pm/apt.py | 4 ---- rwx/prj/sphinx.py | 8 ++------ 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/rwx/os/debian.py b/rwx/os/debian.py index f8b5fdd..dbaaabb 100644 --- a/rwx/os/debian.py +++ b/rwx/os/debian.py @@ -1,17 +1,11 @@ """Debian operating system.""" -from pathlib import Path - from . import OS class Debian(OS): """Debian operating system.""" - def __init__(self, path: Path) -> None: - """Initialize.""" - super().__init__(path) - def get_name(self) -> str: """Return name.""" return "Debian" diff --git a/rwx/os/pm/apt.py b/rwx/os/pm/apt.py index 17caac3..ac669b6 100644 --- a/rwx/os/pm/apt.py +++ b/rwx/os/pm/apt.py @@ -7,10 +7,6 @@ from rwx.ps import Command class APT(PM): """Advanced Package Tool.""" - def __init__(self) -> None: - """Initialize.""" - super().__init__() - def get_install_command(self) -> Command: """Return install command.""" return Command() diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py index be207ef..c1b2c17 100644 --- a/rwx/prj/sphinx.py +++ b/rwx/prj/sphinx.py @@ -14,10 +14,6 @@ from rwx.prj import Project class SphinxProject(Project): """Child class for a project based on Sphinx.""" - def __init__(self, file_path: str) -> None: - """Call the parent constructor.""" - super().__init__(file_path) - def build(self) -> None: """Build the project.""" output_root: Path = self.root / "out" @@ -31,9 +27,9 @@ class SphinxProject(Project): "-D", f"project={self.name}", "-D", - "master_doc={}".format("index"), + "master_doc=index", "-D", - "html_theme={}".format("sphinx_rtd_theme"), + "html_theme=sphinx_rtd_theme", "-c", str(self.root), # "-C", From 6f9ba7f8f704a24ded03b4c30071f9546b850ba1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 14 Sep 2024 18:16:40 +0200 Subject: [PATCH 356/969] imports --- rwx/prj/sphinx.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py index c1b2c17..592e6dd 100644 --- a/rwx/prj/sphinx.py +++ b/rwx/prj/sphinx.py @@ -2,14 +2,14 @@ from typing import TYPE_CHECKING -if TYPE_CHECKING: - from pathlib import Path - from sphinx.cmd.build import build_main from rwx.fs import wipe from rwx.prj import Project +if TYPE_CHECKING: + from pathlib import Path + class SphinxProject(Project): """Child class for a project based on Sphinx.""" From 0ad5cc97018d13482820304d62494414a1eee995 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 14 Sep 2024 23:40:39 +0200 Subject: [PATCH 357/969] cyclic --- rwx/os/__init__.py | 25 +++++-------------------- rwx/os/abstract.py | 17 +++++++++++++++++ rwx/os/debian.py | 2 +- 3 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 rwx/os/abstract.py diff --git a/rwx/os/__init__.py b/rwx/os/__init__.py index 3dfa782..75a0bc9 100644 --- a/rwx/os/__init__.py +++ b/rwx/os/__init__.py @@ -1,30 +1,15 @@ """Control Operating Systems.""" -from __future__ import annotations - -from abc import ABC, abstractmethod from os import sep from pathlib import Path +from .abstract import OS from .debian import Debian -class OS(ABC): - """Operating System.""" - - def __init__(self, path: Path) -> None: - """Set root.""" - self.root = path - self.name = self.get_name() - - @abstractmethod - def get_name(self) -> str: - """Return mandatory name.""" - - @staticmethod - def from_path(path: Path) -> OS: - """Initialize from an already existing path.""" - return Debian(path) +def from_path(path: Path) -> OS: + """Initialize from an already existing path.""" + return Debian(path) -os = OS.from_path(Path(sep)) +up = from_path(Path(sep)) diff --git a/rwx/os/abstract.py b/rwx/os/abstract.py new file mode 100644 index 0000000..2d86f7e --- /dev/null +++ b/rwx/os/abstract.py @@ -0,0 +1,17 @@ +"""Abstract Operating System.""" + +from abc import ABC, abstractmethod +from pathlib import Path + + +class OS(ABC): + """Operating System.""" + + def __init__(self, path: Path) -> None: + """Set root.""" + self.root = path + self.name = self.get_name() + + @abstractmethod + def get_name(self) -> str: + """Return mandatory name.""" diff --git a/rwx/os/debian.py b/rwx/os/debian.py index dbaaabb..98c8928 100644 --- a/rwx/os/debian.py +++ b/rwx/os/debian.py @@ -1,6 +1,6 @@ """Debian operating system.""" -from . import OS +from .abstract import OS class Debian(OS): From f2991cff049828b0e28c2c24b6eda712f7357894 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 15 Sep 2024 01:35:33 +0200 Subject: [PATCH 358/969] pm/str --- rwx/os/pm/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rwx/os/pm/__init__.py b/rwx/os/pm/__init__.py index 0bcf1e6..e359a88 100644 --- a/rwx/os/pm/__init__.py +++ b/rwx/os/pm/__init__.py @@ -15,3 +15,9 @@ class PM(ABC): @abstractmethod def get_install_command(self) -> Command: """Command to install package(s).""" + + def __str__(self) -> str: + """Return commands.""" + return f"""\ +install = {self.install} +""" From 73c7ac00f426548d88c8af11e9a94d4788e817c8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 15 Sep 2024 01:37:45 +0200 Subject: [PATCH 359/969] os/str --- rwx/os/abstract.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rwx/os/abstract.py b/rwx/os/abstract.py index 2d86f7e..e985dc5 100644 --- a/rwx/os/abstract.py +++ b/rwx/os/abstract.py @@ -15,3 +15,10 @@ class OS(ABC): @abstractmethod def get_name(self) -> str: """Return mandatory name.""" + + def __str__(self) -> str: + """Return root & name.""" + return f"""\ +root = {self.root} +name = {self.name} +""" From 5038e587af65449a7f674be2da7849a8c8d7ab6f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 15 Sep 2024 01:45:06 +0200 Subject: [PATCH 360/969] command/str --- rwx/ps/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 3ea9702..7f21c5d 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -13,6 +13,13 @@ class Command: self.raw = arguments self.flat: list[str] = [] + def __str__(self) -> str: + """Return raw & flat.""" + return f"""\ + raw = {self.raw} +flat = {self.flat} +""" + def get_tuples_args(*items: str | tuple[str, ...]) -> list[str]: """Turn arguments tuples into an arguments list.""" From 304c2bc617b49e8fc466e212f323cf5e2fbd42b3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 15 Sep 2024 01:46:25 +0200 Subject: [PATCH 361/969] project/str --- rwx/prj/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rwx/prj/__init__.py b/rwx/prj/__init__.py index 36dab99..04f1cd9 100644 --- a/rwx/prj/__init__.py +++ b/rwx/prj/__init__.py @@ -11,3 +11,11 @@ class Project: self.file: Path = Path(file_path).resolve() self.root: Path = self.file.parent self.name: str = self.root.name + + def __str__(self) -> str: + """Return file, root & name.""" + return f"""\ +file = {self.file} +root = {self.root} +name = {self.name} +""" From 63c179a0a48b237ae5a581ed823c93ce062f83fe Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 15 Sep 2024 01:49:39 +0200 Subject: [PATCH 362/969] pm/clean --- rwx/os/pm/__init__.py | 6 ++++++ rwx/os/pm/apt.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/rwx/os/pm/__init__.py b/rwx/os/pm/__init__.py index e359a88..d248e47 100644 --- a/rwx/os/pm/__init__.py +++ b/rwx/os/pm/__init__.py @@ -10,8 +10,13 @@ class PM(ABC): def __init__(self) -> None: """Set commands.""" + self.clean = self.get_clean_command() self.install = self.get_install_command() + @abstractmethod + def get_clean_command(self) -> Command: + """Command to clean packages cache.""" + @abstractmethod def get_install_command(self) -> Command: """Command to install package(s).""" @@ -19,5 +24,6 @@ class PM(ABC): def __str__(self) -> str: """Return commands.""" return f"""\ + clean = {self.clean} install = {self.install} """ diff --git a/rwx/os/pm/apt.py b/rwx/os/pm/apt.py index ac669b6..03217b8 100644 --- a/rwx/os/pm/apt.py +++ b/rwx/os/pm/apt.py @@ -7,6 +7,10 @@ from rwx.ps import Command class APT(PM): """Advanced Package Tool.""" + def get_clean_command(self) -> Command: + """Return clean command.""" + return Command() + def get_install_command(self) -> Command: """Return install command.""" return Command() From f8567686fd196d36ef6dd6c2be6304bbef8b328c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 15 Sep 2024 01:59:00 +0200 Subject: [PATCH 363/969] project/repr --- rwx/prj/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rwx/prj/__init__.py b/rwx/prj/__init__.py index 04f1cd9..f4a8acb 100644 --- a/rwx/prj/__init__.py +++ b/rwx/prj/__init__.py @@ -6,15 +6,21 @@ from pathlib import Path class Project: """Parent class for any type of project.""" - def __init__(self, file_path: str) -> None: + def __init__(self, file: Path) -> None: """Set file, root & name.""" - self.file: Path = Path(file_path).resolve() + self.raw = file + self.file = self.raw.resolve() self.root: Path = self.file.parent self.name: str = self.root.name + def __repr__(self) -> str: + """Represent project.""" + return f"Project(file={self.raw!r})" + def __str__(self) -> str: """Return file, root & name.""" return f"""\ + raw = {self.raw} file = {self.file} root = {self.root} name = {self.name} From 5a25c6df27b8be0530f286a27d29e7db55c7f359 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 15 Sep 2024 02:02:36 +0200 Subject: [PATCH 364/969] command/repr --- rwx/ps/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 7f21c5d..54d58cf 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -13,6 +13,10 @@ class Command: self.raw = arguments self.flat: list[str] = [] + def __repr__(self) -> str: + """Represent command.""" + return f"Command({self.raw!r})" + def __str__(self) -> str: """Return raw & flat.""" return f"""\ From 04eaae7ba3042b33c9debcac8d4fb678ada1e77d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 15 Sep 2024 15:03:13 +0200 Subject: [PATCH 365/969] pyproject/pydoclint --- pyproject.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 756a434..462a1d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,11 @@ requires-python = ">= 3.11" [tool.hatch.version] path = "rwx/__init__.py" +[tool.pydoclint] +allow-init-docstring = true +skip-checking-short-docstrings = false +style = "sphinx" + [tool.ruff] line-length = 80 From db47d5c80a70253b584a3cefcee35dc97bf194ea Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 15 Sep 2024 15:07:47 +0200 Subject: [PATCH 366/969] doc/arg.split --- rwx/arg/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rwx/arg/__init__.py b/rwx/arg/__init__.py index 71ce0a7..a35dd4f 100644 --- a/rwx/arg/__init__.py +++ b/rwx/arg/__init__.py @@ -4,6 +4,10 @@ import sys def split() -> tuple[str, list[str]]: - """Split command & actual arguments.""" + """Split command & actual arguments. + + :return: both + :rtype: tuple[str, list[str]] + """ command, *arguments = sys.argv return command, arguments From 2f0c3a04874805570b850bb415e20091a204516d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 15 Sep 2024 23:05:05 +0200 Subject: [PATCH 367/969] readme/wipe --- readme.fr.rst | 7 ------- readme.rst | 8 -------- 2 files changed, 15 deletions(-) delete mode 100644 readme.fr.rst delete mode 100644 readme.rst diff --git a/readme.fr.rst b/readme.fr.rst deleted file mode 100644 index c8e6491..0000000 --- a/readme.fr.rst +++ /dev/null @@ -1,7 +0,0 @@ -****************** -Read Write eXecute -****************** - -`English `_ | `Français `_ - -Français diff --git a/readme.rst b/readme.rst deleted file mode 100644 index 954b375..0000000 --- a/readme.rst +++ /dev/null @@ -1,8 +0,0 @@ -Read Write eXecute -================== - -`English `_ ---------------------------------- - -`Français `_ ----------------------------------- From c300ab86d730e88fc8775985f2fae36d213f7732 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 15 Sep 2024 23:35:51 +0200 Subject: [PATCH 368/969] readme/md --- readme.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 readme.md diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..b149e9d --- /dev/null +++ b/readme.md @@ -0,0 +1,52 @@ +# Read Write eXecute + +A tiny framework to read, write & execute things. + +--- + +## Why + +--- + +## How + +--- + +## What + +--- + +## Who + +### By + +* [Marc Beninca](https://marc.beninca.link) + +### For + +* myself + +--- + +## Where + +### Chat + +* [Discord](https://discord.com/channels/983145051985154108/1255894474895134761) +* [IRC](ircs://irc.libera.chat/##rwx) + +### Forge + +* [Repository](https://forge.rwx.work/rwx.work/rwx) +* [RSS](https://forge.rwx.work/rwx.work/rwx.rss) +* [Workflows](https://forge.rwx.work/rwx.work/rwx/actions) + +### Deployment + +* [Site](https://rwx.rwx.work) + +--- + +## When + +### Task stack From 26fea93bdb344a180bcf283435c489f81745e38c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 15 Sep 2024 23:40:15 +0200 Subject: [PATCH 369/969] stack --- readme.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/readme.md b/readme.md index b149e9d..a8a258c 100644 --- a/readme.md +++ b/readme.md @@ -50,3 +50,11 @@ A tiny framework to read, write & execute things. ## When ### Task stack + +* character constants for box drawing +* parse pyproject.toml to write commands +* write classes for + * steps bars to log + * system commands to run + * with single call of subprocess.run + * or alternate subprocess method? From ca88e5bc1d03137626ecd2887800b75ef273f421 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 16 Sep 2024 01:17:55 +0200 Subject: [PATCH 370/969] doc/quiet --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 462a1d5..1d231ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,7 @@ path = "rwx/__init__.py" [tool.pydoclint] allow-init-docstring = true +quiet = true skip-checking-short-docstrings = false style = "sphinx" From 450e10e2f4d82997baf6942f98aa18d3ca48d435 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 16 Sep 2024 11:14:40 +0200 Subject: [PATCH 371/969] class,os --- rwx/__init__.py | 17 +++++++++++++++++ rwx/os/abstract.py | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/rwx/__init__.py b/rwx/__init__.py index a1c5ee6..ee9f51e 100644 --- a/rwx/__init__.py +++ b/rwx/__init__.py @@ -1,3 +1,20 @@ """Read Write eXecute.""" __version__ = "0.0.1" + + +class Class: + """Root class.""" + + def __repr__(self) -> str: + """Represent object variables. + + :return: representation + :rtype: str + """ + name = self.__class__.__name__ + attributes = [ + f"{k}={v!r}" for k, v in vars(self).items() if not k.startswith("_") + ] + arguments = ", ".join(attributes) + return f"{name}({arguments})" diff --git a/rwx/os/abstract.py b/rwx/os/abstract.py index e985dc5..8b99c28 100644 --- a/rwx/os/abstract.py +++ b/rwx/os/abstract.py @@ -3,8 +3,10 @@ from abc import ABC, abstractmethod from pathlib import Path +from rwx import Class -class OS(ABC): + +class OS(Class, ABC): """Operating System.""" def __init__(self, path: Path) -> None: From b7eec788f7b0a77355835a323516adaa5b19aacd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 16 Sep 2024 11:35:29 +0200 Subject: [PATCH 372/969] =?UTF-8?q?=E2=88=92repr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rwx/err/__init__.py | 4 +++- rwx/os/pm/__init__.py | 3 ++- rwx/prj/__init__.py | 8 +++----- rwx/ps/__init__.py | 8 ++------ 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/rwx/err/__init__.py b/rwx/err/__init__.py index 294d8d8..53a63c7 100644 --- a/rwx/err/__init__.py +++ b/rwx/err/__init__.py @@ -1,5 +1,7 @@ """Handle errors.""" +from rwx import Class -class Error(Exception): + +class Error(Class, Exception): """Parent class for all errors.""" diff --git a/rwx/os/pm/__init__.py b/rwx/os/pm/__init__.py index d248e47..b3cacc4 100644 --- a/rwx/os/pm/__init__.py +++ b/rwx/os/pm/__init__.py @@ -2,10 +2,11 @@ from abc import ABC, abstractmethod +from rwx import Class from rwx.ps import Command -class PM(ABC): +class PM(Class, ABC): """Package Manager.""" def __init__(self) -> None: diff --git a/rwx/prj/__init__.py b/rwx/prj/__init__.py index f4a8acb..3cba90b 100644 --- a/rwx/prj/__init__.py +++ b/rwx/prj/__init__.py @@ -2,8 +2,10 @@ from pathlib import Path +from rwx import Class -class Project: + +class Project(Class): """Parent class for any type of project.""" def __init__(self, file: Path) -> None: @@ -13,10 +15,6 @@ class Project: self.root: Path = self.file.parent self.name: str = self.root.name - def __repr__(self) -> str: - """Represent project.""" - return f"Project(file={self.raw!r})" - def __str__(self) -> str: """Return file, root & name.""" return f"""\ diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 54d58cf..601aca3 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -2,10 +2,10 @@ import subprocess -from rwx import txt +from rwx import Class, txt -class Command: +class Command(Class): """Command to run.""" def __init__(self, *arguments: str | tuple[str, ...]) -> None: @@ -13,10 +13,6 @@ class Command: self.raw = arguments self.flat: list[str] = [] - def __repr__(self) -> str: - """Represent command.""" - return f"Command({self.raw!r})" - def __str__(self) -> str: """Return raw & flat.""" return f"""\ From 487d7cb9b2edd5d9d7f058da427c8e2db5a45176 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 16 Sep 2024 12:04:43 +0200 Subject: [PATCH 373/969] str --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index a8a258c..e2beac8 100644 --- a/readme.md +++ b/readme.md @@ -52,6 +52,7 @@ A tiny framework to read, write & execute things. ### Task stack * character constants for box drawing +* common __str__ function * parse pyproject.toml to write commands * write classes for * steps bars to log From 8227524a7c45a1ac01a7b6c4568507ee289b94a4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 16 Sep 2024 21:41:45 +0200 Subject: [PATCH 374/969] class/str --- rwx/__init__.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/rwx/__init__.py b/rwx/__init__.py index ee9f51e..50c7cbe 100644 --- a/rwx/__init__.py +++ b/rwx/__init__.py @@ -2,14 +2,16 @@ __version__ = "0.0.1" +from os import linesep + class Class: """Root class.""" def __repr__(self) -> str: - """Represent object variables. + """Return machine-readable state. - :return: representation + :return: state :rtype: str """ name = self.__class__.__name__ @@ -18,3 +20,14 @@ class Class: ] arguments = ", ".join(attributes) return f"{name}({arguments})" + + def __str__(self) -> str: + """Return human-readable state. + + :return: state + :rtype: str + """ + attributes = [ + f"{k} = {v}" for k, v in vars(self).items() if not k.startswith("_") + ] + return linesep.join(attributes) From e5bb634cf41e5266d1a6e254f241e6c9bf2066ef Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 16 Sep 2024 21:45:21 +0200 Subject: [PATCH 375/969] =?UTF-8?q?=E2=88=92str?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rwx/os/abstract.py | 7 ------- rwx/os/pm/__init__.py | 7 ------- rwx/prj/__init__.py | 9 --------- rwx/ps/__init__.py | 7 ------- 4 files changed, 30 deletions(-) diff --git a/rwx/os/abstract.py b/rwx/os/abstract.py index 8b99c28..f4837fc 100644 --- a/rwx/os/abstract.py +++ b/rwx/os/abstract.py @@ -17,10 +17,3 @@ class OS(Class, ABC): @abstractmethod def get_name(self) -> str: """Return mandatory name.""" - - def __str__(self) -> str: - """Return root & name.""" - return f"""\ -root = {self.root} -name = {self.name} -""" diff --git a/rwx/os/pm/__init__.py b/rwx/os/pm/__init__.py index b3cacc4..6236ee6 100644 --- a/rwx/os/pm/__init__.py +++ b/rwx/os/pm/__init__.py @@ -21,10 +21,3 @@ class PM(Class, ABC): @abstractmethod def get_install_command(self) -> Command: """Command to install package(s).""" - - def __str__(self) -> str: - """Return commands.""" - return f"""\ - clean = {self.clean} -install = {self.install} -""" diff --git a/rwx/prj/__init__.py b/rwx/prj/__init__.py index 3cba90b..c0251e2 100644 --- a/rwx/prj/__init__.py +++ b/rwx/prj/__init__.py @@ -14,12 +14,3 @@ class Project(Class): self.file = self.raw.resolve() self.root: Path = self.file.parent self.name: str = self.root.name - - def __str__(self) -> str: - """Return file, root & name.""" - return f"""\ - raw = {self.raw} -file = {self.file} -root = {self.root} -name = {self.name} -""" diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 601aca3..584c50d 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -13,13 +13,6 @@ class Command(Class): self.raw = arguments self.flat: list[str] = [] - def __str__(self) -> str: - """Return raw & flat.""" - return f"""\ - raw = {self.raw} -flat = {self.flat} -""" - def get_tuples_args(*items: str | tuple[str, ...]) -> list[str]: """Turn arguments tuples into an arguments list.""" From 622122cdefd7bd32a1647d24e3f637bbc555ae8f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 12:53:17 +0200 Subject: [PATCH 376/969] doc/prj --- rwx/prj/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rwx/prj/__init__.py b/rwx/prj/__init__.py index c0251e2..cfbe3ae 100644 --- a/rwx/prj/__init__.py +++ b/rwx/prj/__init__.py @@ -9,7 +9,11 @@ class Project(Class): """Parent class for any type of project.""" def __init__(self, file: Path) -> None: - """Set file, root & name.""" + """Set file, root & name. + + :param file: root reference file + :type file: Path + """ self.raw = file self.file = self.raw.resolve() self.root: Path = self.file.parent From d6e112d6c50115faa4d54c6c21fd6aa26541ce46 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 12:54:41 +0200 Subject: [PATCH 377/969] doc/debian --- rwx/os/debian.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rwx/os/debian.py b/rwx/os/debian.py index 98c8928..5cefdaa 100644 --- a/rwx/os/debian.py +++ b/rwx/os/debian.py @@ -7,5 +7,8 @@ class Debian(OS): """Debian operating system.""" def get_name(self) -> str: - """Return name.""" + """Return name. + + :rtype: str + """ return "Debian" From 012b10f7d56d12b7125798cbed00e7f28b8ef61f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 14:53:21 +0200 Subject: [PATCH 378/969] doc/grub --- rwx/grub/__init__.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/rwx/grub/__init__.py b/rwx/grub/__init__.py index 7c0cccc..572b13e 100644 --- a/rwx/grub/__init__.py +++ b/rwx/grub/__init__.py @@ -24,7 +24,19 @@ def make_image( memdisk_path: str, pubkey_path: str | None = None, ) -> None: - """Make a binary bootable image.""" + """Make a binary bootable image. + + :param image_format: output format (x86_64-efi, i386-pc, arm64-efi) + :type image_format: str + :param image_path: output file + :type image_path: str + :param modules: modules to embed + :type modules: list[str] + :param memdisk_path: archive to include + :type memdisk_path: str + :param pubkey_path: extra public key to add + :type pubkey_path: str | None + """ args: list[str | tuple[str, ...]] = [ "grub-mkimage", ("--compress", COMPRESSION), From b9754b5dde4ad682883f1ea7affabeb207c6a276 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 21:32:08 +0200 Subject: [PATCH 379/969] doc/cmd --- rwx/cmd/__init__.py | 6 +++++- rwx/cmd/squashfs/__init__.py | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/rwx/cmd/__init__.py b/rwx/cmd/__init__.py index ca4dced..be9e540 100644 --- a/rwx/cmd/__init__.py +++ b/rwx/cmd/__init__.py @@ -5,7 +5,11 @@ packages: list[str] = [] def need(command: str) -> None: - """Assert package dependency for a command.""" + """Assert package dependency for a command. + + :param command: name of the requested command + :type command: str + """ package: str | None match command: case "debootstrap": diff --git a/rwx/cmd/squashfs/__init__.py b/rwx/cmd/squashfs/__init__.py index db603da..b3ec864 100644 --- a/rwx/cmd/squashfs/__init__.py +++ b/rwx/cmd/squashfs/__init__.py @@ -1,16 +1,24 @@ """Wrap SquashFS commands.""" +from pathlib import Path + from rwx import cmd, ps cmd.need("mksquashfs") -def mksquashfs(input_root: str, output_file: str) -> None: - """Make a SquashFS bootable image file.""" +def mksquashfs(input_root: Path, output_file: Path) -> None: + """Make a SquashFS bootable image file. + + :param input_root: ? + :type input_root: Path + :param output_file: ? + :type output_file: Path + """ ps.run( "mksquashfs", - input_root, - output_file, + str(input_root), + str(output_file), "-comp", "zstd", "-Xcompression-level", From 2e00140e8267a2840828f1d4646cd01a0ed4e4b8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 22:08:14 +0200 Subject: [PATCH 380/969] doc/deb --- rwx/deb/__init__.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/rwx/deb/__init__.py b/rwx/deb/__init__.py index fcd4198..2537321 100644 --- a/rwx/deb/__init__.py +++ b/rwx/deb/__init__.py @@ -1,5 +1,7 @@ """Wrap Debian commands.""" +from pathlib import Path + from rwx import cmd, ps cmd.need("debootstrap") @@ -8,14 +10,22 @@ BOOTSTRAP_ARCHITECTURE = "amd64" BOOTSTRAP_VARIANT = "minbase" -def bootstrap(root_path: str, suite: str, mirror_location: str) -> None: - """Boostrap a base operating filesystem.""" - command = [ - ("debootstrap",), +def bootstrap(root_path: Path, suite: str, mirror_location: str) -> None: + """Boostrap a base operating filesystem. + + :param root_path: target output path + :type root_path: Path + :param suite: target distribution name + :type suite: str + :param mirror_location: source input repository + :type mirror_location: str + """ + command = ( + "debootstrap", ("--arch", BOOTSTRAP_ARCHITECTURE), ("--variant", BOOTSTRAP_VARIANT), - (suite,), - (root_path,), - (mirror_location,), - ] + suite, + str(root_path), + mirror_location, + ) ps.run(*command) From 3940d3219561aca50f321ad8749addaa325536bd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 22:14:01 +0200 Subject: [PATCH 381/969] doc/pm --- rwx/os/pm/__init__.py | 10 ++++++++-- rwx/os/pm/apt.py | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/rwx/os/pm/__init__.py b/rwx/os/pm/__init__.py index 6236ee6..c55179a 100644 --- a/rwx/os/pm/__init__.py +++ b/rwx/os/pm/__init__.py @@ -16,8 +16,14 @@ class PM(Class, ABC): @abstractmethod def get_clean_command(self) -> Command: - """Command to clean packages cache.""" + """Command to clean packages cache. + + :rtype: Command + """ @abstractmethod def get_install_command(self) -> Command: - """Command to install package(s).""" + """Command to install package(s). + + :rtype: Command + """ diff --git a/rwx/os/pm/apt.py b/rwx/os/pm/apt.py index 03217b8..3e3cb81 100644 --- a/rwx/os/pm/apt.py +++ b/rwx/os/pm/apt.py @@ -8,9 +8,15 @@ class APT(PM): """Advanced Package Tool.""" def get_clean_command(self) -> Command: - """Return clean command.""" + """Return clean command. + + :rtype: Command + """ return Command() def get_install_command(self) -> Command: - """Return install command.""" + """Return install command. + + :rtype: Command + """ return Command() From e9d228ba2c556822a946a146952312e719a13cd7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 22:17:41 +0200 Subject: [PATCH 382/969] doc/os --- rwx/os/__init__.py | 7 ++++++- rwx/os/abstract.py | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/rwx/os/__init__.py b/rwx/os/__init__.py index 75a0bc9..27c1748 100644 --- a/rwx/os/__init__.py +++ b/rwx/os/__init__.py @@ -8,7 +8,12 @@ from .debian import Debian def from_path(path: Path) -> OS: - """Initialize from an already existing path.""" + """Initialize from an already existing path. + + :param path: source root directory + :type path: Path + :rtype: OS + """ return Debian(path) diff --git a/rwx/os/abstract.py b/rwx/os/abstract.py index f4837fc..77f9cb1 100644 --- a/rwx/os/abstract.py +++ b/rwx/os/abstract.py @@ -10,10 +10,17 @@ class OS(Class, ABC): """Operating System.""" def __init__(self, path: Path) -> None: - """Set root.""" + """Set root. + + :param path: root directory + :type path: Path + """ self.root = path self.name = self.get_name() @abstractmethod def get_name(self) -> str: - """Return mandatory name.""" + """Return mandatory name. + + :rtype: str + """ From 149ed2dc3be27e1d336fffddf1bd3cfd6b3ded21 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 22:22:03 +0200 Subject: [PATCH 383/969] doc/log --- rwx/log/__init__.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rwx/log/__init__.py b/rwx/log/__init__.py index 3b245ae..53cfebc 100644 --- a/rwx/log/__init__.py +++ b/rwx/log/__init__.py @@ -5,7 +5,12 @@ import sys def get_file_logger(name: str) -> logging.Logger: - """Return a file logger.""" + """Return a file logger. + + :param name: arbitrary name + :type name: str + :rtype: logging.Logger + """ # formatter items = [ "%(name)s: %(asctime)s", @@ -27,7 +32,12 @@ def get_file_logger(name: str) -> logging.Logger: def get_stream_logger(level: int) -> logging.Logger: - """Return a stream logger.""" + """Return a stream logger. + + :param level: filtering level + :type level: int + :rtype: logging.Logger + """ # handler out_handler = logging.StreamHandler(stream=sys.stdout) out_handler.setLevel(level) From 313cc30aec004067751607d3ca62570d4ffc5671 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 22:35:05 +0200 Subject: [PATCH 384/969] doc/ps --- rwx/ps/__init__.py | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 584c50d..821b9e3 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -9,13 +9,22 @@ class Command(Class): """Command to run.""" def __init__(self, *arguments: str | tuple[str, ...]) -> None: - """Set raw & flat arguments.""" + """Set raw & flat arguments. + + :param *arguments: single argument or grouped ones + :type *arguments: str | tuple[str, ...] + """ self.raw = arguments self.flat: list[str] = [] def get_tuples_args(*items: str | tuple[str, ...]) -> list[str]: - """Turn arguments tuples into an arguments list.""" + """Turn arguments tuples into an arguments list. + + :param *items: single item or grouped ones + :type *items: str | tuple[str, ...] + :rtype: list[str] + """ args: list[str] = [] for item in items: match item: @@ -27,14 +36,26 @@ def get_tuples_args(*items: str | tuple[str, ...]) -> list[str]: def run(*items: str | tuple[str, ...]) -> subprocess.CompletedProcess: - """Run from a list of arguments tuples.""" + """Run from a list of arguments tuples. + + :param *items: single item or grouped ones + :type *items: str | tuple[str, ...] + :rtype: subprocess.CompletedProcess + """ return subprocess.run( get_tuples_args(*items), capture_output=False, check=True ) def run_line(*items: str | tuple[str, ...], charset: str = txt.CHARSET) -> str: - """Run and return output line.""" + """Run and return output line. + + :param *items: single item or grouped ones + :type *items: str | tuple[str, ...] + :param charset: charset to use for decoding binary output + :type charset: str + :rtype: str + """ line, *_ = run_lines(*items, charset=charset) return line @@ -42,7 +63,14 @@ def run_line(*items: str | tuple[str, ...], charset: str = txt.CHARSET) -> str: def run_lines( *items: str | tuple[str, ...], charset: str = txt.CHARSET ) -> list[str]: - """Run and return output lines.""" + """Run and return output lines. + + :param *items: single item or grouped ones + :type *items: str | tuple[str, ...] + :param charset: charset to use for decoding binary output + :type charset: str + :rtype: list[str] + """ process = subprocess.run( get_tuples_args(*items), capture_output=True, check=True ) From b05de437d000545c73d169debe36aff1a7d60edf Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 22:42:19 +0200 Subject: [PATCH 385/969] doc/wipe --- rwx/fs/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index ee1925d..1b9e811 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -69,7 +69,11 @@ def read_file_text(file_path: Path, charset: str = CHARSET) -> str: def wipe(path: Path) -> None: - """Wipe provided path, whether directory or file.""" + """Wipe provided path, whether directory or file. + + :param path: target path + :type path: Path + """ try: shutil.rmtree(path) except NotADirectoryError: From eb0f8621252b0daf3f83545d1754adf877dc3920 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 23:05:00 +0200 Subject: [PATCH 386/969] doc/write --- rwx/fs/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 1b9e811..7595335 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -83,6 +83,14 @@ def wipe(path: Path) -> None: def write(file_path: Path, text: str, charset: str = CHARSET) -> None: - """Write text into a file.""" + """Write text into a file. + + :param file_path: target file path + :type file_path: Path + :param text: content to write + :type text: str + :param charset: charset to use for encoding ouput + :type charset: str + """ with file_path.open(encoding=charset, mode="w") as file_object: file_object.write(text) From 2c6bec253c4ddf88fa567816963cb8e16be2ff73 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 23:07:41 +0200 Subject: [PATCH 387/969] doc/empty_file --- rwx/fs/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 7595335..21ead50 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -19,7 +19,11 @@ def create_image(file_path: str, size_bytes: int) -> None: def empty_file(path: Path) -> None: - """Empty the file at provided path.""" + """Empty the file at provided path. + + :param path: target file to empty + :type path: Path + """ write(path, "") From 0d77038392952ceb36786ffb00d59153c6086b2d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 23:17:36 +0200 Subject: [PATCH 388/969] doc/create_image --- rwx/fs/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 21ead50..b320ed2 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -9,12 +9,18 @@ from rwx import ps CHARSET = "UTF-8" -def create_image(file_path: str, size_bytes: int) -> None: - """Create a virtual device image file.""" +def create_image(file_path: Path, size_bytes: int) -> None: + """Create a virtual device image file. + + :param file_path: target image file + :type file_path: Path + :param size_bytes: virtual volume + :type size_bytes: int + """ ps.run( ("qemu-img", "create"), ("-f", "qcow2"), - (file_path, str(size_bytes)), + (str(file_path), str(size_bytes)), ) From 6fab5ce9b401eeffa123a7ba10aee71eba94a16c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 23:19:29 +0200 Subject: [PATCH 389/969] doc/make_directory --- rwx/fs/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index b320ed2..374a658 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -58,7 +58,11 @@ def get_path_uuid(path: str) -> str: def make_directory(path: Path) -> None: - """Make a directory (and its parents) from a path.""" + """Make a directory (and its parents) from a path. + + :param path: directory to create + :type path: Path + """ path.mkdir(exist_ok=True, parents=True) From 094d66bc33fc39d344153db245192da6caf7c007 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 23:23:38 +0200 Subject: [PATCH 390/969] doc/read_file_ --- rwx/fs/__init__.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 374a658..5767015 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -67,18 +67,37 @@ def make_directory(path: Path) -> None: def read_file_bytes(file_path: Path) -> bytes: - """Read whole file bytes.""" + """Read whole file bytes. + + :param file_path: source input file + :type file_path: Path + :rtype: bytes + """ with file_path.open("br") as file_object: return file_object.read() def read_file_lines(file_path: Path, charset: str = CHARSET) -> list[str]: - """Read whole file lines.""" + """Read whole file lines. + + :param file_path: source input file + :type file_path: Path + :param charset: charset to use for decoding input + :type charset: str + :rtype: list[str] + """ return read_file_text(file_path, charset).split(os.linesep) def read_file_text(file_path: Path, charset: str = CHARSET) -> str: - """Read whole file text.""" + """Read whole file text. + + :param file_path: source input file + :type file_path: Path + :param charset: charset to use for decoding input + :type charset: str + :rtype: str + """ return read_file_bytes(file_path).decode(charset) From 2327d5388dc93f1e5d6255dcfde567ef523c0ba2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 23:32:51 +0200 Subject: [PATCH 391/969] doc/get_path_uuid --- rwx/fs/__init__.py | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 5767015..6abcce7 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -33,27 +33,44 @@ def empty_file(path: Path) -> None: write(path, "") -def get_mount_uuid(path: str) -> str: - """Return the filesystem UUID of a mountpoint path.""" +def get_mount_uuid(path: Path) -> str: + """Return the filesystem UUID of a mountpoint path. + + :param path: mountpoint path + :type path: Path + :rtype: str + """ return ps.run_line( - ("findmnt",), - ("--noheadings",), + "findmnt", + "--noheadings", ("--output", "UUID"), - (path,), + str(path), ) -def get_path_mount(path: str) -> str: - """Return the mountpoint path of an arbitrary path.""" - return ps.run_line( - "stat", - ("--format", "%m"), - path, +def get_path_mount(path: Path) -> Path: + """Return the mountpoint path of an arbitrary path. + + :param path: arbitrary path + :type path: Path + :rtype: Path + """ + return Path( + ps.run_line( + "stat", + ("--format", "%m"), + str(path), + ) ) -def get_path_uuid(path: str) -> str: - """Return the filesystem UUID of an arbitrary path.""" +def get_path_uuid(path: Path) -> str: + """Return the filesystem UUID of an arbitrary path. + + :param path: arbitrary path + :type path: Path + :rtype: str + """ return get_mount_uuid(get_path_mount(path)) From e61be6cf4fdd00a51b6b7f039b005e1a58937051 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 23 Sep 2024 12:53:28 +0200 Subject: [PATCH 392/969] sw.freetube --- rwx/sw/freetube/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 rwx/sw/freetube/__init__.py diff --git a/rwx/sw/freetube/__init__.py b/rwx/sw/freetube/__init__.py new file mode 100644 index 0000000..cb60ff9 --- /dev/null +++ b/rwx/sw/freetube/__init__.py @@ -0,0 +1 @@ +"""Handle FreeTube configuration.""" From 19153b3bc1f7372b2142f1ec403afb87012f003b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 23 Sep 2024 13:04:56 +0200 Subject: [PATCH 393/969] freetube.db --- rwx/sw/freetube/db.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 rwx/sw/freetube/db.py diff --git a/rwx/sw/freetube/db.py b/rwx/sw/freetube/db.py new file mode 100644 index 0000000..4b3f56b --- /dev/null +++ b/rwx/sw/freetube/db.py @@ -0,0 +1,20 @@ +"""Handle FreeTube db.""" + +def to_db(value: object) -> str: + """Render value as string. + + :param value: value to render + :type value: object + :rtype: str + """ + match value: + case bool(): + text = str(value).lower() + case dict(): + sub = ",".join([f'"{i}":{to_db(v)}' for i, v in value.items()]) + text = f"{{{sub}}}" + case float() | str(): + text = f'"{value}"' + case _: + text = str(value) + return text From 45df47519543f239ba7e4ef7ac6c4969aa1c315d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 23 Sep 2024 13:27:16 +0200 Subject: [PATCH 394/969] freetube.settings --- rwx/sw/freetube/__init__.py | 2 +- rwx/sw/freetube/db.py | 2 +- rwx/sw/freetube/settings.py | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 rwx/sw/freetube/settings.py diff --git a/rwx/sw/freetube/__init__.py b/rwx/sw/freetube/__init__.py index cb60ff9..250b9c3 100644 --- a/rwx/sw/freetube/__init__.py +++ b/rwx/sw/freetube/__init__.py @@ -1 +1 @@ -"""Handle FreeTube configuration.""" +"""Configure FreeTube.""" diff --git a/rwx/sw/freetube/db.py b/rwx/sw/freetube/db.py index 4b3f56b..9e37162 100644 --- a/rwx/sw/freetube/db.py +++ b/rwx/sw/freetube/db.py @@ -1,4 +1,4 @@ -"""Handle FreeTube db.""" +"""Output FreeTube db.""" def to_db(value: object) -> str: """Render value as string. diff --git a/rwx/sw/freetube/settings.py b/rwx/sw/freetube/settings.py new file mode 100644 index 0000000..67bb084 --- /dev/null +++ b/rwx/sw/freetube/settings.py @@ -0,0 +1,33 @@ +"""FreeTube settings.""" + +from rwx import Class + +from .db import to_db + + +class Setting(Class): + """FreeTube setting.""" + + def __init__(self, uid: str, value: object) -> None: + """Set uid & value. + + :param uid: unique identifier + :type uid: str + :param value: value + :type value: object + """ + self.uid = uid + self.value = value + + def to_db(self) -> str: + """Return uid & value as db string. + + :rtype: str + """ + return f"""\ +{{\ +"_id":"{self.uid}"\ +,\ +"value":{to_db(self.value)}\ +}}\ +""" From 2a01ef0066b332f7165f298bfab8a907e67f5d48 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 23 Sep 2024 14:24:58 +0200 Subject: [PATCH 395/969] freetube.channels --- rwx/sw/freetube/channels.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 rwx/sw/freetube/channels.py diff --git a/rwx/sw/freetube/channels.py b/rwx/sw/freetube/channels.py new file mode 100644 index 0000000..48f6d05 --- /dev/null +++ b/rwx/sw/freetube/channels.py @@ -0,0 +1,29 @@ +"""FreeTube channels.""" + +from rwx import Class + + +class Channel(Class): + """FreeTube channel.""" + + def __init__(self, uid: str, name: str) -> None: + """Set uid & name. + + :param uid: unique identifier + :type uid: str + :param name: label + :type name: str + """ + self.id = uid + self.name = name + + def to_db(self) -> str: + """Return identifier as db. + + :rtype: str + """ + return f"""\ +{{\ +"id":"{self.id}"\ +}}\ +""" From 6ece695be4c1d2d508bd4aaebc12798ebdf9a484 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 23 Sep 2024 14:35:16 +0200 Subject: [PATCH 396/969] channel.uid --- rwx/sw/freetube/channels.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rwx/sw/freetube/channels.py b/rwx/sw/freetube/channels.py index 48f6d05..30777e9 100644 --- a/rwx/sw/freetube/channels.py +++ b/rwx/sw/freetube/channels.py @@ -14,7 +14,7 @@ class Channel(Class): :param name: label :type name: str """ - self.id = uid + self.uid = uid self.name = name def to_db(self) -> str: @@ -24,6 +24,6 @@ class Channel(Class): """ return f"""\ {{\ -"id":"{self.id}"\ +"id":"{self.uid}"\ }}\ """ From 46ec104b7571a8dd1de42a5044841aaa28305015 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 23 Sep 2024 14:35:32 +0200 Subject: [PATCH 397/969] freetube.videos --- rwx/sw/freetube/videos.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 rwx/sw/freetube/videos.py diff --git a/rwx/sw/freetube/videos.py b/rwx/sw/freetube/videos.py new file mode 100644 index 0000000..8a53713 --- /dev/null +++ b/rwx/sw/freetube/videos.py @@ -0,0 +1,33 @@ +"""FreeTube videos.""" + +from rwx import Class + + +class Video(Class): + """FreeTube video.""" + + def __init__(self, uid: str, name: str) -> None: + """Set id & name. + + :param uid: identifier + :type uid: str + :param name: label + :type name: str + """ + self.uid = uid + self.name = name + + def to_db(self) -> str: + """Return identifier, zero length & title. + + :rtype: str + """ + return f"""\ +{{\ +"videoId":"{self.uid}"\ +,\ +"lengthSeconds":0\ +,\ +"title":"{self.name}"\ +}}\ +""" From a92a3a786a672dc93b3ad20904ffdcc1b94c5b6f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 23 Sep 2024 14:46:13 +0200 Subject: [PATCH 398/969] freetube.playlists --- rwx/sw/freetube/playlists.py | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 rwx/sw/freetube/playlists.py diff --git a/rwx/sw/freetube/playlists.py b/rwx/sw/freetube/playlists.py new file mode 100644 index 0000000..4183336 --- /dev/null +++ b/rwx/sw/freetube/playlists.py @@ -0,0 +1,47 @@ +"""FreeTube playlists.""" + +from rwx import Class + +from .videos import Video + + +class Playlist(Class): + """FreeTube playlist.""" + + def __init__(self, uid: str, name: str) -> None: + """Set uid & name. + + :param uid: identifier + :type uid: str + :param name: label + :type name: str + """ + self.uid = uid + self.name = name + self.videos: list[Video] = [] + + def add(self, video: Video) -> None: + """Add video. + + :param video: video to add + :type video: Video + """ + self.videos.append(video) + + def to_db(self) -> str: + """Return identifier, name & videos. + + :rtype: str + """ + videos = ",".join([video.to_db() for video in self.videos]) + return f"""\ +{{\ +"_id":"{self.uid}"\ +,\ +"playlistName":"{self.name}"\ +,\ +"protected":true\ +,\ +"videos":[{videos}]\ +}}\ +""" From edd8e15978b1d08938f363f48339fa691776afe7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 23 Sep 2024 14:59:00 +0200 Subject: [PATCH 399/969] freetube.profiles --- rwx/sw/freetube/profiles.py | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 rwx/sw/freetube/profiles.py diff --git a/rwx/sw/freetube/profiles.py b/rwx/sw/freetube/profiles.py new file mode 100644 index 0000000..ffb0adc --- /dev/null +++ b/rwx/sw/freetube/profiles.py @@ -0,0 +1,45 @@ +"""FreeTube profiles.""" + +from rwx import Class + +from .channels import Channel + + +class Profile(Class): + """FreeTube profile.""" + + def __init__(self, uid: str, name: str) -> None: + """Set uid & name. + + :param uid: unique identifier + :type uid: str + :param name: label + :type name: str + """ + self.id = uid + self.name = name + self.channels: list[Channel] = [] + + def add(self, channel: Channel) -> None: + """Add channel. + + :param channel: channel to add + :type channel: Channel + """ + self.channels.append(channel) + + def to_db(self) -> str: + """Return identifier, name & channels. + + :rtype: str + """ + channels = ",".join([channel.to_db() for channel in self.channels]) + return f"""\ +{{\ +"_id":"{self.id}"\ +,\ +"name":"{self.name}"\ +,\ +"subscriptions":[{channels}]\ +}}\ +""" From 5eae0334de4494b63207e8e1ad784f8a4c1c7d4d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 23 Sep 2024 17:25:57 +0200 Subject: [PATCH 400/969] fs.read_file_object --- rwx/fs/__init__.py | 14 ++++++++++++++ rwx/sw/freetube/db.py | 1 + 2 files changed, 15 insertions(+) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 6abcce7..184c198 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -2,6 +2,7 @@ import os import shutil +import tomllib from pathlib import Path from rwx import ps @@ -106,6 +107,19 @@ def read_file_lines(file_path: Path, charset: str = CHARSET) -> list[str]: return read_file_text(file_path, charset).split(os.linesep) +def read_file_object(file_path: Path, charset: str = CHARSET) -> object: + """Read whole file as toml object. + + :param file_path: source input file + :type file_path: Path + :param charset: charset to use for decoding input + :type charset: str + :rtype: object + """ + text = read_file_text(file_path, charset) + return tomllib.loads(text) + + def read_file_text(file_path: Path, charset: str = CHARSET) -> str: """Read whole file text. diff --git a/rwx/sw/freetube/db.py b/rwx/sw/freetube/db.py index 9e37162..e3eb31e 100644 --- a/rwx/sw/freetube/db.py +++ b/rwx/sw/freetube/db.py @@ -1,5 +1,6 @@ """Output FreeTube db.""" + def to_db(value: object) -> str: """Render value as string. From daccf01b8c406704d088a621a6b18f567bcba673 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 23 Sep 2024 18:48:44 +0200 Subject: [PATCH 401/969] read_file_dict --- rwx/fs/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 184c198..46a26e6 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -107,14 +107,14 @@ def read_file_lines(file_path: Path, charset: str = CHARSET) -> list[str]: return read_file_text(file_path, charset).split(os.linesep) -def read_file_object(file_path: Path, charset: str = CHARSET) -> object: +def read_file_dict(file_path: Path, charset: str = CHARSET) -> dict: """Read whole file as toml object. :param file_path: source input file :type file_path: Path :param charset: charset to use for decoding input :type charset: str - :rtype: object + :rtype: dict """ text = read_file_text(file_path, charset) return tomllib.loads(text) From eb3c9814bb1f1f5408fa2667437cbf4050ac1493 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 23 Sep 2024 18:49:34 +0200 Subject: [PATCH 402/969] mv --- rwx/fs/__init__.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 46a26e6..205746d 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -95,18 +95,6 @@ def read_file_bytes(file_path: Path) -> bytes: return file_object.read() -def read_file_lines(file_path: Path, charset: str = CHARSET) -> list[str]: - """Read whole file lines. - - :param file_path: source input file - :type file_path: Path - :param charset: charset to use for decoding input - :type charset: str - :rtype: list[str] - """ - return read_file_text(file_path, charset).split(os.linesep) - - def read_file_dict(file_path: Path, charset: str = CHARSET) -> dict: """Read whole file as toml object. @@ -120,6 +108,18 @@ def read_file_dict(file_path: Path, charset: str = CHARSET) -> dict: return tomllib.loads(text) +def read_file_lines(file_path: Path, charset: str = CHARSET) -> list[str]: + """Read whole file lines. + + :param file_path: source input file + :type file_path: Path + :param charset: charset to use for decoding input + :type charset: str + :rtype: list[str] + """ + return read_file_text(file_path, charset).split(os.linesep) + + def read_file_text(file_path: Path, charset: str = CHARSET) -> str: """Read whole file text. From 1c4f52007cb1022da2011006708f1160afed9941 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 13 Oct 2024 21:42:16 +0200 Subject: [PATCH 403/969] build & workflow --- .forgejo/workflows/main.yaml | 18 ++++++++++++++++++ build.py | 11 +++++++++++ 2 files changed, 29 insertions(+) create mode 100644 .forgejo/workflows/main.yaml create mode 100755 build.py diff --git a/.forgejo/workflows/main.yaml b/.forgejo/workflows/main.yaml new file mode 100644 index 0000000..78facd9 --- /dev/null +++ b/.forgejo/workflows/main.yaml @@ -0,0 +1,18 @@ +on: [push] +jobs: + job: + container: + image: ${{vars.DOCKER}}debian:bookworm + steps: + - name: spcd + env: + SPCD: ${{vars.SPCD}} + SPCD_SSH_HOSTS: ${{vars.SPCD_SSH_HOSTS}} + SPCD_SSH_KEY: ${{secrets.SPCD_SSH_KEY}} + SPCD_TXT_LOCALE: ${{vars.SPCD_TXT_LOCALE}} + run: ${{vars.SPCD}} + + - run: spcd-check-project + - run: spcd-build-project + - run: spcd-browse-workspace + - run: spcd-synchronize diff --git a/build.py b/build.py new file mode 100755 index 0000000..3a0a957 --- /dev/null +++ b/build.py @@ -0,0 +1,11 @@ +#! /usr/bin/env python3 +"""Dummy build.""" + +from pathlib import Path + +from rwx.fs import make_directory, write + +if __name__ == "__main__": + out = Path(__file__).parent / "out" / "web" + make_directory(out) + write(out / "index.html", "rwx.rwx.work") From 98350281993d8821cba71087f7ad8ad83e9dded7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 13 Oct 2024 21:46:54 +0200 Subject: [PATCH 404/969] =?UTF-8?q?=E2=88=92check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .forgejo/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/main.yaml b/.forgejo/workflows/main.yaml index 78facd9..bcc505a 100644 --- a/.forgejo/workflows/main.yaml +++ b/.forgejo/workflows/main.yaml @@ -12,7 +12,7 @@ jobs: SPCD_TXT_LOCALE: ${{vars.SPCD_TXT_LOCALE}} run: ${{vars.SPCD}} - - run: spcd-check-project + #- run: spcd-check-project - run: spcd-build-project - run: spcd-browse-workspace - run: spcd-synchronize From e32da9d7fa8717e9fb5561e73f744f9c15ac54d5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 22 Oct 2024 18:24:17 +0200 Subject: [PATCH 405/969] ft/artist --- rwx/sw/freetube/artists.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 rwx/sw/freetube/artists.py diff --git a/rwx/sw/freetube/artists.py b/rwx/sw/freetube/artists.py new file mode 100644 index 0000000..8100fba --- /dev/null +++ b/rwx/sw/freetube/artists.py @@ -0,0 +1,18 @@ +"""FreeTube artists.""" + +from rwx import Class + + +class Artist(Class): + """FreeTube artist.""" + + def __init__(self, uid: str, name:str) -> None: + """Set uid & name. + + :param uid: identifier + :type uid: str + :param name: label + :type name: str + """ + self.uid = uid + self.name = name From 75e8940a43931ddc61c44c7be765020830fd38da Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 22 Oct 2024 18:29:24 +0200 Subject: [PATCH 406/969] object --- rwx/__init__.py | 4 ++-- rwx/sw/freetube/artists.py | 4 ++-- rwx/sw/freetube/playlists.py | 4 ++-- rwx/sw/freetube/profiles.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rwx/__init__.py b/rwx/__init__.py index 50c7cbe..3dbfd68 100644 --- a/rwx/__init__.py +++ b/rwx/__init__.py @@ -5,8 +5,8 @@ __version__ = "0.0.1" from os import linesep -class Class: - """Root class.""" +class Object: + """Root object.""" def __repr__(self) -> str: """Return machine-readable state. diff --git a/rwx/sw/freetube/artists.py b/rwx/sw/freetube/artists.py index 8100fba..7c32f47 100644 --- a/rwx/sw/freetube/artists.py +++ b/rwx/sw/freetube/artists.py @@ -1,9 +1,9 @@ """FreeTube artists.""" -from rwx import Class +from rwx import Object -class Artist(Class): +class Artist(Object): """FreeTube artist.""" def __init__(self, uid: str, name:str) -> None: diff --git a/rwx/sw/freetube/playlists.py b/rwx/sw/freetube/playlists.py index 4183336..f4b17de 100644 --- a/rwx/sw/freetube/playlists.py +++ b/rwx/sw/freetube/playlists.py @@ -1,11 +1,11 @@ """FreeTube playlists.""" -from rwx import Class +from rwx import Object from .videos import Video -class Playlist(Class): +class Playlist(Object): """FreeTube playlist.""" def __init__(self, uid: str, name: str) -> None: diff --git a/rwx/sw/freetube/profiles.py b/rwx/sw/freetube/profiles.py index ffb0adc..e164296 100644 --- a/rwx/sw/freetube/profiles.py +++ b/rwx/sw/freetube/profiles.py @@ -1,11 +1,11 @@ """FreeTube profiles.""" -from rwx import Class +from rwx import Object from .channels import Channel -class Profile(Class): +class Profile(Object): """FreeTube profile.""" def __init__(self, uid: str, name: str) -> None: From 018f99c1d6002a14182e76363d6e89e9ead4c811 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 22 Oct 2024 18:33:35 +0200 Subject: [PATCH 407/969] object --- rwx/err/__init__.py | 4 ++-- rwx/os/abstract.py | 4 ++-- rwx/os/pm/__init__.py | 4 ++-- rwx/prj/__init__.py | 4 ++-- rwx/ps/__init__.py | 4 ++-- rwx/sw/freetube/artists.py | 2 +- rwx/sw/freetube/channels.py | 4 ++-- rwx/sw/freetube/settings.py | 4 ++-- rwx/sw/freetube/videos.py | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/rwx/err/__init__.py b/rwx/err/__init__.py index 53a63c7..6c473e0 100644 --- a/rwx/err/__init__.py +++ b/rwx/err/__init__.py @@ -1,7 +1,7 @@ """Handle errors.""" -from rwx import Class +from rwx import Object -class Error(Class, Exception): +class Error(Object, Exception): """Parent class for all errors.""" diff --git a/rwx/os/abstract.py b/rwx/os/abstract.py index 77f9cb1..98f3f0d 100644 --- a/rwx/os/abstract.py +++ b/rwx/os/abstract.py @@ -3,10 +3,10 @@ from abc import ABC, abstractmethod from pathlib import Path -from rwx import Class +from rwx import Object -class OS(Class, ABC): +class OS(Object, ABC): """Operating System.""" def __init__(self, path: Path) -> None: diff --git a/rwx/os/pm/__init__.py b/rwx/os/pm/__init__.py index c55179a..785ce74 100644 --- a/rwx/os/pm/__init__.py +++ b/rwx/os/pm/__init__.py @@ -2,11 +2,11 @@ from abc import ABC, abstractmethod -from rwx import Class +from rwx import Object from rwx.ps import Command -class PM(Class, ABC): +class PM(Object, ABC): """Package Manager.""" def __init__(self) -> None: diff --git a/rwx/prj/__init__.py b/rwx/prj/__init__.py index cfbe3ae..62d91d9 100644 --- a/rwx/prj/__init__.py +++ b/rwx/prj/__init__.py @@ -2,10 +2,10 @@ from pathlib import Path -from rwx import Class +from rwx import Object -class Project(Class): +class Project(Object): """Parent class for any type of project.""" def __init__(self, file: Path) -> None: diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 821b9e3..82c9640 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -2,10 +2,10 @@ import subprocess -from rwx import Class, txt +from rwx import Object, txt -class Command(Class): +class Command(Object): """Command to run.""" def __init__(self, *arguments: str | tuple[str, ...]) -> None: diff --git a/rwx/sw/freetube/artists.py b/rwx/sw/freetube/artists.py index 7c32f47..2981245 100644 --- a/rwx/sw/freetube/artists.py +++ b/rwx/sw/freetube/artists.py @@ -6,7 +6,7 @@ from rwx import Object class Artist(Object): """FreeTube artist.""" - def __init__(self, uid: str, name:str) -> None: + def __init__(self, uid: str, name: str) -> None: """Set uid & name. :param uid: identifier diff --git a/rwx/sw/freetube/channels.py b/rwx/sw/freetube/channels.py index 30777e9..556dea7 100644 --- a/rwx/sw/freetube/channels.py +++ b/rwx/sw/freetube/channels.py @@ -1,9 +1,9 @@ """FreeTube channels.""" -from rwx import Class +from rwx import Object -class Channel(Class): +class Channel(Object): """FreeTube channel.""" def __init__(self, uid: str, name: str) -> None: diff --git a/rwx/sw/freetube/settings.py b/rwx/sw/freetube/settings.py index 67bb084..621454b 100644 --- a/rwx/sw/freetube/settings.py +++ b/rwx/sw/freetube/settings.py @@ -1,11 +1,11 @@ """FreeTube settings.""" -from rwx import Class +from rwx import Object from .db import to_db -class Setting(Class): +class Setting(Object): """FreeTube setting.""" def __init__(self, uid: str, value: object) -> None: diff --git a/rwx/sw/freetube/videos.py b/rwx/sw/freetube/videos.py index 8a53713..6003c75 100644 --- a/rwx/sw/freetube/videos.py +++ b/rwx/sw/freetube/videos.py @@ -1,9 +1,9 @@ """FreeTube videos.""" -from rwx import Class +from rwx import Object -class Video(Class): +class Video(Object): """FreeTube video.""" def __init__(self, uid: str, name: str) -> None: From f7757d1fbf4697a39169773384f86190e5aa8bd8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 24 Oct 2024 11:21:05 +0200 Subject: [PATCH 408/969] artist.playlist --- rwx/sw/freetube/artists.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rwx/sw/freetube/artists.py b/rwx/sw/freetube/artists.py index 2981245..269c607 100644 --- a/rwx/sw/freetube/artists.py +++ b/rwx/sw/freetube/artists.py @@ -1,7 +1,12 @@ """FreeTube artists.""" +from typing import TYPE_CHECKING + from rwx import Object +if TYPE_CHECKING: + from .playlists import Playlist + class Artist(Object): """FreeTube artist.""" @@ -16,3 +21,4 @@ class Artist(Object): """ self.uid = uid self.name = name + self.playlist: Playlist From b9856a5e326085f80ef639da7844409a4ae4309f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 24 Oct 2024 12:11:32 +0200 Subject: [PATCH 409/969] language --- rwx/sw/freetube/languages.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 rwx/sw/freetube/languages.py diff --git a/rwx/sw/freetube/languages.py b/rwx/sw/freetube/languages.py new file mode 100644 index 0000000..42f1e75 --- /dev/null +++ b/rwx/sw/freetube/languages.py @@ -0,0 +1,18 @@ +"""FreeTube languages.""" + +from rwx import Object + + +class Language(Object): + """FreeTube language.""" + + def __init__(self, uid: str, name: str) -> None: + """Set uid & name. + + :param uid: identifier + :type uid: str + :param name: label + :type name: str + """ + self.uid = uid + self.name = name From 925006e4969d0b846e5922e7e1ae7787735f5520 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 24 Oct 2024 12:21:23 +0200 Subject: [PATCH 410/969] language.playlist --- rwx/sw/freetube/languages.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rwx/sw/freetube/languages.py b/rwx/sw/freetube/languages.py index 42f1e75..beeb173 100644 --- a/rwx/sw/freetube/languages.py +++ b/rwx/sw/freetube/languages.py @@ -1,7 +1,12 @@ """FreeTube languages.""" +from typing import TYPE_CHECKING + from rwx import Object +if TYPE_CHECKING: + from .playlists import Playlist + class Language(Object): """FreeTube language.""" @@ -16,3 +21,4 @@ class Language(Object): """ self.uid = uid self.name = name + self.playlist: Playlist From 5dc81a45087ca697b2809c4722dfda95feb0f233 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 25 Oct 2024 16:19:42 +0200 Subject: [PATCH 411/969] artist/nbsp --- rwx/sw/freetube/artists.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rwx/sw/freetube/artists.py b/rwx/sw/freetube/artists.py index 269c607..0584296 100644 --- a/rwx/sw/freetube/artists.py +++ b/rwx/sw/freetube/artists.py @@ -20,5 +20,5 @@ class Artist(Object): :type name: str """ self.uid = uid - self.name = name + self.name = name.replace(" ", " ") self.playlist: Playlist From 0ae7d01a1ed6e4e5363f62ab8cf7f82a0c5bbe68 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 26 Oct 2024 10:57:08 +0200 Subject: [PATCH 412/969] =?UTF-8?q?artists=20=E2=86=92=20authors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rwx/sw/freetube/{artists.py => authors.py} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename rwx/sw/freetube/{artists.py => authors.py} (84%) diff --git a/rwx/sw/freetube/artists.py b/rwx/sw/freetube/authors.py similarity index 84% rename from rwx/sw/freetube/artists.py rename to rwx/sw/freetube/authors.py index 0584296..7f108e7 100644 --- a/rwx/sw/freetube/artists.py +++ b/rwx/sw/freetube/authors.py @@ -1,4 +1,4 @@ -"""FreeTube artists.""" +"""FreeTube authors.""" from typing import TYPE_CHECKING @@ -8,8 +8,8 @@ if TYPE_CHECKING: from .playlists import Playlist -class Artist(Object): - """FreeTube artist.""" +class Author(Object): + """FreeTube author.""" def __init__(self, uid: str, name: str) -> None: """Set uid & name. From 27329865ee44b6f3d75e19de078bef0706ef396d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 26 Oct 2024 10:57:20 +0200 Subject: [PATCH 413/969] fs/wipe --- rwx/fs/__init__.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 205746d..0772a8d 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -139,11 +139,9 @@ def wipe(path: Path) -> None: :type path: Path """ try: - shutil.rmtree(path) - except NotADirectoryError: path.unlink(missing_ok=True) - except FileNotFoundError: - pass + except IsADirectoryError: + shutil.rmtree(path) def write(file_path: Path, text: str, charset: str = CHARSET) -> None: From 125e2ac9ca9570d741f7bede5799f371195e8233 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 26 Oct 2024 11:29:40 +0200 Subject: [PATCH 414/969] author.to_db --- rwx/sw/freetube/authors.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rwx/sw/freetube/authors.py b/rwx/sw/freetube/authors.py index 7f108e7..f577701 100644 --- a/rwx/sw/freetube/authors.py +++ b/rwx/sw/freetube/authors.py @@ -20,5 +20,12 @@ class Author(Object): :type name: str """ self.uid = uid - self.name = name.replace(" ", " ") + self.name = name self.playlist: Playlist + + def to_db(self) -> str: + """Return non-breakable name. + + :rtype: str + """ + return self.name.replace(" ", " ") From a3191908ddfb3c3c3162f602673e8f3140487e5f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 26 Oct 2024 12:24:23 +0200 Subject: [PATCH 415/969] unicode --- rwx/sw/freetube/authors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rwx/sw/freetube/authors.py b/rwx/sw/freetube/authors.py index f577701..e7cb913 100644 --- a/rwx/sw/freetube/authors.py +++ b/rwx/sw/freetube/authors.py @@ -28,4 +28,4 @@ class Author(Object): :rtype: str """ - return self.name.replace(" ", " ") + return self.name.replace(" ", chr(0xA0)) From cc8ca58cffb6d2426a1370ba15e15814967a8e75 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 11:57:19 +0100 Subject: [PATCH 416/969] rescue/bash --- bash/ovh-rescue.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index bcd66c4..4487403 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -1,4 +1,6 @@ -function ovh-rescue-configure { +#! /usr/bin/env bash + +ovh_rescue_configure() { local host="${1}" local packages=( 'byobu' 'mosh' @@ -119,8 +121,8 @@ function ovh-rescue-wipe-1-2TB { local unit='mib' # lsblk - echo -n 'WIPE' "${device}" '/?\ OR CANCEL /!\' - read + echo -n 'WIPE' "${device}" "/?\\ OR CANCEL /!\\" + read -r # parted "${device}" --script mktable gpt # From 6f17ecfec36c12afc9c76527cc6fa39fc291f53a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 12:17:52 +0100 Subject: [PATCH 417/969] quoootes --- bash/ovh-rescue.sh | 103 +++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 4487403..e63c7b2 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -1,12 +1,12 @@ -#! /usr/bin/env bash +#! /usr/bin/env sh ovh_rescue_configure() { local host="${1}" local packages=( - 'byobu' 'mosh' + "byobu" "mosh" ) # apt / conf - echo -n "\ + printf "\ Acquire::AllowInsecureRepositories False; Acquire::AllowWeakRepositories False; Acquire::AllowDowngradeToInsecureRepositories False; @@ -16,26 +16,26 @@ APT::Install-Suggests False; APT::Get::Show-Versions True; Dir::Etc::SourceParts ''; Dpkg::Progress True; -" > '/etc/apt/apt.conf' +" > "/etc/apt/apt.conf" # apt / sources - echo -n "\ + printf "\ deb https://deb.debian.org/debian buster main contrib non-free deb https://deb.debian.org/debian buster-backports main contrib non-free deb https://deb.debian.org/debian buster-updates main contrib non-free deb https://deb.debian.org/debian-security buster/updates main contrib non-free -" > '/etc/apt/sources.list' +" > "/etc/apt/sources.list" # bash / rc main_link_bashrc # host name hostname "${host}" # locales - echo -n "\ + printf "\ en_US.UTF-8 UTF-8 fr_FR.UTF-8 UTF-8 " > '/etc/locale.gen' # fix alias - rm --force '/usr/share/locale/locale.alias' - ln --symbolic '/etc/locale.alias' '/usr/share/locale/locale.alias' + rm --force "/usr/share/locale/locale.alias" + ln --symbolic "/etc/locale.alias" "/usr/share/locale/locale.alias" # generate locales locale-gen # update catalog @@ -48,25 +48,25 @@ fr_FR.UTF-8 UTF-8 apt_clean_cache } -function ovh-rescue-install { - local release='buster' +ovh_rescue_install() { + local release="buster" local packages=( # installed - 'parted' 'mdadm' 'lvm2' + "parted" "mdadm" "lvm2" # install - 'lshw' - 'file' 'micro' - 'grub-efi-amd64-bin' 'grub-pc-bin' - 'htop' 'iotop' 'lsof' - 'exa' 'ncdu' 'nnn' 'ranger' 'tree' - 'squashfs-tools' - 'uuid-runtime' + "lshw" + "file" "micro" + "grub-efi-amd64-bin" "grub-pc-bin" + "htop" "iotop" "lsof" + "exa" "ncdu" "nnn" "ranger" "tree" + "squashfs-tools" + "uuid-runtime" ) local backports=( # installed - 'cryptsetup-bin' 'rsync' + "cryptsetup-bin" "rsync" # install - 'git' + "git" ) # update catalog apt-get update @@ -87,27 +87,28 @@ function ovh-rescue-install { apt_clean_cache } -function ovh-rescue-upload { +ovh_rescue_upload() { local host="${1}" if [ "${host}" ] ; then - local user='root' + local user="root" # local user_host="${user}@${host}" # remove fingerprints ssh-keygen -R "${host}" # copy ssh id ssh-copy-id \ - -o 'StrictHostKeyChecking=accept-new' \ + -o "StrictHostKeyChecking=accept-new" \ "${user_host}" # upload root rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" # call setup # TODO variable - ssh "${user_host}" -- "source '/etc/bash/main.sh' ; ovh-rescue-configure '${host}'" + ssh "${user_host}" -- \ + "source \"/etc/bash/main.sh\" ; ovh-rescue-configure \"${host}\"" # create session ssh "${user_host}" -- byobu new-session -d # send keys - ssh "${user_host}" -- byobu send-keys 'ovh-rescue-install' 'C-m' + ssh "${user_host}" -- byobu send-keys "ovh-rescue-install" "C-m" # attach session mosh "${user_host}" -- byobu attach-session else @@ -116,66 +117,66 @@ else fi } -function ovh-rescue-wipe-1-2TB { - local device='/dev/sda' - local unit='mib' +ovh_rescue_wipe_1_2TB() { + local device="/dev/sda" + local unit="mib" # lsblk - echo -n 'WIPE' "${device}" "/?\\ OR CANCEL /!\\" + printf "%s" "WIPE ${device} /?\\ OR CANCEL /!\\" read -r # parted "${device}" --script mktable gpt # - parted "${device}" unit "${unit}" mkpart 'crypt' 65795 1907729 + parted "${device}" unit "${unit}" mkpart "crypt" 65795 1907729 # - parted "${device}" unit "${unit}" mkpart 'boot' 259 65795 + parted "${device}" unit "${unit}" mkpart "boot" 259 65795 # - parted "${device}" unit "${unit}" mkpart 'esp' 2 259 + parted "${device}" unit "${unit}" mkpart "esp" 2 259 parted "${device}" set 3 esp on # parted "${device}" unit "${unit}" mkpart bios 1 2 parted "${device}" set 4 bios_grub on # wipe bios - dd if='/dev/zero' of='/dev/sda4' + dd if="/dev/zero" of="/dev/sda4" # format esp - mkfs.vfat -F 32 -n 'esp' '/dev/sda3' + mkfs.vfat -F 32 -n "esp" "/dev/sda3" # format boot - mkfs.ext4 -F -L 'boot' '/dev/sda2' + mkfs.ext4 -F -L "boot" "/dev/sda2" # read passphrase local passphrase - echo -n 'PassPhrase: ' + printf "PassPhrase: " read -r -s passphrase # encrypt echo "${passphrase}" \ | cryptsetup \ --verbose \ --batch-mode \ - --type 'luks2' \ - --pbkdf 'argon2id' \ - --cipher 'aes-xts-plain64' \ + --type "luks2" \ + --pbkdf "argon2id" \ + --cipher "aes-xts-plain64" \ --iter-time 8192 \ --key-size 512 \ - --hash 'sha512' \ + --hash "sha512" \ --use-random \ luksFormat \ - '/dev/sda1' + "/dev/sda1" # open echo "${passphrase}" \ - | cryptsetup luksOpen '/dev/sda1' 'crypt' + | cryptsetup luksOpen "/dev/sda1" "crypt" # pv - pvcreate '/dev/mapper/crypt' + pvcreate "/dev/mapper/crypt" # vg - vgcreate 'crypt' '/dev/mapper/crypt' + vgcreate "crypt" "/dev/mapper/crypt" # lv swap - lvcreate --name 'swap' --size '68719476736b' 'crypt' + lvcreate --name "swap" --size "68719476736b" "crypt" # lv data - lvcreate --name 'data' --extents '100%FREE' 'crypt' + lvcreate --name "data" --extents "100%FREE" "crypt" # format swap - mkswap --label 'swap' '/dev/mapper/crypt-swap' + mkswap --label "swap" "/dev/mapper/crypt-swap" # format data - mkfs.ext4 -L 'data' '/dev/mapper/crypt-data' + mkfs.ext4 -L "data" "/dev/mapper/crypt-data" # vg off - vgchange --activate n 'crypt' + vgchange --activate "n" "crypt" # close - cryptsetup luksClose 'crypt' + cryptsetup luksClose "crypt" } From 0ffbf27412914ba9904225063c76a735aa7f10d0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 12:29:48 +0100 Subject: [PATCH 418/969] arrays --- bash/ovh-rescue.sh | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index e63c7b2..b8af8c3 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -1,10 +1,7 @@ #! /usr/bin/env sh ovh_rescue_configure() { -local host="${1}" - local packages=( - "byobu" "mosh" - ) + local host="${1}" # apt / conf printf "\ Acquire::AllowInsecureRepositories False; @@ -43,31 +40,15 @@ fr_FR.UTF-8 UTF-8 # debian_disable_frontend # install packages - apt-get install --assume-yes "${packages[@]}" + apt-get install --assume-yes \ + "byobu" \ + "mosh" # apt_clean_cache } ovh_rescue_install() { local release="buster" - local packages=( - # installed - "parted" "mdadm" "lvm2" - # install - "lshw" - "file" "micro" - "grub-efi-amd64-bin" "grub-pc-bin" - "htop" "iotop" "lsof" - "exa" "ncdu" "nnn" "ranger" "tree" - "squashfs-tools" - "uuid-runtime" - ) - local backports=( - # installed - "cryptsetup-bin" "rsync" - # install - "git" - ) # update catalog apt-get update # @@ -77,12 +58,24 @@ ovh_rescue_install() { # apt_clean_cache # install packages - apt-get install --assume-yes "${packages[@]}" + apt-get install --assume-yes \ + "parted" "mdadm" "lvm2" \ +\ + "lshw" \ + "file" "micro" \ + "grub-efi-amd64-bin" "grub-pc-bin" \ + "htop" "iotop" "lsof" \ + "exa" "ncdu" "nnn" "ranger" "tree" \ + "squashfs-tools" \ + "uuid-runtime" # apt_clean_cache # install backports apt-get install --assume-yes \ - --target-release "${release}-backports" "${backports[@]}" + --target-release "${release}-backports" \ + "cryptsetup-bin" "rsync" \ +\ + "git" # apt_clean_cache } From 801f3b859c5ea10cd71f3c2416adec1c7c22dd49 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 12:32:13 +0100 Subject: [PATCH 419/969] indent --- bash/ovh-rescue.sh | 276 ++++++++++++++++++++++----------------------- 1 file changed, 138 insertions(+), 138 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index b8af8c3..aa2f061 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -1,9 +1,9 @@ #! /usr/bin/env sh ovh_rescue_configure() { - local host="${1}" - # apt / conf - printf "\ + local host="${1}" + # apt / conf + printf "\ Acquire::AllowInsecureRepositories False; Acquire::AllowWeakRepositories False; Acquire::AllowDowngradeToInsecureRepositories False; @@ -14,162 +14,162 @@ APT::Get::Show-Versions True; Dir::Etc::SourceParts ''; Dpkg::Progress True; " > "/etc/apt/apt.conf" - # apt / sources - printf "\ + # apt / sources + printf "\ deb https://deb.debian.org/debian buster main contrib non-free deb https://deb.debian.org/debian buster-backports main contrib non-free deb https://deb.debian.org/debian buster-updates main contrib non-free deb https://deb.debian.org/debian-security buster/updates main contrib non-free " > "/etc/apt/sources.list" - # bash / rc - main_link_bashrc - # host name - hostname "${host}" - # locales - printf "\ + # bash / rc + main_link_bashrc + # host name + hostname "${host}" + # locales + printf "\ en_US.UTF-8 UTF-8 fr_FR.UTF-8 UTF-8 " > '/etc/locale.gen' - # fix alias - rm --force "/usr/share/locale/locale.alias" - ln --symbolic "/etc/locale.alias" "/usr/share/locale/locale.alias" - # generate locales - locale-gen - # update catalog - apt-get update - # - debian_disable_frontend - # install packages - apt-get install --assume-yes \ - "byobu" \ - "mosh" - # - apt_clean_cache + # fix alias + rm --force "/usr/share/locale/locale.alias" + ln --symbolic "/etc/locale.alias" "/usr/share/locale/locale.alias" + # generate locales + locale-gen + # update catalog + apt-get update + # + debian_disable_frontend + # install packages + apt-get install --assume-yes \ + "byobu" \ + "mosh" + # + apt_clean_cache } ovh_rescue_install() { - local release="buster" - # update catalog - apt-get update - # - debian_disable_frontend - # upgrade packages - apt-get upgrade --assume-yes - # - apt_clean_cache - # install packages - apt-get install --assume-yes \ - "parted" "mdadm" "lvm2" \ + local release="buster" + # update catalog + apt-get update + # + debian_disable_frontend + # upgrade packages + apt-get upgrade --assume-yes + # + apt_clean_cache + # install packages + apt-get install --assume-yes \ + "parted" "mdadm" "lvm2" \ \ - "lshw" \ - "file" "micro" \ - "grub-efi-amd64-bin" "grub-pc-bin" \ - "htop" "iotop" "lsof" \ - "exa" "ncdu" "nnn" "ranger" "tree" \ - "squashfs-tools" \ - "uuid-runtime" - # - apt_clean_cache - # install backports - apt-get install --assume-yes \ - --target-release "${release}-backports" \ - "cryptsetup-bin" "rsync" \ + "lshw" \ + "file" "micro" \ + "grub-efi-amd64-bin" "grub-pc-bin" \ + "htop" "iotop" "lsof" \ + "exa" "ncdu" "nnn" "ranger" "tree" \ + "squashfs-tools" \ + "uuid-runtime" + # + apt_clean_cache + # install backports + apt-get install --assume-yes \ + --target-release "${release}-backports" \ + "cryptsetup-bin" "rsync" \ \ - "git" - # - apt_clean_cache + "git" + # + apt_clean_cache } ovh_rescue_upload() { local host="${1}" if [ "${host}" ] ; then - local user="root" - # - local user_host="${user}@${host}" - # remove fingerprints - ssh-keygen -R "${host}" - # copy ssh id - ssh-copy-id \ - -o "StrictHostKeyChecking=accept-new" \ - "${user_host}" - # upload root - rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" - # call setup - # TODO variable - ssh "${user_host}" -- \ - "source \"/etc/bash/main.sh\" ; ovh-rescue-configure \"${host}\"" - # create session - ssh "${user_host}" -- byobu new-session -d - # send keys - ssh "${user_host}" -- byobu send-keys "ovh-rescue-install" "C-m" - # attach session - mosh "${user_host}" -- byobu attach-session + local user="root" + # + local user_host="${user}@${host}" + # remove fingerprints + ssh-keygen -R "${host}" + # copy ssh id + ssh-copy-id \ + -o "StrictHostKeyChecking=accept-new" \ + "${user_host}" + # upload root + rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" + # call setup + # TODO variable + ssh "${user_host}" -- \ + "source \"/etc/bash/main.sh\" ; ovh-rescue-configure \"${host}\"" + # create session + ssh "${user_host}" -- byobu new-session -d + # send keys + ssh "${user_host}" -- byobu send-keys "ovh-rescue-install" "C-m" + # attach session + mosh "${user_host}" -- byobu attach-session else - echo 'Host?' - return 1 + echo 'Host?' + return 1 fi } ovh_rescue_wipe_1_2TB() { - local device="/dev/sda" - local unit="mib" - # - lsblk - printf "%s" "WIPE ${device} /?\\ OR CANCEL /!\\" - read -r - # - parted "${device}" --script mktable gpt - # - parted "${device}" unit "${unit}" mkpart "crypt" 65795 1907729 - # - parted "${device}" unit "${unit}" mkpart "boot" 259 65795 - # - parted "${device}" unit "${unit}" mkpart "esp" 2 259 - parted "${device}" set 3 esp on - # - parted "${device}" unit "${unit}" mkpart bios 1 2 - parted "${device}" set 4 bios_grub on - # wipe bios - dd if="/dev/zero" of="/dev/sda4" - # format esp - mkfs.vfat -F 32 -n "esp" "/dev/sda3" - # format boot - mkfs.ext4 -F -L "boot" "/dev/sda2" - # read passphrase - local passphrase - printf "PassPhrase: " - read -r -s passphrase - # encrypt - echo "${passphrase}" \ - | cryptsetup \ - --verbose \ - --batch-mode \ - --type "luks2" \ - --pbkdf "argon2id" \ - --cipher "aes-xts-plain64" \ - --iter-time 8192 \ - --key-size 512 \ - --hash "sha512" \ - --use-random \ - luksFormat \ - "/dev/sda1" - # open - echo "${passphrase}" \ - | cryptsetup luksOpen "/dev/sda1" "crypt" - # pv - pvcreate "/dev/mapper/crypt" - # vg - vgcreate "crypt" "/dev/mapper/crypt" - # lv swap - lvcreate --name "swap" --size "68719476736b" "crypt" - # lv data - lvcreate --name "data" --extents "100%FREE" "crypt" - # format swap - mkswap --label "swap" "/dev/mapper/crypt-swap" - # format data - mkfs.ext4 -L "data" "/dev/mapper/crypt-data" - # vg off - vgchange --activate "n" "crypt" - # close - cryptsetup luksClose "crypt" + local device="/dev/sda" + local unit="mib" + # + lsblk + printf "%s" "WIPE ${device} /?\\ OR CANCEL /!\\" + read -r + # + parted "${device}" --script mktable gpt + # + parted "${device}" unit "${unit}" mkpart "crypt" 65795 1907729 + # + parted "${device}" unit "${unit}" mkpart "boot" 259 65795 + # + parted "${device}" unit "${unit}" mkpart "esp" 2 259 + parted "${device}" set 3 esp on + # + parted "${device}" unit "${unit}" mkpart bios 1 2 + parted "${device}" set 4 bios_grub on + # wipe bios + dd if="/dev/zero" of="/dev/sda4" + # format esp + mkfs.vfat -F 32 -n "esp" "/dev/sda3" + # format boot + mkfs.ext4 -F -L "boot" "/dev/sda2" + # read passphrase + local passphrase + printf "PassPhrase: " + read -r -s passphrase + # encrypt + echo "${passphrase}" \ + | cryptsetup \ + --verbose \ + --batch-mode \ + --type "luks2" \ + --pbkdf "argon2id" \ + --cipher "aes-xts-plain64" \ + --iter-time 8192 \ + --key-size 512 \ + --hash "sha512" \ + --use-random \ + luksFormat \ + "/dev/sda1" + # open + echo "${passphrase}" \ + | cryptsetup luksOpen "/dev/sda1" "crypt" + # pv + pvcreate "/dev/mapper/crypt" + # vg + vgcreate "crypt" "/dev/mapper/crypt" + # lv swap + lvcreate --name "swap" --size "68719476736b" "crypt" + # lv data + lvcreate --name "data" --extents "100%FREE" "crypt" + # format swap + mkswap --label "swap" "/dev/mapper/crypt-swap" + # format data + mkfs.ext4 -L "data" "/dev/mapper/crypt-data" + # vg off + vgchange --activate "n" "crypt" + # close + cryptsetup luksClose "crypt" } From 3b05dfecc4e8d20f70a9cbeed858127c0ea3ff48 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 12:37:07 +0100 Subject: [PATCH 420/969] indents --- bash/ovh-rescue.sh | 121 +++++++++++++++++++++++---------------------- 1 file changed, 61 insertions(+), 60 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index aa2f061..fe61576 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -13,14 +13,14 @@ APT::Install-Suggests False; APT::Get::Show-Versions True; Dir::Etc::SourceParts ''; Dpkg::Progress True; -" > "/etc/apt/apt.conf" +" >"/etc/apt/apt.conf" # apt / sources printf "\ deb https://deb.debian.org/debian buster main contrib non-free deb https://deb.debian.org/debian buster-backports main contrib non-free deb https://deb.debian.org/debian buster-updates main contrib non-free deb https://deb.debian.org/debian-security buster/updates main contrib non-free -" > "/etc/apt/sources.list" +" >"/etc/apt/sources.list" # bash / rc main_link_bashrc # host name @@ -29,7 +29,7 @@ deb https://deb.debian.org/debian-security buster/updates main contrib non-free printf "\ en_US.UTF-8 UTF-8 fr_FR.UTF-8 UTF-8 -" > '/etc/locale.gen' +" >"/etc/locale.gen" # fix alias rm --force "/usr/share/locale/locale.alias" ln --symbolic "/etc/locale.alias" "/usr/share/locale/locale.alias" @@ -41,8 +41,9 @@ fr_FR.UTF-8 UTF-8 debian_disable_frontend # install packages apt-get install --assume-yes \ - "byobu" \ - "mosh" + "mosh" \ + "tmux" \ + "byobu" # apt_clean_cache } @@ -59,55 +60,55 @@ ovh_rescue_install() { apt_clean_cache # install packages apt-get install --assume-yes \ - "parted" "mdadm" "lvm2" \ -\ - "lshw" \ - "file" "micro" \ - "grub-efi-amd64-bin" "grub-pc-bin" \ - "htop" "iotop" "lsof" \ - "exa" "ncdu" "nnn" "ranger" "tree" \ - "squashfs-tools" \ - "uuid-runtime" + "parted" "mdadm" "lvm2" \ + \ + "lshw" \ + "file" "micro" \ + "grub-efi-amd64-bin" "grub-pc-bin" \ + "htop" "iotop" "lsof" \ + "exa" "ncdu" "nnn" "ranger" "tree" \ + "squashfs-tools" \ + "uuid-runtime" # apt_clean_cache # install backports apt-get install --assume-yes \ - --target-release "${release}-backports" \ - "cryptsetup-bin" "rsync" \ -\ - "git" + --target-release "${release}-backports" \ + "cryptsetup-bin" "rsync" \ + \ + "git" # apt_clean_cache } ovh_rescue_upload() { -local host="${1}" -if [ "${host}" ] ; then - local user="root" - # - local user_host="${user}@${host}" - # remove fingerprints - ssh-keygen -R "${host}" - # copy ssh id - ssh-copy-id \ - -o "StrictHostKeyChecking=accept-new" \ - "${user_host}" - # upload root - rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" - # call setup - # TODO variable - ssh "${user_host}" -- \ - "source \"/etc/bash/main.sh\" ; ovh-rescue-configure \"${host}\"" - # create session - ssh "${user_host}" -- byobu new-session -d - # send keys - ssh "${user_host}" -- byobu send-keys "ovh-rescue-install" "C-m" - # attach session - mosh "${user_host}" -- byobu attach-session -else - echo 'Host?' - return 1 -fi + local host="${1}" + if [ "${host}" ]; then + local user="root" + # + local user_host="${user}@${host}" + # remove fingerprints + ssh-keygen -R "${host}" + # copy ssh id + ssh-copy-id \ + -o "StrictHostKeyChecking=accept-new" \ + "${user_host}" + # upload root + rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" + # call setup + # TODO variable + ssh "${user_host}" -- \ + "source \"/etc/bash/main.sh\" ; ovh-rescue-configure \"${host}\"" + # create session + ssh "${user_host}" -- byobu new-session -d + # send keys + ssh "${user_host}" -- byobu send-keys "ovh-rescue-install" "C-m" + # attach session + mosh "${user_host}" -- byobu attach-session + else + echo 'Host?' + return 1 + fi } ovh_rescue_wipe_1_2TB() { @@ -140,22 +141,22 @@ ovh_rescue_wipe_1_2TB() { printf "PassPhrase: " read -r -s passphrase # encrypt - echo "${passphrase}" \ - | cryptsetup \ - --verbose \ - --batch-mode \ - --type "luks2" \ - --pbkdf "argon2id" \ - --cipher "aes-xts-plain64" \ - --iter-time 8192 \ - --key-size 512 \ - --hash "sha512" \ - --use-random \ - luksFormat \ - "/dev/sda1" + echo "${passphrase}" | + cryptsetup \ + --verbose \ + --batch-mode \ + --type "luks2" \ + --pbkdf "argon2id" \ + --cipher "aes-xts-plain64" \ + --iter-time 8192 \ + --key-size 512 \ + --hash "sha512" \ + --use-random \ + luksFormat \ + "/dev/sda1" # open - echo "${passphrase}" \ - | cryptsetup luksOpen "/dev/sda1" "crypt" + echo "${passphrase}" | + cryptsetup luksOpen "/dev/sda1" "crypt" # pv pvcreate "/dev/mapper/crypt" # vg From efada1fce56a6b8486d93f50510da8e819e61ebd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 12:38:32 +0100 Subject: [PATCH 421/969] quotes --- bash/ovh-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index fe61576..c876d5a 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -106,7 +106,7 @@ ovh_rescue_upload() { # attach session mosh "${user_host}" -- byobu attach-session else - echo 'Host?' + echo "Host?" return 1 fi } From 718d1d1e78d69c41e79250f4c43992c98694e4f6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 12:46:43 +0100 Subject: [PATCH 422/969] tmux,cleans --- bash/ovh-rescue.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index c876d5a..db81ac8 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -41,10 +41,11 @@ fr_FR.UTF-8 UTF-8 debian_disable_frontend # install packages apt-get install --assume-yes \ - "mosh" \ "tmux" \ - "byobu" - # + \ + "byobu" \ + "mosh" + # clean cache apt_clean_cache } @@ -69,7 +70,7 @@ ovh_rescue_install() { "exa" "ncdu" "nnn" "ranger" "tree" \ "squashfs-tools" \ "uuid-runtime" - # + # clean cache apt_clean_cache # install backports apt-get install --assume-yes \ @@ -77,7 +78,7 @@ ovh_rescue_install() { "cryptsetup-bin" "rsync" \ \ "git" - # + # clean cache apt_clean_cache } From 9b830a7d36a7935b7cda904b2848ae142af184b5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 12:55:45 +0100 Subject: [PATCH 423/969] packages --- bash/ovh-rescue.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index db81ac8..da6ab26 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -61,12 +61,11 @@ ovh_rescue_install() { apt_clean_cache # install packages apt-get install --assume-yes \ - "parted" "mdadm" "lvm2" \ + "file" "htop" "iotop" "lsof" \ \ + "parted" "mdadm" "lvm2" \ "lshw" \ - "file" "micro" \ - "grub-efi-amd64-bin" "grub-pc-bin" \ - "htop" "iotop" "lsof" \ + "micro" \ "exa" "ncdu" "nnn" "ranger" "tree" \ "squashfs-tools" \ "uuid-runtime" @@ -75,8 +74,10 @@ ovh_rescue_install() { # install backports apt-get install --assume-yes \ --target-release "${release}-backports" \ - "cryptsetup-bin" "rsync" \ + "rsync" \ \ + "cryptsetup-bin" \ + "grub-efi-amd64-bin" "grub-pc-bin" \ "git" # clean cache apt_clean_cache From dce03fc9b9c83c5a237d93291503fc213c483455 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 13:05:39 +0100 Subject: [PATCH 424/969] bookworm --- bash/ovh-rescue.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index da6ab26..16f1abf 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -2,6 +2,7 @@ ovh_rescue_configure() { local host="${1}" + local release="bookworm" # apt / conf printf "\ Acquire::AllowInsecureRepositories False; @@ -41,16 +42,20 @@ fr_FR.UTF-8 UTF-8 debian_disable_frontend # install packages apt-get install --assume-yes \ - "tmux" \ - \ "byobu" \ "mosh" # clean cache apt_clean_cache + # install backports + apt-get install --assume-yes \ + --target-release "${release}-backports" \ + "tmux" + # clean cache + apt_clean_cache } ovh_rescue_install() { - local release="buster" + local release="bookworm" # update catalog apt-get update # @@ -100,7 +105,7 @@ ovh_rescue_upload() { # call setup # TODO variable ssh "${user_host}" -- \ - "source \"/etc/bash/main.sh\" ; ovh-rescue-configure \"${host}\"" + "source \"/etc/bash/main.sh\" ; ovh_rescue_configure \"${host}\"" # create session ssh "${user_host}" -- byobu new-session -d # send keys From cb02b1514603ec000175a3573bd181a233231707 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 13:11:27 +0100 Subject: [PATCH 425/969] release --- bash/ovh-rescue.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 16f1abf..f04d157 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -12,15 +12,15 @@ Acquire::Check-Valid-Until True; APT::Install-Recommends False; APT::Install-Suggests False; APT::Get::Show-Versions True; -Dir::Etc::SourceParts ''; +Dir::Etc::SourceParts \"\"; Dpkg::Progress True; -" >"/etc/apt/apt.conf" +" >"/etc/apt/apt.conf.d/apt.conf" # apt / sources printf "\ -deb https://deb.debian.org/debian buster main contrib non-free -deb https://deb.debian.org/debian buster-backports main contrib non-free -deb https://deb.debian.org/debian buster-updates main contrib non-free -deb https://deb.debian.org/debian-security buster/updates main contrib non-free +deb https://deb.debian.org/debian ${release} main non-free-firmware contrib non-free +deb https://deb.debian.org/debian ${release}-backports main non-free-firmware contrib non-free +deb https://deb.debian.org/debian ${release}-updates main non-free-firmware contrib non-free +deb https://deb.debian.org/debian-security ${release}-security main non-free-firmware contrib non-free " >"/etc/apt/sources.list" # bash / rc main_link_bashrc @@ -31,9 +31,6 @@ deb https://deb.debian.org/debian-security buster/updates main contrib non-free en_US.UTF-8 UTF-8 fr_FR.UTF-8 UTF-8 " >"/etc/locale.gen" - # fix alias - rm --force "/usr/share/locale/locale.alias" - ln --symbolic "/etc/locale.alias" "/usr/share/locale/locale.alias" # generate locales locale-gen # update catalog From 91b0862539261f500a9e04a3964c621d304cbb25 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 13:13:25 +0100 Subject: [PATCH 426/969] tmux --- bash/ovh-rescue.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index f04d157..e5aa429 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -37,18 +37,18 @@ fr_FR.UTF-8 UTF-8 apt-get update # debian_disable_frontend - # install packages - apt-get install --assume-yes \ - "byobu" \ - "mosh" - # clean cache - apt_clean_cache # install backports apt-get install --assume-yes \ --target-release "${release}-backports" \ "tmux" # clean cache apt_clean_cache + # install packages + apt-get install --assume-yes \ + "byobu" \ + "mosh" + # clean cache + apt_clean_cache } ovh_rescue_install() { From 48e29b9e600a78c52adfca85159bebef3cf5e2ce Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 13:26:01 +0100 Subject: [PATCH 427/969] packages --- bash/ovh-rescue.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index e5aa429..e8008d2 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -63,24 +63,22 @@ ovh_rescue_install() { apt_clean_cache # install packages apt-get install --assume-yes \ - "file" "htop" "iotop" "lsof" \ + "file" "htop" "iotop" "lsof" "rsync" \ \ - "parted" "mdadm" "lvm2" \ + "parted" "mdadm" "cryptsetup-bin" "lvm2" \ "lshw" \ "micro" \ "exa" "ncdu" "nnn" "ranger" "tree" \ "squashfs-tools" \ - "uuid-runtime" + "git" # clean cache apt_clean_cache # install backports apt-get install --assume-yes \ --target-release "${release}-backports" \ - "rsync" \ + "grub-pc-bin" \ \ - "cryptsetup-bin" \ - "grub-efi-amd64-bin" "grub-pc-bin" \ - "git" + "grub-efi-amd64-bin" # clean cache apt_clean_cache } From b693e17e297dacd710a8f247c396ac7fc6028c46 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 13:27:51 +0100 Subject: [PATCH 428/969] printf --- bash/ovh-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index e8008d2..b6f81f5 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -16,7 +16,7 @@ Dir::Etc::SourceParts \"\"; Dpkg::Progress True; " >"/etc/apt/apt.conf.d/apt.conf" # apt / sources - printf "\ + printf "%s" "\ deb https://deb.debian.org/debian ${release} main non-free-firmware contrib non-free deb https://deb.debian.org/debian ${release}-backports main non-free-firmware contrib non-free deb https://deb.debian.org/debian ${release}-updates main non-free-firmware contrib non-free From d468491ae03fa6b064c5ffc0464d65e8cc9e3a50 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 13:32:08 +0100 Subject: [PATCH 429/969] _ --- bash/ovh-rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index b6f81f5..0acce32 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -104,7 +104,7 @@ ovh_rescue_upload() { # create session ssh "${user_host}" -- byobu new-session -d # send keys - ssh "${user_host}" -- byobu send-keys "ovh-rescue-install" "C-m" + ssh "${user_host}" -- byobu send-keys "ovh_rescue_install" "C-m" # attach session mosh "${user_host}" -- byobu attach-session else From d2ce7a1b74eeec4001e285fbffa586d47684830e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 13:58:49 +0100 Subject: [PATCH 430/969] configure --- bash/ovh-rescue.sh | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 0acce32..a725271 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -1,8 +1,9 @@ #! /usr/bin/env sh ovh_rescue_configure() { - local host="${1}" + local hostname="${1}" local release="bookworm" + local package # apt / conf printf "\ Acquire::AllowInsecureRepositories False; @@ -24,8 +25,9 @@ deb https://deb.debian.org/debian-security ${release}-security main non-free-fir " >"/etc/apt/sources.list" # bash / rc main_link_bashrc + mv .bashrc .bashrc.old # host name - hostname "${host}" + hostname "${hostname}" # locales printf "\ en_US.UTF-8 UTF-8 @@ -35,20 +37,27 @@ fr_FR.UTF-8 UTF-8 locale-gen # update catalog apt-get update - # + # disable frontend debian_disable_frontend # install backports - apt-get install --assume-yes \ - --target-release "${release}-backports" \ - "tmux" - # clean cache - apt_clean_cache + set "tmux" + for package in "${@}"; do + echo ; echo "${package}" + apt-get install --assume-yes \ + --target-release "${release}-backports" \ + "${package}" + apt_clean_cache + done # install packages - apt-get install --assume-yes \ - "byobu" \ - "mosh" - # clean cache - apt_clean_cache + set "apt-file" "mosh" "byobu" + for package in "${@}"; do + echo ; echo "${package}" + apt-get install --assume-yes \ + "${package}" + apt_clean_cache + done + # update catalog + apt-get update } ovh_rescue_install() { From 8ab6d5758df050dbb157811246e6a0ee44e536c2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 14:03:33 +0100 Subject: [PATCH 431/969] install --- bash/ovh-rescue.sh | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index a725271..8c3d07b 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -61,17 +61,18 @@ fr_FR.UTF-8 UTF-8 } ovh_rescue_install() { + local package local release="bookworm" # update catalog apt-get update - # + # disable frontend debian_disable_frontend # upgrade packages apt-get upgrade --assume-yes - # + # clean cache apt_clean_cache # install packages - apt-get install --assume-yes \ + set \ "file" "htop" "iotop" "lsof" "rsync" \ \ "parted" "mdadm" "cryptsetup-bin" "lvm2" \ @@ -80,16 +81,24 @@ ovh_rescue_install() { "exa" "ncdu" "nnn" "ranger" "tree" \ "squashfs-tools" \ "git" - # clean cache - apt_clean_cache + for package in "${@}"; do + echo ; echo "${package}" + apt-get install --assume-yes \ + "${package}" + apt_clean_cache + done # install backports - apt-get install --assume-yes \ - --target-release "${release}-backports" \ + set \ "grub-pc-bin" \ \ "grub-efi-amd64-bin" - # clean cache - apt_clean_cache + for package in "${@}"; do + echo ; echo "${package}" + apt-get install --assume-yes \ + --target-release "${release}-backports" \ + "${package}" + apt_clean_cache + done } ovh_rescue_upload() { From 0face50a529ab67dcb4d002546b89df6851a6c8b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 14:04:48 +0100 Subject: [PATCH 432/969] echoes --- bash/ovh-rescue.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 8c3d07b..16ddad7 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -42,7 +42,8 @@ fr_FR.UTF-8 UTF-8 # install backports set "tmux" for package in "${@}"; do - echo ; echo "${package}" + echo + echo "${package}" apt-get install --assume-yes \ --target-release "${release}-backports" \ "${package}" @@ -51,7 +52,8 @@ fr_FR.UTF-8 UTF-8 # install packages set "apt-file" "mosh" "byobu" for package in "${@}"; do - echo ; echo "${package}" + echo + echo "${package}" apt-get install --assume-yes \ "${package}" apt_clean_cache @@ -82,7 +84,8 @@ ovh_rescue_install() { "squashfs-tools" \ "git" for package in "${@}"; do - echo ; echo "${package}" + echo + echo "${package}" apt-get install --assume-yes \ "${package}" apt_clean_cache @@ -93,7 +96,8 @@ ovh_rescue_install() { \ "grub-efi-amd64-bin" for package in "${@}"; do - echo ; echo "${package}" + echo + echo "${package}" apt-get install --assume-yes \ --target-release "${release}-backports" \ "${package}" From c7659c47fae7ee7e36493acc585939d781a1aea1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 14:32:37 +0100 Subject: [PATCH 433/969] packages --- bash/ovh-rescue.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 16ddad7..d79616f 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -75,14 +75,13 @@ ovh_rescue_install() { apt_clean_cache # install packages set \ - "file" "htop" "iotop" "lsof" "rsync" \ - \ + "man-db" \ + "dmidecode" "efibootmgr" "lshw" "pciutils" "usbutils" \ "parted" "mdadm" "cryptsetup-bin" "lvm2" \ - "lshw" \ - "micro" \ - "exa" "ncdu" "nnn" "ranger" "tree" \ - "squashfs-tools" \ - "git" + "btrfs-progs" "dosfstools" "duperemove" "squashfs-tools" \ + "git" "micro" "nano" "python3" "rsync" "vim" \ + "exa" "lf" "ncdu" "nnn" "ranger" "tree" \ + "file" "htop" "iotop" "ipcalc" "libdigest-sha3-perl" "lsof" for package in "${@}"; do echo echo "${package}" From bee3710cde42b432500fe3d42f7a2dd1e2a321c1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 14:40:55 +0100 Subject: [PATCH 434/969] upload --- bash/ovh-rescue.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index d79616f..46f81cf 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -18,10 +18,14 @@ Dpkg::Progress True; " >"/etc/apt/apt.conf.d/apt.conf" # apt / sources printf "%s" "\ -deb https://deb.debian.org/debian ${release} main non-free-firmware contrib non-free -deb https://deb.debian.org/debian ${release}-backports main non-free-firmware contrib non-free -deb https://deb.debian.org/debian ${release}-updates main non-free-firmware contrib non-free -deb https://deb.debian.org/debian-security ${release}-security main non-free-firmware contrib non-free +deb https://deb.debian.org/debian \ +${release} main non-free-firmware contrib non-free +deb https://deb.debian.org/debian \ +${release}-backports main non-free-firmware contrib non-free +deb https://deb.debian.org/debian \ +${release}-updates main non-free-firmware contrib non-free +deb https://deb.debian.org/debian-security \ +${release}-security main non-free-firmware contrib non-free " >"/etc/apt/sources.list" # bash / rc main_link_bashrc @@ -106,7 +110,8 @@ ovh_rescue_install() { ovh_rescue_upload() { local host="${1}" - if [ "${host}" ]; then + local hostname="${2}" + if [ "${hostname}" ]; then local user="root" # local user_host="${user}@${host}" @@ -117,11 +122,12 @@ ovh_rescue_upload() { -o "StrictHostKeyChecking=accept-new" \ "${user_host}" # upload root - rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" + rsync --delete --recursive \ + "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" # call setup # TODO variable - ssh "${user_host}" -- \ - "source \"/etc/bash/main.sh\" ; ovh_rescue_configure \"${host}\"" + ssh "${user_host}" -- "\ +source \"/etc/bash/main.sh\" ; ovh_rescue_configure \"${hostname}\"" # create session ssh "${user_host}" -- byobu new-session -d # send keys From 28e3acd8a7f308f9501734e6854384c22c065032 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 15:40:04 +0100 Subject: [PATCH 435/969] device --- bash/ovh-rescue.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 46f81cf..cabce07 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -140,9 +140,13 @@ source \"/etc/bash/main.sh\" ; ovh_rescue_configure \"${hostname}\"" fi } -ovh_rescue_wipe_1_2TB() { - local device="/dev/sda" +ovh_rescue_wipe_vle2_0_init() { + local device="/dev/sdb" + local passphrase local unit="mib" + # read passphrase + printf "PassPhrase: " + read -r -s passphrase # lsblk printf "%s" "WIPE ${device} /?\\ OR CANCEL /!\\" @@ -152,23 +156,19 @@ ovh_rescue_wipe_1_2TB() { # parted "${device}" unit "${unit}" mkpart "crypt" 65795 1907729 # - parted "${device}" unit "${unit}" mkpart "boot" 259 65795 + parted "${device}" unit "${unit}" mkpart "boot" 514 65795 # - parted "${device}" unit "${unit}" mkpart "esp" 2 259 + parted "${device}" unit "${unit}" mkpart "esp" 2 514 parted "${device}" set 3 esp on # parted "${device}" unit "${unit}" mkpart bios 1 2 parted "${device}" set 4 bios_grub on # wipe bios - dd if="/dev/zero" of="/dev/sda4" + dd if="/dev/zero" of="${device}4" # format esp - mkfs.vfat -F 32 -n "esp" "/dev/sda3" + mkfs.vfat -F 32 -n "esp" "${device}3" # format boot - mkfs.ext4 -F -L "boot" "/dev/sda2" - # read passphrase - local passphrase - printf "PassPhrase: " - read -r -s passphrase + mkfs.ext4 -F -L "boot" "${device}2" # encrypt echo "${passphrase}" | cryptsetup \ @@ -182,10 +182,10 @@ ovh_rescue_wipe_1_2TB() { --hash "sha512" \ --use-random \ luksFormat \ - "/dev/sda1" + "${device}1" # open echo "${passphrase}" | - cryptsetup luksOpen "/dev/sda1" "crypt" + cryptsetup luksOpen "${device}1" "crypt" # pv pvcreate "/dev/mapper/crypt" # vg From 566189cc80846fbbb496c1887bbb6886412add68 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 16:37:27 +0100 Subject: [PATCH 436/969] functions --- bash/ovh-rescue.sh | 112 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 85 insertions(+), 27 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index cabce07..0b12f67 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -147,29 +147,51 @@ ovh_rescue_wipe_vle2_0_init() { # read passphrase printf "PassPhrase: " read -r -s passphrase - # + # warn lsblk printf "%s" "WIPE ${device} /?\\ OR CANCEL /!\\" read -r # parted "${device}" --script mktable gpt # - parted "${device}" unit "${unit}" mkpart "crypt" 65795 1907729 + parted "${device}" unit "${unit}" mkpart "crypt" 4610 40960 # - parted "${device}" unit "${unit}" mkpart "boot" 514 65795 + parted "${device}" unit "${unit}" mkpart "boot" 514 4610 # parted "${device}" unit "${unit}" mkpart "esp" 2 514 parted "${device}" set 3 esp on # parted "${device}" unit "${unit}" mkpart bios 1 2 parted "${device}" set 4 bios_grub on - # wipe bios + # bios / wipe dd if="/dev/zero" of="${device}4" - # format esp - mkfs.vfat -F 32 -n "esp" "${device}3" - # format boot - mkfs.ext4 -F -L "boot" "${device}2" - # encrypt + # esp / wipe + dd if="/dev/zero" of="${device}3" bs="1M" + # esp / format + mkfs.vfat \ + -F 32 \ + -S 4096 \ + -i "00000001" \ + -n "esp" \ + "${device}3" + # esp / mount + mkdir --parents "/media/esp" + mount "${device}3" "/media/esp" + # boot / wipe + dd status="progress" if="/dev/zero" of="${device}2" bs="1G" count=1 + # boot / format + mkfs.btrfs --force \ + --checksum "sha256" \ + --label "boot" \ + --uuid "00000000-0000-0000-0000-00000000000b" \ + "${device}2" + # boot / mount + mkdir --parents "/media/boot" + mount --options "autodefrag,compress-force=zstd" \ + "${device}2" "/media/boot" + # crypt / wipe + dd status="progress" if="/dev/zero" of="${device}1" bs="1G" count=1 + # crypt / encrypt echo "${passphrase}" | cryptsetup \ --verbose \ @@ -177,29 +199,65 @@ ovh_rescue_wipe_vle2_0_init() { --type "luks2" \ --pbkdf "argon2id" \ --cipher "aes-xts-plain64" \ - --iter-time 8192 \ + --iter-time 4096 \ --key-size 512 \ --hash "sha512" \ --use-random \ luksFormat \ "${device}1" - # open + # crypt / open echo "${passphrase}" | cryptsetup luksOpen "${device}1" "crypt" - # pv - pvcreate "/dev/mapper/crypt" - # vg - vgcreate "crypt" "/dev/mapper/crypt" - # lv swap - lvcreate --name "swap" --size "68719476736b" "crypt" - # lv data - lvcreate --name "data" --extents "100%FREE" "crypt" - # format swap - mkswap --label "swap" "/dev/mapper/crypt-swap" - # format data - mkfs.ext4 -L "data" "/dev/mapper/crypt-data" - # vg off - vgchange --activate "n" "crypt" - # close - cryptsetup luksClose "crypt" +} + +ovh_rescue_wipe_vle2_1_zero() { + # crypt / zero + dd status="progress" if="/dev/zero" of="/dev/mapper/crypt" bs="1G" +} + +ovh_rescue_wipe_vle2_2_make() { + local passphrase + # crypt / close + cryptsetup luksClose "crypt" + # read passphrase + printf "PassPhrase: " + read -r -s passphrase + # crypt / encrypt + echo "${passphrase}" | + cryptsetup \ + --verbose \ + --batch-mode \ + --type "luks2" \ + --pbkdf "argon2id" \ + --cipher "aes-xts-plain64" \ + --iter-time 4096 \ + --key-size 512 \ + --hash "sha512" \ + --use-random \ + luksFormat \ + "${device}1" + # crypt / open + echo "${passphrase}" | + cryptsetup luksOpen "${device}1" "crypt" + # crypt / format + mkfs.btrfs --force \ + --checksum "sha256" \ + --label "crypt" \ + --uuid "00000000-0000-0000-0000-00000000000c" \ + "${device}1" + # crypt / mount + mkdir --parents "/media/crypt" + mount --options "autodefrag,compress-force=zstd" \ + "${device}1" "/media/crypt" + # crypt / swap + btrfs filesystem mkswapfile \ + --size "4g" \ + --uuid "00000000-0000-0000-0000-000000000005" \ + "/media/crypt/swap" +} + +ovh_rescue_wipe_vle2_3_close() { + umount "/media/boot" + umount "/media/crypt" && + cryptsetup luksClose "crypt" } From 63af101db9541ee39394176227f6ad8c7dce9757 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 16:38:48 +0100 Subject: [PATCH 437/969] indent --- bash/ovh-rescue.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index 0b12f67..f639df5 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -181,10 +181,10 @@ ovh_rescue_wipe_vle2_0_init() { dd status="progress" if="/dev/zero" of="${device}2" bs="1G" count=1 # boot / format mkfs.btrfs --force \ - --checksum "sha256" \ - --label "boot" \ - --uuid "00000000-0000-0000-0000-00000000000b" \ - "${device}2" + --checksum "sha256" \ + --label "boot" \ + --uuid "00000000-0000-0000-0000-00000000000b" \ + "${device}2" # boot / mount mkdir --parents "/media/boot" mount --options "autodefrag,compress-force=zstd" \ @@ -241,19 +241,19 @@ ovh_rescue_wipe_vle2_2_make() { cryptsetup luksOpen "${device}1" "crypt" # crypt / format mkfs.btrfs --force \ - --checksum "sha256" \ - --label "crypt" \ - --uuid "00000000-0000-0000-0000-00000000000c" \ - "${device}1" + --checksum "sha256" \ + --label "crypt" \ + --uuid "00000000-0000-0000-0000-00000000000c" \ + "${device}1" # crypt / mount mkdir --parents "/media/crypt" mount --options "autodefrag,compress-force=zstd" \ "${device}1" "/media/crypt" # crypt / swap btrfs filesystem mkswapfile \ - --size "4g" \ - --uuid "00000000-0000-0000-0000-000000000005" \ - "/media/crypt/swap" + --size "4g" \ + --uuid "00000000-0000-0000-0000-000000000005" \ + "/media/crypt/swap" } ovh_rescue_wipe_vle2_3_close() { From 8983b9cd9f41b4bf29682ee4e4b7fe512c25c4b7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 16:42:18 +0100 Subject: [PATCH 438/969] rename --- bash/{hetzner-rescue.sh => rescue-hetzner.sh} | 0 bash/{ovh-rescue.sh => rescue-ovh.sh} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename bash/{hetzner-rescue.sh => rescue-hetzner.sh} (100%) rename bash/{ovh-rescue.sh => rescue-ovh.sh} (100%) diff --git a/bash/hetzner-rescue.sh b/bash/rescue-hetzner.sh similarity index 100% rename from bash/hetzner-rescue.sh rename to bash/rescue-hetzner.sh diff --git a/bash/ovh-rescue.sh b/bash/rescue-ovh.sh similarity index 100% rename from bash/ovh-rescue.sh rename to bash/rescue-ovh.sh From 768703707005d424e6e85f7ee1d53d7a71ffa7eb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 16:43:16 +0100 Subject: [PATCH 439/969] rescue --- bash/rescue.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 bash/rescue.sh diff --git a/bash/rescue.sh b/bash/rescue.sh new file mode 100644 index 0000000..e69de29 From 33e823024cc1318f47928fd6b57310a7119c8ec3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 16:48:26 +0100 Subject: [PATCH 440/969] ovh --- bash/rescue-ovh.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index f639df5..a98e8f7 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -1,6 +1,6 @@ #! /usr/bin/env sh -ovh_rescue_configure() { +rescue_ovh_configure() { local hostname="${1}" local release="bookworm" local package @@ -66,7 +66,7 @@ fr_FR.UTF-8 UTF-8 apt-get update } -ovh_rescue_install() { +rescue_ovh_install() { local package local release="bookworm" # update catalog @@ -108,7 +108,7 @@ ovh_rescue_install() { done } -ovh_rescue_upload() { +rescue_ovh_upload() { local host="${1}" local hostname="${2}" if [ "${hostname}" ]; then @@ -127,11 +127,11 @@ ovh_rescue_upload() { # call setup # TODO variable ssh "${user_host}" -- "\ -source \"/etc/bash/main.sh\" ; ovh_rescue_configure \"${hostname}\"" +source \"/etc/bash/main.sh\" ; rescue_ovh_configure \"${hostname}\"" # create session ssh "${user_host}" -- byobu new-session -d # send keys - ssh "${user_host}" -- byobu send-keys "ovh_rescue_install" "C-m" + ssh "${user_host}" -- byobu send-keys "rescue_ovh_install" "C-m" # attach session mosh "${user_host}" -- byobu attach-session else @@ -140,7 +140,7 @@ source \"/etc/bash/main.sh\" ; ovh_rescue_configure \"${hostname}\"" fi } -ovh_rescue_wipe_vle2_0_init() { +rescue_ovh_wipe_vle2_0_init() { local device="/dev/sdb" local passphrase local unit="mib" @@ -210,12 +210,12 @@ ovh_rescue_wipe_vle2_0_init() { cryptsetup luksOpen "${device}1" "crypt" } -ovh_rescue_wipe_vle2_1_zero() { +rescue_ovh_wipe_vle2_1_zero() { # crypt / zero dd status="progress" if="/dev/zero" of="/dev/mapper/crypt" bs="1G" } -ovh_rescue_wipe_vle2_2_make() { +rescue_ovh_wipe_vle2_2_make() { local passphrase # crypt / close cryptsetup luksClose "crypt" @@ -256,7 +256,7 @@ ovh_rescue_wipe_vle2_2_make() { "/media/crypt/swap" } -ovh_rescue_wipe_vle2_3_close() { +rescue_ovh_wipe_vle2_3_close() { umount "/media/boot" umount "/media/crypt" && cryptsetup luksClose "crypt" From 5f13535022dc2bf12d41cb4fbf9415ffabcc4191 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 16:56:00 +0100 Subject: [PATCH 441/969] hetzner --- bash/rescue-hetzner.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 852346f..c0d1de3 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -1,4 +1,4 @@ -function hetzner-rescue-configure { +function rescue_hetzner_configure { local hostname="${1}" local package local packages=( @@ -53,7 +53,7 @@ fr_FR.UTF-8 UTF-8 apt-get update } -function hetzner-rescue-install { +function rescue_hetzner_install { local package local release='bookworm' local packages=( @@ -100,7 +100,7 @@ function hetzner-rescue-install { done } -function hetzner-rescue-upload { +function rescue_hetzner_upload { local host="${1}" local hostname="${2}" if [ "${hostname}" ] ; then @@ -117,11 +117,11 @@ if [ "${hostname}" ] ; then rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" # call setup # TODO variable - ssh "${user_host}" -- "source '/etc/bash/main.sh' ; hetzner-rescue-configure '${hostname}'" + ssh "${user_host}" -- "source '/etc/bash/main.sh' ; rescue_hetzner_configure '${hostname}'" # create session ssh "${user_host}" -- byobu new-session -d # send keys - ssh "${user_host}" -- byobu send-keys 'hetzner-rescue-install' 'C-m' + ssh "${user_host}" -- byobu send-keys 'rescue_hetzner_install' 'C-m' # attach session mosh "${user_host}" -- byobu attach-session else @@ -130,7 +130,7 @@ else fi } -function hetzner-rescue-wipe-8-8-0-init { +function rescue_hetzner_wipe_8_8_0_init { local device local devices=( '/dev/sda' @@ -270,13 +270,13 @@ function hetzner-rescue-wipe-8-8-0-init { | cryptsetup luksOpen '/dev/md/crypt' 'crypt' } -function hetzner-rescue-wipe-8-8-1-zero { +function rescue_hetzner_wipe_8_8_1_zero { # wipe crypt dd status='progress' \ if='/dev/zero' of='/dev/mapper/crypt' bs='8G' } -function hetzner-rescue-wipe-8-8-2-make { +function rescue_hetzner_wipe_8_8_2_make { local passphrase # close cryptsetup luksClose 'crypt' @@ -318,7 +318,7 @@ function hetzner-rescue-wipe-8-8-2-make { '/media/crypt/swap' } -function hetzner-rescue-wipe-8-8-3-close { +function rescue_hetzner_wipe_8_8_3_close { umount '/media/boot' # umount '/media/crypt' \ From 783d5e334e55d2a7a0202fa2504534cb1829606c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 16:57:37 +0100 Subject: [PATCH 442/969] functions --- bash/rescue-hetzner.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index c0d1de3..dcbab30 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -1,4 +1,4 @@ -function rescue_hetzner_configure { +rescue_hetzner_configure() { local hostname="${1}" local package local packages=( @@ -53,7 +53,7 @@ fr_FR.UTF-8 UTF-8 apt-get update } -function rescue_hetzner_install { +rescue_hetzner_install() { local package local release='bookworm' local packages=( @@ -100,7 +100,7 @@ function rescue_hetzner_install { done } -function rescue_hetzner_upload { +rescue_hetzner_upload() { local host="${1}" local hostname="${2}" if [ "${hostname}" ] ; then @@ -130,7 +130,7 @@ else fi } -function rescue_hetzner_wipe_8_8_0_init { +rescue_hetzner_wipe_8_8_0_init() { local device local devices=( '/dev/sda' @@ -270,13 +270,13 @@ function rescue_hetzner_wipe_8_8_0_init { | cryptsetup luksOpen '/dev/md/crypt' 'crypt' } -function rescue_hetzner_wipe_8_8_1_zero { +rescue_hetzner_wipe_8_8_1_zero() { # wipe crypt dd status='progress' \ if='/dev/zero' of='/dev/mapper/crypt' bs='8G' } -function rescue_hetzner_wipe_8_8_2_make { +rescue_hetzner_wipe_8_8_2_make() { local passphrase # close cryptsetup luksClose 'crypt' @@ -318,7 +318,7 @@ function rescue_hetzner_wipe_8_8_2_make { '/media/crypt/swap' } -function rescue_hetzner_wipe_8_8_3_close { +rescue_hetzner_wipe_8_8_3_close() { umount '/media/boot' # umount '/media/crypt' \ From bf1e7539faf1b198a9338b88e72e4949bc5d23e6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 17:01:19 +0100 Subject: [PATCH 443/969] tabs --- bash/rescue-hetzner.sh | 564 ++++++++++++++++++++--------------------- 1 file changed, 282 insertions(+), 282 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index dcbab30..49ad0a5 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -1,13 +1,13 @@ rescue_hetzner_configure() { local hostname="${1}" - local package - local packages=( - 'mosh' - 'screen' 'tmux' 'byobu' - 'apt-file' - ) - # apt / conf - echo -n "\ + local package + local packages=( + 'mosh' + 'screen' 'tmux' 'byobu' + 'apt-file' + ) + # apt / conf + echo -n "\ Acquire::AllowInsecureRepositories False; Acquire::AllowWeakRepositories False; Acquire::AllowDowngradeToInsecureRepositories False; @@ -18,309 +18,309 @@ APT::Get::Show-Versions True; Dir::Etc::SourceParts ''; Dpkg::Progress True; " > '/etc/apt/apt.conf' - # apt / sources - echo -n "\ + # apt / sources + echo -n "\ deb https://deb.debian.org/debian bookworm main non-free-firmware contrib non-free deb https://deb.debian.org/debian bookworm-backports main non-free-firmware contrib non-free deb https://deb.debian.org/debian bookworm-updates main non-free-firmware contrib non-free deb https://deb.debian.org/debian-security bookworm-security main non-free-firmware contrib non-free " > '/etc/apt/sources.list' - # bash / rc - main_link_bashrc - mv .bashrc .bashrc.old - # host name - hostname "${hostname}" - # locales - echo -n "\ + # bash / rc + main_link_bashrc + mv .bashrc .bashrc.old + # host name + hostname "${hostname}" + # locales + echo -n "\ en_US.UTF-8 UTF-8 fr_FR.UTF-8 UTF-8 " > '/etc/locale.gen' - # generate locales - locale-gen - # update catalog - apt-get update - # - debian_disable_frontend - # install packages - for package in "${packages[@]}" ; do - echo ; echo "${package}" - apt-get install \ - --assume-yes \ - "${package}" - apt_clean_cache - done - # update catalog - apt-get update + # generate locales + locale-gen + # update catalog + apt-get update + # + debian_disable_frontend + # install packages + for package in "${packages[@]}" ; do + echo ; echo "${package}" + apt-get install \ + --assume-yes \ + "${package}" + apt_clean_cache + done + # update catalog + apt-get update } rescue_hetzner_install() { - local package - local release='bookworm' - local packages=( - # installed - 'dmidecode' 'efibootmgr' 'pciutils' 'usbutils' - 'parted' 'mdadm' 'cryptsetup-bin' 'lvm2' - 'btrfs-progs' 'dosfstools' - 'git' 'nano' 'python3' 'rsync' 'vim' - 'file' 'htop' 'lsof' 'man-db' 'tree' 'uuid-runtime' - # install - 'lshw' - 'duperemove' 'squashfs-tools' - 'grub-efi-amd64-bin' 'grub-pc-bin' - 'libdigest-sha3-perl' 'micro' - 'iotop' - 'exa' 'ipcalc' 'lf' 'ncdu' 'nnn' 'ranger' - ) - local backports=( - ) - # update catalog - apt-get update - # - debian_disable_frontend - # upgrade packages - apt-get upgrade --assume-yes - # - apt_clean_cache - # install packages - for package in "${packages[@]}" ; do - echo ; echo "${package}" - apt-get install \ - --assume-yes \ - "${package}" - apt_clean_cache - done - # install backports - for package in "${backports[@]}" ; do - echo ; echo "${package}" - apt-get install \ - --assume-yes \ - --target-release "${release}-backports" \ - "${package}" - apt_clean_cache - done + local package + local release='bookworm' + local packages=( + # installed + 'dmidecode' 'efibootmgr' 'pciutils' 'usbutils' + 'parted' 'mdadm' 'cryptsetup-bin' 'lvm2' + 'btrfs-progs' 'dosfstools' + 'git' 'nano' 'python3' 'rsync' 'vim' + 'file' 'htop' 'lsof' 'man-db' 'tree' 'uuid-runtime' + # install + 'lshw' + 'duperemove' 'squashfs-tools' + 'grub-efi-amd64-bin' 'grub-pc-bin' + 'libdigest-sha3-perl' 'micro' + 'iotop' + 'exa' 'ipcalc' 'lf' 'ncdu' 'nnn' 'ranger' + ) + local backports=( + ) + # update catalog + apt-get update + # + debian_disable_frontend + # upgrade packages + apt-get upgrade --assume-yes + # + apt_clean_cache + # install packages + for package in "${packages[@]}" ; do + echo ; echo "${package}" + apt-get install \ + --assume-yes \ + "${package}" + apt_clean_cache + done + # install backports + for package in "${backports[@]}" ; do + echo ; echo "${package}" + apt-get install \ + --assume-yes \ + --target-release "${release}-backports" \ + "${package}" + apt_clean_cache + done } rescue_hetzner_upload() { local host="${1}" local hostname="${2}" if [ "${hostname}" ] ; then - local user='root' - # - local user_host="${user}@${host}" - # remove fingerprints - ssh-keygen -R "${host}" - # copy ssh id - ssh-copy-id \ - -o 'StrictHostKeyChecking=accept-new' \ - "${user_host}" - # upload root - rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" - # call setup - # TODO variable - ssh "${user_host}" -- "source '/etc/bash/main.sh' ; rescue_hetzner_configure '${hostname}'" - # create session - ssh "${user_host}" -- byobu new-session -d - # send keys - ssh "${user_host}" -- byobu send-keys 'rescue_hetzner_install' 'C-m' - # attach session - mosh "${user_host}" -- byobu attach-session + local user='root' + # + local user_host="${user}@${host}" + # remove fingerprints + ssh-keygen -R "${host}" + # copy ssh id + ssh-copy-id \ + -o 'StrictHostKeyChecking=accept-new' \ + "${user_host}" + # upload root + rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" + # call setup + # TODO variable + ssh "${user_host}" -- "source '/etc/bash/main.sh' ; rescue_hetzner_configure '${hostname}'" + # create session + ssh "${user_host}" -- byobu new-session -d + # send keys + ssh "${user_host}" -- byobu send-keys 'rescue_hetzner_install' 'C-m' + # attach session + mosh "${user_host}" -- byobu attach-session else - echo 'Host?' - return 1 + echo 'Host?' + return 1 fi } rescue_hetzner_wipe_8_8_0_init() { - local device - local devices=( - '/dev/sda' - '/dev/sdb' - ) - local members - local number - local passphrase - local unit='mib' - # read passphrase - echo -n 'PassPhrase: ' - read -r -s passphrase - # - lsblk - echo -n 'WIPE' "${devices[@]}" '/?\ OR CANCEL /!\' - read - # - number=0 - for device in "${devices[@]}" ; do - ((number++)) - echo ; echo "#${number}: ${device}" - # - parted "${device}" --script mktable gpt - # - parted "${device}" unit "${unit}" \ - mkpart "crypt-${number}" 33282 7630885 - # - parted "${device}" unit "${unit}" \ - mkpart "boot-${number}" 514 33282 - # - parted "${device}" unit "${unit}" \ - mkpart "esp-${number}" 2 514 - parted "${device}" set 3 esp on - # - parted "${device}" unit "${unit}" \ - mkpart "bios-${number}" 1 2 - parted "${device}" set 4 bios_grub on - done - # - number=0 - for device in "${devices[@]}" ; do - ((number++)) - echo ; echo "#${number}: ${device}4" - # wipe bios - dd \ - if='/dev/zero' of="${device}4" - done - # - number=0 - for device in "${devices[@]}" ; do - ((number++)) - echo ; echo "#${number}: ${device}3" - # format esp - dd \ - if='/dev/zero' of="${device}3" bs='1M' - mkfs.vfat \ - -F 32 \ - -S 4096 \ - -i "0000000${number}" \ - -n "esp-${number}" \ - "${device}3" - # mount esp - mkdir --parents "/media/esp/${number}" - mount "${device}3" "/media/esp/${number}" - done - # - number=0 - for device in "${devices[@]}" ; do - ((number++)) - echo ; echo "#${number}: ${device}2" - # wipe boot - dd status='progress' \ - if='/dev/zero' of="${device}2" bs='1G' count=1 - done - # - members=() - for device in "${devices[@]}" ; do - members+=("${device}2") - done - mdadm \ - --create '/dev/md/boot' \ - --level 0 \ - --metadata 1 \ - --name 'md:boot' \ - --raid-devices ${#devices[@]} \ - --uuid '00000000:00000000:00000000:00000002' \ - "${members[@]}" - # - mkfs.btrfs --force \ - --checksum 'sha256' \ - --label 'boot' \ - --uuid '00000000-0000-0000-0000-00000000000b' \ - '/dev/md/boot' - # mount boot - mkdir --parents '/media/boot' - mount \ - --options 'autodefrag,compress-force=zstd' \ - '/dev/md/boot' '/media/boot' - # - number=0 - for device in "${devices[@]}" ; do - ((number++)) - echo ; echo "#${number}: ${device}1" - # wipe crypt head - dd status='progress' \ - if='/dev/zero' of="${device}1" bs='1G' count=1 - done - # - members=() - for device in "${devices[@]}" ; do - members+=("${device}1") - done - mdadm \ - --create '/dev/md/crypt' \ - --level 0 \ - --metadata 1 \ - --name 'md:crypt' \ - --raid-devices ${#devices[@]} \ - --uuid '00000000:00000000:00000000:00000001' \ - "${members[@]}" - # encrypt - echo "${passphrase}" \ - | cryptsetup \ - --verbose \ - --batch-mode \ - --type 'luks2' \ - --pbkdf 'argon2id' \ - --cipher 'aes-xts-plain64' \ - --iter-time 8192 \ - --key-size 512 \ - --hash 'sha512' \ - --use-random \ - luksFormat \ - '/dev/md/crypt' - # open - echo "${passphrase}" \ - | cryptsetup luksOpen '/dev/md/crypt' 'crypt' + local device + local devices=( + '/dev/sda' + '/dev/sdb' + ) + local members + local number + local passphrase + local unit='mib' + # read passphrase + echo -n 'PassPhrase: ' + read -r -s passphrase + # + lsblk + echo -n 'WIPE' "${devices[@]}" '/?\ OR CANCEL /!\' + read + # + number=0 + for device in "${devices[@]}" ; do + ((number++)) + echo ; echo "#${number}: ${device}" + # + parted "${device}" --script mktable gpt + # + parted "${device}" unit "${unit}" \ + mkpart "crypt-${number}" 33282 7630885 + # + parted "${device}" unit "${unit}" \ + mkpart "boot-${number}" 514 33282 + # + parted "${device}" unit "${unit}" \ + mkpart "esp-${number}" 2 514 + parted "${device}" set 3 esp on + # + parted "${device}" unit "${unit}" \ + mkpart "bios-${number}" 1 2 + parted "${device}" set 4 bios_grub on + done + # + number=0 + for device in "${devices[@]}" ; do + ((number++)) + echo ; echo "#${number}: ${device}4" + # wipe bios + dd \ + if='/dev/zero' of="${device}4" + done + # + number=0 + for device in "${devices[@]}" ; do + ((number++)) + echo ; echo "#${number}: ${device}3" + # format esp + dd \ + if='/dev/zero' of="${device}3" bs='1M' + mkfs.vfat \ + -F 32 \ + -S 4096 \ + -i "0000000${number}" \ + -n "esp-${number}" \ + "${device}3" + # mount esp + mkdir --parents "/media/esp/${number}" + mount "${device}3" "/media/esp/${number}" + done + # + number=0 + for device in "${devices[@]}" ; do + ((number++)) + echo ; echo "#${number}: ${device}2" + # wipe boot + dd status='progress' \ + if='/dev/zero' of="${device}2" bs='1G' count=1 + done + # + members=() + for device in "${devices[@]}" ; do + members+=("${device}2") + done + mdadm \ + --create '/dev/md/boot' \ + --level 0 \ + --metadata 1 \ + --name 'md:boot' \ + --raid-devices ${#devices[@]} \ + --uuid '00000000:00000000:00000000:00000002' \ + "${members[@]}" + # + mkfs.btrfs --force \ + --checksum 'sha256' \ + --label 'boot' \ + --uuid '00000000-0000-0000-0000-00000000000b' \ + '/dev/md/boot' + # mount boot + mkdir --parents '/media/boot' + mount \ + --options 'autodefrag,compress-force=zstd' \ + '/dev/md/boot' '/media/boot' + # + number=0 + for device in "${devices[@]}" ; do + ((number++)) + echo ; echo "#${number}: ${device}1" + # wipe crypt head + dd status='progress' \ + if='/dev/zero' of="${device}1" bs='1G' count=1 + done + # + members=() + for device in "${devices[@]}" ; do + members+=("${device}1") + done + mdadm \ + --create '/dev/md/crypt' \ + --level 0 \ + --metadata 1 \ + --name 'md:crypt' \ + --raid-devices ${#devices[@]} \ + --uuid '00000000:00000000:00000000:00000001' \ + "${members[@]}" + # encrypt + echo "${passphrase}" \ + | cryptsetup \ + --verbose \ + --batch-mode \ + --type 'luks2' \ + --pbkdf 'argon2id' \ + --cipher 'aes-xts-plain64' \ + --iter-time 8192 \ + --key-size 512 \ + --hash 'sha512' \ + --use-random \ + luksFormat \ + '/dev/md/crypt' + # open + echo "${passphrase}" \ + | cryptsetup luksOpen '/dev/md/crypt' 'crypt' } rescue_hetzner_wipe_8_8_1_zero() { - # wipe crypt - dd status='progress' \ - if='/dev/zero' of='/dev/mapper/crypt' bs='8G' + # wipe crypt + dd status='progress' \ + if='/dev/zero' of='/dev/mapper/crypt' bs='8G' } rescue_hetzner_wipe_8_8_2_make() { - local passphrase - # close - cryptsetup luksClose 'crypt' - # read passphrase - echo -n 'PassPhrase: ' - read -r -s passphrase - # encrypt - echo "${passphrase}" \ - | cryptsetup \ - --verbose \ - --batch-mode \ - --type 'luks2' \ - --pbkdf 'argon2id' \ - --cipher 'aes-xts-plain64' \ - --iter-time 8192 \ - --key-size 512 \ - --hash 'sha512' \ - --use-random \ - luksFormat \ - '/dev/md/crypt' - # open - echo "${passphrase}" \ - | cryptsetup luksOpen '/dev/md/crypt' 'crypt' - # format crypt - mkfs.btrfs --force \ - --checksum 'sha256' \ - --label 'crypt' \ - --uuid '00000000-0000-0000-0000-00000000000c' \ - '/dev/mapper/crypt' - # mount crypt - mkdir --parents '/media/crypt' - mount \ - --options 'autodefrag,compress-force=zstd' \ - '/dev/mapper/crypt' '/media/crypt' - # make swap file - btrfs filesystem mkswapfile \ - --size '64g' \ - --uuid '00000000-0000-0000-0000-000000000005' \ - '/media/crypt/swap' + local passphrase + # close + cryptsetup luksClose 'crypt' + # read passphrase + echo -n 'PassPhrase: ' + read -r -s passphrase + # encrypt + echo "${passphrase}" \ + | cryptsetup \ + --verbose \ + --batch-mode \ + --type 'luks2' \ + --pbkdf 'argon2id' \ + --cipher 'aes-xts-plain64' \ + --iter-time 8192 \ + --key-size 512 \ + --hash 'sha512' \ + --use-random \ + luksFormat \ + '/dev/md/crypt' + # open + echo "${passphrase}" \ + | cryptsetup luksOpen '/dev/md/crypt' 'crypt' + # format crypt + mkfs.btrfs --force \ + --checksum 'sha256' \ + --label 'crypt' \ + --uuid '00000000-0000-0000-0000-00000000000c' \ + '/dev/mapper/crypt' + # mount crypt + mkdir --parents '/media/crypt' + mount \ + --options 'autodefrag,compress-force=zstd' \ + '/dev/mapper/crypt' '/media/crypt' + # make swap file + btrfs filesystem mkswapfile \ + --size '64g' \ + --uuid '00000000-0000-0000-0000-000000000005' \ + '/media/crypt/swap' } rescue_hetzner_wipe_8_8_3_close() { - umount '/media/boot' - # - umount '/media/crypt' \ - && cryptsetup luksClose 'crypt' + umount '/media/boot' + # + umount '/media/crypt' \ + && cryptsetup luksClose 'crypt' } From 5776a03fe4d9aeb8fdea18a5a6997f4ae7962641 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 17:02:08 +0100 Subject: [PATCH 444/969] indent --- bash/rescue-hetzner.sh | 54 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 49ad0a5..676568d 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -101,33 +101,33 @@ rescue_hetzner_install() { } rescue_hetzner_upload() { -local host="${1}" -local hostname="${2}" -if [ "${hostname}" ] ; then - local user='root' - # - local user_host="${user}@${host}" - # remove fingerprints - ssh-keygen -R "${host}" - # copy ssh id - ssh-copy-id \ - -o 'StrictHostKeyChecking=accept-new' \ - "${user_host}" - # upload root - rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" - # call setup - # TODO variable - ssh "${user_host}" -- "source '/etc/bash/main.sh' ; rescue_hetzner_configure '${hostname}'" - # create session - ssh "${user_host}" -- byobu new-session -d - # send keys - ssh "${user_host}" -- byobu send-keys 'rescue_hetzner_install' 'C-m' - # attach session - mosh "${user_host}" -- byobu attach-session -else - echo 'Host?' - return 1 -fi + local host="${1}" + local hostname="${2}" + if [ "${hostname}" ] ; then + local user='root' + # + local user_host="${user}@${host}" + # remove fingerprints + ssh-keygen -R "${host}" + # copy ssh id + ssh-copy-id \ + -o 'StrictHostKeyChecking=accept-new' \ + "${user_host}" + # upload root + rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" + # call setup + # TODO variable + ssh "${user_host}" -- "source '/etc/bash/main.sh' ; rescue_hetzner_configure '${hostname}'" + # create session + ssh "${user_host}" -- byobu new-session -d + # send keys + ssh "${user_host}" -- byobu send-keys 'rescue_hetzner_install' 'C-m' + # attach session + mosh "${user_host}" -- byobu attach-session + else + echo 'Host?' + return 1 + fi } rescue_hetzner_wipe_8_8_0_init() { From 641924309802dcfc32ca95fbd73b56f17611b96c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 17:14:04 +0100 Subject: [PATCH 445/969] shfmt --- bash/rescue-hetzner.sh | 271 +++++++++++++++++++++-------------------- 1 file changed, 141 insertions(+), 130 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 676568d..d170c95 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -1,10 +1,10 @@ rescue_hetzner_configure() { -local hostname="${1}" + local hostname="${1}" local package local packages=( - 'mosh' - 'screen' 'tmux' 'byobu' - 'apt-file' + 'mosh' + 'screen' 'tmux' 'byobu' + 'apt-file' ) # apt / conf echo -n "\ @@ -17,14 +17,14 @@ APT::Install-Suggests False; APT::Get::Show-Versions True; Dir::Etc::SourceParts ''; Dpkg::Progress True; -" > '/etc/apt/apt.conf' +" >'/etc/apt/apt.conf' # apt / sources echo -n "\ deb https://deb.debian.org/debian bookworm main non-free-firmware contrib non-free deb https://deb.debian.org/debian bookworm-backports main non-free-firmware contrib non-free deb https://deb.debian.org/debian bookworm-updates main non-free-firmware contrib non-free deb https://deb.debian.org/debian-security bookworm-security main non-free-firmware contrib non-free -" > '/etc/apt/sources.list' +" >'/etc/apt/sources.list' # bash / rc main_link_bashrc mv .bashrc .bashrc.old @@ -34,7 +34,7 @@ deb https://deb.debian.org/debian-security bookworm-security main non-free-firmw echo -n "\ en_US.UTF-8 UTF-8 fr_FR.UTF-8 UTF-8 -" > '/etc/locale.gen' +" >'/etc/locale.gen' # generate locales locale-gen # update catalog @@ -42,11 +42,12 @@ fr_FR.UTF-8 UTF-8 # debian_disable_frontend # install packages - for package in "${packages[@]}" ; do - echo ; echo "${package}" + for package in "${packages[@]}"; do + echo + echo "${package}" apt-get install \ - --assume-yes \ - "${package}" + --assume-yes \ + "${package}" apt_clean_cache done # update catalog @@ -57,19 +58,19 @@ rescue_hetzner_install() { local package local release='bookworm' local packages=( - # installed - 'dmidecode' 'efibootmgr' 'pciutils' 'usbutils' - 'parted' 'mdadm' 'cryptsetup-bin' 'lvm2' - 'btrfs-progs' 'dosfstools' - 'git' 'nano' 'python3' 'rsync' 'vim' - 'file' 'htop' 'lsof' 'man-db' 'tree' 'uuid-runtime' - # install - 'lshw' - 'duperemove' 'squashfs-tools' - 'grub-efi-amd64-bin' 'grub-pc-bin' - 'libdigest-sha3-perl' 'micro' - 'iotop' - 'exa' 'ipcalc' 'lf' 'ncdu' 'nnn' 'ranger' + # installed + 'dmidecode' 'efibootmgr' 'pciutils' 'usbutils' + 'parted' 'mdadm' 'cryptsetup-bin' 'lvm2' + 'btrfs-progs' 'dosfstools' + 'git' 'nano' 'python3' 'rsync' 'vim' + 'file' 'htop' 'lsof' 'man-db' 'tree' 'uuid-runtime' + # install + 'lshw' + 'duperemove' 'squashfs-tools' + 'grub-efi-amd64-bin' 'grub-pc-bin' + 'libdigest-sha3-perl' 'micro' + 'iotop' + 'exa' 'ipcalc' 'lf' 'ncdu' 'nnn' 'ranger' ) local backports=( ) @@ -82,20 +83,22 @@ rescue_hetzner_install() { # apt_clean_cache # install packages - for package in "${packages[@]}" ; do - echo ; echo "${package}" + for package in "${packages[@]}"; do + echo + echo "${package}" apt-get install \ - --assume-yes \ - "${package}" + --assume-yes \ + "${package}" apt_clean_cache done # install backports - for package in "${backports[@]}" ; do - echo ; echo "${package}" + for package in "${backports[@]}"; do + echo + echo "${package}" apt-get install \ - --assume-yes \ - --target-release "${release}-backports" \ - "${package}" + --assume-yes \ + --target-release "${release}-backports" \ + "${package}" apt_clean_cache done } @@ -103,7 +106,7 @@ rescue_hetzner_install() { rescue_hetzner_upload() { local host="${1}" local hostname="${2}" - if [ "${hostname}" ] ; then + if [ "${hostname}" ]; then local user='root' # local user_host="${user}@${host}" @@ -111,8 +114,8 @@ rescue_hetzner_upload() { ssh-keygen -R "${host}" # copy ssh id ssh-copy-id \ - -o 'StrictHostKeyChecking=accept-new' \ - "${user_host}" + -o 'StrictHostKeyChecking=accept-new' \ + "${user_host}" # upload root rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" # call setup @@ -149,131 +152,139 @@ rescue_hetzner_wipe_8_8_0_init() { read # number=0 - for device in "${devices[@]}" ; do + for device in "${devices[@]}"; do ((number++)) - echo ; echo "#${number}: ${device}" + echo + echo "#${number}: ${device}" # - parted "${device}" --script mktable gpt + parted "${device}" --script \ + mktable gpt # - parted "${device}" unit "${unit}" \ - mkpart "crypt-${number}" 33282 7630885 + parted "${device}" \ + unit "${unit}" mkpart "crypt-${number}" 33282 7630885 # - parted "${device}" unit "${unit}" \ - mkpart "boot-${number}" 514 33282 + parted "${device}" \ + unit "${unit}" mkpart "boot-${number}" 514 33282 # - parted "${device}" unit "${unit}" \ - mkpart "esp-${number}" 2 514 - parted "${device}" set 3 esp on + parted "${device}" \ + unit "${unit}" mkpart "esp-${number}" 2 514 + parted "${device}" \ + set 3 esp on # - parted "${device}" unit "${unit}" \ - mkpart "bios-${number}" 1 2 - parted "${device}" set 4 bios_grub on + parted "${device}" \ + unit "${unit}" mkpart "bios-${number}" 1 2 + parted "${device}" \ + set 4 bios_grub on done # number=0 - for device in "${devices[@]}" ; do + for device in "${devices[@]}"; do ((number++)) - echo ; echo "#${number}: ${device}4" + echo + echo "#${number}: ${device}4" # wipe bios dd \ - if='/dev/zero' of="${device}4" + if='/dev/zero' of="${device}4" done # number=0 - for device in "${devices[@]}" ; do + for device in "${devices[@]}"; do ((number++)) - echo ; echo "#${number}: ${device}3" + echo + echo "#${number}: ${device}3" # format esp dd \ - if='/dev/zero' of="${device}3" bs='1M' + if='/dev/zero' of="${device}3" bs='1M' mkfs.vfat \ - -F 32 \ - -S 4096 \ - -i "0000000${number}" \ - -n "esp-${number}" \ - "${device}3" + -F 32 \ + -S 4096 \ + -i "0000000${number}" \ + -n "esp-${number}" \ + "${device}3" # mount esp mkdir --parents "/media/esp/${number}" mount "${device}3" "/media/esp/${number}" done # number=0 - for device in "${devices[@]}" ; do + for device in "${devices[@]}"; do ((number++)) - echo ; echo "#${number}: ${device}2" + echo + echo "#${number}: ${device}2" # wipe boot dd status='progress' \ - if='/dev/zero' of="${device}2" bs='1G' count=1 + if='/dev/zero' of="${device}2" bs='1G' count=1 done # members=() - for device in "${devices[@]}" ; do + for device in "${devices[@]}"; do members+=("${device}2") done mdadm \ - --create '/dev/md/boot' \ - --level 0 \ - --metadata 1 \ - --name 'md:boot' \ - --raid-devices ${#devices[@]} \ - --uuid '00000000:00000000:00000000:00000002' \ - "${members[@]}" + --create '/dev/md/boot' \ + --level 0 \ + --metadata 1 \ + --name 'md:boot' \ + --raid-devices ${#devices[@]} \ + --uuid '00000000:00000000:00000000:00000002' \ + "${members[@]}" # mkfs.btrfs --force \ - --checksum 'sha256' \ - --label 'boot' \ - --uuid '00000000-0000-0000-0000-00000000000b' \ - '/dev/md/boot' + --checksum 'sha256' \ + --label 'boot' \ + --uuid '00000000-0000-0000-0000-00000000000b' \ + '/dev/md/boot' # mount boot mkdir --parents '/media/boot' mount \ - --options 'autodefrag,compress-force=zstd' \ - '/dev/md/boot' '/media/boot' + --options 'autodefrag,compress-force=zstd' \ + '/dev/md/boot' '/media/boot' # number=0 - for device in "${devices[@]}" ; do + for device in "${devices[@]}"; do ((number++)) - echo ; echo "#${number}: ${device}1" + echo + echo "#${number}: ${device}1" # wipe crypt head dd status='progress' \ - if='/dev/zero' of="${device}1" bs='1G' count=1 + if='/dev/zero' of="${device}1" bs='1G' count=1 done # members=() - for device in "${devices[@]}" ; do + for device in "${devices[@]}"; do members+=("${device}1") done mdadm \ - --create '/dev/md/crypt' \ - --level 0 \ - --metadata 1 \ - --name 'md:crypt' \ - --raid-devices ${#devices[@]} \ - --uuid '00000000:00000000:00000000:00000001' \ - "${members[@]}" + --create '/dev/md/crypt' \ + --level 0 \ + --metadata 1 \ + --name 'md:crypt' \ + --raid-devices ${#devices[@]} \ + --uuid '00000000:00000000:00000000:00000001' \ + "${members[@]}" # encrypt - echo "${passphrase}" \ - | cryptsetup \ - --verbose \ - --batch-mode \ - --type 'luks2' \ - --pbkdf 'argon2id' \ - --cipher 'aes-xts-plain64' \ - --iter-time 8192 \ - --key-size 512 \ - --hash 'sha512' \ - --use-random \ - luksFormat \ - '/dev/md/crypt' + echo "${passphrase}" | + cryptsetup \ + --verbose \ + --batch-mode \ + --type 'luks2' \ + --pbkdf 'argon2id' \ + --cipher 'aes-xts-plain64' \ + --iter-time 8192 \ + --key-size 512 \ + --hash 'sha512' \ + --use-random \ + luksFormat \ + '/dev/md/crypt' # open - echo "${passphrase}" \ - | cryptsetup luksOpen '/dev/md/crypt' 'crypt' + echo "${passphrase}" | + cryptsetup luksOpen '/dev/md/crypt' 'crypt' } rescue_hetzner_wipe_8_8_1_zero() { # wipe crypt dd status='progress' \ - if='/dev/zero' of='/dev/mapper/crypt' bs='8G' + if='/dev/zero' of='/dev/mapper/crypt' bs='8G' } rescue_hetzner_wipe_8_8_2_make() { @@ -284,43 +295,43 @@ rescue_hetzner_wipe_8_8_2_make() { echo -n 'PassPhrase: ' read -r -s passphrase # encrypt - echo "${passphrase}" \ - | cryptsetup \ - --verbose \ - --batch-mode \ - --type 'luks2' \ - --pbkdf 'argon2id' \ - --cipher 'aes-xts-plain64' \ - --iter-time 8192 \ - --key-size 512 \ - --hash 'sha512' \ - --use-random \ - luksFormat \ - '/dev/md/crypt' + echo "${passphrase}" | + cryptsetup \ + --verbose \ + --batch-mode \ + --type 'luks2' \ + --pbkdf 'argon2id' \ + --cipher 'aes-xts-plain64' \ + --iter-time 8192 \ + --key-size 512 \ + --hash 'sha512' \ + --use-random \ + luksFormat \ + '/dev/md/crypt' # open - echo "${passphrase}" \ - | cryptsetup luksOpen '/dev/md/crypt' 'crypt' + echo "${passphrase}" | + cryptsetup luksOpen '/dev/md/crypt' 'crypt' # format crypt mkfs.btrfs --force \ - --checksum 'sha256' \ - --label 'crypt' \ - --uuid '00000000-0000-0000-0000-00000000000c' \ - '/dev/mapper/crypt' + --checksum 'sha256' \ + --label 'crypt' \ + --uuid '00000000-0000-0000-0000-00000000000c' \ + '/dev/mapper/crypt' # mount crypt mkdir --parents '/media/crypt' mount \ - --options 'autodefrag,compress-force=zstd' \ - '/dev/mapper/crypt' '/media/crypt' + --options 'autodefrag,compress-force=zstd' \ + '/dev/mapper/crypt' '/media/crypt' # make swap file btrfs filesystem mkswapfile \ - --size '64g' \ - --uuid '00000000-0000-0000-0000-000000000005' \ - '/media/crypt/swap' + --size '64g' \ + --uuid '00000000-0000-0000-0000-000000000005' \ + '/media/crypt/swap' } rescue_hetzner_wipe_8_8_3_close() { umount '/media/boot' # - umount '/media/crypt' \ - && cryptsetup luksClose 'crypt' + umount '/media/crypt' && + cryptsetup luksClose 'crypt' } From 1f9ba3b19d72b698b2d53f8d2eac56a631c190d4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 17:19:05 +0100 Subject: [PATCH 446/969] parted --- bash/rescue-hetzner.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index d170c95..ab7d379 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -157,22 +157,27 @@ rescue_hetzner_wipe_8_8_0_init() { echo echo "#${number}: ${device}" # - parted "${device}" --script \ + parted "${device}" \ + --script \ mktable gpt # parted "${device}" \ - unit "${unit}" mkpart "crypt-${number}" 33282 7630885 + unit "${unit}" \ + mkpart "crypt-${number}" 33282 7630885 # parted "${device}" \ - unit "${unit}" mkpart "boot-${number}" 514 33282 + unit "${unit}" \ + mkpart "boot-${number}" 514 33282 # parted "${device}" \ - unit "${unit}" mkpart "esp-${number}" 2 514 + unit "${unit}" \ + mkpart "esp-${number}" 2 514 parted "${device}" \ set 3 esp on # parted "${device}" \ - unit "${unit}" mkpart "bios-${number}" 1 2 + unit "${unit}" \ + mkpart "bios-${number}" 1 2 parted "${device}" \ set 4 bios_grub on done From ef87d4d410ffefa8013167d5a7d3df6211a58351 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 17:21:21 +0100 Subject: [PATCH 447/969] parted/ovh --- bash/rescue-ovh.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index a98e8f7..a88b9af 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -152,17 +152,29 @@ rescue_ovh_wipe_vle2_0_init() { printf "%s" "WIPE ${device} /?\\ OR CANCEL /!\\" read -r # - parted "${device}" --script mktable gpt + parted "${device}" \ + --script \ + mktable gpt # - parted "${device}" unit "${unit}" mkpart "crypt" 4610 40960 + parted "${device}" \ + unit "${unit}" \ + mkpart "crypt" 4610 40960 # - parted "${device}" unit "${unit}" mkpart "boot" 514 4610 + parted "${device}" \ + unit "${unit}" \ + mkpart "boot" 514 4610 # - parted "${device}" unit "${unit}" mkpart "esp" 2 514 - parted "${device}" set 3 esp on + parted "${device}" \ + unit "${unit}" \ + mkpart "esp" 2 514 + parted "${device}" \ + set 3 esp on # - parted "${device}" unit "${unit}" mkpart bios 1 2 - parted "${device}" set 4 bios_grub on + parted "${device}" \ + unit "${unit}" \ + mkpart bios 1 2 + parted "${device}" \ + set 4 bios_grub on # bios / wipe dd if="/dev/zero" of="${device}4" # esp / wipe From d11ab01afe392b952f4e7cee08fcf1e4461ce271 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 17:33:55 +0100 Subject: [PATCH 448/969] configure --- bash/rescue-hetzner.sh | 70 +++++------------------------------------- bash/rescue-ovh.sh | 68 +--------------------------------------- bash/rescue.sh | 65 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 129 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index ab7d379..5b123ab 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -1,59 +1,3 @@ -rescue_hetzner_configure() { - local hostname="${1}" - local package - local packages=( - 'mosh' - 'screen' 'tmux' 'byobu' - 'apt-file' - ) - # apt / conf - echo -n "\ -Acquire::AllowInsecureRepositories False; -Acquire::AllowWeakRepositories False; -Acquire::AllowDowngradeToInsecureRepositories False; -Acquire::Check-Valid-Until True; -APT::Install-Recommends False; -APT::Install-Suggests False; -APT::Get::Show-Versions True; -Dir::Etc::SourceParts ''; -Dpkg::Progress True; -" >'/etc/apt/apt.conf' - # apt / sources - echo -n "\ -deb https://deb.debian.org/debian bookworm main non-free-firmware contrib non-free -deb https://deb.debian.org/debian bookworm-backports main non-free-firmware contrib non-free -deb https://deb.debian.org/debian bookworm-updates main non-free-firmware contrib non-free -deb https://deb.debian.org/debian-security bookworm-security main non-free-firmware contrib non-free -" >'/etc/apt/sources.list' - # bash / rc - main_link_bashrc - mv .bashrc .bashrc.old - # host name - hostname "${hostname}" - # locales - echo -n "\ -en_US.UTF-8 UTF-8 -fr_FR.UTF-8 UTF-8 -" >'/etc/locale.gen' - # generate locales - locale-gen - # update catalog - apt-get update - # - debian_disable_frontend - # install packages - for package in "${packages[@]}"; do - echo - echo "${package}" - apt-get install \ - --assume-yes \ - "${package}" - apt_clean_cache - done - # update catalog - apt-get update -} - rescue_hetzner_install() { local package local release='bookworm' @@ -107,28 +51,30 @@ rescue_hetzner_upload() { local host="${1}" local hostname="${2}" if [ "${hostname}" ]; then - local user='root' + local user="root" # local user_host="${user}@${host}" # remove fingerprints ssh-keygen -R "${host}" # copy ssh id ssh-copy-id \ - -o 'StrictHostKeyChecking=accept-new' \ + -o "StrictHostKeyChecking=accept-new" \ "${user_host}" # upload root - rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" + rsync --delete --recursive \ + "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" # call setup # TODO variable - ssh "${user_host}" -- "source '/etc/bash/main.sh' ; rescue_hetzner_configure '${hostname}'" + ssh "${user_host}" -- "\ +source \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\"" # create session ssh "${user_host}" -- byobu new-session -d # send keys - ssh "${user_host}" -- byobu send-keys 'rescue_hetzner_install' 'C-m' + ssh "${user_host}" -- byobu send-keys "rescue_hetzner_install" "C-m" # attach session mosh "${user_host}" -- byobu attach-session else - echo 'Host?' + echo "Host?" return 1 fi } diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index a88b9af..cd91e87 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -1,71 +1,5 @@ #! /usr/bin/env sh -rescue_ovh_configure() { - local hostname="${1}" - local release="bookworm" - local package - # apt / conf - printf "\ -Acquire::AllowInsecureRepositories False; -Acquire::AllowWeakRepositories False; -Acquire::AllowDowngradeToInsecureRepositories False; -Acquire::Check-Valid-Until True; -APT::Install-Recommends False; -APT::Install-Suggests False; -APT::Get::Show-Versions True; -Dir::Etc::SourceParts \"\"; -Dpkg::Progress True; -" >"/etc/apt/apt.conf.d/apt.conf" - # apt / sources - printf "%s" "\ -deb https://deb.debian.org/debian \ -${release} main non-free-firmware contrib non-free -deb https://deb.debian.org/debian \ -${release}-backports main non-free-firmware contrib non-free -deb https://deb.debian.org/debian \ -${release}-updates main non-free-firmware contrib non-free -deb https://deb.debian.org/debian-security \ -${release}-security main non-free-firmware contrib non-free -" >"/etc/apt/sources.list" - # bash / rc - main_link_bashrc - mv .bashrc .bashrc.old - # host name - hostname "${hostname}" - # locales - printf "\ -en_US.UTF-8 UTF-8 -fr_FR.UTF-8 UTF-8 -" >"/etc/locale.gen" - # generate locales - locale-gen - # update catalog - apt-get update - # disable frontend - debian_disable_frontend - # install backports - set "tmux" - for package in "${@}"; do - echo - echo "${package}" - apt-get install --assume-yes \ - --target-release "${release}-backports" \ - "${package}" - apt_clean_cache - done - # install packages - set "apt-file" "mosh" "byobu" - for package in "${@}"; do - echo - echo "${package}" - apt-get install --assume-yes \ - "${package}" - apt_clean_cache - done - # update catalog - apt-get update -} - rescue_ovh_install() { local package local release="bookworm" @@ -127,7 +61,7 @@ rescue_ovh_upload() { # call setup # TODO variable ssh "${user_host}" -- "\ -source \"/etc/bash/main.sh\" ; rescue_ovh_configure \"${hostname}\"" +source \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\"" # create session ssh "${user_host}" -- byobu new-session -d # send keys diff --git a/bash/rescue.sh b/bash/rescue.sh index e69de29..8b1bc32 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -0,0 +1,65 @@ +rescue_configure() { + local hostname="${1}" + local release="bookworm" + local package + # apt / conf + printf "\ +Acquire::AllowInsecureRepositories False; +Acquire::AllowWeakRepositories False; +Acquire::AllowDowngradeToInsecureRepositories False; +Acquire::Check-Valid-Until True; +APT::Install-Recommends False; +APT::Install-Suggests False; +APT::Get::Show-Versions True; +Dir::Etc::SourceParts \"\"; +Dpkg::Progress True; +" >"/etc/apt/apt.conf.d/apt.conf" + # apt / sources + printf "%s" "\ +deb https://deb.debian.org/debian \ +${release} main non-free-firmware contrib non-free +deb https://deb.debian.org/debian \ +${release}-backports main non-free-firmware contrib non-free +deb https://deb.debian.org/debian \ +${release}-updates main non-free-firmware contrib non-free +deb https://deb.debian.org/debian-security \ +${release}-security main non-free-firmware contrib non-free +" >"/etc/apt/sources.list" + # bash / rc + main_link_bashrc + mv .bashrc .bashrc.old + # host name + hostname "${hostname}" + # locales + printf "\ +en_US.UTF-8 UTF-8 +fr_FR.UTF-8 UTF-8 +" >"/etc/locale.gen" + # generate locales + locale-gen + # update catalog + apt-get update + # disable frontend + debian_disable_frontend + # install backports + set "tmux" + for package in "${@}"; do + echo + echo "${package}" + apt-get install --assume-yes \ + --target-release "${release}-backports" \ + "${package}" + apt_clean_cache + done + # install packages + set "apt-file" "mosh" "screen" "byobu" + for package in "${@}"; do + echo + echo "${package}" + apt-get install --assume-yes \ + "${package}" + apt_clean_cache + done + # update catalog + apt-get update +} From d3a510ab38d16bd46ce831fab3f75edb0dc2a230 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 17:34:32 +0100 Subject: [PATCH 449/969] shebang --- bash/rescue-ovh.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index cd91e87..b44c5fd 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -1,5 +1,3 @@ -#! /usr/bin/env sh - rescue_ovh_install() { local package local release="bookworm" From 98c121d8374464a4fa440cfa44ec00f833a74290 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 17:52:34 +0100 Subject: [PATCH 450/969] install --- bash/rescue-hetzner.sh | 51 +----------------------------------------- bash/rescue-ovh.sh | 44 +----------------------------------- bash/rescue.sh | 42 ++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 93 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 5b123ab..0af9723 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -1,52 +1,3 @@ -rescue_hetzner_install() { - local package - local release='bookworm' - local packages=( - # installed - 'dmidecode' 'efibootmgr' 'pciutils' 'usbutils' - 'parted' 'mdadm' 'cryptsetup-bin' 'lvm2' - 'btrfs-progs' 'dosfstools' - 'git' 'nano' 'python3' 'rsync' 'vim' - 'file' 'htop' 'lsof' 'man-db' 'tree' 'uuid-runtime' - # install - 'lshw' - 'duperemove' 'squashfs-tools' - 'grub-efi-amd64-bin' 'grub-pc-bin' - 'libdigest-sha3-perl' 'micro' - 'iotop' - 'exa' 'ipcalc' 'lf' 'ncdu' 'nnn' 'ranger' - ) - local backports=( - ) - # update catalog - apt-get update - # - debian_disable_frontend - # upgrade packages - apt-get upgrade --assume-yes - # - apt_clean_cache - # install packages - for package in "${packages[@]}"; do - echo - echo "${package}" - apt-get install \ - --assume-yes \ - "${package}" - apt_clean_cache - done - # install backports - for package in "${backports[@]}"; do - echo - echo "${package}" - apt-get install \ - --assume-yes \ - --target-release "${release}-backports" \ - "${package}" - apt_clean_cache - done -} - rescue_hetzner_upload() { local host="${1}" local hostname="${2}" @@ -70,7 +21,7 @@ source \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\"" # create session ssh "${user_host}" -- byobu new-session -d # send keys - ssh "${user_host}" -- byobu send-keys "rescue_hetzner_install" "C-m" + ssh "${user_host}" -- byobu send-keys "rescue_install" "C-m" # attach session mosh "${user_host}" -- byobu attach-session else diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index b44c5fd..a62ae4e 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -1,45 +1,3 @@ -rescue_ovh_install() { - local package - local release="bookworm" - # update catalog - apt-get update - # disable frontend - debian_disable_frontend - # upgrade packages - apt-get upgrade --assume-yes - # clean cache - apt_clean_cache - # install packages - set \ - "man-db" \ - "dmidecode" "efibootmgr" "lshw" "pciutils" "usbutils" \ - "parted" "mdadm" "cryptsetup-bin" "lvm2" \ - "btrfs-progs" "dosfstools" "duperemove" "squashfs-tools" \ - "git" "micro" "nano" "python3" "rsync" "vim" \ - "exa" "lf" "ncdu" "nnn" "ranger" "tree" \ - "file" "htop" "iotop" "ipcalc" "libdigest-sha3-perl" "lsof" - for package in "${@}"; do - echo - echo "${package}" - apt-get install --assume-yes \ - "${package}" - apt_clean_cache - done - # install backports - set \ - "grub-pc-bin" \ - \ - "grub-efi-amd64-bin" - for package in "${@}"; do - echo - echo "${package}" - apt-get install --assume-yes \ - --target-release "${release}-backports" \ - "${package}" - apt_clean_cache - done -} - rescue_ovh_upload() { local host="${1}" local hostname="${2}" @@ -63,7 +21,7 @@ source \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\"" # create session ssh "${user_host}" -- byobu new-session -d # send keys - ssh "${user_host}" -- byobu send-keys "rescue_ovh_install" "C-m" + ssh "${user_host}" -- byobu send-keys "rescue_install" "C-m" # attach session mosh "${user_host}" -- byobu attach-session else diff --git a/bash/rescue.sh b/bash/rescue.sh index 8b1bc32..2a716bd 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -63,3 +63,45 @@ fr_FR.UTF-8 UTF-8 # update catalog apt-get update } + +rescue_install() { + local package + local release="bookworm" + # update catalog + apt-get update + # disable frontend + debian_disable_frontend + # upgrade packages + apt-get upgrade --assume-yes + # clean cache + apt_clean_cache + # install packages + set \ + "man-db" \ + "dmidecode" "efibootmgr" "lshw" "pciutils" "usbutils" \ + "parted" "mdadm" "cryptsetup-bin" "lvm2" \ + "btrfs-progs" "dosfstools" "duperemove" "squashfs-tools" \ + "git" "micro" "nano" "python3" "rsync" "vim" \ + "exa" "lf" "ncdu" "nnn" "ranger" "tree" \ + "file" "htop" "iotop" "ipcalc" "libdigest-sha3-perl" "lsof" + for package in "${@}"; do + echo + echo "${package}" + apt-get install --assume-yes \ + "${package}" + apt_clean_cache + done + # install backports + set \ + "grub-pc-bin" \ + \ + "grub-efi-amd64-bin" + for package in "${@}"; do + echo + echo "${package}" + apt-get install --assume-yes \ + --target-release "${release}-backports" \ + "${package}" + apt_clean_cache + done +} From ddde3e3c6b8462f0a74460d18116da589c489f02 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 17:56:25 +0100 Subject: [PATCH 451/969] upload --- bash/rescue-hetzner.sh | 32 -------------------------------- bash/rescue-ovh.sh | 32 -------------------------------- bash/rescue.sh | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 64 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 0af9723..0ef1d8a 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -1,35 +1,3 @@ -rescue_hetzner_upload() { - local host="${1}" - local hostname="${2}" - if [ "${hostname}" ]; then - local user="root" - # - local user_host="${user}@${host}" - # remove fingerprints - ssh-keygen -R "${host}" - # copy ssh id - ssh-copy-id \ - -o "StrictHostKeyChecking=accept-new" \ - "${user_host}" - # upload root - rsync --delete --recursive \ - "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" - # call setup - # TODO variable - ssh "${user_host}" -- "\ -source \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\"" - # create session - ssh "${user_host}" -- byobu new-session -d - # send keys - ssh "${user_host}" -- byobu send-keys "rescue_install" "C-m" - # attach session - mosh "${user_host}" -- byobu attach-session - else - echo "Host?" - return 1 - fi -} - rescue_hetzner_wipe_8_8_0_init() { local device local devices=( diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index a62ae4e..8312dab 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -1,35 +1,3 @@ -rescue_ovh_upload() { - local host="${1}" - local hostname="${2}" - if [ "${hostname}" ]; then - local user="root" - # - local user_host="${user}@${host}" - # remove fingerprints - ssh-keygen -R "${host}" - # copy ssh id - ssh-copy-id \ - -o "StrictHostKeyChecking=accept-new" \ - "${user_host}" - # upload root - rsync --delete --recursive \ - "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" - # call setup - # TODO variable - ssh "${user_host}" -- "\ -source \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\"" - # create session - ssh "${user_host}" -- byobu new-session -d - # send keys - ssh "${user_host}" -- byobu send-keys "rescue_install" "C-m" - # attach session - mosh "${user_host}" -- byobu attach-session - else - echo "Host?" - return 1 - fi -} - rescue_ovh_wipe_vle2_0_init() { local device="/dev/sdb" local passphrase diff --git a/bash/rescue.sh b/bash/rescue.sh index 2a716bd..c40abcc 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -105,3 +105,35 @@ rescue_install() { apt_clean_cache done } + +rescue_upload() { + local host="${1}" + local hostname="${2}" + if [ "${hostname}" ]; then + local user="root" + # + local user_host="${user}@${host}" + # remove fingerprints + ssh-keygen -R "${host}" + # copy ssh id + ssh-copy-id \ + -o "StrictHostKeyChecking=accept-new" \ + "${user_host}" + # upload root + rsync --delete --recursive \ + "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" + # call setup + # TODO variable + ssh "${user_host}" -- "\ +source \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\"" + # create session + ssh "${user_host}" -- byobu new-session -d + # send keys + ssh "${user_host}" -- byobu send-keys "rescue_install" "C-m" + # attach session + mosh "${user_host}" -- byobu attach-session + else + echo "Host?" + return 1 + fi +} From 6b81ee0a5a458d569cdad3325da12816dfcfef21 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 17:59:03 +0100 Subject: [PATCH 452/969] close --- bash/rescue-hetzner.sh | 7 ------- bash/rescue-ovh.sh | 6 ------ bash/rescue.sh | 6 ++++++ 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 0ef1d8a..4d1100c 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -198,10 +198,3 @@ rescue_hetzner_wipe_8_8_2_make() { --uuid '00000000-0000-0000-0000-000000000005' \ '/media/crypt/swap' } - -rescue_hetzner_wipe_8_8_3_close() { - umount '/media/boot' - # - umount '/media/crypt' && - cryptsetup luksClose 'crypt' -} diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index 8312dab..0b26d0d 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -125,9 +125,3 @@ rescue_ovh_wipe_vle2_2_make() { --uuid "00000000-0000-0000-0000-000000000005" \ "/media/crypt/swap" } - -rescue_ovh_wipe_vle2_3_close() { - umount "/media/boot" - umount "/media/crypt" && - cryptsetup luksClose "crypt" -} diff --git a/bash/rescue.sh b/bash/rescue.sh index c40abcc..a23f6d9 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -137,3 +137,9 @@ source \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\"" return 1 fi } + +rescue_wipe_3_close() { + umount "/media/boot" + umount "/media/crypt" && + cryptsetup luksClose "crypt" +} From c4fcfbdca29dc618db4ce209bd6e2966594d1864 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 18:02:21 +0100 Subject: [PATCH 453/969] zero --- bash/rescue-hetzner.sh | 6 ------ bash/rescue-ovh.sh | 5 ----- bash/rescue.sh | 5 +++++ 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 4d1100c..5a076fc 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -151,12 +151,6 @@ rescue_hetzner_wipe_8_8_0_init() { cryptsetup luksOpen '/dev/md/crypt' 'crypt' } -rescue_hetzner_wipe_8_8_1_zero() { - # wipe crypt - dd status='progress' \ - if='/dev/zero' of='/dev/mapper/crypt' bs='8G' -} - rescue_hetzner_wipe_8_8_2_make() { local passphrase # close diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index 0b26d0d..1b7af69 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -80,11 +80,6 @@ rescue_ovh_wipe_vle2_0_init() { cryptsetup luksOpen "${device}1" "crypt" } -rescue_ovh_wipe_vle2_1_zero() { - # crypt / zero - dd status="progress" if="/dev/zero" of="/dev/mapper/crypt" bs="1G" -} - rescue_ovh_wipe_vle2_2_make() { local passphrase # crypt / close diff --git a/bash/rescue.sh b/bash/rescue.sh index a23f6d9..beee576 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -138,6 +138,11 @@ source \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\"" fi } +rescue_wipe_1_zero() { + dd status="progress" \ + if="/dev/zero" of="/dev/mapper/crypt" bs="1G" +} + rescue_wipe_3_close() { umount "/media/boot" umount "/media/crypt" && From 9f550c4412c3012b1c3b4039a44cbaff2c3a6222 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 18:06:27 +0100 Subject: [PATCH 454/969] functions --- bash/rescue-hetzner.sh | 4 ++-- bash/rescue-ovh.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 5a076fc..bbbf94a 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -1,4 +1,4 @@ -rescue_hetzner_wipe_8_8_0_init() { +rescue_wipe_0_init_hetzner_8_8() { local device local devices=( '/dev/sda' @@ -151,7 +151,7 @@ rescue_hetzner_wipe_8_8_0_init() { cryptsetup luksOpen '/dev/md/crypt' 'crypt' } -rescue_hetzner_wipe_8_8_2_make() { +rescue_wipe_2_make_hetzner_8_8() { local passphrase # close cryptsetup luksClose 'crypt' diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index 1b7af69..1ef38a2 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -1,4 +1,4 @@ -rescue_ovh_wipe_vle2_0_init() { +rescue_wipe_0_init_ovh_vle2() { local device="/dev/sdb" local passphrase local unit="mib" @@ -80,7 +80,7 @@ rescue_ovh_wipe_vle2_0_init() { cryptsetup luksOpen "${device}1" "crypt" } -rescue_ovh_wipe_vle2_2_make() { +rescue_wipe_2_make_ovh_vle2() { local passphrase # crypt / close cryptsetup luksClose "crypt" From 9b9e5032250a80c9283a9eda3673fb4aa2e2d1e0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 20:30:11 +0100 Subject: [PATCH 455/969] .shellcheckrc --- bash/.shellcheckrc | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 bash/.shellcheckrc diff --git a/bash/.shellcheckrc b/bash/.shellcheckrc new file mode 100644 index 0000000..26775fc --- /dev/null +++ b/bash/.shellcheckrc @@ -0,0 +1,3 @@ +#disable=2312,3043 +enable=all +shell=sh From a6180ecd657bbc2ceeaff1144545dbe2951ef983 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 20:33:23 +0100 Subject: [PATCH 456/969] log --- bash/log.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bash/log.sh b/bash/log.sh index f7d325e..5bb7906 100644 --- a/bash/log.sh +++ b/bash/log.sh @@ -7,14 +7,14 @@ LOG_LEVEL_TRACE=5 LOG_LEVEL=${LOG_LEVEL_WARN} -function log_fatal { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_FATAL} ] && echo "${@}" ; } +log_fatal() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_FATAL}" ] && echo "${@}" ; } -function log_error { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_ERROR} ] && echo "${@}" ; } +log_error() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_ERROR}" ] && echo "${@}" ; } -function log_warn { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_WARN} ] && echo "${@}" ; } +log_warn() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_WARN}" ] && echo "${@}" ; } -function log_info { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_INFO} ] && echo "${@}" ; } +log_info() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_INFO}" ] && echo "${@}" ; } -function log_debug { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_DEBUG} ] && echo "${@}" ; } +log_debug() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_DEBUG}" ] && echo "${@}" ; } -function log_trace { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_TRACE} ] && echo "${@}" ; } +log_trace() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_TRACE}" ] && echo "${@}" ; } From e139ac77580ff1217515c39760471b2ad84bc452 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 20:37:25 +0100 Subject: [PATCH 457/969] apt_clean --- bash/apt.sh | 4 ++-- bash/rescue.sh | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bash/apt.sh b/bash/apt.sh index e83ccc1..36bd5d6 100644 --- a/bash/apt.sh +++ b/bash/apt.sh @@ -1,3 +1,3 @@ -function apt_clean_cache { - apt-get clean +apt_clean() { + apt-get clean } diff --git a/bash/rescue.sh b/bash/rescue.sh index beee576..05ecac8 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -49,7 +49,7 @@ fr_FR.UTF-8 UTF-8 apt-get install --assume-yes \ --target-release "${release}-backports" \ "${package}" - apt_clean_cache + apt_clean done # install packages set "apt-file" "mosh" "screen" "byobu" @@ -58,7 +58,7 @@ fr_FR.UTF-8 UTF-8 echo "${package}" apt-get install --assume-yes \ "${package}" - apt_clean_cache + apt_clean done # update catalog apt-get update @@ -74,7 +74,7 @@ rescue_install() { # upgrade packages apt-get upgrade --assume-yes # clean cache - apt_clean_cache + apt_clean # install packages set \ "man-db" \ @@ -89,7 +89,7 @@ rescue_install() { echo "${package}" apt-get install --assume-yes \ "${package}" - apt_clean_cache + apt_clean done # install backports set \ @@ -102,7 +102,7 @@ rescue_install() { apt-get install --assume-yes \ --target-release "${release}-backports" \ "${package}" - apt_clean_cache + apt_clean done } From cc7e1cafb449177a5343a46dba1bc61366557f4d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 20:40:56 +0100 Subject: [PATCH 458/969] apt_upgrade --- bash/apt.sh | 9 ++++++++- bash/rescue.sh | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bash/apt.sh b/bash/apt.sh index 36bd5d6..ce43f1a 100644 --- a/bash/apt.sh +++ b/bash/apt.sh @@ -1,3 +1,10 @@ apt_clean() { - apt-get clean + apt-get \ + clean +} + +apt_upgrade() { + apt-get \ + upgrade \ + --assume-yes } diff --git a/bash/rescue.sh b/bash/rescue.sh index 05ecac8..34f1881 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -72,7 +72,7 @@ rescue_install() { # disable frontend debian_disable_frontend # upgrade packages - apt-get upgrade --assume-yes + apt_upgrade # clean cache apt_clean # install packages From 7c8f2d8f4963d1c2e09b03a298593f0b565fc06a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 20:42:37 +0100 Subject: [PATCH 459/969] apt_update --- bash/apt.sh | 5 +++++ bash/rescue.sh | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bash/apt.sh b/bash/apt.sh index ce43f1a..5b821e2 100644 --- a/bash/apt.sh +++ b/bash/apt.sh @@ -3,6 +3,11 @@ apt_clean() { clean } +apt_update() { + apt-get \ + update +} + apt_upgrade() { apt-get \ upgrade \ diff --git a/bash/rescue.sh b/bash/rescue.sh index 34f1881..1d64d59 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -38,7 +38,7 @@ fr_FR.UTF-8 UTF-8 # generate locales locale-gen # update catalog - apt-get update + apt_update # disable frontend debian_disable_frontend # install backports @@ -61,14 +61,14 @@ fr_FR.UTF-8 UTF-8 apt_clean done # update catalog - apt-get update + apt_update } rescue_install() { local package local release="bookworm" # update catalog - apt-get update + apt_update # disable frontend debian_disable_frontend # upgrade packages From c2d83e717f8c3fbb9862f4d8e2aa70a6e23e88a0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 21:08:52 +0100 Subject: [PATCH 460/969] error --- bash/rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/rescue.sh b/bash/rescue.sh index 1d64d59..b466b92 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -133,7 +133,7 @@ source \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\"" # attach session mosh "${user_host}" -- byobu attach-session else - echo "Host?" + echo "host & hostname" return 1 fi } From dbf1295148b97b19f982bf657234a8764498822e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 22:16:37 +0100 Subject: [PATCH 461/969] fixes --- bash/rescue-ovh.sh | 3 ++- bash/rescue.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index 1ef38a2..5dee19b 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -16,7 +16,7 @@ rescue_wipe_0_init_ovh_vle2() { # parted "${device}" \ unit "${unit}" \ - mkpart "crypt" 4610 40960 + mkpart "crypt" 4610 40959 # parted "${device}" \ unit "${unit}" \ @@ -81,6 +81,7 @@ rescue_wipe_0_init_ovh_vle2() { } rescue_wipe_2_make_ovh_vle2() { + local device="/dev/sdb" local passphrase # crypt / close cryptsetup luksClose "crypt" diff --git a/bash/rescue.sh b/bash/rescue.sh index b466b92..732d1ea 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -140,7 +140,7 @@ source \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\"" rescue_wipe_1_zero() { dd status="progress" \ - if="/dev/zero" of="/dev/mapper/crypt" bs="1G" + if="/dev/zero" of="/dev/mapper/crypt" bs="512M" } rescue_wipe_3_close() { From 918090d9be0d794e5d468c5db954fa3eaddab774 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 11 Nov 2024 22:21:17 +0100 Subject: [PATCH 462/969] mapper --- bash/rescue-ovh.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index 5dee19b..314d452 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -110,11 +110,11 @@ rescue_wipe_2_make_ovh_vle2() { --checksum "sha256" \ --label "crypt" \ --uuid "00000000-0000-0000-0000-00000000000c" \ - "${device}1" + "/dev/mapper/crypt" # crypt / mount mkdir --parents "/media/crypt" mount --options "autodefrag,compress-force=zstd" \ - "${device}1" "/media/crypt" + "/dev/mapper/crypt" "/media/crypt" # crypt / swap btrfs filesystem mkswapfile \ --size "4g" \ From 084c92e50a63bcfafeea6140ae1305048031245c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 06:03:36 +0100 Subject: [PATCH 463/969] install --- bash/apt.sh | 25 ++++++++++++++++++++++++ bash/debian.sh | 9 +++++++-- bash/rescue.sh | 52 ++++++++------------------------------------------ 3 files changed, 40 insertions(+), 46 deletions(-) diff --git a/bash/apt.sh b/bash/apt.sh index 5b821e2..a0f7353 100644 --- a/bash/apt.sh +++ b/bash/apt.sh @@ -3,6 +3,30 @@ apt_clean() { clean } +apt_install_backports() { + apt_install_target "${DEBIAN_CODENAME}-backports" "${@}" +} + +apt_install_release() { + apt_install_target "${DEBIAN_CODENAME}" "${@}" +} + +apt_install_target() { + local target="${1}" + shift + local package + for package in "${@}"; do + log_info + log_info "${package} ← ${target}" + apt-get \ + install \ + --assume-yes \ + --target-release "${target}" \ + "${package}" + apt_clean + done +} + apt_update() { apt-get \ update @@ -12,4 +36,5 @@ apt_upgrade() { apt-get \ upgrade \ --assume-yes + apt_clean } diff --git a/bash/debian.sh b/bash/debian.sh index acf628d..e3aa7ba 100644 --- a/bash/debian.sh +++ b/bash/debian.sh @@ -1,3 +1,8 @@ -function debian_disable_frontend { - export DEBIAN_FRONTEND='noninteractive' +DEBIAN_CODENAME="$( + grep "VERSION_CODENAME" "/etc/os-release" | + cut --delimiter "=" --fields "2" +)" + +debian_disable_frontend() { + export DEBIAN_FRONTEND='noninteractive' } diff --git a/bash/rescue.sh b/bash/rescue.sh index 732d1ea..3a4bb7d 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -1,7 +1,5 @@ rescue_configure() { local hostname="${1}" - local release="bookworm" - local package # apt / conf printf "\ Acquire::AllowInsecureRepositories False; @@ -17,13 +15,13 @@ Dpkg::Progress True; # apt / sources printf "%s" "\ deb https://deb.debian.org/debian \ -${release} main non-free-firmware contrib non-free +${DEBIAN_CODENAME} main non-free-firmware contrib non-free deb https://deb.debian.org/debian \ -${release}-backports main non-free-firmware contrib non-free +${DEBIAN_CODENAME}-backports main non-free-firmware contrib non-free deb https://deb.debian.org/debian \ -${release}-updates main non-free-firmware contrib non-free +${DEBIAN_CODENAME}-updates main non-free-firmware contrib non-free deb https://deb.debian.org/debian-security \ -${release}-security main non-free-firmware contrib non-free +${DEBIAN_CODENAME}-security main non-free-firmware contrib non-free " >"/etc/apt/sources.list" # bash / rc main_link_bashrc @@ -42,41 +40,22 @@ fr_FR.UTF-8 UTF-8 # disable frontend debian_disable_frontend # install backports - set "tmux" - for package in "${@}"; do - echo - echo "${package}" - apt-get install --assume-yes \ - --target-release "${release}-backports" \ - "${package}" - apt_clean - done + apt_install_backports "tmux" # install packages - set "apt-file" "mosh" "screen" "byobu" - for package in "${@}"; do - echo - echo "${package}" - apt-get install --assume-yes \ - "${package}" - apt_clean - done + apt_install_release "apt-file" "mosh" "screen" "byobu" # update catalog apt_update } rescue_install() { - local package - local release="bookworm" # update catalog apt_update # disable frontend debian_disable_frontend # upgrade packages apt_upgrade - # clean cache - apt_clean # install packages - set \ + apt_install_release \ "man-db" \ "dmidecode" "efibootmgr" "lshw" "pciutils" "usbutils" \ "parted" "mdadm" "cryptsetup-bin" "lvm2" \ @@ -84,26 +63,11 @@ rescue_install() { "git" "micro" "nano" "python3" "rsync" "vim" \ "exa" "lf" "ncdu" "nnn" "ranger" "tree" \ "file" "htop" "iotop" "ipcalc" "libdigest-sha3-perl" "lsof" - for package in "${@}"; do - echo - echo "${package}" - apt-get install --assume-yes \ - "${package}" - apt_clean - done # install backports - set \ + apt_install_backports \ "grub-pc-bin" \ \ "grub-efi-amd64-bin" - for package in "${@}"; do - echo - echo "${package}" - apt-get install --assume-yes \ - --target-release "${release}-backports" \ - "${package}" - apt_clean - done } rescue_upload() { From 68d5c0b51a9053f88475d2b50a963041843e8330 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 06:26:24 +0100 Subject: [PATCH 464/969] local --- bash/.shellcheckrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/.shellcheckrc b/bash/.shellcheckrc index 26775fc..4a9be0e 100644 --- a/bash/.shellcheckrc +++ b/bash/.shellcheckrc @@ -1,3 +1,3 @@ -#disable=2312,3043 +disable=3043 enable=all shell=sh From 763d199cdef29cc40b9ba30b5a032209dcb9f41e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 06:26:59 +0100 Subject: [PATCH 465/969] gpg_ssh --- bash/gpg.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/bash/gpg.sh b/bash/gpg.sh index 358b4ca..f9d6ef6 100644 --- a/bash/gpg.sh +++ b/bash/gpg.sh @@ -1,5 +1,12 @@ -if [ ${EUID} -ne 0 ] ; then - if [ -f "${HOME}/.gnupg/gpg-agent.conf" ] ; then - export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" - fi -fi +gpg_ssh() { + local user_id + user_id=$(id --user) + if [ "${user_id}" -ne 0 ]; then + if [ -f "${HOME}/.gnupg/gpg-agent.conf" ]; then + SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" + export SSH_AUTH_SOCK + fi + fi +} + +gpg_ssh From abb6ed3a26c14be29eb88d65d4a20ab6b5bfb140 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 06:30:26 +0100 Subject: [PATCH 466/969] bsl --- bash/btrfs.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bash/btrfs.sh b/bash/btrfs.sh index 2513eda..1172d2d 100644 --- a/bash/btrfs.sh +++ b/bash/btrfs.sh @@ -1,7 +1,7 @@ -function bsl { - if [ "${1}" ] ; then - btrfs subvolume list "${1}" \ - | cut -d ' ' -f 9 \ - | sort - fi +bsl() { + if [ -n "${1}" ]; then + btrfs subvolume list "${1}" | + cut --delimiter " " --fields 9 | + sort + fi } From b37e4abc4ec13c54e095e8fda0ae8ab24bbeb68d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 06:42:16 +0100 Subject: [PATCH 467/969] not --- bash/util.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 bash/util.sh diff --git a/bash/util.sh b/bash/util.sh new file mode 100644 index 0000000..e3781a7 --- /dev/null +++ b/bash/util.sh @@ -0,0 +1,7 @@ +not() { + case "${1}" in + "false") echo "true" ;; + "true") echo "false" ;; + *) ;; + esac +} From 304d163d74daaceb2305a929a894460bf3666c25 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 06:43:20 +0100 Subject: [PATCH 468/969] ws --- bash/gsettings.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bash/gsettings.sh b/bash/gsettings.sh index 1fd3b72..e7e6a9d 100644 --- a/bash/gsettings.sh +++ b/bash/gsettings.sh @@ -1,12 +1,12 @@ -function ws { -local boolean="${1}" - if [ "${boolean}" == '1' ] ; then - boolean='true' - else - boolean='false' - fi - gsettings 'set' \ - 'org.gnome.mutter' \ - 'workspaces-only-on-primary' \ - "${boolean}" +ws() { + local boolean="${1}" + if [ "${boolean}" = "1" ]; then + boolean="true" + else + boolean="false" + fi + gsettings set \ + "org.gnome.mutter" \ + "workspaces-only-on-primary" \ + "${boolean}" } From 3d784b81c471b366f9f8d1d69032f537d80230b9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 06:52:21 +0100 Subject: [PATCH 469/969] ws --- bash/gsettings.sh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/bash/gsettings.sh b/bash/gsettings.sh index e7e6a9d..1b4a08b 100644 --- a/bash/gsettings.sh +++ b/bash/gsettings.sh @@ -1,12 +1,9 @@ ws() { - local boolean="${1}" - if [ "${boolean}" = "1" ]; then - boolean="true" - else - boolean="false" - fi - gsettings set \ - "org.gnome.mutter" \ - "workspaces-only-on-primary" \ - "${boolean}" + local bool + local group="org.gnome.mutter" + local var="workspaces-only-on-primary" + bool="$(gsettings get "${group}" "${var}")" + bool="$(not "${bool}")" + gsettings set "${group}" "${var}" "${bool}" + log_info "${group}/${var}: ${bool}" } From 95828fe06ccec736bd2dd299e732db1ad9ee4e84 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 07:20:25 +0100 Subject: [PATCH 470/969] log --- bash/log.sh | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/bash/log.sh b/bash/log.sh index 5bb7906..069377e 100644 --- a/bash/log.sh +++ b/bash/log.sh @@ -5,16 +5,40 @@ LOG_LEVEL_INFO=3 LOG_LEVEL_DEBUG=4 LOG_LEVEL_TRACE=5 -LOG_LEVEL=${LOG_LEVEL_WARN} +LOG_LEVEL=${LOG_LEVEL_INFO} -log_fatal() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_FATAL}" ] && echo "${@}" ; } +log_debug() { + if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_DEBUG}" ]; then + echo "${@}" + fi +} -log_error() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_ERROR}" ] && echo "${@}" ; } +log_error() { + if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_ERROR}" ]; then + echo "${@}" + fi +} -log_warn() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_WARN}" ] && echo "${@}" ; } +log_fatal() { + if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_FATAL}" ]; then + echo "${@}" + fi +} -log_info() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_INFO}" ] && echo "${@}" ; } +log_info() { + if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_INFO}" ]; then + echo "${@}" + fi +} -log_debug() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_DEBUG}" ] && echo "${@}" ; } +log_trace() { + if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_TRACE}" ]; then + echo "${@}" + fi +} -log_trace() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_TRACE}" ] && echo "${@}" ; } +log_warn() { + if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_WARN}" ]; then + echo "${@}" + fi +} From 9da2ddeb6f127ec8c41776305484fabb61a5e170 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 07:28:41 +0100 Subject: [PATCH 471/969] ws --- bash/gsettings.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bash/gsettings.sh b/bash/gsettings.sh index 1b4a08b..d47db25 100644 --- a/bash/gsettings.sh +++ b/bash/gsettings.sh @@ -1,9 +1,15 @@ ws() { local bool local group="org.gnome.mutter" - local var="workspaces-only-on-primary" - bool="$(gsettings get "${group}" "${var}")" + local name="workspaces-only-on-primary" + local var="${group}/${name}" + # get + bool="$(gsettings get "${group}" "${name}")" + log_debug "${var}: ${bool}" + # not bool="$(not "${bool}")" - gsettings set "${group}" "${var}" "${bool}" - log_info "${group}/${var}: ${bool}" + log_debug "${var}: ${bool}" + # set + gsettings set "${group}" "${name}" "${bool}" + log_info "${var}: ${bool}" } From f163abbd37ffbbd0daf7059c186cefb7f1275703 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 07:29:36 +0100 Subject: [PATCH 472/969] bool --- bash/gsettings.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/gsettings.sh b/bash/gsettings.sh index d47db25..8916766 100644 --- a/bash/gsettings.sh +++ b/bash/gsettings.sh @@ -8,7 +8,7 @@ ws() { log_debug "${var}: ${bool}" # not bool="$(not "${bool}")" - log_debug "${var}: ${bool}" + log_debug "bool: ${bool}" # set gsettings set "${group}" "${name}" "${bool}" log_info "${var}: ${bool}" From 976cb6e919eb925076c252e9525c8745a357976b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 07:44:21 +0100 Subject: [PATCH 473/969] fixes --- bash/main.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index 59788aa..dacbbfc 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -4,14 +4,14 @@ MAIN_BASH_FILE="$(realpath "${BASH_SOURCE[0]}")" MAIN_BASH_ROOT="$(dirname "${MAIN_BASH_FILE}")" -function main_link_bashrc { +main_link_bashrc() { local file='/etc/bash.bashrc' rm --force "${file}" ln --symbolic "${MAIN_BASH_FILE}" "${file}" } # import modules -function main_import_modules { +main_import_modules() { local file="${1}" if [ -f "${file}" ] ; then local path="$(realpath "${file}")" @@ -21,7 +21,7 @@ if [ -f "${file}" ] ; then local module for module in "${modules[@]}" ; do if [ "${module}" != "${path}" ] ; then - source "${module}" + . "${module}" fi done log_trace "${modules[@]}" From 195b185f6e879b6366055905b732742ffa3c853a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 07:58:17 +0100 Subject: [PATCH 474/969] completion --- bash/bash/completion.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bash/bash/completion.sh b/bash/bash/completion.sh index 748a2b9..21e8a21 100644 --- a/bash/bash/completion.sh +++ b/bash/bash/completion.sh @@ -1,5 +1,5 @@ -file='/usr/share/bash-completion/bash_completion' +file="/usr/share/bash-completion/bash_completion" -if [ -f "${file}" ] ; then - source "${file}" +if [ -f "${file}" ]; then + . "${file}" fi From 671beb4b0e124e4d4ef46eaf4e2a47de2180e9c5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 07:59:50 +0100 Subject: [PATCH 475/969] history --- bash/bash/history.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/bash/history.sh b/bash/bash/history.sh index 4a47ba3..59234ad 100644 --- a/bash/bash/history.sh +++ b/bash/bash/history.sh @@ -1,5 +1,5 @@ -HISTCONTROL='ignorespace' +HISTCONTROL="ignorespace" HISTSIZE=-1 -HISTTIMEFORMAT='%Y%m%d %H%M%S ' +HISTTIMEFORMAT="%Y%m%d %H%M%S " From fe5c75b1424ce29c4a1733bd822c4165222792d9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 09:28:08 +0100 Subject: [PATCH 476/969] passphrase --- bash/rescue-hetzner.sh | 10 ++++++---- bash/rescue-ovh.sh | 10 ++++++---- bash/util.sh | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index bbbf94a..f2e6d34 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -9,8 +9,7 @@ rescue_wipe_0_init_hetzner_8_8() { local passphrase local unit='mib' # read passphrase - echo -n 'PassPhrase: ' - read -r -s passphrase + passphrase="$(read_passphrase)" # lsblk echo -n 'WIPE' "${devices[@]}" '/?\ OR CANCEL /!\' @@ -149,6 +148,8 @@ rescue_wipe_0_init_hetzner_8_8() { # open echo "${passphrase}" | cryptsetup luksOpen '/dev/md/crypt' 'crypt' + # passphrase + unset passphrase } rescue_wipe_2_make_hetzner_8_8() { @@ -156,8 +157,7 @@ rescue_wipe_2_make_hetzner_8_8() { # close cryptsetup luksClose 'crypt' # read passphrase - echo -n 'PassPhrase: ' - read -r -s passphrase + passphrase="$(read_passphrase)" # encrypt echo "${passphrase}" | cryptsetup \ @@ -175,6 +175,8 @@ rescue_wipe_2_make_hetzner_8_8() { # open echo "${passphrase}" | cryptsetup luksOpen '/dev/md/crypt' 'crypt' + # passphrase + unset passphrase # format crypt mkfs.btrfs --force \ --checksum 'sha256' \ diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index 314d452..ea71bcf 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -3,8 +3,7 @@ rescue_wipe_0_init_ovh_vle2() { local passphrase local unit="mib" # read passphrase - printf "PassPhrase: " - read -r -s passphrase + passphrase="$(read_passphrase)" # warn lsblk printf "%s" "WIPE ${device} /?\\ OR CANCEL /!\\" @@ -78,6 +77,8 @@ rescue_wipe_0_init_ovh_vle2() { # crypt / open echo "${passphrase}" | cryptsetup luksOpen "${device}1" "crypt" + # passphrase + unset passphrase } rescue_wipe_2_make_ovh_vle2() { @@ -86,8 +87,7 @@ rescue_wipe_2_make_ovh_vle2() { # crypt / close cryptsetup luksClose "crypt" # read passphrase - printf "PassPhrase: " - read -r -s passphrase + passphrase="$(read_passphrase)" # crypt / encrypt echo "${passphrase}" | cryptsetup \ @@ -105,6 +105,8 @@ rescue_wipe_2_make_ovh_vle2() { # crypt / open echo "${passphrase}" | cryptsetup luksOpen "${device}1" "crypt" + # passphrase + unset passphrase # crypt / format mkfs.btrfs --force \ --checksum "sha256" \ diff --git a/bash/util.sh b/bash/util.sh index e3781a7..2711b03 100644 --- a/bash/util.sh +++ b/bash/util.sh @@ -5,3 +5,17 @@ not() { *) ;; esac } + +read_passphrase() { + read_secret "PassPhrase: " +} + +read_secret() { + local prompt="${1}" + local secret + printf "${prompt}" 1>&2 + read -r -s secret + echo >&2 + echo "${secret}" + unset secret +} From 305968a9e678cfe17aef0c968bb700f413a354f3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 09:31:24 +0100 Subject: [PATCH 477/969] noninteractive --- bash/debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/debian.sh b/bash/debian.sh index e3aa7ba..ffce0da 100644 --- a/bash/debian.sh +++ b/bash/debian.sh @@ -4,5 +4,5 @@ DEBIAN_CODENAME="$( )" debian_disable_frontend() { - export DEBIAN_FRONTEND='noninteractive' + export DEBIAN_FRONTEND="noninteractive" } From 4e81f18817c18d70dd3b456cb46c8683532f48d9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 09:35:29 +0100 Subject: [PATCH 478/969] quotes --- bash/rescue-hetzner.sh | 92 +++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index f2e6d34..6991368 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -1,18 +1,18 @@ rescue_wipe_0_init_hetzner_8_8() { local device local devices=( - '/dev/sda' - '/dev/sdb' + "/dev/sda" + "/dev/sdb" ) local members local number local passphrase - local unit='mib' + local unit="mib" # read passphrase passphrase="$(read_passphrase)" # lsblk - echo -n 'WIPE' "${devices[@]}" '/?\ OR CANCEL /!\' + echo -n "WIPE" "${devices[@]}" "/?\\ OR CANCEL /!\\" read # number=0 @@ -53,7 +53,7 @@ rescue_wipe_0_init_hetzner_8_8() { echo "#${number}: ${device}4" # wipe bios dd \ - if='/dev/zero' of="${device}4" + if="/dev/zero" of="${device}4" done # number=0 @@ -63,7 +63,7 @@ rescue_wipe_0_init_hetzner_8_8() { echo "#${number}: ${device}3" # format esp dd \ - if='/dev/zero' of="${device}3" bs='1M' + if="/dev/zero" of="${device}3" bs="1M" mkfs.vfat \ -F 32 \ -S 4096 \ @@ -81,8 +81,8 @@ rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}2" # wipe boot - dd status='progress' \ - if='/dev/zero' of="${device}2" bs='1G' count=1 + dd status="progress" \ + if="/dev/zero" of="${device}2" bs="1G" count=1 done # members=() @@ -90,24 +90,24 @@ rescue_wipe_0_init_hetzner_8_8() { members+=("${device}2") done mdadm \ - --create '/dev/md/boot' \ + --create "/dev/md/boot" \ --level 0 \ --metadata 1 \ - --name 'md:boot' \ + --name "md:boot" \ --raid-devices ${#devices[@]} \ - --uuid '00000000:00000000:00000000:00000002' \ + --uuid "00000000:00000000:00000000:00000002" \ "${members[@]}" # mkfs.btrfs --force \ - --checksum 'sha256' \ - --label 'boot' \ - --uuid '00000000-0000-0000-0000-00000000000b' \ - '/dev/md/boot' + --checksum "sha256" \ + --label "boot" \ + --uuid "00000000-0000-0000-0000-00000000000b" \ + "/dev/md/boot" # mount boot - mkdir --parents '/media/boot' + mkdir --parents "/media/boot" mount \ - --options 'autodefrag,compress-force=zstd' \ - '/dev/md/boot' '/media/boot' + --options "autodefrag,compress-force=zstd" \ + "/dev/md/boot" "/media/boot" # number=0 for device in "${devices[@]}"; do @@ -115,8 +115,8 @@ rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}1" # wipe crypt head - dd status='progress' \ - if='/dev/zero' of="${device}1" bs='1G' count=1 + dd status="progress" \ + if="/dev/zero" of="${device}1" bs="1G" count=1 done # members=() @@ -124,30 +124,30 @@ rescue_wipe_0_init_hetzner_8_8() { members+=("${device}1") done mdadm \ - --create '/dev/md/crypt' \ + --create "/dev/md/crypt" \ --level 0 \ --metadata 1 \ - --name 'md:crypt' \ + --name "md:crypt" \ --raid-devices ${#devices[@]} \ - --uuid '00000000:00000000:00000000:00000001' \ + --uuid "00000000:00000000:00000000:00000001" \ "${members[@]}" # encrypt echo "${passphrase}" | cryptsetup \ --verbose \ --batch-mode \ - --type 'luks2' \ - --pbkdf 'argon2id' \ - --cipher 'aes-xts-plain64' \ + --type "luks2" \ + --pbkdf "argon2id" \ + --cipher "aes-xts-plain64" \ --iter-time 8192 \ --key-size 512 \ - --hash 'sha512' \ + --hash "sha512" \ --use-random \ luksFormat \ - '/dev/md/crypt' + "/dev/md/crypt" # open echo "${passphrase}" | - cryptsetup luksOpen '/dev/md/crypt' 'crypt' + cryptsetup luksOpen "/dev/md/crypt" "crypt" # passphrase unset passphrase } @@ -155,7 +155,7 @@ rescue_wipe_0_init_hetzner_8_8() { rescue_wipe_2_make_hetzner_8_8() { local passphrase # close - cryptsetup luksClose 'crypt' + cryptsetup luksClose "crypt" # read passphrase passphrase="$(read_passphrase)" # encrypt @@ -163,34 +163,34 @@ rescue_wipe_2_make_hetzner_8_8() { cryptsetup \ --verbose \ --batch-mode \ - --type 'luks2' \ - --pbkdf 'argon2id' \ - --cipher 'aes-xts-plain64' \ + --type "luks2" \ + --pbkdf "argon2id" \ + --cipher "aes-xts-plain64" \ --iter-time 8192 \ --key-size 512 \ - --hash 'sha512' \ + --hash "sha512" \ --use-random \ luksFormat \ - '/dev/md/crypt' + "/dev/md/crypt" # open echo "${passphrase}" | - cryptsetup luksOpen '/dev/md/crypt' 'crypt' + cryptsetup luksOpen "/dev/md/crypt" "crypt" # passphrase unset passphrase # format crypt mkfs.btrfs --force \ - --checksum 'sha256' \ - --label 'crypt' \ - --uuid '00000000-0000-0000-0000-00000000000c' \ - '/dev/mapper/crypt' + --checksum "sha256" \ + --label "crypt" \ + --uuid "00000000-0000-0000-0000-00000000000c" \ + "/dev/mapper/crypt" # mount crypt - mkdir --parents '/media/crypt' + mkdir --parents "/media/crypt" mount \ - --options 'autodefrag,compress-force=zstd' \ - '/dev/mapper/crypt' '/media/crypt' + --options "autodefrag,compress-force=zstd" \ + "/dev/mapper/crypt" "/media/crypt" # make swap file btrfs filesystem mkswapfile \ - --size '64g' \ - --uuid '00000000-0000-0000-0000-000000000005' \ - '/media/crypt/swap' + --size "64g" \ + --uuid "00000000-0000-0000-0000-000000000005" \ + "/media/crypt/swap" } From 6840588cd5143cf482c763f13a1c05ac5d87b27e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 09:43:56 +0100 Subject: [PATCH 479/969] fixes --- bash/alias/bash.sh | 2 +- bash/alias/ls.sh | 2 +- bash/alias/pass.sh | 2 +- bash/mount-lxc.sh | 16 ++++++++-------- bash/mount.sh | 14 +++++++------- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/bash/alias/bash.sh b/bash/alias/bash.sh index f363670..aaa10ca 100644 --- a/bash/alias/bash.sh +++ b/bash/alias/bash.sh @@ -4,7 +4,7 @@ cd \ .. \ " -# change current directory to its parent's parent +# change current directory to its parent’s parent alias ...="\ cd \ ../.. \ diff --git a/bash/alias/ls.sh b/bash/alias/ls.sh index 952bc85..b6d3204 100644 --- a/bash/alias/ls.sh +++ b/bash/alias/ls.sh @@ -2,7 +2,7 @@ export LS_COLORS="\ di=0;94\ " -# list current directory's entries +# list current directory’s entries alias l="\ ls \ --all \ diff --git a/bash/alias/pass.sh b/bash/alias/pass.sh index f01c653..1f48255 100644 --- a/bash/alias/pass.sh +++ b/bash/alias/pass.sh @@ -1,4 +1,4 @@ -# display pass entry's content +# display pass entry’s content alias p="\ pass \ " diff --git a/bash/mount-lxc.sh b/bash/mount-lxc.sh index a0b3ace..2cc5a7e 100644 --- a/bash/mount-lxc.sh +++ b/bash/mount-lxc.sh @@ -1,31 +1,31 @@ -function mrc { +mrc() { local container="${1}" local f - for f in 'dev' 'dev/pts' 'proc' 'sys' ; do + for f in "dev" "dev/pts" "proc" "sys" ; do mount --bind "/${f}" "overlay/mount/var/lib/lxc/${container}/squashfs-root/${f}" done } -function crc { +crc() { local container="${1}" shift chroot "overlay/mount/var/lib/lxc/${container}/squashfs-root" "${@}" } -function urc { +urc() { local container="${1}" - for f in 'sys' 'proc' 'dev/pts' 'dev' ; do + for f in "sys" "proc" "dev/pts" "dev" ; do umount --lazy "overlay/mount/var/lib/lxc/${container}/squashfs-root/${f}" done } -function mmc { +mmc() { local container="${1}" - mount --bind '/deb' "overlay/mount/var/lib/lxc/${container}/squashfs-root/deb" + mount --bind "/deb" "overlay/mount/var/lib/lxc/${container}/squashfs-root/deb" } -function umc { +umc() { local container="${1}" umount "overlay/mount/var/lib/lxc/${container}/squashfs-root/deb" } diff --git a/bash/mount.sh b/bash/mount.sh index c3ee8a3..5fe26a7 100644 --- a/bash/mount.sh +++ b/bash/mount.sh @@ -1,4 +1,4 @@ -function mo { +mo() { local directory="${1}" local file if [ "${directory}" ] ; then @@ -18,7 +18,7 @@ else fi } -function uo { +uo() { cd 'overlay' if umount 'mount' ; then rmdir 'mount' @@ -32,7 +32,7 @@ rmdir 'overlay' } -function mr { +mr() { for f in 'dev' 'dev/pts' 'proc' 'sys' ; do mount --bind "/${f}" "overlay/mount/${f}" done @@ -49,23 +49,23 @@ chroot \ \"overlay/mount\" \ " -function ur { +ur() { for f in 'sys' 'proc' 'dev/pts' 'dev' ; do umount --lazy "overlay/mount/${f}" done } -function mm { +mm() { mount --make-rslave --rbind '/deb' 'overlay/mount/deb' } -function um { +um() { umount --recursive 'overlay/mount/deb' } -function ms { +ms() { local directory="${1}" local level="${2}" if [ "${directory}" ] ; then From 3b979057c1bb5dc8d54a71709651c86e27af1bfa Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 09:46:29 +0100 Subject: [PATCH 480/969] mount --- bash/mount.sh | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/bash/mount.sh b/bash/mount.sh index 5fe26a7..9fda047 100644 --- a/bash/mount.sh +++ b/bash/mount.sh @@ -4,36 +4,36 @@ local file if [ "${directory}" ] ; then directory="$(realpath "${directory}")" file="${directory}/filesystem.squashfs" - if mkdir 'overlay' ; then - cd 'overlay' + if mkdir "overlay" ; then + cd "overlay" mkdir {lower,upper,work,mount} - if mount "${file}" 'lower' ; then - mount -t 'overlay' 'overlay' 'mount' \ --o lowerdir='lower',upperdir='upper',workdir='work' + if mount "${file}" "lower" ; then + mount -t "overlay" "overlay" "mount" \ +-o lowerdir="lower",upperdir="upper",workdir="work" fi cd .. fi else - echo 'KO: directory?' + echo "KO: directory?" fi } uo() { -cd 'overlay' -if umount 'mount' ; then - rmdir 'mount' - rm --recursive 'upper' 'work' - if umount 'lower' ; then - rmdir 'lower' +cd "overlay" +if umount "mount" ; then + rmdir "mount" + rm --recursive "upper" "work" + if umount "lower" ; then + rmdir "lower" fi fi cd .. -rmdir 'overlay' +rmdir "overlay" } mr() { -for f in 'dev' 'dev/pts' 'proc' 'sys' ; do +for f in "dev" "dev/pts" "proc" "sys" ; do mount --bind "/${f}" "overlay/mount/${f}" done } @@ -50,18 +50,18 @@ chroot \ " ur() { -for f in 'sys' 'proc' 'dev/pts' 'dev' ; do +for f in "sys" "proc" "dev/pts" "dev" ; do umount --lazy "overlay/mount/${f}" done } mm() { -mount --make-rslave --rbind '/deb' 'overlay/mount/deb' +mount --make-rslave --rbind "/deb" "overlay/mount/deb" } um() { -umount --recursive 'overlay/mount/deb' +umount --recursive "overlay/mount/deb" } @@ -70,12 +70,12 @@ local directory="${1}" local level="${2}" if [ "${directory}" ] ; then if mkdir "${directory}" ; then - [ "${level}" ] || level='18' + [ "${level}" ] || level="18" cp overlay/mount/{vmlinuz,initrd.img} "${directory}" mksquashfs \ -'overlay/mount' "${directory}/filesystem.squashfs" \ +"overlay/mount" "${directory}/filesystem.squashfs" \ -noappend \ --comp 'zstd' -Xcompression-level "${level}" +-comp "zstd" -Xcompression-level "${level}" chown --recursive 1000:1000 "${directory}" fi fi From d7e2f152573a7e1daa685d596a91c0a438875264 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 09:49:47 +0100 Subject: [PATCH 481/969] function --- bash/bash/prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/bash/prompt.sh b/bash/bash/prompt.sh index da8a978..30e9014 100644 --- a/bash/bash/prompt.sh +++ b/bash/bash/prompt.sh @@ -15,7 +15,7 @@ local view="└ " view="${view}\e[0;32m" fi view="${view}${code}\e[0m @ \e[0;33m${date}\e[0m" - if [ "$(type -t __git_ps1)" == 'function' ] ; then + if [ "$(type -t __git_ps1)" == "function" ] ; then git="$(__git_ps1)" if [ "${git}" ] ; then view="${view} –\e[0;35m${git}\e[0m" From 6267af5ef8f062856788ddb83c1884e2fe99117e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 09:50:58 +0100 Subject: [PATCH 482/969] proxy --- bash/proxy.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bash/proxy.sh b/bash/proxy.sh index a5713ad..e594e63 100644 --- a/bash/proxy.sh +++ b/bash/proxy.sh @@ -1,8 +1,8 @@ function socks { local value case "${1}" in - 'on') value='manual' ;; - *) value='none' ;; + "on") value="manual" ;; + *) value="none" ;; esac - gsettings set 'org.gnome.system.proxy' 'mode' "${value}" + gsettings set "org.gnome.system.proxy" "mode" "${value}" } From 3a2a6a483c235d39b6710ecd2de0539da04a041b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 09:51:58 +0100 Subject: [PATCH 483/969] main --- bash/main.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index dacbbfc..7df12eb 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -5,7 +5,7 @@ MAIN_BASH_FILE="$(realpath "${BASH_SOURCE[0]}")" MAIN_BASH_ROOT="$(dirname "${MAIN_BASH_FILE}")" main_link_bashrc() { - local file='/etc/bash.bashrc' + local file="/etc/bash.bashrc" rm --force "${file}" ln --symbolic "${MAIN_BASH_FILE}" "${file}" } @@ -17,7 +17,7 @@ if [ -f "${file}" ] ; then local path="$(realpath "${file}")" local root="$(dirname "${path}")" local IFS=$'\n' - local modules=($(find "${root}" -type 'f' -name '*.sh' | sort)) + local modules=($(find "${root}" -type "f" -name "*.sh" | sort)) local module for module in "${modules[@]}" ; do if [ "${module}" != "${path}" ] ; then From 373b40dcf1d154f628ca923e452c7237c0a5daf9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 09:56:52 +0100 Subject: [PATCH 484/969] ps2 --- bash/bash/prompt.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bash/bash/prompt.sh b/bash/bash/prompt.sh index 30e9014..12ab4a7 100644 --- a/bash/bash/prompt.sh +++ b/bash/bash/prompt.sh @@ -1,14 +1,11 @@ -PS2="\ -├ " - -function ps1 { -local code=${1} -local date="$(date +%H:%M:%S)" -local git -local host="$(hostname)" -local path="${PWD}" -local user="${USER}" -local view="└ " +ps1() { + local code=${1} + local date="$(date +%H:%M:%S)" + local git + local host="$(hostname)" + local path="${PWD}" + local user="${USER}" + local view="└ " if [ ${code} -ne 0 ] ; then view="${view}\e[0;31m" else @@ -33,3 +30,6 @@ local view="└ " } PS1='$(eval ps1 ${?})' + +PS2="\ +├ " From d3bfa52eda4d4c3c83db0450df0bc99c6843c912 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 09:59:53 +0100 Subject: [PATCH 485/969] ps1 --- bash/bash/prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/bash/prompt.sh b/bash/bash/prompt.sh index 12ab4a7..2fd0724 100644 --- a/bash/bash/prompt.sh +++ b/bash/bash/prompt.sh @@ -29,7 +29,7 @@ ps1() { echo -e "${view}\n${PS2}" } -PS1='$(eval ps1 ${?})' +PS1="\$(ps1 \${?})" PS2="\ ├ " From 44adf7cc8ffac17c5f1f163774a7d2c5fb0cccfa Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 10:00:55 +0100 Subject: [PATCH 486/969] socks --- bash/proxy.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/proxy.sh b/bash/proxy.sh index e594e63..02ee28a 100644 --- a/bash/proxy.sh +++ b/bash/proxy.sh @@ -1,5 +1,5 @@ -function socks { -local value +socks() { + local value case "${1}" in "on") value="manual" ;; *) value="none" ;; From fbfb4c27e623dffcfdae5d0c7480e0ddab2ad7bb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 10:11:35 +0100 Subject: [PATCH 487/969] mount --- bash/mount.sh | 100 ++++++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 48 deletions(-) diff --git a/bash/mount.sh b/bash/mount.sh index 9fda047..b9bc609 100644 --- a/bash/mount.sh +++ b/bash/mount.sh @@ -1,41 +1,44 @@ mo() { -local directory="${1}" -local file -if [ "${directory}" ] ; then - directory="$(realpath "${directory}")" - file="${directory}/filesystem.squashfs" - if mkdir "overlay" ; then - cd "overlay" - mkdir {lower,upper,work,mount} - if mount "${file}" "lower" ; then - mount -t "overlay" "overlay" "mount" \ --o lowerdir="lower",upperdir="upper",workdir="work" - fi - cd .. - fi -else - echo "KO: directory?" -fi + local directory="${1}" + local file + if [ "${directory}" ] ; then + directory="$(realpath "${directory}")" + file="${directory}/filesystem.squashfs" + if mkdir "overlay" ; then + cd "overlay" + mkdir {lower,upper,work,mount} + if mount "${file}" "lower" ; then + mount \ + -o lowerdir="lower",upperdir="upper",workdir="work" + -t "overlay" \ + "overlay" "mount" + fi + cd .. + fi + else + echo "KO: directory?" + fi } uo() { -cd "overlay" -if umount "mount" ; then - rmdir "mount" - rm --recursive "upper" "work" - if umount "lower" ; then - rmdir "lower" - fi -fi -cd .. -rmdir "overlay" + cd "overlay" + if umount "mount" ; then + rmdir "mount" + rm --recursive "upper" "work" + if umount "lower" ; then + rmdir "lower" + fi + fi + cd .. + rmdir "overlay" } mr() { -for f in "dev" "dev/pts" "proc" "sys" ; do - mount --bind "/${f}" "overlay/mount/${f}" -done + local f + for f in "dev" "dev/pts" "proc" "sys" ; do + mount --bind "/${f}" "overlay/mount/${f}" + done } alias cr="\ @@ -50,33 +53,34 @@ chroot \ " ur() { -for f in "sys" "proc" "dev/pts" "dev" ; do - umount --lazy "overlay/mount/${f}" -done + local f + for f in "sys" "proc" "dev/pts" "dev" ; do + umount --lazy "overlay/mount/${f}" + done } mm() { -mount --make-rslave --rbind "/deb" "overlay/mount/deb" + mount --make-rslave --rbind "/deb" "overlay/mount/deb" } um() { -umount --recursive "overlay/mount/deb" + umount --recursive "overlay/mount/deb" } ms() { -local directory="${1}" -local level="${2}" -if [ "${directory}" ] ; then - if mkdir "${directory}" ; then - [ "${level}" ] || level="18" - cp overlay/mount/{vmlinuz,initrd.img} "${directory}" - mksquashfs \ -"overlay/mount" "${directory}/filesystem.squashfs" \ --noappend \ --comp "zstd" -Xcompression-level "${level}" - chown --recursive 1000:1000 "${directory}" - fi -fi + local directory="${1}" + local level="${2}" + if [ "${directory}" ] ; then + if mkdir "${directory}" ; then + [ "${level}" ] || level="18" + cp overlay/mount/{vmlinuz,initrd.img} "${directory}" + mksquashfs \ + "overlay/mount" "${directory}/filesystem.squashfs" \ + -noappend \ + -comp "zstd" -Xcompression-level "${level}" + chown --recursive 1000:1000 "${directory}" + fi + fi } From 8b39df8ed0727a8b7087c6ab05f21df728d534fe Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 10:14:08 +0100 Subject: [PATCH 488/969] main,proxy --- bash/main.sh | 42 +++++++++++++++++++++--------------------- bash/proxy.sh | 12 ++++++------ 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index 7df12eb..01b2691 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -5,31 +5,31 @@ MAIN_BASH_FILE="$(realpath "${BASH_SOURCE[0]}")" MAIN_BASH_ROOT="$(dirname "${MAIN_BASH_FILE}")" main_link_bashrc() { - local file="/etc/bash.bashrc" - rm --force "${file}" - ln --symbolic "${MAIN_BASH_FILE}" "${file}" + local file="/etc/bash.bashrc" + rm --force "${file}" + ln --symbolic "${MAIN_BASH_FILE}" "${file}" } # import modules main_import_modules() { -local file="${1}" -if [ -f "${file}" ] ; then - local path="$(realpath "${file}")" - local root="$(dirname "${path}")" - local IFS=$'\n' - local modules=($(find "${root}" -type "f" -name "*.sh" | sort)) - local module - for module in "${modules[@]}" ; do - if [ "${module}" != "${path}" ] ; then - . "${module}" - fi - done - log_trace "${modules[@]}" - return 0 -else - log_fatal "No file: ${file}" - return 1 -fi + local file="${1}" + if [ -f "${file}" ] ; then + local path="$(realpath "${file}")" + local root="$(dirname "${path}")" + local IFS=$'\n' + local modules=($(find "${root}" -type "f" -name "*.sh" | sort)) + local module + for module in "${modules[@]}" ; do + if [ "${module}" != "${path}" ] ; then + . "${module}" + fi + done + log_trace "${modules[@]}" + return 0 + else + log_fatal "No file: ${file}" + return 1 + fi } # import modules diff --git a/bash/proxy.sh b/bash/proxy.sh index 02ee28a..0ccc891 100644 --- a/bash/proxy.sh +++ b/bash/proxy.sh @@ -1,8 +1,8 @@ socks() { - local value - case "${1}" in - "on") value="manual" ;; - *) value="none" ;; - esac - gsettings set "org.gnome.system.proxy" "mode" "${value}" + local value + case "${1}" in + "on") value="manual" ;; + *) value="none" ;; + esac + gsettings set "org.gnome.system.proxy" "mode" "${value}" } From 663d99bb14fd92d4b47f06a12ed344893e96e843 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 10:15:58 +0100 Subject: [PATCH 489/969] lxc --- bash/mount-lxc.sh | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/bash/mount-lxc.sh b/bash/mount-lxc.sh index 2cc5a7e..2a4b5a1 100644 --- a/bash/mount-lxc.sh +++ b/bash/mount-lxc.sh @@ -1,31 +1,32 @@ mrc() { -local container="${1}" -local f - for f in "dev" "dev/pts" "proc" "sys" ; do - mount --bind "/${f}" "overlay/mount/var/lib/lxc/${container}/squashfs-root/${f}" - done + local container="${1}" + local f + for f in "dev" "dev/pts" "proc" "sys" ; do + mount --bind "/${f}" "overlay/mount/var/lib/lxc/${container}/squashfs-root/${f}" + done } crc() { -local container="${1}" - shift - chroot "overlay/mount/var/lib/lxc/${container}/squashfs-root" "${@}" + local container="${1}" + shift + chroot "overlay/mount/var/lib/lxc/${container}/squashfs-root" "${@}" } urc() { -local container="${1}" - for f in "sys" "proc" "dev/pts" "dev" ; do - umount --lazy "overlay/mount/var/lib/lxc/${container}/squashfs-root/${f}" - done + local container="${1}" + local f + for f in "sys" "proc" "dev/pts" "dev" ; do + umount --lazy "overlay/mount/var/lib/lxc/${container}/squashfs-root/${f}" + done } mmc() { -local container="${1}" - mount --bind "/deb" "overlay/mount/var/lib/lxc/${container}/squashfs-root/deb" + local container="${1}" + mount --bind "/deb" "overlay/mount/var/lib/lxc/${container}/squashfs-root/deb" } umc() { -local container="${1}" - umount "overlay/mount/var/lib/lxc/${container}/squashfs-root/deb" + local container="${1}" + umount "overlay/mount/var/lib/lxc/${container}/squashfs-root/deb" } From 88162d22fe44d12878599fc106081a37e4c74eaf Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 10:18:44 +0100 Subject: [PATCH 490/969] prompt --- bash/bash/prompt.sh | 56 ++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/bash/bash/prompt.sh b/bash/bash/prompt.sh index 2fd0724..069b34e 100644 --- a/bash/bash/prompt.sh +++ b/bash/bash/prompt.sh @@ -1,32 +1,32 @@ ps1() { - local code=${1} - local date="$(date +%H:%M:%S)" - local git - local host="$(hostname)" - local path="${PWD}" - local user="${USER}" - local view="└ " - if [ ${code} -ne 0 ] ; then - view="${view}\e[0;31m" - else - view="${view}\e[0;32m" - fi - view="${view}${code}\e[0m @ \e[0;33m${date}\e[0m" - if [ "$(type -t __git_ps1)" == "function" ] ; then - git="$(__git_ps1)" - if [ "${git}" ] ; then - view="${view} –\e[0;35m${git}\e[0m" - fi - fi - view="${view}\n\e[0;36m${path}\e[0m" - view="${view}\n┌ " - if [ ${EUID} -eq 0 ] ; then - view="${view}\e[0;31m" - else - view="${view}\e[0;32m" - fi - view="${view}${user}\e[0m @ \e[0;33m${host}\e[0m" - echo -e "${view}\n${PS2}" + local code=${1} + local date="$(date +%H:%M:%S)" + local git + local host="$(hostname)" + local path="${PWD}" + local user="${USER}" + local view="└ " + if [ ${code} -ne 0 ] ; then + view="${view}\e[0;31m" + else + view="${view}\e[0;32m" + fi + view="${view}${code}\e[0m @ \e[0;33m${date}\e[0m" + if [ "$(type -t __git_ps1)" == "function" ] ; then + git="$(__git_ps1)" + if [ "${git}" ] ; then + view="${view} –\e[0;35m${git}\e[0m" + fi + fi + view="${view}\n\e[0;36m${path}\e[0m" + view="${view}\n┌ " + if [ ${EUID} -eq 0 ] ; then + view="${view}\e[0;31m" + else + view="${view}\e[0;32m" + fi + view="${view}${user}\e[0m @ \e[0;33m${host}\e[0m" + echo -e "${view}\n${PS2}" } PS1="\$(ps1 \${?})" From a4ed6cdbdbf40d202a342acf530dbf3a44712336 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 10:25:44 +0100 Subject: [PATCH 491/969] fixes --- bash/mount.sh | 6 +++--- bash/rescue.sh | 2 +- bash/util.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bash/mount.sh b/bash/mount.sh index b9bc609..ca6ac45 100644 --- a/bash/mount.sh +++ b/bash/mount.sh @@ -9,7 +9,7 @@ mo() { mkdir {lower,upper,work,mount} if mount "${file}" "lower" ; then mount \ - -o lowerdir="lower",upperdir="upper",workdir="work" + -o lowerdir="lower",upperdir="upper",workdir="work" \ -t "overlay" \ "overlay" "mount" fi @@ -72,9 +72,9 @@ um() { ms() { local directory="${1}" local level="${2}" - if [ "${directory}" ] ; then + if [ -n "${directory}" ] ; then if mkdir "${directory}" ; then - [ "${level}" ] || level="18" + [ -n "${level}" ] || level="18" cp overlay/mount/{vmlinuz,initrd.img} "${directory}" mksquashfs \ "overlay/mount" "${directory}/filesystem.squashfs" \ diff --git a/bash/rescue.sh b/bash/rescue.sh index 3a4bb7d..58076e6 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -73,7 +73,7 @@ rescue_install() { rescue_upload() { local host="${1}" local hostname="${2}" - if [ "${hostname}" ]; then + if [ -n "${hostname}" ]; then local user="root" # local user_host="${user}@${host}" diff --git a/bash/util.sh b/bash/util.sh index 2711b03..458995f 100644 --- a/bash/util.sh +++ b/bash/util.sh @@ -13,7 +13,7 @@ read_passphrase() { read_secret() { local prompt="${1}" local secret - printf "${prompt}" 1>&2 + printf "%s" "${prompt}" 1>&2 read -r -s secret echo >&2 echo "${secret}" From 0dfc4d99ed4e48b5e1edf84e16380bbd8b480c49 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 10:27:50 +0100 Subject: [PATCH 492/969] read --- bash/rescue-hetzner.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 6991368..b4cf60a 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -13,7 +13,7 @@ rescue_wipe_0_init_hetzner_8_8() { # lsblk echo -n "WIPE" "${devices[@]}" "/?\\ OR CANCEL /!\\" - read + read -r # number=0 for device in "${devices[@]}"; do From 11c131e849230f53587d21058e18f769e5ce9e29 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 10:29:09 +0100 Subject: [PATCH 493/969] nano --- bash/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/mount.sh b/bash/mount.sh index ca6ac45..ee14c83 100644 --- a/bash/mount.sh +++ b/bash/mount.sh @@ -1,7 +1,7 @@ mo() { local directory="${1}" local file - if [ "${directory}" ] ; then + if [ -n "${directory}" ] ; then directory="$(realpath "${directory}")" file="${directory}/filesystem.squashfs" if mkdir "overlay" ; then From 5cf0d4021ea1f5755758de30c69d0d4398a57b9a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 19:45:47 +0100 Subject: [PATCH 494/969] partitions --- bash/rescue-hetzner.sh | 31 ++++++++----------------------- bash/rescue-ovh.sh | 31 ++++++++----------------------- 2 files changed, 16 insertions(+), 46 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index b4cf60a..4536e47 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -7,7 +7,6 @@ rescue_wipe_0_init_hetzner_8_8() { local members local number local passphrase - local unit="mib" # read passphrase passphrase="$(read_passphrase)" # @@ -21,28 +20,14 @@ rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}" # - parted "${device}" \ - --script \ - mktable gpt - # - parted "${device}" \ - unit "${unit}" \ - mkpart "crypt-${number}" 33282 7630885 - # - parted "${device}" \ - unit "${unit}" \ - mkpart "boot-${number}" 514 33282 - # - parted "${device}" \ - unit "${unit}" \ - mkpart "esp-${number}" 2 514 - parted "${device}" \ - set 3 esp on - # - parted "${device}" \ - unit "${unit}" \ - mkpart "bios-${number}" 1 2 - parted "${device}" \ + parted --script "${device}" \ + mktable gpt \ + unit "mib" \ + mkpart "crypt-${number}" 33282 7630885 \ + mkpart "boot-${number}" 514 33282 \ + mkpart "esp-${number}" 2 514 \ + set 3 esp on \ + mkpart "bios-${number}" 1 2 \ set 4 bios_grub on done # diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index ea71bcf..c267929 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -1,7 +1,6 @@ rescue_wipe_0_init_ovh_vle2() { local device="/dev/sdb" local passphrase - local unit="mib" # read passphrase passphrase="$(read_passphrase)" # warn @@ -9,28 +8,14 @@ rescue_wipe_0_init_ovh_vle2() { printf "%s" "WIPE ${device} /?\\ OR CANCEL /!\\" read -r # - parted "${device}" \ - --script \ - mktable gpt - # - parted "${device}" \ - unit "${unit}" \ - mkpart "crypt" 4610 40959 - # - parted "${device}" \ - unit "${unit}" \ - mkpart "boot" 514 4610 - # - parted "${device}" \ - unit "${unit}" \ - mkpart "esp" 2 514 - parted "${device}" \ - set 3 esp on - # - parted "${device}" \ - unit "${unit}" \ - mkpart bios 1 2 - parted "${device}" \ + parted --script "${device}" \ + mktable gpt \ + unit "mib" \ + mkpart "crypt" 4610 40959 \ + mkpart "boot" 514 4610 \ + mkpart "esp" 2 514 \ + set 3 esp on \ + mkpart bios 1 2 \ set 4 bios_grub on # bios / wipe dd if="/dev/zero" of="${device}4" From dfe3be4f1cf521d24f49713c2196af66bbad2078 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 20:03:47 +0100 Subject: [PATCH 495/969] fat --- bash/fs.sh | 19 +++++++++++++++++++ bash/rescue-hetzner.sh | 7 +------ bash/rescue-ovh.sh | 7 +------ 3 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 bash/fs.sh diff --git a/bash/fs.sh b/bash/fs.sh new file mode 100644 index 0000000..df0980e --- /dev/null +++ b/bash/fs.sh @@ -0,0 +1,19 @@ +fs_make_fat() { + local device="${1}" + local name="${2}" + local volid="${3}" + if [ -b "${device}" ]; then + set -- \ + -F 32 \ + -S 4096 + if [ -n "${name}" ]; then + set -- "${@}" \ + -n "${name}" + fi + if [ -n "${volid}" ]; then + set -- "${@}" \ + -i "${volid}" + fi + mkfs.fat "${@}" "${device}" + fi +} diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 4536e47..3ca0f3b 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -49,12 +49,7 @@ rescue_wipe_0_init_hetzner_8_8() { # format esp dd \ if="/dev/zero" of="${device}3" bs="1M" - mkfs.vfat \ - -F 32 \ - -S 4096 \ - -i "0000000${number}" \ - -n "esp-${number}" \ - "${device}3" + fs_make_fat "${device}3" "esp-${number}" "0000000${number}" # mount esp mkdir --parents "/media/esp/${number}" mount "${device}3" "/media/esp/${number}" diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index c267929..63c5192 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -22,12 +22,7 @@ rescue_wipe_0_init_ovh_vle2() { # esp / wipe dd if="/dev/zero" of="${device}3" bs="1M" # esp / format - mkfs.vfat \ - -F 32 \ - -S 4096 \ - -i "00000001" \ - -n "esp" \ - "${device}3" + fs_make_fat "${device}3" "esp" "00000001" # esp / mount mkdir --parents "/media/esp" mount "${device}3" "/media/esp" From 3b2df8f8a067bef320a3e941f997e43f3c55e7b4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 20:13:32 +0100 Subject: [PATCH 496/969] fs_wipe --- bash/fs.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/bash/fs.sh b/bash/fs.sh index df0980e..1b2e72b 100644 --- a/bash/fs.sh +++ b/bash/fs.sh @@ -17,3 +17,24 @@ fs_make_fat() { mkfs.fat "${@}" "${device}" fi } + +fs_wipe() { + local device="${1}" + local buffer="${2}" + local count="${3}" + if [ -b "${device}" ]; then + set -- \ + status="progress" \ + if="/dev/zero" \ + of="${device}" + if [ -n "${buffer}" ]; then + set -- "${@}" \ + bs="${buffer}" + fi + if [ -n "${count}" ]; then + set -- "${@}" \ + count=${count} + fi + dd "${@}" + fi +} From 378e0e530f7bd0bda618d28ffc0f79c837ac63aa Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 20:22:58 +0100 Subject: [PATCH 497/969] wipes --- bash/rescue-hetzner.sh | 12 ++++-------- bash/rescue-ovh.sh | 8 ++++---- bash/rescue.sh | 3 +-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 3ca0f3b..6386621 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -37,8 +37,7 @@ rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}4" # wipe bios - dd \ - if="/dev/zero" of="${device}4" + fs_wipe "${device}4" done # number=0 @@ -47,8 +46,7 @@ rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}3" # format esp - dd \ - if="/dev/zero" of="${device}3" bs="1M" + fs_wipe "${device}3" "1M" fs_make_fat "${device}3" "esp-${number}" "0000000${number}" # mount esp mkdir --parents "/media/esp/${number}" @@ -61,8 +59,7 @@ rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}2" # wipe boot - dd status="progress" \ - if="/dev/zero" of="${device}2" bs="1G" count=1 + fs_wipe "${device}2" "1G" 1 done # members=() @@ -95,8 +92,7 @@ rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}1" # wipe crypt head - dd status="progress" \ - if="/dev/zero" of="${device}1" bs="1G" count=1 + fs_wipe "${device}1" "1G" 1 done # members=() diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index 63c5192..0683acf 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -18,16 +18,16 @@ rescue_wipe_0_init_ovh_vle2() { mkpart bios 1 2 \ set 4 bios_grub on # bios / wipe - dd if="/dev/zero" of="${device}4" + fs_wipe "${device}4" # esp / wipe - dd if="/dev/zero" of="${device}3" bs="1M" + fs_wipe "${device}3" "1M" # esp / format fs_make_fat "${device}3" "esp" "00000001" # esp / mount mkdir --parents "/media/esp" mount "${device}3" "/media/esp" # boot / wipe - dd status="progress" if="/dev/zero" of="${device}2" bs="1G" count=1 + fs_wipe "${device}2" "1G" 1 # boot / format mkfs.btrfs --force \ --checksum "sha256" \ @@ -39,7 +39,7 @@ rescue_wipe_0_init_ovh_vle2() { mount --options "autodefrag,compress-force=zstd" \ "${device}2" "/media/boot" # crypt / wipe - dd status="progress" if="/dev/zero" of="${device}1" bs="1G" count=1 + fs_wipe "${device}1" "1G" 1 # crypt / encrypt echo "${passphrase}" | cryptsetup \ diff --git a/bash/rescue.sh b/bash/rescue.sh index 58076e6..47f6ca7 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -103,8 +103,7 @@ source \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\"" } rescue_wipe_1_zero() { - dd status="progress" \ - if="/dev/zero" of="/dev/mapper/crypt" bs="512M" + fs_wipe "/dev/mapper/crypt" "512M" } rescue_wipe_3_close() { From fdffd7fb08549d21d7d6b94aa9b7573712d3aad1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 22:38:38 +0100 Subject: [PATCH 498/969] fs_make_btrfs --- bash/fs.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bash/fs.sh b/bash/fs.sh index 1b2e72b..e13a498 100644 --- a/bash/fs.sh +++ b/bash/fs.sh @@ -1,3 +1,23 @@ +fs_make_btrfs() { + local device="${1}" + local label="${2}" + local uuid="${3}" + if [ -b "${device}" ]; then + set -- \ + --force \ + --checksum "sha256" + if [ -n "${label}" ]; then + set -- "${@}" \ + --label "${label}" + fi + if [ -n "${uuid}" ]; then + set -- "${@}" \ + --uuid "${uuid}" + fi + mkfs.btrfs "${@}" "${device}" + fi +} + fs_make_fat() { local device="${1}" local name="${2}" From 7611ee6103605f5d83c9d59f63c840a40c4dc074 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 22:47:18 +0100 Subject: [PATCH 499/969] btrfs --- bash/rescue-hetzner.sh | 14 ++++---------- bash/rescue-ovh.sh | 14 ++++---------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 6386621..142e07d 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -75,11 +75,8 @@ rescue_wipe_0_init_hetzner_8_8() { --uuid "00000000:00000000:00000000:00000002" \ "${members[@]}" # - mkfs.btrfs --force \ - --checksum "sha256" \ - --label "boot" \ - --uuid "00000000-0000-0000-0000-00000000000b" \ - "/dev/md/boot" + fs_make_btrfs "/dev/md/boot" "boot" \ + "00000000-0000-0000-0000-00000000000b" # mount boot mkdir --parents "/media/boot" mount \ @@ -154,11 +151,8 @@ rescue_wipe_2_make_hetzner_8_8() { # passphrase unset passphrase # format crypt - mkfs.btrfs --force \ - --checksum "sha256" \ - --label "crypt" \ - --uuid "00000000-0000-0000-0000-00000000000c" \ - "/dev/mapper/crypt" + fs_make_btrfs "/dev/mapper/crypt" "crypt" \ + "00000000-0000-0000-0000-00000000000c" # mount crypt mkdir --parents "/media/crypt" mount \ diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index 0683acf..4792c6c 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -29,11 +29,8 @@ rescue_wipe_0_init_ovh_vle2() { # boot / wipe fs_wipe "${device}2" "1G" 1 # boot / format - mkfs.btrfs --force \ - --checksum "sha256" \ - --label "boot" \ - --uuid "00000000-0000-0000-0000-00000000000b" \ - "${device}2" + fs_make_btrfs "${device}2" "boot" \ + "00000000-0000-0000-0000-00000000000b" # boot / mount mkdir --parents "/media/boot" mount --options "autodefrag,compress-force=zstd" \ @@ -88,11 +85,8 @@ rescue_wipe_2_make_ovh_vle2() { # passphrase unset passphrase # crypt / format - mkfs.btrfs --force \ - --checksum "sha256" \ - --label "crypt" \ - --uuid "00000000-0000-0000-0000-00000000000c" \ - "/dev/mapper/crypt" + fs_make_btrfs "/dev/mapper/crypt" "crypt" \ + "00000000-0000-0000-0000-00000000000c" # crypt / mount mkdir --parents "/media/crypt" mount --options "autodefrag,compress-force=zstd" \ From 4590c5cda6eb08d7eada76162a13b4eb3faa61e8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 22:52:21 +0100 Subject: [PATCH 500/969] fs_make_btrfs_swap --- bash/fs.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bash/fs.sh b/bash/fs.sh index e13a498..71db3a7 100644 --- a/bash/fs.sh +++ b/bash/fs.sh @@ -18,6 +18,24 @@ fs_make_btrfs() { fi } +fs_make_btrfs_swap() { + local path="${1}" + local size="${2}" + local uuid="${3}" + if [ -n "${path}" ]; then + set filesystem mkswapfile + if [ -n "${size}" ]; then + set -- "${@}" \ + --size "${size}" + fi + if [ -n "${uuid}" ]; then + set -- "${@}" \ + --uuid "${uuid}" + fi + btrfs "${@}" "${path}" + fi +} + fs_make_fat() { local device="${1}" local name="${2}" From 799732c8ef52e5587e8cb725c50a478e30811b0c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 22:59:49 +0100 Subject: [PATCH 501/969] swaps --- bash/rescue-hetzner.sh | 6 ++---- bash/rescue-ovh.sh | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 142e07d..9637910 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -159,8 +159,6 @@ rescue_wipe_2_make_hetzner_8_8() { --options "autodefrag,compress-force=zstd" \ "/dev/mapper/crypt" "/media/crypt" # make swap file - btrfs filesystem mkswapfile \ - --size "64g" \ - --uuid "00000000-0000-0000-0000-000000000005" \ - "/media/crypt/swap" + fs_make_btrfs_swap "/media/crypt/swap" "64g" \ + "00000000-0000-0000-0000-000000000005" } diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index 4792c6c..e15c9d9 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -92,8 +92,6 @@ rescue_wipe_2_make_ovh_vle2() { mount --options "autodefrag,compress-force=zstd" \ "/dev/mapper/crypt" "/media/crypt" # crypt / swap - btrfs filesystem mkswapfile \ - --size "4g" \ - --uuid "00000000-0000-0000-0000-000000000005" \ - "/media/crypt/swap" + fs_make_btrfs_swap "/media/crypt/swap" "4g" \ + "00000000-0000-0000-0000-000000000005" } From 6be681d0fbb67d8f56c720bbfc4d288efc3ded10 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 23:13:45 +0100 Subject: [PATCH 502/969] luks_format --- bash/fs.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bash/fs.sh b/bash/fs.sh index 71db3a7..567479d 100644 --- a/bash/fs.sh +++ b/bash/fs.sh @@ -76,3 +76,23 @@ fs_wipe() { dd "${@}" fi } + +luks_format() { + local device="${1}" + local passphrase="${2}" + if [ -b "${device}" ]; then + echo "${passphrase}" | + cryptsetup \ + --verbose \ + --batch-mode \ + --type "luks2" \ + --pbkdf "argon2id" \ + --cipher "aes-xts-plain64" \ + --iter-time 4096 \ + --key-size 512 \ + --hash "sha512" \ + --use-random \ + luksFormat \ + "${device}" + fi +} From 7bce373af61db6b14ec2c74b71eafff160b708b4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 23:27:19 +0100 Subject: [PATCH 503/969] =?UTF-8?q?=E2=86=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash/fs.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bash/fs.sh b/bash/fs.sh index 567479d..07bd84f 100644 --- a/bash/fs.sh +++ b/bash/fs.sh @@ -78,20 +78,22 @@ fs_wipe() { } luks_format() { - local device="${1}" - local passphrase="${2}" + local passphrase="${1}" + local device="${2}" + local label="${3}" + local uuid="${4}" if [ -b "${device}" ]; then echo "${passphrase}" | cryptsetup \ - --verbose \ --batch-mode \ - --type "luks2" \ - --pbkdf "argon2id" \ --cipher "aes-xts-plain64" \ + --hash "sha512" \ --iter-time 4096 \ --key-size 512 \ - --hash "sha512" \ + --pbkdf "argon2id" \ + --type "luks2" \ --use-random \ + --verbose \ luksFormat \ "${device}" fi From 5e800b713d9abcd09c130bcb08919e2da5aafaf8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 23:32:14 +0100 Subject: [PATCH 504/969] args --- bash/fs.sh | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/bash/fs.sh b/bash/fs.sh index 07bd84f..bf59782 100644 --- a/bash/fs.sh +++ b/bash/fs.sh @@ -83,18 +83,23 @@ luks_format() { local label="${3}" local uuid="${4}" if [ -b "${device}" ]; then + set -- \ + --batch-mode \ + --cipher "aes-xts-plain64" \ + --hash "sha512" \ + --iter-time 4096 \ + --key-size 512 \ + --pbkdf "argon2id" \ + --type "luks2" \ + --use-random \ + --verbose + if [ -n "${label}" ]; then + set -- "${@}" --label "${label}" + fi + if [ -n "${uuid}" ]; then + set -- "${@}" --label "${uuid}" + fi echo "${passphrase}" | - cryptsetup \ - --batch-mode \ - --cipher "aes-xts-plain64" \ - --hash "sha512" \ - --iter-time 4096 \ - --key-size 512 \ - --pbkdf "argon2id" \ - --type "luks2" \ - --use-random \ - --verbose \ - luksFormat \ - "${device}" + cryptsetup "${@}" luksFormat "${device}" fi } From c4f68fc29b8cff6d833492dc8b3ff789b12c7c14 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 23:32:36 +0100 Subject: [PATCH 505/969] fix --- bash/fs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/fs.sh b/bash/fs.sh index bf59782..9c1d122 100644 --- a/bash/fs.sh +++ b/bash/fs.sh @@ -97,7 +97,7 @@ luks_format() { set -- "${@}" --label "${label}" fi if [ -n "${uuid}" ]; then - set -- "${@}" --label "${uuid}" + set -- "${@}" --uuid "${uuid}" fi echo "${passphrase}" | cryptsetup "${@}" luksFormat "${device}" From b557ddde70c1f7b203f89b9cd32089ecd9d8b509 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 23:36:20 +0100 Subject: [PATCH 506/969] formats --- bash/rescue-hetzner.sh | 28 ++-------------------------- bash/rescue-ovh.sh | 28 ++-------------------------- 2 files changed, 4 insertions(+), 52 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 9637910..81930b4 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -105,19 +105,7 @@ rescue_wipe_0_init_hetzner_8_8() { --uuid "00000000:00000000:00000000:00000001" \ "${members[@]}" # encrypt - echo "${passphrase}" | - cryptsetup \ - --verbose \ - --batch-mode \ - --type "luks2" \ - --pbkdf "argon2id" \ - --cipher "aes-xts-plain64" \ - --iter-time 8192 \ - --key-size 512 \ - --hash "sha512" \ - --use-random \ - luksFormat \ - "/dev/md/crypt" + luks_format "${passphrase}" "/dev/md/crypt" # open echo "${passphrase}" | cryptsetup luksOpen "/dev/md/crypt" "crypt" @@ -132,19 +120,7 @@ rescue_wipe_2_make_hetzner_8_8() { # read passphrase passphrase="$(read_passphrase)" # encrypt - echo "${passphrase}" | - cryptsetup \ - --verbose \ - --batch-mode \ - --type "luks2" \ - --pbkdf "argon2id" \ - --cipher "aes-xts-plain64" \ - --iter-time 8192 \ - --key-size 512 \ - --hash "sha512" \ - --use-random \ - luksFormat \ - "/dev/md/crypt" + luks_format "${passphrase}" "/dev/md/crypt" # open echo "${passphrase}" | cryptsetup luksOpen "/dev/md/crypt" "crypt" diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh index e15c9d9..ed225d1 100644 --- a/bash/rescue-ovh.sh +++ b/bash/rescue-ovh.sh @@ -38,19 +38,7 @@ rescue_wipe_0_init_ovh_vle2() { # crypt / wipe fs_wipe "${device}1" "1G" 1 # crypt / encrypt - echo "${passphrase}" | - cryptsetup \ - --verbose \ - --batch-mode \ - --type "luks2" \ - --pbkdf "argon2id" \ - --cipher "aes-xts-plain64" \ - --iter-time 4096 \ - --key-size 512 \ - --hash "sha512" \ - --use-random \ - luksFormat \ - "${device}1" + luks_format "${passphrase}" "${device}1" # crypt / open echo "${passphrase}" | cryptsetup luksOpen "${device}1" "crypt" @@ -66,19 +54,7 @@ rescue_wipe_2_make_ovh_vle2() { # read passphrase passphrase="$(read_passphrase)" # crypt / encrypt - echo "${passphrase}" | - cryptsetup \ - --verbose \ - --batch-mode \ - --type "luks2" \ - --pbkdf "argon2id" \ - --cipher "aes-xts-plain64" \ - --iter-time 4096 \ - --key-size 512 \ - --hash "sha512" \ - --use-random \ - luksFormat \ - "${device}1" + luks_format "${passphrase}" "${device}1" # crypt / open echo "${passphrase}" | cryptsetup luksOpen "${device}1" "crypt" From 010cb76003dfbf45431ec62b9039249e8307c153 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 09:11:24 +0100 Subject: [PATCH 507/969] _shell_ --- bash/main.sh | 8 ++++---- bash/rescue.sh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index 01b2691..44c3910 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -1,13 +1,13 @@ #! /usr/bin/env bash -MAIN_BASH_FILE="$(realpath "${BASH_SOURCE[0]}")" +MAIN_SHELL_FILE="$(realpath "${BASH_SOURCE[0]}")" -MAIN_BASH_ROOT="$(dirname "${MAIN_BASH_FILE}")" +MAIN_SHELL_ROOT="$(dirname "${MAIN_SHELL_FILE}")" main_link_bashrc() { local file="/etc/bash.bashrc" rm --force "${file}" - ln --symbolic "${MAIN_BASH_FILE}" "${file}" + ln --symbolic "${MAIN_SHELL_FILE}" "${file}" } # import modules @@ -33,4 +33,4 @@ main_import_modules() { } # import modules -main_import_modules "${MAIN_BASH_FILE}" +main_import_modules "${MAIN_SHELL_FILE}" diff --git a/bash/rescue.sh b/bash/rescue.sh index 47f6ca7..162985a 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -85,7 +85,7 @@ rescue_upload() { "${user_host}" # upload root rsync --delete --recursive \ - "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" + "${MAIN_SHELL_ROOT}/" "${user_host}:/etc/bash/" # call setup # TODO variable ssh "${user_host}" -- "\ From 40c151d69e8d9d6c43e34074c8cc77bfc6d7f64c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 09:30:59 +0100 Subject: [PATCH 508/969] main/readlink --- bash/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/main.sh b/bash/main.sh index 44c3910..63d91f2 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -1,6 +1,6 @@ #! /usr/bin/env bash -MAIN_SHELL_FILE="$(realpath "${BASH_SOURCE[0]}")" +MAIN_SHELL_FILE="$(readlink --canonicalize-existing "${0}")" MAIN_SHELL_ROOT="$(dirname "${MAIN_SHELL_FILE}")" From e8c65c9821f91a7d1f7968973bd91bdbae5ef3e4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 09:41:47 +0100 Subject: [PATCH 509/969] users --- bash/main.sh | 8 ++++---- bash/rescue.sh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index 63d91f2..797aed1 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -1,13 +1,13 @@ #! /usr/bin/env bash -MAIN_SHELL_FILE="$(readlink --canonicalize-existing "${0}")" +MAIN_USERS_FILE="$(readlink --canonicalize-existing "${0}")" -MAIN_SHELL_ROOT="$(dirname "${MAIN_SHELL_FILE}")" +MAIN_USERS_ROOT="$(dirname "${MAIN_USERS_FILE}")" main_link_bashrc() { local file="/etc/bash.bashrc" rm --force "${file}" - ln --symbolic "${MAIN_SHELL_FILE}" "${file}" + ln --symbolic "${MAIN_USERS_FILE}" "${file}" } # import modules @@ -33,4 +33,4 @@ main_import_modules() { } # import modules -main_import_modules "${MAIN_SHELL_FILE}" +main_import_modules "${MAIN_USERS_FILE}" diff --git a/bash/rescue.sh b/bash/rescue.sh index 162985a..ded689d 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -85,7 +85,7 @@ rescue_upload() { "${user_host}" # upload root rsync --delete --recursive \ - "${MAIN_SHELL_ROOT}/" "${user_host}:/etc/bash/" + "${MAIN_USERS_ROOT}/" "${user_host}:/etc/bash/" # call setup # TODO variable ssh "${user_host}" -- "\ From 0cc06b6de097d63a626874134bcb57f100f88aac Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 09:43:27 +0100 Subject: [PATCH 510/969] shfmt --- bash/main.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index 797aed1..4442460 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -13,14 +13,14 @@ main_link_bashrc() { # import modules main_import_modules() { local file="${1}" - if [ -f "${file}" ] ; then + if [ -f "${file}" ]; then local path="$(realpath "${file}")" local root="$(dirname "${path}")" local IFS=$'\n' local modules=($(find "${root}" -type "f" -name "*.sh" | sort)) local module - for module in "${modules[@]}" ; do - if [ "${module}" != "${path}" ] ; then + for module in "${modules[@]}"; do + if [ "${module}" != "${path}" ]; then . "${module}" fi done From 8f81cb445568f58669d34ddcfa9378122d46e8b6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 10:40:27 +0100 Subject: [PATCH 511/969] realpath --- bash/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/main.sh b/bash/main.sh index 4442460..e9c0d27 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -1,6 +1,6 @@ #! /usr/bin/env bash -MAIN_USERS_FILE="$(readlink --canonicalize-existing "${0}")" +MAIN_USERS_FILE="$(realpath --canonicalize-existing "${0}")" MAIN_USERS_ROOT="$(dirname "${MAIN_USERS_FILE}")" From c22e6d18ce3ecf9a7d79c1ae191c4a37eb514a13 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 11:21:37 +0100 Subject: [PATCH 512/969] source --- bash/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/main.sh b/bash/main.sh index e9c0d27..bbfcc87 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -1,6 +1,6 @@ #! /usr/bin/env bash -MAIN_USERS_FILE="$(realpath --canonicalize-existing "${0}")" +MAIN_USERS_FILE="$(realpath --canonicalize-existing "${BASH_SOURCE[0]}")" MAIN_USERS_ROOT="$(dirname "${MAIN_USERS_FILE}")" From 39fdabd885711063e363d1c66c19b06acc0e096d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 11:24:51 +0100 Subject: [PATCH 513/969] . --- bash/rescue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/rescue.sh b/bash/rescue.sh index ded689d..e7ff374 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -89,7 +89,7 @@ rescue_upload() { # call setup # TODO variable ssh "${user_host}" -- "\ -source \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\"" +. \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\"" # create session ssh "${user_host}" -- byobu new-session -d # send keys From a6e63a67228d7bc5e2af8cd2eb66b981581bbb36 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 11:34:59 +0100 Subject: [PATCH 514/969] shfmt --- bash/bash/prompt.sh | 8 ++++---- bash/mount-lxc.sh | 5 ++--- bash/mount.sh | 21 +++++++++------------ bash/proxy.sh | 4 ++-- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/bash/bash/prompt.sh b/bash/bash/prompt.sh index 069b34e..d77a307 100644 --- a/bash/bash/prompt.sh +++ b/bash/bash/prompt.sh @@ -6,21 +6,21 @@ ps1() { local path="${PWD}" local user="${USER}" local view="└ " - if [ ${code} -ne 0 ] ; then + if [ ${code} -ne 0 ]; then view="${view}\e[0;31m" else view="${view}\e[0;32m" fi view="${view}${code}\e[0m @ \e[0;33m${date}\e[0m" - if [ "$(type -t __git_ps1)" == "function" ] ; then + if [ "$(type -t __git_ps1)" == "function" ]; then git="$(__git_ps1)" - if [ "${git}" ] ; then + if [ "${git}" ]; then view="${view} –\e[0;35m${git}\e[0m" fi fi view="${view}\n\e[0;36m${path}\e[0m" view="${view}\n┌ " - if [ ${EUID} -eq 0 ] ; then + if [ ${EUID} -eq 0 ]; then view="${view}\e[0;31m" else view="${view}\e[0;32m" diff --git a/bash/mount-lxc.sh b/bash/mount-lxc.sh index 2a4b5a1..8cc946e 100644 --- a/bash/mount-lxc.sh +++ b/bash/mount-lxc.sh @@ -1,7 +1,7 @@ mrc() { local container="${1}" local f - for f in "dev" "dev/pts" "proc" "sys" ; do + for f in "dev" "dev/pts" "proc" "sys"; do mount --bind "/${f}" "overlay/mount/var/lib/lxc/${container}/squashfs-root/${f}" done } @@ -15,12 +15,11 @@ crc() { urc() { local container="${1}" local f - for f in "sys" "proc" "dev/pts" "dev" ; do + for f in "sys" "proc" "dev/pts" "dev"; do umount --lazy "overlay/mount/var/lib/lxc/${container}/squashfs-root/${f}" done } - mmc() { local container="${1}" mount --bind "/deb" "overlay/mount/var/lib/lxc/${container}/squashfs-root/deb" diff --git a/bash/mount.sh b/bash/mount.sh index ee14c83..fe5b273 100644 --- a/bash/mount.sh +++ b/bash/mount.sh @@ -1,13 +1,13 @@ mo() { local directory="${1}" local file - if [ -n "${directory}" ] ; then + if [ -n "${directory}" ]; then directory="$(realpath "${directory}")" file="${directory}/filesystem.squashfs" - if mkdir "overlay" ; then + if mkdir "overlay"; then cd "overlay" mkdir {lower,upper,work,mount} - if mount "${file}" "lower" ; then + if mount "${file}" "lower"; then mount \ -o lowerdir="lower",upperdir="upper",workdir="work" \ -t "overlay" \ @@ -22,10 +22,10 @@ mo() { uo() { cd "overlay" - if umount "mount" ; then + if umount "mount"; then rmdir "mount" rm --recursive "upper" "work" - if umount "lower" ; then + if umount "lower"; then rmdir "lower" fi fi @@ -33,10 +33,9 @@ uo() { rmdir "overlay" } - mr() { local f - for f in "dev" "dev/pts" "proc" "sys" ; do + for f in "dev" "dev/pts" "proc" "sys"; do mount --bind "/${f}" "overlay/mount/${f}" done } @@ -54,12 +53,11 @@ chroot \ ur() { local f - for f in "sys" "proc" "dev/pts" "dev" ; do + for f in "sys" "proc" "dev/pts" "dev"; do umount --lazy "overlay/mount/${f}" done } - mm() { mount --make-rslave --rbind "/deb" "overlay/mount/deb" } @@ -68,12 +66,11 @@ um() { umount --recursive "overlay/mount/deb" } - ms() { local directory="${1}" local level="${2}" - if [ -n "${directory}" ] ; then - if mkdir "${directory}" ; then + if [ -n "${directory}" ]; then + if mkdir "${directory}"; then [ -n "${level}" ] || level="18" cp overlay/mount/{vmlinuz,initrd.img} "${directory}" mksquashfs \ diff --git a/bash/proxy.sh b/bash/proxy.sh index 0ccc891..dd154a6 100644 --- a/bash/proxy.sh +++ b/bash/proxy.sh @@ -1,8 +1,8 @@ socks() { local value case "${1}" in - "on") value="manual" ;; - *) value="none" ;; + "on") value="manual" ;; + *) value="none" ;; esac gsettings set "org.gnome.system.proxy" "mode" "${value}" } From 76225ff81532d7733317b1a432a9d10c323e7761 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 11:43:12 +0100 Subject: [PATCH 515/969] quote --- bash/fs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/fs.sh b/bash/fs.sh index 9c1d122..5b53b9a 100644 --- a/bash/fs.sh +++ b/bash/fs.sh @@ -71,7 +71,7 @@ fs_wipe() { fi if [ -n "${count}" ]; then set -- "${@}" \ - count=${count} + count="${count}" fi dd "${@}" fi From 7398fa0726d88e9626433917b1f8daff6bcadec3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 11:55:48 +0100 Subject: [PATCH 516/969] rc/. --- bash/.shellcheckrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/.shellcheckrc b/bash/.shellcheckrc index 4a9be0e..173f983 100644 --- a/bash/.shellcheckrc +++ b/bash/.shellcheckrc @@ -1,3 +1,3 @@ -disable=3043 +disable=1090,3043 enable=all shell=sh From 28330ca3c8886b77e15d98450480a058da3d1b19 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 11:57:56 +0100 Subject: [PATCH 517/969] path,root --- bash/main.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index bbfcc87..c12cdf8 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -14,8 +14,10 @@ main_link_bashrc() { main_import_modules() { local file="${1}" if [ -f "${file}" ]; then - local path="$(realpath "${file}")" - local root="$(dirname "${path}")" + local path + local root + path="$(realpath "${file}")" + root="$(dirname "${path}")" local IFS=$'\n' local modules=($(find "${root}" -type "f" -name "*.sh" | sort)) local module From f332104d12f3a672f3920c208be732360b6d9153 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 12:03:00 +0100 Subject: [PATCH 518/969] main_get_root --- bash/main.sh | 4 +++- bash/rescue.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index c12cdf8..5237bd3 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -2,7 +2,9 @@ MAIN_USERS_FILE="$(realpath --canonicalize-existing "${BASH_SOURCE[0]}")" -MAIN_USERS_ROOT="$(dirname "${MAIN_USERS_FILE}")" +main_get_root() { + dirname "${MAIN_USERS_FILE}" +} main_link_bashrc() { local file="/etc/bash.bashrc" diff --git a/bash/rescue.sh b/bash/rescue.sh index e7ff374..0d14bbd 100644 --- a/bash/rescue.sh +++ b/bash/rescue.sh @@ -85,7 +85,7 @@ rescue_upload() { "${user_host}" # upload root rsync --delete --recursive \ - "${MAIN_USERS_ROOT}/" "${user_host}:/etc/bash/" + "$(main_get_root)/" "${user_host}:/etc/bash/" # call setup # TODO variable ssh "${user_host}" -- "\ From dae14f780e7584e0691e64dbe3298b945fc2c27b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 12:08:04 +0100 Subject: [PATCH 519/969] log/prefix --- bash/log.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bash/log.sh b/bash/log.sh index 069377e..1891609 100644 --- a/bash/log.sh +++ b/bash/log.sh @@ -9,19 +9,19 @@ LOG_LEVEL=${LOG_LEVEL_INFO} log_debug() { if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_DEBUG}" ]; then - echo "${@}" + echo "[DEBUG]" "${@}" fi } log_error() { if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_ERROR}" ]; then - echo "${@}" + echo "[ERROR]" "${@}" fi } log_fatal() { if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_FATAL}" ]; then - echo "${@}" + echo "[FATAL]" "${@}" fi } @@ -33,12 +33,12 @@ log_info() { log_trace() { if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_TRACE}" ]; then - echo "${@}" + echo "[TRACE]" "${@}" fi } log_warn() { if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_WARN}" ]; then - echo "${@}" + echo " [WARN]" "${@}" fi } From 2a568eeb221079ac69d840246e35882a4d3e0a15 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 12:41:37 +0100 Subject: [PATCH 520/969] ifs --- bash/main.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index 5237bd3..029e6f4 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -16,19 +16,20 @@ main_link_bashrc() { main_import_modules() { local file="${1}" if [ -f "${file}" ]; then - local path - local root - path="$(realpath "${file}")" + local ifs module modules path root + path="$(realpath --canonicalize-existing "${file}")" root="$(dirname "${path}")" - local IFS=$'\n' - local modules=($(find "${root}" -type "f" -name "*.sh" | sort)) - local module - for module in "${modules[@]}"; do + modules="$(find "${root}" -type "f" -name "*.sh" | sort)" + ifs="${IFS}" + IFS=" +" + for module in ${modules}; do if [ "${module}" != "${path}" ]; then . "${module}" fi done - log_trace "${modules[@]}" + IFS="${ifs}" + log_trace "${modules}" return 0 else log_fatal "No file: ${file}" From 458e4b60f6ada50582b7011d63dd0aacd72ea1e1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 12:50:49 +0100 Subject: [PATCH 521/969] relative --- bash/main.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bash/main.sh b/bash/main.sh index 029e6f4..6adce22 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -19,11 +19,13 @@ main_import_modules() { local ifs module modules path root path="$(realpath --canonicalize-existing "${file}")" root="$(dirname "${path}")" - modules="$(find "${root}" -type "f" -name "*.sh" | sort)" + modules="$(find "${root}" -type "f" -name "*.sh" -printf "%P +" | sort)" ifs="${IFS}" IFS=" " for module in ${modules}; do + module="${root}/${module}" if [ "${module}" != "${path}" ]; then . "${module}" fi From 3b062767c3e31cbe4a603d6f3ad422ce40d4805e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 12:55:14 +0100 Subject: [PATCH 522/969] log --- bash/main.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bash/main.sh b/bash/main.sh index 6adce22..540747f 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -31,7 +31,9 @@ main_import_modules() { fi done IFS="${ifs}" - log_trace "${modules}" + log_info + log_info "${root}" + log_info "${modules}" return 0 else log_fatal "No file: ${file}" From c4e9f06cb24d925fbed0720e580015e4f65e3f3c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 13:08:09 +0100 Subject: [PATCH 523/969] stty --- bash/util.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bash/util.sh b/bash/util.sh index 458995f..8a345ba 100644 --- a/bash/util.sh +++ b/bash/util.sh @@ -14,7 +14,9 @@ read_secret() { local prompt="${1}" local secret printf "%s" "${prompt}" 1>&2 - read -r -s secret + stty -echo + read -r secret + stty echo echo >&2 echo "${secret}" unset secret From 818f48d92f4239712fdcbdc3d879883483edeba6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 13:10:19 +0100 Subject: [PATCH 524/969] -n --- bash/bash/prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/bash/prompt.sh b/bash/bash/prompt.sh index d77a307..73ef1ff 100644 --- a/bash/bash/prompt.sh +++ b/bash/bash/prompt.sh @@ -14,7 +14,7 @@ ps1() { view="${view}${code}\e[0m @ \e[0;33m${date}\e[0m" if [ "$(type -t __git_ps1)" == "function" ]; then git="$(__git_ps1)" - if [ "${git}" ]; then + if [ -n "${git}" ]; then view="${view} –\e[0;35m${git}\e[0m" fi fi From 87c53a18bafc1bdbd6ca05b91a4f9dd6e6131340 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 13:14:58 +0100 Subject: [PATCH 525/969] lint --- bash/bash/prompt.sh | 9 +++++---- bash/fs.sh | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bash/bash/prompt.sh b/bash/bash/prompt.sh index 73ef1ff..5ba1159 100644 --- a/bash/bash/prompt.sh +++ b/bash/bash/prompt.sh @@ -1,12 +1,13 @@ ps1() { - local code=${1} - local date="$(date +%H:%M:%S)" + local date host + local code="${1}" + date="$(date +%H:%M:%S)" local git - local host="$(hostname)" + host="$(hostname)" local path="${PWD}" local user="${USER}" local view="└ " - if [ ${code} -ne 0 ]; then + if [ "${code}" -ne 0 ]; then view="${view}\e[0;31m" else view="${view}\e[0;32m" diff --git a/bash/fs.sh b/bash/fs.sh index 5b53b9a..05ac088 100644 --- a/bash/fs.sh +++ b/bash/fs.sh @@ -23,7 +23,7 @@ fs_make_btrfs_swap() { local size="${2}" local uuid="${3}" if [ -n "${path}" ]; then - set filesystem mkswapfile + set -- filesystem mkswapfile if [ -n "${size}" ]; then set -- "${@}" \ --size "${size}" From d028d83f7ac722463347eacbc267b528fd37de90 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 13:54:13 +0100 Subject: [PATCH 526/969] number --- bash/rescue-hetzner.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 81930b4..ee68157 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -16,7 +16,7 @@ rescue_wipe_0_init_hetzner_8_8() { # number=0 for device in "${devices[@]}"; do - ((number++)) + number=$((number + 1)) echo echo "#${number}: ${device}" # @@ -33,7 +33,7 @@ rescue_wipe_0_init_hetzner_8_8() { # number=0 for device in "${devices[@]}"; do - ((number++)) + number=$((number + 1)) echo echo "#${number}: ${device}4" # wipe bios @@ -42,7 +42,7 @@ rescue_wipe_0_init_hetzner_8_8() { # number=0 for device in "${devices[@]}"; do - ((number++)) + number=$((number + 1)) echo echo "#${number}: ${device}3" # format esp @@ -55,7 +55,7 @@ rescue_wipe_0_init_hetzner_8_8() { # number=0 for device in "${devices[@]}"; do - ((number++)) + number=$((number + 1)) echo echo "#${number}: ${device}2" # wipe boot @@ -85,7 +85,7 @@ rescue_wipe_0_init_hetzner_8_8() { # number=0 for device in "${devices[@]}"; do - ((number++)) + number=$((number + 1)) echo echo "#${number}: ${device}1" # wipe crypt head From 8d53e86bcdace9881ac3f1738bc5ff26b1edb2c3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 14:00:10 +0100 Subject: [PATCH 527/969] devices --- bash/rescue-hetzner.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index ee68157..82694d6 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -1,9 +1,8 @@ rescue_wipe_0_init_hetzner_8_8() { local device - local devices=( - "/dev/sda" + set \ + "/dev/sda" \ "/dev/sdb" - ) local members local number local passphrase @@ -11,11 +10,11 @@ rescue_wipe_0_init_hetzner_8_8() { passphrase="$(read_passphrase)" # lsblk - echo -n "WIPE" "${devices[@]}" "/?\\ OR CANCEL /!\\" + echo -n "WIPE" "${@}" "/?\\ OR CANCEL /!\\" read -r # number=0 - for device in "${devices[@]}"; do + for device in "${@}"; do number=$((number + 1)) echo echo "#${number}: ${device}" @@ -32,7 +31,7 @@ rescue_wipe_0_init_hetzner_8_8() { done # number=0 - for device in "${devices[@]}"; do + for device in "${@}"; do number=$((number + 1)) echo echo "#${number}: ${device}4" @@ -41,7 +40,7 @@ rescue_wipe_0_init_hetzner_8_8() { done # number=0 - for device in "${devices[@]}"; do + for device in "${@}"; do number=$((number + 1)) echo echo "#${number}: ${device}3" @@ -54,7 +53,7 @@ rescue_wipe_0_init_hetzner_8_8() { done # number=0 - for device in "${devices[@]}"; do + for device in "${@}"; do number=$((number + 1)) echo echo "#${number}: ${device}2" @@ -63,7 +62,7 @@ rescue_wipe_0_init_hetzner_8_8() { done # members=() - for device in "${devices[@]}"; do + for device in "${@}"; do members+=("${device}2") done mdadm \ @@ -71,7 +70,7 @@ rescue_wipe_0_init_hetzner_8_8() { --level 0 \ --metadata 1 \ --name "md:boot" \ - --raid-devices ${#devices[@]} \ + --raid-devices ${#} \ --uuid "00000000:00000000:00000000:00000002" \ "${members[@]}" # @@ -84,7 +83,7 @@ rescue_wipe_0_init_hetzner_8_8() { "/dev/md/boot" "/media/boot" # number=0 - for device in "${devices[@]}"; do + for device in "${@}"; do number=$((number + 1)) echo echo "#${number}: ${device}1" @@ -93,7 +92,7 @@ rescue_wipe_0_init_hetzner_8_8() { done # members=() - for device in "${devices[@]}"; do + for device in "${@}"; do members+=("${device}1") done mdadm \ @@ -101,7 +100,7 @@ rescue_wipe_0_init_hetzner_8_8() { --level 0 \ --metadata 1 \ --name "md:crypt" \ - --raid-devices ${#devices[@]} \ + --raid-devices ${#} \ --uuid "00000000:00000000:00000000:00000001" \ "${members[@]}" # encrypt From 2722134a0f7beda608b211efec7b76c23203b44c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 14:24:58 +0100 Subject: [PATCH 528/969] raid_create --- bash/fs.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bash/fs.sh b/bash/fs.sh index 05ac088..005a56d 100644 --- a/bash/fs.sh +++ b/bash/fs.sh @@ -103,3 +103,19 @@ luks_format() { cryptsetup "${@}" luksFormat "${device}" fi } + +raid_create() { + if [ -n "${4}" ]; then + local name="${1}" + local uuid="${2}" + shift 2 + mdadm \ + --create "/dev/md/${name}" \ + --level 0 \ + --metadata 1 \ + --name "md:${name}" \ + --raid-devices ${#} \ + --uuid "${uuid}" \ + "${@}" + fi +} From 6603c88198a0989079947408df72d091fc867390 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 14:30:50 +0100 Subject: [PATCH 529/969] raids --- bash/fs.sh | 32 ++++++++++++++++---------------- bash/rescue-hetzner.sh | 20 ++++---------------- 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/bash/fs.sh b/bash/fs.sh index 005a56d..2635ce0 100644 --- a/bash/fs.sh +++ b/bash/fs.sh @@ -56,6 +56,22 @@ fs_make_fat() { fi } +fs_raid_create() { + if [ -n "${4}" ]; then + local name="${1}" + local uuid="${2}" + shift 2 + mdadm \ + --create "/dev/md/${name}" \ + --level 0 \ + --metadata 1 \ + --name "md:${name}" \ + --raid-devices ${#} \ + --uuid "${uuid}" \ + "${@}" + fi +} + fs_wipe() { local device="${1}" local buffer="${2}" @@ -103,19 +119,3 @@ luks_format() { cryptsetup "${@}" luksFormat "${device}" fi } - -raid_create() { - if [ -n "${4}" ]; then - local name="${1}" - local uuid="${2}" - shift 2 - mdadm \ - --create "/dev/md/${name}" \ - --level 0 \ - --metadata 1 \ - --name "md:${name}" \ - --raid-devices ${#} \ - --uuid "${uuid}" \ - "${@}" - fi -} diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 82694d6..0417230 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -65,14 +65,8 @@ rescue_wipe_0_init_hetzner_8_8() { for device in "${@}"; do members+=("${device}2") done - mdadm \ - --create "/dev/md/boot" \ - --level 0 \ - --metadata 1 \ - --name "md:boot" \ - --raid-devices ${#} \ - --uuid "00000000:00000000:00000000:00000002" \ - "${members[@]}" + fs_raid_create \ + "boot" "00000000:00000000:00000000:00000002" "${members[@]}" # fs_make_btrfs "/dev/md/boot" "boot" \ "00000000-0000-0000-0000-00000000000b" @@ -95,14 +89,8 @@ rescue_wipe_0_init_hetzner_8_8() { for device in "${@}"; do members+=("${device}1") done - mdadm \ - --create "/dev/md/crypt" \ - --level 0 \ - --metadata 1 \ - --name "md:crypt" \ - --raid-devices ${#} \ - --uuid "00000000:00000000:00000000:00000001" \ - "${members[@]}" + fs_raid_create \ + "crypt" "00000000:00000000:00000000:00000001" "${members[@]}" # encrypt luks_format "${passphrase}" "/dev/md/crypt" # open From 216fe057c915ae664dc69da87a460c7c1e0c8e01 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 14:38:35 +0100 Subject: [PATCH 530/969] echoes --- bash/main.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index 540747f..9125fc9 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -19,21 +19,21 @@ main_import_modules() { local ifs module modules path root path="$(realpath --canonicalize-existing "${file}")" root="$(dirname "${path}")" + echo + echo "${root}" modules="$(find "${root}" -type "f" -name "*.sh" -printf "%P " | sort)" ifs="${IFS}" IFS=" " for module in ${modules}; do + echo "${module%.sh}" module="${root}/${module}" if [ "${module}" != "${path}" ]; then . "${module}" fi done IFS="${ifs}" - log_info - log_info "${root}" - log_info "${modules}" return 0 else log_fatal "No file: ${file}" From 8982496082a7621f72e19e6653965a236e326f79 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 14:55:20 +0100 Subject: [PATCH 531/969] count --- bash/main.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index 9125fc9..b809dfe 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -16,18 +16,21 @@ main_link_bashrc() { main_import_modules() { local file="${1}" if [ -f "${file}" ]; then - local ifs module modules path root + local count ifs module modules path root path="$(realpath --canonicalize-existing "${file}")" root="$(dirname "${path}")" - echo - echo "${root}" modules="$(find "${root}" -type "f" -name "*.sh" -printf "%P " | sort)" ifs="${IFS}" IFS=" " + count=0 + echo + echo "${root}" for module in ${modules}; do - echo "${module%.sh}" + count=$((count + 1)) + printf "%02d" "${count}" + echo " ${module%.sh}" module="${root}/${module}" if [ "${module}" != "${path}" ]; then . "${module}" From 00183fecc18e0fa411797333d7b8ea4bd22e6164 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 15:01:02 +0100 Subject: [PATCH 532/969] . --- bash/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/main.sh b/bash/main.sh index b809dfe..c692412 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -26,7 +26,7 @@ main_import_modules() { " count=0 echo - echo "${root}" + echo ". ${root}" for module in ${modules}; do count=$((count + 1)) printf "%02d" "${count}" From 05710e7ef7cafb3b0043ce10d90550d4c0d3763e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 14 Nov 2024 00:07:05 +0100 Subject: [PATCH 533/969] rescue/ --- bash/{rescue.sh => rescue/common.sh} | 0 bash/{rescue-hetzner.sh => rescue/hetzner.sh} | 0 bash/{rescue-ovh.sh => rescue/ovh.sh} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename bash/{rescue.sh => rescue/common.sh} (100%) rename bash/{rescue-hetzner.sh => rescue/hetzner.sh} (100%) rename bash/{rescue-ovh.sh => rescue/ovh.sh} (100%) diff --git a/bash/rescue.sh b/bash/rescue/common.sh similarity index 100% rename from bash/rescue.sh rename to bash/rescue/common.sh diff --git a/bash/rescue-hetzner.sh b/bash/rescue/hetzner.sh similarity index 100% rename from bash/rescue-hetzner.sh rename to bash/rescue/hetzner.sh diff --git a/bash/rescue-ovh.sh b/bash/rescue/ovh.sh similarity index 100% rename from bash/rescue-ovh.sh rename to bash/rescue/ovh.sh From 672b385447efb5b39f7fcaa4b4a5fbfa963706f7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Nov 2024 16:26:54 +0100 Subject: [PATCH 534/969] wip/env --- bash/main.sh | 10 +++------- bash/rescue/common.sh | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index c692412..ff56a3c 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -1,9 +1,5 @@ -#! /usr/bin/env bash - -MAIN_USERS_FILE="$(realpath --canonicalize-existing "${BASH_SOURCE[0]}")" - -main_get_root() { - dirname "${MAIN_USERS_FILE}" +main_env_root() { + dirname "${ENV}" } main_link_bashrc() { @@ -45,4 +41,4 @@ main_import_modules() { } # import modules -main_import_modules "${MAIN_USERS_FILE}" +main_import_modules "${ENV}" diff --git a/bash/rescue/common.sh b/bash/rescue/common.sh index 0d14bbd..3671d15 100644 --- a/bash/rescue/common.sh +++ b/bash/rescue/common.sh @@ -85,7 +85,7 @@ rescue_upload() { "${user_host}" # upload root rsync --delete --recursive \ - "$(main_get_root)/" "${user_host}:/etc/bash/" + "$(main_env_root)" "${user_host}:/etc" # call setup # TODO variable ssh "${user_host}" -- "\ From f52abc28b34fe72c6156aeaaabba50b1b02726a8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Nov 2024 16:27:41 +0100 Subject: [PATCH 535/969] wip/shell --- {bash => shell}/.shellcheckrc | 0 {bash => shell}/alias/apt.sh | 0 {bash => shell}/alias/bash.sh | 0 {bash => shell}/alias/batcat.sh | 0 {bash => shell}/alias/btrfs.sh | 0 {bash => shell}/alias/byobu.sh | 0 {bash => shell}/alias/chmod.sh | 0 {bash => shell}/alias/chown.sh | 0 {bash => shell}/alias/clear.sh | 0 {bash => shell}/alias/cp.sh | 0 {bash => shell}/alias/emacs.sh | 0 {bash => shell}/alias/evince.sh | 0 {bash => shell}/alias/git.sh | 0 {bash => shell}/alias/gpg.sh | 0 {bash => shell}/alias/grep.sh | 0 {bash => shell}/alias/kill.sh | 0 {bash => shell}/alias/killall.sh | 0 {bash => shell}/alias/ls.sh | 0 {bash => shell}/alias/lsblk.sh | 0 {bash => shell}/alias/micro.sh | 0 {bash => shell}/alias/mkdir.sh | 0 {bash => shell}/alias/mount.sh | 0 {bash => shell}/alias/mv.sh | 0 {bash => shell}/alias/nano.sh | 0 {bash => shell}/alias/newsboat.sh | 0 {bash => shell}/alias/otpclient-cli.sh | 0 {bash => shell}/alias/pass.sh | 0 {bash => shell}/alias/ps.sh | 0 {bash => shell}/alias/pwgen.sh | 0 {bash => shell}/alias/rsync.sh | 0 {bash => shell}/alias/tar.sh | 0 {bash => shell}/alias/tree.sh | 0 {bash => shell}/apt.sh | 0 {bash => shell}/bash/completion.sh | 0 {bash => shell}/bash/history.sh | 0 {bash => shell}/bash/prompt.sh | 0 {bash => shell}/btrfs.sh | 0 {bash => shell}/debian.sh | 0 {bash => shell}/fs.sh | 0 {bash => shell}/gpg.sh | 0 {bash => shell}/gsettings.sh | 0 {bash => shell}/log.sh | 0 {bash => shell}/main.sh | 0 {bash => shell}/mount-lxc.sh | 0 {bash => shell}/mount.sh | 0 {bash => shell}/proxy.sh | 0 {bash => shell}/rescue/common.sh | 0 {bash => shell}/rescue/hetzner.sh | 0 {bash => shell}/rescue/ovh.sh | 0 {bash => shell}/util.sh | 0 50 files changed, 0 insertions(+), 0 deletions(-) rename {bash => shell}/.shellcheckrc (100%) rename {bash => shell}/alias/apt.sh (100%) rename {bash => shell}/alias/bash.sh (100%) rename {bash => shell}/alias/batcat.sh (100%) rename {bash => shell}/alias/btrfs.sh (100%) rename {bash => shell}/alias/byobu.sh (100%) rename {bash => shell}/alias/chmod.sh (100%) rename {bash => shell}/alias/chown.sh (100%) rename {bash => shell}/alias/clear.sh (100%) rename {bash => shell}/alias/cp.sh (100%) rename {bash => shell}/alias/emacs.sh (100%) rename {bash => shell}/alias/evince.sh (100%) rename {bash => shell}/alias/git.sh (100%) rename {bash => shell}/alias/gpg.sh (100%) rename {bash => shell}/alias/grep.sh (100%) rename {bash => shell}/alias/kill.sh (100%) rename {bash => shell}/alias/killall.sh (100%) rename {bash => shell}/alias/ls.sh (100%) rename {bash => shell}/alias/lsblk.sh (100%) rename {bash => shell}/alias/micro.sh (100%) rename {bash => shell}/alias/mkdir.sh (100%) rename {bash => shell}/alias/mount.sh (100%) rename {bash => shell}/alias/mv.sh (100%) rename {bash => shell}/alias/nano.sh (100%) rename {bash => shell}/alias/newsboat.sh (100%) rename {bash => shell}/alias/otpclient-cli.sh (100%) rename {bash => shell}/alias/pass.sh (100%) rename {bash => shell}/alias/ps.sh (100%) rename {bash => shell}/alias/pwgen.sh (100%) rename {bash => shell}/alias/rsync.sh (100%) rename {bash => shell}/alias/tar.sh (100%) rename {bash => shell}/alias/tree.sh (100%) rename {bash => shell}/apt.sh (100%) rename {bash => shell}/bash/completion.sh (100%) rename {bash => shell}/bash/history.sh (100%) rename {bash => shell}/bash/prompt.sh (100%) rename {bash => shell}/btrfs.sh (100%) rename {bash => shell}/debian.sh (100%) rename {bash => shell}/fs.sh (100%) rename {bash => shell}/gpg.sh (100%) rename {bash => shell}/gsettings.sh (100%) rename {bash => shell}/log.sh (100%) rename {bash => shell}/main.sh (100%) rename {bash => shell}/mount-lxc.sh (100%) rename {bash => shell}/mount.sh (100%) rename {bash => shell}/proxy.sh (100%) rename {bash => shell}/rescue/common.sh (100%) rename {bash => shell}/rescue/hetzner.sh (100%) rename {bash => shell}/rescue/ovh.sh (100%) rename {bash => shell}/util.sh (100%) diff --git a/bash/.shellcheckrc b/shell/.shellcheckrc similarity index 100% rename from bash/.shellcheckrc rename to shell/.shellcheckrc diff --git a/bash/alias/apt.sh b/shell/alias/apt.sh similarity index 100% rename from bash/alias/apt.sh rename to shell/alias/apt.sh diff --git a/bash/alias/bash.sh b/shell/alias/bash.sh similarity index 100% rename from bash/alias/bash.sh rename to shell/alias/bash.sh diff --git a/bash/alias/batcat.sh b/shell/alias/batcat.sh similarity index 100% rename from bash/alias/batcat.sh rename to shell/alias/batcat.sh diff --git a/bash/alias/btrfs.sh b/shell/alias/btrfs.sh similarity index 100% rename from bash/alias/btrfs.sh rename to shell/alias/btrfs.sh diff --git a/bash/alias/byobu.sh b/shell/alias/byobu.sh similarity index 100% rename from bash/alias/byobu.sh rename to shell/alias/byobu.sh diff --git a/bash/alias/chmod.sh b/shell/alias/chmod.sh similarity index 100% rename from bash/alias/chmod.sh rename to shell/alias/chmod.sh diff --git a/bash/alias/chown.sh b/shell/alias/chown.sh similarity index 100% rename from bash/alias/chown.sh rename to shell/alias/chown.sh diff --git a/bash/alias/clear.sh b/shell/alias/clear.sh similarity index 100% rename from bash/alias/clear.sh rename to shell/alias/clear.sh diff --git a/bash/alias/cp.sh b/shell/alias/cp.sh similarity index 100% rename from bash/alias/cp.sh rename to shell/alias/cp.sh diff --git a/bash/alias/emacs.sh b/shell/alias/emacs.sh similarity index 100% rename from bash/alias/emacs.sh rename to shell/alias/emacs.sh diff --git a/bash/alias/evince.sh b/shell/alias/evince.sh similarity index 100% rename from bash/alias/evince.sh rename to shell/alias/evince.sh diff --git a/bash/alias/git.sh b/shell/alias/git.sh similarity index 100% rename from bash/alias/git.sh rename to shell/alias/git.sh diff --git a/bash/alias/gpg.sh b/shell/alias/gpg.sh similarity index 100% rename from bash/alias/gpg.sh rename to shell/alias/gpg.sh diff --git a/bash/alias/grep.sh b/shell/alias/grep.sh similarity index 100% rename from bash/alias/grep.sh rename to shell/alias/grep.sh diff --git a/bash/alias/kill.sh b/shell/alias/kill.sh similarity index 100% rename from bash/alias/kill.sh rename to shell/alias/kill.sh diff --git a/bash/alias/killall.sh b/shell/alias/killall.sh similarity index 100% rename from bash/alias/killall.sh rename to shell/alias/killall.sh diff --git a/bash/alias/ls.sh b/shell/alias/ls.sh similarity index 100% rename from bash/alias/ls.sh rename to shell/alias/ls.sh diff --git a/bash/alias/lsblk.sh b/shell/alias/lsblk.sh similarity index 100% rename from bash/alias/lsblk.sh rename to shell/alias/lsblk.sh diff --git a/bash/alias/micro.sh b/shell/alias/micro.sh similarity index 100% rename from bash/alias/micro.sh rename to shell/alias/micro.sh diff --git a/bash/alias/mkdir.sh b/shell/alias/mkdir.sh similarity index 100% rename from bash/alias/mkdir.sh rename to shell/alias/mkdir.sh diff --git a/bash/alias/mount.sh b/shell/alias/mount.sh similarity index 100% rename from bash/alias/mount.sh rename to shell/alias/mount.sh diff --git a/bash/alias/mv.sh b/shell/alias/mv.sh similarity index 100% rename from bash/alias/mv.sh rename to shell/alias/mv.sh diff --git a/bash/alias/nano.sh b/shell/alias/nano.sh similarity index 100% rename from bash/alias/nano.sh rename to shell/alias/nano.sh diff --git a/bash/alias/newsboat.sh b/shell/alias/newsboat.sh similarity index 100% rename from bash/alias/newsboat.sh rename to shell/alias/newsboat.sh diff --git a/bash/alias/otpclient-cli.sh b/shell/alias/otpclient-cli.sh similarity index 100% rename from bash/alias/otpclient-cli.sh rename to shell/alias/otpclient-cli.sh diff --git a/bash/alias/pass.sh b/shell/alias/pass.sh similarity index 100% rename from bash/alias/pass.sh rename to shell/alias/pass.sh diff --git a/bash/alias/ps.sh b/shell/alias/ps.sh similarity index 100% rename from bash/alias/ps.sh rename to shell/alias/ps.sh diff --git a/bash/alias/pwgen.sh b/shell/alias/pwgen.sh similarity index 100% rename from bash/alias/pwgen.sh rename to shell/alias/pwgen.sh diff --git a/bash/alias/rsync.sh b/shell/alias/rsync.sh similarity index 100% rename from bash/alias/rsync.sh rename to shell/alias/rsync.sh diff --git a/bash/alias/tar.sh b/shell/alias/tar.sh similarity index 100% rename from bash/alias/tar.sh rename to shell/alias/tar.sh diff --git a/bash/alias/tree.sh b/shell/alias/tree.sh similarity index 100% rename from bash/alias/tree.sh rename to shell/alias/tree.sh diff --git a/bash/apt.sh b/shell/apt.sh similarity index 100% rename from bash/apt.sh rename to shell/apt.sh diff --git a/bash/bash/completion.sh b/shell/bash/completion.sh similarity index 100% rename from bash/bash/completion.sh rename to shell/bash/completion.sh diff --git a/bash/bash/history.sh b/shell/bash/history.sh similarity index 100% rename from bash/bash/history.sh rename to shell/bash/history.sh diff --git a/bash/bash/prompt.sh b/shell/bash/prompt.sh similarity index 100% rename from bash/bash/prompt.sh rename to shell/bash/prompt.sh diff --git a/bash/btrfs.sh b/shell/btrfs.sh similarity index 100% rename from bash/btrfs.sh rename to shell/btrfs.sh diff --git a/bash/debian.sh b/shell/debian.sh similarity index 100% rename from bash/debian.sh rename to shell/debian.sh diff --git a/bash/fs.sh b/shell/fs.sh similarity index 100% rename from bash/fs.sh rename to shell/fs.sh diff --git a/bash/gpg.sh b/shell/gpg.sh similarity index 100% rename from bash/gpg.sh rename to shell/gpg.sh diff --git a/bash/gsettings.sh b/shell/gsettings.sh similarity index 100% rename from bash/gsettings.sh rename to shell/gsettings.sh diff --git a/bash/log.sh b/shell/log.sh similarity index 100% rename from bash/log.sh rename to shell/log.sh diff --git a/bash/main.sh b/shell/main.sh similarity index 100% rename from bash/main.sh rename to shell/main.sh diff --git a/bash/mount-lxc.sh b/shell/mount-lxc.sh similarity index 100% rename from bash/mount-lxc.sh rename to shell/mount-lxc.sh diff --git a/bash/mount.sh b/shell/mount.sh similarity index 100% rename from bash/mount.sh rename to shell/mount.sh diff --git a/bash/proxy.sh b/shell/proxy.sh similarity index 100% rename from bash/proxy.sh rename to shell/proxy.sh diff --git a/bash/rescue/common.sh b/shell/rescue/common.sh similarity index 100% rename from bash/rescue/common.sh rename to shell/rescue/common.sh diff --git a/bash/rescue/hetzner.sh b/shell/rescue/hetzner.sh similarity index 100% rename from bash/rescue/hetzner.sh rename to shell/rescue/hetzner.sh diff --git a/bash/rescue/ovh.sh b/shell/rescue/ovh.sh similarity index 100% rename from bash/rescue/ovh.sh rename to shell/rescue/ovh.sh diff --git a/bash/util.sh b/shell/util.sh similarity index 100% rename from bash/util.sh rename to shell/util.sh From 52e7cf8f9cb2efce6519a0e5a5433149c7b10616 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Nov 2024 16:43:48 +0100 Subject: [PATCH 536/969] wip/default --- shell/main.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/main.sh b/shell/main.sh index ff56a3c..f39c92b 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -1,3 +1,5 @@ +[ "${ENV}" ] || export ENV="/etc/shell/main.sh" + main_env_root() { dirname "${ENV}" } @@ -40,5 +42,4 @@ main_import_modules() { fi } -# import modules main_import_modules "${ENV}" From b73663cf4bbe7ddd42de0e869c35b069dbcf7271 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Nov 2024 16:58:16 +0100 Subject: [PATCH 537/969] wip/bash --- shell/{bash/prompt.sh => bash.sh} | 10 ++++++++++ shell/bash/completion.sh | 5 ----- shell/bash/history.sh | 5 ----- 3 files changed, 10 insertions(+), 10 deletions(-) rename shell/{bash/prompt.sh => bash.sh} (81%) delete mode 100644 shell/bash/completion.sh delete mode 100644 shell/bash/history.sh diff --git a/shell/bash/prompt.sh b/shell/bash.sh similarity index 81% rename from shell/bash/prompt.sh rename to shell/bash.sh index 5ba1159..7b0f3c7 100644 --- a/shell/bash/prompt.sh +++ b/shell/bash.sh @@ -1,3 +1,13 @@ +HISTCONTROL="ignorespace" + +HISTSIZE=-1 + +HISTTIMEFORMAT="%Y%m%d %H%M%S " +file="/usr/share/bash-completion/bash_completion" + +if [ -f "${file}" ]; then + . "${file}" +fi ps1() { local date host local code="${1}" diff --git a/shell/bash/completion.sh b/shell/bash/completion.sh deleted file mode 100644 index 21e8a21..0000000 --- a/shell/bash/completion.sh +++ /dev/null @@ -1,5 +0,0 @@ -file="/usr/share/bash-completion/bash_completion" - -if [ -f "${file}" ]; then - . "${file}" -fi diff --git a/shell/bash/history.sh b/shell/bash/history.sh deleted file mode 100644 index 59234ad..0000000 --- a/shell/bash/history.sh +++ /dev/null @@ -1,5 +0,0 @@ -HISTCONTROL="ignorespace" - -HISTSIZE=-1 - -HISTTIMEFORMAT="%Y%m%d %H%M%S " From 1486ff4246e30be8312bf7338d5bb1fb7ccaff9d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Nov 2024 17:06:29 +0100 Subject: [PATCH 538/969] wip/bash --- shell/bash.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/shell/bash.sh b/shell/bash.sh index 7b0f3c7..9e2b27e 100644 --- a/shell/bash.sh +++ b/shell/bash.sh @@ -1,13 +1,23 @@ -HISTCONTROL="ignorespace" +[ "$(cat /proc/$$/comm)" = "bash" ] || return -HISTSIZE=-1 +# completion -HISTTIMEFORMAT="%Y%m%d %H%M%S " file="/usr/share/bash-completion/bash_completion" if [ -f "${file}" ]; then . "${file}" fi + +# history + +HISTCONTROL="ignorespace" + +HISTSIZE=-1 + +HISTTIMEFORMAT="%Y%m%d %H%M%S " + +# prompt + ps1() { local date host local code="${1}" From 4f6e6e7ba20bdb7189012ad82ad4e152e080f597 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Nov 2024 17:07:19 +0100 Subject: [PATCH 539/969] wip/hetzner --- shell/rescue/hetzner.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shell/rescue/hetzner.sh b/shell/rescue/hetzner.sh index 0417230..d5ec527 100644 --- a/shell/rescue/hetzner.sh +++ b/shell/rescue/hetzner.sh @@ -1,3 +1,5 @@ +[ "$(cat /proc/$$/comm)" = "bash" ] || return + rescue_wipe_0_init_hetzner_8_8() { local device set \ From ba5d7403622fed72327fe11848922422424d7522 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Nov 2024 17:17:57 +0100 Subject: [PATCH 540/969] wip/user --- shell/main.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/main.sh b/shell/main.sh index f39c92b..ea2f2e1 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -43,3 +43,4 @@ main_import_modules() { } main_import_modules "${ENV}" +main_import_modules ~/shell/main.sh From 6ce158712d909143fbed0b1e3417efa42967cfd4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Nov 2024 19:02:22 +0100 Subject: [PATCH 541/969] wip/path --- shell/main.sh | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/shell/main.sh b/shell/main.sh index ea2f2e1..de250bc 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -10,37 +10,44 @@ main_link_bashrc() { ln --symbolic "${MAIN_USERS_FILE}" "${file}" } -# import modules -main_import_modules() { - local file="${1}" - if [ -f "${file}" ]; then - local count ifs module modules path root - path="$(realpath --canonicalize-existing "${file}")" - root="$(dirname "${path}")" - modules="$(find "${root}" -type "f" -name "*.sh" -printf "%P +main_import_directory() { + local path="${1}" + if [ -d "${path}" ]; then + local count ifs module modules + modules="$(find "${path}" -type "f" -name "*.sh" -printf "%P " | sort)" ifs="${IFS}" IFS=" " count=0 echo - echo ". ${root}" + echo ". ${path}" for module in ${modules}; do count=$((count + 1)) printf "%02d" "${count}" echo " ${module%.sh}" - module="${root}/${module}" - if [ "${module}" != "${path}" ]; then + module="${path}/${module}" + if [ "${module}" != "${ENV}" ]; then . "${module}" fi done IFS="${ifs}" - return 0 else - log_fatal "No file: ${file}" + echo "Not a directory: ${path}" return 1 fi } -main_import_modules "${ENV}" -main_import_modules ~/shell/main.sh +main_import_file() { + local path="${1}" + if [ -f "${path}" ]; then + main_import_directory "$(dirname "${path}")" + else + echo "Not a file: ${path}" + return 1 + fi +} + +main_import_file "${ENV}" + +main_import_directory ~/shell From d7bf240ba0e4bf3d8472820911024baef0d4e6bd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Nov 2024 19:06:14 +0100 Subject: [PATCH 542/969] main_source_ --- shell/main.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/main.sh b/shell/main.sh index de250bc..63e00f6 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -10,7 +10,7 @@ main_link_bashrc() { ln --symbolic "${MAIN_USERS_FILE}" "${file}" } -main_import_directory() { +main_source_directory() { local path="${1}" if [ -d "${path}" ]; then local count ifs module modules @@ -38,7 +38,7 @@ main_import_directory() { fi } -main_import_file() { +main_source_file() { local path="${1}" if [ -f "${path}" ]; then main_import_directory "$(dirname "${path}")" @@ -48,6 +48,6 @@ main_import_file() { fi } -main_import_file "${ENV}" +main_source_file "${ENV}" -main_import_directory ~/shell +main_source_directory ~/shell From 8c5b43a4e8e20247e1d6e73a6194284d40f94621 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Nov 2024 19:10:40 +0100 Subject: [PATCH 543/969] args --- shell/main.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shell/main.sh b/shell/main.sh index 63e00f6..afd1d56 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -14,7 +14,10 @@ main_source_directory() { local path="${1}" if [ -d "${path}" ]; then local count ifs module modules - modules="$(find "${path}" -type "f" -name "*.sh" -printf "%P + modules="$(find "${path}" \ + -type "f" \ + -name "*.sh" \ + -printf "%P " | sort)" ifs="${IFS}" IFS=" From 9b5d0de8407f56914b12563f8edd95778a6a4ca7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Nov 2024 19:11:16 +0100 Subject: [PATCH 544/969] fix --- shell/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/main.sh b/shell/main.sh index afd1d56..a286723 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -44,7 +44,7 @@ main_source_directory() { main_source_file() { local path="${1}" if [ -f "${path}" ]; then - main_import_directory "$(dirname "${path}")" + main_source_directory "$(dirname "${path}")" else echo "Not a file: ${path}" return 1 From 1a05b48cf5de16b2b8419bcacea6d7a340a52da9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Nov 2024 19:20:55 +0100 Subject: [PATCH 545/969] =?UTF-8?q?=E2=88=92apt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/apt.sh | 40 ---------------------------------------- shell/debian.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 40 deletions(-) delete mode 100644 shell/apt.sh diff --git a/shell/apt.sh b/shell/apt.sh deleted file mode 100644 index a0f7353..0000000 --- a/shell/apt.sh +++ /dev/null @@ -1,40 +0,0 @@ -apt_clean() { - apt-get \ - clean -} - -apt_install_backports() { - apt_install_target "${DEBIAN_CODENAME}-backports" "${@}" -} - -apt_install_release() { - apt_install_target "${DEBIAN_CODENAME}" "${@}" -} - -apt_install_target() { - local target="${1}" - shift - local package - for package in "${@}"; do - log_info - log_info "${package} ← ${target}" - apt-get \ - install \ - --assume-yes \ - --target-release "${target}" \ - "${package}" - apt_clean - done -} - -apt_update() { - apt-get \ - update -} - -apt_upgrade() { - apt-get \ - upgrade \ - --assume-yes - apt_clean -} diff --git a/shell/debian.sh b/shell/debian.sh index ffce0da..4ce02de 100644 --- a/shell/debian.sh +++ b/shell/debian.sh @@ -3,6 +3,47 @@ DEBIAN_CODENAME="$( cut --delimiter "=" --fields "2" )" +apt_clean() { + apt-get \ + clean +} + +apt_install_backports() { + apt_install_target "${DEBIAN_CODENAME}-backports" "${@}" +} + +apt_install_release() { + apt_install_target "${DEBIAN_CODENAME}" "${@}" +} + +apt_install_target() { + local target="${1}" + shift + local package + for package in "${@}"; do + log_info + log_info "${package} ← ${target}" + apt-get \ + install \ + --assume-yes \ + --target-release "${target}" \ + "${package}" + apt_clean + done +} + +apt_update() { + apt-get \ + update +} + +apt_upgrade() { + apt-get \ + upgrade \ + --assume-yes + apt_clean +} + debian_disable_frontend() { export DEBIAN_FRONTEND="noninteractive" } From 1d86226365715379255715bd984e90f446aa6c4f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Nov 2024 19:23:33 +0100 Subject: [PATCH 546/969] apt_sources_write --- shell/debian.sh | 13 +++++++++++++ shell/rescue/common.sh | 11 +---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/shell/debian.sh b/shell/debian.sh index 4ce02de..e4085df 100644 --- a/shell/debian.sh +++ b/shell/debian.sh @@ -32,6 +32,19 @@ apt_install_target() { done } +apt_sources_write() { + printf "%s" "\ +deb https://deb.debian.org/debian \ +${DEBIAN_CODENAME} main non-free-firmware contrib non-free +deb https://deb.debian.org/debian \ +${DEBIAN_CODENAME}-backports main non-free-firmware contrib non-free +deb https://deb.debian.org/debian \ +${DEBIAN_CODENAME}-updates main non-free-firmware contrib non-free +deb https://deb.debian.org/debian-security \ +${DEBIAN_CODENAME}-security main non-free-firmware contrib non-free +" >"/etc/apt/sources.list" +} + apt_update() { apt-get \ update diff --git a/shell/rescue/common.sh b/shell/rescue/common.sh index 3671d15..306f7fa 100644 --- a/shell/rescue/common.sh +++ b/shell/rescue/common.sh @@ -13,16 +13,7 @@ Dir::Etc::SourceParts \"\"; Dpkg::Progress True; " >"/etc/apt/apt.conf.d/apt.conf" # apt / sources - printf "%s" "\ -deb https://deb.debian.org/debian \ -${DEBIAN_CODENAME} main non-free-firmware contrib non-free -deb https://deb.debian.org/debian \ -${DEBIAN_CODENAME}-backports main non-free-firmware contrib non-free -deb https://deb.debian.org/debian \ -${DEBIAN_CODENAME}-updates main non-free-firmware contrib non-free -deb https://deb.debian.org/debian-security \ -${DEBIAN_CODENAME}-security main non-free-firmware contrib non-free -" >"/etc/apt/sources.list" + apt_sources_write # bash / rc main_link_bashrc mv .bashrc .bashrc.old From 5ff98571f938315ca665b923fc363fe234421fd3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Nov 2024 19:24:48 +0100 Subject: [PATCH 547/969] apt_conf_write --- shell/debian.sh | 14 ++++++++++++++ shell/rescue/common.sh | 12 +----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/shell/debian.sh b/shell/debian.sh index e4085df..f806ba6 100644 --- a/shell/debian.sh +++ b/shell/debian.sh @@ -8,6 +8,20 @@ apt_clean() { clean } +apt_conf_write() { + printf "\ +Acquire::AllowInsecureRepositories False; +Acquire::AllowWeakRepositories False; +Acquire::AllowDowngradeToInsecureRepositories False; +Acquire::Check-Valid-Until True; +APT::Install-Recommends False; +APT::Install-Suggests False; +APT::Get::Show-Versions True; +Dir::Etc::SourceParts \"\"; +Dpkg::Progress True; +" >"/etc/apt/apt.conf.d/apt.conf" +} + apt_install_backports() { apt_install_target "${DEBIAN_CODENAME}-backports" "${@}" } diff --git a/shell/rescue/common.sh b/shell/rescue/common.sh index 306f7fa..49a9305 100644 --- a/shell/rescue/common.sh +++ b/shell/rescue/common.sh @@ -1,17 +1,7 @@ rescue_configure() { local hostname="${1}" # apt / conf - printf "\ -Acquire::AllowInsecureRepositories False; -Acquire::AllowWeakRepositories False; -Acquire::AllowDowngradeToInsecureRepositories False; -Acquire::Check-Valid-Until True; -APT::Install-Recommends False; -APT::Install-Suggests False; -APT::Get::Show-Versions True; -Dir::Etc::SourceParts \"\"; -Dpkg::Progress True; -" >"/etc/apt/apt.conf.d/apt.conf" + apt_conf_write # apt / sources apt_sources_write # bash / rc From bc7b4962f63bbbd55edfcbed8cc9abf5916fe1de Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Nov 2024 19:29:10 +0100 Subject: [PATCH 548/969] -n --- shell/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/main.sh b/shell/main.sh index a286723..7925a6f 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -1,4 +1,4 @@ -[ "${ENV}" ] || export ENV="/etc/shell/main.sh" +[ -n "${ENV}" ] || export ENV="/etc/shell/main.sh" main_env_root() { dirname "${ENV}" From 4d888d97843583127abea05ad9fdfa464d52b92d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 15 Nov 2024 19:38:54 +0100 Subject: [PATCH 549/969] =?UTF-8?q?=E2=88=92main=5Fenv=5Froot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/main.sh | 4 ---- shell/rescue/common.sh | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/shell/main.sh b/shell/main.sh index 7925a6f..c8d2607 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -1,9 +1,5 @@ [ -n "${ENV}" ] || export ENV="/etc/shell/main.sh" -main_env_root() { - dirname "${ENV}" -} - main_link_bashrc() { local file="/etc/bash.bashrc" rm --force "${file}" diff --git a/shell/rescue/common.sh b/shell/rescue/common.sh index 49a9305..f33c5aa 100644 --- a/shell/rescue/common.sh +++ b/shell/rescue/common.sh @@ -66,11 +66,11 @@ rescue_upload() { "${user_host}" # upload root rsync --delete --recursive \ - "$(main_env_root)" "${user_host}:/etc" + "$(dirname "${ENV}")" "${user_host}:/etc" # call setup # TODO variable - ssh "${user_host}" -- "\ -. \"/etc/bash/main.sh\" ; rescue_configure \"${hostname}\"" + ssh "${user_host}" -- \ + ". \"${ENV}\" ; rescue_configure \"${hostname}\"" # create session ssh "${user_host}" -- byobu new-session -d # send keys From e27dcc2eb3306a59e13a97db5e763f3c6734bafb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 01:23:33 +0100 Subject: [PATCH 550/969] readme --- readme.md | 1 - 1 file changed, 1 deletion(-) diff --git a/readme.md b/readme.md index 4021d7f..9a0b6d3 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,6 @@ ## ToDo -* [ ] import modules recursively * [ ] log * [ ] ovh * [ ] clean apt cache after each install/upgrade step From 4cc5b8a502288415fe593eb8b1ad77fb76e5f0d7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 01:24:20 +0100 Subject: [PATCH 551/969] wip/shell --- shell/{bash.sh => shell.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename shell/{bash.sh => shell.sh} (100%) diff --git a/shell/bash.sh b/shell/shell.sh similarity index 100% rename from shell/bash.sh rename to shell/shell.sh From 62a33a5583853413e151e65783a1f0c086f0537a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 01:41:42 +0100 Subject: [PATCH 552/969] wip/fixes --- shell/shell.sh | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/shell/shell.sh b/shell/shell.sh index 9e2b27e..82a1ed2 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -1,29 +1,30 @@ -[ "$(cat /proc/$$/comm)" = "bash" ] || return +SH="$(cat /proc/$$/comm)" -# completion - -file="/usr/share/bash-completion/bash_completion" - -if [ -f "${file}" ]; then - . "${file}" -fi - -# history - -HISTCONTROL="ignorespace" - -HISTSIZE=-1 - -HISTTIMEFORMAT="%Y%m%d %H%M%S " +case "${SH}" in +"bash") + # completion + file="/usr/share/bash-completion/bash_completion" + if [ -f "${file}" ]; then + . "${file}" + fi + # history + HISTCONTROL="ignorespace" + HISTSIZE=-1 + HISTTIMEFORMAT="%Y%m%d %H%M%S " + ;; +*) + ;; +esac # prompt ps1() { - local date host + local date host id local code="${1}" date="$(date +%H:%M:%S)" local git host="$(hostname)" + id="$(id --user)" local path="${PWD}" local user="${USER}" local view="└ " @@ -33,7 +34,7 @@ ps1() { view="${view}\e[0;32m" fi view="${view}${code}\e[0m @ \e[0;33m${date}\e[0m" - if [ "$(type -t __git_ps1)" == "function" ]; then + if [ "$(type -t __git_ps1)" = "function" ]; then git="$(__git_ps1)" if [ -n "${git}" ]; then view="${view} –\e[0;35m${git}\e[0m" @@ -41,7 +42,7 @@ ps1() { fi view="${view}\n\e[0;36m${path}\e[0m" view="${view}\n┌ " - if [ ${EUID} -eq 0 ]; then + if [ "${id}" -eq 0 ]; then view="${view}\e[0;31m" else view="${view}\e[0;32m" From 347951cbdf3362ddb85849b2a9c1fa3ef4a21d67 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 01:54:13 +0100 Subject: [PATCH 553/969] wip/shell_color --- shell/shell.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/shell/shell.sh b/shell/shell.sh index 82a1ed2..e164562 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -1,5 +1,16 @@ SH="$(cat /proc/$$/comm)" +shell_color() { + local code="${1}" + if [ -n "${code}" ]; then + case "${SH}" in + "bash") printf "\e[0;" ;; + *) printf "\033[" ;; + esac + printf "%s" "${code}m" + fi +} + case "${SH}" in "bash") # completion From ba3b90366b7ca3ad7aab79757430657b9170ecc7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 02:19:41 +0100 Subject: [PATCH 554/969] wip/colors --- shell/shell.sh | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/shell/shell.sh b/shell/shell.sh index e164562..7fde50e 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -2,14 +2,30 @@ SH="$(cat /proc/$$/comm)" shell_color() { local code="${1}" - if [ -n "${code}" ]; then - case "${SH}" in - "bash") printf "\e[0;" ;; - *) printf "\033[" ;; - esac - printf "%s" "${code}m" - fi + case "${SH}" in + "bash") + printf "\e[0" + if [ -n "${code}" ]; then + printf "%s" ";${code}" + fi + ;; + *) + printf "\033[" + if [ -n "${code}" ]; then + printf "%s" "${code}" + else + printf "0" + fi + ;; + esac + printf "m" } +SH_DEFAULT="$(shell_color)" +SH_GREEN="$(shell_color 31)" +SH_RED="$(shell_color 32)" +SH_BROWN="$(shell_color 33)" +SH_MAGENTA="$(shell_color 35)" +SH_CYAN="$(shell_color 36)" case "${SH}" in "bash") @@ -40,25 +56,25 @@ ps1() { local user="${USER}" local view="└ " if [ "${code}" -ne 0 ]; then - view="${view}\e[0;31m" + view="${view}${SH_GREEN}" else - view="${view}\e[0;32m" + view="${view}${SH_RED}" fi - view="${view}${code}\e[0m @ \e[0;33m${date}\e[0m" + view="${view}${code}${SH_DEFAULT} @ ${SH_BROWN}${date}${SH_DEFAULT}" if [ "$(type -t __git_ps1)" = "function" ]; then git="$(__git_ps1)" if [ -n "${git}" ]; then - view="${view} –\e[0;35m${git}\e[0m" + view="${view} –${SH_MAGENTA}${git}${SH_DEFAULT}" fi fi - view="${view}\n\e[0;36m${path}\e[0m" + view="${view}\n${SH_CYAN}${path}${SH_DEFAULT}" view="${view}\n┌ " if [ "${id}" -eq 0 ]; then - view="${view}\e[0;31m" + view="${view}${SH_GREEN}" else - view="${view}\e[0;32m" + view="${view}${SH_RED}" fi - view="${view}${user}\e[0m @ \e[0;33m${host}\e[0m" + view="${view}${user}${SH_DEFAULT} @ ${SH_BROWN}${host}${SH_DEFAULT}" echo -e "${view}\n${PS2}" } From ce576b7a9957f73116de43f983083028f7fa638f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 02:27:43 +0100 Subject: [PATCH 555/969] splits --- shell/shell.sh | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/shell/shell.sh b/shell/shell.sh index 7fde50e..b205caf 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -55,26 +55,41 @@ ps1() { local path="${PWD}" local user="${USER}" local view="└ " + # code if [ "${code}" -ne 0 ]; then view="${view}${SH_GREEN}" else view="${view}${SH_RED}" fi - view="${view}${code}${SH_DEFAULT} @ ${SH_BROWN}${date}${SH_DEFAULT}" + view="${view}${code}" + # date + view="${view}${SH_DEFAULT} @ " + view="${view}${SH_BROWN}${date}" + # git if [ "$(type -t __git_ps1)" = "function" ]; then git="$(__git_ps1)" if [ -n "${git}" ]; then - view="${view} –${SH_MAGENTA}${git}${SH_DEFAULT}" + view="${view}${SH_DEFAULT} –${SH_MAGENTA}${git}" fi fi - view="${view}\n${SH_CYAN}${path}${SH_DEFAULT}" - view="${view}\n┌ " + # new + view="${view}\n" + # path + view="${view}${SH_CYAN}${path}" + # new + view="${view}\n" + # frame + view="${view}┌ " + # user if [ "${id}" -eq 0 ]; then view="${view}${SH_GREEN}" else view="${view}${SH_RED}" fi - view="${view}${user}${SH_DEFAULT} @ ${SH_BROWN}${host}${SH_DEFAULT}" + view="${view}${user}" + # host + view="${view}${SH_DEFAULT} @ " + view="${view}${SH_BROWN}${host}${SH_DEFAULT}" echo -e "${view}\n${PS2}" } From 60adeb9f4096cae45d210412af1a5f7c96e8eff3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 02:32:58 +0100 Subject: [PATCH 556/969] fixes --- shell/shell.sh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/shell/shell.sh b/shell/shell.sh index b205caf..d5ed4e2 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -1,3 +1,6 @@ +PS1="\$(ps1 \${?})" +PS2="\ +├ " SH="$(cat /proc/$$/comm)" shell_color() { @@ -20,12 +23,12 @@ shell_color() { esac printf "m" } +SH_BROWN="$(shell_color 33)" +SH_CYAN="$(shell_color 36)" SH_DEFAULT="$(shell_color)" SH_GREEN="$(shell_color 31)" -SH_RED="$(shell_color 32)" -SH_BROWN="$(shell_color 33)" SH_MAGENTA="$(shell_color 35)" -SH_CYAN="$(shell_color 36)" +SH_RED="$(shell_color 32)" case "${SH}" in "bash") @@ -79,7 +82,7 @@ ps1() { # new view="${view}\n" # frame - view="${view}┌ " + view="${view}${SH_DEFAULT}┌ " # user if [ "${id}" -eq 0 ]; then view="${view}${SH_GREEN}" @@ -90,10 +93,5 @@ ps1() { # host view="${view}${SH_DEFAULT} @ " view="${view}${SH_BROWN}${host}${SH_DEFAULT}" - echo -e "${view}\n${PS2}" + printf "%s" "${view}\n${PS2}" } - -PS1="\$(ps1 \${?})" - -PS2="\ -├ " From 62ae8d73cc3d89fdcea21d68c03de4aa878e6e07 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 02:43:06 +0100 Subject: [PATCH 557/969] wip/works --- shell/shell.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/shell/shell.sh b/shell/shell.sh index d5ed4e2..ec85222 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -7,13 +7,13 @@ shell_color() { local code="${1}" case "${SH}" in "bash") - printf "\e[0" + printf "\\e[0" if [ -n "${code}" ]; then printf "%s" ";${code}" fi ;; *) - printf "\033[" + printf "\\033[" if [ -n "${code}" ]; then printf "%s" "${code}" else @@ -76,11 +76,13 @@ ps1() { fi fi # new - view="${view}\n" + view="${view} +" # path view="${view}${SH_CYAN}${path}" # new - view="${view}\n" + view="${view} +" # frame view="${view}${SH_DEFAULT}┌ " # user @@ -92,6 +94,12 @@ ps1() { view="${view}${user}" # host view="${view}${SH_DEFAULT} @ " - view="${view}${SH_BROWN}${host}${SH_DEFAULT}" - printf "%s" "${view}\n${PS2}" + view="${view}${SH_BROWN}${host}" + # new + view="${view} +" + # prompt + view="${view}${SH_DEFAULT}${PS2}" + # print + printf "%s" "${view}" } From e8dfd1b98a3d73c17b420703564611718217b6b0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 02:44:04 +0100 Subject: [PATCH 558/969] useless --- shell/shell.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/shell.sh b/shell/shell.sh index ec85222..52a00f3 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -7,13 +7,13 @@ shell_color() { local code="${1}" case "${SH}" in "bash") - printf "\\e[0" + printf "\e[0" if [ -n "${code}" ]; then printf "%s" ";${code}" fi ;; *) - printf "\\033[" + printf "\033[" if [ -n "${code}" ]; then printf "%s" "${code}" else From 6eaab0b75f6575f5309083d43d4c25de1089b79c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 02:49:14 +0100 Subject: [PATCH 559/969] fixes --- shell/shell.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shell/shell.sh b/shell/shell.sh index 52a00f3..b984e6c 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -49,13 +49,14 @@ esac # prompt ps1() { - local date host id + local date host id type local code="${1}" date="$(date +%H:%M:%S)" local git host="$(hostname)" id="$(id --user)" local path="${PWD}" + type="$(type -t __git_ps1)" local user="${USER}" local view="└ " # code @@ -69,7 +70,7 @@ ps1() { view="${view}${SH_DEFAULT} @ " view="${view}${SH_BROWN}${date}" # git - if [ "$(type -t __git_ps1)" = "function" ]; then + if [ "${type}" = "function" ]; then git="$(__git_ps1)" if [ -n "${git}" ]; then view="${view}${SH_DEFAULT} –${SH_MAGENTA}${git}" From f3666204183eca2c3ba172fd21d49b437d4276ef Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 02:55:41 +0100 Subject: [PATCH 560/969] =?UTF-8?q?=E2=88=92type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/shell.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/shell/shell.sh b/shell/shell.sh index b984e6c..5e100fa 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -49,14 +49,13 @@ esac # prompt ps1() { - local date host id type + local date host id local code="${1}" date="$(date +%H:%M:%S)" local git host="$(hostname)" id="$(id --user)" local path="${PWD}" - type="$(type -t __git_ps1)" local user="${USER}" local view="└ " # code @@ -70,7 +69,7 @@ ps1() { view="${view}${SH_DEFAULT} @ " view="${view}${SH_BROWN}${date}" # git - if [ "${type}" = "function" ]; then + if command -v "__git_ps1" >"/dev/null"; then git="$(__git_ps1)" if [ -n "${git}" ]; then view="${view}${SH_DEFAULT} –${SH_MAGENTA}${git}" From 5139c4367ea1fd0f6fc06849435650289c9551b6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 03:21:30 +0100 Subject: [PATCH 561/969] fixes --- shell/main.sh | 6 ------ shell/shell.sh | 48 +++++++++++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/shell/main.sh b/shell/main.sh index c8d2607..0ccf86b 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -1,11 +1,5 @@ [ -n "${ENV}" ] || export ENV="/etc/shell/main.sh" -main_link_bashrc() { - local file="/etc/bash.bashrc" - rm --force "${file}" - ln --symbolic "${MAIN_USERS_FILE}" "${file}" -} - main_source_directory() { local path="${1}" if [ -d "${path}" ]; then diff --git a/shell/shell.sh b/shell/shell.sh index 5e100fa..d8df42b 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -1,4 +1,4 @@ -PS1="\$(ps1 \${?})" +PS1="\$(shell_prompt \${?})" PS2="\ ├ " SH="$(cat /proc/$$/comm)" @@ -30,25 +30,26 @@ SH_GREEN="$(shell_color 31)" SH_MAGENTA="$(shell_color 35)" SH_RED="$(shell_color 32)" -case "${SH}" in -"bash") - # completion - file="/usr/share/bash-completion/bash_completion" - if [ -f "${file}" ]; then - . "${file}" - fi - # history - HISTCONTROL="ignorespace" - HISTSIZE=-1 - HISTTIMEFORMAT="%Y%m%d %H%M%S " - ;; -*) - ;; -esac +shell_configure() { + case "${SH}" in + "bash") + # completion + file="/usr/share/bash-completion/bash_completion" + if [ -f "${file}" ]; then + . "${file}" + fi + # history + HISTCONTROL="ignorespace" + HISTSIZE=-1 + HISTTIMEFORMAT="%Y%m%d %H%M%S " + ;; + *) + ;; + esac +} +shell_configure -# prompt - -ps1() { +shell_prompt() { local date host id local code="${1}" date="$(date +%H:%M:%S)" @@ -103,3 +104,12 @@ ps1() { # print printf "%s" "${view}" } + +shell_setup() { + # shell + echo "export ENV=\"${ENV}\"" >"/etc/profile.d/shell.sh" + # bash + local file="/etc/bash.bashrc" + rm --force --recursive "${file}" + ln --symbolic "${ENV}" "${file}" +} From 964df6e8dc3a471d9e9a33fc255aca62897baae3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 03:23:19 +0100 Subject: [PATCH 562/969] fixes --- shell/shell.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/shell/shell.sh b/shell/shell.sh index d8df42b..b50964e 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -34,7 +34,7 @@ shell_configure() { case "${SH}" in "bash") # completion - file="/usr/share/bash-completion/bash_completion" + local file="/usr/share/bash-completion/bash_completion" if [ -f "${file}" ]; then . "${file}" fi @@ -43,8 +43,7 @@ shell_configure() { HISTSIZE=-1 HISTTIMEFORMAT="%Y%m%d %H%M%S " ;; - *) - ;; + *) ;; esac } shell_configure From 2b807632b3fc7688fde01a439499dbb54ab606b8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 03:34:01 +0100 Subject: [PATCH 563/969] directories & files --- shell/mount.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/shell/mount.sh b/shell/mount.sh index fe5b273..cb7bb5a 100644 --- a/shell/mount.sh +++ b/shell/mount.sh @@ -1,12 +1,14 @@ mo() { - local directory="${1}" - local file - if [ -n "${directory}" ]; then - directory="$(realpath "${directory}")" - file="${directory}/filesystem.squashfs" + local root="${1}" + local directory file + if [ -n "${root}" ]; then + root="$(realpath "${root}")" + file="${root}/filesystem.squashfs" if mkdir "overlay"; then cd "overlay" - mkdir {lower,upper,work,mount} + for directory in "lower" "upper" "work" "mount"; do + mkdir "${directory}" + done if mount "${file}" "lower"; then mount \ -o lowerdir="lower",upperdir="upper",workdir="work" \ @@ -16,7 +18,8 @@ mo() { cd .. fi else - echo "KO: directory?" + log_fatal "No root" + return 1 fi } @@ -68,11 +71,14 @@ um() { ms() { local directory="${1}" + local file local level="${2}" if [ -n "${directory}" ]; then if mkdir "${directory}"; then [ -n "${level}" ] || level="18" - cp overlay/mount/{vmlinuz,initrd.img} "${directory}" + for file in "vmlinuz" "initrd.img"; do + cp "overlay/mount/${file}" "${directory}" + done mksquashfs \ "overlay/mount" "${directory}/filesystem.squashfs" \ -noappend \ From 36aaa275a7a888a51d269072dabf338a4a6c7f4e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 04:04:44 +0100 Subject: [PATCH 564/969] mo --- shell/mount.sh | 51 +++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/shell/mount.sh b/shell/mount.sh index cb7bb5a..118f8e9 100644 --- a/shell/mount.sh +++ b/shell/mount.sh @@ -1,26 +1,39 @@ mo() { local root="${1}" - local directory file - if [ -n "${root}" ]; then - root="$(realpath "${root}")" - file="${root}/filesystem.squashfs" - if mkdir "overlay"; then - cd "overlay" - for directory in "lower" "upper" "work" "mount"; do - mkdir "${directory}" - done - if mount "${file}" "lower"; then - mount \ - -o lowerdir="lower",upperdir="upper",workdir="work" \ - -t "overlay" \ - "overlay" "mount" - fi - cd .. - fi - else - log_fatal "No root" + if [ -z "${root}" ]; then + log_error "No root" return 1 fi + root="$(realpath "${root}")" + if ! mkdir "overlay"; then + log_error "Unable to make mount directory" + return 2 + fi + { + if ! cd "overlay"; then + log_error "Unable to move into mount directory" + return 3 + fi + local directory + for directory in "lower" "upper" "work" "mount"; do + if ! mkdir --parents "${directory}"; then + log_error "Unable to move into: ${directory}" + return 4 + fi + done + local file="${root}/filesystem.squashfs" + if ! mount "${file}" "lower"; then + log_error "Unable to mount: ${file}" + return 5 + fi + if ! mount \ + -o "lowerdir=lower,upperdir=upper,workdir=work" \ + -t "overlay" \ + "overlay" "mount"; then + log_error "Unable to mount: ${file}" + return 6 + fi + } } uo() { From 58ca9eb86fa35da57eafcbf3e75d2700d569e5bc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 04:23:54 +0100 Subject: [PATCH 565/969] wip/mount --- shell/mount.sh | 55 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/shell/mount.sh b/shell/mount.sh index 118f8e9..ed78546 100644 --- a/shell/mount.sh +++ b/shell/mount.sh @@ -1,52 +1,75 @@ mo() { local root="${1}" if [ -z "${root}" ]; then - log_error "No root" + log_error "No root target directory" return 1 fi root="$(realpath "${root}")" if ! mkdir "overlay"; then - log_error "Unable to make mount directory" + log_error "Unable to make overlay directory" return 2 fi - { + ( if ! cd "overlay"; then - log_error "Unable to move into mount directory" + log_error "Unable to move into overlay directory" return 3 fi local directory for directory in "lower" "upper" "work" "mount"; do if ! mkdir --parents "${directory}"; then - log_error "Unable to move into: ${directory}" + log_error "Unable to make directory: ${directory}" return 4 fi done local file="${root}/filesystem.squashfs" if ! mount "${file}" "lower"; then - log_error "Unable to mount: ${file}" + log_error "Unable to lower mount: ${file}" return 5 fi if ! mount \ -o "lowerdir=lower,upperdir=upper,workdir=work" \ -t "overlay" \ "overlay" "mount"; then - log_error "Unable to mount: ${file}" + log_error "Unable to overlay mount" return 6 fi - } + ) } uo() { - cd "overlay" - if umount "mount"; then - rmdir "mount" - rm --recursive "upper" "work" - if umount "lower"; then - rmdir "lower" + ( + if ! cd "overlay"; then + log_error "Unable to move into overlay directory" + return 1 fi + if ! umount "mount"; then + log_error "Unable to unmount mount directory" + return 2 + fi + if ! rmdir "mount"; then + log_error "Unable to remove mount directory" + return 3 + fi + local directory + for directory in "upper" "work"; do + if ! rm --force --recursive "${directory}"; then + log_error "Unable to remove directory: ${directory}" + return 4 + fi + done + if ! umount "lower"; then + log_error "Unable to unmount lower directory" + return 5 + fi + if ! rmdir "lower"; then + log_error "Unable to remove lower directory" + return 6 + fi + ) + if ! rmdir "overlay"; then + log_error "Unable to remove overlay directory" + return 7 fi - cd .. - rmdir "overlay" } mr() { From 94746ca4977d3f851364ed1009c573b01f71bd10 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 04:27:07 +0100 Subject: [PATCH 566/969] mr --- shell/mount.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shell/mount.sh b/shell/mount.sh index ed78546..b27b1a2 100644 --- a/shell/mount.sh +++ b/shell/mount.sh @@ -73,9 +73,12 @@ uo() { } mr() { - local f - for f in "dev" "dev/pts" "proc" "sys"; do - mount --bind "/${f}" "overlay/mount/${f}" + local directory + for directory in "dev" "dev/pts" "proc" "sys"; do + if ! mount --bind "/${directory}" "overlay/mount/${directory}"; then + log_error "Unable to bind mount directory: ${directory}" + return 1 + fi done } From dc087a205b2fad63c9868d34e3fad19b0c11ce2a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 04:28:32 +0100 Subject: [PATCH 567/969] ur --- shell/mount.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shell/mount.sh b/shell/mount.sh index b27b1a2..0211131 100644 --- a/shell/mount.sh +++ b/shell/mount.sh @@ -94,9 +94,12 @@ chroot \ " ur() { - local f - for f in "sys" "proc" "dev/pts" "dev"; do - umount --lazy "overlay/mount/${f}" + local directory + for directory in "sys" "proc" "dev/pts" "dev"; do + if ! umount --lazy "overlay/mount/${directory}"; then + log_error "Unable to bind unmount directory: ${directory}" + return 1 + fi done } From c03750a2f317152979252708f80104e8392efccc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 04:34:35 +0100 Subject: [PATCH 568/969] cr,cru --- shell/mount.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/shell/mount.sh b/shell/mount.sh index 0211131..7e715cf 100644 --- a/shell/mount.sh +++ b/shell/mount.sh @@ -82,16 +82,16 @@ mr() { done } -alias cr="\ -chroot \ -\"overlay/mount\" \ -" +cr() { + chroot \ + "overlay/mount" "${@}" +} -alias cru="\ -chroot \ ---userspec \"1000:1000\" \ -\"overlay/mount\" \ -" +cru() { + chroot \ + --userspec "1000:1000" \ + "overlay/mount" "${@}" +} ur() { local directory From 9d4c32e34ae0c609cde354759b67c19e01f9527f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 04:45:44 +0100 Subject: [PATCH 569/969] . --- shell/alias/bash.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/alias/bash.sh b/shell/alias/bash.sh index aaa10ca..9c9e8e7 100644 --- a/shell/alias/bash.sh +++ b/shell/alias/bash.sh @@ -23,7 +23,7 @@ cd \ # import source file alias src="\ -source \ +. \ " # exit terminal From 1e6a8d5c2a5dd8f47efbbb54ba02a77e37374a66 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 04:46:38 +0100 Subject: [PATCH 570/969] todo/() --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 9a0b6d3..f303f1f 100644 --- a/readme.md +++ b/readme.md @@ -2,6 +2,7 @@ ## ToDo +* [ ] convert alias to () * [ ] log * [ ] ovh * [ ] clean apt cache after each install/upgrade step From cafe6ab80b9f3ad762e7d5833eb21722715bd16e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 13:10:31 +0100 Subject: [PATCH 571/969] ${*} --- shell/rescue/hetzner.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/rescue/hetzner.sh b/shell/rescue/hetzner.sh index d5ec527..05e12d5 100644 --- a/shell/rescue/hetzner.sh +++ b/shell/rescue/hetzner.sh @@ -12,7 +12,7 @@ rescue_wipe_0_init_hetzner_8_8() { passphrase="$(read_passphrase)" # lsblk - echo -n "WIPE" "${@}" "/?\\ OR CANCEL /!\\" + printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\" read -r # number=0 From 213f6ae1f15b19e11880429f122ffcb238dd3fc9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 13:22:55 +0100 Subject: [PATCH 572/969] warn_wipe --- shell/rescue/hetzner.sh | 6 ++---- shell/rescue/ovh.sh | 4 +--- shell/util.sh | 8 ++++++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/shell/rescue/hetzner.sh b/shell/rescue/hetzner.sh index 05e12d5..b14d5c7 100644 --- a/shell/rescue/hetzner.sh +++ b/shell/rescue/hetzner.sh @@ -10,10 +10,8 @@ rescue_wipe_0_init_hetzner_8_8() { local passphrase # read passphrase passphrase="$(read_passphrase)" - # - lsblk - printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\" - read -r + # warn + warn_wipe "${@}" # number=0 for device in "${@}"; do diff --git a/shell/rescue/ovh.sh b/shell/rescue/ovh.sh index ed225d1..b12c50b 100644 --- a/shell/rescue/ovh.sh +++ b/shell/rescue/ovh.sh @@ -4,9 +4,7 @@ rescue_wipe_0_init_ovh_vle2() { # read passphrase passphrase="$(read_passphrase)" # warn - lsblk - printf "%s" "WIPE ${device} /?\\ OR CANCEL /!\\" - read -r + warn_wipe "${device}" # parted --script "${device}" \ mktable gpt \ diff --git a/shell/util.sh b/shell/util.sh index 8a345ba..7d333ae 100644 --- a/shell/util.sh +++ b/shell/util.sh @@ -21,3 +21,11 @@ read_secret() { echo "${secret}" unset secret } + +warn_wipe() { + local tmp + lsblk --noempty + printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\" + read -r tmp + log_trace "${tmp}" +} From 014ac219ac0ad9ef4a4bce4d01d5205aefe4ffa5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 13:25:02 +0100 Subject: [PATCH 573/969] list_block_devices --- shell/util.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shell/util.sh b/shell/util.sh index 7d333ae..4dcd59a 100644 --- a/shell/util.sh +++ b/shell/util.sh @@ -1,3 +1,9 @@ +list_block_devices() { + lsblk \ + --noempty \ + --output "NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINTS" +} + not() { case "${1}" in "false") echo "true" ;; @@ -24,7 +30,7 @@ read_secret() { warn_wipe() { local tmp - lsblk --noempty + list_block_devices printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\" read -r tmp log_trace "${tmp}" From 0c6f8d6dd7f49a11208ebed3414eb8fb439785d9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 13:31:52 +0100 Subject: [PATCH 574/969] members --- shell/rescue/hetzner.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/shell/rescue/hetzner.sh b/shell/rescue/hetzner.sh index b14d5c7..48ea37e 100644 --- a/shell/rescue/hetzner.sh +++ b/shell/rescue/hetzner.sh @@ -61,12 +61,12 @@ rescue_wipe_0_init_hetzner_8_8() { fs_wipe "${device}2" "1G" 1 done # - members=() + members="" for device in "${@}"; do - members+=("${device}2") + members="${members} ${device}2" done fs_raid_create \ - "boot" "00000000:00000000:00000000:00000002" "${members[@]}" + "boot" "00000000:00000000:00000000:00000002" ${members} # fs_make_btrfs "/dev/md/boot" "boot" \ "00000000-0000-0000-0000-00000000000b" @@ -85,12 +85,12 @@ rescue_wipe_0_init_hetzner_8_8() { fs_wipe "${device}1" "1G" 1 done # - members=() + members="" for device in "${@}"; do - members+=("${device}1") + members="${members} ${device}1" done fs_raid_create \ - "crypt" "00000000:00000000:00000000:00000001" "${members[@]}" + "crypt" "00000000:00000000:00000000:00000001" ${members} # encrypt luks_format "${passphrase}" "/dev/md/crypt" # open From 3522a8a2f414324998c4018d4c92b5cc7ab4ea81 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 13:33:53 +0100 Subject: [PATCH 575/969] on purpose --- shell/rescue/hetzner.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shell/rescue/hetzner.sh b/shell/rescue/hetzner.sh index 48ea37e..c312fce 100644 --- a/shell/rescue/hetzner.sh +++ b/shell/rescue/hetzner.sh @@ -65,6 +65,7 @@ rescue_wipe_0_init_hetzner_8_8() { for device in "${@}"; do members="${members} ${device}2" done + # shellcheck disable=SC2086 fs_raid_create \ "boot" "00000000:00000000:00000000:00000002" ${members} # @@ -89,6 +90,7 @@ rescue_wipe_0_init_hetzner_8_8() { for device in "${@}"; do members="${members} ${device}1" done + # shellcheck disable=SC2086 fs_raid_create \ "crypt" "00000000:00000000:00000000:00000001" ${members} # encrypt From 9d8772d716aecb8125b183c674a2c56741c2e56e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 13:34:39 +0100 Subject: [PATCH 576/969] =?UTF-8?q?=E2=88=92exception?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/rescue/hetzner.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/shell/rescue/hetzner.sh b/shell/rescue/hetzner.sh index c312fce..80d901b 100644 --- a/shell/rescue/hetzner.sh +++ b/shell/rescue/hetzner.sh @@ -1,5 +1,3 @@ -[ "$(cat /proc/$$/comm)" = "bash" ] || return - rescue_wipe_0_init_hetzner_8_8() { local device set \ From e43429a6838a1bd6cb55c3a8a67ec5a7977dbbb0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 13:53:18 +0100 Subject: [PATCH 577/969] tree --- shell/alias/tree.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/shell/alias/tree.sh b/shell/alias/tree.sh index 2252fc1..dbea341 100644 --- a/shell/alias/tree.sh +++ b/shell/alias/tree.sh @@ -1,8 +1,8 @@ -alias t="\ -tree \ -" +t() { + tree +} -alias ta="\ -tree \ --a \ -" +ta() { + tree \ + -a +} From c7d3d72e62fb3acc337e1ca2ccc3c0f04eb84a52 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 13:55:07 +0100 Subject: [PATCH 578/969] tree/@ --- shell/alias/tree.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shell/alias/tree.sh b/shell/alias/tree.sh index dbea341..c96738c 100644 --- a/shell/alias/tree.sh +++ b/shell/alias/tree.sh @@ -1,8 +1,10 @@ t() { - tree + tree \ + "${@}" } ta() { tree \ - -a + -a \ + "${@}" } From 895c169599af6f224fc625905d1e341c81063179 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 14:00:55 +0100 Subject: [PATCH 579/969] batcat --- shell/alias/batcat.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shell/alias/batcat.sh b/shell/alias/batcat.sh index e62f4ac..352cff1 100644 --- a/shell/alias/batcat.sh +++ b/shell/alias/batcat.sh @@ -1,3 +1,4 @@ -alias bat="\ -batcat \ -" +bat() { + batcat \ + "${@}" +} From 97389ceef759fa3d6499742dcbad9b0a5a0bef85 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 14:03:13 +0100 Subject: [PATCH 580/969] cmd,cmf --- shell/alias/chmod.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/shell/alias/chmod.sh b/shell/alias/chmod.sh index 4df1df3..c523a11 100644 --- a/shell/alias/chmod.sh +++ b/shell/alias/chmod.sh @@ -1,11 +1,13 @@ # change mode as directory -alias cmd="\ -chmod \ -\"755\" \ -" +cmd() { + chmod \ + "755" \ + "${@}" +} # change mode as file -alias cmf="\ -chmod \ -\"644\" \ -" +cmf() { + chmod \ + "644" \ + "${@}" +} From 524ddb8968cf8167166de154e36e811b3b7bb582 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 14:04:50 +0100 Subject: [PATCH 581/969] cor,cou --- shell/alias/chmod.sh | 4 ++-- shell/alias/chown.sh | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/shell/alias/chmod.sh b/shell/alias/chmod.sh index c523a11..89b8bd7 100644 --- a/shell/alias/chmod.sh +++ b/shell/alias/chmod.sh @@ -1,11 +1,11 @@ -# change mode as directory +# change mode to directory cmd() { chmod \ "755" \ "${@}" } -# change mode as file +# change mode to file cmf() { chmod \ "644" \ diff --git a/shell/alias/chown.sh b/shell/alias/chown.sh index 5a51942..f7bbef9 100644 --- a/shell/alias/chown.sh +++ b/shell/alias/chown.sh @@ -1,11 +1,13 @@ -# change owner as root -alias cor="\ -chown \ -\"0:0\" \ -" +# change owner to root +cor() { + chown \ + "0:0" \ + "${@}" +} -# change owner as user -alias cou="\ -chown \ -\"1000:1000\" \ -" +# change owner to user +cou() { + chown \ + "1000:1000" \ + "${@}" +} From a5a9beff265218b48437e571b10c2a305b68f9f5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 14:06:00 +0100 Subject: [PATCH 582/969] clear --- shell/alias/clear.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shell/alias/clear.sh b/shell/alias/clear.sh index afa9bb0..6a69638 100644 --- a/shell/alias/clear.sh +++ b/shell/alias/clear.sh @@ -1,4 +1,5 @@ # clear terminal -alias c="\ -clear \ -" +c() { + clear \ + "${@}" +} From 3c737f19285a86cb5018d26c954f067d948a5ace Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 14:40:28 +0100 Subject: [PATCH 583/969] =?UTF-8?q?cpi,=C2=B5,mvi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/alias/cp.sh | 9 +++++---- shell/alias/micro.sh | 7 ++++--- shell/alias/mv.sh | 9 +++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/shell/alias/cp.sh b/shell/alias/cp.sh index 946182f..5db0082 100644 --- a/shell/alias/cp.sh +++ b/shell/alias/cp.sh @@ -1,5 +1,6 @@ # copy interactively -alias cpi="\ -cp \ ---interactive \ -" +cpi() { + cp \ + --interactive \ + "${@}" +} diff --git a/shell/alias/micro.sh b/shell/alias/micro.sh index 05102a2..b0aa4be 100644 --- a/shell/alias/micro.sh +++ b/shell/alias/micro.sh @@ -1,3 +1,4 @@ -alias µ="\ -micro \ -" +µ() { + micro \ + "${@}" +} diff --git a/shell/alias/mv.sh b/shell/alias/mv.sh index dff7f63..89d6efd 100644 --- a/shell/alias/mv.sh +++ b/shell/alias/mv.sh @@ -1,5 +1,6 @@ # move interactively -alias mvi="\ -mv \ ---interactive \ -" +mvi() { + mv \ + --interactive \ + "${@}" +} From e73163d2d3fdc561cde7175d0bab87d63a89c9c0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 14:41:35 +0100 Subject: [PATCH 584/969] shell --- shell/alias/{bash.sh => shell.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename shell/alias/{bash.sh => shell.sh} (100%) diff --git a/shell/alias/bash.sh b/shell/alias/shell.sh similarity index 100% rename from shell/alias/bash.sh rename to shell/alias/shell.sh From 95f52f32eb1b2b9e05c528b67eb123ffa4d33b17 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 14:58:58 +0100 Subject: [PATCH 585/969] a,sd,x,..,... --- shell/alias/shell.sh | 49 ++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/shell/alias/shell.sh b/shell/alias/shell.sh index 9c9e8e7..d6aa697 100644 --- a/shell/alias/shell.sh +++ b/shell/alias/shell.sh @@ -1,32 +1,27 @@ -# change current directory to its parent -alias ..="\ -cd \ -.. \ -" - -# change current directory to its parent’s parent -alias ...="\ -cd \ -../.. \ -" - # shorten alias -alias a="\ -alias \ -" +a() { + alias \ + "${@}" +} # swap directory (current ↔ previous) -alias sd="\ -cd \ -- \ -" - -# import source file -alias src="\ -. \ -" +sd() { + cd - || return +} # exit terminal -alias x="\ -exit \ -" +x() { + exit \ + "${@}" +} + +# back + +# shellcheck disable=SC3033 +..() { + cd .. +} +# shellcheck disable=SC3033 +...() { + cd ../.. +} From adddd9af3bf1aabd66874bc387a19f762cc76369 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 14:59:54 +0100 Subject: [PATCH 586/969] =?UTF-8?q?=E2=88=92otpclient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/alias/otpclient-cli.sh | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 shell/alias/otpclient-cli.sh diff --git a/shell/alias/otpclient-cli.sh b/shell/alias/otpclient-cli.sh deleted file mode 100644 index 4fbe9cd..0000000 --- a/shell/alias/otpclient-cli.sh +++ /dev/null @@ -1,12 +0,0 @@ -# list otp accounts -alias otpl="\ -otpclient-cli \ -list \ -" - -# display otp code -alias otps="\ -otpclient-cli \ -show \ --a \ -" From 6df0543e89202206b8f911b172504ba5a406d941 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 15:02:40 +0100 Subject: [PATCH 587/969] newsboat --- shell/alias/newsboat.sh | 7 ++++--- shell/alias/shell.sh | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/shell/alias/newsboat.sh b/shell/alias/newsboat.sh index 971ad9d..c877906 100644 --- a/shell/alias/newsboat.sh +++ b/shell/alias/newsboat.sh @@ -1,3 +1,4 @@ -alias nb="\ -newsboat \ -" +nb() { + newsboat \ + "${@}" +} diff --git a/shell/alias/shell.sh b/shell/alias/shell.sh index d6aa697..d38c3cb 100644 --- a/shell/alias/shell.sh +++ b/shell/alias/shell.sh @@ -6,7 +6,9 @@ a() { # swap directory (current ↔ previous) sd() { - cd - || return + cd \ + - || + return } # exit terminal From 03450c9ac79e08638149d357d26561de60d70427 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 15:04:04 +0100 Subject: [PATCH 588/969] evince --- shell/alias/evince.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shell/alias/evince.sh b/shell/alias/evince.sh index 0d36d89..01ec950 100644 --- a/shell/alias/evince.sh +++ b/shell/alias/evince.sh @@ -1,3 +1,4 @@ -alias ev="\ -evince \ -" +ev() { + evince \ + "${@}" +} From c1f5176e25c6fdf91543e46fc3149e27ed61785a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 15:07:23 +0100 Subject: [PATCH 589/969] em,g --- shell/alias/emacs.sh | 8 ++++---- shell/alias/grep.sh | 13 +++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/shell/alias/emacs.sh b/shell/alias/emacs.sh index 7984a4a..8bd77fc 100644 --- a/shell/alias/emacs.sh +++ b/shell/alias/emacs.sh @@ -1,4 +1,4 @@ -# short -alias em="\ -emacs \ -" +em() { + emacs \ + "${@}" +} diff --git a/shell/alias/grep.sh b/shell/alias/grep.sh index 73179dd..ab8e396 100644 --- a/shell/alias/grep.sh +++ b/shell/alias/grep.sh @@ -1,7 +1,8 @@ # grep from current directory with regex -alias g="\ -grep \ ---directories \"recurse\" \ ---line-number \ ---regexp \ -" +g() { + grep \ + --directories "recurse" \ + --line-number \ + --regexp \ + "${@}" +} From a2726f2f3b27e57407917c239e5feff2933865b8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 15:16:45 +0100 Subject: [PATCH 590/969] byobu --- shell/alias/byobu.sh | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/shell/alias/byobu.sh b/shell/alias/byobu.sh index df37d6f..d645cb1 100644 --- a/shell/alias/byobu.sh +++ b/shell/alias/byobu.sh @@ -1,19 +1,23 @@ -alias bb="\ -byobu \ -" +bb() { + byobu \ + "${@}" +} -alias bba="\ -byobu \ -attach-session \ -" +bba() { + byobu \ + attach-session \ + "${@}" +} -alias bbl="\ -byobu \ -ls \ -" +bbl() { + byobu \ + ls \ + "${@}" +} -alias bbn="\ -byobu \ -new-session \ --d \ -" +bbnd() { + byobu \ + new-session \ + -d \ + "${@}" +} From e2a59923af9aec7014635235018c1e01a8f98f1e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 15:17:36 +0100 Subject: [PATCH 591/969] tm --- shell/alias/tmux.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 shell/alias/tmux.sh diff --git a/shell/alias/tmux.sh b/shell/alias/tmux.sh new file mode 100644 index 0000000..fa96b6a --- /dev/null +++ b/shell/alias/tmux.sh @@ -0,0 +1,4 @@ +tm() { + tmux \ + "${@}" +} From 449f1dadd819b730076abbc8c79fe75321ba1127 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 15:18:41 +0100 Subject: [PATCH 592/969] nn --- shell/alias/nano.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shell/alias/nano.sh b/shell/alias/nano.sh index 37bd342..2718583 100644 --- a/shell/alias/nano.sh +++ b/shell/alias/nano.sh @@ -1,3 +1,4 @@ -alias n="\ -nano \ -" +nn() { + nano \ + "${@}" +} From db65dea9dd6a3f74eb6dfd0d73706a8bb2e52cbe Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 15:20:14 +0100 Subject: [PATCH 593/969] p,pc --- shell/alias/pass.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/shell/alias/pass.sh b/shell/alias/pass.sh index 1f48255..ddcfa48 100644 --- a/shell/alias/pass.sh +++ b/shell/alias/pass.sh @@ -1,10 +1,12 @@ # display pass entry’s content -alias p="\ -pass \ -" +p() { + pass \ + "${@}" +} # copy passphrase into clipboard -alias pc="\ -pass \ ---clip \ -" +pc() { + pass \ + --clip \ + "${@}" +} From 11fc443c8f4be82dd33228927f911def2ffa9e59 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 15:22:14 +0100 Subject: [PATCH 594/969] rmi --- shell/alias/rm.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 shell/alias/rm.sh diff --git a/shell/alias/rm.sh b/shell/alias/rm.sh new file mode 100644 index 0000000..0d42f42 --- /dev/null +++ b/shell/alias/rm.sh @@ -0,0 +1,6 @@ +# remove interactively +rmi() { + rm \ + --interactive \ + "${@}" +} From 259dbd11d1a02420a24f3cdbbc05d1cfb429a2ea Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 15:26:30 +0100 Subject: [PATCH 595/969] pwg,pwgs --- shell/alias/pwgen.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/shell/alias/pwgen.sh b/shell/alias/pwgen.sh index c462028..4052d61 100644 --- a/shell/alias/pwgen.sh +++ b/shell/alias/pwgen.sh @@ -1,16 +1,15 @@ # generate passwords -alias pwg="\ -pwgen \ --1 \ ---num-passwords 1048576 \ ---secure \ -" +pwg() { + pwgen \ + -1 \ + --num-passwords 1048576 \ + --secure \ + "${@}" +} # generate passwords with symbols -alias pwgs="\ -pwgen \ --1 \ ---num-passwords 1048576 \ ---secure \ ---symbols \ -" +pwgs() { + pwg \ + --symbols \ + "${@}" +} From ccf058440c527b1150d167e691ee67d790864fca Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 15:29:05 +0100 Subject: [PATCH 596/969] pg --- shell/alias/ps.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/shell/alias/ps.sh b/shell/alias/ps.sh index 0e643ae..bbb93de 100644 --- a/shell/alias/ps.sh +++ b/shell/alias/ps.sh @@ -1,7 +1,7 @@ # look for a string in processes names -alias pg="\ -ps \ --A \ -| \ -grep \ -" +pg() { + ps \ + -A | + grep \ + "${@}" +} From 8df4abafcad8ceee58018ab1743785e94b9cd59d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 15:37:38 +0100 Subject: [PATCH 597/969] tc,tl,tv,tx --- shell/alias/tar.sh | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/shell/alias/tar.sh b/shell/alias/tar.sh index 74b5020..bfbf7be 100644 --- a/shell/alias/tar.sh +++ b/shell/alias/tar.sh @@ -1,21 +1,27 @@ -alias tc="\ -tar \ ---verbose \ ---create \ ---auto-compress \ ---file \ -" +tc() { + tv \ + --create \ + --auto-compress \ + --file \ + "${@}" +} -alias tl="\ -tar \ ---verbose \ ---list \ ---file \ -" +tl() { + tv \ + --list \ + --file \ + "${@}" +} -alias tx="\ -tar \ ---verbose \ ---extract \ ---file \ -" +tv() { + tar \ + --verbose \ + "${@}" +} + +tx() { + tv \ + --extract \ + --file \ + "${@}" +} From 7ae9eb739a5a4f78d2479701ca4f92e541694481 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 15:40:17 +0100 Subject: [PATCH 598/969] k,kf --- shell/alias/kill.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/shell/alias/kill.sh b/shell/alias/kill.sh index 970352d..a6e105c 100644 --- a/shell/alias/kill.sh +++ b/shell/alias/kill.sh @@ -1,10 +1,12 @@ # kill a process by id -alias k="\ -kill \ -" +k() { + kill \ + "${@}" +} # force kill a process by id -alias kf="\ -kill \ --9 \ -" +kf() { + kill \ + -9 \ + "${@}" +} From 5af5181aa49bbd3efb9d34df72bd28a28f8fb585 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 15:42:21 +0100 Subject: [PATCH 599/969] ka,kaf --- shell/alias/killall.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/shell/alias/killall.sh b/shell/alias/killall.sh index 43c4cbe..2fbb157 100644 --- a/shell/alias/killall.sh +++ b/shell/alias/killall.sh @@ -1,10 +1,12 @@ # kill all instances of a process by name -alias ka="\ -killall \ -" +ka() { + killall \ + "${@}" +} # force kill all instances of a process by name -alias kaf="\ -killall \ --9 \ -" +kaf() { + killall \ + -9 \ + "${@}" +} From ca0399d4f35bf2e40858ffb2db8e96755f2ea7cf Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 15:53:58 +0100 Subject: [PATCH 600/969] lb,lbc,lbo --- shell/alias/lsblk.sh | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/shell/alias/lsblk.sh b/shell/alias/lsblk.sh index 4d63193..fb50d87 100644 --- a/shell/alias/lsblk.sh +++ b/shell/alias/lsblk.sh @@ -1,12 +1,27 @@ # list block devices -alias lb="\ -lsblk \ ---output \"NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINTS\" \ ---noempty \ -" +lb() { + lbo \ + "SIZE" \ + "TYPE" \ + "FSTYPE" \ + "LABEL" \ + "MOUNTPOINTS" +} -# list block devices (old) -alias lbo="\ -lsblk \ ---output \"NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINT\" \ -" +# common arguments +lbc() { + lsblk \ + --noempty \ + "${@}" +} + +# output arguments +lbo() { + local argument + local arguments="NAME" + for argument in "${@}"; do + arguments="${arguments},${argument}" + done + lbc \ + --output "${arguments}" +} From ea5bd6cfb2b9dda7ccf22e6544db3f451bdb184f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 15:59:29 +0100 Subject: [PATCH 601/969] gak,gau --- shell/alias/gpg.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/shell/alias/gpg.sh b/shell/alias/gpg.sh index 549c34e..4c1d4e5 100644 --- a/shell/alias/gpg.sh +++ b/shell/alias/gpg.sh @@ -1,12 +1,12 @@ # turn gpg agent off -alias gak="\ -gpgconf \ ---kill \"gpg-agent\" \ -" +gak() { + gpgconf \ + --kill "gpg-agent" +} # bind gpg agent to current tty -alias gau="\ -gpg-connect-agent \ -updatestartuptty \ -/bye \ -" +gau() { + gpg-connect-agent \ + updatestartuptty \ + /bye +} From 8d6b4884a10ff06267e63a056a4f1d174ea8a97e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 15:59:57 +0100 Subject: [PATCH 602/969] fix --- shell/alias/killall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/alias/killall.sh b/shell/alias/killall.sh index 2fbb157..a4d083e 100644 --- a/shell/alias/killall.sh +++ b/shell/alias/killall.sh @@ -7,6 +7,6 @@ ka() { # force kill all instances of a process by name kaf() { killall \ - -9 \ + -9 \ "${@}" } From a31401bd773d8f4363198f107b37fc8d4b160978 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 16:02:25 +0100 Subject: [PATCH 603/969] md,mdp --- shell/alias/mkdir.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/shell/alias/mkdir.sh b/shell/alias/mkdir.sh index 52745dd..961e14b 100644 --- a/shell/alias/mkdir.sh +++ b/shell/alias/mkdir.sh @@ -1,10 +1,12 @@ # make a directory -alias md="\ -mkdir \ -" +md() { + mkdir \ + "${@}" +} # make a directory after making its parents -alias mdp="\ -mkdir \ ---parents \ -" +mdp() { + mkdir \ + --parents \ + "${@}" +} From ecb4005b0edb6eb991b2c2f09af343f7c2980eb7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 16:07:47 +0100 Subject: [PATCH 604/969] bases --- shell/alias/lsblk.sh | 6 +++--- shell/alias/rsync.sh | 23 +++++++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/shell/alias/lsblk.sh b/shell/alias/lsblk.sh index fb50d87..398bc42 100644 --- a/shell/alias/lsblk.sh +++ b/shell/alias/lsblk.sh @@ -8,8 +8,8 @@ lb() { "MOUNTPOINTS" } -# common arguments -lbc() { +# base arguments +lbb() { lsblk \ --noempty \ "${@}" @@ -22,6 +22,6 @@ lbo() { for argument in "${@}"; do arguments="${arguments},${argument}" done - lbc \ + lbb \ --output "${arguments}" } diff --git a/shell/alias/rsync.sh b/shell/alias/rsync.sh index 7c08c91..d7c66b6 100644 --- a/shell/alias/rsync.sh +++ b/shell/alias/rsync.sh @@ -1,12 +1,19 @@ # synchronize -alias rs="\ -rsync \ ---archive \ ---partial \ ---progress \ ---verbose \ ---no-inc-recursive \ -" +rs() { + rsb \ + "${@}" +} + +# base arguments +rsb() { + rsync \ + --archive \ + --no-inc-recursive \ + --partial \ + --progress \ + --verbose \ + "${@}" +} # synchronize and delete after alias rsda="\ From dd801e188e6e6123db576002d3374188cdfd0506 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 16:10:16 +0100 Subject: [PATCH 605/969] rsda,rsdb --- shell/alias/rsync.sh | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/shell/alias/rsync.sh b/shell/alias/rsync.sh index d7c66b6..a5efc09 100644 --- a/shell/alias/rsync.sh +++ b/shell/alias/rsync.sh @@ -16,21 +16,15 @@ rsb() { } # synchronize and delete after -alias rsda="\ -rsync \ ---archive \ ---partial \ ---progress \ ---verbose \ ---delete-after \ -" +rsda() { + rsb \ + --delete-after \ + "${@}" +} # synchronize and delete before -alias rsdb="\ -rsync \ ---archive \ ---partial \ ---progress \ ---verbose \ ---delete-before \ -" +rsdb() { + rsb \ + --delete-before \ + "${@}" +} From 6a49f4981ac7d346b9775947316551c0e05ce524 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 16:24:18 +0100 Subject: [PATCH 606/969] =?UTF-8?q?=E2=88=92=C2=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/alias/micro.sh | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 shell/alias/micro.sh diff --git a/shell/alias/micro.sh b/shell/alias/micro.sh deleted file mode 100644 index b0aa4be..0000000 --- a/shell/alias/micro.sh +++ /dev/null @@ -1,4 +0,0 @@ -µ() { - micro \ - "${@}" -} From c68598931b8e5104233a5467791d5feef214db52 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 16:37:04 +0100 Subject: [PATCH 607/969] sh --- shell/alias/shell.sh | 3 +++ shell/main.sh | 3 +++ shell/shell.sh | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/shell/alias/shell.sh b/shell/alias/shell.sh index d38c3cb..531b4b0 100644 --- a/shell/alias/shell.sh +++ b/shell/alias/shell.sh @@ -17,6 +17,9 @@ x() { "${@}" } +# shellcheck disable=SC2154 +[ "${SH}" = "bash" ] || return + # back # shellcheck disable=SC3033 diff --git a/shell/main.sh b/shell/main.sh index 0ccf86b..226062c 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -1,5 +1,8 @@ [ -n "${ENV}" ] || export ENV="/etc/shell/main.sh" +SH="$(cat /proc/$$/comm)" +export SH + main_source_directory() { local path="${1}" if [ -d "${path}" ]; then diff --git a/shell/shell.sh b/shell/shell.sh index b50964e..edddde6 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -1,10 +1,10 @@ PS1="\$(shell_prompt \${?})" PS2="\ ├ " -SH="$(cat /proc/$$/comm)" shell_color() { local code="${1}" + # shellcheck disable=SC2154 case "${SH}" in "bash") printf "\e[0" From bd4fe3656e7449db063baf38f528f281b1f5102c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 16:45:07 +0100 Subject: [PATCH 608/969] m,remount --- shell/alias/mount.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/shell/alias/mount.sh b/shell/alias/mount.sh index ca11b0e..d6329c3 100644 --- a/shell/alias/mount.sh +++ b/shell/alias/mount.sh @@ -1,10 +1,11 @@ -alias m="\ -mount \ -" +m() { + mount \ + "${@}" +} # remount read-only medium in read-write -alias remount="\ -mount \ --o \"remount,rw\" \ -\"/usr/lib/live/mount/medium\" \ -" +remount() { + mount \ + -o "remount,rw" \ + "/usr/lib/live/mount/medium" +} From 2acb0be68a43c54d714c69fa48c15da0721eb8be Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 16:48:48 +0100 Subject: [PATCH 609/969] bfdf,bfdu --- shell/alias/btrfs.sh | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/shell/alias/btrfs.sh b/shell/alias/btrfs.sh index 6b4392c..c72346d 100644 --- a/shell/alias/btrfs.sh +++ b/shell/alias/btrfs.sh @@ -1,15 +1,17 @@ -alias bfdf="\ -btrfs \ -filesystem \ -df \ -" +bfdf() { + btrfs \ + filesystem \ + df \ + "${@}" +} -alias bfdu="\ -btrfs \ -filesystem \ -du \ ---summarize \ -" +bfdu() { + btrfs \ + filesystem \ + du \ + --summarize \ + "${@}" +} alias bfu="\ btrfs \ From 9312698f43e5cd3c78f0d46cb2e1e024ce94756b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 16:49:41 +0100 Subject: [PATCH 610/969] bfu --- shell/alias/btrfs.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/shell/alias/btrfs.sh b/shell/alias/btrfs.sh index c72346d..6e8e0f2 100644 --- a/shell/alias/btrfs.sh +++ b/shell/alias/btrfs.sh @@ -13,11 +13,12 @@ bfdu() { "${@}" } -alias bfu="\ -btrfs \ -filesystem \ -usage \ -" +bfu() { + btrfs \ + filesystem \ + usage \ + "${@}" +} alias bpg="\ btrfs \ From 01b0224eee7ebe31028294ecdeb0736a742a156d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 16:53:19 +0100 Subject: [PATCH 611/969] bsc,bsd,bss,bssr --- shell/alias/btrfs.sh | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/shell/alias/btrfs.sh b/shell/alias/btrfs.sh index 6e8e0f2..defbf1a 100644 --- a/shell/alias/btrfs.sh +++ b/shell/alias/btrfs.sh @@ -26,26 +26,30 @@ property \ get \ " -alias bsc="\ -btrfs \ -subvolume \ -create \ -" +bsc() { + btrfs \ + subvolume \ + create \ + "${@}" +} -alias bsd="\ -btrfs \ -subvolume \ -delete \ -" +bsd() { + btrfs \ + subvolume \ + delete \ + "${@}" +} -alias bss="\ -btrfs \ -subvolume \ -snapshot \ -" +bss() { + btrfs \ + subvolume \ + snapshot \ + "${@}" +} -alias bssr="\ -btrfs \ -subvolume \ -snapshot -r \ -" +bssr() { + btrfs \ + subvolume \ + snapshot -r \ + "${@}" +} From db596ce969b63f1e29bd8bc1f34c381e6f34c6dc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 16:55:31 +0100 Subject: [PATCH 612/969] bpg --- shell/alias/btrfs.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/shell/alias/btrfs.sh b/shell/alias/btrfs.sh index defbf1a..061d373 100644 --- a/shell/alias/btrfs.sh +++ b/shell/alias/btrfs.sh @@ -20,11 +20,12 @@ bfu() { "${@}" } -alias bpg="\ -btrfs \ -property \ -get \ -" +bpg() { + btrfs \ + property \ + get \ + "${@}" +} bsc() { btrfs \ From 3360a7983dca85189112679b1d7aebe1f8136d2b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 16:59:23 +0100 Subject: [PATCH 613/969] ga,gaa --- shell/alias/git.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index a639a75..fdcbffc 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -1,15 +1,17 @@ # add to index -alias ga="\ -git \ -add \ -" +ga() { + git \ + add \ + "${@}" +} # add all to index -alias gaa="\ -git \ -add \ ---all \ -" +gaa() { + git \ + add \ + --all \ + "${@}" +} # add parts to index alias gap="\ From ecb6a686f2e2d30340dfd7ad4e9fa4cc57f8a8ac Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 17:01:12 +0100 Subject: [PATCH 614/969] gaap,gap --- shell/alias/git.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index fdcbffc..88188c2 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -13,12 +13,22 @@ gaa() { "${@}" } +# add parts of all to index +gaap() { + git \ + add \ + --all \ + --patch \ + "${@}" +} + # add parts to index -alias gap="\ -git \ -add \ ---patch \ -" +gap() { + git \ + add \ + --patch \ + "${@}" +} # create a branch alias gb="\ From 1ddba597596a31b6335c0a10616b61dc01ee280f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 18:43:09 +0100 Subject: [PATCH 615/969] gb,gbd,gbdf,gbl,gbs --- shell/alias/git.sh | 61 +++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 88188c2..ce073a0 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -31,42 +31,47 @@ gap() { } # create a branch -alias gb="\ -git \ -branch \ -" +gb() { + git \ + branch \ + "${@}" +} # delete a branch -alias gbd="\ -git \ -branch \ ---delete \ -" +gbd() { + git \ + branch \ + --delete \ + "${@}" +} # force a branch deletion -alias gbdf="\ -git \ -branch \ ---delete \ ---force \ -" +gbdf() { + git \ + branch \ + --delete \ + --force \ + "${@}" +} # list branches -alias gbl="\ -git \ -branch \ ---all \ ---list \ ---verbose \ ---verbose \ -" +gbl() { + git \ + branch \ + --all \ + --list \ + --verbose \ + --verbose \ + "${@}" +} # set the link to a remote branch from a local branch -alias gbsu="\ -git \ -branch \ ---set-upstream-to \ -" +gbs() { + git \ + branch \ + --set-upstream-to \ + "${@}" +} # clone a remote repository alias gc="\ From a92770848e336e08f8c04752e49ff48439c38410 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 18:48:01 +0100 Subject: [PATCH 616/969] gcf --- shell/alias/git.sh | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index ce073a0..5bec3a2 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -73,19 +73,14 @@ gbs() { "${@}" } -# clone a remote repository -alias gc="\ -git \ -clone \ -" - # clean untracked files -alias gcf="\ -git \ -clean \ --d \ ---force \ -" +gcf() { + git \ + clean \ + -d \ + --force \ + "${@}" +} # commit the index alias gcm="\ From 3554f0b90536fccd1b670b283b5c3c584d291abd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 18:51:33 +0100 Subject: [PATCH 617/969] gco,gcoo,gcp,gcpa,gcpc --- shell/alias/git.sh | 51 +++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 5bec3a2..b1ebb60 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -115,37 +115,42 @@ commit \ " # switch to a branch or checkout file(s) from a commit -alias gco="\ -git \ -checkout \ -" +gco() { + git \ + checkout \ + "${@}" +} # checkout an orphan branch -alias gcoo="\ -git \ -checkout \ ---orphan \ -" +gcoo() { + git \ + checkout \ + --orphan \ + "${@}" +} # pick a commit -alias gcp="\ -git \ -cherry-pick \ -" +gcp() { + git \ + cherry-pick \ + "${@}" +} # abort the commit pick -alias gcpa="\ -git \ -cherry-pick \ ---abort \ -" +gcpa() { + git \ + cherry-pick \ + --abort \ + "${@}" +} # continue the commit pick -alias gcpc="\ -git \ -cherry-pick \ ---continue \ -" +gcpc() { + git \ + cherry-pick \ + --continue \ + "${@}" +} # configure the user name alias gcun="\ From c5185768b0c71b18e5c26c7aa34c01702d2d85b7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 18:54:56 +0100 Subject: [PATCH 618/969] gcue,gcun --- shell/alias/git.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index b1ebb60..5ce5859 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -152,19 +152,21 @@ gcpc() { "${@}" } -# configure the user name -alias gcun="\ -git \ -config \ -user.name \ -" - # configure the user email -alias gcue="\ -git \ -config \ -user.email \ -" +gcue() { + git \ + config \ + "user.email" \ + "${@}" +} + +# configure the user name +gcun() { + git \ + config \ + "user.name" \ + "${@}" +} # differences from last or between commits alias gd="\ From 5539baa3402946e85b68f3fc55f2ad857389bdaa Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 19:01:27 +0100 Subject: [PATCH 619/969] gd,gdc,gdcw,gdt,gdw --- shell/alias/git.sh | 55 +++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 5ce5859..a93bcb5 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -169,39 +169,44 @@ gcun() { } # differences from last or between commits -alias gd="\ -git \ -diff \ -" +gd() { + git \ + diff \ + "${@}" +} # display what is indexed in cache -alias gdc="\ -git \ -diff \ ---cached \ -" +gdc() { + git \ + diff \ + --cached \ + "${@}" +} # indexed character-level differences -alias gdcw="\ -git \ -diff \ ---cached \ ---word-diff-regex=. \ -" +gdcw() { + git \ + diff \ + --cached \ + --word-diff-regex "." \ + "${@}" +} # differences via external tool -alias gdt="\ -git \ -difftool \ ---dir-diff \ -" +gdt() { + git \ + difftool \ + --dir-diff \ + "${@}" +} # character-level differences -alias gdw="\ -git \ -diff \ ---word-diff-regex=. \ -" +gdw() { + git \ + diff \ + --word-diff-regex "." \ + "${@}" +} # fetch from the remote repository alias gf="\ From 7f814102e06b748d1939d54787c833a57d57f54c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 19:02:56 +0100 Subject: [PATCH 620/969] gf,gfp --- shell/alias/git.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index a93bcb5..4044fa8 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -209,21 +209,20 @@ gdw() { } # fetch from the remote repository -alias gf="\ -git \ -fetch \ ---verbose \ ---tags \ -" +gf() { + git \ + fetch \ + --tags \ + --verbose \ + "${@}" +} # fetch from remote repository and prune local orphan branches -alias gfp="\ -git \ -fetch \ ---verbose \ ---tags \ ---prune \ -" +gfp() { + gf \ + --prune \ + "${@}" +} # garbage collect all orphan commits alias ggc="\ From beb479ba7ce4931b004fba3e0fc3a09b815dd993 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 19:07:11 +0100 Subject: [PATCH 621/969] ggc --- shell/alias/git.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 4044fa8..801df15 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -225,18 +225,17 @@ gfp() { } # garbage collect all orphan commits -alias ggc="\ -git \ -reflog \ -expire \ ---all \ ---expire \"all\" \ -; \ -git \ -gc \ ---aggressive \ ---prune=\"now\" \ -" +ggc() { + git \ + reflog \ + expire \ + --all \ + --expire "all" && + git \ + gc \ + --aggressive \ + --prune="now" +} # initialize a new repository alias gi="\ From d8de9913ce6c20ec99e62c4adb0aff8820e565e4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 19:08:27 +0100 Subject: [PATCH 622/969] gi,gib --- shell/alias/git.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 801df15..977b3e0 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -238,17 +238,19 @@ ggc() { } # initialize a new repository -alias gi="\ -git \ -init \ -" +gi() { + git \ + init \ + "${@}" +} # initialize a new bare repository -alias gib="\ -git \ -init \ ---bare \ -" +gib() { + git \ + init \ + --bare \ + "${@}" +} # log commits history alias gl="\ From 7a1320e10828675512df3404a0012f23a90135f6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 19:17:36 +0100 Subject: [PATCH 623/969] gla,glb --- shell/alias/git.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 977b3e0..60d84d9 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -252,14 +252,21 @@ gib() { "${@}" } -# log commits history -alias gl="\ -git \ -log \ ---all \ ---graph \ ---format=\"%C(auto)%h%d %C(red)%ai%C(auto) %an%n%B\" \ -" +# log all history +gla() { + glb \ + --all \ + "${@}" +} + +# log branch history +glb() { + git \ + log \ + --graph \ + --format="%C(auto)%h%d %C(red)%ai%C(auto) %an%n%B" \ + "${@}" +} # log medium information alias glm="\ From c2ce37595c33a222abe0b81a380b2b4ff3807e71 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 19:18:00 +0100 Subject: [PATCH 624/969] =?UTF-8?q?=E2=86=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/alias/git.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 60d84d9..2b79893 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -263,8 +263,8 @@ gla() { glb() { git \ log \ - --graph \ --format="%C(auto)%h%d %C(red)%ai%C(auto) %an%n%B" \ + --graph \ "${@}" } From 58578f952322c87886e15afe0cba62bddc29bfdc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 20:27:36 +0100 Subject: [PATCH 625/969] gl,gla,glap,glp --- shell/alias/git.sh | 61 +++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 2b79893..cd81130 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -252,41 +252,46 @@ gib() { "${@}" } -# log all history -gla() { - glb \ - --all \ - "${@}" -} - -# log branch history -glb() { +# log history +gl() { + local format="\ +%C(auto)%h%d +S %C(red)%GS +A %C(green)%ai + %C(green)%an %ae +C %C(blue)%ci + %C(blue)%cn %ce +%B" git \ log \ - --format="%C(auto)%h%d %C(red)%ai%C(auto) %an%n%B" \ + --abbrev=8 \ + --abbrev-commit \ + --format="${format}" \ --graph \ "${@}" } -# log medium information -alias glm="\ -git \ -log \ ---all \ ---decorate \ ---graph \ ---pretty=medium \ -" +# log all history +gla() { + gl \ + --all \ + "${@}" +} -# log commits history with patches -alias glp="\ -git \ -log \ ---all \ ---graph \ ---format=\"%C(auto)%h%d %C(red)%ai%C(auto) %an%n%B\" \ ---patch \ -" +# log all history with patches +glap() { + gl \ + --all \ + --patch \ + "${@}" +} + +# log history with patches +glp() { + gl \ + --patch \ + "${@}" +} # abort the current merge commit alias gma="\ From 232f583be3fae64e3a8de0002d39b0ea3dbfa18f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 21:49:50 +0100 Subject: [PATCH 626/969] =?UTF-8?q?=E2=88=92sign?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/alias/git.sh | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index cd81130..61188ed 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -308,15 +308,6 @@ merge \ --message \ " -# do a signed merge commit -alias gmcs="\ -git \ -merge \ ---no-ff \ ---gpg-sign \ --m \ -" - # fast-forward to remote branch alias gmf="\ git \ @@ -468,10 +459,3 @@ git \ tag \ --delete \ " - -# tag a commit and sign -alias gts="\ -git \ -tag \ ---sign \ -" From 19b95e6061798dd9e55b2860d5d3657bb90894f0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 01:31:06 +0100 Subject: [PATCH 627/969] \n --- shell/shell.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/shell/shell.sh b/shell/shell.sh index edddde6..7d32424 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -76,13 +76,11 @@ shell_prompt() { fi fi # new - view="${view} -" + view="${view}\\n" # path view="${view}${SH_CYAN}${path}" # new - view="${view} -" + view="${view}\\n" # frame view="${view}${SH_DEFAULT}┌ " # user @@ -96,8 +94,7 @@ shell_prompt() { view="${view}${SH_DEFAULT} @ " view="${view}${SH_BROWN}${host}" # new - view="${view} -" + view="${view}\\n" # prompt view="${view}${SH_DEFAULT}${PS2}" # print From 5e9ae45748bc01bbfef30e287ebd902898bc346f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 01:32:34 +0100 Subject: [PATCH 628/969] %b --- shell/shell.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/shell.sh b/shell/shell.sh index 7d32424..189fd1b 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -98,7 +98,7 @@ shell_prompt() { # prompt view="${view}${SH_DEFAULT}${PS2}" # print - printf "%s" "${view}" + printf "%b" "${view}" } shell_setup() { From 0eea7d052eaf7e4a5bf204f3edb412bc16589dd6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 02:05:07 +0100 Subject: [PATCH 629/969] fix --- shell/shell.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shell/shell.sh b/shell/shell.sh index 189fd1b..c25ab55 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -7,10 +7,11 @@ shell_color() { # shellcheck disable=SC2154 case "${SH}" in "bash") - printf "\e[0" + printf "\x01\e[0" if [ -n "${code}" ]; then printf "%s" ";${code}" fi + printf "m\x02" ;; *) printf "\033[" @@ -19,9 +20,9 @@ shell_color() { else printf "0" fi + printf "m" ;; esac - printf "m" } SH_BROWN="$(shell_color 33)" SH_CYAN="$(shell_color 36)" From 235202a64dd8cebc39ab05f5ae8fefea6517be50 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 02:26:32 +0100 Subject: [PATCH 630/969] gma,gmc,gmf,gms,gmt --- shell/alias/git.sh | 55 +++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 61188ed..57c897c 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -294,39 +294,44 @@ glp() { } # abort the current merge commit -alias gma="\ -git \ -merge \ ---abort \ -" +gma() { + git \ + merge \ + --abort \ + "${@}" +} # do a merge commit -alias gmc="\ -git \ -merge \ ---no-ff \ ---message \ -" +gmc() { + git \ + merge \ + --no-ff \ + --message \ + "${@}" +} # fast-forward to remote branch -alias gmf="\ -git \ -merge \ ---ff-only \ -" +gmf() { + git \ + merge \ + --ff-only \ + "${@}" +} # squash a branch and index its modifications -alias gms="\ -git \ -merge \ ---squash \ -" +gms() { + git \ + merge \ + --squash \ + "${@}" +} # merge via external tool -alias gmt="\ -git \ -mergetool \ -" +gmt() { + git \ + mergetool \ + "${@}" +} # push to the remote repository alias gp="\ From 5780c0ed185b4ec98501a3607a8883874070c0b6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 02:31:52 +0100 Subject: [PATCH 631/969] gp,gpd,gpf --- shell/alias/git.sh | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 57c897c..9956b23 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -334,29 +334,28 @@ gmt() { } # push to the remote repository -alias gp="\ -git \ -push \ ---verbose \ ---tags \ -" +gp() { + git \ + push \ + --tags \ + --verbose \ + "${@}" +} # delete from the remote repository -alias gpd="\ -git \ -push \ ---verbose \ ---delete \ -" +gpd() { + git \ + push \ + --delete \ + "${@}" +} # force the push to the remote repository -alias gpf="\ -git \ -push \ ---verbose \ ---tags \ ---force \ -" +gpf() { + gp \ + --force \ + "${@}" +} # rebase current branch onto another alias grb="\ From af70985d82224125cde15c3ec1f4f6decb80a0ab Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 02:45:45 +0100 Subject: [PATCH 632/969] rebase,rm --- shell/alias/git.sh | 62 +++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 9956b23..3517ea0 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -358,44 +358,50 @@ gpf() { } # rebase current branch onto another -alias grb="\ -git \ -rebase \ -" +grb() { + git \ + rebase \ + "${@}" +} # abort current rebase -alias grba="\ -git \ -rebase \ ---abort \ -" +grba() { + git \ + rebase \ + --abort \ + "${@}" +} # continue current rebase -alias grbc="\ -git \ -rebase \ ---continue \ -" +grbc() { + git \ + rebase \ + --continue \ + "${@}" +} # force rebase without fast-forward -alias grbf="\ -git \ -rebase \ ---force-rebase \ -" +grbf() { + git \ + rebase \ + --force-rebase \ + "${@}" +} # rebase interactively -alias grbi="\ -git \ -rebase \ ---interactive \ -" +grbi() { + git \ + rebase \ + --interactive \ + "${@}" +} # remove and add removal to index -alias grm="\ -git \ -rm \ -" +grm() { + git \ + rm \ + "${@}" +} # add a new remote repository alias grma="\ From 79b5c724e4ebadfdc8ce09e27340debab65bf10c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 02:53:03 +0100 Subject: [PATCH 633/969] remote --- shell/alias/git.sh | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 3517ea0..87a4978 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -404,32 +404,28 @@ grm() { } # add a new remote repository -alias grma="\ -git \ -remote \ -add \ -" +grma() { + git \ + remote \ + add \ + "${@}" +} # list remote repositories -alias grml="\ -git \ -remote \ ---verbose \ -" - -# show a connection to a repository -alias grms="\ -git \ -remote \ -show \ -" +grml() { + git \ + remote \ + --verbose \ + "${@}" +} # set the location of the remote repository -alias grmsu="\ -git \ -remote \ -set-url \ -" +grms() { + git \ + remote \ + set-url \ + "${@}" +} # remove file(s) from index or move current branch pointer alias grs="\ From e5c43ae6769fc8d1daf93e3d6bc9ff0cccf59d62 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 02:54:03 +0100 Subject: [PATCH 634/969] reset --- shell/alias/git.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 87a4978..7a74031 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -428,17 +428,19 @@ grms() { } # remove file(s) from index or move current branch pointer -alias grs="\ -git \ -reset \ -" +grs() { + git \ + reset \ + "${@}" +} # wipe modifications or reset current branch to another commit -alias grsh="\ -git \ -reset \ ---hard \ -" +grsh() { + git \ + reset \ + --hard \ + "${@}" +} # current state of repository alias gs="\ From 5f23aadfe598504f1e8a13fe2bcda72ba862260b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 02:55:45 +0100 Subject: [PATCH 635/969] tag --- shell/alias/git.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 7a74031..00bc731 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -456,14 +456,16 @@ show \ " # tag a commit -alias gt="\ -git \ -tag \ -" +gt() { + git \ + tag \ + "${@}" +} # delete a tag -alias gtd="\ -git \ -tag \ ---delete \ -" +gtd() { + git \ + tag \ + --delete \ + "${@}" +} From 033999e9f6243165c45e2bbbb803db81fc660756 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 02:58:43 +0100 Subject: [PATCH 636/969] gs,gsc --- shell/alias/git.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 00bc731..a95c7f5 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -443,17 +443,19 @@ grsh() { } # current state of repository -alias gs="\ -git \ -status \ ---untracked-files=all \ -" +gs() { + git \ + status \ + --untracked-files="all" \ + "${@}" +} # show a commit -alias gsc="\ -git \ -show \ -" +gsc() { + git \ + show \ + "${@}" +} # tag a commit gt() { From 7e788e5940c7bc91862538864f4b2a89084f7f05 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 03:07:23 +0100 Subject: [PATCH 637/969] commit --- shell/alias/git.sh | 47 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index a95c7f5..bb7301e 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -83,36 +83,31 @@ gcf() { } # commit the index -alias gcm="\ -git \ -commit \ ---message \ -" +gcm() { + git \ + commit \ + --message \ + "${@}" +} # redo the last commit with a different message -alias gcma="\ -git \ -commit \ ---amend \ ---message \ -" +gcma() { + git \ + commit \ + --amend \ + --message \ + "${@}" +} # make a root commit -alias gcme="\ -git \ -commit \ ---allow-empty \ ---allow-empty-message \ ---message \"\" \ -" - -# commit the index and sign -alias gcms="\ -git \ -commit \ ---gpg-sign \ ---message \ -" +gcme() { + git \ + commit \ + --allow-empty \ + --allow-empty-message \ + --message \ + "${@}" +} # switch to a branch or checkout file(s) from a commit gco() { From cd4d7d3fcb01980eb4a1230bcaf0d1ecccb4a257 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 03:09:36 +0100 Subject: [PATCH 638/969] gcam,gcem --- shell/alias/git.sh | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index bb7301e..6dd641e 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -73,6 +73,25 @@ gbs() { "${@}" } +# redo the last commit with a different message +gcam() { + git \ + commit \ + --amend \ + --message \ + "${@}" +} + +# make a root commit +gcem() { + git \ + commit \ + --allow-empty \ + --allow-empty-message \ + --message \ + "${@}" +} + # clean untracked files gcf() { git \ @@ -90,25 +109,6 @@ gcm() { "${@}" } -# redo the last commit with a different message -gcma() { - git \ - commit \ - --amend \ - --message \ - "${@}" -} - -# make a root commit -gcme() { - git \ - commit \ - --allow-empty \ - --allow-empty-message \ - --message \ - "${@}" -} - # switch to a branch or checkout file(s) from a commit gco() { git \ From dde88afb21956c016b3395f7aff7b1c39e279560 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 03:16:32 +0100 Subject: [PATCH 639/969] agud,agug --- shell/alias/apt.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/shell/alias/apt.sh b/shell/alias/apt.sh index c4a0a7a..b01e62d 100644 --- a/shell/alias/apt.sh +++ b/shell/alias/apt.sh @@ -59,13 +59,15 @@ remove \ " # update packages catalog -alias agud="\ -apt-get \ -update \ -" +agud() { + apt-get \ + update \ + "${@}" +} # upgrade forbidding package installation or removal -alias agug="\ -apt-get \ -upgrade \ -" +agug() { + apt-get \ + upgrade \ + "${@}" +} From a2efc157076fefbf8ee1e2b5b8c86fa6920b7051 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 03:18:15 +0100 Subject: [PATCH 640/969] agp,agr --- shell/alias/apt.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/shell/alias/apt.sh b/shell/alias/apt.sh index b01e62d..de8ddfa 100644 --- a/shell/alias/apt.sh +++ b/shell/alias/apt.sh @@ -47,16 +47,18 @@ install \ " # -alias agp="\ -apt-get \ -purge \ -" +agp() { + apt-get \ + purge \ + "${@}" +} # -alias agr="\ -apt-get \ -remove \ -" +agr() { + apt-get \ + remove \ + "${@}" +} # update packages catalog agud() { From 34b6b915f48e6c2de388bf567378250f6ad8bacb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 03:20:31 +0100 Subject: [PATCH 641/969] agi --- shell/alias/apt.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/shell/alias/apt.sh b/shell/alias/apt.sh index de8ddfa..a4d38b0 100644 --- a/shell/alias/apt.sh +++ b/shell/alias/apt.sh @@ -41,10 +41,11 @@ dist-upgrade \ " # install packages -alias agi="\ -apt-get \ -install \ -" +agi() { + apt-get \ + install \ + "${@}" +} # agp() { From f8ed45ad959e6693303300d4baa59e56316a105c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 03:25:02 +0100 Subject: [PATCH 642/969] agap,agar --- shell/alias/apt.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/shell/alias/apt.sh b/shell/alias/apt.sh index a4d38b0..f3c7624 100644 --- a/shell/alias/apt.sh +++ b/shell/alias/apt.sh @@ -17,16 +17,18 @@ search \ " # -alias agap="\ -apt-get \ -autopurge \ -" +agap() { + apt-get \ + autopurge \ + "${@}" +} # -alias agar="\ -apt-get \ -autoremove \ -" +agar() { + apt-get \ + autoremove \ + "${@}" +} # clean packages cache alias agc="\ From d34c06899024bfe95aa3cd56e3e4fc1701a929aa Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 03:32:01 +0100 Subject: [PATCH 643/969] acl,acp,acs --- shell/alias/apt.sh | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/shell/alias/apt.sh b/shell/alias/apt.sh index f3c7624..afc1dbd 100644 --- a/shell/alias/apt.sh +++ b/shell/alias/apt.sh @@ -1,20 +1,23 @@ # show package information -alias ac="\ -apt-cache \ -show \ -" +acl() { + apt-cache \ + show \ + "${@}" +} # package versions policy -alias acp="\ -apt-cache \ -policy \ -" +acp() { + apt-cache \ + policy \ + "${@}" +} # search package -alias acs="\ -apt-cache \ -search \ -" +acs() { + apt-cache \ + search \ + "${@}" +} # agap() { From 29ac7232426bb20a991a6327294595893ef20bfd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 03:32:58 +0100 Subject: [PATCH 644/969] agc --- shell/alias/apt.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/shell/alias/apt.sh b/shell/alias/apt.sh index afc1dbd..8ce8252 100644 --- a/shell/alias/apt.sh +++ b/shell/alias/apt.sh @@ -34,10 +34,11 @@ agar() { } # clean packages cache -alias agc="\ -apt-get \ -clean \ -" +agc() { + apt-get \ + clean \ + "${@}" +} # upgrade allowing package installation or removal alias agdu="\ From df71c07296b14cc4ad60e7d756c79a59b60e6ed7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 03:42:34 +0100 Subject: [PATCH 645/969] l --- shell/alias/ls.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/shell/alias/ls.sh b/shell/alias/ls.sh index b6d3204..75eb5a5 100644 --- a/shell/alias/ls.sh +++ b/shell/alias/ls.sh @@ -3,11 +3,12 @@ di=0;94\ " # list current directory’s entries -alias l="\ -ls \ ---all \ ---color \ --l \ --p \ ---time-style \"+%Y%m%d-%H%M%S%-:::z\" \ -" +l() { + ls \ + --all \ + --color \ + -l \ + -p \ + --time-style "+%Y%m%d-%H%M%S%-:::z" \ + "${@}" +} From 7918a3c33628d1e89d97b1770e132911b7c4461f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 03:47:24 +0100 Subject: [PATCH 646/969] lt,ltt --- shell/alias/ls.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/shell/alias/ls.sh b/shell/alias/ls.sh index 75eb5a5..8be2be0 100644 --- a/shell/alias/ls.sh +++ b/shell/alias/ls.sh @@ -9,6 +9,20 @@ l() { --color \ -l \ -p \ + "${@}" +} + +# list timestamps +lt() { + l \ --time-style "+%Y%m%d-%H%M%S%-:::z" \ "${@}" } + +# list timestamps recent last +ltt() { + l \ + --reverse \ + -t \ + "${@}" +} From bb90ce401be2ea7f3096785dd941916f6ca8e7a3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 03:50:00 +0100 Subject: [PATCH 647/969] fixes --- shell/alias/ls.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/alias/ls.sh b/shell/alias/ls.sh index 8be2be0..da0d1bc 100644 --- a/shell/alias/ls.sh +++ b/shell/alias/ls.sh @@ -9,6 +9,7 @@ l() { --color \ -l \ -p \ + --time-style "+" \ "${@}" } @@ -21,7 +22,7 @@ lt() { # list timestamps recent last ltt() { - l \ + lt \ --reverse \ -t \ "${@}" From a38610d0e9ada3883d4deef067812d730f426faa Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 03:55:05 +0100 Subject: [PATCH 648/969] agfu --- shell/alias/apt.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/shell/alias/apt.sh b/shell/alias/apt.sh index 8ce8252..aba5844 100644 --- a/shell/alias/apt.sh +++ b/shell/alias/apt.sh @@ -41,10 +41,11 @@ agc() { } # upgrade allowing package installation or removal -alias agdu="\ -apt-get \ -dist-upgrade \ -" +agfu() { + apt-get \ + full-upgrade \ + "${@}" +} # install packages agi() { From ae0807bf54e84a4a72f02cd33f07be7ac30fe4f8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 03:59:26 +0100 Subject: [PATCH 649/969] remote --- shell/alias/git.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 6dd641e..44d1d62 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -414,8 +414,16 @@ grml() { "${@}" } -# set the location of the remote repository +# show connection to a remote repository grms() { + git \ + remote \ + show \ + "${@}" +} + +# set the location of a remote repository +grmsu() { git \ remote \ set-url \ From a6e05017b7cb5c8cdaff3f6adc03586271a177d8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 13:23:38 +0100 Subject: [PATCH 650/969] gbsu --- shell/alias/git.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 44d1d62..7765adb 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -66,12 +66,13 @@ gbl() { } # set the link to a remote branch from a local branch -gbs() { +git_branch_set_upstream() { git \ branch \ --set-upstream-to \ "${@}" } +gbsu() { git_branch_set_upstream "${@}"; } # redo the last commit with a different message gcam() { From f4b9f4780cb8c8fadec53eeb1397dca2f5408b63 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 13:35:36 +0100 Subject: [PATCH 651/969] wip --- shell/alias/git.sh | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 7765adb..802813e 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -75,16 +75,17 @@ git_branch_set_upstream() { gbsu() { git_branch_set_upstream "${@}"; } # redo the last commit with a different message -gcam() { +git_commit_amend_message() { git \ commit \ --amend \ --message \ "${@}" } +gcam() { git_commit_amend_message "${@}"; } # make a root commit -gcem() { +git_commit_empty_message() { git \ commit \ --allow-empty \ @@ -92,61 +93,69 @@ gcem() { --message \ "${@}" } +gcem() { git_commit_empty_message "${@}"; } # clean untracked files -gcf() { +git_clean_force() { git \ clean \ -d \ --force \ "${@}" } +gcf() { git_clean_force "${@}"; } # commit the index -gcm() { +git_commit_message() { git \ commit \ --message \ "${@}" } +gcm() { git_commit_message "${@}"; } # switch to a branch or checkout file(s) from a commit -gco() { +git_checkout() { git \ checkout \ "${@}" } +gc() { git_checkout "${@}"; } # checkout an orphan branch -gcoo() { +git_checkout_orphan() { git \ checkout \ --orphan \ "${@}" } +gco() { git_checkout_orphan "${@}"; } # pick a commit -gcp() { +git_cherry_pick() { git \ cherry-pick \ "${@}" } +gcp() { git_cherry_pick "${@}"; } # abort the commit pick -gcpa() { +git_cherry_pick_abort() { git \ cherry-pick \ --abort \ "${@}" } +gcpa() { git_cherry_pick_abort "${@}"; } # continue the commit pick -gcpc() { +git_cherry_pick_continue() { git \ cherry-pick \ --continue \ "${@}" } +gcpc() { git_cherry_pick_continue "${@}"; } # configure the user email gcue() { From 1bafe4d3852a2b26aa9f0745c5e09c73ac228a4d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 13:58:39 +0100 Subject: [PATCH 652/969] wip --- shell/alias/git.sh | 54 ++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 802813e..cff9961 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -158,79 +158,88 @@ git_cherry_pick_continue() { gcpc() { git_cherry_pick_continue "${@}"; } # configure the user email -gcue() { +git_config_user_email() { git \ config \ "user.email" \ "${@}" } +gcue() { git_config_user_email "${@}"; } # configure the user name -gcun() { +git_config_user_name() { git \ config \ "user.name" \ "${@}" } +gcun() { git_config_user_name "${@}"; } # differences from last or between commits -gd() { +git_diff() { git \ diff \ "${@}" } +gd() { git_diff "${@}"; } # display what is indexed in cache -gdc() { +git_diff_cached() { git \ diff \ --cached \ "${@}" } +gdc() { git_diff_cached "${@}"; } # indexed character-level differences -gdcw() { +git_diff_cached_word() { git \ diff \ --cached \ --word-diff-regex "." \ "${@}" } +gdcw() { git_diff_cached_word "${@}"; } # differences via external tool -gdt() { +git_diff_tool() { git \ difftool \ --dir-diff \ "${@}" } +gdt() { git_diff_tool "${@}"; } # character-level differences -gdw() { +git_diff_word() { git \ diff \ --word-diff-regex "." \ "${@}" } +gdw() { git_diff_word "${@}"; } # fetch from the remote repository -gf() { +git_fetch() { git \ fetch \ --tags \ --verbose \ "${@}" } +gf() { git_fetch "${@}"; } # fetch from remote repository and prune local orphan branches -gfp() { +git_fetch_prune() { gf \ --prune \ "${@}" } +gfp() { git_fetch_prune "${@}"; } # garbage collect all orphan commits -ggc() { +git_garbage_collect() { git \ reflog \ expire \ @@ -241,24 +250,27 @@ ggc() { --aggressive \ --prune="now" } +ggc() { git_garbage_collect "${@}"; } # initialize a new repository -gi() { +git_init() { git \ init \ "${@}" } +gi() { git_init "${@}"; } # initialize a new bare repository -gib() { +git_init_bare() { git \ init \ --bare \ "${@}" } +gib() { git_init_bare "${@}"; } # log history -gl() { +git_log() { local format="\ %C(auto)%h%d S %C(red)%GS @@ -275,45 +287,51 @@ C %C(blue)%ci --graph \ "${@}" } +gl() { git_log "${@}"; } # log all history -gla() { +git_log_all() { gl \ --all \ "${@}" } +gla() { git_log_all "${@}"; } # log all history with patches -glap() { +git_log_all_patch() { gl \ --all \ --patch \ "${@}" } +glap() { git_log_all_patch "${@}"; } # log history with patches -glp() { +git_log_patch() { gl \ --patch \ "${@}" } +glp() { git_log_patch "${@}"; } # abort the current merge commit -gma() { +git_merge_abort() { git \ merge \ --abort \ "${@}" } +gma() { git_merge_abort "${@}"; } # do a merge commit -gmc() { +git_merge_commit() { git \ merge \ --no-ff \ --message \ "${@}" } +gmc() { git_merge_commit "${@}"; } # fast-forward to remote branch gmf() { From 03d4f4289cd50be38e736df7e25e9a3262d07097 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 13:59:52 +0100 Subject: [PATCH 653/969] gm --- shell/alias/git.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index cff9961..f043683 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -314,6 +314,15 @@ git_log_patch() { } glp() { git_log_patch "${@}"; } +# fast-forward merge to remote branch +git_merge() { + git \ + merge \ + --ff-only \ + "${@}" +} +gm() { git_merge "${@}"; } + # abort the current merge commit git_merge_abort() { git \ @@ -333,14 +342,6 @@ git_merge_commit() { } gmc() { git_merge_commit "${@}"; } -# fast-forward to remote branch -gmf() { - git \ - merge \ - --ff-only \ - "${@}" -} - # squash a branch and index its modifications gms() { git \ From d24113e1b0ed45d451b5c5fb6419d6fc9b6d1a6a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 14:03:22 +0100 Subject: [PATCH 654/969] wip --- shell/alias/git.sh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index f043683..5bedf14 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -1,61 +1,68 @@ # add to index -ga() { +git_add() { git \ add \ "${@}" } +ga() { git_add "${@}"; } # add all to index -gaa() { +git_add_all() { git \ add \ --all \ "${@}" } +gaa() { git_add_all "${@}"; } # add parts of all to index -gaap() { +git_add_all_patch() { git \ add \ --all \ --patch \ "${@}" } +gaap() { git_add_all_patch "${@}"; } # add parts to index -gap() { +git_add_patch() { git \ add \ --patch \ "${@}" } +gap() { git_add_patch "${@}"; } # create a branch -gb() { +git_branch() { git \ branch \ "${@}" } +gb() { git_branch "${@}"; } # delete a branch -gbd() { +git_branch_delete() { git \ branch \ --delete \ "${@}" } +gbd() { git_branch_delete "${@}"; } # force a branch deletion -gbdf() { +git_branch_delete_force() { git \ branch \ --delete \ --force \ "${@}" } +gbdf() { git_branch_delete_force "${@}"; } # list branches -gbl() { +git_branch_list() { git \ branch \ --all \ @@ -64,6 +71,7 @@ gbl() { --verbose \ "${@}" } +gbl() { git_branch_list "${@}"; } # set the link to a remote branch from a local branch git_branch_set_upstream() { From 941adedabaa1c8f1aa0cd3b4a219f6baad1adcd6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 14:19:41 +0100 Subject: [PATCH 655/969] tasks --- readme.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/readme.md b/readme.md index f303f1f..011ed62 100644 --- a/readme.md +++ b/readme.md @@ -3,6 +3,9 @@ ## ToDo * [ ] convert alias to () +* [ ] git switch signing commits & tags +* [ ] shellcheck & shfmt +* [ ] python tools * [ ] log * [ ] ovh * [ ] clean apt cache after each install/upgrade step From 33a638dbef0d1e1a7d135c0b63bc552d67c9739a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 14:20:55 +0100 Subject: [PATCH 656/969] git --- shell/alias/git.sh | 63 ++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 5bedf14..05609a9 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -351,163 +351,184 @@ git_merge_commit() { gmc() { git_merge_commit "${@}"; } # squash a branch and index its modifications -gms() { +git_merge_squash() { git \ merge \ --squash \ "${@}" } +gms() { git_merge_squash "${@}"; } # merge via external tool -gmt() { +git_merge_tool() { git \ mergetool \ "${@}" } +gmt() { git_merge_tool "${@}"; } # push to the remote repository -gp() { +git_push() { git \ push \ --tags \ --verbose \ "${@}" } +gp() { git_push "${@}"; } # delete from the remote repository -gpd() { +git_push_delete() { git \ push \ --delete \ "${@}" } +gpd() { git_push_delete "${@}"; } # force the push to the remote repository -gpf() { +git_push_force() { gp \ --force \ "${@}" } +gpf() { git_push_force "${@}"; } # rebase current branch onto another -grb() { +git_re_base() { git \ rebase \ "${@}" } +grb() { git_re_base "${@}"; } # abort current rebase -grba() { +git_re_base_abort() { git \ rebase \ --abort \ "${@}" } +grba() { git_re_base_abort "${@}"; } # continue current rebase -grbc() { +git_re_base_continue() { git \ rebase \ --continue \ "${@}" } +grbc() { git_re_base_continue "${@}"; } # force rebase without fast-forward -grbf() { +git_re_base_force() { git \ rebase \ --force-rebase \ "${@}" } +grbf() { git_re_base_force "${@}"; } # rebase interactively -grbi() { +git_re_base_interactive() { git \ rebase \ --interactive \ "${@}" } +grbi() { git_re_base_interactive "${@}"; } # remove and add removal to index -grm() { +git_re_move() { git \ rm \ "${@}" } +grm() { git_re_move "${@}"; } # add a new remote repository -grma() { +git_re_mote_add() { git \ remote \ add \ "${@}" } +grma() { git_re_mote_add "${@}"; } # list remote repositories -grml() { +git_re_mote_list() { git \ remote \ --verbose \ "${@}" } +grml() { git_re_mote_list "${@}"; } # show connection to a remote repository -grms() { +git_re_mote_show() { git \ remote \ show \ "${@}" } +grms() { git_re_mote_show "${@}"; } # set the location of a remote repository -grmsu() { +git_re_mote_set_upstream() { git \ remote \ set-url \ "${@}" } +grmsu() { git_re_mote_set_upstream "${@}"; } # remove file(s) from index or move current branch pointer -grs() { +git_re_set() { git \ reset \ "${@}" } +grs() { git_re_set "${@}"; } # wipe modifications or reset current branch to another commit -grsh() { +git_re_set_hard() { git \ reset \ --hard \ "${@}" } +grsh() { git_re_set_hard "${@}"; } # current state of repository -gs() { +git_status() { git \ status \ --untracked-files="all" \ "${@}" } +gs() { git_status "${@}"; } # show a commit -gsc() { +git_show_commit() { git \ show \ "${@}" } +gsc() { git_show_commit "${@}"; } # tag a commit -gt() { +git_tag() { git \ tag \ "${@}" } +gt() { git_tag "${@}"; } # delete a tag -gtd() { +git_tag_delete() { git \ tag \ --delete \ "${@}" } +gtd() { git_tag_delete "${@}"; } From 797b5659402baf56cb15ed46853cd31ad46e2098 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 15:40:29 +0100 Subject: [PATCH 657/969] =?UTF-8?q?=E2=88=92~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/main.sh b/shell/main.sh index 226062c..327c956 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -46,4 +46,4 @@ main_source_file() { main_source_file "${ENV}" -main_source_directory ~/shell +main_source_directory "${HOME}/shell" From 237d34eef37c0b8bdba5fd775bdea4d62a4c7a90 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 16:59:22 +0100 Subject: [PATCH 658/969] =?UTF-8?q?=E2=86=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/alias/git.sh | 116 ++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 05609a9..8310385 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -1,21 +1,22 @@ # add to index +ga() { git_add "${@}"; } git_add() { git \ add \ "${@}" } -ga() { git_add "${@}"; } # add all to index +gaa() { git_add_all "${@}"; } git_add_all() { git \ add \ --all \ "${@}" } -gaa() { git_add_all "${@}"; } # add parts of all to index +gaap() { git_add_all_patch "${@}"; } git_add_all_patch() { git \ add \ @@ -23,35 +24,35 @@ git_add_all_patch() { --patch \ "${@}" } -gaap() { git_add_all_patch "${@}"; } # add parts to index +gap() { git_add_patch "${@}"; } git_add_patch() { git \ add \ --patch \ "${@}" } -gap() { git_add_patch "${@}"; } # create a branch +gb() { git_branch "${@}"; } git_branch() { git \ branch \ "${@}" } -gb() { git_branch "${@}"; } # delete a branch +gbd() { git_branch_delete "${@}"; } git_branch_delete() { git \ branch \ --delete \ "${@}" } -gbd() { git_branch_delete "${@}"; } # force a branch deletion +gbdf() { git_branch_delete_force "${@}"; } git_branch_delete_force() { git \ branch \ @@ -59,9 +60,9 @@ git_branch_delete_force() { --force \ "${@}" } -gbdf() { git_branch_delete_force "${@}"; } # list branches +gbl() { git_branch_list "${@}"; } git_branch_list() { git \ branch \ @@ -71,18 +72,18 @@ git_branch_list() { --verbose \ "${@}" } -gbl() { git_branch_list "${@}"; } # set the link to a remote branch from a local branch +gbsu() { git_branch_set_upstream "${@}"; } git_branch_set_upstream() { git \ branch \ --set-upstream-to \ "${@}" } -gbsu() { git_branch_set_upstream "${@}"; } # redo the last commit with a different message +gcam() { git_commit_amend_message "${@}"; } git_commit_amend_message() { git \ commit \ @@ -90,9 +91,9 @@ git_commit_amend_message() { --message \ "${@}" } -gcam() { git_commit_amend_message "${@}"; } # make a root commit +gcem() { git_commit_empty_message "${@}"; } git_commit_empty_message() { git \ commit \ @@ -101,9 +102,9 @@ git_commit_empty_message() { --message \ "${@}" } -gcem() { git_commit_empty_message "${@}"; } # clean untracked files +gcf() { git_clean_force "${@}"; } git_clean_force() { git \ clean \ @@ -111,96 +112,96 @@ git_clean_force() { --force \ "${@}" } -gcf() { git_clean_force "${@}"; } # commit the index +gcm() { git_commit_message "${@}"; } git_commit_message() { git \ commit \ --message \ "${@}" } -gcm() { git_commit_message "${@}"; } # switch to a branch or checkout file(s) from a commit +gc() { git_checkout "${@}"; } git_checkout() { git \ checkout \ "${@}" } -gc() { git_checkout "${@}"; } # checkout an orphan branch +gco() { git_checkout_orphan "${@}"; } git_checkout_orphan() { git \ checkout \ --orphan \ "${@}" } -gco() { git_checkout_orphan "${@}"; } # pick a commit +gcp() { git_cherry_pick "${@}"; } git_cherry_pick() { git \ cherry-pick \ "${@}" } -gcp() { git_cherry_pick "${@}"; } # abort the commit pick +gcpa() { git_cherry_pick_abort "${@}"; } git_cherry_pick_abort() { git \ cherry-pick \ --abort \ "${@}" } -gcpa() { git_cherry_pick_abort "${@}"; } # continue the commit pick +gcpc() { git_cherry_pick_continue "${@}"; } git_cherry_pick_continue() { git \ cherry-pick \ --continue \ "${@}" } -gcpc() { git_cherry_pick_continue "${@}"; } # configure the user email +gcue() { git_config_user_email "${@}"; } git_config_user_email() { git \ config \ "user.email" \ "${@}" } -gcue() { git_config_user_email "${@}"; } # configure the user name +gcun() { git_config_user_name "${@}"; } git_config_user_name() { git \ config \ "user.name" \ "${@}" } -gcun() { git_config_user_name "${@}"; } # differences from last or between commits +gd() { git_diff "${@}"; } git_diff() { git \ diff \ "${@}" } -gd() { git_diff "${@}"; } # display what is indexed in cache +gdc() { git_diff_cached "${@}"; } git_diff_cached() { git \ diff \ --cached \ "${@}" } -gdc() { git_diff_cached "${@}"; } # indexed character-level differences +gdcw() { git_diff_cached_word "${@}"; } git_diff_cached_word() { git \ diff \ @@ -208,27 +209,27 @@ git_diff_cached_word() { --word-diff-regex "." \ "${@}" } -gdcw() { git_diff_cached_word "${@}"; } # differences via external tool +gdt() { git_diff_tool "${@}"; } git_diff_tool() { git \ difftool \ --dir-diff \ "${@}" } -gdt() { git_diff_tool "${@}"; } # character-level differences +gdw() { git_diff_word "${@}"; } git_diff_word() { git \ diff \ --word-diff-regex "." \ "${@}" } -gdw() { git_diff_word "${@}"; } # fetch from the remote repository +gf() { git_fetch "${@}"; } git_fetch() { git \ fetch \ @@ -236,17 +237,17 @@ git_fetch() { --verbose \ "${@}" } -gf() { git_fetch "${@}"; } # fetch from remote repository and prune local orphan branches +gfp() { git_fetch_prune "${@}"; } git_fetch_prune() { gf \ --prune \ "${@}" } -gfp() { git_fetch_prune "${@}"; } # garbage collect all orphan commits +ggc() { git_garbage_collect "${@}"; } git_garbage_collect() { git \ reflog \ @@ -258,26 +259,26 @@ git_garbage_collect() { --aggressive \ --prune="now" } -ggc() { git_garbage_collect "${@}"; } # initialize a new repository +gi() { git_init "${@}"; } git_init() { git \ init \ "${@}" } -gi() { git_init "${@}"; } # initialize a new bare repository +gib() { git_init_bare "${@}"; } git_init_bare() { git \ init \ --bare \ "${@}" } -gib() { git_init_bare "${@}"; } # log history +gl() { git_log "${@}"; } git_log() { local format="\ %C(auto)%h%d @@ -295,52 +296,52 @@ C %C(blue)%ci --graph \ "${@}" } -gl() { git_log "${@}"; } # log all history +gla() { git_log_all "${@}"; } git_log_all() { gl \ --all \ "${@}" } -gla() { git_log_all "${@}"; } # log all history with patches +glap() { git_log_all_patch "${@}"; } git_log_all_patch() { gl \ --all \ --patch \ "${@}" } -glap() { git_log_all_patch "${@}"; } # log history with patches +glp() { git_log_patch "${@}"; } git_log_patch() { gl \ --patch \ "${@}" } -glp() { git_log_patch "${@}"; } # fast-forward merge to remote branch +gm() { git_merge "${@}"; } git_merge() { git \ merge \ --ff-only \ "${@}" } -gm() { git_merge "${@}"; } # abort the current merge commit +gma() { git_merge_abort "${@}"; } git_merge_abort() { git \ merge \ --abort \ "${@}" } -gma() { git_merge_abort "${@}"; } # do a merge commit +gmc() { git_merge_commit "${@}"; } git_merge_commit() { git \ merge \ @@ -348,26 +349,26 @@ git_merge_commit() { --message \ "${@}" } -gmc() { git_merge_commit "${@}"; } # squash a branch and index its modifications +gms() { git_merge_squash "${@}"; } git_merge_squash() { git \ merge \ --squash \ "${@}" } -gms() { git_merge_squash "${@}"; } # merge via external tool +gmt() { git_merge_tool "${@}"; } git_merge_tool() { git \ mergetool \ "${@}" } -gmt() { git_merge_tool "${@}"; } # push to the remote repository +gp() { git_push "${@}"; } git_push() { git \ push \ @@ -375,160 +376,159 @@ git_push() { --verbose \ "${@}" } -gp() { git_push "${@}"; } # delete from the remote repository +gpd() { git_push_delete "${@}"; } git_push_delete() { git \ push \ --delete \ "${@}" } -gpd() { git_push_delete "${@}"; } # force the push to the remote repository +gpf() { git_push_force "${@}"; } git_push_force() { gp \ --force \ "${@}" } -gpf() { git_push_force "${@}"; } # rebase current branch onto another +grb() { git_re_base "${@}"; } git_re_base() { git \ rebase \ "${@}" } -grb() { git_re_base "${@}"; } # abort current rebase +grba() { git_re_base_abort "${@}"; } git_re_base_abort() { git \ rebase \ --abort \ "${@}" } -grba() { git_re_base_abort "${@}"; } # continue current rebase +grbc() { git_re_base_continue "${@}"; } git_re_base_continue() { git \ rebase \ --continue \ "${@}" } -grbc() { git_re_base_continue "${@}"; } # force rebase without fast-forward +grbf() { git_re_base_force "${@}"; } git_re_base_force() { git \ rebase \ --force-rebase \ "${@}" } -grbf() { git_re_base_force "${@}"; } # rebase interactively +grbi() { git_re_base_interactive "${@}"; } git_re_base_interactive() { git \ rebase \ --interactive \ "${@}" } -grbi() { git_re_base_interactive "${@}"; } # remove and add removal to index +grm() { git_re_move "${@}"; } git_re_move() { git \ rm \ "${@}" } -grm() { git_re_move "${@}"; } # add a new remote repository +grma() { git_re_mote_add "${@}"; } git_re_mote_add() { git \ remote \ add \ "${@}" } -grma() { git_re_mote_add "${@}"; } # list remote repositories +grml() { git_re_mote_list "${@}"; } git_re_mote_list() { git \ remote \ --verbose \ "${@}" } -grml() { git_re_mote_list "${@}"; } # show connection to a remote repository +grms() { git_re_mote_show "${@}"; } git_re_mote_show() { git \ remote \ show \ "${@}" } -grms() { git_re_mote_show "${@}"; } # set the location of a remote repository +grmsu() { git_re_mote_set_upstream "${@}"; } git_re_mote_set_upstream() { git \ remote \ set-url \ "${@}" } -grmsu() { git_re_mote_set_upstream "${@}"; } # remove file(s) from index or move current branch pointer +grs() { git_re_set "${@}"; } git_re_set() { git \ reset \ "${@}" } -grs() { git_re_set "${@}"; } # wipe modifications or reset current branch to another commit +grsh() { git_re_set_hard "${@}"; } git_re_set_hard() { git \ reset \ --hard \ "${@}" } -grsh() { git_re_set_hard "${@}"; } # current state of repository +gs() { git_status "${@}"; } git_status() { git \ status \ --untracked-files="all" \ "${@}" } -gs() { git_status "${@}"; } # show a commit +gsc() { git_show_commit "${@}"; } git_show_commit() { git \ show \ "${@}" } -gsc() { git_show_commit "${@}"; } # tag a commit +gt() { git_tag "${@}"; } git_tag() { git \ tag \ "${@}" } -gt() { git_tag "${@}"; } # delete a tag +gtd() { git_tag_delete "${@}"; } git_tag_delete() { git \ tag \ --delete \ "${@}" } -gtd() { git_tag_delete "${@}"; } From a9fa61d7a85785b500b9d14a4b36999e11fea60e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 17:02:03 +0100 Subject: [PATCH 659/969] clean --- shell/alias/git.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 8310385..04719c1 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -82,6 +82,16 @@ git_branch_set_upstream() { "${@}" } +# clean untracked files +gcf() { git_clean_force "${@}"; } +git_clean_force() { + git \ + clean \ + -d \ + --force \ + "${@}" +} + # redo the last commit with a different message gcam() { git_commit_amend_message "${@}"; } git_commit_amend_message() { @@ -103,16 +113,6 @@ git_commit_empty_message() { "${@}" } -# clean untracked files -gcf() { git_clean_force "${@}"; } -git_clean_force() { - git \ - clean \ - -d \ - --force \ - "${@}" -} - # commit the index gcm() { git_commit_message "${@}"; } git_commit_message() { From cfd529a5d8f8dab3cf1490ae270300b021f27e53 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 17:03:30 +0100 Subject: [PATCH 660/969] rm --- shell/alias/git.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 04719c1..9a423ac 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -438,14 +438,6 @@ git_re_base_interactive() { "${@}" } -# remove and add removal to index -grm() { git_re_move "${@}"; } -git_re_move() { - git \ - rm \ - "${@}" -} - # add a new remote repository grma() { git_re_mote_add "${@}"; } git_re_mote_add() { @@ -482,6 +474,14 @@ git_re_mote_set_upstream() { "${@}" } +# remove and add removal to index +grm() { git_re_move "${@}"; } +git_re_move() { + git \ + rm \ + "${@}" +} + # remove file(s) from index or move current branch pointer grs() { git_re_set "${@}"; } git_re_set() { From 975382a359a68676dbb7611692c0daa9e836ef43 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 17:05:44 +0100 Subject: [PATCH 661/969] =?UTF-8?q?=E2=86=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/alias/git.sh | 80 +++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 9a423ac..df627b8 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -82,46 +82,6 @@ git_branch_set_upstream() { "${@}" } -# clean untracked files -gcf() { git_clean_force "${@}"; } -git_clean_force() { - git \ - clean \ - -d \ - --force \ - "${@}" -} - -# redo the last commit with a different message -gcam() { git_commit_amend_message "${@}"; } -git_commit_amend_message() { - git \ - commit \ - --amend \ - --message \ - "${@}" -} - -# make a root commit -gcem() { git_commit_empty_message "${@}"; } -git_commit_empty_message() { - git \ - commit \ - --allow-empty \ - --allow-empty-message \ - --message \ - "${@}" -} - -# commit the index -gcm() { git_commit_message "${@}"; } -git_commit_message() { - git \ - commit \ - --message \ - "${@}" -} - # switch to a branch or checkout file(s) from a commit gc() { git_checkout "${@}"; } git_checkout() { @@ -165,6 +125,46 @@ git_cherry_pick_continue() { "${@}" } +# clean untracked files +gcf() { git_clean_force "${@}"; } +git_clean_force() { + git \ + clean \ + -d \ + --force \ + "${@}" +} + +# redo the last commit with a different message +gcam() { git_commit_amend_message "${@}"; } +git_commit_amend_message() { + git \ + commit \ + --amend \ + --message \ + "${@}" +} + +# make a root commit +gcem() { git_commit_empty_message "${@}"; } +git_commit_empty_message() { + git \ + commit \ + --allow-empty \ + --allow-empty-message \ + --message \ + "${@}" +} + +# commit the index +gcm() { git_commit_message "${@}"; } +git_commit_message() { + git \ + commit \ + --message \ + "${@}" +} + # configure the user email gcue() { git_config_user_email "${@}"; } git_config_user_email() { From dcef6d2d626f94d9e03278ff17b03081b4ca440f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 17:08:46 +0100 Subject: [PATCH 662/969] =?UTF-8?q?=E2=86=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/alias/git.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index df627b8..eaa83a6 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -456,15 +456,6 @@ git_re_mote_list() { "${@}" } -# show connection to a remote repository -grms() { git_re_mote_show "${@}"; } -git_re_mote_show() { - git \ - remote \ - show \ - "${@}" -} - # set the location of a remote repository grmsu() { git_re_mote_set_upstream "${@}"; } git_re_mote_set_upstream() { @@ -474,6 +465,15 @@ git_re_mote_set_upstream() { "${@}" } +# show connection to a remote repository +grms() { git_re_mote_show "${@}"; } +git_re_mote_show() { + git \ + remote \ + show \ + "${@}" +} + # remove and add removal to index grm() { git_re_move "${@}"; } git_re_move() { @@ -499,6 +499,14 @@ git_re_set_hard() { "${@}" } +# show a commit +gsc() { git_show_commit "${@}"; } +git_show_commit() { + git \ + show \ + "${@}" +} + # current state of repository gs() { git_status "${@}"; } git_status() { @@ -508,14 +516,6 @@ git_status() { "${@}" } -# show a commit -gsc() { git_show_commit "${@}"; } -git_show_commit() { - git \ - show \ - "${@}" -} - # tag a commit gt() { git_tag "${@}"; } git_tag() { From bbff4013f357c6aef0cbfda5755872217eedfbcc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 17:14:15 +0100 Subject: [PATCH 663/969] functions --- shell/alias/git.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index eaa83a6..628799a 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -241,7 +241,7 @@ git_fetch() { # fetch from remote repository and prune local orphan branches gfp() { git_fetch_prune "${@}"; } git_fetch_prune() { - gf \ + git_fetch \ --prune \ "${@}" } @@ -300,7 +300,7 @@ C %C(blue)%ci # log all history gla() { git_log_all "${@}"; } git_log_all() { - gl \ + git_log \ --all \ "${@}" } @@ -308,7 +308,7 @@ git_log_all() { # log all history with patches glap() { git_log_all_patch "${@}"; } git_log_all_patch() { - gl \ + git_log \ --all \ --patch \ "${@}" @@ -317,7 +317,7 @@ git_log_all_patch() { # log history with patches glp() { git_log_patch "${@}"; } git_log_patch() { - gl \ + git_log \ --patch \ "${@}" } @@ -389,7 +389,7 @@ git_push_delete() { # force the push to the remote repository gpf() { git_push_force "${@}"; } git_push_force() { - gp \ + git_push \ --force \ "${@}" } From 18e2154931cda64cf6f3ed7added01b2fbcd1c0b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 17:15:47 +0100 Subject: [PATCH 664/969] format --- shell/alias/git.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index 628799a..eb72938 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -1,3 +1,12 @@ +GIT_LOG_FORMAT="\ +%C(auto)%h%d +S %C(red)%GS +A %C(green)%ai + %C(green)%an %ae +C %C(blue)%ci + %C(blue)%cn %ce +%B" + # add to index ga() { git_add "${@}"; } git_add() { @@ -280,19 +289,11 @@ git_init_bare() { # log history gl() { git_log "${@}"; } git_log() { - local format="\ -%C(auto)%h%d -S %C(red)%GS -A %C(green)%ai - %C(green)%an %ae -C %C(blue)%ci - %C(blue)%cn %ce -%B" git \ log \ --abbrev=8 \ --abbrev-commit \ - --format="${format}" \ + --format="${GIT_LOG_FORMAT}" \ --graph \ "${@}" } From 7363e51f4ee2b69592d1997fabe380c6bfa4eda7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 17:18:36 +0100 Subject: [PATCH 665/969] gpg --- shell/alias/gpg.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shell/alias/gpg.sh b/shell/alias/gpg.sh index 4c1d4e5..d971cab 100644 --- a/shell/alias/gpg.sh +++ b/shell/alias/gpg.sh @@ -1,11 +1,13 @@ # turn gpg agent off -gak() { +gak() { gpg_agent_kill "${@}"; } +gpg_agent_kill() { gpgconf \ --kill "gpg-agent" } # bind gpg agent to current tty -gau() { +gau() { gpg_agent_update "${@}"; } +gpg_agent_update() { gpg-connect-agent \ updatestartuptty \ /bye From cb3c7de6415ac7d92a08c0bd08964521d3e0e725 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 17:24:17 +0100 Subject: [PATCH 666/969] =?UTF-8?q?=E2=86=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/alias/git.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/alias/git.sh b/shell/alias/git.sh index eb72938..9e84251 100644 --- a/shell/alias/git.sh +++ b/shell/alias/git.sh @@ -1,10 +1,10 @@ GIT_LOG_FORMAT="\ %C(auto)%h%d S %C(red)%GS -A %C(green)%ai - %C(green)%an %ae -C %C(blue)%ci - %C(blue)%cn %ce +A %C(green)%an %ae + %C(green)%ai +C %C(blue)%cn %ce + %C(blue)%ci %B" # add to index From 93a9ed20d50e1d11e6047a1eee71f7bec39211f0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 17:28:52 +0100 Subject: [PATCH 667/969] gpg --- shell/alias/gpg.sh | 14 -------------- shell/gpg.sh | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 14 deletions(-) delete mode 100644 shell/alias/gpg.sh diff --git a/shell/alias/gpg.sh b/shell/alias/gpg.sh deleted file mode 100644 index d971cab..0000000 --- a/shell/alias/gpg.sh +++ /dev/null @@ -1,14 +0,0 @@ -# turn gpg agent off -gak() { gpg_agent_kill "${@}"; } -gpg_agent_kill() { - gpgconf \ - --kill "gpg-agent" -} - -# bind gpg agent to current tty -gau() { gpg_agent_update "${@}"; } -gpg_agent_update() { - gpg-connect-agent \ - updatestartuptty \ - /bye -} diff --git a/shell/gpg.sh b/shell/gpg.sh index f9d6ef6..e4ebb38 100644 --- a/shell/gpg.sh +++ b/shell/gpg.sh @@ -1,3 +1,18 @@ +# turn gpg agent off +gak() { gpg_agent_kill "${@}"; } +gpg_agent_kill() { + gpgconf \ + --kill "gpg-agent" +} + +# bind gpg agent to current tty +gau() { gpg_agent_update "${@}"; } +gpg_agent_update() { + gpg-connect-agent \ + updatestartuptty \ + /bye +} + gpg_ssh() { local user_id user_id=$(id --user) From 049eaaff6ff8051be1423e8fd3997ad9904ddb34 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 17:29:15 +0100 Subject: [PATCH 668/969] git --- shell/{alias => }/git.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename shell/{alias => }/git.sh (100%) diff --git a/shell/alias/git.sh b/shell/git.sh similarity index 100% rename from shell/alias/git.sh rename to shell/git.sh From 9b05b663da73d6801a1d201743c50d41cad4fb49 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 17:36:25 +0100 Subject: [PATCH 669/969] shell --- shell/alias/shell.sh | 32 -------------------------------- shell/shell.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 32 deletions(-) delete mode 100644 shell/alias/shell.sh diff --git a/shell/alias/shell.sh b/shell/alias/shell.sh deleted file mode 100644 index 531b4b0..0000000 --- a/shell/alias/shell.sh +++ /dev/null @@ -1,32 +0,0 @@ -# shorten alias -a() { - alias \ - "${@}" -} - -# swap directory (current ↔ previous) -sd() { - cd \ - - || - return -} - -# exit terminal -x() { - exit \ - "${@}" -} - -# shellcheck disable=SC2154 -[ "${SH}" = "bash" ] || return - -# back - -# shellcheck disable=SC3033 -..() { - cd .. -} -# shellcheck disable=SC3033 -...() { - cd ../.. -} diff --git a/shell/shell.sh b/shell/shell.sh index c25ab55..bfb6b98 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -110,3 +110,34 @@ shell_setup() { rm --force --recursive "${file}" ln --symbolic "${ENV}" "${file}" } + +# shorten alias +a() { + alias \ + "${@}" +} + +# swap directory (current ↔ previous) +sd() { + cd \ + - || + return +} + +# exit terminal +x() { + exit \ + "${@}" +} + +# shellcheck disable=SC2154 +[ "${SH}" = "bash" ] || return + +# shellcheck disable=SC3033 +..() { + cd .. +} +# shellcheck disable=SC3033 +...() { + cd ../.. +} From 3d5e4f5a68c404823abe95fa1c5100ca58a71af3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 17:40:02 +0100 Subject: [PATCH 670/969] sh --- shell/main.sh | 3 --- shell/shell.sh | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/shell/main.sh b/shell/main.sh index 327c956..85888e7 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -1,8 +1,5 @@ [ -n "${ENV}" ] || export ENV="/etc/shell/main.sh" -SH="$(cat /proc/$$/comm)" -export SH - main_source_directory() { local path="${1}" if [ -d "${path}" ]; then diff --git a/shell/shell.sh b/shell/shell.sh index bfb6b98..00174fc 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -1,10 +1,10 @@ PS1="\$(shell_prompt \${?})" PS2="\ ├ " +SH="$(cat /proc/$$/comm)" shell_color() { local code="${1}" - # shellcheck disable=SC2154 case "${SH}" in "bash") printf "\x01\e[0" @@ -130,7 +130,6 @@ x() { "${@}" } -# shellcheck disable=SC2154 [ "${SH}" = "bash" ] || return # shellcheck disable=SC3033 From dcde6ddbc9e7722e3edcf7e6b694e7dfbde206a1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 18:11:25 +0100 Subject: [PATCH 671/969] commands --- shell/main.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/shell/main.sh b/shell/main.sh index 85888e7..e41bdf9 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -1,9 +1,15 @@ [ -n "${ENV}" ] || export ENV="/etc/shell/main.sh" +main_commands() { + local file="${1}" + grep "{\$" "${file}" | + cut --delimiter "(" --fields 1 +} + main_source_directory() { local path="${1}" if [ -d "${path}" ]; then - local count ifs module modules + local cmd count ifs module modules modules="$(find "${path}" \ -type "f" \ -name "*.sh" \ @@ -22,9 +28,14 @@ main_source_directory() { module="${path}/${module}" if [ "${module}" != "${ENV}" ]; then . "${module}" + cmd="$(main_commands "${module}")" + [ -n "${cmd}" ] && CMD="${CMD} +${cmd}" fi done IFS="${ifs}" + log_info + log_info "${CMD}" else echo "Not a directory: ${path}" return 1 From 8262f7c5d0b50ef8d9cba1a65df1ed824ad56efb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 18:17:06 +0100 Subject: [PATCH 672/969] cmd --- shell/main.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/shell/main.sh b/shell/main.sh index e41bdf9..37dfdfc 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -29,8 +29,11 @@ main_source_directory() { if [ "${module}" != "${ENV}" ]; then . "${module}" cmd="$(main_commands "${module}")" - [ -n "${cmd}" ] && CMD="${CMD} -${cmd}" + if [ -n "${cmd}" ]; then + [ -n "${CMD}" ] && CMD="${CMD} +" + CMD="${CMD}${cmd}" + fi fi done IFS="${ifs}" From 20f4af36d0cda8a54323fb62119aff624d1740f2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 18:49:04 +0100 Subject: [PATCH 673/969] completions/git --- shell/shell.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/shell/shell.sh b/shell/shell.sh index 00174fc..0813560 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -35,10 +35,14 @@ shell_configure() { case "${SH}" in "bash") # completion - local file="/usr/share/bash-completion/bash_completion" - if [ -f "${file}" ]; then - . "${file}" - fi + local root="/usr/share/bash-completion" + local file path + for file in "bash_completion" "completions/git"; do + path="${root}/${file}" + if [ -f "${path}" ]; then + . "${path}" + fi + done # history HISTCONTROL="ignorespace" HISTSIZE=-1 From 982a81adbe2536cb9d80d2d6cab77f3d13881b47 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 19:10:18 +0100 Subject: [PATCH 674/969] 1line --- shell/shell.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/shell/shell.sh b/shell/shell.sh index 0813560..cb4557c 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -39,9 +39,7 @@ shell_configure() { local file path for file in "bash_completion" "completions/git"; do path="${root}/${file}" - if [ -f "${path}" ]; then - . "${path}" - fi + [ -f "${path}" ] && . "${path}" done # history HISTCONTROL="ignorespace" From 44c771534a35e9a8589045ba964c0108540985db Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 19:23:24 +0100 Subject: [PATCH 675/969] set --- shell/shell.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/shell/shell.sh b/shell/shell.sh index cb4557c..5676d0d 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -36,11 +36,19 @@ shell_configure() { "bash") # completion local root="/usr/share/bash-completion" - local file path - for file in "bash_completion" "completions/git"; do - path="${root}/${file}" - [ -f "${path}" ] && . "${path}" - done + local file="bash_completion" + local path="${root}/${file}" + [ -f "${path}" ] && . "${path}" + root="${root}/completions" + if [ -d "${root}" ]; then + set \ + "git" \ + "tar" + for file in "${@}"; do + path="${root}/${file}" + [ -f "${path}" ] && . "${path}" + done + fi # history HISTCONTROL="ignorespace" HISTSIZE=-1 From 808d0dc0642c0cc73e180d800f07d16a8590d785 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 19:34:08 +0100 Subject: [PATCH 676/969] nb --- shell/alias/newsboat.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/alias/newsboat.sh b/shell/alias/newsboat.sh index c877906..adbfd37 100644 --- a/shell/alias/newsboat.sh +++ b/shell/alias/newsboat.sh @@ -1,4 +1,5 @@ -nb() { +nb() { news_boat "${@}"; } +news_boat() { newsboat \ "${@}" } From 0d3d0bc21136de394a89becdb09e37bfcb729be4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 21:46:01 +0100 Subject: [PATCH 677/969] () --- shell/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/main.sh b/shell/main.sh index 37dfdfc..5fe13d8 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -2,7 +2,7 @@ main_commands() { local file="${1}" - grep "{\$" "${file}" | + grep "()" "${file}" | cut --delimiter "(" --fields 1 } From 12515e62844e864154b2dd19f973a0ad310ddd40 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 22:04:36 +0100 Subject: [PATCH 678/969] rsdb --- shell/alias/rsync.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/alias/rsync.sh b/shell/alias/rsync.sh index a5efc09..7a94aac 100644 --- a/shell/alias/rsync.sh +++ b/shell/alias/rsync.sh @@ -23,7 +23,8 @@ rsda() { } # synchronize and delete before -rsdb() { +rsdb() { r_sync_delete_before "${@}"; } +r_sync_delete_before() { rsb \ --delete-before \ "${@}" From 1084edee23a234eabcf97e90eb3be49ebcafd673 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 22:27:05 +0100 Subject: [PATCH 679/969] env --- shell/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/main.sh b/shell/main.sh index 5fe13d8..902c7f8 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -1,4 +1,4 @@ -[ -n "${ENV}" ] || export ENV="/etc/shell/main.sh" +[ -n "${ENV}" ] || export ENV="/etc/sh/main.sh" main_commands() { local file="${1}" From 02a743fc1bbc5e7adbaaf09807eab7f8fd318280 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 22:27:38 +0100 Subject: [PATCH 680/969] sh --- {shell => sh}/.shellcheckrc | 0 {shell => sh}/alias/apt.sh | 0 {shell => sh}/alias/batcat.sh | 0 {shell => sh}/alias/btrfs.sh | 0 {shell => sh}/alias/byobu.sh | 0 {shell => sh}/alias/chmod.sh | 0 {shell => sh}/alias/chown.sh | 0 {shell => sh}/alias/clear.sh | 0 {shell => sh}/alias/cp.sh | 0 {shell => sh}/alias/emacs.sh | 0 {shell => sh}/alias/evince.sh | 0 {shell => sh}/alias/grep.sh | 0 {shell => sh}/alias/kill.sh | 0 {shell => sh}/alias/killall.sh | 0 {shell => sh}/alias/ls.sh | 0 {shell => sh}/alias/lsblk.sh | 0 {shell => sh}/alias/mkdir.sh | 0 {shell => sh}/alias/mount.sh | 0 {shell => sh}/alias/mv.sh | 0 {shell => sh}/alias/nano.sh | 0 {shell => sh}/alias/newsboat.sh | 0 {shell => sh}/alias/pass.sh | 0 {shell => sh}/alias/ps.sh | 0 {shell => sh}/alias/pwgen.sh | 0 {shell => sh}/alias/rm.sh | 0 {shell => sh}/alias/rsync.sh | 0 {shell => sh}/alias/tar.sh | 0 {shell => sh}/alias/tmux.sh | 0 {shell => sh}/alias/tree.sh | 0 {shell => sh}/btrfs.sh | 0 {shell => sh}/debian.sh | 0 {shell => sh}/fs.sh | 0 {shell => sh}/git.sh | 0 {shell => sh}/gpg.sh | 0 {shell => sh}/gsettings.sh | 0 {shell => sh}/log.sh | 0 {shell => sh}/main.sh | 0 {shell => sh}/mount-lxc.sh | 0 {shell => sh}/mount.sh | 0 {shell => sh}/proxy.sh | 0 {shell => sh}/rescue/common.sh | 0 {shell => sh}/rescue/hetzner.sh | 0 {shell => sh}/rescue/ovh.sh | 0 {shell => sh}/shell.sh | 0 {shell => sh}/util.sh | 0 45 files changed, 0 insertions(+), 0 deletions(-) rename {shell => sh}/.shellcheckrc (100%) rename {shell => sh}/alias/apt.sh (100%) rename {shell => sh}/alias/batcat.sh (100%) rename {shell => sh}/alias/btrfs.sh (100%) rename {shell => sh}/alias/byobu.sh (100%) rename {shell => sh}/alias/chmod.sh (100%) rename {shell => sh}/alias/chown.sh (100%) rename {shell => sh}/alias/clear.sh (100%) rename {shell => sh}/alias/cp.sh (100%) rename {shell => sh}/alias/emacs.sh (100%) rename {shell => sh}/alias/evince.sh (100%) rename {shell => sh}/alias/grep.sh (100%) rename {shell => sh}/alias/kill.sh (100%) rename {shell => sh}/alias/killall.sh (100%) rename {shell => sh}/alias/ls.sh (100%) rename {shell => sh}/alias/lsblk.sh (100%) rename {shell => sh}/alias/mkdir.sh (100%) rename {shell => sh}/alias/mount.sh (100%) rename {shell => sh}/alias/mv.sh (100%) rename {shell => sh}/alias/nano.sh (100%) rename {shell => sh}/alias/newsboat.sh (100%) rename {shell => sh}/alias/pass.sh (100%) rename {shell => sh}/alias/ps.sh (100%) rename {shell => sh}/alias/pwgen.sh (100%) rename {shell => sh}/alias/rm.sh (100%) rename {shell => sh}/alias/rsync.sh (100%) rename {shell => sh}/alias/tar.sh (100%) rename {shell => sh}/alias/tmux.sh (100%) rename {shell => sh}/alias/tree.sh (100%) rename {shell => sh}/btrfs.sh (100%) rename {shell => sh}/debian.sh (100%) rename {shell => sh}/fs.sh (100%) rename {shell => sh}/git.sh (100%) rename {shell => sh}/gpg.sh (100%) rename {shell => sh}/gsettings.sh (100%) rename {shell => sh}/log.sh (100%) rename {shell => sh}/main.sh (100%) rename {shell => sh}/mount-lxc.sh (100%) rename {shell => sh}/mount.sh (100%) rename {shell => sh}/proxy.sh (100%) rename {shell => sh}/rescue/common.sh (100%) rename {shell => sh}/rescue/hetzner.sh (100%) rename {shell => sh}/rescue/ovh.sh (100%) rename {shell => sh}/shell.sh (100%) rename {shell => sh}/util.sh (100%) diff --git a/shell/.shellcheckrc b/sh/.shellcheckrc similarity index 100% rename from shell/.shellcheckrc rename to sh/.shellcheckrc diff --git a/shell/alias/apt.sh b/sh/alias/apt.sh similarity index 100% rename from shell/alias/apt.sh rename to sh/alias/apt.sh diff --git a/shell/alias/batcat.sh b/sh/alias/batcat.sh similarity index 100% rename from shell/alias/batcat.sh rename to sh/alias/batcat.sh diff --git a/shell/alias/btrfs.sh b/sh/alias/btrfs.sh similarity index 100% rename from shell/alias/btrfs.sh rename to sh/alias/btrfs.sh diff --git a/shell/alias/byobu.sh b/sh/alias/byobu.sh similarity index 100% rename from shell/alias/byobu.sh rename to sh/alias/byobu.sh diff --git a/shell/alias/chmod.sh b/sh/alias/chmod.sh similarity index 100% rename from shell/alias/chmod.sh rename to sh/alias/chmod.sh diff --git a/shell/alias/chown.sh b/sh/alias/chown.sh similarity index 100% rename from shell/alias/chown.sh rename to sh/alias/chown.sh diff --git a/shell/alias/clear.sh b/sh/alias/clear.sh similarity index 100% rename from shell/alias/clear.sh rename to sh/alias/clear.sh diff --git a/shell/alias/cp.sh b/sh/alias/cp.sh similarity index 100% rename from shell/alias/cp.sh rename to sh/alias/cp.sh diff --git a/shell/alias/emacs.sh b/sh/alias/emacs.sh similarity index 100% rename from shell/alias/emacs.sh rename to sh/alias/emacs.sh diff --git a/shell/alias/evince.sh b/sh/alias/evince.sh similarity index 100% rename from shell/alias/evince.sh rename to sh/alias/evince.sh diff --git a/shell/alias/grep.sh b/sh/alias/grep.sh similarity index 100% rename from shell/alias/grep.sh rename to sh/alias/grep.sh diff --git a/shell/alias/kill.sh b/sh/alias/kill.sh similarity index 100% rename from shell/alias/kill.sh rename to sh/alias/kill.sh diff --git a/shell/alias/killall.sh b/sh/alias/killall.sh similarity index 100% rename from shell/alias/killall.sh rename to sh/alias/killall.sh diff --git a/shell/alias/ls.sh b/sh/alias/ls.sh similarity index 100% rename from shell/alias/ls.sh rename to sh/alias/ls.sh diff --git a/shell/alias/lsblk.sh b/sh/alias/lsblk.sh similarity index 100% rename from shell/alias/lsblk.sh rename to sh/alias/lsblk.sh diff --git a/shell/alias/mkdir.sh b/sh/alias/mkdir.sh similarity index 100% rename from shell/alias/mkdir.sh rename to sh/alias/mkdir.sh diff --git a/shell/alias/mount.sh b/sh/alias/mount.sh similarity index 100% rename from shell/alias/mount.sh rename to sh/alias/mount.sh diff --git a/shell/alias/mv.sh b/sh/alias/mv.sh similarity index 100% rename from shell/alias/mv.sh rename to sh/alias/mv.sh diff --git a/shell/alias/nano.sh b/sh/alias/nano.sh similarity index 100% rename from shell/alias/nano.sh rename to sh/alias/nano.sh diff --git a/shell/alias/newsboat.sh b/sh/alias/newsboat.sh similarity index 100% rename from shell/alias/newsboat.sh rename to sh/alias/newsboat.sh diff --git a/shell/alias/pass.sh b/sh/alias/pass.sh similarity index 100% rename from shell/alias/pass.sh rename to sh/alias/pass.sh diff --git a/shell/alias/ps.sh b/sh/alias/ps.sh similarity index 100% rename from shell/alias/ps.sh rename to sh/alias/ps.sh diff --git a/shell/alias/pwgen.sh b/sh/alias/pwgen.sh similarity index 100% rename from shell/alias/pwgen.sh rename to sh/alias/pwgen.sh diff --git a/shell/alias/rm.sh b/sh/alias/rm.sh similarity index 100% rename from shell/alias/rm.sh rename to sh/alias/rm.sh diff --git a/shell/alias/rsync.sh b/sh/alias/rsync.sh similarity index 100% rename from shell/alias/rsync.sh rename to sh/alias/rsync.sh diff --git a/shell/alias/tar.sh b/sh/alias/tar.sh similarity index 100% rename from shell/alias/tar.sh rename to sh/alias/tar.sh diff --git a/shell/alias/tmux.sh b/sh/alias/tmux.sh similarity index 100% rename from shell/alias/tmux.sh rename to sh/alias/tmux.sh diff --git a/shell/alias/tree.sh b/sh/alias/tree.sh similarity index 100% rename from shell/alias/tree.sh rename to sh/alias/tree.sh diff --git a/shell/btrfs.sh b/sh/btrfs.sh similarity index 100% rename from shell/btrfs.sh rename to sh/btrfs.sh diff --git a/shell/debian.sh b/sh/debian.sh similarity index 100% rename from shell/debian.sh rename to sh/debian.sh diff --git a/shell/fs.sh b/sh/fs.sh similarity index 100% rename from shell/fs.sh rename to sh/fs.sh diff --git a/shell/git.sh b/sh/git.sh similarity index 100% rename from shell/git.sh rename to sh/git.sh diff --git a/shell/gpg.sh b/sh/gpg.sh similarity index 100% rename from shell/gpg.sh rename to sh/gpg.sh diff --git a/shell/gsettings.sh b/sh/gsettings.sh similarity index 100% rename from shell/gsettings.sh rename to sh/gsettings.sh diff --git a/shell/log.sh b/sh/log.sh similarity index 100% rename from shell/log.sh rename to sh/log.sh diff --git a/shell/main.sh b/sh/main.sh similarity index 100% rename from shell/main.sh rename to sh/main.sh diff --git a/shell/mount-lxc.sh b/sh/mount-lxc.sh similarity index 100% rename from shell/mount-lxc.sh rename to sh/mount-lxc.sh diff --git a/shell/mount.sh b/sh/mount.sh similarity index 100% rename from shell/mount.sh rename to sh/mount.sh diff --git a/shell/proxy.sh b/sh/proxy.sh similarity index 100% rename from shell/proxy.sh rename to sh/proxy.sh diff --git a/shell/rescue/common.sh b/sh/rescue/common.sh similarity index 100% rename from shell/rescue/common.sh rename to sh/rescue/common.sh diff --git a/shell/rescue/hetzner.sh b/sh/rescue/hetzner.sh similarity index 100% rename from shell/rescue/hetzner.sh rename to sh/rescue/hetzner.sh diff --git a/shell/rescue/ovh.sh b/sh/rescue/ovh.sh similarity index 100% rename from shell/rescue/ovh.sh rename to sh/rescue/ovh.sh diff --git a/shell/shell.sh b/sh/shell.sh similarity index 100% rename from shell/shell.sh rename to sh/shell.sh diff --git a/shell/util.sh b/sh/util.sh similarity index 100% rename from shell/util.sh rename to sh/util.sh From 9910b4786b67b083e2936df79373ecd6de39e5b5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 22:28:07 +0100 Subject: [PATCH 681/969] sh.sh --- sh/{shell.sh => sh.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{shell.sh => sh.sh} (100%) diff --git a/sh/shell.sh b/sh/sh.sh similarity index 100% rename from sh/shell.sh rename to sh/sh.sh From 7376790a309c928a5a94c9834d5f4761b6c11762 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 22:31:13 +0100 Subject: [PATCH 682/969] sh --- sh/main.sh | 2 +- sh/sh.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 902c7f8..a4ef43b 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -57,4 +57,4 @@ main_source_file() { main_source_file "${ENV}" -main_source_directory "${HOME}/shell" +main_source_directory "${HOME}/sh" diff --git a/sh/sh.sh b/sh/sh.sh index 5676d0d..6fab8a6 100644 --- a/sh/sh.sh +++ b/sh/sh.sh @@ -114,7 +114,7 @@ shell_prompt() { shell_setup() { # shell - echo "export ENV=\"${ENV}\"" >"/etc/profile.d/shell.sh" + echo "export ENV=\"${ENV}\"" >"/etc/profile.d/sh.sh" # bash local file="/etc/bash.bashrc" rm --force --recursive "${file}" From 4931f47fe2a088eaf3ece2def2dfbb42c547f50c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 11:41:12 +0100 Subject: [PATCH 683/969] constants --- sh/main.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index a4ef43b..8081179 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -1,4 +1,11 @@ -[ -n "${ENV}" ] || export ENV="/etc/sh/main.sh" +SH_NAME="sh" + +SH_ROOT="/etc/${SH_NAME}" +SH_USER="${HOME}/${SH_NAME}" + +SH_MAIN="${SH_ROOT}/main.sh" + +[ -n "${ENV}" ] || export ENV="${SH_MAIN}" main_commands() { local file="${1}" @@ -57,4 +64,4 @@ main_source_file() { main_source_file "${ENV}" -main_source_directory "${HOME}/sh" +main_source_directory "${SH_USER}" From b11bb1c60a1a006ea816d7717cbff96aef68c26d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 11:54:27 +0100 Subject: [PATCH 684/969] prefix --- sh/git.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/git.sh b/sh/git.sh index 9e84251..38e1551 100644 --- a/sh/git.sh +++ b/sh/git.sh @@ -1,4 +1,4 @@ -GIT_LOG_FORMAT="\ +SH_GIT_LOG_FORMAT="\ %C(auto)%h%d S %C(red)%GS A %C(green)%an %ae @@ -293,7 +293,7 @@ git_log() { log \ --abbrev=8 \ --abbrev-commit \ - --format="${GIT_LOG_FORMAT}" \ + --format="${SH_GIT_LOG_FORMAT}" \ --graph \ "${@}" } From 4d8be7e2993ee9f02721298fd06563f307473741 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 11:58:32 +0100 Subject: [PATCH 685/969] prefixes --- sh/git.sh | 242 +++++++++++++++++++++++++++--------------------------- 1 file changed, 121 insertions(+), 121 deletions(-) diff --git a/sh/git.sh b/sh/git.sh index 38e1551..e8b210e 100644 --- a/sh/git.sh +++ b/sh/git.sh @@ -8,16 +8,16 @@ C %C(blue)%cn %ce %B" # add to index -ga() { git_add "${@}"; } -git_add() { +ga() { sh_git_add "${@}"; } +sh_git_add() { git \ add \ "${@}" } # add all to index -gaa() { git_add_all "${@}"; } -git_add_all() { +gaa() { sh_git_add_all "${@}"; } +sh_git_add_all() { git \ add \ --all \ @@ -25,8 +25,8 @@ git_add_all() { } # add parts of all to index -gaap() { git_add_all_patch "${@}"; } -git_add_all_patch() { +gaap() { sh_git_add_all_patch "${@}"; } +sh_git_add_all_patch() { git \ add \ --all \ @@ -35,8 +35,8 @@ git_add_all_patch() { } # add parts to index -gap() { git_add_patch "${@}"; } -git_add_patch() { +gap() { sh_git_add_patch "${@}"; } +sh_git_add_patch() { git \ add \ --patch \ @@ -44,16 +44,16 @@ git_add_patch() { } # create a branch -gb() { git_branch "${@}"; } -git_branch() { +gb() { sh_git_branch "${@}"; } +sh_git_branch() { git \ branch \ "${@}" } # delete a branch -gbd() { git_branch_delete "${@}"; } -git_branch_delete() { +gbd() { sh_git_branch_delete "${@}"; } +sh_git_branch_delete() { git \ branch \ --delete \ @@ -61,8 +61,8 @@ git_branch_delete() { } # force a branch deletion -gbdf() { git_branch_delete_force "${@}"; } -git_branch_delete_force() { +gbdf() { sh_git_branch_delete_force "${@}"; } +sh_git_branch_delete_force() { git \ branch \ --delete \ @@ -71,8 +71,8 @@ git_branch_delete_force() { } # list branches -gbl() { git_branch_list "${@}"; } -git_branch_list() { +gbl() { sh_git_branch_list "${@}"; } +sh_git_branch_list() { git \ branch \ --all \ @@ -83,8 +83,8 @@ git_branch_list() { } # set the link to a remote branch from a local branch -gbsu() { git_branch_set_upstream "${@}"; } -git_branch_set_upstream() { +gbsu() { sh_git_branch_set_upstream "${@}"; } +sh_git_branch_set_upstream() { git \ branch \ --set-upstream-to \ @@ -92,16 +92,16 @@ git_branch_set_upstream() { } # switch to a branch or checkout file(s) from a commit -gc() { git_checkout "${@}"; } -git_checkout() { +gc() { sh_git_checkout "${@}"; } +sh_git_checkout() { git \ checkout \ "${@}" } # checkout an orphan branch -gco() { git_checkout_orphan "${@}"; } -git_checkout_orphan() { +gco() { sh_git_checkout_orphan "${@}"; } +sh_git_checkout_orphan() { git \ checkout \ --orphan \ @@ -109,16 +109,16 @@ git_checkout_orphan() { } # pick a commit -gcp() { git_cherry_pick "${@}"; } -git_cherry_pick() { +gcp() { sh_git_cherry_pick "${@}"; } +sh_git_cherry_pick() { git \ cherry-pick \ "${@}" } # abort the commit pick -gcpa() { git_cherry_pick_abort "${@}"; } -git_cherry_pick_abort() { +gcpa() { sh_git_cherry_pick_abort "${@}"; } +sh_git_cherry_pick_abort() { git \ cherry-pick \ --abort \ @@ -126,8 +126,8 @@ git_cherry_pick_abort() { } # continue the commit pick -gcpc() { git_cherry_pick_continue "${@}"; } -git_cherry_pick_continue() { +gcpc() { sh_git_cherry_pick_continue "${@}"; } +sh_git_cherry_pick_continue() { git \ cherry-pick \ --continue \ @@ -135,8 +135,8 @@ git_cherry_pick_continue() { } # clean untracked files -gcf() { git_clean_force "${@}"; } -git_clean_force() { +gcf() { sh_git_clean_force "${@}"; } +sh_git_clean_force() { git \ clean \ -d \ @@ -145,8 +145,8 @@ git_clean_force() { } # redo the last commit with a different message -gcam() { git_commit_amend_message "${@}"; } -git_commit_amend_message() { +gcam() { sh_git_commit_amend_message "${@}"; } +sh_git_commit_amend_message() { git \ commit \ --amend \ @@ -155,8 +155,8 @@ git_commit_amend_message() { } # make a root commit -gcem() { git_commit_empty_message "${@}"; } -git_commit_empty_message() { +gcem() { sh_git_commit_empty_message "${@}"; } +sh_git_commit_empty_message() { git \ commit \ --allow-empty \ @@ -166,8 +166,8 @@ git_commit_empty_message() { } # commit the index -gcm() { git_commit_message "${@}"; } -git_commit_message() { +gcm() { sh_git_commit_message "${@}"; } +sh_git_commit_message() { git \ commit \ --message \ @@ -175,8 +175,8 @@ git_commit_message() { } # configure the user email -gcue() { git_config_user_email "${@}"; } -git_config_user_email() { +gcue() { sh_git_config_user_email "${@}"; } +sh_git_config_user_email() { git \ config \ "user.email" \ @@ -184,8 +184,8 @@ git_config_user_email() { } # configure the user name -gcun() { git_config_user_name "${@}"; } -git_config_user_name() { +gcun() { sh_git_config_user_name "${@}"; } +sh_git_config_user_name() { git \ config \ "user.name" \ @@ -193,16 +193,16 @@ git_config_user_name() { } # differences from last or between commits -gd() { git_diff "${@}"; } -git_diff() { +gd() { sh_git_diff "${@}"; } +sh_git_diff() { git \ diff \ "${@}" } # display what is indexed in cache -gdc() { git_diff_cached "${@}"; } -git_diff_cached() { +gdc() { sh_git_diff_cached "${@}"; } +sh_git_diff_cached() { git \ diff \ --cached \ @@ -210,8 +210,8 @@ git_diff_cached() { } # indexed character-level differences -gdcw() { git_diff_cached_word "${@}"; } -git_diff_cached_word() { +gdcw() { sh_git_diff_cached_word "${@}"; } +sh_git_diff_cached_word() { git \ diff \ --cached \ @@ -220,8 +220,8 @@ git_diff_cached_word() { } # differences via external tool -gdt() { git_diff_tool "${@}"; } -git_diff_tool() { +gdt() { sh_git_diff_tool "${@}"; } +sh_git_diff_tool() { git \ difftool \ --dir-diff \ @@ -229,8 +229,8 @@ git_diff_tool() { } # character-level differences -gdw() { git_diff_word "${@}"; } -git_diff_word() { +gdw() { sh_git_diff_word "${@}"; } +sh_git_diff_word() { git \ diff \ --word-diff-regex "." \ @@ -238,8 +238,8 @@ git_diff_word() { } # fetch from the remote repository -gf() { git_fetch "${@}"; } -git_fetch() { +gf() { sh_git_fetch "${@}"; } +sh_git_fetch() { git \ fetch \ --tags \ @@ -248,16 +248,16 @@ git_fetch() { } # fetch from remote repository and prune local orphan branches -gfp() { git_fetch_prune "${@}"; } -git_fetch_prune() { - git_fetch \ +gfp() { sh_git_fetch_prune "${@}"; } +sh_git_fetch_prune() { + sh_git_fetch \ --prune \ "${@}" } # garbage collect all orphan commits -ggc() { git_garbage_collect "${@}"; } -git_garbage_collect() { +ggc() { sh_git_garbage_collect "${@}"; } +sh_git_garbage_collect() { git \ reflog \ expire \ @@ -270,16 +270,16 @@ git_garbage_collect() { } # initialize a new repository -gi() { git_init "${@}"; } -git_init() { +gi() { sh_git_init "${@}"; } +sh_git_init() { git \ init \ "${@}" } # initialize a new bare repository -gib() { git_init_bare "${@}"; } -git_init_bare() { +gib() { sh_git_init_bare "${@}"; } +sh_git_init_bare() { git \ init \ --bare \ @@ -287,8 +287,8 @@ git_init_bare() { } # log history -gl() { git_log "${@}"; } -git_log() { +gl() { sh_git_log "${@}"; } +sh_git_log() { git \ log \ --abbrev=8 \ @@ -299,33 +299,33 @@ git_log() { } # log all history -gla() { git_log_all "${@}"; } -git_log_all() { - git_log \ +gla() { sh_git_log_all "${@}"; } +sh_git_log_all() { + sh_git_log \ --all \ "${@}" } # log all history with patches -glap() { git_log_all_patch "${@}"; } -git_log_all_patch() { - git_log \ +glap() { sh_git_log_all_patch "${@}"; } +sh_git_log_all_patch() { + sh_git_log \ --all \ --patch \ "${@}" } # log history with patches -glp() { git_log_patch "${@}"; } -git_log_patch() { - git_log \ +glp() { sh_git_log_patch "${@}"; } +sh_git_log_patch() { + sh_git_log \ --patch \ "${@}" } # fast-forward merge to remote branch -gm() { git_merge "${@}"; } -git_merge() { +gm() { sh_git_merge "${@}"; } +sh_git_merge() { git \ merge \ --ff-only \ @@ -333,8 +333,8 @@ git_merge() { } # abort the current merge commit -gma() { git_merge_abort "${@}"; } -git_merge_abort() { +gma() { sh_git_merge_abort "${@}"; } +sh_git_merge_abort() { git \ merge \ --abort \ @@ -342,8 +342,8 @@ git_merge_abort() { } # do a merge commit -gmc() { git_merge_commit "${@}"; } -git_merge_commit() { +gmc() { sh_git_merge_commit "${@}"; } +sh_git_merge_commit() { git \ merge \ --no-ff \ @@ -352,8 +352,8 @@ git_merge_commit() { } # squash a branch and index its modifications -gms() { git_merge_squash "${@}"; } -git_merge_squash() { +gms() { sh_git_merge_squash "${@}"; } +sh_git_merge_squash() { git \ merge \ --squash \ @@ -361,16 +361,16 @@ git_merge_squash() { } # merge via external tool -gmt() { git_merge_tool "${@}"; } -git_merge_tool() { +gmt() { sh_git_merge_tool "${@}"; } +sh_git_merge_tool() { git \ mergetool \ "${@}" } # push to the remote repository -gp() { git_push "${@}"; } -git_push() { +gp() { sh_git_push "${@}"; } +sh_git_push() { git \ push \ --tags \ @@ -379,8 +379,8 @@ git_push() { } # delete from the remote repository -gpd() { git_push_delete "${@}"; } -git_push_delete() { +gpd() { sh_git_push_delete "${@}"; } +sh_git_push_delete() { git \ push \ --delete \ @@ -388,24 +388,24 @@ git_push_delete() { } # force the push to the remote repository -gpf() { git_push_force "${@}"; } -git_push_force() { - git_push \ +gpf() { sh_git_push_force "${@}"; } +sh_git_push_force() { + sh_git_push \ --force \ "${@}" } # rebase current branch onto another -grb() { git_re_base "${@}"; } -git_re_base() { +grb() { sh_git_re_base "${@}"; } +sh_git_re_base() { git \ rebase \ "${@}" } # abort current rebase -grba() { git_re_base_abort "${@}"; } -git_re_base_abort() { +grba() { sh_git_re_base_abort "${@}"; } +sh_git_re_base_abort() { git \ rebase \ --abort \ @@ -413,8 +413,8 @@ git_re_base_abort() { } # continue current rebase -grbc() { git_re_base_continue "${@}"; } -git_re_base_continue() { +grbc() { sh_git_re_base_continue "${@}"; } +sh_git_re_base_continue() { git \ rebase \ --continue \ @@ -422,8 +422,8 @@ git_re_base_continue() { } # force rebase without fast-forward -grbf() { git_re_base_force "${@}"; } -git_re_base_force() { +grbf() { sh_git_re_base_force "${@}"; } +sh_git_re_base_force() { git \ rebase \ --force-rebase \ @@ -431,8 +431,8 @@ git_re_base_force() { } # rebase interactively -grbi() { git_re_base_interactive "${@}"; } -git_re_base_interactive() { +grbi() { sh_git_re_base_interactive "${@}"; } +sh_git_re_base_interactive() { git \ rebase \ --interactive \ @@ -440,8 +440,8 @@ git_re_base_interactive() { } # add a new remote repository -grma() { git_re_mote_add "${@}"; } -git_re_mote_add() { +grma() { sh_git_re_mote_add "${@}"; } +sh_git_re_mote_add() { git \ remote \ add \ @@ -449,8 +449,8 @@ git_re_mote_add() { } # list remote repositories -grml() { git_re_mote_list "${@}"; } -git_re_mote_list() { +grml() { sh_git_re_mote_list "${@}"; } +sh_git_re_mote_list() { git \ remote \ --verbose \ @@ -458,8 +458,8 @@ git_re_mote_list() { } # set the location of a remote repository -grmsu() { git_re_mote_set_upstream "${@}"; } -git_re_mote_set_upstream() { +grmsu() { sh_git_re_mote_set_upstream "${@}"; } +sh_git_re_mote_set_upstream() { git \ remote \ set-url \ @@ -467,8 +467,8 @@ git_re_mote_set_upstream() { } # show connection to a remote repository -grms() { git_re_mote_show "${@}"; } -git_re_mote_show() { +grms() { sh_git_re_mote_show "${@}"; } +sh_git_re_mote_show() { git \ remote \ show \ @@ -476,24 +476,24 @@ git_re_mote_show() { } # remove and add removal to index -grm() { git_re_move "${@}"; } -git_re_move() { +grm() { sh_git_re_move "${@}"; } +sh_git_re_move() { git \ rm \ "${@}" } # remove file(s) from index or move current branch pointer -grs() { git_re_set "${@}"; } -git_re_set() { +grs() { sh_git_re_set "${@}"; } +sh_git_re_set() { git \ reset \ "${@}" } # wipe modifications or reset current branch to another commit -grsh() { git_re_set_hard "${@}"; } -git_re_set_hard() { +grsh() { sh_git_re_set_hard "${@}"; } +sh_git_re_set_hard() { git \ reset \ --hard \ @@ -501,16 +501,16 @@ git_re_set_hard() { } # show a commit -gsc() { git_show_commit "${@}"; } -git_show_commit() { +gsc() { sh_git_show_commit "${@}"; } +sh_git_show_commit() { git \ show \ "${@}" } # current state of repository -gs() { git_status "${@}"; } -git_status() { +gs() { sh_git_status "${@}"; } +sh_git_status() { git \ status \ --untracked-files="all" \ @@ -518,16 +518,16 @@ git_status() { } # tag a commit -gt() { git_tag "${@}"; } -git_tag() { +gt() { sh_git_tag "${@}"; } +sh_git_tag() { git \ tag \ "${@}" } # delete a tag -gtd() { git_tag_delete "${@}"; } -git_tag_delete() { +gtd() { sh_git_tag_delete "${@}"; } +sh_git_tag_delete() { git \ tag \ --delete \ From 9a83206f3c84954efe219a2e64a09ad503e7da65 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 12:03:15 +0100 Subject: [PATCH 686/969] gpg --- sh/gpg.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sh/gpg.sh b/sh/gpg.sh index e4ebb38..ffa4f63 100644 --- a/sh/gpg.sh +++ b/sh/gpg.sh @@ -1,19 +1,19 @@ # turn gpg agent off gak() { gpg_agent_kill "${@}"; } -gpg_agent_kill() { +sh_gpg_agent_kill() { gpgconf \ --kill "gpg-agent" } # bind gpg agent to current tty gau() { gpg_agent_update "${@}"; } -gpg_agent_update() { +sh_gpg_agent_update() { gpg-connect-agent \ updatestartuptty \ /bye } -gpg_ssh() { +sh_gpg_ssh() { local user_id user_id=$(id --user) if [ "${user_id}" -ne 0 ]; then @@ -24,4 +24,4 @@ gpg_ssh() { fi } -gpg_ssh +sh_gpg_ssh From 3b0f3c14c1db016cb35fc293297e4612be29f2c7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 12:05:20 +0100 Subject: [PATCH 687/969] primary --- sh/gsettings.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/gsettings.sh b/sh/gsettings.sh index 8916766..0f32226 100644 --- a/sh/gsettings.sh +++ b/sh/gsettings.sh @@ -1,4 +1,4 @@ -ws() { +sh_gnome_workspaces_primary() { local bool local group="org.gnome.mutter" local name="workspaces-only-on-primary" From b68d4746e6af385b6fbc02c4f2d852a032c3140b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 12:07:42 +0100 Subject: [PATCH 688/969] log/constants --- sh/log.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/sh/log.sh b/sh/log.sh index 1891609..040bf28 100644 --- a/sh/log.sh +++ b/sh/log.sh @@ -1,44 +1,44 @@ -LOG_LEVEL_FATAL=0 -LOG_LEVEL_ERROR=1 -LOG_LEVEL_WARN=2 -LOG_LEVEL_INFO=3 -LOG_LEVEL_DEBUG=4 -LOG_LEVEL_TRACE=5 +SH_LOG_LEVEL_FATAL=0 +SH_LOG_LEVEL_ERROR=1 +SH_LOG_LEVEL_WARN=2 +SH_LOG_LEVEL_INFO=3 +SH_LOG_LEVEL_DEBUG=4 +SH_LOG_LEVEL_TRACE=5 -LOG_LEVEL=${LOG_LEVEL_INFO} +SH_LOG_LEVEL=${SH_LOG_LEVEL_INFO} log_debug() { - if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_DEBUG}" ]; then + if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_DEBUG}" ]; then echo "[DEBUG]" "${@}" fi } log_error() { - if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_ERROR}" ]; then + if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_ERROR}" ]; then echo "[ERROR]" "${@}" fi } log_fatal() { - if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_FATAL}" ]; then + if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_FATAL}" ]; then echo "[FATAL]" "${@}" fi } log_info() { - if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_INFO}" ]; then + if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_INFO}" ]; then echo "${@}" fi } log_trace() { - if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_TRACE}" ]; then + if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_TRACE}" ]; then echo "[TRACE]" "${@}" fi } log_warn() { - if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_WARN}" ]; then + if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_WARN}" ]; then echo " [WARN]" "${@}" fi } From 69dac56a26f451380bd935d98518acf26864b071 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 12:15:29 +0100 Subject: [PATCH 689/969] log --- sh/debian.sh | 4 ++-- sh/gsettings.sh | 6 +++--- sh/log.sh | 12 ++++++------ sh/main.sh | 4 ++-- sh/mount.sh | 30 +++++++++++++++--------------- sh/util.sh | 2 +- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/sh/debian.sh b/sh/debian.sh index f806ba6..db37cae 100644 --- a/sh/debian.sh +++ b/sh/debian.sh @@ -35,8 +35,8 @@ apt_install_target() { shift local package for package in "${@}"; do - log_info - log_info "${package} ← ${target}" + sh_log_info + sh_log_info "${package} ← ${target}" apt-get \ install \ --assume-yes \ diff --git a/sh/gsettings.sh b/sh/gsettings.sh index 0f32226..4aa6746 100644 --- a/sh/gsettings.sh +++ b/sh/gsettings.sh @@ -5,11 +5,11 @@ sh_gnome_workspaces_primary() { local var="${group}/${name}" # get bool="$(gsettings get "${group}" "${name}")" - log_debug "${var}: ${bool}" + sh_log_debug "${var}: ${bool}" # not bool="$(not "${bool}")" - log_debug "bool: ${bool}" + sh_log_debug "bool: ${bool}" # set gsettings set "${group}" "${name}" "${bool}" - log_info "${var}: ${bool}" + sh_log_info "${var}: ${bool}" } diff --git a/sh/log.sh b/sh/log.sh index 040bf28..19f7c1b 100644 --- a/sh/log.sh +++ b/sh/log.sh @@ -7,37 +7,37 @@ SH_LOG_LEVEL_TRACE=5 SH_LOG_LEVEL=${SH_LOG_LEVEL_INFO} -log_debug() { +sh_log_debug() { if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_DEBUG}" ]; then echo "[DEBUG]" "${@}" fi } -log_error() { +sh_log_error() { if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_ERROR}" ]; then echo "[ERROR]" "${@}" fi } -log_fatal() { +sh_log_fatal() { if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_FATAL}" ]; then echo "[FATAL]" "${@}" fi } -log_info() { +sh_log_info() { if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_INFO}" ]; then echo "${@}" fi } -log_trace() { +sh_log_trace() { if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_TRACE}" ]; then echo "[TRACE]" "${@}" fi } -log_warn() { +sh_log_warn() { if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_WARN}" ]; then echo " [WARN]" "${@}" fi diff --git a/sh/main.sh b/sh/main.sh index 8081179..f04cf71 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -44,8 +44,8 @@ main_source_directory() { fi done IFS="${ifs}" - log_info - log_info "${CMD}" + sh_log_info + sh_log_info "${CMD}" else echo "Not a directory: ${path}" return 1 diff --git a/sh/mount.sh b/sh/mount.sh index 7e715cf..b2bd77f 100644 --- a/sh/mount.sh +++ b/sh/mount.sh @@ -1,36 +1,36 @@ mo() { local root="${1}" if [ -z "${root}" ]; then - log_error "No root target directory" + sh_log_error "No root target directory" return 1 fi root="$(realpath "${root}")" if ! mkdir "overlay"; then - log_error "Unable to make overlay directory" + sh_log_error "Unable to make overlay directory" return 2 fi ( if ! cd "overlay"; then - log_error "Unable to move into overlay directory" + sh_log_error "Unable to move into overlay directory" return 3 fi local directory for directory in "lower" "upper" "work" "mount"; do if ! mkdir --parents "${directory}"; then - log_error "Unable to make directory: ${directory}" + sh_log_error "Unable to make directory: ${directory}" return 4 fi done local file="${root}/filesystem.squashfs" if ! mount "${file}" "lower"; then - log_error "Unable to lower mount: ${file}" + sh_log_error "Unable to lower mount: ${file}" return 5 fi if ! mount \ -o "lowerdir=lower,upperdir=upper,workdir=work" \ -t "overlay" \ "overlay" "mount"; then - log_error "Unable to overlay mount" + sh_log_error "Unable to overlay mount" return 6 fi ) @@ -39,35 +39,35 @@ mo() { uo() { ( if ! cd "overlay"; then - log_error "Unable to move into overlay directory" + sh_log_error "Unable to move into overlay directory" return 1 fi if ! umount "mount"; then - log_error "Unable to unmount mount directory" + sh_log_error "Unable to unmount mount directory" return 2 fi if ! rmdir "mount"; then - log_error "Unable to remove mount directory" + sh_log_error "Unable to remove mount directory" return 3 fi local directory for directory in "upper" "work"; do if ! rm --force --recursive "${directory}"; then - log_error "Unable to remove directory: ${directory}" + sh_log_error "Unable to remove directory: ${directory}" return 4 fi done if ! umount "lower"; then - log_error "Unable to unmount lower directory" + sh_log_error "Unable to unmount lower directory" return 5 fi if ! rmdir "lower"; then - log_error "Unable to remove lower directory" + sh_log_error "Unable to remove lower directory" return 6 fi ) if ! rmdir "overlay"; then - log_error "Unable to remove overlay directory" + sh_log_error "Unable to remove overlay directory" return 7 fi } @@ -76,7 +76,7 @@ mr() { local directory for directory in "dev" "dev/pts" "proc" "sys"; do if ! mount --bind "/${directory}" "overlay/mount/${directory}"; then - log_error "Unable to bind mount directory: ${directory}" + sh_log_error "Unable to bind mount directory: ${directory}" return 1 fi done @@ -97,7 +97,7 @@ ur() { local directory for directory in "sys" "proc" "dev/pts" "dev"; do if ! umount --lazy "overlay/mount/${directory}"; then - log_error "Unable to bind unmount directory: ${directory}" + sh_log_error "Unable to bind unmount directory: ${directory}" return 1 fi done diff --git a/sh/util.sh b/sh/util.sh index 4dcd59a..2f2b400 100644 --- a/sh/util.sh +++ b/sh/util.sh @@ -33,5 +33,5 @@ warn_wipe() { list_block_devices printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\" read -r tmp - log_trace "${tmp}" + sh_log_trace "${tmp}" } From eaaa9662cdc24d7d24715b8711b8519527cddd23 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 12:17:47 +0100 Subject: [PATCH 690/969] sh_log --- sh/log.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sh/log.sh b/sh/log.sh index 19f7c1b..c938663 100644 --- a/sh/log.sh +++ b/sh/log.sh @@ -7,6 +7,8 @@ SH_LOG_LEVEL_TRACE=5 SH_LOG_LEVEL=${SH_LOG_LEVEL_INFO} +sh_log() { sh_log_info "${@}"; } + sh_log_debug() { if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_DEBUG}" ]; then echo "[DEBUG]" "${@}" From b9804edd7a74905e09815d71b90ba9d1d5879b99 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 12:19:19 +0100 Subject: [PATCH 691/969] gnome --- sh/{gsettings.sh => gnome.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{gsettings.sh => gnome.sh} (100%) diff --git a/sh/gsettings.sh b/sh/gnome.sh similarity index 100% rename from sh/gsettings.sh rename to sh/gnome.sh From aae50d9bef5bb6364f9614e265362f38c3fddf47 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 12:22:08 +0100 Subject: [PATCH 692/969] btrfs --- sh/btrfs.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/btrfs.sh b/sh/btrfs.sh index 1172d2d..253be28 100644 --- a/sh/btrfs.sh +++ b/sh/btrfs.sh @@ -1,4 +1,5 @@ -bsl() { +bsl() { sh_btrfs_subvolume_list "${@}"; } +sh_btrfs_subvolume_list() { if [ -n "${1}" ]; then btrfs subvolume list "${1}" | cut --delimiter " " --fields 9 | From 0cce49e919e115a89010c0fba22fe4895f72be93 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 12:32:57 +0100 Subject: [PATCH 693/969] btrfs --- sh/alias/btrfs.sh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/sh/alias/btrfs.sh b/sh/alias/btrfs.sh index 061d373..4ec3ff6 100644 --- a/sh/alias/btrfs.sh +++ b/sh/alias/btrfs.sh @@ -1,11 +1,13 @@ -bfdf() { +bfdf() { sh_btrfs_filesystem_d_f "${@}"; } +sh_btrfs_filesystem_d_f() { btrfs \ filesystem \ df \ "${@}" } -bfdu() { +bfdu() { sh_btrfs_filesystem_d_u "${@}"; } +sh_btrfs_filesystem_d_u() { btrfs \ filesystem \ du \ @@ -13,42 +15,48 @@ bfdu() { "${@}" } -bfu() { +bfu() { sh_btrfs_filesystem_usage "${@}"; } +sh_btrfs_filesystem_usage() { btrfs \ filesystem \ usage \ "${@}" } -bpg() { +bpg() { sh_btrfs_property_get "${@}"; } +sh_btrfs_property_get() { btrfs \ property \ get \ "${@}" } -bsc() { +bsc() { sh_btrfs_subvolume_create "${@}"; } +sh_btrfs_subvolume_create() { btrfs \ subvolume \ create \ "${@}" } -bsd() { +bsd() { sh_btrfs_subvolume_delete "${@}"; } +sh_btrfs_subvolume_delete() { btrfs \ subvolume \ delete \ "${@}" } -bss() { +bss() { sh_btrfs_subvolume_snapshot "${@}"; } +sh_btrfs_subvolume_snapshot() { btrfs \ subvolume \ snapshot \ "${@}" } -bssr() { +bssr() { sh_btrfs_subvolume_snapshot_r "${@}"; } +sh_btrfs_subvolume_snapshot_r() { btrfs \ subvolume \ snapshot -r \ From d82805ff38a945a04ed3d8f8a013eaf6841769f2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 12:38:15 +0100 Subject: [PATCH 694/969] cmd --- sh/{alias => cmd}/apt.sh | 0 sh/{alias => cmd}/batcat.sh | 0 sh/{alias => cmd}/btrfs.sh | 0 sh/{alias => cmd}/byobu.sh | 0 sh/{alias => cmd}/chmod.sh | 0 sh/{alias => cmd}/chown.sh | 0 sh/{alias => cmd}/clear.sh | 0 sh/{alias => cmd}/cp.sh | 0 sh/{alias => cmd}/emacs.sh | 0 sh/{alias => cmd}/evince.sh | 0 sh/{alias => cmd}/grep.sh | 0 sh/{alias => cmd}/kill.sh | 0 sh/{alias => cmd}/killall.sh | 0 sh/{alias => cmd}/ls.sh | 0 sh/{alias => cmd}/lsblk.sh | 0 sh/{alias => cmd}/mkdir.sh | 0 sh/{alias => cmd}/mount.sh | 0 sh/{alias => cmd}/mv.sh | 0 sh/{alias => cmd}/nano.sh | 0 sh/{alias => cmd}/newsboat.sh | 0 sh/{alias => cmd}/pass.sh | 0 sh/{alias => cmd}/ps.sh | 0 sh/{alias => cmd}/pwgen.sh | 0 sh/{alias => cmd}/rm.sh | 0 sh/{alias => cmd}/rsync.sh | 0 sh/{alias => cmd}/tar.sh | 0 sh/{alias => cmd}/tmux.sh | 0 sh/{alias => cmd}/tree.sh | 0 28 files changed, 0 insertions(+), 0 deletions(-) rename sh/{alias => cmd}/apt.sh (100%) rename sh/{alias => cmd}/batcat.sh (100%) rename sh/{alias => cmd}/btrfs.sh (100%) rename sh/{alias => cmd}/byobu.sh (100%) rename sh/{alias => cmd}/chmod.sh (100%) rename sh/{alias => cmd}/chown.sh (100%) rename sh/{alias => cmd}/clear.sh (100%) rename sh/{alias => cmd}/cp.sh (100%) rename sh/{alias => cmd}/emacs.sh (100%) rename sh/{alias => cmd}/evince.sh (100%) rename sh/{alias => cmd}/grep.sh (100%) rename sh/{alias => cmd}/kill.sh (100%) rename sh/{alias => cmd}/killall.sh (100%) rename sh/{alias => cmd}/ls.sh (100%) rename sh/{alias => cmd}/lsblk.sh (100%) rename sh/{alias => cmd}/mkdir.sh (100%) rename sh/{alias => cmd}/mount.sh (100%) rename sh/{alias => cmd}/mv.sh (100%) rename sh/{alias => cmd}/nano.sh (100%) rename sh/{alias => cmd}/newsboat.sh (100%) rename sh/{alias => cmd}/pass.sh (100%) rename sh/{alias => cmd}/ps.sh (100%) rename sh/{alias => cmd}/pwgen.sh (100%) rename sh/{alias => cmd}/rm.sh (100%) rename sh/{alias => cmd}/rsync.sh (100%) rename sh/{alias => cmd}/tar.sh (100%) rename sh/{alias => cmd}/tmux.sh (100%) rename sh/{alias => cmd}/tree.sh (100%) diff --git a/sh/alias/apt.sh b/sh/cmd/apt.sh similarity index 100% rename from sh/alias/apt.sh rename to sh/cmd/apt.sh diff --git a/sh/alias/batcat.sh b/sh/cmd/batcat.sh similarity index 100% rename from sh/alias/batcat.sh rename to sh/cmd/batcat.sh diff --git a/sh/alias/btrfs.sh b/sh/cmd/btrfs.sh similarity index 100% rename from sh/alias/btrfs.sh rename to sh/cmd/btrfs.sh diff --git a/sh/alias/byobu.sh b/sh/cmd/byobu.sh similarity index 100% rename from sh/alias/byobu.sh rename to sh/cmd/byobu.sh diff --git a/sh/alias/chmod.sh b/sh/cmd/chmod.sh similarity index 100% rename from sh/alias/chmod.sh rename to sh/cmd/chmod.sh diff --git a/sh/alias/chown.sh b/sh/cmd/chown.sh similarity index 100% rename from sh/alias/chown.sh rename to sh/cmd/chown.sh diff --git a/sh/alias/clear.sh b/sh/cmd/clear.sh similarity index 100% rename from sh/alias/clear.sh rename to sh/cmd/clear.sh diff --git a/sh/alias/cp.sh b/sh/cmd/cp.sh similarity index 100% rename from sh/alias/cp.sh rename to sh/cmd/cp.sh diff --git a/sh/alias/emacs.sh b/sh/cmd/emacs.sh similarity index 100% rename from sh/alias/emacs.sh rename to sh/cmd/emacs.sh diff --git a/sh/alias/evince.sh b/sh/cmd/evince.sh similarity index 100% rename from sh/alias/evince.sh rename to sh/cmd/evince.sh diff --git a/sh/alias/grep.sh b/sh/cmd/grep.sh similarity index 100% rename from sh/alias/grep.sh rename to sh/cmd/grep.sh diff --git a/sh/alias/kill.sh b/sh/cmd/kill.sh similarity index 100% rename from sh/alias/kill.sh rename to sh/cmd/kill.sh diff --git a/sh/alias/killall.sh b/sh/cmd/killall.sh similarity index 100% rename from sh/alias/killall.sh rename to sh/cmd/killall.sh diff --git a/sh/alias/ls.sh b/sh/cmd/ls.sh similarity index 100% rename from sh/alias/ls.sh rename to sh/cmd/ls.sh diff --git a/sh/alias/lsblk.sh b/sh/cmd/lsblk.sh similarity index 100% rename from sh/alias/lsblk.sh rename to sh/cmd/lsblk.sh diff --git a/sh/alias/mkdir.sh b/sh/cmd/mkdir.sh similarity index 100% rename from sh/alias/mkdir.sh rename to sh/cmd/mkdir.sh diff --git a/sh/alias/mount.sh b/sh/cmd/mount.sh similarity index 100% rename from sh/alias/mount.sh rename to sh/cmd/mount.sh diff --git a/sh/alias/mv.sh b/sh/cmd/mv.sh similarity index 100% rename from sh/alias/mv.sh rename to sh/cmd/mv.sh diff --git a/sh/alias/nano.sh b/sh/cmd/nano.sh similarity index 100% rename from sh/alias/nano.sh rename to sh/cmd/nano.sh diff --git a/sh/alias/newsboat.sh b/sh/cmd/newsboat.sh similarity index 100% rename from sh/alias/newsboat.sh rename to sh/cmd/newsboat.sh diff --git a/sh/alias/pass.sh b/sh/cmd/pass.sh similarity index 100% rename from sh/alias/pass.sh rename to sh/cmd/pass.sh diff --git a/sh/alias/ps.sh b/sh/cmd/ps.sh similarity index 100% rename from sh/alias/ps.sh rename to sh/cmd/ps.sh diff --git a/sh/alias/pwgen.sh b/sh/cmd/pwgen.sh similarity index 100% rename from sh/alias/pwgen.sh rename to sh/cmd/pwgen.sh diff --git a/sh/alias/rm.sh b/sh/cmd/rm.sh similarity index 100% rename from sh/alias/rm.sh rename to sh/cmd/rm.sh diff --git a/sh/alias/rsync.sh b/sh/cmd/rsync.sh similarity index 100% rename from sh/alias/rsync.sh rename to sh/cmd/rsync.sh diff --git a/sh/alias/tar.sh b/sh/cmd/tar.sh similarity index 100% rename from sh/alias/tar.sh rename to sh/cmd/tar.sh diff --git a/sh/alias/tmux.sh b/sh/cmd/tmux.sh similarity index 100% rename from sh/alias/tmux.sh rename to sh/cmd/tmux.sh diff --git a/sh/alias/tree.sh b/sh/cmd/tree.sh similarity index 100% rename from sh/alias/tree.sh rename to sh/cmd/tree.sh From b380b2c0b0232492cb41e85cd7a54dfcc132271a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 12:40:20 +0100 Subject: [PATCH 695/969] gnome/proxy --- sh/gnome.sh | 9 +++++++++ sh/proxy.sh | 8 -------- 2 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 sh/proxy.sh diff --git a/sh/gnome.sh b/sh/gnome.sh index 4aa6746..c773ff8 100644 --- a/sh/gnome.sh +++ b/sh/gnome.sh @@ -1,3 +1,12 @@ +sh_gnome_proxy() { + local value + case "${1}" in + "on") value="manual" ;; + *) value="none" ;; + esac + gsettings set "org.gnome.system.proxy" "mode" "${value}" +} + sh_gnome_workspaces_primary() { local bool local group="org.gnome.mutter" diff --git a/sh/proxy.sh b/sh/proxy.sh deleted file mode 100644 index dd154a6..0000000 --- a/sh/proxy.sh +++ /dev/null @@ -1,8 +0,0 @@ -socks() { - local value - case "${1}" in - "on") value="manual" ;; - *) value="none" ;; - esac - gsettings set "org.gnome.system.proxy" "mode" "${value}" -} From 6ab26f51873cdb080fc40ec856690af8d4a8ac16 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 12:41:54 +0100 Subject: [PATCH 696/969] bsl --- sh/btrfs.sh | 8 -------- sh/cmd/btrfs.sh | 9 +++++++++ 2 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 sh/btrfs.sh diff --git a/sh/btrfs.sh b/sh/btrfs.sh deleted file mode 100644 index 253be28..0000000 --- a/sh/btrfs.sh +++ /dev/null @@ -1,8 +0,0 @@ -bsl() { sh_btrfs_subvolume_list "${@}"; } -sh_btrfs_subvolume_list() { - if [ -n "${1}" ]; then - btrfs subvolume list "${1}" | - cut --delimiter " " --fields 9 | - sort - fi -} diff --git a/sh/cmd/btrfs.sh b/sh/cmd/btrfs.sh index 4ec3ff6..fd880c1 100644 --- a/sh/cmd/btrfs.sh +++ b/sh/cmd/btrfs.sh @@ -47,6 +47,15 @@ sh_btrfs_subvolume_delete() { "${@}" } +bsl() { sh_btrfs_subvolume_list "${@}"; } +sh_btrfs_subvolume_list() { + if [ -n "${1}" ]; then + btrfs subvolume list "${1}" | + cut --delimiter " " --fields 9 | + sort + fi +} + bss() { sh_btrfs_subvolume_snapshot "${@}"; } sh_btrfs_subvolume_snapshot() { btrfs \ From ffe24a4c91a471f4cefd73507f8436a6e29a4792 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 13:15:46 +0100 Subject: [PATCH 697/969] git --- sh/{ => cmd}/git.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{ => cmd}/git.sh (100%) diff --git a/sh/git.sh b/sh/cmd/git.sh similarity index 100% rename from sh/git.sh rename to sh/cmd/git.sh From ede62d14ef035e43fcc380808aabba59ef036f77 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 13:16:16 +0100 Subject: [PATCH 698/969] gnome --- sh/{ => cmd}/gnome.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{ => cmd}/gnome.sh (100%) diff --git a/sh/gnome.sh b/sh/cmd/gnome.sh similarity index 100% rename from sh/gnome.sh rename to sh/cmd/gnome.sh From c46896293bb799e1caefe2954cadcf61c5c23892 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 14:27:43 +0100 Subject: [PATCH 699/969] alias --- sh/{cmd => alias}/git.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/git.sh (100%) diff --git a/sh/cmd/git.sh b/sh/alias/git.sh similarity index 100% rename from sh/cmd/git.sh rename to sh/alias/git.sh From ee10bfe04c8c5729c36baedc43d9f5712221c88e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 14:31:15 +0100 Subject: [PATCH 700/969] git --- sh/alias/git.sh | 242 ++++++++++++++++++++++++------------------------ 1 file changed, 121 insertions(+), 121 deletions(-) diff --git a/sh/alias/git.sh b/sh/alias/git.sh index e8b210e..6cd4311 100644 --- a/sh/alias/git.sh +++ b/sh/alias/git.sh @@ -8,16 +8,16 @@ C %C(blue)%cn %ce %B" # add to index -ga() { sh_git_add "${@}"; } -sh_git_add() { +ga() { sh_alias__git_add "${@}"; } +sh_alias__git_add() { git \ add \ "${@}" } # add all to index -gaa() { sh_git_add_all "${@}"; } -sh_git_add_all() { +gaa() { sh_alias__git_add_all "${@}"; } +sh_alias__git_add_all() { git \ add \ --all \ @@ -25,8 +25,8 @@ sh_git_add_all() { } # add parts of all to index -gaap() { sh_git_add_all_patch "${@}"; } -sh_git_add_all_patch() { +gaap() { sh_alias__git_add_all_patch "${@}"; } +sh_alias__git_add_all_patch() { git \ add \ --all \ @@ -35,8 +35,8 @@ sh_git_add_all_patch() { } # add parts to index -gap() { sh_git_add_patch "${@}"; } -sh_git_add_patch() { +gap() { sh_alias__git_add_patch "${@}"; } +sh_alias__git_add_patch() { git \ add \ --patch \ @@ -44,16 +44,16 @@ sh_git_add_patch() { } # create a branch -gb() { sh_git_branch "${@}"; } -sh_git_branch() { +gb() { sh_alias__git_branch "${@}"; } +sh_alias__git_branch() { git \ branch \ "${@}" } # delete a branch -gbd() { sh_git_branch_delete "${@}"; } -sh_git_branch_delete() { +gbd() { sh_alias__git_branch_delete "${@}"; } +sh_alias__git_branch_delete() { git \ branch \ --delete \ @@ -61,8 +61,8 @@ sh_git_branch_delete() { } # force a branch deletion -gbdf() { sh_git_branch_delete_force "${@}"; } -sh_git_branch_delete_force() { +gbdf() { sh_alias__git_branch_delete_force "${@}"; } +sh_alias__git_branch_delete_force() { git \ branch \ --delete \ @@ -71,8 +71,8 @@ sh_git_branch_delete_force() { } # list branches -gbl() { sh_git_branch_list "${@}"; } -sh_git_branch_list() { +gbl() { sh_alias__git_branch_list "${@}"; } +sh_alias__git_branch_list() { git \ branch \ --all \ @@ -83,8 +83,8 @@ sh_git_branch_list() { } # set the link to a remote branch from a local branch -gbsu() { sh_git_branch_set_upstream "${@}"; } -sh_git_branch_set_upstream() { +gbsu() { sh_alias__git_branch_set_upstream "${@}"; } +sh_alias__git_branch_set_upstream() { git \ branch \ --set-upstream-to \ @@ -92,16 +92,16 @@ sh_git_branch_set_upstream() { } # switch to a branch or checkout file(s) from a commit -gc() { sh_git_checkout "${@}"; } -sh_git_checkout() { +gc() { sh_alias__git_checkout "${@}"; } +sh_alias__git_checkout() { git \ checkout \ "${@}" } # checkout an orphan branch -gco() { sh_git_checkout_orphan "${@}"; } -sh_git_checkout_orphan() { +gco() { sh_alias__git_checkout_orphan "${@}"; } +sh_alias__git_checkout_orphan() { git \ checkout \ --orphan \ @@ -109,16 +109,16 @@ sh_git_checkout_orphan() { } # pick a commit -gcp() { sh_git_cherry_pick "${@}"; } -sh_git_cherry_pick() { +gcp() { sh_alias__git_cherry_pick "${@}"; } +sh_alias__git_cherry_pick() { git \ cherry-pick \ "${@}" } # abort the commit pick -gcpa() { sh_git_cherry_pick_abort "${@}"; } -sh_git_cherry_pick_abort() { +gcpa() { sh_alias__git_cherry_pick_abort "${@}"; } +sh_alias__git_cherry_pick_abort() { git \ cherry-pick \ --abort \ @@ -126,8 +126,8 @@ sh_git_cherry_pick_abort() { } # continue the commit pick -gcpc() { sh_git_cherry_pick_continue "${@}"; } -sh_git_cherry_pick_continue() { +gcpc() { sh_alias__git_cherry_pick_continue "${@}"; } +sh_alias__git_cherry_pick_continue() { git \ cherry-pick \ --continue \ @@ -135,8 +135,8 @@ sh_git_cherry_pick_continue() { } # clean untracked files -gcf() { sh_git_clean_force "${@}"; } -sh_git_clean_force() { +gcf() { sh_alias__git_clean_force "${@}"; } +sh_alias__git_clean_force() { git \ clean \ -d \ @@ -145,8 +145,8 @@ sh_git_clean_force() { } # redo the last commit with a different message -gcam() { sh_git_commit_amend_message "${@}"; } -sh_git_commit_amend_message() { +gcam() { sh_alias__git_commit_amend_message "${@}"; } +sh_alias__git_commit_amend_message() { git \ commit \ --amend \ @@ -155,8 +155,8 @@ sh_git_commit_amend_message() { } # make a root commit -gcem() { sh_git_commit_empty_message "${@}"; } -sh_git_commit_empty_message() { +gcem() { sh_alias__git_commit_empty_message "${@}"; } +sh_alias__git_commit_empty_message() { git \ commit \ --allow-empty \ @@ -166,8 +166,8 @@ sh_git_commit_empty_message() { } # commit the index -gcm() { sh_git_commit_message "${@}"; } -sh_git_commit_message() { +gcm() { sh_alias__git_commit_message "${@}"; } +sh_alias__git_commit_message() { git \ commit \ --message \ @@ -175,8 +175,8 @@ sh_git_commit_message() { } # configure the user email -gcue() { sh_git_config_user_email "${@}"; } -sh_git_config_user_email() { +gcue() { sh_alias__git_config_user_email "${@}"; } +sh_alias__git_config_user_email() { git \ config \ "user.email" \ @@ -184,8 +184,8 @@ sh_git_config_user_email() { } # configure the user name -gcun() { sh_git_config_user_name "${@}"; } -sh_git_config_user_name() { +gcun() { sh_alias__git_config_user_name "${@}"; } +sh_alias__git_config_user_name() { git \ config \ "user.name" \ @@ -193,16 +193,16 @@ sh_git_config_user_name() { } # differences from last or between commits -gd() { sh_git_diff "${@}"; } -sh_git_diff() { +gd() { sh_alias__git_diff "${@}"; } +sh_alias__git_diff() { git \ diff \ "${@}" } # display what is indexed in cache -gdc() { sh_git_diff_cached "${@}"; } -sh_git_diff_cached() { +gdc() { sh_alias__git_diff_cached "${@}"; } +sh_alias__git_diff_cached() { git \ diff \ --cached \ @@ -210,8 +210,8 @@ sh_git_diff_cached() { } # indexed character-level differences -gdcw() { sh_git_diff_cached_word "${@}"; } -sh_git_diff_cached_word() { +gdcw() { sh_alias__git_diff_cached_word "${@}"; } +sh_alias__git_diff_cached_word() { git \ diff \ --cached \ @@ -220,8 +220,8 @@ sh_git_diff_cached_word() { } # differences via external tool -gdt() { sh_git_diff_tool "${@}"; } -sh_git_diff_tool() { +gdt() { sh_alias__git_diff_tool "${@}"; } +sh_alias__git_diff_tool() { git \ difftool \ --dir-diff \ @@ -229,8 +229,8 @@ sh_git_diff_tool() { } # character-level differences -gdw() { sh_git_diff_word "${@}"; } -sh_git_diff_word() { +gdw() { sh_alias__git_diff_word "${@}"; } +sh_alias__git_diff_word() { git \ diff \ --word-diff-regex "." \ @@ -238,8 +238,8 @@ sh_git_diff_word() { } # fetch from the remote repository -gf() { sh_git_fetch "${@}"; } -sh_git_fetch() { +gf() { sh_alias__git_fetch "${@}"; } +sh_alias__git_fetch() { git \ fetch \ --tags \ @@ -248,16 +248,16 @@ sh_git_fetch() { } # fetch from remote repository and prune local orphan branches -gfp() { sh_git_fetch_prune "${@}"; } -sh_git_fetch_prune() { - sh_git_fetch \ +gfp() { sh_alias__git_fetch_prune "${@}"; } +sh_alias__git_fetch_prune() { + sh_alias__git_fetch \ --prune \ "${@}" } # garbage collect all orphan commits -ggc() { sh_git_garbage_collect "${@}"; } -sh_git_garbage_collect() { +ggc() { sh_alias__git_garbage_collect "${@}"; } +sh_alias__git_garbage_collect() { git \ reflog \ expire \ @@ -270,16 +270,16 @@ sh_git_garbage_collect() { } # initialize a new repository -gi() { sh_git_init "${@}"; } -sh_git_init() { +gi() { sh_alias__git_init "${@}"; } +sh_alias__git_init() { git \ init \ "${@}" } # initialize a new bare repository -gib() { sh_git_init_bare "${@}"; } -sh_git_init_bare() { +gib() { sh_alias__git_init_bare "${@}"; } +sh_alias__git_init_bare() { git \ init \ --bare \ @@ -287,8 +287,8 @@ sh_git_init_bare() { } # log history -gl() { sh_git_log "${@}"; } -sh_git_log() { +gl() { sh_alias__git_log "${@}"; } +sh_alias__git_log() { git \ log \ --abbrev=8 \ @@ -299,33 +299,33 @@ sh_git_log() { } # log all history -gla() { sh_git_log_all "${@}"; } -sh_git_log_all() { - sh_git_log \ +gla() { sh_alias__git_log_all "${@}"; } +sh_alias__git_log_all() { + sh_alias__git_log \ --all \ "${@}" } # log all history with patches -glap() { sh_git_log_all_patch "${@}"; } -sh_git_log_all_patch() { - sh_git_log \ +glap() { sh_alias__git_log_all_patch "${@}"; } +sh_alias__git_log_all_patch() { + sh_alias__git_log \ --all \ --patch \ "${@}" } # log history with patches -glp() { sh_git_log_patch "${@}"; } -sh_git_log_patch() { - sh_git_log \ +glp() { sh_alias__git_log_patch "${@}"; } +sh_alias__git_log_patch() { + sh_alias__git_log \ --patch \ "${@}" } # fast-forward merge to remote branch -gm() { sh_git_merge "${@}"; } -sh_git_merge() { +gm() { sh_alias__git_merge "${@}"; } +sh_alias__git_merge() { git \ merge \ --ff-only \ @@ -333,8 +333,8 @@ sh_git_merge() { } # abort the current merge commit -gma() { sh_git_merge_abort "${@}"; } -sh_git_merge_abort() { +gma() { sh_alias__git_merge_abort "${@}"; } +sh_alias__git_merge_abort() { git \ merge \ --abort \ @@ -342,8 +342,8 @@ sh_git_merge_abort() { } # do a merge commit -gmc() { sh_git_merge_commit "${@}"; } -sh_git_merge_commit() { +gmc() { sh_alias__git_merge_commit "${@}"; } +sh_alias__git_merge_commit() { git \ merge \ --no-ff \ @@ -352,8 +352,8 @@ sh_git_merge_commit() { } # squash a branch and index its modifications -gms() { sh_git_merge_squash "${@}"; } -sh_git_merge_squash() { +gms() { sh_alias__git_merge_squash "${@}"; } +sh_alias__git_merge_squash() { git \ merge \ --squash \ @@ -361,16 +361,16 @@ sh_git_merge_squash() { } # merge via external tool -gmt() { sh_git_merge_tool "${@}"; } -sh_git_merge_tool() { +gmt() { sh_alias__git_merge_tool "${@}"; } +sh_alias__git_merge_tool() { git \ mergetool \ "${@}" } # push to the remote repository -gp() { sh_git_push "${@}"; } -sh_git_push() { +gp() { sh_alias__git_push "${@}"; } +sh_alias__git_push() { git \ push \ --tags \ @@ -379,8 +379,8 @@ sh_git_push() { } # delete from the remote repository -gpd() { sh_git_push_delete "${@}"; } -sh_git_push_delete() { +gpd() { sh_alias__git_push_delete "${@}"; } +sh_alias__git_push_delete() { git \ push \ --delete \ @@ -388,24 +388,24 @@ sh_git_push_delete() { } # force the push to the remote repository -gpf() { sh_git_push_force "${@}"; } -sh_git_push_force() { - sh_git_push \ +gpf() { sh_alias__git_push_force "${@}"; } +sh_alias__git_push_force() { + sh_alias__git_push \ --force \ "${@}" } # rebase current branch onto another -grb() { sh_git_re_base "${@}"; } -sh_git_re_base() { +grb() { sh_alias__git_re_base "${@}"; } +sh_alias__git_re_base() { git \ rebase \ "${@}" } # abort current rebase -grba() { sh_git_re_base_abort "${@}"; } -sh_git_re_base_abort() { +grba() { sh_alias__git_re_base_abort "${@}"; } +sh_alias__git_re_base_abort() { git \ rebase \ --abort \ @@ -413,8 +413,8 @@ sh_git_re_base_abort() { } # continue current rebase -grbc() { sh_git_re_base_continue "${@}"; } -sh_git_re_base_continue() { +grbc() { sh_alias__git_re_base_continue "${@}"; } +sh_alias__git_re_base_continue() { git \ rebase \ --continue \ @@ -422,8 +422,8 @@ sh_git_re_base_continue() { } # force rebase without fast-forward -grbf() { sh_git_re_base_force "${@}"; } -sh_git_re_base_force() { +grbf() { sh_alias__git_re_base_force "${@}"; } +sh_alias__git_re_base_force() { git \ rebase \ --force-rebase \ @@ -431,8 +431,8 @@ sh_git_re_base_force() { } # rebase interactively -grbi() { sh_git_re_base_interactive "${@}"; } -sh_git_re_base_interactive() { +grbi() { sh_alias__git_re_base_interactive "${@}"; } +sh_alias__git_re_base_interactive() { git \ rebase \ --interactive \ @@ -440,8 +440,8 @@ sh_git_re_base_interactive() { } # add a new remote repository -grma() { sh_git_re_mote_add "${@}"; } -sh_git_re_mote_add() { +grma() { sh_alias__git_re_mote_add "${@}"; } +sh_alias__git_re_mote_add() { git \ remote \ add \ @@ -449,8 +449,8 @@ sh_git_re_mote_add() { } # list remote repositories -grml() { sh_git_re_mote_list "${@}"; } -sh_git_re_mote_list() { +grml() { sh_alias__git_re_mote_list "${@}"; } +sh_alias__git_re_mote_list() { git \ remote \ --verbose \ @@ -458,8 +458,8 @@ sh_git_re_mote_list() { } # set the location of a remote repository -grmsu() { sh_git_re_mote_set_upstream "${@}"; } -sh_git_re_mote_set_upstream() { +grmsu() { sh_alias__git_re_mote_set_upstream "${@}"; } +sh_alias__git_re_mote_set_upstream() { git \ remote \ set-url \ @@ -467,8 +467,8 @@ sh_git_re_mote_set_upstream() { } # show connection to a remote repository -grms() { sh_git_re_mote_show "${@}"; } -sh_git_re_mote_show() { +grms() { sh_alias__git_re_mote_show "${@}"; } +sh_alias__git_re_mote_show() { git \ remote \ show \ @@ -476,24 +476,24 @@ sh_git_re_mote_show() { } # remove and add removal to index -grm() { sh_git_re_move "${@}"; } -sh_git_re_move() { +grm() { sh_alias__git_re_move "${@}"; } +sh_alias__git_re_move() { git \ rm \ "${@}" } # remove file(s) from index or move current branch pointer -grs() { sh_git_re_set "${@}"; } -sh_git_re_set() { +grs() { sh_alias__git_re_set "${@}"; } +sh_alias__git_re_set() { git \ reset \ "${@}" } # wipe modifications or reset current branch to another commit -grsh() { sh_git_re_set_hard "${@}"; } -sh_git_re_set_hard() { +grsh() { sh_alias__git_re_set_hard "${@}"; } +sh_alias__git_re_set_hard() { git \ reset \ --hard \ @@ -501,16 +501,16 @@ sh_git_re_set_hard() { } # show a commit -gsc() { sh_git_show_commit "${@}"; } -sh_git_show_commit() { +gsc() { sh_alias__git_show_commit "${@}"; } +sh_alias__git_show_commit() { git \ show \ "${@}" } # current state of repository -gs() { sh_git_status "${@}"; } -sh_git_status() { +gs() { sh_alias__git_status "${@}"; } +sh_alias__git_status() { git \ status \ --untracked-files="all" \ @@ -518,16 +518,16 @@ sh_git_status() { } # tag a commit -gt() { sh_git_tag "${@}"; } -sh_git_tag() { +gt() { sh_alias__git_tag "${@}"; } +sh_alias__git_tag() { git \ tag \ "${@}" } # delete a tag -gtd() { sh_git_tag_delete "${@}"; } -sh_git_tag_delete() { +gtd() { sh_alias__git_tag_delete "${@}"; } +sh_alias__git_tag_delete() { git \ tag \ --delete \ From f96bcd9a9fbcad4da14017a92a5765be0361b531 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 14:33:59 +0100 Subject: [PATCH 701/969] mv --- sh/{cmd => alias}/btrfs.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/btrfs.sh (100%) diff --git a/sh/cmd/btrfs.sh b/sh/alias/btrfs.sh similarity index 100% rename from sh/cmd/btrfs.sh rename to sh/alias/btrfs.sh From aceca1fc69329d43ea6414f5556e5fee53f82b6e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 14:35:14 +0100 Subject: [PATCH 702/969] btrfs --- sh/alias/btrfs.sh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/sh/alias/btrfs.sh b/sh/alias/btrfs.sh index fd880c1..3ec74fb 100644 --- a/sh/alias/btrfs.sh +++ b/sh/alias/btrfs.sh @@ -1,13 +1,13 @@ -bfdf() { sh_btrfs_filesystem_d_f "${@}"; } -sh_btrfs_filesystem_d_f() { +bfdf() { sh_a__btrfs_filesystem_d_f "${@}"; } +sh_a__btrfs_filesystem_d_f() { btrfs \ filesystem \ df \ "${@}" } -bfdu() { sh_btrfs_filesystem_d_u "${@}"; } -sh_btrfs_filesystem_d_u() { +bfdu() { sh_a__btrfs_filesystem_d_u "${@}"; } +sh_a__btrfs_filesystem_d_u() { btrfs \ filesystem \ du \ @@ -15,40 +15,40 @@ sh_btrfs_filesystem_d_u() { "${@}" } -bfu() { sh_btrfs_filesystem_usage "${@}"; } -sh_btrfs_filesystem_usage() { +bfu() { sh_a__btrfs_filesystem_usage "${@}"; } +sh_a__btrfs_filesystem_usage() { btrfs \ filesystem \ usage \ "${@}" } -bpg() { sh_btrfs_property_get "${@}"; } -sh_btrfs_property_get() { +bpg() { sh_a__btrfs_property_get "${@}"; } +sh_a__btrfs_property_get() { btrfs \ property \ get \ "${@}" } -bsc() { sh_btrfs_subvolume_create "${@}"; } -sh_btrfs_subvolume_create() { +bsc() { sh_a__btrfs_subvolume_create "${@}"; } +sh_a__btrfs_subvolume_create() { btrfs \ subvolume \ create \ "${@}" } -bsd() { sh_btrfs_subvolume_delete "${@}"; } -sh_btrfs_subvolume_delete() { +bsd() { sh_a__btrfs_subvolume_delete "${@}"; } +sh_a__btrfs_subvolume_delete() { btrfs \ subvolume \ delete \ "${@}" } -bsl() { sh_btrfs_subvolume_list "${@}"; } -sh_btrfs_subvolume_list() { +bsl() { sh_a__btrfs_subvolume_list "${@}"; } +sh_a__btrfs_subvolume_list() { if [ -n "${1}" ]; then btrfs subvolume list "${1}" | cut --delimiter " " --fields 9 | @@ -56,16 +56,16 @@ sh_btrfs_subvolume_list() { fi } -bss() { sh_btrfs_subvolume_snapshot "${@}"; } -sh_btrfs_subvolume_snapshot() { +bss() { sh_a__btrfs_subvolume_snapshot "${@}"; } +sh_a__btrfs_subvolume_snapshot() { btrfs \ subvolume \ snapshot \ "${@}" } -bssr() { sh_btrfs_subvolume_snapshot_r "${@}"; } -sh_btrfs_subvolume_snapshot_r() { +bssr() { sh_a__btrfs_subvolume_snapshot_r "${@}"; } +sh_a__btrfs_subvolume_snapshot_r() { btrfs \ subvolume \ snapshot -r \ From 92010392aed8e8b9d00e25c94d63ce7a54eeae0a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 14:39:06 +0100 Subject: [PATCH 703/969] git --- sh/alias/git.sh | 242 ++++++++++++++++++++++++------------------------ 1 file changed, 121 insertions(+), 121 deletions(-) diff --git a/sh/alias/git.sh b/sh/alias/git.sh index 6cd4311..864620b 100644 --- a/sh/alias/git.sh +++ b/sh/alias/git.sh @@ -8,16 +8,16 @@ C %C(blue)%cn %ce %B" # add to index -ga() { sh_alias__git_add "${@}"; } -sh_alias__git_add() { +ga() { sh_a__git_add "${@}"; } +sh_a__git_add() { git \ add \ "${@}" } # add all to index -gaa() { sh_alias__git_add_all "${@}"; } -sh_alias__git_add_all() { +gaa() { sh_a__git_add_all "${@}"; } +sh_a__git_add_all() { git \ add \ --all \ @@ -25,8 +25,8 @@ sh_alias__git_add_all() { } # add parts of all to index -gaap() { sh_alias__git_add_all_patch "${@}"; } -sh_alias__git_add_all_patch() { +gaap() { sh_a__git_add_all_patch "${@}"; } +sh_a__git_add_all_patch() { git \ add \ --all \ @@ -35,8 +35,8 @@ sh_alias__git_add_all_patch() { } # add parts to index -gap() { sh_alias__git_add_patch "${@}"; } -sh_alias__git_add_patch() { +gap() { sh_a__git_add_patch "${@}"; } +sh_a__git_add_patch() { git \ add \ --patch \ @@ -44,16 +44,16 @@ sh_alias__git_add_patch() { } # create a branch -gb() { sh_alias__git_branch "${@}"; } -sh_alias__git_branch() { +gb() { sh_a__git_branch "${@}"; } +sh_a__git_branch() { git \ branch \ "${@}" } # delete a branch -gbd() { sh_alias__git_branch_delete "${@}"; } -sh_alias__git_branch_delete() { +gbd() { sh_a__git_branch_delete "${@}"; } +sh_a__git_branch_delete() { git \ branch \ --delete \ @@ -61,8 +61,8 @@ sh_alias__git_branch_delete() { } # force a branch deletion -gbdf() { sh_alias__git_branch_delete_force "${@}"; } -sh_alias__git_branch_delete_force() { +gbdf() { sh_a__git_branch_delete_force "${@}"; } +sh_a__git_branch_delete_force() { git \ branch \ --delete \ @@ -71,8 +71,8 @@ sh_alias__git_branch_delete_force() { } # list branches -gbl() { sh_alias__git_branch_list "${@}"; } -sh_alias__git_branch_list() { +gbl() { sh_a__git_branch_list "${@}"; } +sh_a__git_branch_list() { git \ branch \ --all \ @@ -83,8 +83,8 @@ sh_alias__git_branch_list() { } # set the link to a remote branch from a local branch -gbsu() { sh_alias__git_branch_set_upstream "${@}"; } -sh_alias__git_branch_set_upstream() { +gbsu() { sh_a__git_branch_set_upstream "${@}"; } +sh_a__git_branch_set_upstream() { git \ branch \ --set-upstream-to \ @@ -92,16 +92,16 @@ sh_alias__git_branch_set_upstream() { } # switch to a branch or checkout file(s) from a commit -gc() { sh_alias__git_checkout "${@}"; } -sh_alias__git_checkout() { +gc() { sh_a__git_checkout "${@}"; } +sh_a__git_checkout() { git \ checkout \ "${@}" } # checkout an orphan branch -gco() { sh_alias__git_checkout_orphan "${@}"; } -sh_alias__git_checkout_orphan() { +gco() { sh_a__git_checkout_orphan "${@}"; } +sh_a__git_checkout_orphan() { git \ checkout \ --orphan \ @@ -109,16 +109,16 @@ sh_alias__git_checkout_orphan() { } # pick a commit -gcp() { sh_alias__git_cherry_pick "${@}"; } -sh_alias__git_cherry_pick() { +gcp() { sh_a__git_cherry_pick "${@}"; } +sh_a__git_cherry_pick() { git \ cherry-pick \ "${@}" } # abort the commit pick -gcpa() { sh_alias__git_cherry_pick_abort "${@}"; } -sh_alias__git_cherry_pick_abort() { +gcpa() { sh_a__git_cherry_pick_abort "${@}"; } +sh_a__git_cherry_pick_abort() { git \ cherry-pick \ --abort \ @@ -126,8 +126,8 @@ sh_alias__git_cherry_pick_abort() { } # continue the commit pick -gcpc() { sh_alias__git_cherry_pick_continue "${@}"; } -sh_alias__git_cherry_pick_continue() { +gcpc() { sh_a__git_cherry_pick_continue "${@}"; } +sh_a__git_cherry_pick_continue() { git \ cherry-pick \ --continue \ @@ -135,8 +135,8 @@ sh_alias__git_cherry_pick_continue() { } # clean untracked files -gcf() { sh_alias__git_clean_force "${@}"; } -sh_alias__git_clean_force() { +gcf() { sh_a__git_clean_force "${@}"; } +sh_a__git_clean_force() { git \ clean \ -d \ @@ -145,8 +145,8 @@ sh_alias__git_clean_force() { } # redo the last commit with a different message -gcam() { sh_alias__git_commit_amend_message "${@}"; } -sh_alias__git_commit_amend_message() { +gcam() { sh_a__git_commit_amend_message "${@}"; } +sh_a__git_commit_amend_message() { git \ commit \ --amend \ @@ -155,8 +155,8 @@ sh_alias__git_commit_amend_message() { } # make a root commit -gcem() { sh_alias__git_commit_empty_message "${@}"; } -sh_alias__git_commit_empty_message() { +gcem() { sh_a__git_commit_empty_message "${@}"; } +sh_a__git_commit_empty_message() { git \ commit \ --allow-empty \ @@ -166,8 +166,8 @@ sh_alias__git_commit_empty_message() { } # commit the index -gcm() { sh_alias__git_commit_message "${@}"; } -sh_alias__git_commit_message() { +gcm() { sh_a__git_commit_message "${@}"; } +sh_a__git_commit_message() { git \ commit \ --message \ @@ -175,8 +175,8 @@ sh_alias__git_commit_message() { } # configure the user email -gcue() { sh_alias__git_config_user_email "${@}"; } -sh_alias__git_config_user_email() { +gcue() { sh_a__git_config_user_email "${@}"; } +sh_a__git_config_user_email() { git \ config \ "user.email" \ @@ -184,8 +184,8 @@ sh_alias__git_config_user_email() { } # configure the user name -gcun() { sh_alias__git_config_user_name "${@}"; } -sh_alias__git_config_user_name() { +gcun() { sh_a__git_config_user_name "${@}"; } +sh_a__git_config_user_name() { git \ config \ "user.name" \ @@ -193,16 +193,16 @@ sh_alias__git_config_user_name() { } # differences from last or between commits -gd() { sh_alias__git_diff "${@}"; } -sh_alias__git_diff() { +gd() { sh_a__git_diff "${@}"; } +sh_a__git_diff() { git \ diff \ "${@}" } # display what is indexed in cache -gdc() { sh_alias__git_diff_cached "${@}"; } -sh_alias__git_diff_cached() { +gdc() { sh_a__git_diff_cached "${@}"; } +sh_a__git_diff_cached() { git \ diff \ --cached \ @@ -210,8 +210,8 @@ sh_alias__git_diff_cached() { } # indexed character-level differences -gdcw() { sh_alias__git_diff_cached_word "${@}"; } -sh_alias__git_diff_cached_word() { +gdcw() { sh_a__git_diff_cached_word "${@}"; } +sh_a__git_diff_cached_word() { git \ diff \ --cached \ @@ -220,8 +220,8 @@ sh_alias__git_diff_cached_word() { } # differences via external tool -gdt() { sh_alias__git_diff_tool "${@}"; } -sh_alias__git_diff_tool() { +gdt() { sh_a__git_diff_tool "${@}"; } +sh_a__git_diff_tool() { git \ difftool \ --dir-diff \ @@ -229,8 +229,8 @@ sh_alias__git_diff_tool() { } # character-level differences -gdw() { sh_alias__git_diff_word "${@}"; } -sh_alias__git_diff_word() { +gdw() { sh_a__git_diff_word "${@}"; } +sh_a__git_diff_word() { git \ diff \ --word-diff-regex "." \ @@ -238,8 +238,8 @@ sh_alias__git_diff_word() { } # fetch from the remote repository -gf() { sh_alias__git_fetch "${@}"; } -sh_alias__git_fetch() { +gf() { sh_a__git_fetch "${@}"; } +sh_a__git_fetch() { git \ fetch \ --tags \ @@ -248,16 +248,16 @@ sh_alias__git_fetch() { } # fetch from remote repository and prune local orphan branches -gfp() { sh_alias__git_fetch_prune "${@}"; } -sh_alias__git_fetch_prune() { - sh_alias__git_fetch \ +gfp() { sh_a__git_fetch_prune "${@}"; } +sh_a__git_fetch_prune() { + sh_a__git_fetch \ --prune \ "${@}" } # garbage collect all orphan commits -ggc() { sh_alias__git_garbage_collect "${@}"; } -sh_alias__git_garbage_collect() { +ggc() { sh_a__git_garbage_collect "${@}"; } +sh_a__git_garbage_collect() { git \ reflog \ expire \ @@ -270,16 +270,16 @@ sh_alias__git_garbage_collect() { } # initialize a new repository -gi() { sh_alias__git_init "${@}"; } -sh_alias__git_init() { +gi() { sh_a__git_init "${@}"; } +sh_a__git_init() { git \ init \ "${@}" } # initialize a new bare repository -gib() { sh_alias__git_init_bare "${@}"; } -sh_alias__git_init_bare() { +gib() { sh_a__git_init_bare "${@}"; } +sh_a__git_init_bare() { git \ init \ --bare \ @@ -287,8 +287,8 @@ sh_alias__git_init_bare() { } # log history -gl() { sh_alias__git_log "${@}"; } -sh_alias__git_log() { +gl() { sh_a__git_log "${@}"; } +sh_a__git_log() { git \ log \ --abbrev=8 \ @@ -299,33 +299,33 @@ sh_alias__git_log() { } # log all history -gla() { sh_alias__git_log_all "${@}"; } -sh_alias__git_log_all() { - sh_alias__git_log \ +gla() { sh_a__git_log_all "${@}"; } +sh_a__git_log_all() { + sh_a__git_log \ --all \ "${@}" } # log all history with patches -glap() { sh_alias__git_log_all_patch "${@}"; } -sh_alias__git_log_all_patch() { - sh_alias__git_log \ +glap() { sh_a__git_log_all_patch "${@}"; } +sh_a__git_log_all_patch() { + sh_a__git_log \ --all \ --patch \ "${@}" } # log history with patches -glp() { sh_alias__git_log_patch "${@}"; } -sh_alias__git_log_patch() { - sh_alias__git_log \ +glp() { sh_a__git_log_patch "${@}"; } +sh_a__git_log_patch() { + sh_a__git_log \ --patch \ "${@}" } # fast-forward merge to remote branch -gm() { sh_alias__git_merge "${@}"; } -sh_alias__git_merge() { +gm() { sh_a__git_merge "${@}"; } +sh_a__git_merge() { git \ merge \ --ff-only \ @@ -333,8 +333,8 @@ sh_alias__git_merge() { } # abort the current merge commit -gma() { sh_alias__git_merge_abort "${@}"; } -sh_alias__git_merge_abort() { +gma() { sh_a__git_merge_abort "${@}"; } +sh_a__git_merge_abort() { git \ merge \ --abort \ @@ -342,8 +342,8 @@ sh_alias__git_merge_abort() { } # do a merge commit -gmc() { sh_alias__git_merge_commit "${@}"; } -sh_alias__git_merge_commit() { +gmc() { sh_a__git_merge_commit "${@}"; } +sh_a__git_merge_commit() { git \ merge \ --no-ff \ @@ -352,8 +352,8 @@ sh_alias__git_merge_commit() { } # squash a branch and index its modifications -gms() { sh_alias__git_merge_squash "${@}"; } -sh_alias__git_merge_squash() { +gms() { sh_a__git_merge_squash "${@}"; } +sh_a__git_merge_squash() { git \ merge \ --squash \ @@ -361,16 +361,16 @@ sh_alias__git_merge_squash() { } # merge via external tool -gmt() { sh_alias__git_merge_tool "${@}"; } -sh_alias__git_merge_tool() { +gmt() { sh_a__git_merge_tool "${@}"; } +sh_a__git_merge_tool() { git \ mergetool \ "${@}" } # push to the remote repository -gp() { sh_alias__git_push "${@}"; } -sh_alias__git_push() { +gp() { sh_a__git_push "${@}"; } +sh_a__git_push() { git \ push \ --tags \ @@ -379,8 +379,8 @@ sh_alias__git_push() { } # delete from the remote repository -gpd() { sh_alias__git_push_delete "${@}"; } -sh_alias__git_push_delete() { +gpd() { sh_a__git_push_delete "${@}"; } +sh_a__git_push_delete() { git \ push \ --delete \ @@ -388,24 +388,24 @@ sh_alias__git_push_delete() { } # force the push to the remote repository -gpf() { sh_alias__git_push_force "${@}"; } -sh_alias__git_push_force() { - sh_alias__git_push \ +gpf() { sh_a__git_push_force "${@}"; } +sh_a__git_push_force() { + sh_a__git_push \ --force \ "${@}" } # rebase current branch onto another -grb() { sh_alias__git_re_base "${@}"; } -sh_alias__git_re_base() { +grb() { sh_a__git_re_base "${@}"; } +sh_a__git_re_base() { git \ rebase \ "${@}" } # abort current rebase -grba() { sh_alias__git_re_base_abort "${@}"; } -sh_alias__git_re_base_abort() { +grba() { sh_a__git_re_base_abort "${@}"; } +sh_a__git_re_base_abort() { git \ rebase \ --abort \ @@ -413,8 +413,8 @@ sh_alias__git_re_base_abort() { } # continue current rebase -grbc() { sh_alias__git_re_base_continue "${@}"; } -sh_alias__git_re_base_continue() { +grbc() { sh_a__git_re_base_continue "${@}"; } +sh_a__git_re_base_continue() { git \ rebase \ --continue \ @@ -422,8 +422,8 @@ sh_alias__git_re_base_continue() { } # force rebase without fast-forward -grbf() { sh_alias__git_re_base_force "${@}"; } -sh_alias__git_re_base_force() { +grbf() { sh_a__git_re_base_force "${@}"; } +sh_a__git_re_base_force() { git \ rebase \ --force-rebase \ @@ -431,8 +431,8 @@ sh_alias__git_re_base_force() { } # rebase interactively -grbi() { sh_alias__git_re_base_interactive "${@}"; } -sh_alias__git_re_base_interactive() { +grbi() { sh_a__git_re_base_interactive "${@}"; } +sh_a__git_re_base_interactive() { git \ rebase \ --interactive \ @@ -440,8 +440,8 @@ sh_alias__git_re_base_interactive() { } # add a new remote repository -grma() { sh_alias__git_re_mote_add "${@}"; } -sh_alias__git_re_mote_add() { +grma() { sh_a__git_re_mote_add "${@}"; } +sh_a__git_re_mote_add() { git \ remote \ add \ @@ -449,8 +449,8 @@ sh_alias__git_re_mote_add() { } # list remote repositories -grml() { sh_alias__git_re_mote_list "${@}"; } -sh_alias__git_re_mote_list() { +grml() { sh_a__git_re_mote_list "${@}"; } +sh_a__git_re_mote_list() { git \ remote \ --verbose \ @@ -458,8 +458,8 @@ sh_alias__git_re_mote_list() { } # set the location of a remote repository -grmsu() { sh_alias__git_re_mote_set_upstream "${@}"; } -sh_alias__git_re_mote_set_upstream() { +grmsu() { sh_a__git_re_mote_set_upstream "${@}"; } +sh_a__git_re_mote_set_upstream() { git \ remote \ set-url \ @@ -467,8 +467,8 @@ sh_alias__git_re_mote_set_upstream() { } # show connection to a remote repository -grms() { sh_alias__git_re_mote_show "${@}"; } -sh_alias__git_re_mote_show() { +grms() { sh_a__git_re_mote_show "${@}"; } +sh_a__git_re_mote_show() { git \ remote \ show \ @@ -476,24 +476,24 @@ sh_alias__git_re_mote_show() { } # remove and add removal to index -grm() { sh_alias__git_re_move "${@}"; } -sh_alias__git_re_move() { +grm() { sh_a__git_re_move "${@}"; } +sh_a__git_re_move() { git \ rm \ "${@}" } # remove file(s) from index or move current branch pointer -grs() { sh_alias__git_re_set "${@}"; } -sh_alias__git_re_set() { +grs() { sh_a__git_re_set "${@}"; } +sh_a__git_re_set() { git \ reset \ "${@}" } # wipe modifications or reset current branch to another commit -grsh() { sh_alias__git_re_set_hard "${@}"; } -sh_alias__git_re_set_hard() { +grsh() { sh_a__git_re_set_hard "${@}"; } +sh_a__git_re_set_hard() { git \ reset \ --hard \ @@ -501,16 +501,16 @@ sh_alias__git_re_set_hard() { } # show a commit -gsc() { sh_alias__git_show_commit "${@}"; } -sh_alias__git_show_commit() { +gsc() { sh_a__git_show_commit "${@}"; } +sh_a__git_show_commit() { git \ show \ "${@}" } # current state of repository -gs() { sh_alias__git_status "${@}"; } -sh_alias__git_status() { +gs() { sh_a__git_status "${@}"; } +sh_a__git_status() { git \ status \ --untracked-files="all" \ @@ -518,16 +518,16 @@ sh_alias__git_status() { } # tag a commit -gt() { sh_alias__git_tag "${@}"; } -sh_alias__git_tag() { +gt() { sh_a__git_tag "${@}"; } +sh_a__git_tag() { git \ tag \ "${@}" } # delete a tag -gtd() { sh_alias__git_tag_delete "${@}"; } -sh_alias__git_tag_delete() { +gtd() { sh_a__git_tag_delete "${@}"; } +sh_a__git_tag_delete() { git \ tag \ --delete \ From f77081fd17f831f30972d50ddea169db153bb240 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 14:42:18 +0100 Subject: [PATCH 704/969] mv --- sh/{cmd => alias}/nano.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/nano.sh (100%) diff --git a/sh/cmd/nano.sh b/sh/alias/nano.sh similarity index 100% rename from sh/cmd/nano.sh rename to sh/alias/nano.sh From 95df4c78e51a0c58edb69aa5d2711fbc9f991174 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 14:45:04 +0100 Subject: [PATCH 705/969] nano --- sh/alias/nano.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/alias/nano.sh b/sh/alias/nano.sh index 2718583..ca6eb65 100644 --- a/sh/alias/nano.sh +++ b/sh/alias/nano.sh @@ -1,4 +1,5 @@ -nn() { +nn() { sh_a__na_no "${@}"; } +sh_a__na_no() { nano \ "${@}" } From ab509523173a838af68d9f0b1506086afc87053f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 14:46:59 +0100 Subject: [PATCH 706/969] mv --- sh/{cmd => alias}/byobu.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/byobu.sh (100%) diff --git a/sh/cmd/byobu.sh b/sh/alias/byobu.sh similarity index 100% rename from sh/cmd/byobu.sh rename to sh/alias/byobu.sh From 75c3627d2c71dd7b9d303d5e6eab85e32c8d92df Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:07:17 +0100 Subject: [PATCH 707/969] byobu --- sh/alias/byobu.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sh/alias/byobu.sh b/sh/alias/byobu.sh index d645cb1..79155b5 100644 --- a/sh/alias/byobu.sh +++ b/sh/alias/byobu.sh @@ -1,21 +1,25 @@ -bb() { +bb() { sh_a__byo_bu "${@}"; } +sh_a__byo_bu() { byobu \ "${@}" } -bba() { +bba() { sh_a__byo_bu_attach "${@}"; } +sh_a__byo_bu_attach() { byobu \ attach-session \ "${@}" } -bbl() { +bbl() { sh_a__byo_bu_ls "${@}"; } +sh_a__byo_bu_ls() { byobu \ ls \ "${@}" } -bbnd() { +bbnd() { sh_a__byo_bu_new_detach "${@}"; } +sh_a__byo_bu_new_detach() { byobu \ new-session \ -d \ From c7430d275ad04c5cc2c03cd9b64897c9677cd74f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:17:11 +0100 Subject: [PATCH 708/969] mv --- sh/{cmd => alias}/evince.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/evince.sh (100%) diff --git a/sh/cmd/evince.sh b/sh/alias/evince.sh similarity index 100% rename from sh/cmd/evince.sh rename to sh/alias/evince.sh From 7df87a0517b710331bbfc66e72b0bbf23cc291b9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:17:50 +0100 Subject: [PATCH 709/969] evince --- sh/alias/evince.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/alias/evince.sh b/sh/alias/evince.sh index 01ec950..3c609ef 100644 --- a/sh/alias/evince.sh +++ b/sh/alias/evince.sh @@ -1,4 +1,5 @@ -ev() { +ev() { sh_a__e_vince "${@}"; } +sh_a__e_vince() { evince \ "${@}" } From 6d000b2ead23e49f48ed06f93c4530e3d573637b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:18:29 +0100 Subject: [PATCH 710/969] mv --- sh/{cmd => alias}/pass.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/pass.sh (100%) diff --git a/sh/cmd/pass.sh b/sh/alias/pass.sh similarity index 100% rename from sh/cmd/pass.sh rename to sh/alias/pass.sh From 464d23cba3b5c6f510d5f710d2783189928b6931 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:19:29 +0100 Subject: [PATCH 711/969] pass --- sh/alias/pass.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sh/alias/pass.sh b/sh/alias/pass.sh index ddcfa48..e94898a 100644 --- a/sh/alias/pass.sh +++ b/sh/alias/pass.sh @@ -1,11 +1,13 @@ # display pass entry’s content -p() { +p() { sh_a__pass "${@}"; } +sh_a__pass() { pass \ "${@}" } # copy passphrase into clipboard -pc() { +pc() { sh_a__pass_clip "${@}"; } +sh_a__pass_clip() { pass \ --clip \ "${@}" From 1ef0f04b0776e2a6bf5a5dffdfdd9efe64ae5004 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:22:47 +0100 Subject: [PATCH 712/969] mv --- sh/{cmd => alias}/tmux.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/tmux.sh (100%) diff --git a/sh/cmd/tmux.sh b/sh/alias/tmux.sh similarity index 100% rename from sh/cmd/tmux.sh rename to sh/alias/tmux.sh From 078d3b783e9c9ae6bd618b92ec2ce8bc47b84509 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:23:25 +0100 Subject: [PATCH 713/969] tmux --- sh/alias/tmux.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/alias/tmux.sh b/sh/alias/tmux.sh index fa96b6a..fa51bd5 100644 --- a/sh/alias/tmux.sh +++ b/sh/alias/tmux.sh @@ -1,4 +1,5 @@ -tm() { +tm() { sh_a__t_mux "${@}"; } +sh_a__t_mux() { tmux \ "${@}" } From 8d01c89dc10e2d137335b354c3d49b15fd017109 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:24:12 +0100 Subject: [PATCH 714/969] mv --- sh/{cmd => alias}/newsboat.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/newsboat.sh (100%) diff --git a/sh/cmd/newsboat.sh b/sh/alias/newsboat.sh similarity index 100% rename from sh/cmd/newsboat.sh rename to sh/alias/newsboat.sh From be22e290f483159f518ace2cdd33aaeac3d6ff56 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:25:06 +0100 Subject: [PATCH 715/969] newsboat --- sh/alias/newsboat.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/alias/newsboat.sh b/sh/alias/newsboat.sh index adbfd37..18c09e3 100644 --- a/sh/alias/newsboat.sh +++ b/sh/alias/newsboat.sh @@ -1,5 +1,5 @@ -nb() { news_boat "${@}"; } -news_boat() { +nb() { sh_a__news_boat "${@}"; } +sh_a__news_boat() { newsboat \ "${@}" } From 9522c537b4b6a392d18ef82bc0683d309c2a07f7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:25:31 +0100 Subject: [PATCH 716/969] mv --- sh/{cmd => alias}/emacs.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/emacs.sh (100%) diff --git a/sh/cmd/emacs.sh b/sh/alias/emacs.sh similarity index 100% rename from sh/cmd/emacs.sh rename to sh/alias/emacs.sh From 63deee73265375f81264de82770348379b670237 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:26:03 +0100 Subject: [PATCH 717/969] emacs --- sh/alias/emacs.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/alias/emacs.sh b/sh/alias/emacs.sh index 8bd77fc..84fc56f 100644 --- a/sh/alias/emacs.sh +++ b/sh/alias/emacs.sh @@ -1,4 +1,5 @@ -em() { +em() { sh_a__e_macs "${@}"; } +sh_a__e_macs() { emacs \ "${@}" } From 0f312f6c853632df75cce201a7ed96b37da77539 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:30:45 +0100 Subject: [PATCH 718/969] mv --- sh/{cmd => alias}/rm.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/rm.sh (100%) diff --git a/sh/cmd/rm.sh b/sh/alias/rm.sh similarity index 100% rename from sh/cmd/rm.sh rename to sh/alias/rm.sh From dcc82f1cf77e6ab4ca925a14a0886a5801795b5b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:31:30 +0100 Subject: [PATCH 719/969] rm --- sh/alias/rm.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/alias/rm.sh b/sh/alias/rm.sh index 0d42f42..f944698 100644 --- a/sh/alias/rm.sh +++ b/sh/alias/rm.sh @@ -1,5 +1,6 @@ # remove interactively -rmi() { +rmi() { sh_a__re_move_interactive "${@}"; } +sh_a__re_move_interactive() { rm \ --interactive \ "${@}" From baa163b5b2c93468a14103e7c778b1ee7c8be606 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:33:10 +0100 Subject: [PATCH 720/969] mv --- sh/{cmd => alias}/clear.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/clear.sh (100%) diff --git a/sh/cmd/clear.sh b/sh/alias/clear.sh similarity index 100% rename from sh/cmd/clear.sh rename to sh/alias/clear.sh From b2df5a6eb5804e8c4e1001d37fc7355bd364756c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:33:44 +0100 Subject: [PATCH 721/969] clear --- sh/alias/clear.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/alias/clear.sh b/sh/alias/clear.sh index 6a69638..9731fe0 100644 --- a/sh/alias/clear.sh +++ b/sh/alias/clear.sh @@ -1,5 +1,6 @@ # clear terminal -c() { +c() { sh_a__clear "${@}"; } +sh_a__clear() { clear \ "${@}" } From 53957e5690e75f32ebc873092f7af546d89a9290 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:34:30 +0100 Subject: [PATCH 722/969] mv --- sh/{cmd => alias}/cp.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/cp.sh (100%) diff --git a/sh/cmd/cp.sh b/sh/alias/cp.sh similarity index 100% rename from sh/cmd/cp.sh rename to sh/alias/cp.sh From 743b82cb2d6c6d428e6dab087eee2985464f970a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:35:18 +0100 Subject: [PATCH 723/969] cp --- sh/alias/cp.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/alias/cp.sh b/sh/alias/cp.sh index 5db0082..dd1a271 100644 --- a/sh/alias/cp.sh +++ b/sh/alias/cp.sh @@ -1,5 +1,6 @@ # copy interactively -cpi() { +cpi() { sh_a__co_py_interactive "${@}"; } +sh_a__co_py_interactive() { cp \ --interactive \ "${@}" From 08179f386e96a6fae366e418e0ed2cfb1e2f2e18 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:35:54 +0100 Subject: [PATCH 724/969] mv --- sh/{cmd => alias}/mv.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/mv.sh (100%) diff --git a/sh/cmd/mv.sh b/sh/alias/mv.sh similarity index 100% rename from sh/cmd/mv.sh rename to sh/alias/mv.sh From 97e985f2667533a00bfc74899e83e8e414052dc3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:36:57 +0100 Subject: [PATCH 725/969] mvi --- sh/alias/mv.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/alias/mv.sh b/sh/alias/mv.sh index 89d6efd..2a4ae5e 100644 --- a/sh/alias/mv.sh +++ b/sh/alias/mv.sh @@ -1,5 +1,6 @@ # move interactively -mvi() { +mvi() { sh_a__mo_ve_interactive "${@}"; } +sh_a__mo_ve_interactive() { mv \ --interactive \ "${@}" From 15dfd51681682844c40a0d09eadbe17e7bc926a6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:38:27 +0100 Subject: [PATCH 726/969] mv --- sh/{cmd => alias}/tree.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/tree.sh (100%) diff --git a/sh/cmd/tree.sh b/sh/alias/tree.sh similarity index 100% rename from sh/cmd/tree.sh rename to sh/alias/tree.sh From 491dc1fa1cd4507213b7a385940474c4b4388805 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 15:39:27 +0100 Subject: [PATCH 727/969] tree --- sh/alias/tree.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sh/alias/tree.sh b/sh/alias/tree.sh index c96738c..9d807c0 100644 --- a/sh/alias/tree.sh +++ b/sh/alias/tree.sh @@ -1,9 +1,11 @@ -t() { +t() { sh_a__tree "${@}"; } +sh_a__tree() { tree \ "${@}" } -ta() { +ta() { sh_a__tree_all "${@}"; } +sh_a__tree_all() { tree \ -a \ "${@}" From 6a7800e19e34bb014671e654a4061ec035dcc3b8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:08:55 +0100 Subject: [PATCH 728/969] cp --- sh/alias/mount.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 sh/alias/mount.sh diff --git a/sh/alias/mount.sh b/sh/alias/mount.sh new file mode 100644 index 0000000..d6329c3 --- /dev/null +++ b/sh/alias/mount.sh @@ -0,0 +1,11 @@ +m() { + mount \ + "${@}" +} + +# remount read-only medium in read-write +remount() { + mount \ + -o "remount,rw" \ + "/usr/lib/live/mount/medium" +} From 22c9a661621432a05e2b4aa258c8b96dba478dbb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:10:14 +0100 Subject: [PATCH 729/969] m --- sh/alias/mount.sh | 10 ++-------- sh/cmd/mount.sh | 5 ----- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/sh/alias/mount.sh b/sh/alias/mount.sh index d6329c3..9aa0aad 100644 --- a/sh/alias/mount.sh +++ b/sh/alias/mount.sh @@ -1,11 +1,5 @@ -m() { +m() { sh_a__mount "${@}"; } +sh_a__mount() { mount \ "${@}" } - -# remount read-only medium in read-write -remount() { - mount \ - -o "remount,rw" \ - "/usr/lib/live/mount/medium" -} diff --git a/sh/cmd/mount.sh b/sh/cmd/mount.sh index d6329c3..4454c41 100644 --- a/sh/cmd/mount.sh +++ b/sh/cmd/mount.sh @@ -1,8 +1,3 @@ -m() { - mount \ - "${@}" -} - # remount read-only medium in read-write remount() { mount \ From 4cbdeae4e9038686d47fb95c719b2f968caa0b9f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:11:50 +0100 Subject: [PATCH 730/969] mv --- sh/{cmd => alias}/chmod.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/chmod.sh (100%) diff --git a/sh/cmd/chmod.sh b/sh/alias/chmod.sh similarity index 100% rename from sh/cmd/chmod.sh rename to sh/alias/chmod.sh From ef0a7a6f2867e246c62dd0f9a7656dd6da22de00 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:13:13 +0100 Subject: [PATCH 731/969] chmod --- sh/alias/chmod.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sh/alias/chmod.sh b/sh/alias/chmod.sh index 89b8bd7..1c55b40 100644 --- a/sh/alias/chmod.sh +++ b/sh/alias/chmod.sh @@ -1,12 +1,14 @@ # change mode to directory -cmd() { +cmd() { sh_a__change_mode_directory "${@}"; } +sh_a__change_mode_directory() { chmod \ "755" \ "${@}" } # change mode to file -cmf() { +cmf() { sh_a__change_mode_file "${@}"; } +sh_a__change_mode_file() { chmod \ "644" \ "${@}" From d418c758d810cd67e4bcf0b14c19f693947f85ef Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:16:41 +0100 Subject: [PATCH 732/969] mv --- sh/{cmd => alias}/chown.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/chown.sh (100%) diff --git a/sh/cmd/chown.sh b/sh/alias/chown.sh similarity index 100% rename from sh/cmd/chown.sh rename to sh/alias/chown.sh From 12bc25233cdf426153593680b086eacdfcf5f194 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:17:43 +0100 Subject: [PATCH 733/969] chown --- sh/alias/chown.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sh/alias/chown.sh b/sh/alias/chown.sh index f7bbef9..6a7a156 100644 --- a/sh/alias/chown.sh +++ b/sh/alias/chown.sh @@ -1,12 +1,14 @@ # change owner to root -cor() { +cor() { sh_a__change_owner_root "${@}"; } +sh_a__change_owner_root() { chown \ "0:0" \ "${@}" } # change owner to user -cou() { +cou() { sh_a__change_owner_user "${@}"; } +sh_a__change_owner_user() { chown \ "1000:1000" \ "${@}" From 3108283a42f9c97b254c5a0725a6777f1591a6d1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:19:37 +0100 Subject: [PATCH 734/969] mv --- sh/{cmd => alias}/ls.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/ls.sh (100%) diff --git a/sh/cmd/ls.sh b/sh/alias/ls.sh similarity index 100% rename from sh/cmd/ls.sh rename to sh/alias/ls.sh From 41ca1b08f8113fdc10a6d017ebc6a4e1a9171483 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:24:54 +0100 Subject: [PATCH 735/969] ls --- sh/alias/ls.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sh/alias/ls.sh b/sh/alias/ls.sh index da0d1bc..f464b3a 100644 --- a/sh/alias/ls.sh +++ b/sh/alias/ls.sh @@ -3,7 +3,8 @@ di=0;94\ " # list current directory’s entries -l() { +l() { sh_a__ls "${@}"; } +sh_a__ls() { ls \ --all \ --color \ @@ -14,15 +15,17 @@ l() { } # list timestamps -lt() { - l \ +lt() { sh_a__ls_time "${@}"; } +sh_a__ls_time() { + sh_a__ls \ --time-style "+%Y%m%d-%H%M%S%-:::z" \ "${@}" } # list timestamps recent last -ltt() { - lt \ +ltr() { sh_a__ls_time_reverse "${@}"; } +sh_a__ls_time_reverse() { + sh_a__ls_time \ --reverse \ -t \ "${@}" From 63efbb7028f7e8eb003890b6eca0819d525b63e6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:25:25 +0100 Subject: [PATCH 736/969] mv --- sh/{cmd => alias}/mkdir.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/mkdir.sh (100%) diff --git a/sh/cmd/mkdir.sh b/sh/alias/mkdir.sh similarity index 100% rename from sh/cmd/mkdir.sh rename to sh/alias/mkdir.sh From 0f4bd2be8540ec9a06049055dfa940474edb82b9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:27:41 +0100 Subject: [PATCH 737/969] mkdir --- sh/alias/mkdir.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sh/alias/mkdir.sh b/sh/alias/mkdir.sh index 961e14b..ae8ac4b 100644 --- a/sh/alias/mkdir.sh +++ b/sh/alias/mkdir.sh @@ -1,11 +1,13 @@ # make a directory -md() { +md() { sh_a__make_directory "${@}"; } +sh_a__make_directory() { mkdir \ "${@}" } # make a directory after making its parents -mdp() { +mdp() { sh_a__make_directory_parents "${@}"; } +sh_a__make_directory_parents() { mkdir \ --parents \ "${@}" From 81b1f9529c4c5be58bbc5becc0974ba14f0073d3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:28:41 +0100 Subject: [PATCH 738/969] mv --- sh/{cmd => alias}/pwgen.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/pwgen.sh (100%) diff --git a/sh/cmd/pwgen.sh b/sh/alias/pwgen.sh similarity index 100% rename from sh/cmd/pwgen.sh rename to sh/alias/pwgen.sh From 9974f0a99d9ed69acee1c42e1d922079d6a1f599 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:30:11 +0100 Subject: [PATCH 739/969] pwgen --- sh/alias/pwgen.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sh/alias/pwgen.sh b/sh/alias/pwgen.sh index 4052d61..4c0b1f2 100644 --- a/sh/alias/pwgen.sh +++ b/sh/alias/pwgen.sh @@ -1,5 +1,6 @@ # generate passwords -pwg() { +pwg() { sh_a__pass_word_gen "${@}"; } +sh_a__pass_word_gen() { pwgen \ -1 \ --num-passwords 1048576 \ @@ -8,8 +9,9 @@ pwg() { } # generate passwords with symbols -pwgs() { - pwg \ +pwgs() { sh_a__pass_word_gen_symbols "${@}"; } +sh_a__pass_word_gen_symbols() { + sh_a__pass_word_gen \ --symbols \ "${@}" } From e55392137c5564531911a0693edf6ab63243f9c0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:35:44 +0100 Subject: [PATCH 740/969] mv --- sh/{cmd => alias}/kill.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/kill.sh (100%) diff --git a/sh/cmd/kill.sh b/sh/alias/kill.sh similarity index 100% rename from sh/cmd/kill.sh rename to sh/alias/kill.sh From 0b4ac490cd994bdfc0977d5cdf96b7a8f39f377e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:37:07 +0100 Subject: [PATCH 741/969] kill --- sh/alias/kill.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sh/alias/kill.sh b/sh/alias/kill.sh index a6e105c..ce47bd9 100644 --- a/sh/alias/kill.sh +++ b/sh/alias/kill.sh @@ -1,11 +1,13 @@ # kill a process by id -k() { +k() { sh_a__kill "${@}"; } +sh_a__kill() { kill \ "${@}" } # force kill a process by id -kf() { +kf() { sh_a__kill_force "${@}"; } +sh_a__kill_force() { kill \ -9 \ "${@}" From 5e21bdec58ec2d8fe3e72436c9cf83570e2156f6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:37:18 +0100 Subject: [PATCH 742/969] mv --- sh/{cmd => alias}/killall.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/killall.sh (100%) diff --git a/sh/cmd/killall.sh b/sh/alias/killall.sh similarity index 100% rename from sh/cmd/killall.sh rename to sh/alias/killall.sh From 95ea69c92ff9627f646d3aee808d84a2e90f91b3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:38:17 +0100 Subject: [PATCH 743/969] killall --- sh/alias/killall.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sh/alias/killall.sh b/sh/alias/killall.sh index a4d083e..0f63b0e 100644 --- a/sh/alias/killall.sh +++ b/sh/alias/killall.sh @@ -1,11 +1,13 @@ # kill all instances of a process by name -ka() { +ka() { sh_a__kill_all "${@}"; } +sh_a__kill_all() { killall \ "${@}" } # force kill all instances of a process by name -kaf() { +kaf() { sh_a__kill_all_force "${@}"; } +sh_a__kill_all_force() { killall \ -9 \ "${@}" From b13056034b9da6572e9a6c6e4c9bd22a483c1aeb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:41:12 +0100 Subject: [PATCH 744/969] mv --- sh/{cmd => alias}/tar.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/tar.sh (100%) diff --git a/sh/cmd/tar.sh b/sh/alias/tar.sh similarity index 100% rename from sh/cmd/tar.sh rename to sh/alias/tar.sh From 6588da4ad645cd00683a111aecb2992d22a8455a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:43:42 +0100 Subject: [PATCH 745/969] tar --- sh/alias/tar.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sh/alias/tar.sh b/sh/alias/tar.sh index bfbf7be..6da0d03 100644 --- a/sh/alias/tar.sh +++ b/sh/alias/tar.sh @@ -1,26 +1,30 @@ -tc() { - tv \ +tc() { sh_a__tar_create "${@}"; } +sh_a__tar_create() { + sh_a__tar_verbose \ --create \ --auto-compress \ --file \ "${@}" } -tl() { - tv \ +tl() { sh_a__tar_list "${@}"; } +sh_a__tar_list() { + sh_a__tar_verbose \ --list \ --file \ "${@}" } -tv() { +tv() { sh_a__tar_verbose "${@}"; } +sh_a__tar_verbose() { tar \ --verbose \ "${@}" } -tx() { - tv \ +tx() { sh_a__tar_xtract "${@}"; } +sh_a__tar_xtract() { + sh_a__tar_verbose \ --extract \ --file \ "${@}" From 40e3b95aaf54241979741d2a40b7aec3fdf4adbc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:49:37 +0100 Subject: [PATCH 746/969] m --- sh/{cmd => alias}/rsync.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/rsync.sh (100%) diff --git a/sh/cmd/rsync.sh b/sh/alias/rsync.sh similarity index 100% rename from sh/cmd/rsync.sh rename to sh/alias/rsync.sh From dd4fd93e1213962ab7a4d4e03cc2378e1385e1ec Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:53:12 +0100 Subject: [PATCH 747/969] rsync --- sh/alias/rsync.sh | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/sh/alias/rsync.sh b/sh/alias/rsync.sh index 7a94aac..02ea400 100644 --- a/sh/alias/rsync.sh +++ b/sh/alias/rsync.sh @@ -1,11 +1,6 @@ # synchronize -rs() { - rsb \ - "${@}" -} - -# base arguments -rsb() { +rs() { sh_a__r_sync "${@}"; } +sh_a__r_sync() { rsync \ --archive \ --no-inc-recursive \ @@ -16,16 +11,17 @@ rsb() { } # synchronize and delete after -rsda() { - rsb \ +rsda() { sh_a__r_sync_delete_after "${@}"; } +sh_a__r_sync_delete_after() { + sh_a__r_sync \ --delete-after \ "${@}" } # synchronize and delete before -rsdb() { r_sync_delete_before "${@}"; } -r_sync_delete_before() { - rsb \ +rsdb() { sh_a__r_sync_delete_before "${@}"; } +sh_a__r_sync_delete_before() { + sh_a__r_sync \ --delete-before \ "${@}" } From b6ffd7256931e7b264be60feab56f0d48f656877 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:55:46 +0100 Subject: [PATCH 748/969] mv --- sh/{cmd => alias}/batcat.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/batcat.sh (100%) diff --git a/sh/cmd/batcat.sh b/sh/alias/batcat.sh similarity index 100% rename from sh/cmd/batcat.sh rename to sh/alias/batcat.sh From 985d4f45a62c6bb7be9c810f2d43c74168d1f2e0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 16:57:19 +0100 Subject: [PATCH 749/969] batcat --- sh/alias/batcat.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/alias/batcat.sh b/sh/alias/batcat.sh index 352cff1..e31ab6d 100644 --- a/sh/alias/batcat.sh +++ b/sh/alias/batcat.sh @@ -1,4 +1,5 @@ -bat() { +bat() { sh_a__b_a_t "${@}"; } +sh_a__b_a_t() { batcat \ "${@}" } From 9e80019dddfa7cebfb77f73b2df5ed5cbfbeddad Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 18:20:49 +0100 Subject: [PATCH 750/969] mv --- sh/{cmd => alias}/apt.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/apt.sh (100%) diff --git a/sh/cmd/apt.sh b/sh/alias/apt.sh similarity index 100% rename from sh/cmd/apt.sh rename to sh/alias/apt.sh From e933c159c3cea04a09dac16028c8a38639764f3e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 18:27:59 +0100 Subject: [PATCH 751/969] apt --- sh/alias/apt.sh | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/sh/alias/apt.sh b/sh/alias/apt.sh index aba5844..4747c81 100644 --- a/sh/alias/apt.sh +++ b/sh/alias/apt.sh @@ -1,82 +1,94 @@ # show package information -acl() { +acl() { sh_a__apt_cache_list "${@}"; } +sh_a__apt_cache_list() { apt-cache \ show \ "${@}" } # package versions policy -acp() { +acp() { sh_a__apt_cache_policy "${@}"; } +sh_a__apt_cache_policy() { apt-cache \ policy \ "${@}" } # search package -acs() { +acs() { sh_a__apt_cache_search "${@}"; } +sh_a__apt_cache_search() { apt-cache \ search \ "${@}" } # -agap() { +agap() { sh_a__apt_get_auto_purge "${@}"; } +sh_a__apt_get_auto_purge() { apt-get \ autopurge \ "${@}" } # -agar() { +agar() { sh_a__apt_get_auto_remove "${@}"; } +sh_a__apt_get_auto_remove() { apt-get \ autoremove \ "${@}" } # clean packages cache -agc() { +agc() { sh_a__apt_get_clean "${@}"; } +sh_a__apt_get_clean() { apt-get \ clean \ "${@}" } # upgrade allowing package installation or removal -agfu() { +agfu() { sh_a__apt_get_full_upgrade "${@}"; } +sh_a__apt_get_full_upgrade() { apt-get \ full-upgrade \ "${@}" } # install packages -agi() { +agi() { sh_a__apt_get_install "${@}"; } +sh_a__apt_get_install() { apt-get \ install \ "${@}" } # -agp() { +agp() { sh_a__apt_get_purge "${@}"; } +sh_a__apt_get_purge() { apt-get \ purge \ "${@}" } # -agr() { +agr() { sh_a__apt_get_remove "${@}"; } +sh_a__apt_get_remove() { apt-get \ remove \ "${@}" } # update packages catalog -agud() { +agud() { sh_a__apt_get_up_date "${@}"; } +sh_a__apt_get_up_date() { apt-get \ update \ "${@}" } # upgrade forbidding package installation or removal -agug() { +agug() { sh_a__apt_get_up_grade "${@}"; } +sh_a__apt_get_up_grade() { apt-get \ upgrade \ "${@}" From 04a86e40ed1ef26a45d849cbbb026b1419001017 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 18:29:12 +0100 Subject: [PATCH 752/969] mv --- sh/{cmd => alias}/grep.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/grep.sh (100%) diff --git a/sh/cmd/grep.sh b/sh/alias/grep.sh similarity index 100% rename from sh/cmd/grep.sh rename to sh/alias/grep.sh From 441c42896b09b0b8d7c8a75b740e5749cf0bb485 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 18:29:57 +0100 Subject: [PATCH 753/969] grep --- sh/alias/grep.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/alias/grep.sh b/sh/alias/grep.sh index ab8e396..e4fe62f 100644 --- a/sh/alias/grep.sh +++ b/sh/alias/grep.sh @@ -1,5 +1,6 @@ # grep from current directory with regex -g() { +g() { sh_a__grep "${@}"; } +sh_a__grep() { grep \ --directories "recurse" \ --line-number \ From 31e52f986181ae855e0e341f4dd954895cd94e3c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 18:41:28 +0100 Subject: [PATCH 754/969] mv --- sh/{cmd/ps.sh => alias/pgrep.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd/ps.sh => alias/pgrep.sh} (100%) diff --git a/sh/cmd/ps.sh b/sh/alias/pgrep.sh similarity index 100% rename from sh/cmd/ps.sh rename to sh/alias/pgrep.sh From 39dedbd44030a6e0e894dba635db692a4b05b344 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 18:43:16 +0100 Subject: [PATCH 755/969] pgrep --- sh/alias/pgrep.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sh/alias/pgrep.sh b/sh/alias/pgrep.sh index bbb93de..a17c888 100644 --- a/sh/alias/pgrep.sh +++ b/sh/alias/pgrep.sh @@ -1,7 +1,7 @@ # look for a string in processes names -pg() { - ps \ - -A | - grep \ - "${@}" +pg() { sh_a__proc_grep "${@}"; } +sh_a__proc_grep() { + pgrep \ + --list-full \ + "${@}" } From ec16bff4b05f353f3416db06c179c45b2a01478b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 18:46:23 +0100 Subject: [PATCH 756/969] mv --- sh/{cmd => alias}/lsblk.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => alias}/lsblk.sh (100%) diff --git a/sh/cmd/lsblk.sh b/sh/alias/lsblk.sh similarity index 100% rename from sh/cmd/lsblk.sh rename to sh/alias/lsblk.sh From 96db58083cc741d5907d4c00c95c811e45b5d20c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 18:50:54 +0100 Subject: [PATCH 757/969] lsblk --- sh/alias/lsblk.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sh/alias/lsblk.sh b/sh/alias/lsblk.sh index 398bc42..86e91be 100644 --- a/sh/alias/lsblk.sh +++ b/sh/alias/lsblk.sh @@ -1,27 +1,31 @@ # list block devices -lb() { - lbo \ +lb() { sh_a__list_block "${@}"; } +sh_a__list_block() { + sh_a__list_block_output \ "SIZE" \ "TYPE" \ "FSTYPE" \ "LABEL" \ - "MOUNTPOINTS" + "MOUNTPOINTS" \ + "${@}" } # base arguments -lbb() { +lbne() { sh_a__list_block_no_empty "${@}"; } +sh_a__list_block_no_empty() { lsblk \ --noempty \ "${@}" } # output arguments -lbo() { +lbo() { sh_a__list_block_output "${@}"; } +sh_a__list_block_output() { local argument local arguments="NAME" for argument in "${@}"; do arguments="${arguments},${argument}" done - lbb \ + sh_a__list_block_no_empty \ --output "${arguments}" } From d28e44097c07be29add49a8e632ba899f14fc9a6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 20:33:14 +0100 Subject: [PATCH 758/969] main/log --- sh/main.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index f04cf71..81c412e 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -44,8 +44,6 @@ main_source_directory() { fi done IFS="${ifs}" - sh_log_info - sh_log_info "${CMD}" else echo "Not a directory: ${path}" return 1 From dce638fcbd0ae6554dc07c44747b5f6e2eb0ffa3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 22:20:47 +0100 Subject: [PATCH 759/969] =?UTF-8?q?=E2=88=92=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cs | 3 +-- cs.old | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cs b/cs index 85a53f9..9126efa 100755 --- a/cs +++ b/cs @@ -53,8 +53,7 @@ case "${action}" in ;; "${ACTION_CLOSE}") echo "${container_map_file} ← ${container_mount_directory}" - umount "${container_map_file}" - if [ ${?} -eq 0 ]; then + if umount "${container_map_file}"; then rmdir --ignore-fail-on-non-empty "${container_mount_directory}" echo "${container_file} ← ${container_map_file}" cryptsetup luksClose "${container_name}" diff --git a/cs.old b/cs.old index 85a53f9..9126efa 100755 --- a/cs.old +++ b/cs.old @@ -53,8 +53,7 @@ case "${action}" in ;; "${ACTION_CLOSE}") echo "${container_map_file} ← ${container_mount_directory}" - umount "${container_map_file}" - if [ ${?} -eq 0 ]; then + if umount "${container_map_file}"; then rmdir --ignore-fail-on-non-empty "${container_mount_directory}" echo "${container_file} ← ${container_map_file}" cryptsetup luksClose "${container_name}" From 948e22d64f992c7864d3ef420e447418d90ef18b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 22:22:12 +0100 Subject: [PATCH 760/969] read/-r --- cs | 2 +- cs.old | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cs b/cs index 9126efa..bd9402c 100755 --- a/cs +++ b/cs @@ -25,7 +25,7 @@ case "${action}" in if [ "${1}" ]; then if [ "${action}" == "${ACTION_OPEN}" ]; then echo -n 'PassPhrase: ' - read -s pass_phrase + read -r -s pass_phrase echo fi for container in "${@}"; do diff --git a/cs.old b/cs.old index 9126efa..bd9402c 100755 --- a/cs.old +++ b/cs.old @@ -25,7 +25,7 @@ case "${action}" in if [ "${1}" ]; then if [ "${action}" == "${ACTION_OPEN}" ]; then echo -n 'PassPhrase: ' - read -s pass_phrase + read -r -s pass_phrase echo fi for container in "${@}"; do From 1061c309c3acc02fad5e065da8bf62d19b910b5f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 22:33:59 +0100 Subject: [PATCH 761/969] readme --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 011ed62..f61fc7d 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ -# Public +# SH -## ToDo +## Tasks * [ ] convert alias to () * [ ] git switch signing commits & tags From bbcbcf28a2e909b4219284d3a82935e81ee095fe Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 18 Nov 2024 23:24:14 +0100 Subject: [PATCH 762/969] hetzner --- readme.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/readme.md b/readme.md index f61fc7d..cbcd2bc 100644 --- a/readme.md +++ b/readme.md @@ -2,13 +2,11 @@ ## Tasks -* [ ] convert alias to () * [ ] git switch signing commits & tags * [ ] shellcheck & shfmt * [ ] python tools * [ ] log -* [ ] ovh - * [ ] clean apt cache after each install/upgrade step +* [ ] hetzner * [ ] apt * [ ] apt-file search | grep * [ ] ffmpeg From 46704e9e375805dad467d3b90ad86a246e6327e4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 09:17:14 +0100 Subject: [PATCH 763/969] sa --- sh/alias/apt.sh | 48 ++++----- sh/alias/batcat.sh | 4 +- sh/alias/btrfs.sh | 36 +++---- sh/alias/byobu.sh | 16 +-- sh/alias/chmod.sh | 8 +- sh/alias/chown.sh | 8 +- sh/alias/clear.sh | 4 +- sh/alias/cp.sh | 4 +- sh/alias/emacs.sh | 4 +- sh/alias/evince.sh | 4 +- sh/alias/git.sh | 242 +++++++++++++++++++++---------------------- sh/alias/grep.sh | 4 +- sh/alias/kill.sh | 8 +- sh/alias/killall.sh | 8 +- sh/alias/ls.sh | 16 +-- sh/alias/lsblk.sh | 16 +-- sh/alias/mkdir.sh | 8 +- sh/alias/mount.sh | 4 +- sh/alias/mv.sh | 4 +- sh/alias/nano.sh | 4 +- sh/alias/newsboat.sh | 4 +- sh/alias/pass.sh | 8 +- sh/alias/pgrep.sh | 4 +- sh/alias/pwgen.sh | 10 +- sh/alias/rm.sh | 4 +- sh/alias/rsync.sh | 16 +-- sh/alias/tar.sh | 22 ++-- sh/alias/tmux.sh | 4 +- sh/alias/tree.sh | 8 +- 29 files changed, 265 insertions(+), 265 deletions(-) diff --git a/sh/alias/apt.sh b/sh/alias/apt.sh index 4747c81..1af6d78 100644 --- a/sh/alias/apt.sh +++ b/sh/alias/apt.sh @@ -1,94 +1,94 @@ # show package information -acl() { sh_a__apt_cache_list "${@}"; } -sh_a__apt_cache_list() { +acl() { sa__apt_cache_list "${@}"; } +sa__apt_cache_list() { apt-cache \ show \ "${@}" } # package versions policy -acp() { sh_a__apt_cache_policy "${@}"; } -sh_a__apt_cache_policy() { +acp() { sa__apt_cache_policy "${@}"; } +sa__apt_cache_policy() { apt-cache \ policy \ "${@}" } # search package -acs() { sh_a__apt_cache_search "${@}"; } -sh_a__apt_cache_search() { +acs() { sa__apt_cache_search "${@}"; } +sa__apt_cache_search() { apt-cache \ search \ "${@}" } # -agap() { sh_a__apt_get_auto_purge "${@}"; } -sh_a__apt_get_auto_purge() { +agap() { sa__apt_get_auto_purge "${@}"; } +sa__apt_get_auto_purge() { apt-get \ autopurge \ "${@}" } # -agar() { sh_a__apt_get_auto_remove "${@}"; } -sh_a__apt_get_auto_remove() { +agar() { sa__apt_get_auto_remove "${@}"; } +sa__apt_get_auto_remove() { apt-get \ autoremove \ "${@}" } # clean packages cache -agc() { sh_a__apt_get_clean "${@}"; } -sh_a__apt_get_clean() { +agc() { sa__apt_get_clean "${@}"; } +sa__apt_get_clean() { apt-get \ clean \ "${@}" } # upgrade allowing package installation or removal -agfu() { sh_a__apt_get_full_upgrade "${@}"; } -sh_a__apt_get_full_upgrade() { +agfu() { sa__apt_get_full_upgrade "${@}"; } +sa__apt_get_full_upgrade() { apt-get \ full-upgrade \ "${@}" } # install packages -agi() { sh_a__apt_get_install "${@}"; } -sh_a__apt_get_install() { +agi() { sa__apt_get_install "${@}"; } +sa__apt_get_install() { apt-get \ install \ "${@}" } # -agp() { sh_a__apt_get_purge "${@}"; } -sh_a__apt_get_purge() { +agp() { sa__apt_get_purge "${@}"; } +sa__apt_get_purge() { apt-get \ purge \ "${@}" } # -agr() { sh_a__apt_get_remove "${@}"; } -sh_a__apt_get_remove() { +agr() { sa__apt_get_remove "${@}"; } +sa__apt_get_remove() { apt-get \ remove \ "${@}" } # update packages catalog -agud() { sh_a__apt_get_up_date "${@}"; } -sh_a__apt_get_up_date() { +agud() { sa__apt_get_up_date "${@}"; } +sa__apt_get_up_date() { apt-get \ update \ "${@}" } # upgrade forbidding package installation or removal -agug() { sh_a__apt_get_up_grade "${@}"; } -sh_a__apt_get_up_grade() { +agug() { sa__apt_get_up_grade "${@}"; } +sa__apt_get_up_grade() { apt-get \ upgrade \ "${@}" diff --git a/sh/alias/batcat.sh b/sh/alias/batcat.sh index e31ab6d..4d5968b 100644 --- a/sh/alias/batcat.sh +++ b/sh/alias/batcat.sh @@ -1,5 +1,5 @@ -bat() { sh_a__b_a_t "${@}"; } -sh_a__b_a_t() { +bat() { sa__b_a_t "${@}"; } +sa__b_a_t() { batcat \ "${@}" } diff --git a/sh/alias/btrfs.sh b/sh/alias/btrfs.sh index 3ec74fb..eb48c14 100644 --- a/sh/alias/btrfs.sh +++ b/sh/alias/btrfs.sh @@ -1,13 +1,13 @@ -bfdf() { sh_a__btrfs_filesystem_d_f "${@}"; } -sh_a__btrfs_filesystem_d_f() { +bfdf() { sa__btrfs_filesystem_d_f "${@}"; } +sa__btrfs_filesystem_d_f() { btrfs \ filesystem \ df \ "${@}" } -bfdu() { sh_a__btrfs_filesystem_d_u "${@}"; } -sh_a__btrfs_filesystem_d_u() { +bfdu() { sa__btrfs_filesystem_d_u "${@}"; } +sa__btrfs_filesystem_d_u() { btrfs \ filesystem \ du \ @@ -15,40 +15,40 @@ sh_a__btrfs_filesystem_d_u() { "${@}" } -bfu() { sh_a__btrfs_filesystem_usage "${@}"; } -sh_a__btrfs_filesystem_usage() { +bfu() { sa__btrfs_filesystem_usage "${@}"; } +sa__btrfs_filesystem_usage() { btrfs \ filesystem \ usage \ "${@}" } -bpg() { sh_a__btrfs_property_get "${@}"; } -sh_a__btrfs_property_get() { +bpg() { sa__btrfs_property_get "${@}"; } +sa__btrfs_property_get() { btrfs \ property \ get \ "${@}" } -bsc() { sh_a__btrfs_subvolume_create "${@}"; } -sh_a__btrfs_subvolume_create() { +bsc() { sa__btrfs_subvolume_create "${@}"; } +sa__btrfs_subvolume_create() { btrfs \ subvolume \ create \ "${@}" } -bsd() { sh_a__btrfs_subvolume_delete "${@}"; } -sh_a__btrfs_subvolume_delete() { +bsd() { sa__btrfs_subvolume_delete "${@}"; } +sa__btrfs_subvolume_delete() { btrfs \ subvolume \ delete \ "${@}" } -bsl() { sh_a__btrfs_subvolume_list "${@}"; } -sh_a__btrfs_subvolume_list() { +bsl() { sa__btrfs_subvolume_list "${@}"; } +sa__btrfs_subvolume_list() { if [ -n "${1}" ]; then btrfs subvolume list "${1}" | cut --delimiter " " --fields 9 | @@ -56,16 +56,16 @@ sh_a__btrfs_subvolume_list() { fi } -bss() { sh_a__btrfs_subvolume_snapshot "${@}"; } -sh_a__btrfs_subvolume_snapshot() { +bss() { sa__btrfs_subvolume_snapshot "${@}"; } +sa__btrfs_subvolume_snapshot() { btrfs \ subvolume \ snapshot \ "${@}" } -bssr() { sh_a__btrfs_subvolume_snapshot_r "${@}"; } -sh_a__btrfs_subvolume_snapshot_r() { +bssr() { sa__btrfs_subvolume_snapshot_r "${@}"; } +sa__btrfs_subvolume_snapshot_r() { btrfs \ subvolume \ snapshot -r \ diff --git a/sh/alias/byobu.sh b/sh/alias/byobu.sh index 79155b5..6b66a77 100644 --- a/sh/alias/byobu.sh +++ b/sh/alias/byobu.sh @@ -1,25 +1,25 @@ -bb() { sh_a__byo_bu "${@}"; } -sh_a__byo_bu() { +bb() { sa__byo_bu "${@}"; } +sa__byo_bu() { byobu \ "${@}" } -bba() { sh_a__byo_bu_attach "${@}"; } -sh_a__byo_bu_attach() { +bba() { sa__byo_bu_attach "${@}"; } +sa__byo_bu_attach() { byobu \ attach-session \ "${@}" } -bbl() { sh_a__byo_bu_ls "${@}"; } -sh_a__byo_bu_ls() { +bbl() { sa__byo_bu_ls "${@}"; } +sa__byo_bu_ls() { byobu \ ls \ "${@}" } -bbnd() { sh_a__byo_bu_new_detach "${@}"; } -sh_a__byo_bu_new_detach() { +bbnd() { sa__byo_bu_new_detach "${@}"; } +sa__byo_bu_new_detach() { byobu \ new-session \ -d \ diff --git a/sh/alias/chmod.sh b/sh/alias/chmod.sh index 1c55b40..6a6e0e8 100644 --- a/sh/alias/chmod.sh +++ b/sh/alias/chmod.sh @@ -1,14 +1,14 @@ # change mode to directory -cmd() { sh_a__change_mode_directory "${@}"; } -sh_a__change_mode_directory() { +cmd() { sa__change_mode_directory "${@}"; } +sa__change_mode_directory() { chmod \ "755" \ "${@}" } # change mode to file -cmf() { sh_a__change_mode_file "${@}"; } -sh_a__change_mode_file() { +cmf() { sa__change_mode_file "${@}"; } +sa__change_mode_file() { chmod \ "644" \ "${@}" diff --git a/sh/alias/chown.sh b/sh/alias/chown.sh index 6a7a156..8c992d3 100644 --- a/sh/alias/chown.sh +++ b/sh/alias/chown.sh @@ -1,14 +1,14 @@ # change owner to root -cor() { sh_a__change_owner_root "${@}"; } -sh_a__change_owner_root() { +cor() { sa__change_owner_root "${@}"; } +sa__change_owner_root() { chown \ "0:0" \ "${@}" } # change owner to user -cou() { sh_a__change_owner_user "${@}"; } -sh_a__change_owner_user() { +cou() { sa__change_owner_user "${@}"; } +sa__change_owner_user() { chown \ "1000:1000" \ "${@}" diff --git a/sh/alias/clear.sh b/sh/alias/clear.sh index 9731fe0..542a260 100644 --- a/sh/alias/clear.sh +++ b/sh/alias/clear.sh @@ -1,6 +1,6 @@ # clear terminal -c() { sh_a__clear "${@}"; } -sh_a__clear() { +c() { sa__clear "${@}"; } +sa__clear() { clear \ "${@}" } diff --git a/sh/alias/cp.sh b/sh/alias/cp.sh index dd1a271..d8897c0 100644 --- a/sh/alias/cp.sh +++ b/sh/alias/cp.sh @@ -1,6 +1,6 @@ # copy interactively -cpi() { sh_a__co_py_interactive "${@}"; } -sh_a__co_py_interactive() { +cpi() { sa__co_py_interactive "${@}"; } +sa__co_py_interactive() { cp \ --interactive \ "${@}" diff --git a/sh/alias/emacs.sh b/sh/alias/emacs.sh index 84fc56f..cc7e002 100644 --- a/sh/alias/emacs.sh +++ b/sh/alias/emacs.sh @@ -1,5 +1,5 @@ -em() { sh_a__e_macs "${@}"; } -sh_a__e_macs() { +em() { sa__e_macs "${@}"; } +sa__e_macs() { emacs \ "${@}" } diff --git a/sh/alias/evince.sh b/sh/alias/evince.sh index 3c609ef..5d68ace 100644 --- a/sh/alias/evince.sh +++ b/sh/alias/evince.sh @@ -1,5 +1,5 @@ -ev() { sh_a__e_vince "${@}"; } -sh_a__e_vince() { +ev() { sa__e_vince "${@}"; } +sa__e_vince() { evince \ "${@}" } diff --git a/sh/alias/git.sh b/sh/alias/git.sh index 864620b..5ce2f93 100644 --- a/sh/alias/git.sh +++ b/sh/alias/git.sh @@ -8,16 +8,16 @@ C %C(blue)%cn %ce %B" # add to index -ga() { sh_a__git_add "${@}"; } -sh_a__git_add() { +ga() { sa__git_add "${@}"; } +sa__git_add() { git \ add \ "${@}" } # add all to index -gaa() { sh_a__git_add_all "${@}"; } -sh_a__git_add_all() { +gaa() { sa__git_add_all "${@}"; } +sa__git_add_all() { git \ add \ --all \ @@ -25,8 +25,8 @@ sh_a__git_add_all() { } # add parts of all to index -gaap() { sh_a__git_add_all_patch "${@}"; } -sh_a__git_add_all_patch() { +gaap() { sa__git_add_all_patch "${@}"; } +sa__git_add_all_patch() { git \ add \ --all \ @@ -35,8 +35,8 @@ sh_a__git_add_all_patch() { } # add parts to index -gap() { sh_a__git_add_patch "${@}"; } -sh_a__git_add_patch() { +gap() { sa__git_add_patch "${@}"; } +sa__git_add_patch() { git \ add \ --patch \ @@ -44,16 +44,16 @@ sh_a__git_add_patch() { } # create a branch -gb() { sh_a__git_branch "${@}"; } -sh_a__git_branch() { +gb() { sa__git_branch "${@}"; } +sa__git_branch() { git \ branch \ "${@}" } # delete a branch -gbd() { sh_a__git_branch_delete "${@}"; } -sh_a__git_branch_delete() { +gbd() { sa__git_branch_delete "${@}"; } +sa__git_branch_delete() { git \ branch \ --delete \ @@ -61,8 +61,8 @@ sh_a__git_branch_delete() { } # force a branch deletion -gbdf() { sh_a__git_branch_delete_force "${@}"; } -sh_a__git_branch_delete_force() { +gbdf() { sa__git_branch_delete_force "${@}"; } +sa__git_branch_delete_force() { git \ branch \ --delete \ @@ -71,8 +71,8 @@ sh_a__git_branch_delete_force() { } # list branches -gbl() { sh_a__git_branch_list "${@}"; } -sh_a__git_branch_list() { +gbl() { sa__git_branch_list "${@}"; } +sa__git_branch_list() { git \ branch \ --all \ @@ -83,8 +83,8 @@ sh_a__git_branch_list() { } # set the link to a remote branch from a local branch -gbsu() { sh_a__git_branch_set_upstream "${@}"; } -sh_a__git_branch_set_upstream() { +gbsu() { sa__git_branch_set_upstream "${@}"; } +sa__git_branch_set_upstream() { git \ branch \ --set-upstream-to \ @@ -92,16 +92,16 @@ sh_a__git_branch_set_upstream() { } # switch to a branch or checkout file(s) from a commit -gc() { sh_a__git_checkout "${@}"; } -sh_a__git_checkout() { +gc() { sa__git_checkout "${@}"; } +sa__git_checkout() { git \ checkout \ "${@}" } # checkout an orphan branch -gco() { sh_a__git_checkout_orphan "${@}"; } -sh_a__git_checkout_orphan() { +gco() { sa__git_checkout_orphan "${@}"; } +sa__git_checkout_orphan() { git \ checkout \ --orphan \ @@ -109,16 +109,16 @@ sh_a__git_checkout_orphan() { } # pick a commit -gcp() { sh_a__git_cherry_pick "${@}"; } -sh_a__git_cherry_pick() { +gcp() { sa__git_cherry_pick "${@}"; } +sa__git_cherry_pick() { git \ cherry-pick \ "${@}" } # abort the commit pick -gcpa() { sh_a__git_cherry_pick_abort "${@}"; } -sh_a__git_cherry_pick_abort() { +gcpa() { sa__git_cherry_pick_abort "${@}"; } +sa__git_cherry_pick_abort() { git \ cherry-pick \ --abort \ @@ -126,8 +126,8 @@ sh_a__git_cherry_pick_abort() { } # continue the commit pick -gcpc() { sh_a__git_cherry_pick_continue "${@}"; } -sh_a__git_cherry_pick_continue() { +gcpc() { sa__git_cherry_pick_continue "${@}"; } +sa__git_cherry_pick_continue() { git \ cherry-pick \ --continue \ @@ -135,8 +135,8 @@ sh_a__git_cherry_pick_continue() { } # clean untracked files -gcf() { sh_a__git_clean_force "${@}"; } -sh_a__git_clean_force() { +gcf() { sa__git_clean_force "${@}"; } +sa__git_clean_force() { git \ clean \ -d \ @@ -145,8 +145,8 @@ sh_a__git_clean_force() { } # redo the last commit with a different message -gcam() { sh_a__git_commit_amend_message "${@}"; } -sh_a__git_commit_amend_message() { +gcam() { sa__git_commit_amend_message "${@}"; } +sa__git_commit_amend_message() { git \ commit \ --amend \ @@ -155,8 +155,8 @@ sh_a__git_commit_amend_message() { } # make a root commit -gcem() { sh_a__git_commit_empty_message "${@}"; } -sh_a__git_commit_empty_message() { +gcem() { sa__git_commit_empty_message "${@}"; } +sa__git_commit_empty_message() { git \ commit \ --allow-empty \ @@ -166,8 +166,8 @@ sh_a__git_commit_empty_message() { } # commit the index -gcm() { sh_a__git_commit_message "${@}"; } -sh_a__git_commit_message() { +gcm() { sa__git_commit_message "${@}"; } +sa__git_commit_message() { git \ commit \ --message \ @@ -175,8 +175,8 @@ sh_a__git_commit_message() { } # configure the user email -gcue() { sh_a__git_config_user_email "${@}"; } -sh_a__git_config_user_email() { +gcue() { sa__git_config_user_email "${@}"; } +sa__git_config_user_email() { git \ config \ "user.email" \ @@ -184,8 +184,8 @@ sh_a__git_config_user_email() { } # configure the user name -gcun() { sh_a__git_config_user_name "${@}"; } -sh_a__git_config_user_name() { +gcun() { sa__git_config_user_name "${@}"; } +sa__git_config_user_name() { git \ config \ "user.name" \ @@ -193,16 +193,16 @@ sh_a__git_config_user_name() { } # differences from last or between commits -gd() { sh_a__git_diff "${@}"; } -sh_a__git_diff() { +gd() { sa__git_diff "${@}"; } +sa__git_diff() { git \ diff \ "${@}" } # display what is indexed in cache -gdc() { sh_a__git_diff_cached "${@}"; } -sh_a__git_diff_cached() { +gdc() { sa__git_diff_cached "${@}"; } +sa__git_diff_cached() { git \ diff \ --cached \ @@ -210,8 +210,8 @@ sh_a__git_diff_cached() { } # indexed character-level differences -gdcw() { sh_a__git_diff_cached_word "${@}"; } -sh_a__git_diff_cached_word() { +gdcw() { sa__git_diff_cached_word "${@}"; } +sa__git_diff_cached_word() { git \ diff \ --cached \ @@ -220,8 +220,8 @@ sh_a__git_diff_cached_word() { } # differences via external tool -gdt() { sh_a__git_diff_tool "${@}"; } -sh_a__git_diff_tool() { +gdt() { sa__git_diff_tool "${@}"; } +sa__git_diff_tool() { git \ difftool \ --dir-diff \ @@ -229,8 +229,8 @@ sh_a__git_diff_tool() { } # character-level differences -gdw() { sh_a__git_diff_word "${@}"; } -sh_a__git_diff_word() { +gdw() { sa__git_diff_word "${@}"; } +sa__git_diff_word() { git \ diff \ --word-diff-regex "." \ @@ -238,8 +238,8 @@ sh_a__git_diff_word() { } # fetch from the remote repository -gf() { sh_a__git_fetch "${@}"; } -sh_a__git_fetch() { +gf() { sa__git_fetch "${@}"; } +sa__git_fetch() { git \ fetch \ --tags \ @@ -248,16 +248,16 @@ sh_a__git_fetch() { } # fetch from remote repository and prune local orphan branches -gfp() { sh_a__git_fetch_prune "${@}"; } -sh_a__git_fetch_prune() { - sh_a__git_fetch \ +gfp() { sa__git_fetch_prune "${@}"; } +sa__git_fetch_prune() { + sa__git_fetch \ --prune \ "${@}" } # garbage collect all orphan commits -ggc() { sh_a__git_garbage_collect "${@}"; } -sh_a__git_garbage_collect() { +ggc() { sa__git_garbage_collect "${@}"; } +sa__git_garbage_collect() { git \ reflog \ expire \ @@ -270,16 +270,16 @@ sh_a__git_garbage_collect() { } # initialize a new repository -gi() { sh_a__git_init "${@}"; } -sh_a__git_init() { +gi() { sa__git_init "${@}"; } +sa__git_init() { git \ init \ "${@}" } # initialize a new bare repository -gib() { sh_a__git_init_bare "${@}"; } -sh_a__git_init_bare() { +gib() { sa__git_init_bare "${@}"; } +sa__git_init_bare() { git \ init \ --bare \ @@ -287,8 +287,8 @@ sh_a__git_init_bare() { } # log history -gl() { sh_a__git_log "${@}"; } -sh_a__git_log() { +gl() { sa__git_log "${@}"; } +sa__git_log() { git \ log \ --abbrev=8 \ @@ -299,33 +299,33 @@ sh_a__git_log() { } # log all history -gla() { sh_a__git_log_all "${@}"; } -sh_a__git_log_all() { - sh_a__git_log \ +gla() { sa__git_log_all "${@}"; } +sa__git_log_all() { + sa__git_log \ --all \ "${@}" } # log all history with patches -glap() { sh_a__git_log_all_patch "${@}"; } -sh_a__git_log_all_patch() { - sh_a__git_log \ +glap() { sa__git_log_all_patch "${@}"; } +sa__git_log_all_patch() { + sa__git_log \ --all \ --patch \ "${@}" } # log history with patches -glp() { sh_a__git_log_patch "${@}"; } -sh_a__git_log_patch() { - sh_a__git_log \ +glp() { sa__git_log_patch "${@}"; } +sa__git_log_patch() { + sa__git_log \ --patch \ "${@}" } # fast-forward merge to remote branch -gm() { sh_a__git_merge "${@}"; } -sh_a__git_merge() { +gm() { sa__git_merge "${@}"; } +sa__git_merge() { git \ merge \ --ff-only \ @@ -333,8 +333,8 @@ sh_a__git_merge() { } # abort the current merge commit -gma() { sh_a__git_merge_abort "${@}"; } -sh_a__git_merge_abort() { +gma() { sa__git_merge_abort "${@}"; } +sa__git_merge_abort() { git \ merge \ --abort \ @@ -342,8 +342,8 @@ sh_a__git_merge_abort() { } # do a merge commit -gmc() { sh_a__git_merge_commit "${@}"; } -sh_a__git_merge_commit() { +gmc() { sa__git_merge_commit "${@}"; } +sa__git_merge_commit() { git \ merge \ --no-ff \ @@ -352,8 +352,8 @@ sh_a__git_merge_commit() { } # squash a branch and index its modifications -gms() { sh_a__git_merge_squash "${@}"; } -sh_a__git_merge_squash() { +gms() { sa__git_merge_squash "${@}"; } +sa__git_merge_squash() { git \ merge \ --squash \ @@ -361,16 +361,16 @@ sh_a__git_merge_squash() { } # merge via external tool -gmt() { sh_a__git_merge_tool "${@}"; } -sh_a__git_merge_tool() { +gmt() { sa__git_merge_tool "${@}"; } +sa__git_merge_tool() { git \ mergetool \ "${@}" } # push to the remote repository -gp() { sh_a__git_push "${@}"; } -sh_a__git_push() { +gp() { sa__git_push "${@}"; } +sa__git_push() { git \ push \ --tags \ @@ -379,8 +379,8 @@ sh_a__git_push() { } # delete from the remote repository -gpd() { sh_a__git_push_delete "${@}"; } -sh_a__git_push_delete() { +gpd() { sa__git_push_delete "${@}"; } +sa__git_push_delete() { git \ push \ --delete \ @@ -388,24 +388,24 @@ sh_a__git_push_delete() { } # force the push to the remote repository -gpf() { sh_a__git_push_force "${@}"; } -sh_a__git_push_force() { - sh_a__git_push \ +gpf() { sa__git_push_force "${@}"; } +sa__git_push_force() { + sa__git_push \ --force \ "${@}" } # rebase current branch onto another -grb() { sh_a__git_re_base "${@}"; } -sh_a__git_re_base() { +grb() { sa__git_re_base "${@}"; } +sa__git_re_base() { git \ rebase \ "${@}" } # abort current rebase -grba() { sh_a__git_re_base_abort "${@}"; } -sh_a__git_re_base_abort() { +grba() { sa__git_re_base_abort "${@}"; } +sa__git_re_base_abort() { git \ rebase \ --abort \ @@ -413,8 +413,8 @@ sh_a__git_re_base_abort() { } # continue current rebase -grbc() { sh_a__git_re_base_continue "${@}"; } -sh_a__git_re_base_continue() { +grbc() { sa__git_re_base_continue "${@}"; } +sa__git_re_base_continue() { git \ rebase \ --continue \ @@ -422,8 +422,8 @@ sh_a__git_re_base_continue() { } # force rebase without fast-forward -grbf() { sh_a__git_re_base_force "${@}"; } -sh_a__git_re_base_force() { +grbf() { sa__git_re_base_force "${@}"; } +sa__git_re_base_force() { git \ rebase \ --force-rebase \ @@ -431,8 +431,8 @@ sh_a__git_re_base_force() { } # rebase interactively -grbi() { sh_a__git_re_base_interactive "${@}"; } -sh_a__git_re_base_interactive() { +grbi() { sa__git_re_base_interactive "${@}"; } +sa__git_re_base_interactive() { git \ rebase \ --interactive \ @@ -440,8 +440,8 @@ sh_a__git_re_base_interactive() { } # add a new remote repository -grma() { sh_a__git_re_mote_add "${@}"; } -sh_a__git_re_mote_add() { +grma() { sa__git_re_mote_add "${@}"; } +sa__git_re_mote_add() { git \ remote \ add \ @@ -449,8 +449,8 @@ sh_a__git_re_mote_add() { } # list remote repositories -grml() { sh_a__git_re_mote_list "${@}"; } -sh_a__git_re_mote_list() { +grml() { sa__git_re_mote_list "${@}"; } +sa__git_re_mote_list() { git \ remote \ --verbose \ @@ -458,8 +458,8 @@ sh_a__git_re_mote_list() { } # set the location of a remote repository -grmsu() { sh_a__git_re_mote_set_upstream "${@}"; } -sh_a__git_re_mote_set_upstream() { +grmsu() { sa__git_re_mote_set_upstream "${@}"; } +sa__git_re_mote_set_upstream() { git \ remote \ set-url \ @@ -467,8 +467,8 @@ sh_a__git_re_mote_set_upstream() { } # show connection to a remote repository -grms() { sh_a__git_re_mote_show "${@}"; } -sh_a__git_re_mote_show() { +grms() { sa__git_re_mote_show "${@}"; } +sa__git_re_mote_show() { git \ remote \ show \ @@ -476,24 +476,24 @@ sh_a__git_re_mote_show() { } # remove and add removal to index -grm() { sh_a__git_re_move "${@}"; } -sh_a__git_re_move() { +grm() { sa__git_re_move "${@}"; } +sa__git_re_move() { git \ rm \ "${@}" } # remove file(s) from index or move current branch pointer -grs() { sh_a__git_re_set "${@}"; } -sh_a__git_re_set() { +grs() { sa__git_re_set "${@}"; } +sa__git_re_set() { git \ reset \ "${@}" } # wipe modifications or reset current branch to another commit -grsh() { sh_a__git_re_set_hard "${@}"; } -sh_a__git_re_set_hard() { +grsh() { sa__git_re_set_hard "${@}"; } +sa__git_re_set_hard() { git \ reset \ --hard \ @@ -501,16 +501,16 @@ sh_a__git_re_set_hard() { } # show a commit -gsc() { sh_a__git_show_commit "${@}"; } -sh_a__git_show_commit() { +gsc() { sa__git_show_commit "${@}"; } +sa__git_show_commit() { git \ show \ "${@}" } # current state of repository -gs() { sh_a__git_status "${@}"; } -sh_a__git_status() { +gs() { sa__git_status "${@}"; } +sa__git_status() { git \ status \ --untracked-files="all" \ @@ -518,16 +518,16 @@ sh_a__git_status() { } # tag a commit -gt() { sh_a__git_tag "${@}"; } -sh_a__git_tag() { +gt() { sa__git_tag "${@}"; } +sa__git_tag() { git \ tag \ "${@}" } # delete a tag -gtd() { sh_a__git_tag_delete "${@}"; } -sh_a__git_tag_delete() { +gtd() { sa__git_tag_delete "${@}"; } +sa__git_tag_delete() { git \ tag \ --delete \ diff --git a/sh/alias/grep.sh b/sh/alias/grep.sh index e4fe62f..d479936 100644 --- a/sh/alias/grep.sh +++ b/sh/alias/grep.sh @@ -1,6 +1,6 @@ # grep from current directory with regex -g() { sh_a__grep "${@}"; } -sh_a__grep() { +g() { sa__grep "${@}"; } +sa__grep() { grep \ --directories "recurse" \ --line-number \ diff --git a/sh/alias/kill.sh b/sh/alias/kill.sh index ce47bd9..1900a2d 100644 --- a/sh/alias/kill.sh +++ b/sh/alias/kill.sh @@ -1,13 +1,13 @@ # kill a process by id -k() { sh_a__kill "${@}"; } -sh_a__kill() { +k() { sa__kill "${@}"; } +sa__kill() { kill \ "${@}" } # force kill a process by id -kf() { sh_a__kill_force "${@}"; } -sh_a__kill_force() { +kf() { sa__kill_force "${@}"; } +sa__kill_force() { kill \ -9 \ "${@}" diff --git a/sh/alias/killall.sh b/sh/alias/killall.sh index 0f63b0e..b12e515 100644 --- a/sh/alias/killall.sh +++ b/sh/alias/killall.sh @@ -1,13 +1,13 @@ # kill all instances of a process by name -ka() { sh_a__kill_all "${@}"; } -sh_a__kill_all() { +ka() { sa__kill_all "${@}"; } +sa__kill_all() { killall \ "${@}" } # force kill all instances of a process by name -kaf() { sh_a__kill_all_force "${@}"; } -sh_a__kill_all_force() { +kaf() { sa__kill_all_force "${@}"; } +sa__kill_all_force() { killall \ -9 \ "${@}" diff --git a/sh/alias/ls.sh b/sh/alias/ls.sh index f464b3a..5c90ee5 100644 --- a/sh/alias/ls.sh +++ b/sh/alias/ls.sh @@ -3,8 +3,8 @@ di=0;94\ " # list current directory’s entries -l() { sh_a__ls "${@}"; } -sh_a__ls() { +l() { sa__ls "${@}"; } +sa__ls() { ls \ --all \ --color \ @@ -15,17 +15,17 @@ sh_a__ls() { } # list timestamps -lt() { sh_a__ls_time "${@}"; } -sh_a__ls_time() { - sh_a__ls \ +lt() { sa__ls_time "${@}"; } +sa__ls_time() { + sa__ls \ --time-style "+%Y%m%d-%H%M%S%-:::z" \ "${@}" } # list timestamps recent last -ltr() { sh_a__ls_time_reverse "${@}"; } -sh_a__ls_time_reverse() { - sh_a__ls_time \ +ltr() { sa__ls_time_reverse "${@}"; } +sa__ls_time_reverse() { + sa__ls_time \ --reverse \ -t \ "${@}" diff --git a/sh/alias/lsblk.sh b/sh/alias/lsblk.sh index 86e91be..359f5ae 100644 --- a/sh/alias/lsblk.sh +++ b/sh/alias/lsblk.sh @@ -1,7 +1,7 @@ # list block devices -lb() { sh_a__list_block "${@}"; } -sh_a__list_block() { - sh_a__list_block_output \ +lb() { sa__list_block "${@}"; } +sa__list_block() { + sa__list_block_output \ "SIZE" \ "TYPE" \ "FSTYPE" \ @@ -11,21 +11,21 @@ sh_a__list_block() { } # base arguments -lbne() { sh_a__list_block_no_empty "${@}"; } -sh_a__list_block_no_empty() { +lbne() { sa__list_block_no_empty "${@}"; } +sa__list_block_no_empty() { lsblk \ --noempty \ "${@}" } # output arguments -lbo() { sh_a__list_block_output "${@}"; } -sh_a__list_block_output() { +lbo() { sa__list_block_output "${@}"; } +sa__list_block_output() { local argument local arguments="NAME" for argument in "${@}"; do arguments="${arguments},${argument}" done - sh_a__list_block_no_empty \ + sa__list_block_no_empty \ --output "${arguments}" } diff --git a/sh/alias/mkdir.sh b/sh/alias/mkdir.sh index ae8ac4b..b8821a5 100644 --- a/sh/alias/mkdir.sh +++ b/sh/alias/mkdir.sh @@ -1,13 +1,13 @@ # make a directory -md() { sh_a__make_directory "${@}"; } -sh_a__make_directory() { +md() { sa__make_directory "${@}"; } +sa__make_directory() { mkdir \ "${@}" } # make a directory after making its parents -mdp() { sh_a__make_directory_parents "${@}"; } -sh_a__make_directory_parents() { +mdp() { sa__make_directory_parents "${@}"; } +sa__make_directory_parents() { mkdir \ --parents \ "${@}" diff --git a/sh/alias/mount.sh b/sh/alias/mount.sh index 9aa0aad..b5329a9 100644 --- a/sh/alias/mount.sh +++ b/sh/alias/mount.sh @@ -1,5 +1,5 @@ -m() { sh_a__mount "${@}"; } -sh_a__mount() { +m() { sa__mount "${@}"; } +sa__mount() { mount \ "${@}" } diff --git a/sh/alias/mv.sh b/sh/alias/mv.sh index 2a4ae5e..8f8bffd 100644 --- a/sh/alias/mv.sh +++ b/sh/alias/mv.sh @@ -1,6 +1,6 @@ # move interactively -mvi() { sh_a__mo_ve_interactive "${@}"; } -sh_a__mo_ve_interactive() { +mvi() { sa__mo_ve_interactive "${@}"; } +sa__mo_ve_interactive() { mv \ --interactive \ "${@}" diff --git a/sh/alias/nano.sh b/sh/alias/nano.sh index ca6eb65..b7cad2c 100644 --- a/sh/alias/nano.sh +++ b/sh/alias/nano.sh @@ -1,5 +1,5 @@ -nn() { sh_a__na_no "${@}"; } -sh_a__na_no() { +nn() { sa__na_no "${@}"; } +sa__na_no() { nano \ "${@}" } diff --git a/sh/alias/newsboat.sh b/sh/alias/newsboat.sh index 18c09e3..e061d63 100644 --- a/sh/alias/newsboat.sh +++ b/sh/alias/newsboat.sh @@ -1,5 +1,5 @@ -nb() { sh_a__news_boat "${@}"; } -sh_a__news_boat() { +nb() { sa__news_boat "${@}"; } +sa__news_boat() { newsboat \ "${@}" } diff --git a/sh/alias/pass.sh b/sh/alias/pass.sh index e94898a..6e3a4da 100644 --- a/sh/alias/pass.sh +++ b/sh/alias/pass.sh @@ -1,13 +1,13 @@ # display pass entry’s content -p() { sh_a__pass "${@}"; } -sh_a__pass() { +p() { sa__pass "${@}"; } +sa__pass() { pass \ "${@}" } # copy passphrase into clipboard -pc() { sh_a__pass_clip "${@}"; } -sh_a__pass_clip() { +pc() { sa__pass_clip "${@}"; } +sa__pass_clip() { pass \ --clip \ "${@}" diff --git a/sh/alias/pgrep.sh b/sh/alias/pgrep.sh index a17c888..9350d6e 100644 --- a/sh/alias/pgrep.sh +++ b/sh/alias/pgrep.sh @@ -1,6 +1,6 @@ # look for a string in processes names -pg() { sh_a__proc_grep "${@}"; } -sh_a__proc_grep() { +pg() { sa__proc_grep "${@}"; } +sa__proc_grep() { pgrep \ --list-full \ "${@}" diff --git a/sh/alias/pwgen.sh b/sh/alias/pwgen.sh index 4c0b1f2..a2cfcc7 100644 --- a/sh/alias/pwgen.sh +++ b/sh/alias/pwgen.sh @@ -1,6 +1,6 @@ # generate passwords -pwg() { sh_a__pass_word_gen "${@}"; } -sh_a__pass_word_gen() { +pwg() { sa__pass_word_gen "${@}"; } +sa__pass_word_gen() { pwgen \ -1 \ --num-passwords 1048576 \ @@ -9,9 +9,9 @@ sh_a__pass_word_gen() { } # generate passwords with symbols -pwgs() { sh_a__pass_word_gen_symbols "${@}"; } -sh_a__pass_word_gen_symbols() { - sh_a__pass_word_gen \ +pwgs() { sa__pass_word_gen_symbols "${@}"; } +sa__pass_word_gen_symbols() { + sa__pass_word_gen \ --symbols \ "${@}" } diff --git a/sh/alias/rm.sh b/sh/alias/rm.sh index f944698..ca6bd11 100644 --- a/sh/alias/rm.sh +++ b/sh/alias/rm.sh @@ -1,6 +1,6 @@ # remove interactively -rmi() { sh_a__re_move_interactive "${@}"; } -sh_a__re_move_interactive() { +rmi() { sa__re_move_interactive "${@}"; } +sa__re_move_interactive() { rm \ --interactive \ "${@}" diff --git a/sh/alias/rsync.sh b/sh/alias/rsync.sh index 02ea400..773d317 100644 --- a/sh/alias/rsync.sh +++ b/sh/alias/rsync.sh @@ -1,6 +1,6 @@ # synchronize -rs() { sh_a__r_sync "${@}"; } -sh_a__r_sync() { +rs() { sa__r_sync "${@}"; } +sa__r_sync() { rsync \ --archive \ --no-inc-recursive \ @@ -11,17 +11,17 @@ sh_a__r_sync() { } # synchronize and delete after -rsda() { sh_a__r_sync_delete_after "${@}"; } -sh_a__r_sync_delete_after() { - sh_a__r_sync \ +rsda() { sa__r_sync_delete_after "${@}"; } +sa__r_sync_delete_after() { + sa__r_sync \ --delete-after \ "${@}" } # synchronize and delete before -rsdb() { sh_a__r_sync_delete_before "${@}"; } -sh_a__r_sync_delete_before() { - sh_a__r_sync \ +rsdb() { sa__r_sync_delete_before "${@}"; } +sa__r_sync_delete_before() { + sa__r_sync \ --delete-before \ "${@}" } diff --git a/sh/alias/tar.sh b/sh/alias/tar.sh index 6da0d03..6cebb0d 100644 --- a/sh/alias/tar.sh +++ b/sh/alias/tar.sh @@ -1,30 +1,30 @@ -tc() { sh_a__tar_create "${@}"; } -sh_a__tar_create() { - sh_a__tar_verbose \ +tc() { sa__tar_create "${@}"; } +sa__tar_create() { + sa__tar_verbose \ --create \ --auto-compress \ --file \ "${@}" } -tl() { sh_a__tar_list "${@}"; } -sh_a__tar_list() { - sh_a__tar_verbose \ +tl() { sa__tar_list "${@}"; } +sa__tar_list() { + sa__tar_verbose \ --list \ --file \ "${@}" } -tv() { sh_a__tar_verbose "${@}"; } -sh_a__tar_verbose() { +tv() { sa__tar_verbose "${@}"; } +sa__tar_verbose() { tar \ --verbose \ "${@}" } -tx() { sh_a__tar_xtract "${@}"; } -sh_a__tar_xtract() { - sh_a__tar_verbose \ +tx() { sa__tar_xtract "${@}"; } +sa__tar_xtract() { + sa__tar_verbose \ --extract \ --file \ "${@}" diff --git a/sh/alias/tmux.sh b/sh/alias/tmux.sh index fa51bd5..57d6053 100644 --- a/sh/alias/tmux.sh +++ b/sh/alias/tmux.sh @@ -1,5 +1,5 @@ -tm() { sh_a__t_mux "${@}"; } -sh_a__t_mux() { +tm() { sa__t_mux "${@}"; } +sa__t_mux() { tmux \ "${@}" } diff --git a/sh/alias/tree.sh b/sh/alias/tree.sh index 9d807c0..d172896 100644 --- a/sh/alias/tree.sh +++ b/sh/alias/tree.sh @@ -1,11 +1,11 @@ -t() { sh_a__tree "${@}"; } -sh_a__tree() { +t() { sa__tree "${@}"; } +sa__tree() { tree \ "${@}" } -ta() { sh_a__tree_all "${@}"; } -sh_a__tree_all() { +ta() { sa__tree_all "${@}"; } +sa__tree_all() { tree \ -a \ "${@}" From 07f5f9f4e924aba895ff852d55d9ad4e6aca3f3f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 09:22:24 +0100 Subject: [PATCH 764/969] gak,gau --- sh/alias/gpg.sh | 14 ++++++++++++++ sh/gpg.sh | 15 --------------- 2 files changed, 14 insertions(+), 15 deletions(-) create mode 100644 sh/alias/gpg.sh diff --git a/sh/alias/gpg.sh b/sh/alias/gpg.sh new file mode 100644 index 0000000..30ece71 --- /dev/null +++ b/sh/alias/gpg.sh @@ -0,0 +1,14 @@ +# turn gpg agent off +gak() { sa__gpg_agent_kill "${@}"; } +sa__gpg_agent_kill() { + gpgconf \ + --kill "gpg-agent" +} + +# bind gpg agent to current tty +gau() { sa__gpg_agent_update "${@}"; } +sa__gpg_agent_update() { + gpg-connect-agent \ + updatestartuptty \ + /bye +} diff --git a/sh/gpg.sh b/sh/gpg.sh index ffa4f63..5990fd0 100644 --- a/sh/gpg.sh +++ b/sh/gpg.sh @@ -1,18 +1,3 @@ -# turn gpg agent off -gak() { gpg_agent_kill "${@}"; } -sh_gpg_agent_kill() { - gpgconf \ - --kill "gpg-agent" -} - -# bind gpg agent to current tty -gau() { gpg_agent_update "${@}"; } -sh_gpg_agent_update() { - gpg-connect-agent \ - updatestartuptty \ - /bye -} - sh_gpg_ssh() { local user_id user_id=$(id --user) From 58090332dd998fd4a9c840abaf7093778afc0094 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 09:24:45 +0100 Subject: [PATCH 765/969] b --- sh/alias/batcat.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/alias/batcat.sh b/sh/alias/batcat.sh index 4d5968b..9af2774 100644 --- a/sh/alias/batcat.sh +++ b/sh/alias/batcat.sh @@ -1,5 +1,5 @@ -bat() { sa__b_a_t "${@}"; } -sa__b_a_t() { +b() { sa__bat "${@}"; } +sa__bat() { batcat \ "${@}" } From e212c967b03a95bda59894c0a0ff77a9c285b6a0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 09:25:49 +0100 Subject: [PATCH 766/969] remount --- sh/{cmd/mount.sh => live.sh} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename sh/{cmd/mount.sh => live.sh} (79%) diff --git a/sh/cmd/mount.sh b/sh/live.sh similarity index 79% rename from sh/cmd/mount.sh rename to sh/live.sh index 4454c41..dc77ce5 100644 --- a/sh/cmd/mount.sh +++ b/sh/live.sh @@ -1,5 +1,5 @@ # remount read-only medium in read-write -remount() { +sh_live_medium_remount() { mount \ -o "remount,rw" \ "/usr/lib/live/mount/medium" From 0bbd7a68c1e75f35dce3133842e2832c514bc826 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 09:37:33 +0100 Subject: [PATCH 767/969] home --- sh/rescue/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/rescue/common.sh b/sh/rescue/common.sh index f33c5aa..3b5fc85 100644 --- a/sh/rescue/common.sh +++ b/sh/rescue/common.sh @@ -6,7 +6,7 @@ rescue_configure() { apt_sources_write # bash / rc main_link_bashrc - mv .bashrc .bashrc.old + mv "${HOME}/.bashrc" "${HOME}/.bashrc.old" # host name hostname "${hostname}" # locales From e33138bab4acad1fb4bc2d0aadcdc0e2725177e5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 09:44:00 +0100 Subject: [PATCH 768/969] auth_sock --- sh/gpg.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/gpg.sh b/sh/gpg.sh index 5990fd0..26a4e6e 100644 --- a/sh/gpg.sh +++ b/sh/gpg.sh @@ -1,4 +1,4 @@ -sh_gpg_ssh() { +sh_gpg_ssh_auth_sock() { local user_id user_id=$(id --user) if [ "${user_id}" -ne 0 ]; then @@ -9,4 +9,4 @@ sh_gpg_ssh() { fi } -sh_gpg_ssh +sh_gpg_ssh_auth_sock From 2089e8c1e05995c80a5075308683db60c43d4ad4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 09:52:38 +0100 Subject: [PATCH 769/969] errors --- sh/log.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/log.sh b/sh/log.sh index c938663..e91c3ca 100644 --- a/sh/log.sh +++ b/sh/log.sh @@ -17,13 +17,13 @@ sh_log_debug() { sh_log_error() { if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_ERROR}" ]; then - echo "[ERROR]" "${@}" + echo "[ERROR]" "${@}" >&2 fi } sh_log_fatal() { if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_FATAL}" ]; then - echo "[FATAL]" "${@}" + echo "[FATAL]" "${@}" >&2 fi } From fbe30920d7b79b49376c41cdcc37b2fce74c7ef1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 09:58:15 +0100 Subject: [PATCH 770/969] codes --- sh/log.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sh/log.sh b/sh/log.sh index e91c3ca..34e986f 100644 --- a/sh/log.sh +++ b/sh/log.sh @@ -16,14 +16,22 @@ sh_log_debug() { } sh_log_error() { + local code="${1}" + shift + [ -n "${code}" ] || sh_log_fatal 1 "No error code" if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_ERROR}" ]; then echo "[ERROR]" "${@}" >&2 + return "${code}" fi } sh_log_fatal() { + local code="${1}" + shift + [ -n "${code}" ] || sh_log_fatal 1 "No error code" if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_FATAL}" ]; then echo "[FATAL]" "${@}" >&2 + exit "${code}" fi } From 05e500c36a1d458d84b3804df722051298a93a2e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 10:22:44 +0100 Subject: [PATCH 771/969] frontend --- sh/debian.sh | 2 +- sh/rescue/common.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/debian.sh b/sh/debian.sh index db37cae..a345b08 100644 --- a/sh/debian.sh +++ b/sh/debian.sh @@ -71,6 +71,6 @@ apt_upgrade() { apt_clean } -debian_disable_frontend() { +debian_frontend_disable() { export DEBIAN_FRONTEND="noninteractive" } diff --git a/sh/rescue/common.sh b/sh/rescue/common.sh index 3b5fc85..d94616b 100644 --- a/sh/rescue/common.sh +++ b/sh/rescue/common.sh @@ -19,7 +19,7 @@ fr_FR.UTF-8 UTF-8 # update catalog apt_update # disable frontend - debian_disable_frontend + debian_frontend_disable # install backports apt_install_backports "tmux" # install packages @@ -32,7 +32,7 @@ rescue_install() { # update catalog apt_update # disable frontend - debian_disable_frontend + debian_frontend_disable # upgrade packages apt_upgrade # install packages From d8929dfd4c04872f37bea0c56dee81efe4580d95 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 10:24:05 +0100 Subject: [PATCH 772/969] sh/frontend --- sh/debian.sh | 2 +- sh/rescue/common.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/debian.sh b/sh/debian.sh index a345b08..feeb8ac 100644 --- a/sh/debian.sh +++ b/sh/debian.sh @@ -71,6 +71,6 @@ apt_upgrade() { apt_clean } -debian_frontend_disable() { +sh_debian_frontend_disable() { export DEBIAN_FRONTEND="noninteractive" } diff --git a/sh/rescue/common.sh b/sh/rescue/common.sh index d94616b..69aded0 100644 --- a/sh/rescue/common.sh +++ b/sh/rescue/common.sh @@ -19,7 +19,7 @@ fr_FR.UTF-8 UTF-8 # update catalog apt_update # disable frontend - debian_frontend_disable + sh_debian_frontend_disable # install backports apt_install_backports "tmux" # install packages @@ -32,7 +32,7 @@ rescue_install() { # update catalog apt_update # disable frontend - debian_frontend_disable + sh_debian_frontend_disable # upgrade packages apt_upgrade # install packages From b02b2d183f9d82cedeb8b77231b64bac91d0c798 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 10:25:22 +0100 Subject: [PATCH 773/969] apt/upgrade --- sh/debian.sh | 2 +- sh/rescue/common.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/debian.sh b/sh/debian.sh index feeb8ac..4485be6 100644 --- a/sh/debian.sh +++ b/sh/debian.sh @@ -64,7 +64,7 @@ apt_update() { update } -apt_upgrade() { +sh_apt_upgrade() { apt-get \ upgrade \ --assume-yes diff --git a/sh/rescue/common.sh b/sh/rescue/common.sh index 69aded0..a9a08d7 100644 --- a/sh/rescue/common.sh +++ b/sh/rescue/common.sh @@ -34,7 +34,7 @@ rescue_install() { # disable frontend sh_debian_frontend_disable # upgrade packages - apt_upgrade + sh_apt_upgrade # install packages apt_install_release \ "man-db" \ From 10162404836a8b2b152fb23ca406404ae04d35f4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 10:33:56 +0100 Subject: [PATCH 774/969] apt/update --- sh/debian.sh | 2 +- sh/rescue/common.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sh/debian.sh b/sh/debian.sh index 4485be6..7cc17e1 100644 --- a/sh/debian.sh +++ b/sh/debian.sh @@ -59,7 +59,7 @@ ${DEBIAN_CODENAME}-security main non-free-firmware contrib non-free " >"/etc/apt/sources.list" } -apt_update() { +sh_apt_update() { apt-get \ update } diff --git a/sh/rescue/common.sh b/sh/rescue/common.sh index a9a08d7..200f839 100644 --- a/sh/rescue/common.sh +++ b/sh/rescue/common.sh @@ -17,7 +17,7 @@ fr_FR.UTF-8 UTF-8 # generate locales locale-gen # update catalog - apt_update + sh_apt_update # disable frontend sh_debian_frontend_disable # install backports @@ -25,12 +25,12 @@ fr_FR.UTF-8 UTF-8 # install packages apt_install_release "apt-file" "mosh" "screen" "byobu" # update catalog - apt_update + sh_apt_update } rescue_install() { # update catalog - apt_update + sh_apt_update # disable frontend sh_debian_frontend_disable # upgrade packages From 3c3f8ffeca92056c5cfbfdb5192589e57dd3a653 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 10:36:35 +0100 Subject: [PATCH 775/969] apt/sources --- sh/debian.sh | 2 +- sh/rescue/common.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/debian.sh b/sh/debian.sh index 7cc17e1..36c7cdd 100644 --- a/sh/debian.sh +++ b/sh/debian.sh @@ -46,7 +46,7 @@ apt_install_target() { done } -apt_sources_write() { +sh_apt_sources_write() { printf "%s" "\ deb https://deb.debian.org/debian \ ${DEBIAN_CODENAME} main non-free-firmware contrib non-free diff --git a/sh/rescue/common.sh b/sh/rescue/common.sh index 200f839..ecc21c2 100644 --- a/sh/rescue/common.sh +++ b/sh/rescue/common.sh @@ -3,7 +3,7 @@ rescue_configure() { # apt / conf apt_conf_write # apt / sources - apt_sources_write + sh_apt_sources_write # bash / rc main_link_bashrc mv "${HOME}/.bashrc" "${HOME}/.bashrc.old" From c9c4aa9a6fee467a5657eb10f10f2680e3bd12f8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 10:37:35 +0100 Subject: [PATCH 776/969] apt/clean --- sh/debian.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/debian.sh b/sh/debian.sh index 36c7cdd..c4deb80 100644 --- a/sh/debian.sh +++ b/sh/debian.sh @@ -3,7 +3,7 @@ DEBIAN_CODENAME="$( cut --delimiter "=" --fields "2" )" -apt_clean() { +sh_apt_clean() { apt-get \ clean } @@ -42,7 +42,7 @@ apt_install_target() { --assume-yes \ --target-release "${target}" \ "${package}" - apt_clean + sh_apt_clean done } @@ -68,7 +68,7 @@ sh_apt_upgrade() { apt-get \ upgrade \ --assume-yes - apt_clean + sh_apt_clean } sh_debian_frontend_disable() { From 67510c2deef3e119022493ab200895e3687dad4e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 10:39:25 +0100 Subject: [PATCH 777/969] apt/conf --- sh/debian.sh | 2 +- sh/rescue/common.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/debian.sh b/sh/debian.sh index c4deb80..97bb8d3 100644 --- a/sh/debian.sh +++ b/sh/debian.sh @@ -8,7 +8,7 @@ sh_apt_clean() { clean } -apt_conf_write() { +sh_apt_conf_write() { printf "\ Acquire::AllowInsecureRepositories False; Acquire::AllowWeakRepositories False; diff --git a/sh/rescue/common.sh b/sh/rescue/common.sh index ecc21c2..3f026e7 100644 --- a/sh/rescue/common.sh +++ b/sh/rescue/common.sh @@ -1,7 +1,7 @@ rescue_configure() { local hostname="${1}" # apt / conf - apt_conf_write + sh_apt_conf_write # apt / sources sh_apt_sources_write # bash / rc From 1a1679031e9a5707712be361e86c74c960caaa1e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 10:41:16 +0100 Subject: [PATCH 778/969] apt/target --- sh/debian.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/debian.sh b/sh/debian.sh index 97bb8d3..8d00ac9 100644 --- a/sh/debian.sh +++ b/sh/debian.sh @@ -23,14 +23,14 @@ Dpkg::Progress True; } apt_install_backports() { - apt_install_target "${DEBIAN_CODENAME}-backports" "${@}" + sh_apt_install_target "${DEBIAN_CODENAME}-backports" "${@}" } apt_install_release() { - apt_install_target "${DEBIAN_CODENAME}" "${@}" + sh_apt_install_target "${DEBIAN_CODENAME}" "${@}" } -apt_install_target() { +sh_apt_install_target() { local target="${1}" shift local package From 1ad055dfb48557aedb6c4664b85801d8917096c1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 10:45:49 +0100 Subject: [PATCH 779/969] apt/release --- sh/debian.sh | 2 +- sh/rescue/common.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/debian.sh b/sh/debian.sh index 8d00ac9..64a2751 100644 --- a/sh/debian.sh +++ b/sh/debian.sh @@ -26,7 +26,7 @@ apt_install_backports() { sh_apt_install_target "${DEBIAN_CODENAME}-backports" "${@}" } -apt_install_release() { +sh_apt_install_release() { sh_apt_install_target "${DEBIAN_CODENAME}" "${@}" } diff --git a/sh/rescue/common.sh b/sh/rescue/common.sh index 3f026e7..de35c83 100644 --- a/sh/rescue/common.sh +++ b/sh/rescue/common.sh @@ -23,7 +23,7 @@ fr_FR.UTF-8 UTF-8 # install backports apt_install_backports "tmux" # install packages - apt_install_release "apt-file" "mosh" "screen" "byobu" + sh_apt_install_release "apt-file" "mosh" "screen" "byobu" # update catalog sh_apt_update } @@ -36,7 +36,7 @@ rescue_install() { # upgrade packages sh_apt_upgrade # install packages - apt_install_release \ + sh_apt_install_release \ "man-db" \ "dmidecode" "efibootmgr" "lshw" "pciutils" "usbutils" \ "parted" "mdadm" "cryptsetup-bin" "lvm2" \ From bb08d4c5da497b4db17a694f85a72a2ebcebaf90 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 10:46:30 +0100 Subject: [PATCH 780/969] apt/backports --- sh/debian.sh | 2 +- sh/rescue/common.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/debian.sh b/sh/debian.sh index 64a2751..39639b9 100644 --- a/sh/debian.sh +++ b/sh/debian.sh @@ -22,7 +22,7 @@ Dpkg::Progress True; " >"/etc/apt/apt.conf.d/apt.conf" } -apt_install_backports() { +sh_apt_install_backports() { sh_apt_install_target "${DEBIAN_CODENAME}-backports" "${@}" } diff --git a/sh/rescue/common.sh b/sh/rescue/common.sh index de35c83..b108681 100644 --- a/sh/rescue/common.sh +++ b/sh/rescue/common.sh @@ -21,7 +21,7 @@ fr_FR.UTF-8 UTF-8 # disable frontend sh_debian_frontend_disable # install backports - apt_install_backports "tmux" + sh_apt_install_backports "tmux" # install packages sh_apt_install_release "apt-file" "mosh" "screen" "byobu" # update catalog @@ -45,7 +45,7 @@ rescue_install() { "exa" "lf" "ncdu" "nnn" "ranger" "tree" \ "file" "htop" "iotop" "ipcalc" "libdigest-sha3-perl" "lsof" # install backports - apt_install_backports \ + sh_apt_install_backports \ "grub-pc-bin" \ \ "grub-efi-amd64-bin" From 7dfbb947ff27303b400fca1bdfb6f0e2ec4a05f8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 11:02:32 +0100 Subject: [PATCH 781/969] prefixes --- sh/main.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sh/main.sh b/sh/main.sh index 81c412e..d45a22a 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -44,6 +44,8 @@ main_source_directory() { fi done IFS="${ifs}" + sh_log + sh_log "sa__… sh_… su__…" else echo "Not a directory: ${path}" return 1 From d90f0fd6ef960425a4f9a59a65e121352264ca79 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 12:21:29 +0100 Subject: [PATCH 782/969] _sh_log --- sh/log.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/sh/log.sh b/sh/log.sh index 34e986f..40cb311 100644 --- a/sh/log.sh +++ b/sh/log.sh @@ -11,7 +11,7 @@ sh_log() { sh_log_info "${@}"; } sh_log_debug() { if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_DEBUG}" ]; then - echo "[DEBUG]" "${@}" + _sh_log "[DEBUG]" "${@}" fi } @@ -20,7 +20,7 @@ sh_log_error() { shift [ -n "${code}" ] || sh_log_fatal 1 "No error code" if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_ERROR}" ]; then - echo "[ERROR]" "${@}" >&2 + _sh_log "[ERROR]" "${@}" >&2 return "${code}" fi } @@ -30,25 +30,35 @@ sh_log_fatal() { shift [ -n "${code}" ] || sh_log_fatal 1 "No error code" if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_FATAL}" ]; then - echo "[FATAL]" "${@}" >&2 + _sh_log "[FATAL]" "${@}" >&2 exit "${code}" fi } sh_log_info() { if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_INFO}" ]; then - echo "${@}" + _sh_log "" "${@}" fi } sh_log_trace() { if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_TRACE}" ]; then - echo "[TRACE]" "${@}" + _sh_log "[TRACE]" "${@}" fi } sh_log_warn() { if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_WARN}" ]; then - echo " [WARN]" "${@}" + _sh_log "[ WARN]" "${@}" fi } + +_sh_log() { + local prefix="${1}" + shift + local line + for line in "${@}"; do + printf "%s" "${prefix}" + echo " ${line}" + done +} \ No newline at end of file From ea17fc995a4b5e8054a45053a9695e57d1cc9e33 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 12:29:30 +0100 Subject: [PATCH 783/969] prefix --- sh/log.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/log.sh b/sh/log.sh index 40cb311..1674324 100644 --- a/sh/log.sh +++ b/sh/log.sh @@ -58,7 +58,7 @@ _sh_log() { shift local line for line in "${@}"; do - printf "%s" "${prefix}" - echo " ${line}" + [ -n "${prefix}" ] && printf "%s" "${prefix} " + echo "${line}" done -} \ No newline at end of file +} From a133acea99c1b7aa3ec7db6b7437d0869a1eed7b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 12:32:29 +0100 Subject: [PATCH 784/969] main/log --- sh/main.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index d45a22a..f727013 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -44,8 +44,6 @@ main_source_directory() { fi done IFS="${ifs}" - sh_log - sh_log "sa__… sh_… su__…" else echo "Not a directory: ${path}" return 1 @@ -65,3 +63,8 @@ main_source_file() { main_source_file "${ENV}" main_source_directory "${SH_USER}" + +sh_log "" \ + "sh_… shell functions" \ + "sa__… shell aliases" \ + "su__… shell user" From c8f6264f20556f25c6819227a8999795523d1939 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 14:11:11 +0100 Subject: [PATCH 785/969] main/commands --- sh/main.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index f727013..b761e6e 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -7,7 +7,7 @@ SH_MAIN="${SH_ROOT}/main.sh" [ -n "${ENV}" ] || export ENV="${SH_MAIN}" -main_commands() { +_sh_main_commands() { local file="${1}" grep "()" "${file}" | cut --delimiter "(" --fields 1 @@ -35,7 +35,7 @@ main_source_directory() { module="${path}/${module}" if [ "${module}" != "${ENV}" ]; then . "${module}" - cmd="$(main_commands "${module}")" + cmd="$(_sh_main_commands "${module}")" if [ -n "${cmd}" ]; then [ -n "${CMD}" ] && CMD="${CMD} " From 838dbfc4f567225167557393c1e9e6e4edcda4b3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 14:33:03 +0100 Subject: [PATCH 786/969] user --- sh/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/main.sh b/sh/main.sh index b761e6e..22d716e 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -67,4 +67,4 @@ main_source_directory "${SH_USER}" sh_log "" \ "sh_… shell functions" \ "sa__… shell aliases" \ - "su__… shell user" + "u__… user aliases" From 14e9e52362d7827e720a8f81d8aaaebdda3d7b01 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 14:39:50 +0100 Subject: [PATCH 787/969] main/log --- sh/main.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 22d716e..387b1b3 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -65,6 +65,6 @@ main_source_file "${ENV}" main_source_directory "${SH_USER}" sh_log "" \ - "sh_… shell functions" \ - "sa__… shell aliases" \ - "u__… user aliases" + "sh_… = shell functions" \ + "a__… = aliases" \ + "u__… = user" From 8fae0bd63ecae5f7dc0561f4b06c15f066628e53 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 14:42:11 +0100 Subject: [PATCH 788/969] a__ --- sh/alias/apt.sh | 48 ++++----- sh/alias/batcat.sh | 4 +- sh/alias/btrfs.sh | 36 +++---- sh/alias/byobu.sh | 16 +-- sh/alias/chmod.sh | 8 +- sh/alias/chown.sh | 8 +- sh/alias/clear.sh | 4 +- sh/alias/cp.sh | 4 +- sh/alias/emacs.sh | 4 +- sh/alias/evince.sh | 4 +- sh/alias/git.sh | 242 +++++++++++++++++++++---------------------- sh/alias/gpg.sh | 8 +- sh/alias/grep.sh | 4 +- sh/alias/kill.sh | 8 +- sh/alias/killall.sh | 8 +- sh/alias/ls.sh | 16 +-- sh/alias/lsblk.sh | 16 +-- sh/alias/mkdir.sh | 8 +- sh/alias/mount.sh | 4 +- sh/alias/mv.sh | 4 +- sh/alias/nano.sh | 4 +- sh/alias/newsboat.sh | 4 +- sh/alias/pass.sh | 8 +- sh/alias/pgrep.sh | 4 +- sh/alias/pwgen.sh | 10 +- sh/alias/rm.sh | 4 +- sh/alias/rsync.sh | 16 +-- sh/alias/tar.sh | 22 ++-- sh/alias/tmux.sh | 4 +- sh/alias/tree.sh | 8 +- 30 files changed, 269 insertions(+), 269 deletions(-) diff --git a/sh/alias/apt.sh b/sh/alias/apt.sh index 1af6d78..0f3294e 100644 --- a/sh/alias/apt.sh +++ b/sh/alias/apt.sh @@ -1,94 +1,94 @@ # show package information -acl() { sa__apt_cache_list "${@}"; } -sa__apt_cache_list() { +acl() { a__apt_cache_list "${@}"; } +a__apt_cache_list() { apt-cache \ show \ "${@}" } # package versions policy -acp() { sa__apt_cache_policy "${@}"; } -sa__apt_cache_policy() { +acp() { a__apt_cache_policy "${@}"; } +a__apt_cache_policy() { apt-cache \ policy \ "${@}" } # search package -acs() { sa__apt_cache_search "${@}"; } -sa__apt_cache_search() { +acs() { a__apt_cache_search "${@}"; } +a__apt_cache_search() { apt-cache \ search \ "${@}" } # -agap() { sa__apt_get_auto_purge "${@}"; } -sa__apt_get_auto_purge() { +agap() { a__apt_get_auto_purge "${@}"; } +a__apt_get_auto_purge() { apt-get \ autopurge \ "${@}" } # -agar() { sa__apt_get_auto_remove "${@}"; } -sa__apt_get_auto_remove() { +agar() { a__apt_get_auto_remove "${@}"; } +a__apt_get_auto_remove() { apt-get \ autoremove \ "${@}" } # clean packages cache -agc() { sa__apt_get_clean "${@}"; } -sa__apt_get_clean() { +agc() { a__apt_get_clean "${@}"; } +a__apt_get_clean() { apt-get \ clean \ "${@}" } # upgrade allowing package installation or removal -agfu() { sa__apt_get_full_upgrade "${@}"; } -sa__apt_get_full_upgrade() { +agfu() { a__apt_get_full_upgrade "${@}"; } +a__apt_get_full_upgrade() { apt-get \ full-upgrade \ "${@}" } # install packages -agi() { sa__apt_get_install "${@}"; } -sa__apt_get_install() { +agi() { a__apt_get_install "${@}"; } +a__apt_get_install() { apt-get \ install \ "${@}" } # -agp() { sa__apt_get_purge "${@}"; } -sa__apt_get_purge() { +agp() { a__apt_get_purge "${@}"; } +a__apt_get_purge() { apt-get \ purge \ "${@}" } # -agr() { sa__apt_get_remove "${@}"; } -sa__apt_get_remove() { +agr() { a__apt_get_remove "${@}"; } +a__apt_get_remove() { apt-get \ remove \ "${@}" } # update packages catalog -agud() { sa__apt_get_up_date "${@}"; } -sa__apt_get_up_date() { +agud() { a__apt_get_up_date "${@}"; } +a__apt_get_up_date() { apt-get \ update \ "${@}" } # upgrade forbidding package installation or removal -agug() { sa__apt_get_up_grade "${@}"; } -sa__apt_get_up_grade() { +agug() { a__apt_get_up_grade "${@}"; } +a__apt_get_up_grade() { apt-get \ upgrade \ "${@}" diff --git a/sh/alias/batcat.sh b/sh/alias/batcat.sh index 9af2774..99d8373 100644 --- a/sh/alias/batcat.sh +++ b/sh/alias/batcat.sh @@ -1,5 +1,5 @@ -b() { sa__bat "${@}"; } -sa__bat() { +b() { a__bat "${@}"; } +a__bat() { batcat \ "${@}" } diff --git a/sh/alias/btrfs.sh b/sh/alias/btrfs.sh index eb48c14..0e4ba62 100644 --- a/sh/alias/btrfs.sh +++ b/sh/alias/btrfs.sh @@ -1,13 +1,13 @@ -bfdf() { sa__btrfs_filesystem_d_f "${@}"; } -sa__btrfs_filesystem_d_f() { +bfdf() { a__btrfs_filesystem_d_f "${@}"; } +a__btrfs_filesystem_d_f() { btrfs \ filesystem \ df \ "${@}" } -bfdu() { sa__btrfs_filesystem_d_u "${@}"; } -sa__btrfs_filesystem_d_u() { +bfdu() { a__btrfs_filesystem_d_u "${@}"; } +a__btrfs_filesystem_d_u() { btrfs \ filesystem \ du \ @@ -15,40 +15,40 @@ sa__btrfs_filesystem_d_u() { "${@}" } -bfu() { sa__btrfs_filesystem_usage "${@}"; } -sa__btrfs_filesystem_usage() { +bfu() { a__btrfs_filesystem_usage "${@}"; } +a__btrfs_filesystem_usage() { btrfs \ filesystem \ usage \ "${@}" } -bpg() { sa__btrfs_property_get "${@}"; } -sa__btrfs_property_get() { +bpg() { a__btrfs_property_get "${@}"; } +a__btrfs_property_get() { btrfs \ property \ get \ "${@}" } -bsc() { sa__btrfs_subvolume_create "${@}"; } -sa__btrfs_subvolume_create() { +bsc() { a__btrfs_subvolume_create "${@}"; } +a__btrfs_subvolume_create() { btrfs \ subvolume \ create \ "${@}" } -bsd() { sa__btrfs_subvolume_delete "${@}"; } -sa__btrfs_subvolume_delete() { +bsd() { a__btrfs_subvolume_delete "${@}"; } +a__btrfs_subvolume_delete() { btrfs \ subvolume \ delete \ "${@}" } -bsl() { sa__btrfs_subvolume_list "${@}"; } -sa__btrfs_subvolume_list() { +bsl() { a__btrfs_subvolume_list "${@}"; } +a__btrfs_subvolume_list() { if [ -n "${1}" ]; then btrfs subvolume list "${1}" | cut --delimiter " " --fields 9 | @@ -56,16 +56,16 @@ sa__btrfs_subvolume_list() { fi } -bss() { sa__btrfs_subvolume_snapshot "${@}"; } -sa__btrfs_subvolume_snapshot() { +bss() { a__btrfs_subvolume_snapshot "${@}"; } +a__btrfs_subvolume_snapshot() { btrfs \ subvolume \ snapshot \ "${@}" } -bssr() { sa__btrfs_subvolume_snapshot_r "${@}"; } -sa__btrfs_subvolume_snapshot_r() { +bssr() { a__btrfs_subvolume_snapshot_r "${@}"; } +a__btrfs_subvolume_snapshot_r() { btrfs \ subvolume \ snapshot -r \ diff --git a/sh/alias/byobu.sh b/sh/alias/byobu.sh index 6b66a77..0f5336e 100644 --- a/sh/alias/byobu.sh +++ b/sh/alias/byobu.sh @@ -1,25 +1,25 @@ -bb() { sa__byo_bu "${@}"; } -sa__byo_bu() { +bb() { a__byo_bu "${@}"; } +a__byo_bu() { byobu \ "${@}" } -bba() { sa__byo_bu_attach "${@}"; } -sa__byo_bu_attach() { +bba() { a__byo_bu_attach "${@}"; } +a__byo_bu_attach() { byobu \ attach-session \ "${@}" } -bbl() { sa__byo_bu_ls "${@}"; } -sa__byo_bu_ls() { +bbl() { a__byo_bu_ls "${@}"; } +a__byo_bu_ls() { byobu \ ls \ "${@}" } -bbnd() { sa__byo_bu_new_detach "${@}"; } -sa__byo_bu_new_detach() { +bbnd() { a__byo_bu_new_detach "${@}"; } +a__byo_bu_new_detach() { byobu \ new-session \ -d \ diff --git a/sh/alias/chmod.sh b/sh/alias/chmod.sh index 6a6e0e8..57ec74e 100644 --- a/sh/alias/chmod.sh +++ b/sh/alias/chmod.sh @@ -1,14 +1,14 @@ # change mode to directory -cmd() { sa__change_mode_directory "${@}"; } -sa__change_mode_directory() { +cmd() { a__change_mode_directory "${@}"; } +a__change_mode_directory() { chmod \ "755" \ "${@}" } # change mode to file -cmf() { sa__change_mode_file "${@}"; } -sa__change_mode_file() { +cmf() { a__change_mode_file "${@}"; } +a__change_mode_file() { chmod \ "644" \ "${@}" diff --git a/sh/alias/chown.sh b/sh/alias/chown.sh index 8c992d3..f4fa865 100644 --- a/sh/alias/chown.sh +++ b/sh/alias/chown.sh @@ -1,14 +1,14 @@ # change owner to root -cor() { sa__change_owner_root "${@}"; } -sa__change_owner_root() { +cor() { a__change_owner_root "${@}"; } +a__change_owner_root() { chown \ "0:0" \ "${@}" } # change owner to user -cou() { sa__change_owner_user "${@}"; } -sa__change_owner_user() { +cou() { a__change_owner_user "${@}"; } +a__change_owner_user() { chown \ "1000:1000" \ "${@}" diff --git a/sh/alias/clear.sh b/sh/alias/clear.sh index 542a260..ae32b30 100644 --- a/sh/alias/clear.sh +++ b/sh/alias/clear.sh @@ -1,6 +1,6 @@ # clear terminal -c() { sa__clear "${@}"; } -sa__clear() { +c() { a__clear "${@}"; } +a__clear() { clear \ "${@}" } diff --git a/sh/alias/cp.sh b/sh/alias/cp.sh index d8897c0..c9e7d6b 100644 --- a/sh/alias/cp.sh +++ b/sh/alias/cp.sh @@ -1,6 +1,6 @@ # copy interactively -cpi() { sa__co_py_interactive "${@}"; } -sa__co_py_interactive() { +cpi() { a__co_py_interactive "${@}"; } +a__co_py_interactive() { cp \ --interactive \ "${@}" diff --git a/sh/alias/emacs.sh b/sh/alias/emacs.sh index cc7e002..8e26878 100644 --- a/sh/alias/emacs.sh +++ b/sh/alias/emacs.sh @@ -1,5 +1,5 @@ -em() { sa__e_macs "${@}"; } -sa__e_macs() { +em() { a__e_macs "${@}"; } +a__e_macs() { emacs \ "${@}" } diff --git a/sh/alias/evince.sh b/sh/alias/evince.sh index 5d68ace..25ac069 100644 --- a/sh/alias/evince.sh +++ b/sh/alias/evince.sh @@ -1,5 +1,5 @@ -ev() { sa__e_vince "${@}"; } -sa__e_vince() { +ev() { a__e_vince "${@}"; } +a__e_vince() { evince \ "${@}" } diff --git a/sh/alias/git.sh b/sh/alias/git.sh index 5ce2f93..6400092 100644 --- a/sh/alias/git.sh +++ b/sh/alias/git.sh @@ -8,16 +8,16 @@ C %C(blue)%cn %ce %B" # add to index -ga() { sa__git_add "${@}"; } -sa__git_add() { +ga() { a__git_add "${@}"; } +a__git_add() { git \ add \ "${@}" } # add all to index -gaa() { sa__git_add_all "${@}"; } -sa__git_add_all() { +gaa() { a__git_add_all "${@}"; } +a__git_add_all() { git \ add \ --all \ @@ -25,8 +25,8 @@ sa__git_add_all() { } # add parts of all to index -gaap() { sa__git_add_all_patch "${@}"; } -sa__git_add_all_patch() { +gaap() { a__git_add_all_patch "${@}"; } +a__git_add_all_patch() { git \ add \ --all \ @@ -35,8 +35,8 @@ sa__git_add_all_patch() { } # add parts to index -gap() { sa__git_add_patch "${@}"; } -sa__git_add_patch() { +gap() { a__git_add_patch "${@}"; } +a__git_add_patch() { git \ add \ --patch \ @@ -44,16 +44,16 @@ sa__git_add_patch() { } # create a branch -gb() { sa__git_branch "${@}"; } -sa__git_branch() { +gb() { a__git_branch "${@}"; } +a__git_branch() { git \ branch \ "${@}" } # delete a branch -gbd() { sa__git_branch_delete "${@}"; } -sa__git_branch_delete() { +gbd() { a__git_branch_delete "${@}"; } +a__git_branch_delete() { git \ branch \ --delete \ @@ -61,8 +61,8 @@ sa__git_branch_delete() { } # force a branch deletion -gbdf() { sa__git_branch_delete_force "${@}"; } -sa__git_branch_delete_force() { +gbdf() { a__git_branch_delete_force "${@}"; } +a__git_branch_delete_force() { git \ branch \ --delete \ @@ -71,8 +71,8 @@ sa__git_branch_delete_force() { } # list branches -gbl() { sa__git_branch_list "${@}"; } -sa__git_branch_list() { +gbl() { a__git_branch_list "${@}"; } +a__git_branch_list() { git \ branch \ --all \ @@ -83,8 +83,8 @@ sa__git_branch_list() { } # set the link to a remote branch from a local branch -gbsu() { sa__git_branch_set_upstream "${@}"; } -sa__git_branch_set_upstream() { +gbsu() { a__git_branch_set_upstream "${@}"; } +a__git_branch_set_upstream() { git \ branch \ --set-upstream-to \ @@ -92,16 +92,16 @@ sa__git_branch_set_upstream() { } # switch to a branch or checkout file(s) from a commit -gc() { sa__git_checkout "${@}"; } -sa__git_checkout() { +gc() { a__git_checkout "${@}"; } +a__git_checkout() { git \ checkout \ "${@}" } # checkout an orphan branch -gco() { sa__git_checkout_orphan "${@}"; } -sa__git_checkout_orphan() { +gco() { a__git_checkout_orphan "${@}"; } +a__git_checkout_orphan() { git \ checkout \ --orphan \ @@ -109,16 +109,16 @@ sa__git_checkout_orphan() { } # pick a commit -gcp() { sa__git_cherry_pick "${@}"; } -sa__git_cherry_pick() { +gcp() { a__git_cherry_pick "${@}"; } +a__git_cherry_pick() { git \ cherry-pick \ "${@}" } # abort the commit pick -gcpa() { sa__git_cherry_pick_abort "${@}"; } -sa__git_cherry_pick_abort() { +gcpa() { a__git_cherry_pick_abort "${@}"; } +a__git_cherry_pick_abort() { git \ cherry-pick \ --abort \ @@ -126,8 +126,8 @@ sa__git_cherry_pick_abort() { } # continue the commit pick -gcpc() { sa__git_cherry_pick_continue "${@}"; } -sa__git_cherry_pick_continue() { +gcpc() { a__git_cherry_pick_continue "${@}"; } +a__git_cherry_pick_continue() { git \ cherry-pick \ --continue \ @@ -135,8 +135,8 @@ sa__git_cherry_pick_continue() { } # clean untracked files -gcf() { sa__git_clean_force "${@}"; } -sa__git_clean_force() { +gcf() { a__git_clean_force "${@}"; } +a__git_clean_force() { git \ clean \ -d \ @@ -145,8 +145,8 @@ sa__git_clean_force() { } # redo the last commit with a different message -gcam() { sa__git_commit_amend_message "${@}"; } -sa__git_commit_amend_message() { +gcam() { a__git_commit_amend_message "${@}"; } +a__git_commit_amend_message() { git \ commit \ --amend \ @@ -155,8 +155,8 @@ sa__git_commit_amend_message() { } # make a root commit -gcem() { sa__git_commit_empty_message "${@}"; } -sa__git_commit_empty_message() { +gcem() { a__git_commit_empty_message "${@}"; } +a__git_commit_empty_message() { git \ commit \ --allow-empty \ @@ -166,8 +166,8 @@ sa__git_commit_empty_message() { } # commit the index -gcm() { sa__git_commit_message "${@}"; } -sa__git_commit_message() { +gcm() { a__git_commit_message "${@}"; } +a__git_commit_message() { git \ commit \ --message \ @@ -175,8 +175,8 @@ sa__git_commit_message() { } # configure the user email -gcue() { sa__git_config_user_email "${@}"; } -sa__git_config_user_email() { +gcue() { a__git_config_user_email "${@}"; } +a__git_config_user_email() { git \ config \ "user.email" \ @@ -184,8 +184,8 @@ sa__git_config_user_email() { } # configure the user name -gcun() { sa__git_config_user_name "${@}"; } -sa__git_config_user_name() { +gcun() { a__git_config_user_name "${@}"; } +a__git_config_user_name() { git \ config \ "user.name" \ @@ -193,16 +193,16 @@ sa__git_config_user_name() { } # differences from last or between commits -gd() { sa__git_diff "${@}"; } -sa__git_diff() { +gd() { a__git_diff "${@}"; } +a__git_diff() { git \ diff \ "${@}" } # display what is indexed in cache -gdc() { sa__git_diff_cached "${@}"; } -sa__git_diff_cached() { +gdc() { a__git_diff_cached "${@}"; } +a__git_diff_cached() { git \ diff \ --cached \ @@ -210,8 +210,8 @@ sa__git_diff_cached() { } # indexed character-level differences -gdcw() { sa__git_diff_cached_word "${@}"; } -sa__git_diff_cached_word() { +gdcw() { a__git_diff_cached_word "${@}"; } +a__git_diff_cached_word() { git \ diff \ --cached \ @@ -220,8 +220,8 @@ sa__git_diff_cached_word() { } # differences via external tool -gdt() { sa__git_diff_tool "${@}"; } -sa__git_diff_tool() { +gdt() { a__git_diff_tool "${@}"; } +a__git_diff_tool() { git \ difftool \ --dir-diff \ @@ -229,8 +229,8 @@ sa__git_diff_tool() { } # character-level differences -gdw() { sa__git_diff_word "${@}"; } -sa__git_diff_word() { +gdw() { a__git_diff_word "${@}"; } +a__git_diff_word() { git \ diff \ --word-diff-regex "." \ @@ -238,8 +238,8 @@ sa__git_diff_word() { } # fetch from the remote repository -gf() { sa__git_fetch "${@}"; } -sa__git_fetch() { +gf() { a__git_fetch "${@}"; } +a__git_fetch() { git \ fetch \ --tags \ @@ -248,16 +248,16 @@ sa__git_fetch() { } # fetch from remote repository and prune local orphan branches -gfp() { sa__git_fetch_prune "${@}"; } -sa__git_fetch_prune() { - sa__git_fetch \ +gfp() { a__git_fetch_prune "${@}"; } +a__git_fetch_prune() { + a__git_fetch \ --prune \ "${@}" } # garbage collect all orphan commits -ggc() { sa__git_garbage_collect "${@}"; } -sa__git_garbage_collect() { +ggc() { a__git_garbage_collect "${@}"; } +a__git_garbage_collect() { git \ reflog \ expire \ @@ -270,16 +270,16 @@ sa__git_garbage_collect() { } # initialize a new repository -gi() { sa__git_init "${@}"; } -sa__git_init() { +gi() { a__git_init "${@}"; } +a__git_init() { git \ init \ "${@}" } # initialize a new bare repository -gib() { sa__git_init_bare "${@}"; } -sa__git_init_bare() { +gib() { a__git_init_bare "${@}"; } +a__git_init_bare() { git \ init \ --bare \ @@ -287,8 +287,8 @@ sa__git_init_bare() { } # log history -gl() { sa__git_log "${@}"; } -sa__git_log() { +gl() { a__git_log "${@}"; } +a__git_log() { git \ log \ --abbrev=8 \ @@ -299,33 +299,33 @@ sa__git_log() { } # log all history -gla() { sa__git_log_all "${@}"; } -sa__git_log_all() { - sa__git_log \ +gla() { a__git_log_all "${@}"; } +a__git_log_all() { + a__git_log \ --all \ "${@}" } # log all history with patches -glap() { sa__git_log_all_patch "${@}"; } -sa__git_log_all_patch() { - sa__git_log \ +glap() { a__git_log_all_patch "${@}"; } +a__git_log_all_patch() { + a__git_log \ --all \ --patch \ "${@}" } # log history with patches -glp() { sa__git_log_patch "${@}"; } -sa__git_log_patch() { - sa__git_log \ +glp() { a__git_log_patch "${@}"; } +a__git_log_patch() { + a__git_log \ --patch \ "${@}" } # fast-forward merge to remote branch -gm() { sa__git_merge "${@}"; } -sa__git_merge() { +gm() { a__git_merge "${@}"; } +a__git_merge() { git \ merge \ --ff-only \ @@ -333,8 +333,8 @@ sa__git_merge() { } # abort the current merge commit -gma() { sa__git_merge_abort "${@}"; } -sa__git_merge_abort() { +gma() { a__git_merge_abort "${@}"; } +a__git_merge_abort() { git \ merge \ --abort \ @@ -342,8 +342,8 @@ sa__git_merge_abort() { } # do a merge commit -gmc() { sa__git_merge_commit "${@}"; } -sa__git_merge_commit() { +gmc() { a__git_merge_commit "${@}"; } +a__git_merge_commit() { git \ merge \ --no-ff \ @@ -352,8 +352,8 @@ sa__git_merge_commit() { } # squash a branch and index its modifications -gms() { sa__git_merge_squash "${@}"; } -sa__git_merge_squash() { +gms() { a__git_merge_squash "${@}"; } +a__git_merge_squash() { git \ merge \ --squash \ @@ -361,16 +361,16 @@ sa__git_merge_squash() { } # merge via external tool -gmt() { sa__git_merge_tool "${@}"; } -sa__git_merge_tool() { +gmt() { a__git_merge_tool "${@}"; } +a__git_merge_tool() { git \ mergetool \ "${@}" } # push to the remote repository -gp() { sa__git_push "${@}"; } -sa__git_push() { +gp() { a__git_push "${@}"; } +a__git_push() { git \ push \ --tags \ @@ -379,8 +379,8 @@ sa__git_push() { } # delete from the remote repository -gpd() { sa__git_push_delete "${@}"; } -sa__git_push_delete() { +gpd() { a__git_push_delete "${@}"; } +a__git_push_delete() { git \ push \ --delete \ @@ -388,24 +388,24 @@ sa__git_push_delete() { } # force the push to the remote repository -gpf() { sa__git_push_force "${@}"; } -sa__git_push_force() { - sa__git_push \ +gpf() { a__git_push_force "${@}"; } +a__git_push_force() { + a__git_push \ --force \ "${@}" } # rebase current branch onto another -grb() { sa__git_re_base "${@}"; } -sa__git_re_base() { +grb() { a__git_re_base "${@}"; } +a__git_re_base() { git \ rebase \ "${@}" } # abort current rebase -grba() { sa__git_re_base_abort "${@}"; } -sa__git_re_base_abort() { +grba() { a__git_re_base_abort "${@}"; } +a__git_re_base_abort() { git \ rebase \ --abort \ @@ -413,8 +413,8 @@ sa__git_re_base_abort() { } # continue current rebase -grbc() { sa__git_re_base_continue "${@}"; } -sa__git_re_base_continue() { +grbc() { a__git_re_base_continue "${@}"; } +a__git_re_base_continue() { git \ rebase \ --continue \ @@ -422,8 +422,8 @@ sa__git_re_base_continue() { } # force rebase without fast-forward -grbf() { sa__git_re_base_force "${@}"; } -sa__git_re_base_force() { +grbf() { a__git_re_base_force "${@}"; } +a__git_re_base_force() { git \ rebase \ --force-rebase \ @@ -431,8 +431,8 @@ sa__git_re_base_force() { } # rebase interactively -grbi() { sa__git_re_base_interactive "${@}"; } -sa__git_re_base_interactive() { +grbi() { a__git_re_base_interactive "${@}"; } +a__git_re_base_interactive() { git \ rebase \ --interactive \ @@ -440,8 +440,8 @@ sa__git_re_base_interactive() { } # add a new remote repository -grma() { sa__git_re_mote_add "${@}"; } -sa__git_re_mote_add() { +grma() { a__git_re_mote_add "${@}"; } +a__git_re_mote_add() { git \ remote \ add \ @@ -449,8 +449,8 @@ sa__git_re_mote_add() { } # list remote repositories -grml() { sa__git_re_mote_list "${@}"; } -sa__git_re_mote_list() { +grml() { a__git_re_mote_list "${@}"; } +a__git_re_mote_list() { git \ remote \ --verbose \ @@ -458,8 +458,8 @@ sa__git_re_mote_list() { } # set the location of a remote repository -grmsu() { sa__git_re_mote_set_upstream "${@}"; } -sa__git_re_mote_set_upstream() { +grmsu() { a__git_re_mote_set_upstream "${@}"; } +a__git_re_mote_set_upstream() { git \ remote \ set-url \ @@ -467,8 +467,8 @@ sa__git_re_mote_set_upstream() { } # show connection to a remote repository -grms() { sa__git_re_mote_show "${@}"; } -sa__git_re_mote_show() { +grms() { a__git_re_mote_show "${@}"; } +a__git_re_mote_show() { git \ remote \ show \ @@ -476,24 +476,24 @@ sa__git_re_mote_show() { } # remove and add removal to index -grm() { sa__git_re_move "${@}"; } -sa__git_re_move() { +grm() { a__git_re_move "${@}"; } +a__git_re_move() { git \ rm \ "${@}" } # remove file(s) from index or move current branch pointer -grs() { sa__git_re_set "${@}"; } -sa__git_re_set() { +grs() { a__git_re_set "${@}"; } +a__git_re_set() { git \ reset \ "${@}" } # wipe modifications or reset current branch to another commit -grsh() { sa__git_re_set_hard "${@}"; } -sa__git_re_set_hard() { +grsh() { a__git_re_set_hard "${@}"; } +a__git_re_set_hard() { git \ reset \ --hard \ @@ -501,16 +501,16 @@ sa__git_re_set_hard() { } # show a commit -gsc() { sa__git_show_commit "${@}"; } -sa__git_show_commit() { +gsc() { a__git_show_commit "${@}"; } +a__git_show_commit() { git \ show \ "${@}" } # current state of repository -gs() { sa__git_status "${@}"; } -sa__git_status() { +gs() { a__git_status "${@}"; } +a__git_status() { git \ status \ --untracked-files="all" \ @@ -518,16 +518,16 @@ sa__git_status() { } # tag a commit -gt() { sa__git_tag "${@}"; } -sa__git_tag() { +gt() { a__git_tag "${@}"; } +a__git_tag() { git \ tag \ "${@}" } # delete a tag -gtd() { sa__git_tag_delete "${@}"; } -sa__git_tag_delete() { +gtd() { a__git_tag_delete "${@}"; } +a__git_tag_delete() { git \ tag \ --delete \ diff --git a/sh/alias/gpg.sh b/sh/alias/gpg.sh index 30ece71..496b05e 100644 --- a/sh/alias/gpg.sh +++ b/sh/alias/gpg.sh @@ -1,13 +1,13 @@ # turn gpg agent off -gak() { sa__gpg_agent_kill "${@}"; } -sa__gpg_agent_kill() { +gak() { a__gpg_agent_kill "${@}"; } +a__gpg_agent_kill() { gpgconf \ --kill "gpg-agent" } # bind gpg agent to current tty -gau() { sa__gpg_agent_update "${@}"; } -sa__gpg_agent_update() { +gau() { a__gpg_agent_update "${@}"; } +a__gpg_agent_update() { gpg-connect-agent \ updatestartuptty \ /bye diff --git a/sh/alias/grep.sh b/sh/alias/grep.sh index d479936..5b00ed7 100644 --- a/sh/alias/grep.sh +++ b/sh/alias/grep.sh @@ -1,6 +1,6 @@ # grep from current directory with regex -g() { sa__grep "${@}"; } -sa__grep() { +g() { a__grep "${@}"; } +a__grep() { grep \ --directories "recurse" \ --line-number \ diff --git a/sh/alias/kill.sh b/sh/alias/kill.sh index 1900a2d..718a307 100644 --- a/sh/alias/kill.sh +++ b/sh/alias/kill.sh @@ -1,13 +1,13 @@ # kill a process by id -k() { sa__kill "${@}"; } -sa__kill() { +k() { a__kill "${@}"; } +a__kill() { kill \ "${@}" } # force kill a process by id -kf() { sa__kill_force "${@}"; } -sa__kill_force() { +kf() { a__kill_force "${@}"; } +a__kill_force() { kill \ -9 \ "${@}" diff --git a/sh/alias/killall.sh b/sh/alias/killall.sh index b12e515..6658065 100644 --- a/sh/alias/killall.sh +++ b/sh/alias/killall.sh @@ -1,13 +1,13 @@ # kill all instances of a process by name -ka() { sa__kill_all "${@}"; } -sa__kill_all() { +ka() { a__kill_all "${@}"; } +a__kill_all() { killall \ "${@}" } # force kill all instances of a process by name -kaf() { sa__kill_all_force "${@}"; } -sa__kill_all_force() { +kaf() { a__kill_all_force "${@}"; } +a__kill_all_force() { killall \ -9 \ "${@}" diff --git a/sh/alias/ls.sh b/sh/alias/ls.sh index 5c90ee5..ad5a809 100644 --- a/sh/alias/ls.sh +++ b/sh/alias/ls.sh @@ -3,8 +3,8 @@ di=0;94\ " # list current directory’s entries -l() { sa__ls "${@}"; } -sa__ls() { +l() { a__ls "${@}"; } +a__ls() { ls \ --all \ --color \ @@ -15,17 +15,17 @@ sa__ls() { } # list timestamps -lt() { sa__ls_time "${@}"; } -sa__ls_time() { - sa__ls \ +lt() { a__ls_time "${@}"; } +a__ls_time() { + a__ls \ --time-style "+%Y%m%d-%H%M%S%-:::z" \ "${@}" } # list timestamps recent last -ltr() { sa__ls_time_reverse "${@}"; } -sa__ls_time_reverse() { - sa__ls_time \ +ltr() { a__ls_time_reverse "${@}"; } +a__ls_time_reverse() { + a__ls_time \ --reverse \ -t \ "${@}" diff --git a/sh/alias/lsblk.sh b/sh/alias/lsblk.sh index 359f5ae..43dffc6 100644 --- a/sh/alias/lsblk.sh +++ b/sh/alias/lsblk.sh @@ -1,7 +1,7 @@ # list block devices -lb() { sa__list_block "${@}"; } -sa__list_block() { - sa__list_block_output \ +lb() { a__list_block "${@}"; } +a__list_block() { + a__list_block_output \ "SIZE" \ "TYPE" \ "FSTYPE" \ @@ -11,21 +11,21 @@ sa__list_block() { } # base arguments -lbne() { sa__list_block_no_empty "${@}"; } -sa__list_block_no_empty() { +lbne() { a__list_block_no_empty "${@}"; } +a__list_block_no_empty() { lsblk \ --noempty \ "${@}" } # output arguments -lbo() { sa__list_block_output "${@}"; } -sa__list_block_output() { +lbo() { a__list_block_output "${@}"; } +a__list_block_output() { local argument local arguments="NAME" for argument in "${@}"; do arguments="${arguments},${argument}" done - sa__list_block_no_empty \ + a__list_block_no_empty \ --output "${arguments}" } diff --git a/sh/alias/mkdir.sh b/sh/alias/mkdir.sh index b8821a5..bebc665 100644 --- a/sh/alias/mkdir.sh +++ b/sh/alias/mkdir.sh @@ -1,13 +1,13 @@ # make a directory -md() { sa__make_directory "${@}"; } -sa__make_directory() { +md() { a__make_directory "${@}"; } +a__make_directory() { mkdir \ "${@}" } # make a directory after making its parents -mdp() { sa__make_directory_parents "${@}"; } -sa__make_directory_parents() { +mdp() { a__make_directory_parents "${@}"; } +a__make_directory_parents() { mkdir \ --parents \ "${@}" diff --git a/sh/alias/mount.sh b/sh/alias/mount.sh index b5329a9..535910e 100644 --- a/sh/alias/mount.sh +++ b/sh/alias/mount.sh @@ -1,5 +1,5 @@ -m() { sa__mount "${@}"; } -sa__mount() { +m() { a__mount "${@}"; } +a__mount() { mount \ "${@}" } diff --git a/sh/alias/mv.sh b/sh/alias/mv.sh index 8f8bffd..0630042 100644 --- a/sh/alias/mv.sh +++ b/sh/alias/mv.sh @@ -1,6 +1,6 @@ # move interactively -mvi() { sa__mo_ve_interactive "${@}"; } -sa__mo_ve_interactive() { +mvi() { a__mo_ve_interactive "${@}"; } +a__mo_ve_interactive() { mv \ --interactive \ "${@}" diff --git a/sh/alias/nano.sh b/sh/alias/nano.sh index b7cad2c..7570cda 100644 --- a/sh/alias/nano.sh +++ b/sh/alias/nano.sh @@ -1,5 +1,5 @@ -nn() { sa__na_no "${@}"; } -sa__na_no() { +nn() { a__na_no "${@}"; } +a__na_no() { nano \ "${@}" } diff --git a/sh/alias/newsboat.sh b/sh/alias/newsboat.sh index e061d63..6c08c90 100644 --- a/sh/alias/newsboat.sh +++ b/sh/alias/newsboat.sh @@ -1,5 +1,5 @@ -nb() { sa__news_boat "${@}"; } -sa__news_boat() { +nb() { a__news_boat "${@}"; } +a__news_boat() { newsboat \ "${@}" } diff --git a/sh/alias/pass.sh b/sh/alias/pass.sh index 6e3a4da..66cad55 100644 --- a/sh/alias/pass.sh +++ b/sh/alias/pass.sh @@ -1,13 +1,13 @@ # display pass entry’s content -p() { sa__pass "${@}"; } -sa__pass() { +p() { a__pass "${@}"; } +a__pass() { pass \ "${@}" } # copy passphrase into clipboard -pc() { sa__pass_clip "${@}"; } -sa__pass_clip() { +pc() { a__pass_clip "${@}"; } +a__pass_clip() { pass \ --clip \ "${@}" diff --git a/sh/alias/pgrep.sh b/sh/alias/pgrep.sh index 9350d6e..72de025 100644 --- a/sh/alias/pgrep.sh +++ b/sh/alias/pgrep.sh @@ -1,6 +1,6 @@ # look for a string in processes names -pg() { sa__proc_grep "${@}"; } -sa__proc_grep() { +pg() { a__proc_grep "${@}"; } +a__proc_grep() { pgrep \ --list-full \ "${@}" diff --git a/sh/alias/pwgen.sh b/sh/alias/pwgen.sh index a2cfcc7..3b3dc83 100644 --- a/sh/alias/pwgen.sh +++ b/sh/alias/pwgen.sh @@ -1,6 +1,6 @@ # generate passwords -pwg() { sa__pass_word_gen "${@}"; } -sa__pass_word_gen() { +pwg() { a__pass_word_gen "${@}"; } +a__pass_word_gen() { pwgen \ -1 \ --num-passwords 1048576 \ @@ -9,9 +9,9 @@ sa__pass_word_gen() { } # generate passwords with symbols -pwgs() { sa__pass_word_gen_symbols "${@}"; } -sa__pass_word_gen_symbols() { - sa__pass_word_gen \ +pwgs() { a__pass_word_gen_symbols "${@}"; } +a__pass_word_gen_symbols() { + a__pass_word_gen \ --symbols \ "${@}" } diff --git a/sh/alias/rm.sh b/sh/alias/rm.sh index ca6bd11..9634c1b 100644 --- a/sh/alias/rm.sh +++ b/sh/alias/rm.sh @@ -1,6 +1,6 @@ # remove interactively -rmi() { sa__re_move_interactive "${@}"; } -sa__re_move_interactive() { +rmi() { a__re_move_interactive "${@}"; } +a__re_move_interactive() { rm \ --interactive \ "${@}" diff --git a/sh/alias/rsync.sh b/sh/alias/rsync.sh index 773d317..bdbe4ed 100644 --- a/sh/alias/rsync.sh +++ b/sh/alias/rsync.sh @@ -1,6 +1,6 @@ # synchronize -rs() { sa__r_sync "${@}"; } -sa__r_sync() { +rs() { a__r_sync "${@}"; } +a__r_sync() { rsync \ --archive \ --no-inc-recursive \ @@ -11,17 +11,17 @@ sa__r_sync() { } # synchronize and delete after -rsda() { sa__r_sync_delete_after "${@}"; } -sa__r_sync_delete_after() { - sa__r_sync \ +rsda() { a__r_sync_delete_after "${@}"; } +a__r_sync_delete_after() { + a__r_sync \ --delete-after \ "${@}" } # synchronize and delete before -rsdb() { sa__r_sync_delete_before "${@}"; } -sa__r_sync_delete_before() { - sa__r_sync \ +rsdb() { a__r_sync_delete_before "${@}"; } +a__r_sync_delete_before() { + a__r_sync \ --delete-before \ "${@}" } diff --git a/sh/alias/tar.sh b/sh/alias/tar.sh index 6cebb0d..92b8fbf 100644 --- a/sh/alias/tar.sh +++ b/sh/alias/tar.sh @@ -1,30 +1,30 @@ -tc() { sa__tar_create "${@}"; } -sa__tar_create() { - sa__tar_verbose \ +tc() { a__tar_create "${@}"; } +a__tar_create() { + a__tar_verbose \ --create \ --auto-compress \ --file \ "${@}" } -tl() { sa__tar_list "${@}"; } -sa__tar_list() { - sa__tar_verbose \ +tl() { a__tar_list "${@}"; } +a__tar_list() { + a__tar_verbose \ --list \ --file \ "${@}" } -tv() { sa__tar_verbose "${@}"; } -sa__tar_verbose() { +tv() { a__tar_verbose "${@}"; } +a__tar_verbose() { tar \ --verbose \ "${@}" } -tx() { sa__tar_xtract "${@}"; } -sa__tar_xtract() { - sa__tar_verbose \ +tx() { a__tar_xtract "${@}"; } +a__tar_xtract() { + a__tar_verbose \ --extract \ --file \ "${@}" diff --git a/sh/alias/tmux.sh b/sh/alias/tmux.sh index 57d6053..b30dc79 100644 --- a/sh/alias/tmux.sh +++ b/sh/alias/tmux.sh @@ -1,5 +1,5 @@ -tm() { sa__t_mux "${@}"; } -sa__t_mux() { +tm() { a__t_mux "${@}"; } +a__t_mux() { tmux \ "${@}" } diff --git a/sh/alias/tree.sh b/sh/alias/tree.sh index d172896..03be3de 100644 --- a/sh/alias/tree.sh +++ b/sh/alias/tree.sh @@ -1,11 +1,11 @@ -t() { sa__tree "${@}"; } -sa__tree() { +t() { a__tree "${@}"; } +a__tree() { tree \ "${@}" } -ta() { sa__tree_all "${@}"; } -sa__tree_all() { +ta() { a__tree_all "${@}"; } +a__tree_all() { tree \ -a \ "${@}" From 07483cdadf37bb7c7822fbc21928538168b50490 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 16:15:12 +0100 Subject: [PATCH 789/969] sh_shell --- sh/sh.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sh/sh.sh b/sh/sh.sh index 6fab8a6..a1dc2d1 100644 --- a/sh/sh.sh +++ b/sh/sh.sh @@ -1,11 +1,12 @@ PS1="\$(shell_prompt \${?})" PS2="\ ├ " -SH="$(cat /proc/$$/comm)" + +SH_SHELL="$(cat /proc/$$/comm)" shell_color() { local code="${1}" - case "${SH}" in + case "${SH_SHELL}" in "bash") printf "\x01\e[0" if [ -n "${code}" ]; then @@ -32,7 +33,7 @@ SH_MAGENTA="$(shell_color 35)" SH_RED="$(shell_color 32)" shell_configure() { - case "${SH}" in + case "${SH_SHELL}" in "bash") # completion local root="/usr/share/bash-completion" @@ -140,7 +141,7 @@ x() { "${@}" } -[ "${SH}" = "bash" ] || return +[ "${SH_SHELL}" = "bash" ] || return # shellcheck disable=SC3033 ..() { From 9da45266c4e82c137af9c735c2f8d954f8f6de0a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 16:22:07 +0100 Subject: [PATCH 790/969] sh_shell --- sh/alias/shell.sh | 30 ++++++++++++++++++++++++++++++ sh/main.sh | 2 ++ sh/sh.sh | 32 -------------------------------- 3 files changed, 32 insertions(+), 32 deletions(-) create mode 100644 sh/alias/shell.sh diff --git a/sh/alias/shell.sh b/sh/alias/shell.sh new file mode 100644 index 0000000..8f6684c --- /dev/null +++ b/sh/alias/shell.sh @@ -0,0 +1,30 @@ +# shorten alias +a() { + alias \ + "${@}" +} + +# swap directory (current ↔ previous) +sd() { + cd \ + - || + return +} + +# exit terminal +x() { + exit \ + "${@}" +} + +# shellcheck disable=SC2154 +[ "${SH_SHELL}" = "bash" ] || return + +# shellcheck disable=SC3033 +..() { + cd .. +} +# shellcheck disable=SC3033 +...() { + cd ../.. +} diff --git a/sh/main.sh b/sh/main.sh index 387b1b3..6369d05 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -1,4 +1,6 @@ SH_NAME="sh" +SH_SHELL="$(cat /proc/$$/comm)" +export SH_SHELL SH_ROOT="/etc/${SH_NAME}" SH_USER="${HOME}/${SH_NAME}" diff --git a/sh/sh.sh b/sh/sh.sh index a1dc2d1..39dee54 100644 --- a/sh/sh.sh +++ b/sh/sh.sh @@ -2,8 +2,6 @@ PS1="\$(shell_prompt \${?})" PS2="\ ├ " -SH_SHELL="$(cat /proc/$$/comm)" - shell_color() { local code="${1}" case "${SH_SHELL}" in @@ -121,33 +119,3 @@ shell_setup() { rm --force --recursive "${file}" ln --symbolic "${ENV}" "${file}" } - -# shorten alias -a() { - alias \ - "${@}" -} - -# swap directory (current ↔ previous) -sd() { - cd \ - - || - return -} - -# exit terminal -x() { - exit \ - "${@}" -} - -[ "${SH_SHELL}" = "bash" ] || return - -# shellcheck disable=SC3033 -..() { - cd .. -} -# shellcheck disable=SC3033 -...() { - cd ../.. -} From f2544c4243a8f42486f06d23496d7f4d15591152 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 16:22:29 +0100 Subject: [PATCH 791/969] shell --- sh/{sh.sh => shell.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{sh.sh => shell.sh} (100%) diff --git a/sh/sh.sh b/sh/shell.sh similarity index 100% rename from sh/sh.sh rename to sh/shell.sh From aa1226f8f4bf0eb64b5ded1c2ec2f2231b5fafbe Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 16:38:20 +0100 Subject: [PATCH 792/969] _sh_shell_color --- sh/shell.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sh/shell.sh b/sh/shell.sh index 39dee54..4a2c6ea 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -2,7 +2,7 @@ PS1="\$(shell_prompt \${?})" PS2="\ ├ " -shell_color() { +_sh_shell_color() { local code="${1}" case "${SH_SHELL}" in "bash") @@ -23,12 +23,12 @@ shell_color() { ;; esac } -SH_BROWN="$(shell_color 33)" -SH_CYAN="$(shell_color 36)" -SH_DEFAULT="$(shell_color)" -SH_GREEN="$(shell_color 31)" -SH_MAGENTA="$(shell_color 35)" -SH_RED="$(shell_color 32)" +SH_BROWN="$(_sh_shell_color 33)" +SH_CYAN="$(_sh_shell_color 36)" +SH_DEFAULT="$(_sh_shell_color)" +SH_GREEN="$(_sh_shell_color 31)" +SH_MAGENTA="$(_sh_shell_color 35)" +SH_RED="$(_sh_shell_color 32)" shell_configure() { case "${SH_SHELL}" in From 321d55a8230d1700b3c3e438414b9d9d301786bb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 16:40:11 +0100 Subject: [PATCH 793/969] sh_shell_prompt --- sh/shell.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/shell.sh b/sh/shell.sh index 4a2c6ea..4fcc895 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -1,4 +1,4 @@ -PS1="\$(shell_prompt \${?})" +PS1="\$(sh_shell_prompt \${?})" PS2="\ ├ " @@ -58,7 +58,7 @@ shell_configure() { } shell_configure -shell_prompt() { +sh_shell_prompt() { local date host id local code="${1}" date="$(date +%H:%M:%S)" From aaa530295ee10522de2c00c84ff2ef8a54baebae Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 09:18:40 +0100 Subject: [PATCH 794/969] mv --- sh/{cmd => }/gnome.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cmd => }/gnome.sh (100%) diff --git a/sh/cmd/gnome.sh b/sh/gnome.sh similarity index 100% rename from sh/cmd/gnome.sh rename to sh/gnome.sh From 04f64f68a87f18c6ddadbc9cb4c364faf7a5ee86 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 09:27:41 +0100 Subject: [PATCH 795/969] debian --- sh/debian.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sh/debian.sh b/sh/debian.sh index 39639b9..b544f08 100644 --- a/sh/debian.sh +++ b/sh/debian.sh @@ -1,4 +1,4 @@ -DEBIAN_CODENAME="$( +SH_DEBIAN_CODENAME="$( grep "VERSION_CODENAME" "/etc/os-release" | cut --delimiter "=" --fields "2" )" @@ -23,11 +23,11 @@ Dpkg::Progress True; } sh_apt_install_backports() { - sh_apt_install_target "${DEBIAN_CODENAME}-backports" "${@}" + sh_apt_install_target "${SH_DEBIAN_CODENAME}-backports" "${@}" } sh_apt_install_release() { - sh_apt_install_target "${DEBIAN_CODENAME}" "${@}" + sh_apt_install_target "${SH_DEBIAN_CODENAME}" "${@}" } sh_apt_install_target() { @@ -49,13 +49,13 @@ sh_apt_install_target() { sh_apt_sources_write() { printf "%s" "\ deb https://deb.debian.org/debian \ -${DEBIAN_CODENAME} main non-free-firmware contrib non-free +${SH_DEBIAN_CODENAME} main non-free-firmware contrib non-free deb https://deb.debian.org/debian \ -${DEBIAN_CODENAME}-backports main non-free-firmware contrib non-free +${SH_DEBIAN_CODENAME}-backports main non-free-firmware contrib non-free deb https://deb.debian.org/debian \ -${DEBIAN_CODENAME}-updates main non-free-firmware contrib non-free +${SH_DEBIAN_CODENAME}-updates main non-free-firmware contrib non-free deb https://deb.debian.org/debian-security \ -${DEBIAN_CODENAME}-security main non-free-firmware contrib non-free +${SH_DEBIAN_CODENAME}-security main non-free-firmware contrib non-free " >"/etc/apt/sources.list" } From c641c95c0d61b6b3fae587609e030dff60534342 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 09:31:53 +0100 Subject: [PATCH 796/969] luks_format --- sh/fs.sh | 2 +- sh/rescue/hetzner.sh | 4 ++-- sh/rescue/ovh.sh | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sh/fs.sh b/sh/fs.sh index 2635ce0..67bd2a5 100644 --- a/sh/fs.sh +++ b/sh/fs.sh @@ -93,7 +93,7 @@ fs_wipe() { fi } -luks_format() { +sh_fs_luks_format() { local passphrase="${1}" local device="${2}" local label="${3}" diff --git a/sh/rescue/hetzner.sh b/sh/rescue/hetzner.sh index 80d901b..5f27eaa 100644 --- a/sh/rescue/hetzner.sh +++ b/sh/rescue/hetzner.sh @@ -92,7 +92,7 @@ rescue_wipe_0_init_hetzner_8_8() { fs_raid_create \ "crypt" "00000000:00000000:00000000:00000001" ${members} # encrypt - luks_format "${passphrase}" "/dev/md/crypt" + sh_fs_luks_format "${passphrase}" "/dev/md/crypt" # open echo "${passphrase}" | cryptsetup luksOpen "/dev/md/crypt" "crypt" @@ -107,7 +107,7 @@ rescue_wipe_2_make_hetzner_8_8() { # read passphrase passphrase="$(read_passphrase)" # encrypt - luks_format "${passphrase}" "/dev/md/crypt" + sh_fs_luks_format "${passphrase}" "/dev/md/crypt" # open echo "${passphrase}" | cryptsetup luksOpen "/dev/md/crypt" "crypt" diff --git a/sh/rescue/ovh.sh b/sh/rescue/ovh.sh index b12c50b..333e365 100644 --- a/sh/rescue/ovh.sh +++ b/sh/rescue/ovh.sh @@ -36,7 +36,7 @@ rescue_wipe_0_init_ovh_vle2() { # crypt / wipe fs_wipe "${device}1" "1G" 1 # crypt / encrypt - luks_format "${passphrase}" "${device}1" + sh_fs_luks_format "${passphrase}" "${device}1" # crypt / open echo "${passphrase}" | cryptsetup luksOpen "${device}1" "crypt" @@ -52,7 +52,7 @@ rescue_wipe_2_make_ovh_vle2() { # read passphrase passphrase="$(read_passphrase)" # crypt / encrypt - luks_format "${passphrase}" "${device}1" + sh_fs_luks_format "${passphrase}" "${device}1" # crypt / open echo "${passphrase}" | cryptsetup luksOpen "${device}1" "crypt" From ce6ca845bc6d3e2b9878f0aecc0b63a0a066e76a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 09:34:45 +0100 Subject: [PATCH 797/969] fs_wipe --- sh/fs.sh | 2 +- sh/rescue/common.sh | 2 +- sh/rescue/hetzner.sh | 8 ++++---- sh/rescue/ovh.sh | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sh/fs.sh b/sh/fs.sh index 67bd2a5..46fe414 100644 --- a/sh/fs.sh +++ b/sh/fs.sh @@ -72,7 +72,7 @@ fs_raid_create() { fi } -fs_wipe() { +sh_fs_wipe() { local device="${1}" local buffer="${2}" local count="${3}" diff --git a/sh/rescue/common.sh b/sh/rescue/common.sh index b108681..d28591b 100644 --- a/sh/rescue/common.sh +++ b/sh/rescue/common.sh @@ -84,7 +84,7 @@ rescue_upload() { } rescue_wipe_1_zero() { - fs_wipe "/dev/mapper/crypt" "512M" + sh_fs_wipe "/dev/mapper/crypt" "512M" } rescue_wipe_3_close() { diff --git a/sh/rescue/hetzner.sh b/sh/rescue/hetzner.sh index 5f27eaa..3e95ba3 100644 --- a/sh/rescue/hetzner.sh +++ b/sh/rescue/hetzner.sh @@ -34,7 +34,7 @@ rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}4" # wipe bios - fs_wipe "${device}4" + sh_fs_wipe "${device}4" done # number=0 @@ -43,7 +43,7 @@ rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}3" # format esp - fs_wipe "${device}3" "1M" + sh_fs_wipe "${device}3" "1M" fs_make_fat "${device}3" "esp-${number}" "0000000${number}" # mount esp mkdir --parents "/media/esp/${number}" @@ -56,7 +56,7 @@ rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}2" # wipe boot - fs_wipe "${device}2" "1G" 1 + sh_fs_wipe "${device}2" "1G" 1 done # members="" @@ -81,7 +81,7 @@ rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}1" # wipe crypt head - fs_wipe "${device}1" "1G" 1 + sh_fs_wipe "${device}1" "1G" 1 done # members="" diff --git a/sh/rescue/ovh.sh b/sh/rescue/ovh.sh index 333e365..732b045 100644 --- a/sh/rescue/ovh.sh +++ b/sh/rescue/ovh.sh @@ -16,16 +16,16 @@ rescue_wipe_0_init_ovh_vle2() { mkpart bios 1 2 \ set 4 bios_grub on # bios / wipe - fs_wipe "${device}4" + sh_fs_wipe "${device}4" # esp / wipe - fs_wipe "${device}3" "1M" + sh_fs_wipe "${device}3" "1M" # esp / format fs_make_fat "${device}3" "esp" "00000001" # esp / mount mkdir --parents "/media/esp" mount "${device}3" "/media/esp" # boot / wipe - fs_wipe "${device}2" "1G" 1 + sh_fs_wipe "${device}2" "1G" 1 # boot / format fs_make_btrfs "${device}2" "boot" \ "00000000-0000-0000-0000-00000000000b" @@ -34,7 +34,7 @@ rescue_wipe_0_init_ovh_vle2() { mount --options "autodefrag,compress-force=zstd" \ "${device}2" "/media/boot" # crypt / wipe - fs_wipe "${device}1" "1G" 1 + sh_fs_wipe "${device}1" "1G" 1 # crypt / encrypt sh_fs_luks_format "${passphrase}" "${device}1" # crypt / open From 1dfebbc35a8f4f5c6558837ecc931519960843ec Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 09:35:47 +0100 Subject: [PATCH 798/969] raid_create --- sh/fs.sh | 2 +- sh/rescue/hetzner.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/fs.sh b/sh/fs.sh index 46fe414..fb3db50 100644 --- a/sh/fs.sh +++ b/sh/fs.sh @@ -56,7 +56,7 @@ fs_make_fat() { fi } -fs_raid_create() { +sh_fs_raid_create() { if [ -n "${4}" ]; then local name="${1}" local uuid="${2}" diff --git a/sh/rescue/hetzner.sh b/sh/rescue/hetzner.sh index 3e95ba3..f5283f2 100644 --- a/sh/rescue/hetzner.sh +++ b/sh/rescue/hetzner.sh @@ -64,7 +64,7 @@ rescue_wipe_0_init_hetzner_8_8() { members="${members} ${device}2" done # shellcheck disable=SC2086 - fs_raid_create \ + sh_fs_raid_create \ "boot" "00000000:00000000:00000000:00000002" ${members} # fs_make_btrfs "/dev/md/boot" "boot" \ @@ -89,7 +89,7 @@ rescue_wipe_0_init_hetzner_8_8() { members="${members} ${device}1" done # shellcheck disable=SC2086 - fs_raid_create \ + sh_fs_raid_create \ "crypt" "00000000:00000000:00000000:00000001" ${members} # encrypt sh_fs_luks_format "${passphrase}" "/dev/md/crypt" From beb4695b29d92c8d0b5dff55375d3c7b955609d6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 09:37:07 +0100 Subject: [PATCH 799/969] make_fat --- sh/fs.sh | 2 +- sh/rescue/hetzner.sh | 2 +- sh/rescue/ovh.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/fs.sh b/sh/fs.sh index fb3db50..6cc85ff 100644 --- a/sh/fs.sh +++ b/sh/fs.sh @@ -36,7 +36,7 @@ fs_make_btrfs_swap() { fi } -fs_make_fat() { +sh_fs_make_fat() { local device="${1}" local name="${2}" local volid="${3}" diff --git a/sh/rescue/hetzner.sh b/sh/rescue/hetzner.sh index f5283f2..9de0134 100644 --- a/sh/rescue/hetzner.sh +++ b/sh/rescue/hetzner.sh @@ -44,7 +44,7 @@ rescue_wipe_0_init_hetzner_8_8() { echo "#${number}: ${device}3" # format esp sh_fs_wipe "${device}3" "1M" - fs_make_fat "${device}3" "esp-${number}" "0000000${number}" + sh_fs_make_fat "${device}3" "esp-${number}" "0000000${number}" # mount esp mkdir --parents "/media/esp/${number}" mount "${device}3" "/media/esp/${number}" diff --git a/sh/rescue/ovh.sh b/sh/rescue/ovh.sh index 732b045..117ac5e 100644 --- a/sh/rescue/ovh.sh +++ b/sh/rescue/ovh.sh @@ -20,7 +20,7 @@ rescue_wipe_0_init_ovh_vle2() { # esp / wipe sh_fs_wipe "${device}3" "1M" # esp / format - fs_make_fat "${device}3" "esp" "00000001" + sh_fs_make_fat "${device}3" "esp" "00000001" # esp / mount mkdir --parents "/media/esp" mount "${device}3" "/media/esp" From 844b2f21d3c598d10b10c4261efc8c7135c7f0d0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 09:38:22 +0100 Subject: [PATCH 800/969] btrfs_swap --- sh/fs.sh | 2 +- sh/rescue/hetzner.sh | 2 +- sh/rescue/ovh.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/fs.sh b/sh/fs.sh index 6cc85ff..fa0657f 100644 --- a/sh/fs.sh +++ b/sh/fs.sh @@ -18,7 +18,7 @@ fs_make_btrfs() { fi } -fs_make_btrfs_swap() { +sh_fs_make_btrfs_swap() { local path="${1}" local size="${2}" local uuid="${3}" diff --git a/sh/rescue/hetzner.sh b/sh/rescue/hetzner.sh index 9de0134..b541b26 100644 --- a/sh/rescue/hetzner.sh +++ b/sh/rescue/hetzner.sh @@ -122,6 +122,6 @@ rescue_wipe_2_make_hetzner_8_8() { --options "autodefrag,compress-force=zstd" \ "/dev/mapper/crypt" "/media/crypt" # make swap file - fs_make_btrfs_swap "/media/crypt/swap" "64g" \ + sh_fs_make_btrfs_swap "/media/crypt/swap" "64g" \ "00000000-0000-0000-0000-000000000005" } diff --git a/sh/rescue/ovh.sh b/sh/rescue/ovh.sh index 117ac5e..3127564 100644 --- a/sh/rescue/ovh.sh +++ b/sh/rescue/ovh.sh @@ -66,6 +66,6 @@ rescue_wipe_2_make_ovh_vle2() { mount --options "autodefrag,compress-force=zstd" \ "/dev/mapper/crypt" "/media/crypt" # crypt / swap - fs_make_btrfs_swap "/media/crypt/swap" "4g" \ + sh_fs_make_btrfs_swap "/media/crypt/swap" "4g" \ "00000000-0000-0000-0000-000000000005" } From dc0540c4ca57cb2e8f742b7fac95f0aee23ee93a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 09:40:58 +0100 Subject: [PATCH 801/969] make_btrfs --- sh/fs.sh | 2 +- sh/rescue/hetzner.sh | 4 ++-- sh/rescue/ovh.sh | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sh/fs.sh b/sh/fs.sh index fa0657f..95965e2 100644 --- a/sh/fs.sh +++ b/sh/fs.sh @@ -1,4 +1,4 @@ -fs_make_btrfs() { +sh_fs_make_btrfs() { local device="${1}" local label="${2}" local uuid="${3}" diff --git a/sh/rescue/hetzner.sh b/sh/rescue/hetzner.sh index b541b26..36dc2ea 100644 --- a/sh/rescue/hetzner.sh +++ b/sh/rescue/hetzner.sh @@ -67,7 +67,7 @@ rescue_wipe_0_init_hetzner_8_8() { sh_fs_raid_create \ "boot" "00000000:00000000:00000000:00000002" ${members} # - fs_make_btrfs "/dev/md/boot" "boot" \ + sh_fs_make_btrfs "/dev/md/boot" "boot" \ "00000000-0000-0000-0000-00000000000b" # mount boot mkdir --parents "/media/boot" @@ -114,7 +114,7 @@ rescue_wipe_2_make_hetzner_8_8() { # passphrase unset passphrase # format crypt - fs_make_btrfs "/dev/mapper/crypt" "crypt" \ + sh_fs_make_btrfs "/dev/mapper/crypt" "crypt" \ "00000000-0000-0000-0000-00000000000c" # mount crypt mkdir --parents "/media/crypt" diff --git a/sh/rescue/ovh.sh b/sh/rescue/ovh.sh index 3127564..4a54f64 100644 --- a/sh/rescue/ovh.sh +++ b/sh/rescue/ovh.sh @@ -27,7 +27,7 @@ rescue_wipe_0_init_ovh_vle2() { # boot / wipe sh_fs_wipe "${device}2" "1G" 1 # boot / format - fs_make_btrfs "${device}2" "boot" \ + sh_fs_make_btrfs "${device}2" "boot" \ "00000000-0000-0000-0000-00000000000b" # boot / mount mkdir --parents "/media/boot" @@ -59,7 +59,7 @@ rescue_wipe_2_make_ovh_vle2() { # passphrase unset passphrase # crypt / format - fs_make_btrfs "/dev/mapper/crypt" "crypt" \ + sh_fs_make_btrfs "/dev/mapper/crypt" "crypt" \ "00000000-0000-0000-0000-00000000000c" # crypt / mount mkdir --parents "/media/crypt" From 96f0697e37a7c8f8fd84670f041ccc0470815bc1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 09:42:44 +0100 Subject: [PATCH 802/969] {} --- sh/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/main.sh b/sh/main.sh index 6369d05..fa0c556 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -1,5 +1,5 @@ SH_NAME="sh" -SH_SHELL="$(cat /proc/$$/comm)" +SH_SHELL="$(cat /proc/${$}/comm)" export SH_SHELL SH_ROOT="/etc/${SH_NAME}" From 4cf578356242a5967d28e72907c4690aaf099a17 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 10:05:56 +0100 Subject: [PATCH 803/969] warn_wipe --- sh/rescue/hetzner.sh | 2 +- sh/rescue/ovh.sh | 2 +- sh/util.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/rescue/hetzner.sh b/sh/rescue/hetzner.sh index 36dc2ea..9de13db 100644 --- a/sh/rescue/hetzner.sh +++ b/sh/rescue/hetzner.sh @@ -9,7 +9,7 @@ rescue_wipe_0_init_hetzner_8_8() { # read passphrase passphrase="$(read_passphrase)" # warn - warn_wipe "${@}" + sh_warn_wipe "${@}" # number=0 for device in "${@}"; do diff --git a/sh/rescue/ovh.sh b/sh/rescue/ovh.sh index 4a54f64..e7e2ea8 100644 --- a/sh/rescue/ovh.sh +++ b/sh/rescue/ovh.sh @@ -4,7 +4,7 @@ rescue_wipe_0_init_ovh_vle2() { # read passphrase passphrase="$(read_passphrase)" # warn - warn_wipe "${device}" + sh_warn_wipe "${device}" # parted --script "${device}" \ mktable gpt \ diff --git a/sh/util.sh b/sh/util.sh index 2f2b400..05eb5d2 100644 --- a/sh/util.sh +++ b/sh/util.sh @@ -28,7 +28,7 @@ read_secret() { unset secret } -warn_wipe() { +sh_warn_wipe() { local tmp list_block_devices printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\" From c2a3a130d191f997c9d9c8fab5b4f0e86aa27d3a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 10:06:58 +0100 Subject: [PATCH 804/969] read_secret --- sh/util.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/util.sh b/sh/util.sh index 05eb5d2..5fb3178 100644 --- a/sh/util.sh +++ b/sh/util.sh @@ -13,10 +13,10 @@ not() { } read_passphrase() { - read_secret "PassPhrase: " + sh_read_secret "PassPhrase: " } -read_secret() { +sh_read_secret() { local prompt="${1}" local secret printf "%s" "${prompt}" 1>&2 From 6b45b885c70282af47340d83ecc54b209c59699b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 10:08:23 +0100 Subject: [PATCH 805/969] not --- sh/gnome.sh | 2 +- sh/util.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/gnome.sh b/sh/gnome.sh index c773ff8..ff15c10 100644 --- a/sh/gnome.sh +++ b/sh/gnome.sh @@ -16,7 +16,7 @@ sh_gnome_workspaces_primary() { bool="$(gsettings get "${group}" "${name}")" sh_log_debug "${var}: ${bool}" # not - bool="$(not "${bool}")" + bool="$(sh_not "${bool}")" sh_log_debug "bool: ${bool}" # set gsettings set "${group}" "${name}" "${bool}" diff --git a/sh/util.sh b/sh/util.sh index 5fb3178..e5f9c82 100644 --- a/sh/util.sh +++ b/sh/util.sh @@ -4,7 +4,7 @@ list_block_devices() { --output "NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINTS" } -not() { +sh_not() { case "${1}" in "false") echo "true" ;; "true") echo "false" ;; From 510ca5a5b35fe184a8e5ce3d26eabb303dd6607d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 10:09:40 +0100 Subject: [PATCH 806/969] read_passphrase --- sh/rescue/hetzner.sh | 4 ++-- sh/rescue/ovh.sh | 4 ++-- sh/util.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sh/rescue/hetzner.sh b/sh/rescue/hetzner.sh index 9de13db..8d7f02b 100644 --- a/sh/rescue/hetzner.sh +++ b/sh/rescue/hetzner.sh @@ -7,7 +7,7 @@ rescue_wipe_0_init_hetzner_8_8() { local number local passphrase # read passphrase - passphrase="$(read_passphrase)" + passphrase="$(sh_read_passphrase)" # warn sh_warn_wipe "${@}" # @@ -105,7 +105,7 @@ rescue_wipe_2_make_hetzner_8_8() { # close cryptsetup luksClose "crypt" # read passphrase - passphrase="$(read_passphrase)" + passphrase="$(sh_read_passphrase)" # encrypt sh_fs_luks_format "${passphrase}" "/dev/md/crypt" # open diff --git a/sh/rescue/ovh.sh b/sh/rescue/ovh.sh index e7e2ea8..0d3c860 100644 --- a/sh/rescue/ovh.sh +++ b/sh/rescue/ovh.sh @@ -2,7 +2,7 @@ rescue_wipe_0_init_ovh_vle2() { local device="/dev/sdb" local passphrase # read passphrase - passphrase="$(read_passphrase)" + passphrase="$(sh_read_passphrase)" # warn sh_warn_wipe "${device}" # @@ -50,7 +50,7 @@ rescue_wipe_2_make_ovh_vle2() { # crypt / close cryptsetup luksClose "crypt" # read passphrase - passphrase="$(read_passphrase)" + passphrase="$(sh_read_passphrase)" # crypt / encrypt sh_fs_luks_format "${passphrase}" "${device}1" # crypt / open diff --git a/sh/util.sh b/sh/util.sh index e5f9c82..0454ba8 100644 --- a/sh/util.sh +++ b/sh/util.sh @@ -12,7 +12,7 @@ sh_not() { esac } -read_passphrase() { +sh_read_passphrase() { sh_read_secret "PassPhrase: " } From 86db452e72c25e0ad76d0ae1ad61378eeb9e9fc7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 10:11:02 +0100 Subject: [PATCH 807/969] list_block_devices --- sh/util.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/util.sh b/sh/util.sh index 0454ba8..3f1c614 100644 --- a/sh/util.sh +++ b/sh/util.sh @@ -1,4 +1,4 @@ -list_block_devices() { +sh_list_block_devices() { lsblk \ --noempty \ --output "NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINTS" @@ -30,7 +30,7 @@ sh_read_secret() { sh_warn_wipe() { local tmp - list_block_devices + sh_list_block_devices printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\" read -r tmp sh_log_trace "${tmp}" From 942de1caed7e0c889fb70a8d9a82645ac14455ca Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 14:29:42 +0100 Subject: [PATCH 808/969] colors --- sh/shell.sh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/sh/shell.sh b/sh/shell.sh index 4fcc895..d56ca56 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -23,12 +23,12 @@ _sh_shell_color() { ;; esac } -SH_BROWN="$(_sh_shell_color 33)" -SH_CYAN="$(_sh_shell_color 36)" -SH_DEFAULT="$(_sh_shell_color)" -SH_GREEN="$(_sh_shell_color 31)" -SH_MAGENTA="$(_sh_shell_color 35)" -SH_RED="$(_sh_shell_color 32)" +SH_COLOR_BROWN="$(_sh_shell_color 33)" +SH_COLOR_CYAN="$(_sh_shell_color 36)" +SH_COLOR_DEFAULT="$(_sh_shell_color)" +SH_COLOR_GREEN="$(_sh_shell_color 31)" +SH_COLOR_MAGENTA="$(_sh_shell_color 35)" +SH_COLOR_RED="$(_sh_shell_color 32)" shell_configure() { case "${SH_SHELL}" in @@ -70,43 +70,43 @@ sh_shell_prompt() { local view="└ " # code if [ "${code}" -ne 0 ]; then - view="${view}${SH_GREEN}" + view="${view}${SH_COLOR_GREEN}" else - view="${view}${SH_RED}" + view="${view}${SH_COLOR_RED}" fi view="${view}${code}" # date - view="${view}${SH_DEFAULT} @ " - view="${view}${SH_BROWN}${date}" + view="${view}${SH_COLOR_DEFAULT} @ " + view="${view}${SH_COLOR_BROWN}${date}" # git if command -v "__git_ps1" >"/dev/null"; then git="$(__git_ps1)" if [ -n "${git}" ]; then - view="${view}${SH_DEFAULT} –${SH_MAGENTA}${git}" + view="${view}${SH_COLOR_DEFAULT} –${SH_COLOR_MAGENTA}${git}" fi fi # new view="${view}\\n" # path - view="${view}${SH_CYAN}${path}" + view="${view}${SH_COLOR_CYAN}${path}" # new view="${view}\\n" # frame - view="${view}${SH_DEFAULT}┌ " + view="${view}${SH_COLOR_DEFAULT}┌ " # user if [ "${id}" -eq 0 ]; then - view="${view}${SH_GREEN}" + view="${view}${SH_COLOR_GREEN}" else - view="${view}${SH_RED}" + view="${view}${SH_COLOR_RED}" fi view="${view}${user}" # host - view="${view}${SH_DEFAULT} @ " - view="${view}${SH_BROWN}${host}" + view="${view}${SH_COLOR_DEFAULT} @ " + view="${view}${SH_COLOR_BROWN}${host}" # new view="${view}\\n" # prompt - view="${view}${SH_DEFAULT}${PS2}" + view="${view}${SH_COLOR_DEFAULT}${PS2}" # print printf "%b" "${view}" } From cdc976db0b6bef2f355e26c6295d231f762a01a5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 14:36:41 +0100 Subject: [PATCH 809/969] shell_setup --- sh/shell.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/shell.sh b/sh/shell.sh index d56ca56..099c68d 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -111,7 +111,7 @@ sh_shell_prompt() { printf "%b" "${view}" } -shell_setup() { +sh_shell_setup() { # shell echo "export ENV=\"${ENV}\"" >"/etc/profile.d/sh.sh" # bash From 5ffc9fc84090e64ba01037a8340fc2d5f3d4c7d6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 14:39:01 +0100 Subject: [PATCH 810/969] shell_configure --- sh/shell.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sh/shell.sh b/sh/shell.sh index 099c68d..c4569d1 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -1,7 +1,3 @@ -PS1="\$(sh_shell_prompt \${?})" -PS2="\ -├ " - _sh_shell_color() { local code="${1}" case "${SH_SHELL}" in @@ -30,7 +26,7 @@ SH_COLOR_GREEN="$(_sh_shell_color 31)" SH_COLOR_MAGENTA="$(_sh_shell_color 35)" SH_COLOR_RED="$(_sh_shell_color 32)" -shell_configure() { +sh_shell_configure() { case "${SH_SHELL}" in "bash") # completion @@ -52,11 +48,14 @@ shell_configure() { HISTCONTROL="ignorespace" HISTSIZE=-1 HISTTIMEFORMAT="%Y%m%d %H%M%S " + # prompt + PS1="\$(sh_shell_prompt \${?})" + PS2="├ " ;; *) ;; esac } -shell_configure +sh_shell_configure sh_shell_prompt() { local date host id From e305827808e0ff5af3bed9c929ed1da79de96e0f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 14:47:30 +0100 Subject: [PATCH 811/969] mv --- sh/{mount.sh => alias/overlay.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{mount.sh => alias/overlay.sh} (100%) diff --git a/sh/mount.sh b/sh/alias/overlay.sh similarity index 100% rename from sh/mount.sh rename to sh/alias/overlay.sh From d691f67581762842bc8a5ad5f62d5f4797e09d92 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 15:48:10 +0100 Subject: [PATCH 812/969] main/output --- sh/main.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index fa0c556..68bc516 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -28,12 +28,12 @@ main_source_directory() { IFS=" " count=0 - echo - echo ". ${path}" + #echo + #echo ". ${path}" for module in ${modules}; do count=$((count + 1)) - printf "%02d" "${count}" - echo " ${module%.sh}" + #printf "%02d" "${count}" + #echo " ${module%.sh}" module="${path}/${module}" if [ "${module}" != "${ENV}" ]; then . "${module}" @@ -47,7 +47,7 @@ main_source_directory() { done IFS="${ifs}" else - echo "Not a directory: ${path}" + #echo "Not a directory: ${path}" return 1 fi } @@ -57,7 +57,7 @@ main_source_file() { if [ -f "${path}" ]; then main_source_directory "$(dirname "${path}")" else - echo "Not a file: ${path}" + #echo "Not a file: ${path}" return 1 fi } @@ -66,7 +66,7 @@ main_source_file "${ENV}" main_source_directory "${SH_USER}" -sh_log "" \ - "sh_… = shell functions" \ - "a__… = aliases" \ - "u__… = user" +#sh_log "" \ +# "sh_… = shell functions" \ +# "a__… = aliases" \ +# "u__… = user" From ee694a8fdee08beb2273389f19a16be1ff90336f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 20 Nov 2024 16:47:41 +0100 Subject: [PATCH 813/969] main/log --- sh/main.sh | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 68bc516..d2fafb8 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -15,6 +15,18 @@ _sh_main_commands() { cut --delimiter "(" --fields 1 } +_sh_main_log() { + case "${-}" in + *i*) + local argument + for argument in "${@}"; do + echo "${argument}" + done + ;; + *) ;; + esac +} + main_source_directory() { local path="${1}" if [ -d "${path}" ]; then @@ -28,12 +40,12 @@ main_source_directory() { IFS=" " count=0 - #echo - #echo ". ${path}" + _sh_main_log "" \ + ". ${path}" for module in ${modules}; do count=$((count + 1)) #printf "%02d" "${count}" - #echo " ${module%.sh}" + _sh_main_log "${module%.sh}" module="${path}/${module}" if [ "${module}" != "${ENV}" ]; then . "${module}" @@ -47,7 +59,7 @@ main_source_directory() { done IFS="${ifs}" else - #echo "Not a directory: ${path}" + _sh_main_log "Not a directory: ${path}" return 1 fi } @@ -57,7 +69,7 @@ main_source_file() { if [ -f "${path}" ]; then main_source_directory "$(dirname "${path}")" else - #echo "Not a file: ${path}" + _sh_main_log "Not a file: ${path}" return 1 fi } @@ -66,7 +78,7 @@ main_source_file "${ENV}" main_source_directory "${SH_USER}" -#sh_log "" \ -# "sh_… = shell functions" \ -# "a__… = aliases" \ -# "u__… = user" +_sh_main_log "" \ + "sh_… = shell functions" \ + "a__… = aliases" \ + "u__… = user" From 0ed8b2486c84050d3a43024b3b3ca5a2751204e1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 21 Nov 2024 11:25:40 +0100 Subject: [PATCH 814/969] _sh_main --- sh/main.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index d2fafb8..9a86ebe 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -74,11 +74,13 @@ main_source_file() { fi } -main_source_file "${ENV}" +_sh_main() { + main_source_file "${ENV}" + main_source_directory "${SH_USER}" + _sh_main_log "" \ + "sh_… = shell functions" \ + "a__… = aliases" \ + "u__… = user" +} -main_source_directory "${SH_USER}" - -_sh_main_log "" \ - "sh_… = shell functions" \ - "a__… = aliases" \ - "u__… = user" +_sh_main From a52d3595f747c724825739513f9712bdc9dc18c2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 11:52:42 +0100 Subject: [PATCH 815/969] prompt --- sh/shell.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/shell.sh b/sh/shell.sh index c4569d1..bf39f7b 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -48,12 +48,12 @@ sh_shell_configure() { HISTCONTROL="ignorespace" HISTSIZE=-1 HISTTIMEFORMAT="%Y%m%d %H%M%S " - # prompt - PS1="\$(sh_shell_prompt \${?})" - PS2="├ " ;; *) ;; esac + # prompt + PS1="\$(sh_shell_prompt \${?})" + PS2="├ " } sh_shell_configure From 6b8da7e16b067d5208f0b571c6288cb71a77c6c4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 12:49:17 +0100 Subject: [PATCH 816/969] ovl --- sh/alias/overlay.sh | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/sh/alias/overlay.sh b/sh/alias/overlay.sh index b2bd77f..82fe273 100644 --- a/sh/alias/overlay.sh +++ b/sh/alias/overlay.sh @@ -1,4 +1,5 @@ -mo() { +orm() { a__overlay_root_mount "${@}"; } +a__overlay_root_mount() { local root="${1}" if [ -z "${root}" ]; then sh_log_error "No root target directory" @@ -36,7 +37,8 @@ mo() { ) } -uo() { +oru() { a__overlay_root_unmount "${@}"; } +a__overlay_root_unmount() { ( if ! cd "overlay"; then sh_log_error "Unable to move into overlay directory" @@ -72,7 +74,8 @@ uo() { fi } -mr() { +obm() { a__overlay_bind_mount "${@}"; } +a__overlay_bind_mount() { local directory for directory in "dev" "dev/pts" "proc" "sys"; do if ! mount --bind "/${directory}" "overlay/mount/${directory}"; then @@ -82,18 +85,21 @@ mr() { done } -cr() { +ocr() { a__overlay_command_root "${@}"; } +a__overlay_command_root() { chroot \ "overlay/mount" "${@}" } -cru() { +ocu() { a__overlay_command_user "${@}"; } +a__overlay_command_user() { chroot \ --userspec "1000:1000" \ "overlay/mount" "${@}" } -ur() { +obu() { a__overlay_bind_unmount "${@}"; } +a__overlay_bind_unmount() { local directory for directory in "sys" "proc" "dev/pts" "dev"; do if ! umount --lazy "overlay/mount/${directory}"; then @@ -103,15 +109,18 @@ ur() { done } -mm() { +omm() { a__overlay_mirror_mount "${@}"; } +a__overlay_mirror_mount() { mount --make-rslave --rbind "/deb" "overlay/mount/deb" } -um() { +omu() { a__overlay_mirror_unmount "${@}"; } +a__overlay_mirror_unmount() { umount --recursive "overlay/mount/deb" } -ms() { +ors() { a__overlay_root_squash "${@}"; } +a__overlay_root_squash() { local directory="${1}" local file local level="${2}" From 0b2b2acb7bb456e0e017faeff9ead207c0daa8e5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 12:50:43 +0100 Subject: [PATCH 817/969] ovl/bind --- sh/alias/overlay.sh | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/sh/alias/overlay.sh b/sh/alias/overlay.sh index 82fe273..9418f75 100644 --- a/sh/alias/overlay.sh +++ b/sh/alias/overlay.sh @@ -1,3 +1,25 @@ +obm() { a__overlay_bind_mount "${@}"; } +a__overlay_bind_mount() { + local directory + for directory in "dev" "dev/pts" "proc" "sys"; do + if ! mount --bind "/${directory}" "overlay/mount/${directory}"; then + sh_log_error "Unable to bind mount directory: ${directory}" + return 1 + fi + done +} + +obu() { a__overlay_bind_unmount "${@}"; } +a__overlay_bind_unmount() { + local directory + for directory in "sys" "proc" "dev/pts" "dev"; do + if ! umount --lazy "overlay/mount/${directory}"; then + sh_log_error "Unable to bind unmount directory: ${directory}" + return 1 + fi + done +} + orm() { a__overlay_root_mount "${@}"; } a__overlay_root_mount() { local root="${1}" @@ -74,17 +96,6 @@ a__overlay_root_unmount() { fi } -obm() { a__overlay_bind_mount "${@}"; } -a__overlay_bind_mount() { - local directory - for directory in "dev" "dev/pts" "proc" "sys"; do - if ! mount --bind "/${directory}" "overlay/mount/${directory}"; then - sh_log_error "Unable to bind mount directory: ${directory}" - return 1 - fi - done -} - ocr() { a__overlay_command_root "${@}"; } a__overlay_command_root() { chroot \ @@ -98,17 +109,6 @@ a__overlay_command_user() { "overlay/mount" "${@}" } -obu() { a__overlay_bind_unmount "${@}"; } -a__overlay_bind_unmount() { - local directory - for directory in "sys" "proc" "dev/pts" "dev"; do - if ! umount --lazy "overlay/mount/${directory}"; then - sh_log_error "Unable to bind unmount directory: ${directory}" - return 1 - fi - done -} - omm() { a__overlay_mirror_mount "${@}"; } a__overlay_mirror_mount() { mount --make-rslave --rbind "/deb" "overlay/mount/deb" From 8490621281f655a865c65dbaca43ec0889c6efbb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 12:51:29 +0100 Subject: [PATCH 818/969] ovl/cmd --- sh/alias/overlay.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/sh/alias/overlay.sh b/sh/alias/overlay.sh index 9418f75..7870c2e 100644 --- a/sh/alias/overlay.sh +++ b/sh/alias/overlay.sh @@ -20,6 +20,19 @@ a__overlay_bind_unmount() { done } +ocr() { a__overlay_command_root "${@}"; } +a__overlay_command_root() { + chroot \ + "overlay/mount" "${@}" +} + +ocu() { a__overlay_command_user "${@}"; } +a__overlay_command_user() { + chroot \ + --userspec "1000:1000" \ + "overlay/mount" "${@}" +} + orm() { a__overlay_root_mount "${@}"; } a__overlay_root_mount() { local root="${1}" @@ -96,19 +109,6 @@ a__overlay_root_unmount() { fi } -ocr() { a__overlay_command_root "${@}"; } -a__overlay_command_root() { - chroot \ - "overlay/mount" "${@}" -} - -ocu() { a__overlay_command_user "${@}"; } -a__overlay_command_user() { - chroot \ - --userspec "1000:1000" \ - "overlay/mount" "${@}" -} - omm() { a__overlay_mirror_mount "${@}"; } a__overlay_mirror_mount() { mount --make-rslave --rbind "/deb" "overlay/mount/deb" From c4b7796bb3782e89badc67098dd1eb5e08b5e0c2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 12:52:21 +0100 Subject: [PATCH 819/969] ovl/mirror --- sh/alias/overlay.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sh/alias/overlay.sh b/sh/alias/overlay.sh index 7870c2e..65f1c46 100644 --- a/sh/alias/overlay.sh +++ b/sh/alias/overlay.sh @@ -33,6 +33,16 @@ a__overlay_command_user() { "overlay/mount" "${@}" } +omm() { a__overlay_mirror_mount "${@}"; } +a__overlay_mirror_mount() { + mount --make-rslave --rbind "/deb" "overlay/mount/deb" +} + +omu() { a__overlay_mirror_unmount "${@}"; } +a__overlay_mirror_unmount() { + umount --recursive "overlay/mount/deb" +} + orm() { a__overlay_root_mount "${@}"; } a__overlay_root_mount() { local root="${1}" @@ -109,16 +119,6 @@ a__overlay_root_unmount() { fi } -omm() { a__overlay_mirror_mount "${@}"; } -a__overlay_mirror_mount() { - mount --make-rslave --rbind "/deb" "overlay/mount/deb" -} - -omu() { a__overlay_mirror_unmount "${@}"; } -a__overlay_mirror_unmount() { - umount --recursive "overlay/mount/deb" -} - ors() { a__overlay_root_squash "${@}"; } a__overlay_root_squash() { local directory="${1}" From bb76a2f956d83c3d1ee0e50c2e46a86f1692e45b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 12:53:01 +0100 Subject: [PATCH 820/969] ovl/squash --- sh/alias/overlay.sh | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/sh/alias/overlay.sh b/sh/alias/overlay.sh index 65f1c46..307c470 100644 --- a/sh/alias/overlay.sh +++ b/sh/alias/overlay.sh @@ -82,6 +82,26 @@ a__overlay_root_mount() { ) } +ors() { a__overlay_root_squash "${@}"; } +a__overlay_root_squash() { + local directory="${1}" + local file + local level="${2}" + if [ -n "${directory}" ]; then + if mkdir "${directory}"; then + [ -n "${level}" ] || level="18" + for file in "vmlinuz" "initrd.img"; do + cp "overlay/mount/${file}" "${directory}" + done + mksquashfs \ + "overlay/mount" "${directory}/filesystem.squashfs" \ + -noappend \ + -comp "zstd" -Xcompression-level "${level}" + chown --recursive 1000:1000 "${directory}" + fi + fi +} + oru() { a__overlay_root_unmount "${@}"; } a__overlay_root_unmount() { ( @@ -118,23 +138,3 @@ a__overlay_root_unmount() { return 7 fi } - -ors() { a__overlay_root_squash "${@}"; } -a__overlay_root_squash() { - local directory="${1}" - local file - local level="${2}" - if [ -n "${directory}" ]; then - if mkdir "${directory}"; then - [ -n "${level}" ] || level="18" - for file in "vmlinuz" "initrd.img"; do - cp "overlay/mount/${file}" "${directory}" - done - mksquashfs \ - "overlay/mount" "${directory}/filesystem.squashfs" \ - -noappend \ - -comp "zstd" -Xcompression-level "${level}" - chown --recursive 1000:1000 "${directory}" - fi - fi -} From 6eee35b3a4be4a63ca09f3f7e688a095bfcf9858 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 13:03:00 +0100 Subject: [PATCH 821/969] =?UTF-8?q?=E2=88=92ovl/lxc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sh/mount-lxc.sh | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 sh/mount-lxc.sh diff --git a/sh/mount-lxc.sh b/sh/mount-lxc.sh deleted file mode 100644 index 8cc946e..0000000 --- a/sh/mount-lxc.sh +++ /dev/null @@ -1,31 +0,0 @@ -mrc() { - local container="${1}" - local f - for f in "dev" "dev/pts" "proc" "sys"; do - mount --bind "/${f}" "overlay/mount/var/lib/lxc/${container}/squashfs-root/${f}" - done -} - -crc() { - local container="${1}" - shift - chroot "overlay/mount/var/lib/lxc/${container}/squashfs-root" "${@}" -} - -urc() { - local container="${1}" - local f - for f in "sys" "proc" "dev/pts" "dev"; do - umount --lazy "overlay/mount/var/lib/lxc/${container}/squashfs-root/${f}" - done -} - -mmc() { - local container="${1}" - mount --bind "/deb" "overlay/mount/var/lib/lxc/${container}/squashfs-root/deb" -} - -umc() { - local container="${1}" - umount "overlay/mount/var/lib/lxc/${container}/squashfs-root/deb" -} From e6e446868de04341a2622632d0d31de270a2c599 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 13:16:24 +0100 Subject: [PATCH 822/969] main/lf --- sh/main.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 9a86ebe..60f5df0 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -34,8 +34,8 @@ main_source_directory() { modules="$(find "${path}" \ -type "f" \ -name "*.sh" \ - -printf "%P -" | sort)" + -printf "%P\n" | + sort)" ifs="${IFS}" IFS=" " From 20ea46c5e4774cac160fa20ff9a35a92f1c2977c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 13:21:23 +0100 Subject: [PATCH 823/969] shellcheck/sources --- sh/.shellcheckrc | 1 + 1 file changed, 1 insertion(+) diff --git a/sh/.shellcheckrc b/sh/.shellcheckrc index 173f983..09194f4 100644 --- a/sh/.shellcheckrc +++ b/sh/.shellcheckrc @@ -1,3 +1,4 @@ disable=1090,3043 enable=all +external-sources=true shell=sh From 35626d110458050f4e724f68640b300bbc19e37c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 13:23:09 +0100 Subject: [PATCH 824/969] =?UTF-8?q?=E2=88=92main/export?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sh/main.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/sh/main.sh b/sh/main.sh index 60f5df0..e037089 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -1,6 +1,5 @@ SH_NAME="sh" SH_SHELL="$(cat /proc/${$}/comm)" -export SH_SHELL SH_ROOT="/etc/${SH_NAME}" SH_USER="${HOME}/${SH_NAME}" From d2ee4678d77fdd200e722ef693b78f487b87fcda Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 13:28:42 +0100 Subject: [PATCH 825/969] source/check --- sh/main.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sh/main.sh b/sh/main.sh index e037089..bb7c2bc 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -8,6 +8,17 @@ SH_MAIN="${SH_ROOT}/main.sh" [ -n "${ENV}" ] || export ENV="${SH_MAIN}" +sh_source_check() { + local file=".shellcheck.sh" + find \ + -type "f" \ + -name "*.sh" \ + -printf ". \"%P\"\n" \ + >"${file}" + shellcheck "${file}" + rm "${file}" +} + _sh_main_commands() { local file="${1}" grep "()" "${file}" | From e029b00caebdced768f0187fecaa4dd2086a7d05 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 13:31:34 +0100 Subject: [PATCH 826/969] useless --- sh/alias/shell.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/sh/alias/shell.sh b/sh/alias/shell.sh index 8f6684c..daadbce 100644 --- a/sh/alias/shell.sh +++ b/sh/alias/shell.sh @@ -17,7 +17,6 @@ x() { "${@}" } -# shellcheck disable=SC2154 [ "${SH_SHELL}" = "bash" ] || return # shellcheck disable=SC3033 From 84f6922b6f9a8ad2d2eaf2c4b14a07a9d609d2e5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 13:56:01 +0100 Subject: [PATCH 827/969] check sourced --- sh/main.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sh/main.sh b/sh/main.sh index bb7c2bc..4c1e58b 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -15,7 +15,9 @@ sh_source_check() { -name "*.sh" \ -printf ". \"%P\"\n" \ >"${file}" - shellcheck "${file}" + shellcheck \ + --check-sourced \ + "${file}" rm "${file}" } From ae8aaec327e2180437a4061e31909ee3cd090108 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 14:06:22 +0100 Subject: [PATCH 828/969] not output --- sh/main.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sh/main.sh b/sh/main.sh index 4c1e58b..27aca02 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -13,6 +13,8 @@ sh_source_check() { find \ -type "f" \ -name "*.sh" \ + -not \ + -name "${file}" \ -printf ". \"%P\"\n" \ >"${file}" shellcheck \ From 4b9f7df102f2445ca8aea5dc119fffe862d550bf Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 14:07:38 +0100 Subject: [PATCH 829/969] . --- sh/main.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/sh/main.sh b/sh/main.sh index 27aca02..3e2008f 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -11,6 +11,7 @@ SH_MAIN="${SH_ROOT}/main.sh" sh_source_check() { local file=".shellcheck.sh" find \ + "." \ -type "f" \ -name "*.sh" \ -not \ From 0eaebdf4011b3208c8da12c1fcb15abea18c7187 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 14:16:23 +0100 Subject: [PATCH 830/969] source --- sh/.shellcheckrc | 2 +- sh/main.sh | 1 + sh/shell.sh | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/sh/.shellcheckrc b/sh/.shellcheckrc index 09194f4..8e71c00 100644 --- a/sh/.shellcheckrc +++ b/sh/.shellcheckrc @@ -1,4 +1,4 @@ -disable=1090,3043 +disable=3043 enable=all external-sources=true shell=sh diff --git a/sh/main.sh b/sh/main.sh index 3e2008f..3ce303c 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -63,6 +63,7 @@ main_source_directory() { _sh_main_log "${module%.sh}" module="${path}/${module}" if [ "${module}" != "${ENV}" ]; then + # shellcheck disable=1090 . "${module}" cmd="$(_sh_main_commands "${module}")" if [ -n "${cmd}" ]; then diff --git a/sh/shell.sh b/sh/shell.sh index bf39f7b..720c884 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -33,6 +33,7 @@ sh_shell_configure() { local root="/usr/share/bash-completion" local file="bash_completion" local path="${root}/${file}" + # shellcheck disable=1090 [ -f "${path}" ] && . "${path}" root="${root}/completions" if [ -d "${root}" ]; then @@ -41,6 +42,7 @@ sh_shell_configure() { "tar" for file in "${@}"; do path="${root}/${file}" + # shellcheck disable=1090 [ -f "${path}" ] && . "${path}" done fi From c68409c546b98c98aa628c43b296526c38d223b0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 14:27:23 +0100 Subject: [PATCH 831/969] +sc --- sh/main.sh | 2 +- sh/shell.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 3ce303c..61637fb 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -63,7 +63,7 @@ main_source_directory() { _sh_main_log "${module%.sh}" module="${path}/${module}" if [ "${module}" != "${ENV}" ]; then - # shellcheck disable=1090 + # shellcheck disable=SC1090 . "${module}" cmd="$(_sh_main_commands "${module}")" if [ -n "${cmd}" ]; then diff --git a/sh/shell.sh b/sh/shell.sh index 720c884..733d823 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -33,7 +33,7 @@ sh_shell_configure() { local root="/usr/share/bash-completion" local file="bash_completion" local path="${root}/${file}" - # shellcheck disable=1090 + # shellcheck disable=SC1090 [ -f "${path}" ] && . "${path}" root="${root}/completions" if [ -d "${root}" ]; then @@ -42,7 +42,7 @@ sh_shell_configure() { "tar" for file in "${@}"; do path="${root}/${file}" - # shellcheck disable=1090 + # shellcheck disable=SC1090 [ -f "${path}" ] && . "${path}" done fi From 47f108f0a3022171b99daed5299158fee1ddeeb7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 14:45:16 +0100 Subject: [PATCH 832/969] source/find --- sh/main.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sh/main.sh b/sh/main.sh index 61637fb..7da2446 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -24,6 +24,21 @@ sh_source_check() { rm "${file}" } +sh_source_find() { + local root="${1}" + local file="${2}" + set -- \ + "${root}" \ + -name "*.sh" \ + -type "f" + [ -n "${file}" ] && + set -- "${@}" \ + -not \ + -name "${file}" + find "${@}" \ + -printf "%P\n" +} + _sh_main_commands() { local file="${1}" grep "()" "${file}" | From d517b783d78d8615a31e209219cb007c2473894f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 14:52:47 +0100 Subject: [PATCH 833/969] sort,shfmt --- sh/main.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 7da2446..ff80d0d 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -11,13 +11,13 @@ SH_MAIN="${SH_ROOT}/main.sh" sh_source_check() { local file=".shellcheck.sh" find \ - "." \ - -type "f" \ - -name "*.sh" \ - -not \ - -name "${file}" \ - -printf ". \"%P\"\n" \ - >"${file}" + "." \ + -type "f" \ + -name "*.sh" \ + -not \ + -name "${file}" \ + -printf ". \"%P\"\n" \ + >"${file}" shellcheck \ --check-sourced \ "${file}" @@ -36,7 +36,8 @@ sh_source_find() { -not \ -name "${file}" find "${@}" \ - -printf "%P\n" + -printf "%P\n" | + sort } _sh_main_commands() { From 51de08aaa3175e69a1627cf8fe8dd1c510520918 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 14:59:24 +0100 Subject: [PATCH 834/969] source/find --- sh/main.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index ff80d0d..d593295 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -62,11 +62,7 @@ main_source_directory() { local path="${1}" if [ -d "${path}" ]; then local cmd count ifs module modules - modules="$(find "${path}" \ - -type "f" \ - -name "*.sh" \ - -printf "%P\n" | - sort)" + modules="$(sh_source_find "${path}")" ifs="${IFS}" IFS=" " From 8fb0750b596bfbb30cd5033bc10abd68307da276 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 15:07:19 +0100 Subject: [PATCH 835/969] except --- sh/main.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index d593295..7b3fe28 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -62,7 +62,7 @@ main_source_directory() { local path="${1}" if [ -d "${path}" ]; then local cmd count ifs module modules - modules="$(sh_source_find "${path}")" + modules="$(sh_source_find "${path}" "main.sh")" ifs="${IFS}" IFS=" " @@ -74,15 +74,13 @@ main_source_directory() { #printf "%02d" "${count}" _sh_main_log "${module%.sh}" module="${path}/${module}" - if [ "${module}" != "${ENV}" ]; then - # shellcheck disable=SC1090 - . "${module}" - cmd="$(_sh_main_commands "${module}")" - if [ -n "${cmd}" ]; then - [ -n "${CMD}" ] && CMD="${CMD} + # shellcheck disable=SC1090 + . "${module}" + cmd="$(_sh_main_commands "${module}")" + if [ -n "${cmd}" ]; then + [ -n "${CMD}" ] && CMD="${CMD} " - CMD="${CMD}${cmd}" - fi + CMD="${CMD}${cmd}" fi done IFS="${ifs}" From e9904f2965ea44cf41f9f786a7e7780d9f44ac53 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 15:09:58 +0100 Subject: [PATCH 836/969] main/name --- sh/main.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 7b3fe28..3ee4c6f 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -1,10 +1,11 @@ +SH_MAIN_NAME="main.sh" SH_NAME="sh" SH_SHELL="$(cat /proc/${$}/comm)" SH_ROOT="/etc/${SH_NAME}" SH_USER="${HOME}/${SH_NAME}" -SH_MAIN="${SH_ROOT}/main.sh" +SH_MAIN="${SH_ROOT}/${SH_MAIN_NAME}" [ -n "${ENV}" ] || export ENV="${SH_MAIN}" @@ -62,7 +63,7 @@ main_source_directory() { local path="${1}" if [ -d "${path}" ]; then local cmd count ifs module modules - modules="$(sh_source_find "${path}" "main.sh")" + modules="$(sh_source_find "${path}" "${SH_MAIN_NAME}")" ifs="${IFS}" IFS=" " From df136cbad5c2cbc33f88690e7fdd17ca0ae4b2c1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 15:33:18 +0100 Subject: [PATCH 837/969] check/find --- sh/main.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 3ee4c6f..ea6a4d0 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -11,14 +11,16 @@ SH_MAIN="${SH_ROOT}/${SH_MAIN_NAME}" sh_source_check() { local file=".shellcheck.sh" - find \ - "." \ - -type "f" \ - -name "*.sh" \ - -not \ - -name "${file}" \ - -printf ". \"%P\"\n" \ - >"${file}" + local ifs module modules + modules="$(sh_source_find "." "${file}")" + rm --force "${file}" + ifs="${IFS}" + IFS=" +" + for module in ${modules}; do + echo ". \"${module}\"" >>"${file}" + done + IFS="${ifs}" shellcheck \ --check-sourced \ "${file}" From 62b8f608419eba4dceba3ee2287bfbe3efe92ef1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 16:19:48 +0100 Subject: [PATCH 838/969] main/count --- sh/main.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index ea6a4d0..bfa8c04 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -74,8 +74,7 @@ main_source_directory() { ". ${path}" for module in ${modules}; do count=$((count + 1)) - #printf "%02d" "${count}" - _sh_main_log "${module%.sh}" + _sh_main_log "$(printf "%02d" "${count}") ${module%.sh}" module="${path}/${module}" # shellcheck disable=SC1090 . "${module}" From 678cf741c993310c774d7109b1b8f874b82d146c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 16:31:59 +0100 Subject: [PATCH 839/969] main/if --- sh/main.sh | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index bfa8c04..92edc7b 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -63,33 +63,32 @@ _sh_main_log() { main_source_directory() { local path="${1}" - if [ -d "${path}" ]; then - local cmd count ifs module modules - modules="$(sh_source_find "${path}" "${SH_MAIN_NAME}")" - ifs="${IFS}" - IFS=" -" - count=0 - _sh_main_log "" \ - ". ${path}" - for module in ${modules}; do - count=$((count + 1)) - _sh_main_log "$(printf "%02d" "${count}") ${module%.sh}" - module="${path}/${module}" - # shellcheck disable=SC1090 - . "${module}" - cmd="$(_sh_main_commands "${module}")" - if [ -n "${cmd}" ]; then - [ -n "${CMD}" ] && CMD="${CMD} -" - CMD="${CMD}${cmd}" - fi - done - IFS="${ifs}" - else + if [ ! -d "${path}" ]; then _sh_main_log "Not a directory: ${path}" return 1 fi + local cmd count ifs module modules + modules="$(sh_source_find "${path}" "${SH_MAIN_NAME}")" + ifs="${IFS}" + IFS=" +" + count=0 + _sh_main_log "" \ + ". ${path}" + for module in ${modules}; do + count=$((count + 1)) + _sh_main_log "$(printf "%02d" "${count}") ${module%.sh}" + module="${path}/${module}" + # shellcheck disable=SC1090 + . "${module}" + cmd="$(_sh_main_commands "${module}")" + if [ -n "${cmd}" ]; then + [ -n "${CMD}" ] && CMD="${CMD} +" + CMD="${CMD}${cmd}" + fi + done + IFS="${ifs}" } main_source_file() { From ec8d1c113cd7a05ddce6b10aeb8b3fa906061525 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 16:38:48 +0100 Subject: [PATCH 840/969] ifs/new,pop --- sh/main.sh | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 92edc7b..2c240b6 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -9,18 +9,27 @@ SH_MAIN="${SH_ROOT}/${SH_MAIN_NAME}" [ -n "${ENV}" ] || export ENV="${SH_MAIN}" -sh_source_check() { - local file=".shellcheck.sh" - local ifs module modules - modules="$(sh_source_find "." "${file}")" - rm --force "${file}" - ifs="${IFS}" +_sh_ifs_new() { + SH_IFS="${IFS}" IFS=" " +} + +_sh_ifs_pop() { + IFS="${SH_IFS}" + unset SH_IFS +} + +sh_source_check() { + local file=".shellcheck.sh" + local module modules + modules="$(sh_source_find "." "${file}")" + rm --force "${file}" + _sh_ifs_new for module in ${modules}; do echo ". \"${module}\"" >>"${file}" done - IFS="${ifs}" + _sh_ifs_pop shellcheck \ --check-sourced \ "${file}" @@ -69,9 +78,7 @@ main_source_directory() { fi local cmd count ifs module modules modules="$(sh_source_find "${path}" "${SH_MAIN_NAME}")" - ifs="${IFS}" - IFS=" -" + _sh_ifs_new count=0 _sh_main_log "" \ ". ${path}" @@ -88,7 +95,7 @@ main_source_directory() { CMD="${CMD}${cmd}" fi done - IFS="${ifs}" + _sh_ifs_pop } main_source_file() { From 25e7cc4f6c93d6a6fe383b47703b18cc657fdd4f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 17:17:05 +0100 Subject: [PATCH 841/969] loopback --- sh/main.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 2c240b6..4cbf317 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -21,17 +21,21 @@ _sh_ifs_pop() { } sh_source_check() { - local file=".shellcheck.sh" - local module modules - modules="$(sh_source_find "." "${file}")" - rm --force "${file}" + local root="${1}" + local file module modules + file="$(mktemp)" + modules="$(sh_source_find "${root}")" _sh_ifs_new for module in ${modules}; do - echo ". \"${module}\"" >>"${file}" + echo ". \"${root}/${module}\"" >>"${file}" done _sh_ifs_pop shellcheck \ --check-sourced \ + --enable "all" \ + --exclude "3043" \ + --external-sources \ + --shell "dash" \ "${file}" rm "${file}" } @@ -76,7 +80,7 @@ main_source_directory() { _sh_main_log "Not a directory: ${path}" return 1 fi - local cmd count ifs module modules + local cmd count module modules modules="$(sh_source_find "${path}" "${SH_MAIN_NAME}")" _sh_ifs_new count=0 @@ -111,6 +115,7 @@ main_source_file() { _sh_main() { main_source_file "${ENV}" main_source_directory "${SH_USER}" + sh_source_check "$(dirname "${ENV}")" _sh_main_log "" \ "sh_… = shell functions" \ "a__… = aliases" \ From df1fb4f343b5f93d54514516c129ce7e1e114fcc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 17:32:44 +0100 Subject: [PATCH 842/969] env --- sh/main.sh | 11 ++++++++--- sh/shell.sh | 9 ++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 4cbf317..9189197 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -1,13 +1,18 @@ +# constants + SH_MAIN_NAME="main.sh" SH_NAME="sh" -SH_SHELL="$(cat /proc/${$}/comm)" SH_ROOT="/etc/${SH_NAME}" -SH_USER="${HOME}/${SH_NAME}" SH_MAIN="${SH_ROOT}/${SH_MAIN_NAME}" -[ -n "${ENV}" ] || export ENV="${SH_MAIN}" +# variables + +SH_SHELL="$(cat /proc/${$}/comm)" +SH_USER="${HOME}/${SH_NAME}" + +# functions _sh_ifs_new() { SH_IFS="${IFS}" diff --git a/sh/shell.sh b/sh/shell.sh index 733d823..3a76cb6 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -27,6 +27,12 @@ SH_COLOR_MAGENTA="$(_sh_shell_color 35)" SH_COLOR_RED="$(_sh_shell_color 32)" sh_shell_configure() { + [ -n "${ENV}" ] || ENV="${SH_MAIN}" + export ENV + # prompt + PS1="\$(sh_shell_prompt \${?})" + PS2="├ " + # specific case "${SH_SHELL}" in "bash") # completion @@ -53,9 +59,6 @@ sh_shell_configure() { ;; *) ;; esac - # prompt - PS1="\$(sh_shell_prompt \${?})" - PS2="├ " } sh_shell_configure From 558c5d82c3adf7b1fad4c225c7fab7e5b9112f9a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 17:54:40 +0100 Subject: [PATCH 843/969] quote --- sh/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/main.sh b/sh/main.sh index 9189197..665e707 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -9,7 +9,7 @@ SH_MAIN="${SH_ROOT}/${SH_MAIN_NAME}" # variables -SH_SHELL="$(cat /proc/${$}/comm)" +SH_SHELL="$(cat "/proc/${$}/comm")" SH_USER="${HOME}/${SH_NAME}" # functions From d048757efee2c383bc92971866fef4c7d1104ade Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 17:57:41 +0100 Subject: [PATCH 844/969] main/help --- sh/main.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 665e707..9c1c59d 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -117,14 +117,18 @@ main_source_file() { fi } -_sh_main() { - main_source_file "${ENV}" - main_source_directory "${SH_USER}" - sh_source_check "$(dirname "${ENV}")" +sh_help() { _sh_main_log "" \ "sh_… = shell functions" \ "a__… = aliases" \ "u__… = user" } +_sh_main() { + main_source_file "${ENV}" + main_source_directory "${SH_USER}" + sh_source_check "$(dirname "${ENV}")" + sh_help +} + _sh_main From b9158be284766fb0b696bf1a3e2d2b6f0c9371c3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 18:09:03 +0100 Subject: [PATCH 845/969] main --- sh/main.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 9c1c59d..4fbecc3 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -124,11 +124,11 @@ sh_help() { "u__… = user" } -_sh_main() { +sh_main() { main_source_file "${ENV}" main_source_directory "${SH_USER}" sh_source_check "$(dirname "${ENV}")" sh_help } -_sh_main +sh_main From 80463e92135e82e0754349d1c00409cf985a0576 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 18:20:08 +0100 Subject: [PATCH 846/969] logs --- sh/log.sh | 7 +++++-- sh/main.sh | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sh/log.sh b/sh/log.sh index 1674324..4e7a63e 100644 --- a/sh/log.sh +++ b/sh/log.sh @@ -58,7 +58,10 @@ _sh_log() { shift local line for line in "${@}"; do - [ -n "${prefix}" ] && printf "%s" "${prefix} " - echo "${line}" + if [ -n "${prefix}" ]; then + _sh_main_log "${prefix} ${line}" + else + _sh_main_log "${line}" + fi done } diff --git a/sh/main.sh b/sh/main.sh index 4fbecc3..1cc1116 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -70,9 +70,10 @@ _sh_main_commands() { _sh_main_log() { case "${-}" in *i*) - local argument - for argument in "${@}"; do - echo "${argument}" + [ -n "${1}" ] || set -- "" + local line + for line in "${@}"; do + echo "${line}" done ;; *) ;; From 47188ffedde589db3462acce705a7a267f1e0e47 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 18:22:35 +0100 Subject: [PATCH 847/969] gt --- sh/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/main.sh b/sh/main.sh index 1cc1116..6e68a16 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -70,7 +70,7 @@ _sh_main_commands() { _sh_main_log() { case "${-}" in *i*) - [ -n "${1}" ] || set -- "" + [ ${#} -gt 0 ] || set -- "" local line for line in "${@}"; do echo "${line}" From 1507a935b97b4dd5c303eb368657eadf0eecd6e2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 18:23:48 +0100 Subject: [PATCH 848/969] help/log --- sh/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/main.sh b/sh/main.sh index 6e68a16..2bae67d 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -119,7 +119,7 @@ main_source_file() { } sh_help() { - _sh_main_log "" \ + sh_log "" \ "sh_… = shell functions" \ "a__… = aliases" \ "u__… = user" From a8da17d1965efd1ed1d235e78b00b3079258a989 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 18:25:13 +0100 Subject: [PATCH 849/969] main/logs --- sh/main.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sh/main.sh b/sh/main.sh index 2bae67d..5274b28 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -119,7 +119,7 @@ main_source_file() { } sh_help() { - sh_log "" \ + sh_log \ "sh_… = shell functions" \ "a__… = aliases" \ "u__… = user" @@ -128,7 +128,9 @@ sh_help() { sh_main() { main_source_file "${ENV}" main_source_directory "${SH_USER}" + sh_log sh_source_check "$(dirname "${ENV}")" + sh_log sh_help } From 1bc166a046ec794536ba3e37b36a864d215a8cea Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 18:30:35 +0100 Subject: [PATCH 850/969] empty --- sh/log.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/sh/log.sh b/sh/log.sh index 4e7a63e..2be59e0 100644 --- a/sh/log.sh +++ b/sh/log.sh @@ -56,6 +56,7 @@ sh_log_warn() { _sh_log() { local prefix="${1}" shift + [ ${#} -gt 0 ] || set -- "" local line for line in "${@}"; do if [ -n "${prefix}" ]; then From 839c8fa069cf3792648cd74192fa0158afb115e1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 18:33:23 +0100 Subject: [PATCH 851/969] main/log --- sh/main.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 5274b28..2a351c9 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -12,7 +12,7 @@ SH_MAIN="${SH_ROOT}/${SH_MAIN_NAME}" SH_SHELL="$(cat "/proc/${$}/comm")" SH_USER="${HOME}/${SH_NAME}" -# functions +# private _sh_ifs_new() { SH_IFS="${IFS}" @@ -25,6 +25,21 @@ _sh_ifs_pop() { unset SH_IFS } +_sh_main_log() { + case "${-}" in + *i*) + [ ${#} -gt 0 ] || set -- "" + local line + for line in "${@}"; do + echo "${line}" + done + ;; + *) ;; + esac +} + +# + sh_source_check() { local root="${1}" local file module modules @@ -67,19 +82,6 @@ _sh_main_commands() { cut --delimiter "(" --fields 1 } -_sh_main_log() { - case "${-}" in - *i*) - [ ${#} -gt 0 ] || set -- "" - local line - for line in "${@}"; do - echo "${line}" - done - ;; - *) ;; - esac -} - main_source_directory() { local path="${1}" if [ ! -d "${path}" ]; then From 0e8cab41f6c03824e46b3015b440f0eea213c84c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 18:39:25 +0100 Subject: [PATCH 852/969] shellcheck --- sh/main.sh | 28 ++++++---------------------- sh/shellcheck.sh | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 sh/shellcheck.sh diff --git a/sh/main.sh b/sh/main.sh index 2a351c9..83f0705 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -38,27 +38,7 @@ _sh_main_log() { esac } -# - -sh_source_check() { - local root="${1}" - local file module modules - file="$(mktemp)" - modules="$(sh_source_find "${root}")" - _sh_ifs_new - for module in ${modules}; do - echo ". \"${root}/${module}\"" >>"${file}" - done - _sh_ifs_pop - shellcheck \ - --check-sourced \ - --enable "all" \ - --exclude "3043" \ - --external-sources \ - --shell "dash" \ - "${file}" - rm "${file}" -} +# sort sh_source_find() { local root="${1}" @@ -120,6 +100,8 @@ main_source_file() { fi } +# public + sh_help() { sh_log \ "sh_… = shell functions" \ @@ -131,9 +113,11 @@ sh_main() { main_source_file "${ENV}" main_source_directory "${SH_USER}" sh_log - sh_source_check "$(dirname "${ENV}")" + sh_shellcheck "$(dirname "${ENV}")" sh_log sh_help } +# main + sh_main diff --git a/sh/shellcheck.sh b/sh/shellcheck.sh new file mode 100644 index 0000000..d5ccb53 --- /dev/null +++ b/sh/shellcheck.sh @@ -0,0 +1,19 @@ +sh_shellcheck() { + local root="${1}" + local file module modules + file="$(mktemp)" + modules="$(sh_source_find "${root}")" + _sh_ifs_new + for module in ${modules}; do + echo ". \"${root}/${module}\"" >>"${file}" + done + _sh_ifs_pop + shellcheck \ + --check-sourced \ + --enable "all" \ + --exclude "3043" \ + --external-sources \ + --shell "dash" \ + "${file}" + rm "${file}" +} From 86be462cbe5e4cca8da07d43392255bed0aadc14 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 18:48:22 +0100 Subject: [PATCH 853/969] =?UTF-8?q?=E2=88=92file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sh/main.sh | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 83f0705..4925099 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -90,16 +90,6 @@ main_source_directory() { _sh_ifs_pop } -main_source_file() { - local path="${1}" - if [ -f "${path}" ]; then - main_source_directory "$(dirname "${path}")" - else - _sh_main_log "Not a file: ${path}" - return 1 - fi -} - # public sh_help() { @@ -110,10 +100,10 @@ sh_help() { } sh_main() { - main_source_file "${ENV}" + main_source_directory "${SH_ROOT}" main_source_directory "${SH_USER}" sh_log - sh_shellcheck "$(dirname "${ENV}")" + sh_shellcheck "${SH_ROOT}" sh_log sh_help } From 586373ca3f21e93d86c879ed922d22d235a9ed47 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 18:51:24 +0100 Subject: [PATCH 854/969] erroot --- sh/main.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 4925099..e4f45ba 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -64,10 +64,8 @@ _sh_main_commands() { main_source_directory() { local path="${1}" - if [ ! -d "${path}" ]; then - _sh_main_log "Not a directory: ${path}" + [ -d "${path}" ] || return 1 - fi local cmd count module modules modules="$(sh_source_find "${path}" "${SH_MAIN_NAME}")" _sh_ifs_new @@ -100,7 +98,10 @@ sh_help() { } sh_main() { - main_source_directory "${SH_ROOT}" + if ! main_source_directory "${SH_ROOT}"; then + _sh_main_log "Not a directory: ${SH_ROOT}" + return 1 + fi main_source_directory "${SH_USER}" sh_log sh_shellcheck "${SH_ROOT}" From 13e89092e4cdea1a4fbad0873803d4e80e7524a9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 20:40:57 +0100 Subject: [PATCH 855/969] public/find --- sh/main.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index e4f45ba..99882a7 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -40,22 +40,6 @@ _sh_main_log() { # sort -sh_source_find() { - local root="${1}" - local file="${2}" - set -- \ - "${root}" \ - -name "*.sh" \ - -type "f" - [ -n "${file}" ] && - set -- "${@}" \ - -not \ - -name "${file}" - find "${@}" \ - -printf "%P\n" | - sort -} - _sh_main_commands() { local file="${1}" grep "()" "${file}" | @@ -90,6 +74,22 @@ main_source_directory() { # public +sh_source_find() { + local root="${1}" + local file="${2}" + set -- \ + "${root}" \ + -name "*.sh" \ + -type "f" + [ -n "${file}" ] && + set -- "${@}" \ + -not \ + -name "${file}" + find "${@}" \ + -printf "%P\n" | + sort +} + sh_help() { sh_log \ "sh_… = shell functions" \ From ff7f64e670aa5e143f884d6dd744fa062e6c8e19 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 20:46:09 +0100 Subject: [PATCH 856/969] find/ext,sh --- sh/main.sh | 15 ++++++++++----- sh/shellcheck.sh | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 99882a7..7921bce 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -51,7 +51,7 @@ main_source_directory() { [ -d "${path}" ] || return 1 local cmd count module modules - modules="$(sh_source_find "${path}" "${SH_MAIN_NAME}")" + modules="$(sh_find_sh "${path}" "${SH_MAIN_NAME}")" _sh_ifs_new count=0 _sh_main_log "" \ @@ -74,12 +74,13 @@ main_source_directory() { # public -sh_source_find() { - local root="${1}" - local file="${2}" +sh_find_extension() { + local extension="${1}" + local root="${2}" + local file="${3}" set -- \ "${root}" \ - -name "*.sh" \ + -name "*.${extension}" \ -type "f" [ -n "${file}" ] && set -- "${@}" \ @@ -90,6 +91,10 @@ sh_source_find() { sort } +sh_find_sh() { + sh_find_extension "sh" "${@}" +} + sh_help() { sh_log \ "sh_… = shell functions" \ diff --git a/sh/shellcheck.sh b/sh/shellcheck.sh index d5ccb53..567568c 100644 --- a/sh/shellcheck.sh +++ b/sh/shellcheck.sh @@ -2,7 +2,7 @@ sh_shellcheck() { local root="${1}" local file module modules file="$(mktemp)" - modules="$(sh_source_find "${root}")" + modules="$(sh_find_sh "${root}")" _sh_ifs_new for module in ${modules}; do echo ". \"${root}/${module}\"" >>"${file}" From ff077a039a17129c1471cb45089c9810c778a5f3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 21:00:14 +0100 Subject: [PATCH 857/969] grep_functions --- sh/main.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 7921bce..bc3fecc 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -40,12 +40,6 @@ _sh_main_log() { # sort -_sh_main_commands() { - local file="${1}" - grep "()" "${file}" | - cut --delimiter "(" --fields 1 -} - main_source_directory() { local path="${1}" [ -d "${path}" ] || @@ -62,7 +56,7 @@ main_source_directory() { module="${path}/${module}" # shellcheck disable=SC1090 . "${module}" - cmd="$(_sh_main_commands "${module}")" + cmd="$(sh_grep_functions "${module}")" if [ -n "${cmd}" ]; then [ -n "${CMD}" ] && CMD="${CMD} " @@ -95,6 +89,12 @@ sh_find_sh() { sh_find_extension "sh" "${@}" } +sh_grep_functions() { + local file="${1}" + grep "()" "${file}" | + cut --delimiter "(" --fields 1 +} + sh_help() { sh_log \ "sh_… = shell functions" \ From 4c862481f77ca1c127556a9efaf65b51f529896a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 22:21:01 +0100 Subject: [PATCH 858/969] main/source_dir --- sh/main.sh | 62 ++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index bc3fecc..6c18b48 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -38,34 +38,6 @@ _sh_main_log() { esac } -# sort - -main_source_directory() { - local path="${1}" - [ -d "${path}" ] || - return 1 - local cmd count module modules - modules="$(sh_find_sh "${path}" "${SH_MAIN_NAME}")" - _sh_ifs_new - count=0 - _sh_main_log "" \ - ". ${path}" - for module in ${modules}; do - count=$((count + 1)) - _sh_main_log "$(printf "%02d" "${count}") ${module%.sh}" - module="${path}/${module}" - # shellcheck disable=SC1090 - . "${module}" - cmd="$(sh_grep_functions "${module}")" - if [ -n "${cmd}" ]; then - [ -n "${CMD}" ] && CMD="${CMD} -" - CMD="${CMD}${cmd}" - fi - done - _sh_ifs_pop -} - # public sh_find_extension() { @@ -102,18 +74,44 @@ sh_help() { "u__… = user" } +sh_source_directory() { + local path="${1}" + [ -d "${path}" ] || + return 1 + local cmd count module modules + modules="$(sh_find_sh "${path}" "${SH_MAIN_NAME}")" + _sh_ifs_new + count=0 + _sh_main_log "" \ + ". ${path}" + for module in ${modules}; do + count=$((count + 1)) + _sh_main_log "$(printf "%02d" "${count}") ${module%.sh}" + module="${path}/${module}" + # shellcheck disable=SC1090 + . "${module}" + cmd="$(sh_grep_functions "${module}")" + if [ -n "${cmd}" ]; then + [ -n "${CMD}" ] && CMD="${CMD} +" + CMD="${CMD}${cmd}" + fi + done + _sh_ifs_pop +} + +# main + sh_main() { - if ! main_source_directory "${SH_ROOT}"; then + if ! sh_source_directory "${SH_ROOT}"; then _sh_main_log "Not a directory: ${SH_ROOT}" return 1 fi - main_source_directory "${SH_USER}" + sh_source_directory "${SH_USER}" sh_log sh_shellcheck "${SH_ROOT}" sh_log sh_help } -# main - sh_main From 05271ef8285f77772637b2fd22f7178604b56296 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 11:28:28 +0100 Subject: [PATCH 859/969] members --- sh/rescue/hetzner.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/sh/rescue/hetzner.sh b/sh/rescue/hetzner.sh index 8d7f02b..8d4f56d 100644 --- a/sh/rescue/hetzner.sh +++ b/sh/rescue/hetzner.sh @@ -63,7 +63,6 @@ rescue_wipe_0_init_hetzner_8_8() { for device in "${@}"; do members="${members} ${device}2" done - # shellcheck disable=SC2086 sh_fs_raid_create \ "boot" "00000000:00000000:00000000:00000002" ${members} # @@ -88,7 +87,6 @@ rescue_wipe_0_init_hetzner_8_8() { for device in "${@}"; do members="${members} ${device}1" done - # shellcheck disable=SC2086 sh_fs_raid_create \ "crypt" "00000000:00000000:00000000:00000001" ${members} # encrypt From eee9e38b7d7a7954a3be6e22a58eeb9508bd26d6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 11:55:03 +0100 Subject: [PATCH 860/969] shell/interactive --- sh/main.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sh/main.sh b/sh/main.sh index 6c18b48..692664a 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -74,6 +74,13 @@ sh_help() { "u__… = user" } +sh_shell_interactive() { + case "${-}" in + *i*) ;; + *) return 1 ;; + esac +} + sh_source_directory() { local path="${1}" [ -d "${path}" ] || From 1572a779ae7f25576758891489f5976197b519f7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 12:01:01 +0100 Subject: [PATCH 861/969] if interactive --- sh/main.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 692664a..4c99298 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -26,16 +26,13 @@ _sh_ifs_pop() { } _sh_main_log() { - case "${-}" in - *i*) + if sh_shell_interactive; then [ ${#} -gt 0 ] || set -- "" local line for line in "${@}"; do echo "${line}" done - ;; - *) ;; - esac + fi } # public @@ -115,10 +112,12 @@ sh_main() { return 1 fi sh_source_directory "${SH_USER}" - sh_log - sh_shellcheck "${SH_ROOT}" - sh_log - sh_help + if sh_shell_interactive; then + sh_log + sh_shellcheck "${SH_ROOT}" + sh_log + sh_help + fi } sh_main From 321070d5cc825d027439738a6f17e251b6c80f66 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 12:17:39 +0100 Subject: [PATCH 862/969] +shfmt --- sh/shellcheck.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sh/shellcheck.sh b/sh/shellcheck.sh index 567568c..7b04827 100644 --- a/sh/shellcheck.sh +++ b/sh/shellcheck.sh @@ -1,11 +1,13 @@ sh_shellcheck() { local root="${1}" - local file module modules + local file module modules path file="$(mktemp)" modules="$(sh_find_sh "${root}")" _sh_ifs_new for module in ${modules}; do - echo ". \"${root}/${module}\"" >>"${file}" + path="${root}/${module}" + shfmt --diff "${path}" + echo ". \"${path}\"" >>"${file}" done _sh_ifs_pop shellcheck \ From b93a6909bb4275ac5f85cf19514b6aceca122f71 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 15:42:58 +0100 Subject: [PATCH 863/969] comments --- sh/main.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sh/main.sh b/sh/main.sh index 4c99298..e91efbf 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -37,6 +37,7 @@ _sh_main_log() { # public +# find directory’s files by extension sh_find_extension() { local extension="${1}" local root="${2}" @@ -54,16 +55,19 @@ sh_find_extension() { sort } +# find directory’s sh files sh_find_sh() { sh_find_extension "sh" "${@}" } +# get functions from file sh_grep_functions() { local file="${1}" grep "()" "${file}" | cut --delimiter "(" --fields 1 } +# output help message sh_help() { sh_log \ "sh_… = shell functions" \ @@ -71,6 +75,7 @@ sh_help() { "u__… = user" } +# test if active shell is in interactive mode sh_shell_interactive() { case "${-}" in *i*) ;; @@ -106,18 +111,25 @@ sh_source_directory() { # main +# run initial steps sh_main() { + # system root if ! sh_source_directory "${SH_ROOT}"; then _sh_main_log "Not a directory: ${SH_ROOT}" return 1 fi + # user root sh_source_directory "${SH_USER}" + # run interactive extras if sh_shell_interactive; then + # check sh_log sh_shellcheck "${SH_ROOT}" + # help sh_log sh_help fi } +# run main function sh_main From 6eec85df21914a7d884cec08e1b787726817cd99 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 15:45:32 +0100 Subject: [PATCH 864/969] main/frames --- sh/main.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index e91efbf..cf5f767 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -1,4 +1,6 @@ -# constants +# ╭───────────╮ +# │ constants │ +# ╰───────────╯ SH_MAIN_NAME="main.sh" SH_NAME="sh" @@ -7,12 +9,16 @@ SH_ROOT="/etc/${SH_NAME}" SH_MAIN="${SH_ROOT}/${SH_MAIN_NAME}" -# variables +# ╭───────────╮ +# │ variables │ +# ╰───────────╯ SH_SHELL="$(cat "/proc/${$}/comm")" SH_USER="${HOME}/${SH_NAME}" -# private +# ╭─────────╮ +# │ private │ +# ╰─────────╯ _sh_ifs_new() { SH_IFS="${IFS}" @@ -35,7 +41,9 @@ _sh_main_log() { fi } -# public +# ╭────────╮ +# │ public │ +# ╰────────╯ # find directory’s files by extension sh_find_extension() { @@ -109,7 +117,9 @@ sh_source_directory() { _sh_ifs_pop } -# main +# ╭──────╮ +# │ main │ +# ╰──────╯ # run initial steps sh_main() { From 75e7e2330d73daa714f2407e163ce92ea8c4cc4a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 17:13:51 +0100 Subject: [PATCH 865/969] rwx/main --- sh/main.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index cf5f767..acdb7a2 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -122,7 +122,7 @@ sh_source_directory() { # ╰──────╯ # run initial steps -sh_main() { +rwx_main() { # system root if ! sh_source_directory "${SH_ROOT}"; then _sh_main_log "Not a directory: ${SH_ROOT}" @@ -142,4 +142,4 @@ sh_main() { } # run main function -sh_main +rwx_main From 835f7339f37ead10416f0182ca7718d3b46b9dff Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 17:15:09 +0100 Subject: [PATCH 866/969] rwx/help --- sh/main.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index acdb7a2..8ad5695 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -76,7 +76,7 @@ sh_grep_functions() { } # output help message -sh_help() { +rwx_help() { sh_log \ "sh_… = shell functions" \ "a__… = aliases" \ @@ -137,7 +137,7 @@ rwx_main() { sh_shellcheck "${SH_ROOT}" # help sh_log - sh_help + rwx_help fi } From 68a4d518700e35466df98733acf833c3376775c6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 17:16:56 +0100 Subject: [PATCH 867/969] rwx/shellcheck --- sh/main.sh | 2 +- sh/shellcheck.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 8ad5695..92b9601 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -134,7 +134,7 @@ rwx_main() { if sh_shell_interactive; then # check sh_log - sh_shellcheck "${SH_ROOT}" + rwx_shellcheck_check "${SH_ROOT}" # help sh_log rwx_help diff --git a/sh/shellcheck.sh b/sh/shellcheck.sh index 7b04827..703b21d 100644 --- a/sh/shellcheck.sh +++ b/sh/shellcheck.sh @@ -1,4 +1,4 @@ -sh_shellcheck() { +rwx_shellcheck_check() { local root="${1}" local file module modules path file="$(mktemp)" From f25059d1593126cb82f859759fac71a2efc8a508 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 17:20:38 +0100 Subject: [PATCH 868/969] shfmt --- sh/main.sh | 5 ++++- sh/shellcheck.sh | 1 - sh/shfmt.sh | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 sh/shfmt.sh diff --git a/sh/main.sh b/sh/main.sh index 92b9601..7d85c49 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -132,7 +132,10 @@ rwx_main() { sh_source_directory "${SH_USER}" # run interactive extras if sh_shell_interactive; then - # check + # check format + sh_log + rwx_shfmt "${SH_ROOT}" + # check syntax sh_log rwx_shellcheck_check "${SH_ROOT}" # help diff --git a/sh/shellcheck.sh b/sh/shellcheck.sh index 703b21d..df2c02d 100644 --- a/sh/shellcheck.sh +++ b/sh/shellcheck.sh @@ -6,7 +6,6 @@ rwx_shellcheck_check() { _sh_ifs_new for module in ${modules}; do path="${root}/${module}" - shfmt --diff "${path}" echo ". \"${path}\"" >>"${file}" done _sh_ifs_pop diff --git a/sh/shfmt.sh b/sh/shfmt.sh new file mode 100644 index 0000000..107170b --- /dev/null +++ b/sh/shfmt.sh @@ -0,0 +1,4 @@ +rwx_shfmt_check() { + local root="${1}" + shfmt --diff "${root}" +} From 57da8c62123d4a89cef1c92a05143961f1416411 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 17:21:19 +0100 Subject: [PATCH 869/969] lint --- sh/{ => lint}/shellcheck.sh | 0 sh/{ => lint}/shfmt.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename sh/{ => lint}/shellcheck.sh (100%) rename sh/{ => lint}/shfmt.sh (100%) diff --git a/sh/shellcheck.sh b/sh/lint/shellcheck.sh similarity index 100% rename from sh/shellcheck.sh rename to sh/lint/shellcheck.sh diff --git a/sh/shfmt.sh b/sh/lint/shfmt.sh similarity index 100% rename from sh/shfmt.sh rename to sh/lint/shfmt.sh From 24a623bd6efca50076865678c9471d46d38f86d2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 17:46:09 +0100 Subject: [PATCH 870/969] fix --- sh/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/main.sh b/sh/main.sh index 7d85c49..2611ebe 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -134,7 +134,7 @@ rwx_main() { if sh_shell_interactive; then # check format sh_log - rwx_shfmt "${SH_ROOT}" + rwx_shfmt_check "${SH_ROOT}" # check syntax sh_log rwx_shellcheck_check "${SH_ROOT}" From 1e5451f05992f68bb5cf81f858e9e95c60cec577 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 18:31:49 +0100 Subject: [PATCH 871/969] main/source --- sh/main.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 2611ebe..6376e03 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -91,7 +91,7 @@ sh_shell_interactive() { esac } -sh_source_directory() { +rwx_main_source() { local path="${1}" [ -d "${path}" ] || return 1 @@ -124,12 +124,12 @@ sh_source_directory() { # run initial steps rwx_main() { # system root - if ! sh_source_directory "${SH_ROOT}"; then + if ! rwx_main_source "${SH_ROOT}"; then _sh_main_log "Not a directory: ${SH_ROOT}" return 1 fi # user root - sh_source_directory "${SH_USER}" + rwx_main_source "${SH_USER}" # run interactive extras if sh_shell_interactive; then # check format From 32b5389786152824f0ac22bb045e3c6f8b981fe7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 18:46:52 +0100 Subject: [PATCH 872/969] main/log --- sh/main.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 6376e03..dbba6c3 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -31,7 +31,7 @@ _sh_ifs_pop() { unset SH_IFS } -_sh_main_log() { +_rwx_main_log() { if sh_shell_interactive; then [ ${#} -gt 0 ] || set -- "" local line @@ -99,11 +99,11 @@ rwx_main_source() { modules="$(sh_find_sh "${path}" "${SH_MAIN_NAME}")" _sh_ifs_new count=0 - _sh_main_log "" \ + _rwx_main_log "" \ ". ${path}" for module in ${modules}; do count=$((count + 1)) - _sh_main_log "$(printf "%02d" "${count}") ${module%.sh}" + _rwx_main_log "$(printf "%02d" "${count}") ${module%.sh}" module="${path}/${module}" # shellcheck disable=SC1090 . "${module}" @@ -125,7 +125,7 @@ rwx_main_source() { rwx_main() { # system root if ! rwx_main_source "${SH_ROOT}"; then - _sh_main_log "Not a directory: ${SH_ROOT}" + _rwx_main_log "Not a directory: ${SH_ROOT}" return 1 fi # user root From f1192c0c58cbf4717de5d9e607df4e4d1dcf61fd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 18:48:21 +0100 Subject: [PATCH 873/969] shell/interactive --- sh/main.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index dbba6c3..b8ed82d 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -32,7 +32,7 @@ _sh_ifs_pop() { } _rwx_main_log() { - if sh_shell_interactive; then + if rwx_shell_interactive; then [ ${#} -gt 0 ] || set -- "" local line for line in "${@}"; do @@ -84,7 +84,7 @@ rwx_help() { } # test if active shell is in interactive mode -sh_shell_interactive() { +rwx_shell_interactive() { case "${-}" in *i*) ;; *) return 1 ;; @@ -131,7 +131,7 @@ rwx_main() { # user root rwx_main_source "${SH_USER}" # run interactive extras - if sh_shell_interactive; then + if rwx_shell_interactive; then # check format sh_log rwx_shfmt_check "${SH_ROOT}" From 04199bdfbb9be1bb9d5e7ddb602ee31773996620 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 18:55:34 +0100 Subject: [PATCH 874/969] rescue --- sh/rescue/common.sh | 14 +++++++------- sh/rescue/hetzner.sh | 4 ++-- sh/rescue/ovh.sh | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sh/rescue/common.sh b/sh/rescue/common.sh index d28591b..f2c9d10 100644 --- a/sh/rescue/common.sh +++ b/sh/rescue/common.sh @@ -1,4 +1,4 @@ -rescue_configure() { +rwx_rescue_configure() { local hostname="${1}" # apt / conf sh_apt_conf_write @@ -28,7 +28,7 @@ fr_FR.UTF-8 UTF-8 sh_apt_update } -rescue_install() { +rwx_rescue_install() { # update catalog sh_apt_update # disable frontend @@ -51,7 +51,7 @@ rescue_install() { "grub-efi-amd64-bin" } -rescue_upload() { +rwx_rescue_upload() { local host="${1}" local hostname="${2}" if [ -n "${hostname}" ]; then @@ -70,11 +70,11 @@ rescue_upload() { # call setup # TODO variable ssh "${user_host}" -- \ - ". \"${ENV}\" ; rescue_configure \"${hostname}\"" + ". \"${ENV}\" ; rwx_rescue_configure \"${hostname}\"" # create session ssh "${user_host}" -- byobu new-session -d # send keys - ssh "${user_host}" -- byobu send-keys "rescue_install" "C-m" + ssh "${user_host}" -- byobu send-keys "rwx_rescue_install" "C-m" # attach session mosh "${user_host}" -- byobu attach-session else @@ -83,11 +83,11 @@ rescue_upload() { fi } -rescue_wipe_1_zero() { +rwx_rescue_wipe_1_zero() { sh_fs_wipe "/dev/mapper/crypt" "512M" } -rescue_wipe_3_close() { +rwx_rescue_wipe_3_close() { umount "/media/boot" umount "/media/crypt" && cryptsetup luksClose "crypt" diff --git a/sh/rescue/hetzner.sh b/sh/rescue/hetzner.sh index 8d4f56d..8fe73e3 100644 --- a/sh/rescue/hetzner.sh +++ b/sh/rescue/hetzner.sh @@ -1,4 +1,4 @@ -rescue_wipe_0_init_hetzner_8_8() { +rwx_rescue_wipe_0_init_hetzner_8_8() { local device set \ "/dev/sda" \ @@ -98,7 +98,7 @@ rescue_wipe_0_init_hetzner_8_8() { unset passphrase } -rescue_wipe_2_make_hetzner_8_8() { +rwx_rescue_wipe_2_make_hetzner_8_8() { local passphrase # close cryptsetup luksClose "crypt" diff --git a/sh/rescue/ovh.sh b/sh/rescue/ovh.sh index 0d3c860..c7d89c2 100644 --- a/sh/rescue/ovh.sh +++ b/sh/rescue/ovh.sh @@ -1,4 +1,4 @@ -rescue_wipe_0_init_ovh_vle2() { +rwx_rescue_wipe_0_init_ovh_vle2() { local device="/dev/sdb" local passphrase # read passphrase @@ -44,7 +44,7 @@ rescue_wipe_0_init_ovh_vle2() { unset passphrase } -rescue_wipe_2_make_ovh_vle2() { +rwx_rescue_wipe_2_make_ovh_vle2() { local device="/dev/sdb" local passphrase # crypt / close From 4ba9c94a4282a17b84ff3720266bc8b734c38663 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 18:56:59 +0100 Subject: [PATCH 875/969] gnome --- sh/gnome.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/gnome.sh b/sh/gnome.sh index ff15c10..c30e612 100644 --- a/sh/gnome.sh +++ b/sh/gnome.sh @@ -1,4 +1,4 @@ -sh_gnome_proxy() { +rwx_gnome_proxy() { local value case "${1}" in "on") value="manual" ;; @@ -7,7 +7,7 @@ sh_gnome_proxy() { gsettings set "org.gnome.system.proxy" "mode" "${value}" } -sh_gnome_workspaces_primary() { +rwx_gnome_workspaces_primary() { local bool local group="org.gnome.mutter" local name="workspaces-only-on-primary" From 7719b6a56269d9e354e84ff6fef26ccdb2a72d60 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 18:57:41 +0100 Subject: [PATCH 876/969] gpg --- sh/gpg.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/gpg.sh b/sh/gpg.sh index 26a4e6e..a2b7f50 100644 --- a/sh/gpg.sh +++ b/sh/gpg.sh @@ -1,4 +1,4 @@ -sh_gpg_ssh_auth_sock() { +rwx_gpg_ssh_auth_sock() { local user_id user_id=$(id --user) if [ "${user_id}" -ne 0 ]; then @@ -9,4 +9,4 @@ sh_gpg_ssh_auth_sock() { fi } -sh_gpg_ssh_auth_sock +rwx_gpg_ssh_auth_sock From e811d73563fdf8b5f573a2e9b1255a66dc77713d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 18:59:56 +0100 Subject: [PATCH 877/969] fs --- sh/fs.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sh/fs.sh b/sh/fs.sh index 95965e2..ac46f6d 100644 --- a/sh/fs.sh +++ b/sh/fs.sh @@ -1,4 +1,4 @@ -sh_fs_make_btrfs() { +rwx_fs_make_btrfs() { local device="${1}" local label="${2}" local uuid="${3}" @@ -18,7 +18,7 @@ sh_fs_make_btrfs() { fi } -sh_fs_make_btrfs_swap() { +rwx_fs_make_btrfs_swap() { local path="${1}" local size="${2}" local uuid="${3}" @@ -36,7 +36,7 @@ sh_fs_make_btrfs_swap() { fi } -sh_fs_make_fat() { +rwx_fs_make_fat() { local device="${1}" local name="${2}" local volid="${3}" @@ -56,7 +56,7 @@ sh_fs_make_fat() { fi } -sh_fs_raid_create() { +rwx_fs_raid_create() { if [ -n "${4}" ]; then local name="${1}" local uuid="${2}" @@ -72,7 +72,7 @@ sh_fs_raid_create() { fi } -sh_fs_wipe() { +rwx_fs_wipe() { local device="${1}" local buffer="${2}" local count="${3}" @@ -93,7 +93,7 @@ sh_fs_wipe() { fi } -sh_fs_luks_format() { +rwx_fs_luks_format() { local passphrase="${1}" local device="${2}" local label="${3}" From 897a228614388e258a399145cea58beca492ec3e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 19:04:20 +0100 Subject: [PATCH 878/969] debian --- sh/debian.sh | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/sh/debian.sh b/sh/debian.sh index b544f08..88e8b01 100644 --- a/sh/debian.sh +++ b/sh/debian.sh @@ -1,14 +1,14 @@ -SH_DEBIAN_CODENAME="$( +RWX_DEBIAN_CODENAME="$( grep "VERSION_CODENAME" "/etc/os-release" | cut --delimiter "=" --fields "2" )" -sh_apt_clean() { +rwx_apt_clean() { apt-get \ clean } -sh_apt_conf_write() { +rwx_apt_conf_write() { printf "\ Acquire::AllowInsecureRepositories False; Acquire::AllowWeakRepositories False; @@ -22,55 +22,55 @@ Dpkg::Progress True; " >"/etc/apt/apt.conf.d/apt.conf" } -sh_apt_install_backports() { - sh_apt_install_target "${SH_DEBIAN_CODENAME}-backports" "${@}" +rwx_apt_install_backports() { + rwx_apt_install_target "${RWX_DEBIAN_CODENAME}-backports" "${@}" } -sh_apt_install_release() { - sh_apt_install_target "${SH_DEBIAN_CODENAME}" "${@}" +rwx_apt_install_release() { + rwx_apt_install_target "${RWX_DEBIAN_CODENAME}" "${@}" } -sh_apt_install_target() { +rwx_apt_install_target() { local target="${1}" shift local package for package in "${@}"; do - sh_log_info - sh_log_info "${package} ← ${target}" + rwx_log "" \ + "${package} ← ${target}" apt-get \ install \ --assume-yes \ --target-release "${target}" \ "${package}" - sh_apt_clean + rwx_apt_clean done } -sh_apt_sources_write() { +rwx_apt_sources_write() { printf "%s" "\ deb https://deb.debian.org/debian \ -${SH_DEBIAN_CODENAME} main non-free-firmware contrib non-free +${RWX_DEBIAN_CODENAME} main non-free-firmware contrib non-free deb https://deb.debian.org/debian \ -${SH_DEBIAN_CODENAME}-backports main non-free-firmware contrib non-free +${RWX_DEBIAN_CODENAME}-backports main non-free-firmware contrib non-free deb https://deb.debian.org/debian \ -${SH_DEBIAN_CODENAME}-updates main non-free-firmware contrib non-free +${RWX_DEBIAN_CODENAME}-updates main non-free-firmware contrib non-free deb https://deb.debian.org/debian-security \ -${SH_DEBIAN_CODENAME}-security main non-free-firmware contrib non-free +${RWX_DEBIAN_CODENAME}-security main non-free-firmware contrib non-free " >"/etc/apt/sources.list" } -sh_apt_update() { +rwx_apt_update() { apt-get \ update } -sh_apt_upgrade() { +rwx_apt_upgrade() { apt-get \ upgrade \ --assume-yes - sh_apt_clean + rwx_apt_clean } -sh_debian_frontend_disable() { +rwx_debian_frontend_disable() { export DEBIAN_FRONTEND="noninteractive" } From 1bae77cd6a902cf0e19daaaca4502c0ba2809e2d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 19:04:39 +0100 Subject: [PATCH 879/969] live --- sh/live.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/live.sh b/sh/live.sh index dc77ce5..7d82bfc 100644 --- a/sh/live.sh +++ b/sh/live.sh @@ -1,5 +1,5 @@ # remount read-only medium in read-write -sh_live_medium_remount() { +rwx_live_medium_remount() { mount \ -o "remount,rw" \ "/usr/lib/live/mount/medium" From 7b1e6b0fd5149d32292574e7d414f3b57ffae13f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 19:08:06 +0100 Subject: [PATCH 880/969] log --- sh/log.sh | 62 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/sh/log.sh b/sh/log.sh index 2be59e0..9b2ffc4 100644 --- a/sh/log.sh +++ b/sh/log.sh @@ -1,68 +1,68 @@ -SH_LOG_LEVEL_FATAL=0 -SH_LOG_LEVEL_ERROR=1 -SH_LOG_LEVEL_WARN=2 -SH_LOG_LEVEL_INFO=3 -SH_LOG_LEVEL_DEBUG=4 -SH_LOG_LEVEL_TRACE=5 +RWX_LOG_LEVEL_FATAL=0 +RWX_LOG_LEVEL_ERROR=1 +RWX_LOG_LEVEL_WARN=2 +RWX_LOG_LEVEL_INFO=3 +RWX_LOG_LEVEL_DEBUG=4 +RWX_LOG_LEVEL_TRACE=5 -SH_LOG_LEVEL=${SH_LOG_LEVEL_INFO} +RWX_LOG_LEVEL=${RWX_LOG_LEVEL_INFO} -sh_log() { sh_log_info "${@}"; } +rwx_log() { rwx_log_info "${@}"; } -sh_log_debug() { - if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_DEBUG}" ]; then - _sh_log "[DEBUG]" "${@}" +rwx_log_debug() { + if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_DEBUG}" ]; then + _rwx_log "[DEBUG]" "${@}" fi } -sh_log_error() { +rwx_log_error() { local code="${1}" shift - [ -n "${code}" ] || sh_log_fatal 1 "No error code" - if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_ERROR}" ]; then - _sh_log "[ERROR]" "${@}" >&2 + [ -n "${code}" ] || rwx_log_fatal 1 "No error code" + if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_ERROR}" ]; then + _rwx_log "[ERROR]" "${@}" >&2 return "${code}" fi } -sh_log_fatal() { +rwx_log_fatal() { local code="${1}" shift - [ -n "${code}" ] || sh_log_fatal 1 "No error code" - if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_FATAL}" ]; then - _sh_log "[FATAL]" "${@}" >&2 + [ -n "${code}" ] || rwx_log_fatal 1 "No error code" + if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_FATAL}" ]; then + _rwx_log "[FATAL]" "${@}" >&2 exit "${code}" fi } -sh_log_info() { - if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_INFO}" ]; then - _sh_log "" "${@}" +rwx_log_info() { + if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_INFO}" ]; then + _rwx_log "" "${@}" fi } -sh_log_trace() { - if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_TRACE}" ]; then - _sh_log "[TRACE]" "${@}" +rwx_log_trace() { + if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_TRACE}" ]; then + _rwx_log "[TRACE]" "${@}" fi } -sh_log_warn() { - if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_WARN}" ]; then - _sh_log "[ WARN]" "${@}" +rwx_log_warn() { + if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_WARN}" ]; then + _rwx_log "[ WARN]" "${@}" fi } -_sh_log() { +_rwx_log() { local prefix="${1}" shift [ ${#} -gt 0 ] || set -- "" local line for line in "${@}"; do if [ -n "${prefix}" ]; then - _sh_main_log "${prefix} ${line}" + _rwx_main_log "${prefix} ${line}" else - _sh_main_log "${line}" + _rwx_main_log "${line}" fi done } From d590bfda0c2bca688b5f6f1d8a58e3f0cf7548ce Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 19:14:38 +0100 Subject: [PATCH 881/969] shell --- sh/shell.sh | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/sh/shell.sh b/sh/shell.sh index 3a76cb6..a5f1b99 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -1,4 +1,4 @@ -_sh_shell_color() { +_rwx_shell_color() { local code="${1}" case "${SH_SHELL}" in "bash") @@ -19,18 +19,18 @@ _sh_shell_color() { ;; esac } -SH_COLOR_BROWN="$(_sh_shell_color 33)" -SH_COLOR_CYAN="$(_sh_shell_color 36)" -SH_COLOR_DEFAULT="$(_sh_shell_color)" -SH_COLOR_GREEN="$(_sh_shell_color 31)" -SH_COLOR_MAGENTA="$(_sh_shell_color 35)" -SH_COLOR_RED="$(_sh_shell_color 32)" +RWX_COLOR_BROWN="$(_rwx_shell_color 33)" +RWX_COLOR_CYAN="$(_rwx_shell_color 36)" +RWX_COLOR_DEFAULT="$(_rwx_shell_color)" +RWX_COLOR_GREEN="$(_rwx_shell_color 31)" +RWX_COLOR_MAGENTA="$(_rwx_shell_color 35)" +RWX_COLOR_RED="$(_rwx_shell_color 32)" -sh_shell_configure() { +rwx_shell_configure() { [ -n "${ENV}" ] || ENV="${SH_MAIN}" export ENV # prompt - PS1="\$(sh_shell_prompt \${?})" + PS1="\$(rwx_shell_prompt \${?})" PS2="├ " # specific case "${SH_SHELL}" in @@ -60,9 +60,9 @@ sh_shell_configure() { *) ;; esac } -sh_shell_configure +rwx_shell_configure -sh_shell_prompt() { +rwx_shell_prompt() { local date host id local code="${1}" date="$(date +%H:%M:%S)" @@ -74,50 +74,50 @@ sh_shell_prompt() { local view="└ " # code if [ "${code}" -ne 0 ]; then - view="${view}${SH_COLOR_GREEN}" + view="${view}${RWX_COLOR_GREEN}" else - view="${view}${SH_COLOR_RED}" + view="${view}${RWX_COLOR_RED}" fi view="${view}${code}" # date - view="${view}${SH_COLOR_DEFAULT} @ " - view="${view}${SH_COLOR_BROWN}${date}" + view="${view}${RWX_COLOR_DEFAULT} @ " + view="${view}${RWX_COLOR_BROWN}${date}" # git if command -v "__git_ps1" >"/dev/null"; then git="$(__git_ps1)" if [ -n "${git}" ]; then - view="${view}${SH_COLOR_DEFAULT} –${SH_COLOR_MAGENTA}${git}" + view="${view}${RWX_COLOR_DEFAULT} –${RWX_COLOR_MAGENTA}${git}" fi fi # new view="${view}\\n" # path - view="${view}${SH_COLOR_CYAN}${path}" + view="${view}${RWX_COLOR_CYAN}${path}" # new view="${view}\\n" # frame - view="${view}${SH_COLOR_DEFAULT}┌ " + view="${view}${RWX_COLOR_DEFAULT}┌ " # user if [ "${id}" -eq 0 ]; then - view="${view}${SH_COLOR_GREEN}" + view="${view}${RWX_COLOR_GREEN}" else - view="${view}${SH_COLOR_RED}" + view="${view}${RWX_COLOR_RED}" fi view="${view}${user}" # host - view="${view}${SH_COLOR_DEFAULT} @ " - view="${view}${SH_COLOR_BROWN}${host}" + view="${view}${RWX_COLOR_DEFAULT} @ " + view="${view}${RWX_COLOR_BROWN}${host}" # new view="${view}\\n" # prompt - view="${view}${SH_COLOR_DEFAULT}${PS2}" + view="${view}${RWX_COLOR_DEFAULT}${PS2}" # print printf "%b" "${view}" } -sh_shell_setup() { +rwx_shell_setup() { # shell - echo "export ENV=\"${ENV}\"" >"/etc/profile.d/sh.sh" + echo "export ENV=\"${ENV}\"" >"/etc/profile.d/${SH_NAME}.sh" # bash local file="/etc/bash.bashrc" rm --force --recursive "${file}" From 4335005aace161cb442aa03fac6be330151d34ef Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 19:18:30 +0100 Subject: [PATCH 882/969] util --- sh/util.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sh/util.sh b/sh/util.sh index 3f1c614..7d9cc3f 100644 --- a/sh/util.sh +++ b/sh/util.sh @@ -1,10 +1,10 @@ -sh_list_block_devices() { +rwx_list_block_devices() { lsblk \ --noempty \ --output "NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINTS" } -sh_not() { +rwx_not() { case "${1}" in "false") echo "true" ;; "true") echo "false" ;; @@ -12,11 +12,11 @@ sh_not() { esac } -sh_read_passphrase() { - sh_read_secret "PassPhrase: " +rwx_read_passphrase() { + rwx_read_secret "PassPhrase: " } -sh_read_secret() { +rwx_read_secret() { local prompt="${1}" local secret printf "%s" "${prompt}" 1>&2 @@ -28,10 +28,10 @@ sh_read_secret() { unset secret } -sh_warn_wipe() { +rwx_warn_wipe() { local tmp - sh_list_block_devices + rwx_list_block_devices printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\" read -r tmp - sh_log_trace "${tmp}" + rwx_log_trace "${tmp}" } From 903faba54ed3121005cd3f5cbe32b0e6f22f48a1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 19:25:49 +0100 Subject: [PATCH 883/969] main --- sh/main.sh | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index b8ed82d..694b38b 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -16,19 +16,25 @@ SH_MAIN="${SH_ROOT}/${SH_MAIN_NAME}" SH_SHELL="$(cat "/proc/${$}/comm")" SH_USER="${HOME}/${SH_NAME}" +# ╭──────────╮ +# │ internal │ +# ╰──────────╯ + +# _RWX_IFS + # ╭─────────╮ # │ private │ # ╰─────────╯ -_sh_ifs_new() { - SH_IFS="${IFS}" +rwx_ifs_set() { + _RWX_IFS="${IFS}" IFS=" " } -_sh_ifs_pop() { - IFS="${SH_IFS}" - unset SH_IFS +rwx_ifs_unset() { + IFS="${_RWX_IFS}" + unset RWX_IFS } _rwx_main_log() { @@ -46,7 +52,7 @@ _rwx_main_log() { # ╰────────╯ # find directory’s files by extension -sh_find_extension() { +rwx_find_extension() { local extension="${1}" local root="${2}" local file="${3}" @@ -64,12 +70,12 @@ sh_find_extension() { } # find directory’s sh files -sh_find_sh() { - sh_find_extension "sh" "${@}" +rwx_find_sh() { + rwx_find_extension "sh" "${@}" } # get functions from file -sh_grep_functions() { +rwx_grep_functions() { local file="${1}" grep "()" "${file}" | cut --delimiter "(" --fields 1 @@ -77,10 +83,10 @@ sh_grep_functions() { # output help message rwx_help() { - sh_log \ - "sh_… = shell functions" \ - "a__… = aliases" \ - "u__… = user" + rwx_log \ + "rwx_… = functions" \ + " a__… = aliases" \ + " u__… = user" } # test if active shell is in interactive mode @@ -96,8 +102,8 @@ rwx_main_source() { [ -d "${path}" ] || return 1 local cmd count module modules - modules="$(sh_find_sh "${path}" "${SH_MAIN_NAME}")" - _sh_ifs_new + modules="$(rwx_find_sh "${path}" "${SH_MAIN_NAME}")" + rwx_ifs_set count=0 _rwx_main_log "" \ ". ${path}" @@ -107,14 +113,14 @@ rwx_main_source() { module="${path}/${module}" # shellcheck disable=SC1090 . "${module}" - cmd="$(sh_grep_functions "${module}")" + cmd="$(rwx_grep_functions "${module}")" if [ -n "${cmd}" ]; then [ -n "${CMD}" ] && CMD="${CMD} " CMD="${CMD}${cmd}" fi done - _sh_ifs_pop + rwx_ifs_unset } # ╭──────╮ @@ -133,13 +139,13 @@ rwx_main() { # run interactive extras if rwx_shell_interactive; then # check format - sh_log + rwx_log rwx_shfmt_check "${SH_ROOT}" # check syntax - sh_log + rwx_log rwx_shellcheck_check "${SH_ROOT}" # help - sh_log + rwx_log rwx_help fi } From de22cafbd0c3d630235f7987ad59093b8416be7a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 19:41:07 +0100 Subject: [PATCH 884/969] main --- sh/main.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 694b38b..b2dd223 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -2,19 +2,19 @@ # │ constants │ # ╰───────────╯ -SH_MAIN_NAME="main.sh" -SH_NAME="sh" +RWX_MAIN_FILE_NAME="main.sh" +RWX_NAME="sh" -SH_ROOT="/etc/${SH_NAME}" +RWX_ROOT_SYSTEM="/etc/${RWX_NAME}" -SH_MAIN="${SH_ROOT}/${SH_MAIN_NAME}" +RWX_MAIN="${RWX_ROOT_SYSTEM}/${RWX_MAIN_FILE_NAME}" # ╭───────────╮ # │ variables │ # ╰───────────╯ -SH_SHELL="$(cat "/proc/${$}/comm")" -SH_USER="${HOME}/${SH_NAME}" +RWX_SHELL="$(cat "/proc/${$}/comm")" +RWX_ROOT_USER="${HOME}/${RWX_NAME}" # ╭──────────╮ # │ internal │ @@ -102,7 +102,7 @@ rwx_main_source() { [ -d "${path}" ] || return 1 local cmd count module modules - modules="$(rwx_find_sh "${path}" "${SH_MAIN_NAME}")" + modules="$(rwx_find_sh "${path}" "${RWX_MAIN_FILE_NAME}")" rwx_ifs_set count=0 _rwx_main_log "" \ @@ -130,20 +130,20 @@ rwx_main_source() { # run initial steps rwx_main() { # system root - if ! rwx_main_source "${SH_ROOT}"; then - _rwx_main_log "Not a directory: ${SH_ROOT}" + if ! rwx_main_source "${RWX_ROOT_SYSTEM}"; then + _rwx_main_log "Not a directory: ${RWX_ROOT_SYSTEM}" return 1 fi # user root - rwx_main_source "${SH_USER}" + rwx_main_source "${RWX_ROOT_USER}" # run interactive extras if rwx_shell_interactive; then # check format rwx_log - rwx_shfmt_check "${SH_ROOT}" + rwx_shfmt_check "${RWX_ROOT_SYSTEM}" # check syntax rwx_log - rwx_shellcheck_check "${SH_ROOT}" + rwx_shellcheck_check "${RWX_ROOT_SYSTEM}" # help rwx_log rwx_help From ecff8f16bc3cd12eb0f412f32cd12af75c6ab7cc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 19:43:06 +0100 Subject: [PATCH 885/969] sc/ifs --- sh/lint/shellcheck.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/lint/shellcheck.sh b/sh/lint/shellcheck.sh index df2c02d..61ef8d6 100644 --- a/sh/lint/shellcheck.sh +++ b/sh/lint/shellcheck.sh @@ -3,12 +3,12 @@ rwx_shellcheck_check() { local file module modules path file="$(mktemp)" modules="$(sh_find_sh "${root}")" - _sh_ifs_new + rwx_ifs_set for module in ${modules}; do path="${root}/${module}" echo ". \"${path}\"" >>"${file}" done - _sh_ifs_pop + rwx_ifs_unset shellcheck \ --check-sourced \ --enable "all" \ From dc66287ed1714973f8def7286eadf5dcea3033db Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 19:45:58 +0100 Subject: [PATCH 886/969] alias/overlay --- sh/alias/overlay.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sh/alias/overlay.sh b/sh/alias/overlay.sh index 307c470..6357655 100644 --- a/sh/alias/overlay.sh +++ b/sh/alias/overlay.sh @@ -3,7 +3,7 @@ a__overlay_bind_mount() { local directory for directory in "dev" "dev/pts" "proc" "sys"; do if ! mount --bind "/${directory}" "overlay/mount/${directory}"; then - sh_log_error "Unable to bind mount directory: ${directory}" + rwx_log_error "Unable to bind mount directory: ${directory}" return 1 fi done @@ -14,7 +14,7 @@ a__overlay_bind_unmount() { local directory for directory in "sys" "proc" "dev/pts" "dev"; do if ! umount --lazy "overlay/mount/${directory}"; then - sh_log_error "Unable to bind unmount directory: ${directory}" + rwx_log_error "Unable to bind unmount directory: ${directory}" return 1 fi done @@ -47,36 +47,36 @@ orm() { a__overlay_root_mount "${@}"; } a__overlay_root_mount() { local root="${1}" if [ -z "${root}" ]; then - sh_log_error "No root target directory" + rwx_log_error "No root target directory" return 1 fi root="$(realpath "${root}")" if ! mkdir "overlay"; then - sh_log_error "Unable to make overlay directory" + rwx_log_error "Unable to make overlay directory" return 2 fi ( if ! cd "overlay"; then - sh_log_error "Unable to move into overlay directory" + rwx_log_error "Unable to move into overlay directory" return 3 fi local directory for directory in "lower" "upper" "work" "mount"; do if ! mkdir --parents "${directory}"; then - sh_log_error "Unable to make directory: ${directory}" + rwx_log_error "Unable to make directory: ${directory}" return 4 fi done local file="${root}/filesystem.squashfs" if ! mount "${file}" "lower"; then - sh_log_error "Unable to lower mount: ${file}" + rwx_log_error "Unable to lower mount: ${file}" return 5 fi if ! mount \ -o "lowerdir=lower,upperdir=upper,workdir=work" \ -t "overlay" \ "overlay" "mount"; then - sh_log_error "Unable to overlay mount" + rwx_log_error "Unable to overlay mount" return 6 fi ) @@ -106,35 +106,35 @@ oru() { a__overlay_root_unmount "${@}"; } a__overlay_root_unmount() { ( if ! cd "overlay"; then - sh_log_error "Unable to move into overlay directory" + rwx_log_error "Unable to move into overlay directory" return 1 fi if ! umount "mount"; then - sh_log_error "Unable to unmount mount directory" + rwx_log_error "Unable to unmount mount directory" return 2 fi if ! rmdir "mount"; then - sh_log_error "Unable to remove mount directory" + rwx_log_error "Unable to remove mount directory" return 3 fi local directory for directory in "upper" "work"; do if ! rm --force --recursive "${directory}"; then - sh_log_error "Unable to remove directory: ${directory}" + rwx_log_error "Unable to remove directory: ${directory}" return 4 fi done if ! umount "lower"; then - sh_log_error "Unable to unmount lower directory" + rwx_log_error "Unable to unmount lower directory" return 5 fi if ! rmdir "lower"; then - sh_log_error "Unable to remove lower directory" + rwx_log_error "Unable to remove lower directory" return 6 fi ) if ! rmdir "overlay"; then - sh_log_error "Unable to remove overlay directory" + rwx_log_error "Unable to remove overlay directory" return 7 fi } From a0d487f473721e10dedc74de2de07a4000746148 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 19:51:23 +0100 Subject: [PATCH 887/969] rescue/common --- sh/rescue/common.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/sh/rescue/common.sh b/sh/rescue/common.sh index f2c9d10..4e2684a 100644 --- a/sh/rescue/common.sh +++ b/sh/rescue/common.sh @@ -1,9 +1,9 @@ rwx_rescue_configure() { local hostname="${1}" # apt / conf - sh_apt_conf_write + rwx_apt_conf_write # apt / sources - sh_apt_sources_write + rwx_apt_sources_write # bash / rc main_link_bashrc mv "${HOME}/.bashrc" "${HOME}/.bashrc.old" @@ -17,26 +17,26 @@ fr_FR.UTF-8 UTF-8 # generate locales locale-gen # update catalog - sh_apt_update + rwx_apt_update # disable frontend - sh_debian_frontend_disable + rwx_debian_frontend_disable # install backports - sh_apt_install_backports "tmux" + rwx_apt_install_backports "tmux" # install packages - sh_apt_install_release "apt-file" "mosh" "screen" "byobu" + rwx_apt_install_release "apt-file" "mosh" "screen" "byobu" # update catalog - sh_apt_update + rwx_apt_update } rwx_rescue_install() { # update catalog - sh_apt_update + rwx_apt_update # disable frontend - sh_debian_frontend_disable + rwx_debian_frontend_disable # upgrade packages - sh_apt_upgrade + rwx_apt_upgrade # install packages - sh_apt_install_release \ + rwx_apt_install_release \ "man-db" \ "dmidecode" "efibootmgr" "lshw" "pciutils" "usbutils" \ "parted" "mdadm" "cryptsetup-bin" "lvm2" \ @@ -45,7 +45,7 @@ rwx_rescue_install() { "exa" "lf" "ncdu" "nnn" "ranger" "tree" \ "file" "htop" "iotop" "ipcalc" "libdigest-sha3-perl" "lsof" # install backports - sh_apt_install_backports \ + rwx_apt_install_backports \ "grub-pc-bin" \ \ "grub-efi-amd64-bin" @@ -84,7 +84,7 @@ rwx_rescue_upload() { } rwx_rescue_wipe_1_zero() { - sh_fs_wipe "/dev/mapper/crypt" "512M" + rwx_fs_wipe "/dev/mapper/crypt" "512M" } rwx_rescue_wipe_3_close() { From 4d64db0b70688e2fe494378e3709d2f9aa576b88 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 19:53:27 +0100 Subject: [PATCH 888/969] rescue/ovh --- sh/rescue/ovh.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/sh/rescue/ovh.sh b/sh/rescue/ovh.sh index c7d89c2..b4120e2 100644 --- a/sh/rescue/ovh.sh +++ b/sh/rescue/ovh.sh @@ -2,9 +2,9 @@ rwx_rescue_wipe_0_init_ovh_vle2() { local device="/dev/sdb" local passphrase # read passphrase - passphrase="$(sh_read_passphrase)" + passphrase="$(rwx_read_passphrase)" # warn - sh_warn_wipe "${device}" + rwx_warn_wipe "${device}" # parted --script "${device}" \ mktable gpt \ @@ -16,27 +16,27 @@ rwx_rescue_wipe_0_init_ovh_vle2() { mkpart bios 1 2 \ set 4 bios_grub on # bios / wipe - sh_fs_wipe "${device}4" + rwx_fs_wipe "${device}4" # esp / wipe - sh_fs_wipe "${device}3" "1M" + rwx_fs_wipe "${device}3" "1M" # esp / format - sh_fs_make_fat "${device}3" "esp" "00000001" + rwx_fs_make_fat "${device}3" "esp" "00000001" # esp / mount mkdir --parents "/media/esp" mount "${device}3" "/media/esp" # boot / wipe - sh_fs_wipe "${device}2" "1G" 1 + rwx_fs_wipe "${device}2" "1G" 1 # boot / format - sh_fs_make_btrfs "${device}2" "boot" \ + rwx_fs_make_btrfs "${device}2" "boot" \ "00000000-0000-0000-0000-00000000000b" # boot / mount mkdir --parents "/media/boot" mount --options "autodefrag,compress-force=zstd" \ "${device}2" "/media/boot" # crypt / wipe - sh_fs_wipe "${device}1" "1G" 1 + rwx_fs_wipe "${device}1" "1G" 1 # crypt / encrypt - sh_fs_luks_format "${passphrase}" "${device}1" + rwx_fs_luks_format "${passphrase}" "${device}1" # crypt / open echo "${passphrase}" | cryptsetup luksOpen "${device}1" "crypt" @@ -50,22 +50,22 @@ rwx_rescue_wipe_2_make_ovh_vle2() { # crypt / close cryptsetup luksClose "crypt" # read passphrase - passphrase="$(sh_read_passphrase)" + passphrase="$(rwx_read_passphrase)" # crypt / encrypt - sh_fs_luks_format "${passphrase}" "${device}1" + rwx_fs_luks_format "${passphrase}" "${device}1" # crypt / open echo "${passphrase}" | cryptsetup luksOpen "${device}1" "crypt" # passphrase unset passphrase # crypt / format - sh_fs_make_btrfs "/dev/mapper/crypt" "crypt" \ + rwx_fs_make_btrfs "/dev/mapper/crypt" "crypt" \ "00000000-0000-0000-0000-00000000000c" # crypt / mount mkdir --parents "/media/crypt" mount --options "autodefrag,compress-force=zstd" \ "/dev/mapper/crypt" "/media/crypt" # crypt / swap - sh_fs_make_btrfs_swap "/media/crypt/swap" "4g" \ + rwx_fs_make_btrfs_swap "/media/crypt/swap" "4g" \ "00000000-0000-0000-0000-000000000005" } From dda61e2594e9912e5b7580ffae68846f356e4fad Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 19:55:33 +0100 Subject: [PATCH 889/969] rescue/hetzner --- sh/rescue/hetzner.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sh/rescue/hetzner.sh b/sh/rescue/hetzner.sh index 8fe73e3..47e8304 100644 --- a/sh/rescue/hetzner.sh +++ b/sh/rescue/hetzner.sh @@ -7,9 +7,9 @@ rwx_rescue_wipe_0_init_hetzner_8_8() { local number local passphrase # read passphrase - passphrase="$(sh_read_passphrase)" + passphrase="$(rwx_read_passphrase)" # warn - sh_warn_wipe "${@}" + rwx_warn_wipe "${@}" # number=0 for device in "${@}"; do @@ -34,7 +34,7 @@ rwx_rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}4" # wipe bios - sh_fs_wipe "${device}4" + rwx_fs_wipe "${device}4" done # number=0 @@ -43,8 +43,8 @@ rwx_rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}3" # format esp - sh_fs_wipe "${device}3" "1M" - sh_fs_make_fat "${device}3" "esp-${number}" "0000000${number}" + rwx_fs_wipe "${device}3" "1M" + rwx_fs_make_fat "${device}3" "esp-${number}" "0000000${number}" # mount esp mkdir --parents "/media/esp/${number}" mount "${device}3" "/media/esp/${number}" @@ -56,17 +56,17 @@ rwx_rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}2" # wipe boot - sh_fs_wipe "${device}2" "1G" 1 + rwx_fs_wipe "${device}2" "1G" 1 done # members="" for device in "${@}"; do members="${members} ${device}2" done - sh_fs_raid_create \ + rwx_fs_raid_create \ "boot" "00000000:00000000:00000000:00000002" ${members} # - sh_fs_make_btrfs "/dev/md/boot" "boot" \ + rwx_fs_make_btrfs "/dev/md/boot" "boot" \ "00000000-0000-0000-0000-00000000000b" # mount boot mkdir --parents "/media/boot" @@ -80,17 +80,17 @@ rwx_rescue_wipe_0_init_hetzner_8_8() { echo echo "#${number}: ${device}1" # wipe crypt head - sh_fs_wipe "${device}1" "1G" 1 + rwx_fs_wipe "${device}1" "1G" 1 done # members="" for device in "${@}"; do members="${members} ${device}1" done - sh_fs_raid_create \ + rwx_fs_raid_create \ "crypt" "00000000:00000000:00000000:00000001" ${members} # encrypt - sh_fs_luks_format "${passphrase}" "/dev/md/crypt" + rwx_fs_luks_format "${passphrase}" "/dev/md/crypt" # open echo "${passphrase}" | cryptsetup luksOpen "/dev/md/crypt" "crypt" @@ -103,9 +103,9 @@ rwx_rescue_wipe_2_make_hetzner_8_8() { # close cryptsetup luksClose "crypt" # read passphrase - passphrase="$(sh_read_passphrase)" + passphrase="$(rwx_read_passphrase)" # encrypt - sh_fs_luks_format "${passphrase}" "/dev/md/crypt" + rwx_fs_luks_format "${passphrase}" "/dev/md/crypt" # open echo "${passphrase}" | cryptsetup luksOpen "/dev/md/crypt" "crypt" @@ -120,6 +120,6 @@ rwx_rescue_wipe_2_make_hetzner_8_8() { --options "autodefrag,compress-force=zstd" \ "/dev/mapper/crypt" "/media/crypt" # make swap file - sh_fs_make_btrfs_swap "/media/crypt/swap" "64g" \ + rwx_fs_make_btrfs_swap "/media/crypt/swap" "64g" \ "00000000-0000-0000-0000-000000000005" } From a56aa8124f557ab70ab0b4ecbd43dc49de3263e4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 19:58:07 +0100 Subject: [PATCH 890/969] gnome --- sh/gnome.sh | 8 ++++---- sh/rescue/hetzner.sh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sh/gnome.sh b/sh/gnome.sh index c30e612..11831fb 100644 --- a/sh/gnome.sh +++ b/sh/gnome.sh @@ -14,11 +14,11 @@ rwx_gnome_workspaces_primary() { local var="${group}/${name}" # get bool="$(gsettings get "${group}" "${name}")" - sh_log_debug "${var}: ${bool}" + rwx_log_debug "${var}: ${bool}" # not - bool="$(sh_not "${bool}")" - sh_log_debug "bool: ${bool}" + bool="$(rwx_not "${bool}")" + rwx_log_debug "bool: ${bool}" # set gsettings set "${group}" "${name}" "${bool}" - sh_log_info "${var}: ${bool}" + rwx_log_info "${var}: ${bool}" } diff --git a/sh/rescue/hetzner.sh b/sh/rescue/hetzner.sh index 47e8304..9d22847 100644 --- a/sh/rescue/hetzner.sh +++ b/sh/rescue/hetzner.sh @@ -112,7 +112,7 @@ rwx_rescue_wipe_2_make_hetzner_8_8() { # passphrase unset passphrase # format crypt - sh_fs_make_btrfs "/dev/mapper/crypt" "crypt" \ + rwx_fs_make_btrfs "/dev/mapper/crypt" "crypt" \ "00000000-0000-0000-0000-00000000000c" # mount crypt mkdir --parents "/media/crypt" From 2f686e3512985b29d4416ddc056d0e1adebf0764 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 19:58:38 +0100 Subject: [PATCH 891/969] lint/shellcheck --- sh/lint/shellcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/lint/shellcheck.sh b/sh/lint/shellcheck.sh index 61ef8d6..11b5b0d 100644 --- a/sh/lint/shellcheck.sh +++ b/sh/lint/shellcheck.sh @@ -2,7 +2,7 @@ rwx_shellcheck_check() { local root="${1}" local file module modules path file="$(mktemp)" - modules="$(sh_find_sh "${root}")" + modules="$(rwx_find_sh "${root}")" rwx_ifs_set for module in ${modules}; do path="${root}/${module}" From c3240b8b154fc33f4e72a6d0e7dcb53908faebc4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 20:23:01 +0100 Subject: [PATCH 892/969] =?UTF-8?q?=E2=88=92cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cs | 82 ---------------------------------------------------------- cs.old | 82 ---------------------------------------------------------- 2 files changed, 164 deletions(-) delete mode 100755 cs delete mode 100755 cs.old diff --git a/cs b/cs deleted file mode 100755 index bd9402c..0000000 --- a/cs +++ /dev/null @@ -1,82 +0,0 @@ -#! /usr/bin/env bash -FILE="$(realpath "${BASH_SOURCE[0]}")" -NAME="$(basename "${FILE}")" - -ACTION_OPEN='open' -ACTION_CLOSE='close' - -CONTAINERS_DIRECTORY="/data/home/user/crypt" - -CONTAINERS_MAP_DIRECTORY='/dev/mapper' -CONTAINERS_MOUNT_DIRECTORY='/media' - -function main { -local action="${1}" -local pass_phrase -local container -local container_name -local container_file -local container_map_file -local container_mount_directory - -case "${action}" in - "${ACTION_OPEN}"|"${ACTION_CLOSE}") - shift - if [ "${1}" ]; then - if [ "${action}" == "${ACTION_OPEN}" ]; then - echo -n 'PassPhrase: ' - read -r -s pass_phrase - echo - fi - for container in "${@}"; do - echo - case "${container}" in - 'p') container_name='private' ;; - 's') container_name='sensitive' ;; - 'w') container_name='work' ;; - *) container_name="${container}" ;; - esac - container_file="${CONTAINERS_DIRECTORY}/${container_name}" - if [ -f "${container_file}" ]; then - container_map_file="${CONTAINERS_MAP_DIRECTORY}/${container_name}" - container_mount_directory="${CONTAINERS_MOUNT_DIRECTORY}/${container_name}" - case "${action}" in - "${ACTION_OPEN}") - echo "${container_file} → ${container_map_file}" - echo "${pass_phrase}" \ - | cryptsetup luksOpen "${container_file}" "${container_name}" - if [ ${?} -eq 0 ]; then - mkdir --parents "${container_mount_directory}" - echo "${container_map_file} → ${container_mount_directory}" - mount "${container_map_file}" "${container_mount_directory}" - fi - ;; - "${ACTION_CLOSE}") - echo "${container_map_file} ← ${container_mount_directory}" - if umount "${container_map_file}"; then - rmdir --ignore-fail-on-non-empty "${container_mount_directory}" - echo "${container_file} ← ${container_map_file}" - cryptsetup luksClose "${container_name}" - fi - ;; - esac - else - echo 'This path does not point to a file!' - fi - done - else - echo 'No container name provided!' - fi - ;; - *) - echo 'Usage:' - echo "${NAME} [${ACTION_OPEN}|${ACTION_CLOSE}] [p] [s] [w]" - echo - echo 'p = private' - echo 's = sensitive' - echo 'w = work' - ;; -esac -} - -main "${@}" diff --git a/cs.old b/cs.old deleted file mode 100755 index bd9402c..0000000 --- a/cs.old +++ /dev/null @@ -1,82 +0,0 @@ -#! /usr/bin/env bash -FILE="$(realpath "${BASH_SOURCE[0]}")" -NAME="$(basename "${FILE}")" - -ACTION_OPEN='open' -ACTION_CLOSE='close' - -CONTAINERS_DIRECTORY="/data/home/user/crypt" - -CONTAINERS_MAP_DIRECTORY='/dev/mapper' -CONTAINERS_MOUNT_DIRECTORY='/media' - -function main { -local action="${1}" -local pass_phrase -local container -local container_name -local container_file -local container_map_file -local container_mount_directory - -case "${action}" in - "${ACTION_OPEN}"|"${ACTION_CLOSE}") - shift - if [ "${1}" ]; then - if [ "${action}" == "${ACTION_OPEN}" ]; then - echo -n 'PassPhrase: ' - read -r -s pass_phrase - echo - fi - for container in "${@}"; do - echo - case "${container}" in - 'p') container_name='private' ;; - 's') container_name='sensitive' ;; - 'w') container_name='work' ;; - *) container_name="${container}" ;; - esac - container_file="${CONTAINERS_DIRECTORY}/${container_name}" - if [ -f "${container_file}" ]; then - container_map_file="${CONTAINERS_MAP_DIRECTORY}/${container_name}" - container_mount_directory="${CONTAINERS_MOUNT_DIRECTORY}/${container_name}" - case "${action}" in - "${ACTION_OPEN}") - echo "${container_file} → ${container_map_file}" - echo "${pass_phrase}" \ - | cryptsetup luksOpen "${container_file}" "${container_name}" - if [ ${?} -eq 0 ]; then - mkdir --parents "${container_mount_directory}" - echo "${container_map_file} → ${container_mount_directory}" - mount "${container_map_file}" "${container_mount_directory}" - fi - ;; - "${ACTION_CLOSE}") - echo "${container_map_file} ← ${container_mount_directory}" - if umount "${container_map_file}"; then - rmdir --ignore-fail-on-non-empty "${container_mount_directory}" - echo "${container_file} ← ${container_map_file}" - cryptsetup luksClose "${container_name}" - fi - ;; - esac - else - echo 'This path does not point to a file!' - fi - done - else - echo 'No container name provided!' - fi - ;; - *) - echo 'Usage:' - echo "${NAME} [${ACTION_OPEN}|${ACTION_CLOSE}] [p] [s] [w]" - echo - echo 'p = private' - echo 's = sensitive' - echo 'w = work' - ;; -esac -} - -main "${@}" From 377acbd817ce94e7ffad42bd39962220c5590ce3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 21:04:02 +0100 Subject: [PATCH 893/969] =?UTF-8?q?=E2=88=92readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 readme.md diff --git a/readme.md b/readme.md deleted file mode 100644 index cbcd2bc..0000000 --- a/readme.md +++ /dev/null @@ -1,12 +0,0 @@ -# SH - -## Tasks - -* [ ] git switch signing commits & tags -* [ ] shellcheck & shfmt -* [ ] python tools -* [ ] log -* [ ] hetzner -* [ ] apt - * [ ] apt-file search | grep -* [ ] ffmpeg From 3cdcac98856b84f3e8b628c26fe5a6018b77cfd0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 21:04:19 +0100 Subject: [PATCH 894/969] readme/shell --- readme.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/readme.md b/readme.md index e2beac8..905c975 100644 --- a/readme.md +++ b/readme.md @@ -51,6 +51,8 @@ A tiny framework to read, write & execute things. ### Task stack +#### Python + * character constants for box drawing * common __str__ function * parse pyproject.toml to write commands @@ -59,3 +61,14 @@ A tiny framework to read, write & execute things. * system commands to run * with single call of subprocess.run * or alternate subprocess method? + +#### Shell + +* git switch signing commits & tags +* shellcheck & shfmt +* python tools +* log +* hetzner +* apt + * apt-file search | grep +* ffmpeg From f9baa85fc7facb2e315381fa06f7a6d890056d21 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 21:47:36 +0100 Subject: [PATCH 895/969] usr/local/lib --- sh/main.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index b2dd223..a6e1222 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -5,7 +5,7 @@ RWX_MAIN_FILE_NAME="main.sh" RWX_NAME="sh" -RWX_ROOT_SYSTEM="/etc/${RWX_NAME}" +RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_NAME}" RWX_MAIN="${RWX_ROOT_SYSTEM}/${RWX_MAIN_FILE_NAME}" @@ -13,8 +13,8 @@ RWX_MAIN="${RWX_ROOT_SYSTEM}/${RWX_MAIN_FILE_NAME}" # │ variables │ # ╰───────────╯ -RWX_SHELL="$(cat "/proc/${$}/comm")" RWX_ROOT_USER="${HOME}/${RWX_NAME}" +RWX_SHELL="$(cat "/proc/${$}/comm")" # ╭──────────╮ # │ internal │ From 2e622026cdcefe7d29b2bf6436cf5a0dd429ca7d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 22:04:00 +0100 Subject: [PATCH 896/969] name/rwx --- sh/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/main.sh b/sh/main.sh index a6e1222..e60a0f9 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -3,7 +3,7 @@ # ╰───────────╯ RWX_MAIN_FILE_NAME="main.sh" -RWX_NAME="sh" +RWX_NAME="rwx" RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_NAME}" From 736fd791c2b94dd35d4af10e4cff93f8d77d705e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 22:18:29 +0100 Subject: [PATCH 897/969] fixes --- sh/alias/shell.sh | 2 +- sh/main.sh | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/sh/alias/shell.sh b/sh/alias/shell.sh index daadbce..d6f5801 100644 --- a/sh/alias/shell.sh +++ b/sh/alias/shell.sh @@ -17,7 +17,7 @@ x() { "${@}" } -[ "${SH_SHELL}" = "bash" ] || return +[ "${RWX_SHELL}" = "bash" ] || return # shellcheck disable=SC3033 ..() { diff --git a/sh/main.sh b/sh/main.sh index e60a0f9..8403159 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -7,8 +7,6 @@ RWX_NAME="rwx" RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_NAME}" -RWX_MAIN="${RWX_ROOT_SYSTEM}/${RWX_MAIN_FILE_NAME}" - # ╭───────────╮ # │ variables │ # ╰───────────╯ From 83a3a9d9baa18ce9ba778ed940fb7d2dd1bb5935 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 22:20:34 +0100 Subject: [PATCH 898/969] fixes --- sh/shell.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/shell.sh b/sh/shell.sh index a5f1b99..e4fde1b 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -1,6 +1,6 @@ _rwx_shell_color() { local code="${1}" - case "${SH_SHELL}" in + case "${RWX_SHELL}" in "bash") printf "\x01\e[0" if [ -n "${code}" ]; then @@ -33,7 +33,7 @@ rwx_shell_configure() { PS1="\$(rwx_shell_prompt \${?})" PS2="├ " # specific - case "${SH_SHELL}" in + case "${RWX_SHELL}" in "bash") # completion local root="/usr/share/bash-completion" @@ -117,7 +117,7 @@ rwx_shell_prompt() { rwx_shell_setup() { # shell - echo "export ENV=\"${ENV}\"" >"/etc/profile.d/${SH_NAME}.sh" + echo "export ENV=\"${ENV}\"" >"/etc/profile.d/${RWX_NAME}.sh" # bash local file="/etc/bash.bashrc" rm --force --recursive "${file}" From 8260e4e8703855f422f114263e028e5e4ebbb93c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 22:22:12 +0100 Subject: [PATCH 899/969] main/path --- sh/shell.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/shell.sh b/sh/shell.sh index e4fde1b..c4ca1ec 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -27,7 +27,7 @@ RWX_COLOR_MAGENTA="$(_rwx_shell_color 35)" RWX_COLOR_RED="$(_rwx_shell_color 32)" rwx_shell_configure() { - [ -n "${ENV}" ] || ENV="${SH_MAIN}" + [ -n "${ENV}" ] || ENV="${SH_MAIN_PATH}" export ENV # prompt PS1="\$(rwx_shell_prompt \${?})" From dc301be51d7862726c423ea494aa156dcc606c08 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 22:26:26 +0100 Subject: [PATCH 900/969] main/name,path --- sh/main.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 8403159..088e438 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -2,7 +2,7 @@ # │ constants │ # ╰───────────╯ -RWX_MAIN_FILE_NAME="main.sh" +RWX_MAIN_NAME="main.sh" RWX_NAME="rwx" RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_NAME}" @@ -14,6 +14,8 @@ RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_NAME}" RWX_ROOT_USER="${HOME}/${RWX_NAME}" RWX_SHELL="$(cat "/proc/${$}/comm")" +RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" + # ╭──────────╮ # │ internal │ # ╰──────────╯ @@ -100,7 +102,7 @@ rwx_main_source() { [ -d "${path}" ] || return 1 local cmd count module modules - modules="$(rwx_find_sh "${path}" "${RWX_MAIN_FILE_NAME}")" + modules="$(rwx_find_sh "${path}" "${RWX_MAIN_NAME}")" rwx_ifs_set count=0 _rwx_main_log "" \ From 5e8e84246dd402924b31b5d751ad11fc3d4836cf Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 22:28:09 +0100 Subject: [PATCH 901/969] fix --- sh/shell.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/shell.sh b/sh/shell.sh index c4ca1ec..87a291a 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -27,7 +27,7 @@ RWX_COLOR_MAGENTA="$(_rwx_shell_color 35)" RWX_COLOR_RED="$(_rwx_shell_color 32)" rwx_shell_configure() { - [ -n "${ENV}" ] || ENV="${SH_MAIN_PATH}" + [ -n "${ENV}" ] || ENV="${RWX_MAIN_PATH}" export ENV # prompt PS1="\$(rwx_shell_prompt \${?})" From c60ab4f5f565c9a653196187d68578bb23e8e7f2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 22:54:00 +0100 Subject: [PATCH 902/969] self/help --- sh/main.sh | 10 +--------- sh/self.sh | 7 +++++++ 2 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 sh/self.sh diff --git a/sh/main.sh b/sh/main.sh index 088e438..dfddf39 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -81,14 +81,6 @@ rwx_grep_functions() { cut --delimiter "(" --fields 1 } -# output help message -rwx_help() { - rwx_log \ - "rwx_… = functions" \ - " a__… = aliases" \ - " u__… = user" -} - # test if active shell is in interactive mode rwx_shell_interactive() { case "${-}" in @@ -146,7 +138,7 @@ rwx_main() { rwx_shellcheck_check "${RWX_ROOT_SYSTEM}" # help rwx_log - rwx_help + rwx_self_help fi } diff --git a/sh/self.sh b/sh/self.sh new file mode 100644 index 0000000..134397d --- /dev/null +++ b/sh/self.sh @@ -0,0 +1,7 @@ +# output help message +rwx_self_help() { + rwx_log \ + "rwx_… = functions" \ + " a__… = aliases" \ + " u__… = user" +} From 9eefdb31f8a15d74d8ad627e22d699fed92d1a48 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 22:57:21 +0100 Subject: [PATCH 903/969] lint --- sh/lint/shellcheck.sh | 2 +- sh/lint/shfmt.sh | 2 +- sh/main.sh | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sh/lint/shellcheck.sh b/sh/lint/shellcheck.sh index 11b5b0d..ebec9ad 100644 --- a/sh/lint/shellcheck.sh +++ b/sh/lint/shellcheck.sh @@ -1,4 +1,4 @@ -rwx_shellcheck_check() { +rwx_shellcheck() { local root="${1}" local file module modules path file="$(mktemp)" diff --git a/sh/lint/shfmt.sh b/sh/lint/shfmt.sh index 107170b..097de86 100644 --- a/sh/lint/shfmt.sh +++ b/sh/lint/shfmt.sh @@ -1,4 +1,4 @@ -rwx_shfmt_check() { +rwx_shfmt() { local root="${1}" shfmt --diff "${root}" } diff --git a/sh/main.sh b/sh/main.sh index dfddf39..f591b46 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -132,10 +132,10 @@ rwx_main() { if rwx_shell_interactive; then # check format rwx_log - rwx_shfmt_check "${RWX_ROOT_SYSTEM}" + rwx_shfmt "${RWX_ROOT_SYSTEM}" # check syntax rwx_log - rwx_shellcheck_check "${RWX_ROOT_SYSTEM}" + rwx_shellcheck "${RWX_ROOT_SYSTEM}" # help rwx_log rwx_self_help From d0bf0958c8c9ada2a6f24943f454d649b63bec09 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 23:03:52 +0100 Subject: [PATCH 904/969] +core --- sh/main.sh | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index f591b46..c916049 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -51,6 +51,25 @@ _rwx_main_log() { # │ public │ # ╰────────╯ +# get functions from file +rwx_grep_functions() { + local file="${1}" + grep "()" "${file}" | + cut --delimiter "(" --fields 1 +} + +# test if active shell is in interactive mode +rwx_shell_interactive() { + case "${-}" in + *i*) ;; + *) return 1 ;; + esac +} + +# ╭──────╮ +# │ core │ +# ╰──────╯ + # find directory’s files by extension rwx_find_extension() { local extension="${1}" @@ -70,31 +89,16 @@ rwx_find_extension() { } # find directory’s sh files -rwx_find_sh() { +rwx_find_shell() { rwx_find_extension "sh" "${@}" } -# get functions from file -rwx_grep_functions() { - local file="${1}" - grep "()" "${file}" | - cut --delimiter "(" --fields 1 -} - -# test if active shell is in interactive mode -rwx_shell_interactive() { - case "${-}" in - *i*) ;; - *) return 1 ;; - esac -} - rwx_main_source() { local path="${1}" [ -d "${path}" ] || return 1 local cmd count module modules - modules="$(rwx_find_sh "${path}" "${RWX_MAIN_NAME}")" + modules="$(rwx_find_shell "${path}" "${RWX_MAIN_NAME}")" rwx_ifs_set count=0 _rwx_main_log "" \ From 4b2cc9a24375d81ff2716fc53d6a1004ef10871b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 23:27:43 +0100 Subject: [PATCH 905/969] core --- sh/main.sh | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index c916049..e85f519 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -16,27 +16,10 @@ RWX_SHELL="$(cat "/proc/${$}/comm")" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" -# ╭──────────╮ -# │ internal │ -# ╰──────────╯ - -# _RWX_IFS - # ╭─────────╮ # │ private │ # ╰─────────╯ -rwx_ifs_set() { - _RWX_IFS="${IFS}" - IFS=" -" -} - -rwx_ifs_unset() { - IFS="${_RWX_IFS}" - unset RWX_IFS -} - _rwx_main_log() { if rwx_shell_interactive; then [ ${#} -gt 0 ] || set -- "" @@ -70,6 +53,10 @@ rwx_shell_interactive() { # │ core │ # ╰──────╯ +# ╭──────┬──────╮ +# │ core │ find │ +# ╰──────┴──────╯ + # find directory’s files by extension rwx_find_extension() { local extension="${1}" @@ -93,7 +80,26 @@ rwx_find_shell() { rwx_find_extension "sh" "${@}" } -rwx_main_source() { +# ╭──────┬─────╮ +# │ core │ ifs │ +# ╰──────┴─────╯ + +rwx_ifs_set() { + _RWX_IFS="${IFS}" + IFS=" +" +} + +rwx_ifs_unset() { + IFS="${_RWX_IFS}" + unset RWX_IFS +} + +# ╭──────┬────────╮ +# │ core │ source │ +# ╰──────┴────────╯ + +rwx_source() { local path="${1}" [ -d "${path}" ] || return 1 @@ -119,19 +125,19 @@ rwx_main_source() { rwx_ifs_unset } -# ╭──────╮ -# │ main │ -# ╰──────╯ +# ╭──────┬──────╮ +# │ core │ main │ +# ╰──────┴──────╯ # run initial steps rwx_main() { # system root - if ! rwx_main_source "${RWX_ROOT_SYSTEM}"; then + if ! rwx_source "${RWX_ROOT_SYSTEM}"; then _rwx_main_log "Not a directory: ${RWX_ROOT_SYSTEM}" return 1 fi # user root - rwx_main_source "${RWX_ROOT_USER}" + rwx_source "${RWX_ROOT_USER}" # run interactive extras if rwx_shell_interactive; then # check format From e4d0b71e5d0fe3247d5e0665a10bd2c27a5bf84b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 23:36:32 +0100 Subject: [PATCH 906/969] main/log --- sh/main.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index e85f519..ac92b40 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -16,20 +16,6 @@ RWX_SHELL="$(cat "/proc/${$}/comm")" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" -# ╭─────────╮ -# │ private │ -# ╰─────────╯ - -_rwx_main_log() { - if rwx_shell_interactive; then - [ ${#} -gt 0 ] || set -- "" - local line - for line in "${@}"; do - echo "${line}" - done - fi -} - # ╭────────╮ # │ public │ # ╰────────╯ @@ -53,6 +39,20 @@ rwx_shell_interactive() { # │ core │ # ╰──────╯ +# ╭──────┬─────╮ +# │ core │ log │ +# ╰──────┴─────╯ + +__rwx_log() { + if rwx_shell_interactive; then + [ ${#} -gt 0 ] || set -- "" + local line + for line in "${@}"; do + echo "${line}" + done + fi +} + # ╭──────┬──────╮ # │ core │ find │ # ╰──────┴──────╯ @@ -107,11 +107,11 @@ rwx_source() { modules="$(rwx_find_shell "${path}" "${RWX_MAIN_NAME}")" rwx_ifs_set count=0 - _rwx_main_log "" \ + __rwx_log "" \ ". ${path}" for module in ${modules}; do count=$((count + 1)) - _rwx_main_log "$(printf "%02d" "${count}") ${module%.sh}" + __rwx_log "$(printf "%02d" "${count}") ${module%.sh}" module="${path}/${module}" # shellcheck disable=SC1090 . "${module}" @@ -133,7 +133,7 @@ rwx_source() { rwx_main() { # system root if ! rwx_source "${RWX_ROOT_SYSTEM}"; then - _rwx_main_log "Not a directory: ${RWX_ROOT_SYSTEM}" + __rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}" return 1 fi # user root From 531aa618bb2e68b8bac8e67eff18e7f57cc5f2b8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 23:41:57 +0100 Subject: [PATCH 907/969] shell/interactive --- sh/main.sh | 8 -------- sh/shell.sh | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index ac92b40..5b3978e 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -27,14 +27,6 @@ rwx_grep_functions() { cut --delimiter "(" --fields 1 } -# test if active shell is in interactive mode -rwx_shell_interactive() { - case "${-}" in - *i*) ;; - *) return 1 ;; - esac -} - # ╭──────╮ # │ core │ # ╰──────╯ diff --git a/sh/shell.sh b/sh/shell.sh index 87a291a..e1a6ca8 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -62,6 +62,14 @@ rwx_shell_configure() { } rwx_shell_configure +# test if active shell is in interactive mode +rwx_shell_interactive() { + case "${-}" in + *i*) ;; + *) return 1 ;; + esac +} + rwx_shell_prompt() { local date host id local code="${1}" From 4325ab4776502cea556ccc239d12da197cd5dc05 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 23:49:09 +0100 Subject: [PATCH 908/969] sysroot --- sh/main.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 5b3978e..09ed3b9 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -5,16 +5,16 @@ RWX_MAIN_NAME="main.sh" RWX_NAME="rwx" -RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_NAME}" - # ╭───────────╮ # │ variables │ # ╰───────────╯ RWX_ROOT_USER="${HOME}/${RWX_NAME}" RWX_SHELL="$(cat "/proc/${$}/comm")" +RWX_SYSTEM_ROOT="/usr/local/lib" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" +RWX_ROOT_SYSTEM="${RWX_SYSTEM_ROOT}/${RWX_NAME}" # ╭────────╮ # │ public │ From c032849e9573ea132104574b8f7c2151367996de Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 23:52:46 +0100 Subject: [PATCH 909/969] self/name --- sh/main.sh | 6 +++--- sh/shell.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 09ed3b9..88cc728 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -3,18 +3,18 @@ # ╰───────────╯ RWX_MAIN_NAME="main.sh" -RWX_NAME="rwx" +RWX_SELF_NAME="rwx" # ╭───────────╮ # │ variables │ # ╰───────────╯ -RWX_ROOT_USER="${HOME}/${RWX_NAME}" +RWX_ROOT_USER="${HOME}/${RWX_SELF_NAME}" RWX_SHELL="$(cat "/proc/${$}/comm")" RWX_SYSTEM_ROOT="/usr/local/lib" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" -RWX_ROOT_SYSTEM="${RWX_SYSTEM_ROOT}/${RWX_NAME}" +RWX_ROOT_SYSTEM="${RWX_SYSTEM_ROOT}/${RWX_SELF_NAME}" # ╭────────╮ # │ public │ diff --git a/sh/shell.sh b/sh/shell.sh index e1a6ca8..e09fd01 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -125,7 +125,7 @@ rwx_shell_prompt() { rwx_shell_setup() { # shell - echo "export ENV=\"${ENV}\"" >"/etc/profile.d/${RWX_NAME}.sh" + echo "export ENV=\"${ENV}\"" >"/etc/profile.d/${RWX_SELF_NAME}.sh" # bash local file="/etc/bash.bashrc" rm --force --recursive "${file}" From fbb6e2bb68f3f00be1215f0d2fed76e1f213afc4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 23:56:14 +0100 Subject: [PATCH 910/969] shell/interactive --- sh/main.sh | 8 ++++++++ sh/shell.sh | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 88cc728..261c837 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -31,6 +31,14 @@ rwx_grep_functions() { # │ core │ # ╰──────╯ +# test if active shell is in interactive mode +rwx_shell_interactive() { + case "${-}" in + *i*) ;; + *) return 1 ;; + esac +} + # ╭──────┬─────╮ # │ core │ log │ # ╰──────┴─────╯ diff --git a/sh/shell.sh b/sh/shell.sh index e09fd01..561fcdd 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -62,14 +62,6 @@ rwx_shell_configure() { } rwx_shell_configure -# test if active shell is in interactive mode -rwx_shell_interactive() { - case "${-}" in - *i*) ;; - *) return 1 ;; - esac -} - rwx_shell_prompt() { local date host id local code="${1}" From 317c71fe5257edff83c654c10a8cb9efbee2f325 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 23:57:27 +0100 Subject: [PATCH 911/969] internal/log --- sh/log.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/log.sh b/sh/log.sh index 9b2ffc4..b921d45 100644 --- a/sh/log.sh +++ b/sh/log.sh @@ -60,9 +60,9 @@ _rwx_log() { local line for line in "${@}"; do if [ -n "${prefix}" ]; then - _rwx_main_log "${prefix} ${line}" + __rwx_log "${prefix} ${line}" else - _rwx_main_log "${line}" + __rwx_log "${line}" fi done } From 245aa85f291956f2ee61b4a45d7681e5b6e3dfc4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 29 Nov 2024 23:59:06 +0100 Subject: [PATCH 912/969] fix --- sh/lint/shellcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/lint/shellcheck.sh b/sh/lint/shellcheck.sh index ebec9ad..f31b2b4 100644 --- a/sh/lint/shellcheck.sh +++ b/sh/lint/shellcheck.sh @@ -2,7 +2,7 @@ rwx_shellcheck() { local root="${1}" local file module modules path file="$(mktemp)" - modules="$(rwx_find_sh "${root}")" + modules="$(rwx_find_shell "${root}")" rwx_ifs_set for module in ${modules}; do path="${root}/${module}" From 5fc07cfbc1527ddf7d993370ab184466a9655ad9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 30 Nov 2024 00:10:16 +0100 Subject: [PATCH 913/969] self/functions --- sh/main.sh | 19 +------------------ sh/self.sh | 10 ++++++++++ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 261c837..2b3508c 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -16,17 +16,6 @@ RWX_SYSTEM_ROOT="/usr/local/lib" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" RWX_ROOT_SYSTEM="${RWX_SYSTEM_ROOT}/${RWX_SELF_NAME}" -# ╭────────╮ -# │ public │ -# ╰────────╯ - -# get functions from file -rwx_grep_functions() { - local file="${1}" - grep "()" "${file}" | - cut --delimiter "(" --fields 1 -} - # ╭──────╮ # │ core │ # ╰──────╯ @@ -103,7 +92,7 @@ rwx_source() { local path="${1}" [ -d "${path}" ] || return 1 - local cmd count module modules + local count module modules modules="$(rwx_find_shell "${path}" "${RWX_MAIN_NAME}")" rwx_ifs_set count=0 @@ -115,12 +104,6 @@ rwx_source() { module="${path}/${module}" # shellcheck disable=SC1090 . "${module}" - cmd="$(rwx_grep_functions "${module}")" - if [ -n "${cmd}" ]; then - [ -n "${CMD}" ] && CMD="${CMD} -" - CMD="${CMD}${cmd}" - fi done rwx_ifs_unset } diff --git a/sh/self.sh b/sh/self.sh index 134397d..8c53cb9 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -1,3 +1,13 @@ +# get functions from file +rwx_self_functions() { + local file="${1}" + grep \ + --directories "recurse" \ + --no-filename \ + "()" "${RWX_ROOT_SYSTEM}" | + cut --delimiter "(" --fields 1 +} + # output help message rwx_self_help() { rwx_log \ From 745e8f0a2883bed73d4cb4dceee45c6789e51005 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 30 Nov 2024 00:12:01 +0100 Subject: [PATCH 914/969] useless --- sh/self.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/sh/self.sh b/sh/self.sh index 8c53cb9..4220366 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -1,6 +1,5 @@ # get functions from file rwx_self_functions() { - local file="${1}" grep \ --directories "recurse" \ --no-filename \ From 48d7236451fd873c5fe114d85dd30d0ac810b7ec Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 16:23:53 +0100 Subject: [PATCH 915/969] mv --- sh/.shellcheckrc => .shellcheckrc | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/.shellcheckrc => .shellcheckrc (100%) diff --git a/sh/.shellcheckrc b/.shellcheckrc similarity index 100% rename from sh/.shellcheckrc rename to .shellcheckrc From 482ba47dd9cf8b6660e8634f59251087e862513b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 16:39:55 +0100 Subject: [PATCH 916/969] file/write --- sh/util.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sh/util.sh b/sh/util.sh index 7d9cc3f..a7956ef 100644 --- a/sh/util.sh +++ b/sh/util.sh @@ -1,3 +1,11 @@ +rwx_file_write() { + local file="${1}" + local text="${2}" + if [ -n "${file}" ]; then + printf "%s" "${text}" > "${file}" + fi +} + rwx_list_block_devices() { lsblk \ --noempty \ From d549d03c992267dfd5fb72c678e3c02f5beb63f1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 16:41:48 +0100 Subject: [PATCH 917/969] shellcheck/write --- sh/lint/shellcheck.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sh/lint/shellcheck.sh b/sh/lint/shellcheck.sh index f31b2b4..b520fd9 100644 --- a/sh/lint/shellcheck.sh +++ b/sh/lint/shellcheck.sh @@ -18,3 +18,12 @@ rwx_shellcheck() { "${file}" rm "${file}" } + +rwx_shellcheck_write() { + rwx_file_write ".shellcheckrc" "\ +disable=3043 +enable=all +external-sources=true +shell=sh +" +} From 038853e4bb524d0a4ce8e85dcac3946f2242b594 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 17:47:06 +0100 Subject: [PATCH 918/969] shfmt --- sh/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/util.sh b/sh/util.sh index a7956ef..a81c808 100644 --- a/sh/util.sh +++ b/sh/util.sh @@ -2,7 +2,7 @@ rwx_file_write() { local file="${1}" local text="${2}" if [ -n "${file}" ]; then - printf "%s" "${text}" > "${file}" + printf "%s" "${text}" >"${file}" fi } From 81cb56bd119c0ec089b16526e1477fe4b795ae0c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 17:59:08 +0100 Subject: [PATCH 919/969] ref/head --- sh/alias/git.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sh/alias/git.sh b/sh/alias/git.sh index 6400092..37abaf7 100644 --- a/sh/alias/git.sh +++ b/sh/alias/git.sh @@ -533,3 +533,14 @@ a__git_tag_delete() { --delete \ "${@}" } + +# update head ref +gurh() { a__git_update_ref_head "${@}"; } +a__git_update_ref_head() { + if [ "${2}" ]; then + git \ + update-ref \ + "refs/heads/${1}" \ + "${2}" + fi +} From 01eb1bebd362e5356d37d5fbef93722e442357df Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 18:04:13 +0100 Subject: [PATCH 920/969] rwx/gau --- sh/gpg.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sh/gpg.sh b/sh/gpg.sh index a2b7f50..b5ce07b 100644 --- a/sh/gpg.sh +++ b/sh/gpg.sh @@ -1,3 +1,10 @@ +# bind gpg agent to current tty +rwx_gpg_agent_update() { + gpg-connect-agent \ + updatestartuptty \ + /bye +} + rwx_gpg_ssh_auth_sock() { local user_id user_id=$(id --user) From c69c10684e5ef31b0fb858e4ba225afe54c947bd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 18:06:02 +0100 Subject: [PATCH 921/969] gau/git,gpg --- sh/alias/git.sh | 11 ++++++----- sh/alias/gpg.sh | 4 +--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/sh/alias/git.sh b/sh/alias/git.sh index 37abaf7..73afa5f 100644 --- a/sh/alias/git.sh +++ b/sh/alias/git.sh @@ -371,11 +371,12 @@ a__git_merge_tool() { # push to the remote repository gp() { a__git_push "${@}"; } a__git_push() { - git \ - push \ - --tags \ - --verbose \ - "${@}" + rwx_gpg_agent_update && + git \ + push \ + --tags \ + --verbose \ + "${@}" } # delete from the remote repository diff --git a/sh/alias/gpg.sh b/sh/alias/gpg.sh index 496b05e..eb19651 100644 --- a/sh/alias/gpg.sh +++ b/sh/alias/gpg.sh @@ -8,7 +8,5 @@ a__gpg_agent_kill() { # bind gpg agent to current tty gau() { a__gpg_agent_update "${@}"; } a__gpg_agent_update() { - gpg-connect-agent \ - updatestartuptty \ - /bye + rwx_gpg_agent_update } From 6ed3cb83a6c235291c840cd8a3a60f396af53765 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 18:07:54 +0100 Subject: [PATCH 922/969] gau/gf --- sh/alias/git.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sh/alias/git.sh b/sh/alias/git.sh index 73afa5f..a8ff88d 100644 --- a/sh/alias/git.sh +++ b/sh/alias/git.sh @@ -240,11 +240,12 @@ a__git_diff_word() { # fetch from the remote repository gf() { a__git_fetch "${@}"; } a__git_fetch() { - git \ - fetch \ - --tags \ - --verbose \ - "${@}" + rwx_gpg_agent_update && + git \ + fetch \ + --tags \ + --verbose \ + "${@}" } # fetch from remote repository and prune local orphan branches From 428ea3e9e5b920975656aebd5335654a77f6f2f6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 18:11:09 +0100 Subject: [PATCH 923/969] -n --- sh/alias/git.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/alias/git.sh b/sh/alias/git.sh index a8ff88d..27b586e 100644 --- a/sh/alias/git.sh +++ b/sh/alias/git.sh @@ -539,7 +539,7 @@ a__git_tag_delete() { # update head ref gurh() { a__git_update_ref_head "${@}"; } a__git_update_ref_head() { - if [ "${2}" ]; then + if [ -n "${2}" ]; then git \ update-ref \ "refs/heads/${1}" \ From 9b0b4ecb8059dda3828296c12542f39a2b436909 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 18:35:33 +0100 Subject: [PATCH 924/969] setup/main --- sh/shell.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sh/shell.sh b/sh/shell.sh index 561fcdd..7889951 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -117,9 +117,10 @@ rwx_shell_prompt() { rwx_shell_setup() { # shell - echo "export ENV=\"${ENV}\"" >"/etc/profile.d/${RWX_SELF_NAME}.sh" + echo "export ENV=\"${RWX_MAIN_PATH}\"" \ + >"/etc/profile.d/${RWX_SELF_NAME}.sh" # bash local file="/etc/bash.bashrc" rm --force --recursive "${file}" - ln --symbolic "${ENV}" "${file}" + ln --symbolic "${RWX_MAIN_PATH}" "${file}" } From aec586aa2c9d5737c0603f435116bfb3cf02842d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 18:58:27 +0100 Subject: [PATCH 925/969] self/install --- sh/self.sh | 13 +++++++++++++ sh/shell.sh | 10 ---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/sh/self.sh b/sh/self.sh index 4220366..709feb7 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -14,3 +14,16 @@ rwx_self_help() { " a__… = aliases" \ " u__… = user" } + +rwx_self_install() { + local target="${1}" + local file + # sh + file="${target}/etc/profile.d/${RWX_SELF_NAME}.sh" + rm --force --recursive "${file}" + echo "export ENV=\"${RWX_MAIN_PATH}\"" >"${file}" + # bash + file="/etc/bash.bashrc" + rm --force --recursive "${file}" + ln --symbolic "${RWX_MAIN_PATH}" "${file}" +} diff --git a/sh/shell.sh b/sh/shell.sh index 7889951..4f0db9b 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -114,13 +114,3 @@ rwx_shell_prompt() { # print printf "%b" "${view}" } - -rwx_shell_setup() { - # shell - echo "export ENV=\"${RWX_MAIN_PATH}\"" \ - >"/etc/profile.d/${RWX_SELF_NAME}.sh" - # bash - local file="/etc/bash.bashrc" - rm --force --recursive "${file}" - ln --symbolic "${RWX_MAIN_PATH}" "${file}" -} From a9c98b2853f09ceeedb9e8f232cf4839918def40 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 19:01:05 +0100 Subject: [PATCH 926/969] rwx/remove --- sh/util.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sh/util.sh b/sh/util.sh index a81c808..39e6fce 100644 --- a/sh/util.sh +++ b/sh/util.sh @@ -36,6 +36,13 @@ rwx_read_secret() { unset secret } +rwx_remove() { + rm \ + --force \ + --recursive \ + "${@}" +} + rwx_warn_wipe() { local tmp rwx_list_block_devices From f06d1e2bce5d31451bf37409226fe39168b81eb3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 19:04:23 +0100 Subject: [PATCH 927/969] rwx/link --- sh/util.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sh/util.sh b/sh/util.sh index 39e6fce..15925c6 100644 --- a/sh/util.sh +++ b/sh/util.sh @@ -6,6 +6,15 @@ rwx_file_write() { fi } +rwx_link() { + local link="${1}" + local target="${2}" + ln \ + --sybolic \ + "${target}" \ + "${link}" +} + rwx_list_block_devices() { lsblk \ --noempty \ From 52a43b0e6054faf5fde94e9f389f6c5d99518782 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 19:06:44 +0100 Subject: [PATCH 928/969] self/install --- sh/self.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sh/self.sh b/sh/self.sh index 709feb7..0e6621f 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -20,10 +20,10 @@ rwx_self_install() { local file # sh file="${target}/etc/profile.d/${RWX_SELF_NAME}.sh" - rm --force --recursive "${file}" - echo "export ENV=\"${RWX_MAIN_PATH}\"" >"${file}" + rwx_remove "${file}" + rwx_file_write "${file}" "export ENV=\"${RWX_MAIN_PATH}\"" # bash file="/etc/bash.bashrc" - rm --force --recursive "${file}" - ln --symbolic "${RWX_MAIN_PATH}" "${file}" + rwx_remove "${file}" + rwx_link "${file}" "${RWX_MAIN_PATH}" } From d94880bb75ca38c849101f3c9c31b5d03bf1c376 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 19:40:52 +0100 Subject: [PATCH 929/969] main/shell --- sh/main.sh | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 2b3508c..d205d46 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -114,25 +114,33 @@ rwx_source() { # run initial steps rwx_main() { - # system root - if ! rwx_source "${RWX_ROOT_SYSTEM}"; then - __rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}" - return 1 - fi - # user root - rwx_source "${RWX_ROOT_USER}" - # run interactive extras - if rwx_shell_interactive; then - # check format - rwx_log - rwx_shfmt "${RWX_ROOT_SYSTEM}" - # check syntax - rwx_log - rwx_shellcheck "${RWX_ROOT_SYSTEM}" - # help - rwx_log - rwx_self_help - fi + case "${RWX_SHELL}" in + "sh" | \ + "bash") + # system root + if ! rwx_source "${RWX_ROOT_SYSTEM}"; then + __rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}" + return 1 + fi + # user root + rwx_source "${RWX_ROOT_USER}" + # run interactive extras + if rwx_shell_interactive; then + # check format + rwx_log + rwx_shfmt "${RWX_ROOT_SYSTEM}" + # check syntax + rwx_log + rwx_shellcheck "${RWX_ROOT_SYSTEM}" + # help + rwx_log + rwx_self_help + fi + ;; + *) + echo + ;; + esac } # run main function From ba7a51e1b1f77814e47fae703192404158db1440 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 19:49:14 +0100 Subject: [PATCH 930/969] main/cmd --- sh/main.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index d205d46..0c0be2c 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -138,10 +138,13 @@ rwx_main() { fi ;; *) - echo + local argument="${0}" + local name + name="$(basename "${argument}")" + "rwx_cmd_${name}" "${@}" ;; esac } # run main function -rwx_main +rwx_main "${@}" From 46e14ebf32a7bef8ccd195c610a26a59e09df107 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 19:50:30 +0100 Subject: [PATCH 931/969] +x --- sh/main.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 sh/main.sh diff --git a/sh/main.sh b/sh/main.sh old mode 100644 new mode 100755 From 2054f48931f3046bce6311f16e47ff2ffffccc13 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 19:51:06 +0100 Subject: [PATCH 932/969] main/shebang --- sh/main.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sh/main.sh b/sh/main.sh index 0c0be2c..d40e889 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -1,3 +1,5 @@ +#! /usr/bin/env sh + # ╭───────────╮ # │ constants │ # ╰───────────╯ From 30b002c31e2aeec407a951e14f825ad91a2b57d5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 19:53:12 +0100 Subject: [PATCH 933/969] git/rwx --- sh/alias/git.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/alias/git.sh b/sh/alias/git.sh index 27b586e..cadd10b 100644 --- a/sh/alias/git.sh +++ b/sh/alias/git.sh @@ -1,4 +1,4 @@ -SH_GIT_LOG_FORMAT="\ +RWX_GIT_LOG_FORMAT="\ %C(auto)%h%d S %C(red)%GS A %C(green)%an %ae @@ -294,7 +294,7 @@ a__git_log() { log \ --abbrev=8 \ --abbrev-commit \ - --format="${SH_GIT_LOG_FORMAT}" \ + --format="${RWX_GIT_LOG_FORMAT}" \ --graph \ "${@}" } From b67107c737fde62ada309412872de77ff8944cbb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 20:03:28 +0100 Subject: [PATCH 934/969] self/user --- sh/main.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index d40e889..ec9bd1a 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -11,13 +11,16 @@ RWX_SELF_NAME="rwx" # │ variables │ # ╰───────────╯ -RWX_ROOT_USER="${HOME}/${RWX_SELF_NAME}" RWX_SHELL="$(cat "/proc/${$}/comm")" RWX_SYSTEM_ROOT="/usr/local/lib" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" RWX_ROOT_SYSTEM="${RWX_SYSTEM_ROOT}/${RWX_SELF_NAME}" +rwx_self_user() { + echo "${HOME}/${RWX_SELF_NAME}" +} + # ╭──────╮ # │ core │ # ╰──────╯ @@ -125,7 +128,7 @@ rwx_main() { return 1 fi # user root - rwx_source "${RWX_ROOT_USER}" + rwx_source "$(rwx_self_user)" # run interactive extras if rwx_shell_interactive; then # check format From 527b2d2a67b86703691c310b3256a4ccb3c7e3ba Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 20:15:05 +0100 Subject: [PATCH 935/969] rwx/shell --- sh/alias/shell.sh | 2 +- sh/main.sh | 7 +++++-- sh/shell.sh | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sh/alias/shell.sh b/sh/alias/shell.sh index d6f5801..4b0949b 100644 --- a/sh/alias/shell.sh +++ b/sh/alias/shell.sh @@ -17,7 +17,7 @@ x() { "${@}" } -[ "${RWX_SHELL}" = "bash" ] || return +[ "$(rwx_shell)" = "bash" ] || return # shellcheck disable=SC3033 ..() { diff --git a/sh/main.sh b/sh/main.sh index ec9bd1a..f0f84bc 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -11,7 +11,6 @@ RWX_SELF_NAME="rwx" # │ variables │ # ╰───────────╯ -RWX_SHELL="$(cat "/proc/${$}/comm")" RWX_SYSTEM_ROOT="/usr/local/lib" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" @@ -21,6 +20,10 @@ rwx_self_user() { echo "${HOME}/${RWX_SELF_NAME}" } +rwx_shell() { + cat "/proc/${$}/comm" +} + # ╭──────╮ # │ core │ # ╰──────╯ @@ -119,7 +122,7 @@ rwx_source() { # run initial steps rwx_main() { - case "${RWX_SHELL}" in + case "$(rwx_shell)" in "sh" | \ "bash") # system root diff --git a/sh/shell.sh b/sh/shell.sh index 4f0db9b..54284c6 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -1,6 +1,6 @@ _rwx_shell_color() { local code="${1}" - case "${RWX_SHELL}" in + case "$(rwx_shell)" in "bash") printf "\x01\e[0" if [ -n "${code}" ]; then @@ -33,7 +33,7 @@ rwx_shell_configure() { PS1="\$(rwx_shell_prompt \${?})" PS2="├ " # specific - case "${RWX_SHELL}" in + case "$(rwx_shell)" in "bash") # completion local root="/usr/share/bash-completion" From b85e5768a8e0ba80bf82f3f4a9712b93e5d2bc19 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 20:23:52 +0100 Subject: [PATCH 936/969] unindent --- sh/main.sh | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index f0f84bc..8970910 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -122,29 +122,29 @@ rwx_source() { # run initial steps rwx_main() { + # system root + if ! rwx_source "${RWX_ROOT_SYSTEM}"; then + __rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}" + return 1 + fi + # user root + rwx_source "$(rwx_self_user)" + # run interactive extras + if rwx_shell_interactive; then + # check format + rwx_log + rwx_shfmt "${RWX_ROOT_SYSTEM}" + # check syntax + rwx_log + rwx_shellcheck "${RWX_ROOT_SYSTEM}" + # help + rwx_log + rwx_self_help + fi case "$(rwx_shell)" in - "sh" | \ - "bash") - # system root - if ! rwx_source "${RWX_ROOT_SYSTEM}"; then - __rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}" - return 1 - fi - # user root - rwx_source "$(rwx_self_user)" - # run interactive extras - if rwx_shell_interactive; then - # check format - rwx_log - rwx_shfmt "${RWX_ROOT_SYSTEM}" - # check syntax - rwx_log - rwx_shellcheck "${RWX_ROOT_SYSTEM}" - # help - rwx_log - rwx_self_help - fi - ;; + "bash" | \ + "dash" | \ + "sh") ;; *) local argument="${0}" local name From 163ff926cdaaa1cd1a6f50d7f5abe18f8c0d78b1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 20:25:19 +0100 Subject: [PATCH 937/969] fmt --- sh/main.sh | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 8970910..57d5299 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -129,22 +129,23 @@ rwx_main() { fi # user root rwx_source "$(rwx_self_user)" - # run interactive extras - if rwx_shell_interactive; then - # check format - rwx_log - rwx_shfmt "${RWX_ROOT_SYSTEM}" - # check syntax - rwx_log - rwx_shellcheck "${RWX_ROOT_SYSTEM}" - # help - rwx_log - rwx_self_help - fi case "$(rwx_shell)" in "bash" | \ - "dash" | \ - "sh") ;; + "dash" | \ + "sh") + # run interactive extras + if rwx_shell_interactive; then + # check format + rwx_log + rwx_shfmt "${RWX_ROOT_SYSTEM}" + # check syntax + rwx_log + rwx_shellcheck "${RWX_ROOT_SYSTEM}" + # help + rwx_log + rwx_self_help + fi + ;; *) local argument="${0}" local name From 1e1954ce9b0777cff690d59da2d45373e8f72eb8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 21:03:57 +0100 Subject: [PATCH 938/969] prefix --- sh/main.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 57d5299..ae389aa 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -7,6 +7,8 @@ RWX_MAIN_NAME="main.sh" RWX_SELF_NAME="rwx" +RWX_PREFIX_COMMAND="${RWX_SELF_NAME}_cmd_" + # ╭───────────╮ # │ variables │ # ╰───────────╯ @@ -148,9 +150,10 @@ rwx_main() { ;; *) local argument="${0}" - local name + local function name name="$(basename "${argument}")" - "rwx_cmd_${name}" "${@}" + function="${RWX_PREFIX_COMMAND}${name}" + "${function}" "${@}" ;; esac } From bf10fd4a05f34dfb24875dd9563f8261f9108840 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 21:13:45 +0100 Subject: [PATCH 939/969] cs --- sh/cryptsetup.sh | 6 ++++++ sh/main.sh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 sh/cryptsetup.sh diff --git a/sh/cryptsetup.sh b/sh/cryptsetup.sh new file mode 100644 index 0000000..900083d --- /dev/null +++ b/sh/cryptsetup.sh @@ -0,0 +1,6 @@ +_rwx_cmd_cs() { rwx_crypt_setup "${@}"; } + +rwx_crypt_setup() { + local action="${1}" + echo "cs: ${action}" +} diff --git a/sh/main.sh b/sh/main.sh index ae389aa..d573b21 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -7,7 +7,7 @@ RWX_MAIN_NAME="main.sh" RWX_SELF_NAME="rwx" -RWX_PREFIX_COMMAND="${RWX_SELF_NAME}_cmd_" +RWX_PREFIX_COMMAND="_${RWX_SELF_NAME}_cmd_" # ╭───────────╮ # │ variables │ From ea8be45789fe901b52b75c94ae3f6b084b227c67 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 21:22:35 +0100 Subject: [PATCH 940/969] self/commands --- sh/self.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sh/self.sh b/sh/self.sh index 0e6621f..fe3a86c 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -1,4 +1,14 @@ -# get functions from file +# get commands from root +rwx_self_commands() { + grep \ + --directories "recurse" \ + --no-filename \ + "^${RWX_PREFIX_COMMAND}" "${RWX_ROOT_SYSTEM}" | + cut --delimiter "(" --fields 1 | + sed "s|^${RWX_PREFIX_COMMAND}||" +} + +# get functions from root rwx_self_functions() { grep \ --directories "recurse" \ From f588882b1fa3da28ecbd9b5d6b6bc84bf88c5469 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 21:28:42 +0100 Subject: [PATCH 941/969] lib --- sh/main.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index d573b21..1654ba2 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -13,10 +13,9 @@ RWX_PREFIX_COMMAND="_${RWX_SELF_NAME}_cmd_" # │ variables │ # ╰───────────╯ -RWX_SYSTEM_ROOT="/usr/local/lib" +RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" -RWX_ROOT_SYSTEM="${RWX_SYSTEM_ROOT}/${RWX_SELF_NAME}" rwx_self_user() { echo "${HOME}/${RWX_SELF_NAME}" From 0818e810386ab467e3f54d5770d77a9e35677c89 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 21:37:55 +0100 Subject: [PATCH 942/969] install/commands --- sh/self.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sh/self.sh b/sh/self.sh index fe3a86c..7d22136 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -27,7 +27,14 @@ rwx_self_help() { rwx_self_install() { local target="${1}" - local file + local command file + # commands + local root="${target}/usr/local/bin" + for command in $(rwx_self_commands); do + file="${root}/${command}" + rwx_remove "${file}" + rwx_link "${file}" "${RWX_MAIN_PATH}" + done # sh file="${target}/etc/profile.d/${RWX_SELF_NAME}.sh" rwx_remove "${file}" From b61ec7044d797b6089d3040bcfcc3a735b321f3a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 21:39:41 +0100 Subject: [PATCH 943/969] fix --- sh/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/util.sh b/sh/util.sh index 15925c6..4dd81bf 100644 --- a/sh/util.sh +++ b/sh/util.sh @@ -10,7 +10,7 @@ rwx_link() { local link="${1}" local target="${2}" ln \ - --sybolic \ + --symbolic \ "${target}" \ "${link}" } From 52b6c06cb1e1137907c3d81214ce372c97c3e5f0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 21:48:04 +0100 Subject: [PATCH 944/969] self/command --- sh/main.sh | 4 ++-- sh/self.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 1654ba2..cd8c67a 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -7,7 +7,7 @@ RWX_MAIN_NAME="main.sh" RWX_SELF_NAME="rwx" -RWX_PREFIX_COMMAND="_${RWX_SELF_NAME}_cmd_" +RWX_SELF_COMMAND="_${RWX_SELF_NAME}_cmd_" # ╭───────────╮ # │ variables │ @@ -151,7 +151,7 @@ rwx_main() { local argument="${0}" local function name name="$(basename "${argument}")" - function="${RWX_PREFIX_COMMAND}${name}" + function="${RWX_SELF_COMMAND}${name}" "${function}" "${@}" ;; esac diff --git a/sh/self.sh b/sh/self.sh index 7d22136..dd43765 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -3,9 +3,9 @@ rwx_self_commands() { grep \ --directories "recurse" \ --no-filename \ - "^${RWX_PREFIX_COMMAND}" "${RWX_ROOT_SYSTEM}" | + "^${RWX_SELF_COMMAND}" "${RWX_ROOT_SYSTEM}" | cut --delimiter "(" --fields 1 | - sed "s|^${RWX_PREFIX_COMMAND}||" + sed "s|^${RWX_SELF_COMMAND}||" } # get functions from root From a8f4ad7097c0000975c29f50452a6590015a837f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 22:01:38 +0100 Subject: [PATCH 945/969] ${0} --- sh/main.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/main.sh b/sh/main.sh index cd8c67a..f3671d8 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -130,7 +130,8 @@ rwx_main() { fi # user root rwx_source "$(rwx_self_user)" - case "$(rwx_shell)" in + # + case "${0}" in "bash" | \ "dash" | \ "sh") From dc1fdbace711d6eeb50e7f5a84325ac7e3845975 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 22:06:18 +0100 Subject: [PATCH 946/969] =?UTF-8?q?=E2=88=92arg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sh/main.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index f3671d8..6c6001e 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -149,9 +149,8 @@ rwx_main() { fi ;; *) - local argument="${0}" local function name - name="$(basename "${argument}")" + name="$(basename "${0}")" function="${RWX_SELF_COMMAND}${name}" "${function}" "${@}" ;; From 05e5d00a952c3b23597b3103170f56413a4fca5b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 22:10:05 +0100 Subject: [PATCH 947/969] self/user --- sh/main.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 6c6001e..554a2ce 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -14,13 +14,10 @@ RWX_SELF_COMMAND="_${RWX_SELF_NAME}_cmd_" # ╰───────────╯ RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}" +RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" -rwx_self_user() { - echo "${HOME}/${RWX_SELF_NAME}" -} - rwx_shell() { cat "/proc/${$}/comm" } @@ -129,7 +126,7 @@ rwx_main() { return 1 fi # user root - rwx_source "$(rwx_self_user)" + rwx_source "${RWX_SELF_USER}" # case "${0}" in "bash" | \ From 77a53428e123a9117d5b00b86070258c8da331ff Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 22:11:52 +0100 Subject: [PATCH 948/969] rwx/shell --- sh/alias/shell.sh | 2 +- sh/shell.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/alias/shell.sh b/sh/alias/shell.sh index 4b0949b..d6f5801 100644 --- a/sh/alias/shell.sh +++ b/sh/alias/shell.sh @@ -17,7 +17,7 @@ x() { "${@}" } -[ "$(rwx_shell)" = "bash" ] || return +[ "${RWX_SHELL}" = "bash" ] || return # shellcheck disable=SC3033 ..() { diff --git a/sh/shell.sh b/sh/shell.sh index 54284c6..4f0db9b 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -1,6 +1,6 @@ _rwx_shell_color() { local code="${1}" - case "$(rwx_shell)" in + case "${RWX_SHELL}" in "bash") printf "\x01\e[0" if [ -n "${code}" ]; then @@ -33,7 +33,7 @@ rwx_shell_configure() { PS1="\$(rwx_shell_prompt \${?})" PS2="├ " # specific - case "$(rwx_shell)" in + case "${RWX_SHELL}" in "bash") # completion local root="/usr/share/bash-completion" From 3b11f3b45920811ad4336926f89dcf71a0601623 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 22:13:16 +0100 Subject: [PATCH 949/969] rwx/shell --- sh/main.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 554a2ce..4d311bb 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -15,13 +15,10 @@ RWX_SELF_COMMAND="_${RWX_SELF_NAME}_cmd_" RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}" RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}" +RWX_SHELL="$(cat "/proc/${$}/comm")" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" -rwx_shell() { - cat "/proc/${$}/comm" -} - # ╭──────╮ # │ core │ # ╰──────╯ From 76176ae49f3786da458196dede1b9a58b954d5cd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 22:28:22 +0100 Subject: [PATCH 950/969] cmd/install --- sh/self.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/sh/self.sh b/sh/self.sh index dd43765..cd07ad5 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -25,6 +25,7 @@ rwx_self_help() { " u__… = user" } +_rwx_cmd_rwx_install() { rwx_self_install "${@}"; } rwx_self_install() { local target="${1}" local command file From 8e2cd2a86751a6d85a715170fc67c820ed022a57 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 23:20:05 +0100 Subject: [PATCH 951/969] arg0 --- sh/main.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 4d311bb..a752396 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -125,7 +125,8 @@ rwx_main() { # user root rwx_source "${RWX_SELF_USER}" # - case "${0}" in + local argument="$(echo "${0}" | sed "s|^-||")" + case "${argument}" in "bash" | \ "dash" | \ "sh") @@ -144,7 +145,7 @@ rwx_main() { ;; *) local function name - name="$(basename "${0}")" + name="$(basename "${argument}")" function="${RWX_SELF_COMMAND}${name}" "${function}" "${@}" ;; From 9f705e6af84441df19e5240872d2a0e91c54a717 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 23:21:14 +0100 Subject: [PATCH 952/969] arg --- sh/main.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/main.sh b/sh/main.sh index a752396..2d729f3 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -125,7 +125,8 @@ rwx_main() { # user root rwx_source "${RWX_SELF_USER}" # - local argument="$(echo "${0}" | sed "s|^-||")" + local argument + argument="$(echo "${0}" | sed "s|^-||")" case "${argument}" in "bash" | \ "dash" | \ From ce872d4ecb48c80029b175d68ffd7991ed2f1187 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Dec 2024 23:40:54 +0100 Subject: [PATCH 953/969] file/append,empty --- sh/util.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sh/util.sh b/sh/util.sh index 4dd81bf..cbcd67a 100644 --- a/sh/util.sh +++ b/sh/util.sh @@ -1,3 +1,18 @@ +rwx_file_append() { + local file="${1}" + local text="${2}" + if [ -n "${file}" ]; then + printf "%s" "${text}" >>"${file}" + fi +} + +rwx_file_empty() { + local file="${1}" + if [ -n "${file}" ]; then + rwx_file_write "${file}" "" + fi +} + rwx_file_write() { local file="${1}" local text="${2}" From 7dbf58119172afeb8c60f0ffbb3f5995dd20a7c7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Dec 2024 00:06:42 +0100 Subject: [PATCH 954/969] self/subset,write --- sh/self.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/sh/self.sh b/sh/self.sh index cd07ad5..fdce1af 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -45,3 +45,34 @@ rwx_self_install() { rwx_remove "${file}" rwx_link "${file}" "${RWX_MAIN_PATH}" } + +rwx_self_subset() { + local argument path + for argument in "${@}"; do + path="${RWX_ROOT_SYSTEM}/${argument}" + if [ -d "${path}" ]; then + rwx_find_shell "${path}" + elif [ -f "${path}" ]; then + echo "${argument}" + fi + done +} + +rwx_self_write() { + local target="${1}" + if [ -n "${target}" ]; then + shift + local file text + text="#! /usr/bin/env sh +" + rwx_ifs_set + for file in $(rwx_self_subset "${@}"); do + text="${text} +# ${file} + +$(cat "${RWX_ROOT_SYSTEM}/${file}")" + done + rwx_ifs_unset + rwx_file_write "${target}" "${text}" + fi +} From f3851dbc885960242dcd5b6ba09e1ec7d8936931 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Dec 2024 00:30:01 +0100 Subject: [PATCH 955/969] fixes --- sh/self.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sh/self.sh b/sh/self.sh index fdce1af..870f010 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -51,7 +51,10 @@ rwx_self_subset() { for argument in "${@}"; do path="${RWX_ROOT_SYSTEM}/${argument}" if [ -d "${path}" ]; then - rwx_find_shell "${path}" + local file + for file in $(rwx_find_shell "${path}"); do + echo "${argument}/${file}" + done elif [ -f "${path}" ]; then echo "${argument}" fi @@ -68,9 +71,8 @@ rwx_self_write() { rwx_ifs_set for file in $(rwx_self_subset "${@}"); do text="${text} -# ${file} - -$(cat "${RWX_ROOT_SYSTEM}/${file}")" +$(cat "${RWX_ROOT_SYSTEM}/${file}") +" done rwx_ifs_unset rwx_file_write "${target}" "${text}" From 0dfe86a9704e820b2e825adbfc6a86013bec1153 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Dec 2024 00:39:16 +0100 Subject: [PATCH 956/969] target/shfmt --- sh/lint/shfmt.sh | 4 ++-- sh/self.sh | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sh/lint/shfmt.sh b/sh/lint/shfmt.sh index 097de86..4d6e894 100644 --- a/sh/lint/shfmt.sh +++ b/sh/lint/shfmt.sh @@ -1,4 +1,4 @@ rwx_shfmt() { - local root="${1}" - shfmt --diff "${root}" + local path="${1}" + shfmt --diff "${path}" } diff --git a/sh/self.sh b/sh/self.sh index 870f010..b09d46e 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -76,5 +76,6 @@ $(cat "${RWX_ROOT_SYSTEM}/${file}") done rwx_ifs_unset rwx_file_write "${target}" "${text}" + rwx_shfmt "${target}" fi } From 45d93964e5bef20f3ec0979903a4809769cbd68c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Dec 2024 00:42:35 +0100 Subject: [PATCH 957/969] remove --- sh/lint/shellcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/lint/shellcheck.sh b/sh/lint/shellcheck.sh index b520fd9..d5708ca 100644 --- a/sh/lint/shellcheck.sh +++ b/sh/lint/shellcheck.sh @@ -16,7 +16,7 @@ rwx_shellcheck() { --external-sources \ --shell "dash" \ "${file}" - rm "${file}" + rwx_remove "${file}" } rwx_shellcheck_write() { From aa2c6df97e0a23b9f94e916514c74a4c6af47d57 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Dec 2024 00:46:30 +0100 Subject: [PATCH 958/969] shellcheck/file --- sh/lint/shellcheck.sh | 7 ++++++- sh/self.sh | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sh/lint/shellcheck.sh b/sh/lint/shellcheck.sh index d5708ca..ac8c700 100644 --- a/sh/lint/shellcheck.sh +++ b/sh/lint/shellcheck.sh @@ -9,6 +9,12 @@ rwx_shellcheck() { echo ". \"${path}\"" >>"${file}" done rwx_ifs_unset + rwx_shellcheck_file "${file}" + rwx_remove "${file}" +} + +rwx_shellcheck_file() { + local file="${1}" shellcheck \ --check-sourced \ --enable "all" \ @@ -16,7 +22,6 @@ rwx_shellcheck() { --external-sources \ --shell "dash" \ "${file}" - rwx_remove "${file}" } rwx_shellcheck_write() { diff --git a/sh/self.sh b/sh/self.sh index b09d46e..41a2a0c 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -77,5 +77,6 @@ $(cat "${RWX_ROOT_SYSTEM}/${file}") rwx_ifs_unset rwx_file_write "${target}" "${text}" rwx_shfmt "${target}" + rwx_shellcheck_file "${target}" fi } From 240c0533ecc0ea013a49e1b671fd33ad5f9fedf9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Dec 2024 01:18:40 +0100 Subject: [PATCH 959/969] mv --- sh/{ => log}/log.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{ => log}/log.sh (100%) diff --git a/sh/log.sh b/sh/log/log.sh similarity index 100% rename from sh/log.sh rename to sh/log/log.sh From 8ad9ebc602b4d212071ea48d13d3eabf9d6c4cd5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Dec 2024 01:41:08 +0100 Subject: [PATCH 960/969] step/__ --- sh/log/step.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 sh/log/step.sh diff --git a/sh/log/step.sh b/sh/log/step.sh new file mode 100644 index 0000000..30c64f4 --- /dev/null +++ b/sh/log/step.sh @@ -0,0 +1,11 @@ +# ╭───────────────╮ +# │ __ = internal │ +# ╰───────────────╯ + +# __RWX_BAR_TOP +# __RWX_BAR_MIDDLE +# __RWX_BAR_BOTTOM + +# __RWX_STEP_LEVEL +# __RWX_STEP_level_INDEX +# __RWX_STEP_level_LABEL From 93d1cef6e36dd598cf777cb9319be8801427ffb0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Dec 2024 01:44:01 +0100 Subject: [PATCH 961/969] step/box --- sh/log/step.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sh/log/step.sh b/sh/log/step.sh index 30c64f4..34a5c64 100644 --- a/sh/log/step.sh +++ b/sh/log/step.sh @@ -9,3 +9,17 @@ # __RWX_STEP_LEVEL # __RWX_STEP_level_INDEX # __RWX_STEP_level_LABEL + +# ╭─────────────╮ +# │ _ = private │ +# ╰─────────────╯ + +_RWX_BOX_DOWN_AND_HORIZONTAL="┬" +_RWX_BOX_DOWN_AND_LEFT="╮" +_RWX_BOX_DOWN_AND_RIGHT="╭" +_RWX_BOX_HORIZONTAL="─" +_RWX_BOX_LEFT="╴" +_RWX_BOX_UP_AND_HORIZONTAL="┴" +_RWX_BOX_UP_AND_LEFT="╯" +_RWX_BOX_UP_AND_RIGHT="╰" +_RWX_BOX_VERTICAL="│" From 3495d35051bfe0a77f341d69a5c1fb16f913d26f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Dec 2024 01:53:34 +0100 Subject: [PATCH 962/969] modules --- sh/main.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 2d729f3..d1b3a65 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -95,13 +95,12 @@ rwx_source() { local path="${1}" [ -d "${path}" ] || return 1 - local count module modules - modules="$(rwx_find_shell "${path}" "${RWX_MAIN_NAME}")" - rwx_ifs_set + local count module count=0 __rwx_log "" \ ". ${path}" - for module in ${modules}; do + rwx_ifs_set + for module in $(rwx_find_shell "${path}" "${RWX_MAIN_NAME}"); do count=$((count + 1)) __rwx_log "$(printf "%02d" "${count}") ${module%.sh}" module="${path}/${module}" From 1681e1567f0ed3076dae1816e23ab4de7c4c2549 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Dec 2024 03:05:07 +0100 Subject: [PATCH 963/969] =?UTF-8?q?=E2=86=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sh/main.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/main.sh b/sh/main.sh index d1b3a65..ceb6414 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -13,9 +13,10 @@ RWX_SELF_COMMAND="_${RWX_SELF_NAME}_cmd_" # │ variables │ # ╰───────────╯ +RWX_SHELL="$(cat "/proc/${$}/comm")" + RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}" RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}" -RWX_SHELL="$(cat "/proc/${$}/comm")" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" From e60e72d1da4514d7d47375c537da8629ca571159 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Dec 2024 03:22:30 +0100 Subject: [PATCH 964/969] main --- sh/main.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index ceb6414..3655ca7 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -1,17 +1,17 @@ #! /usr/bin/env sh -# ╭───────────╮ -# │ constants │ -# ╰───────────╯ +# ╭──────┬───────────╮ +# │ main │ constants │ +# ╰──────┴───────────╯ RWX_MAIN_NAME="main.sh" RWX_SELF_NAME="rwx" RWX_SELF_COMMAND="_${RWX_SELF_NAME}_cmd_" -# ╭───────────╮ -# │ variables │ -# ╰───────────╯ +# ╭──────┬───────────╮ +# │ main │ variables │ +# ╰──────┴───────────╯ RWX_SHELL="$(cat "/proc/${$}/comm")" @@ -20,9 +20,9 @@ RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" -# ╭──────╮ -# │ core │ -# ╰──────╯ +# ╭──────┬───────╮ +# │ main │ shell │ +# ╰──────┴───────╯ # test if active shell is in interactive mode rwx_shell_interactive() { @@ -33,7 +33,7 @@ rwx_shell_interactive() { } # ╭──────┬─────╮ -# │ core │ log │ +# │ main │ log │ # ╰──────┴─────╯ __rwx_log() { @@ -47,7 +47,7 @@ __rwx_log() { } # ╭──────┬──────╮ -# │ core │ find │ +# │ main │ find │ # ╰──────┴──────╯ # find directory’s files by extension @@ -74,7 +74,7 @@ rwx_find_shell() { } # ╭──────┬─────╮ -# │ core │ ifs │ +# │ main │ ifs │ # ╰──────┴─────╯ rwx_ifs_set() { @@ -89,7 +89,7 @@ rwx_ifs_unset() { } # ╭──────┬────────╮ -# │ core │ source │ +# │ main │ source │ # ╰──────┴────────╯ rwx_source() { @@ -111,9 +111,9 @@ rwx_source() { rwx_ifs_unset } -# ╭──────┬──────╮ -# │ core │ main │ -# ╰──────┴──────╯ +# ╭──────╮ +# │ main │ +# ╰──────╯ # run initial steps rwx_main() { From 68ec08871cb599899a3e6796adc5ba32c4da036d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Dec 2024 04:02:26 +0100 Subject: [PATCH 965/969] command/argument,name --- sh/main.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sh/main.sh b/sh/main.sh index 3655ca7..6b1605d 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -13,8 +13,15 @@ RWX_SELF_COMMAND="_${RWX_SELF_NAME}_cmd_" # │ main │ variables │ # ╰──────┴───────────╯ +RWX_COMMAND_ARGUMENT="${0}" RWX_SHELL="$(cat "/proc/${$}/comm")" +RWX_COMMAND_NAME="$(basename "${RWX_COMMAND_ARGUMENT}" | + sed "s|^-||")" +case "${RWX_COMMAND_NAME}" in +"bash" | "dash" | "sh") unset RWX_COMMAND_NAME ;; +*) ;; +esac RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}" RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}" From 1eb130320e77765a84c0abadcf0bebfadc30fed6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Dec 2024 15:07:55 +0100 Subject: [PATCH 966/969] context/command,shell --- sh/main.sh | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 6b1605d..eb938e8 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -131,13 +131,11 @@ rwx_main() { fi # user root rwx_source "${RWX_SELF_USER}" - # - local argument - argument="$(echo "${0}" | sed "s|^-||")" - case "${argument}" in - "bash" | \ - "dash" | \ - "sh") + # context / command + if [ -n "${RWX_COMMAND_NAME}" ]; then + "${RWX_SELF_COMMAND}${RWX_COMMAND_NAME}" "${@}" + # context / shell + else # run interactive extras if rwx_shell_interactive; then # check format @@ -150,14 +148,7 @@ rwx_main() { rwx_log rwx_self_help fi - ;; - *) - local function name - name="$(basename "${argument}")" - function="${RWX_SELF_COMMAND}${name}" - "${function}" "${@}" - ;; - esac + fi } # run main function From 01e6165788f2da37a744cd8c53e293728b2bfa1c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 2 Dec 2024 15:24:27 +0100 Subject: [PATCH 967/969] self/init --- sh/main.sh | 13 +------------ sh/self.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index eb938e8..802418f 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -136,18 +136,7 @@ rwx_main() { "${RWX_SELF_COMMAND}${RWX_COMMAND_NAME}" "${@}" # context / shell else - # run interactive extras - if rwx_shell_interactive; then - # check format - rwx_log - rwx_shfmt "${RWX_ROOT_SYSTEM}" - # check syntax - rwx_log - rwx_shellcheck "${RWX_ROOT_SYSTEM}" - # help - rwx_log - rwx_self_help - fi + rwx_self_init fi } diff --git a/sh/self.sh b/sh/self.sh index 41a2a0c..c6fad3b 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -1,3 +1,7 @@ +# ╭──────┬──────────╮ +# │ self │ commands │ +# ╰──────┴──────────╯ + # get commands from root rwx_self_commands() { grep \ @@ -8,6 +12,10 @@ rwx_self_commands() { sed "s|^${RWX_SELF_COMMAND}||" } +# ╭──────┬───────────╮ +# │ self │ functions │ +# ╰──────┴───────────╯ + # get functions from root rwx_self_functions() { grep \ @@ -17,6 +25,10 @@ rwx_self_functions() { cut --delimiter "(" --fields 1 } +# ╭──────┬──────╮ +# │ self │ help │ +# ╰──────┴──────╯ + # output help message rwx_self_help() { rwx_log \ @@ -25,6 +37,29 @@ rwx_self_help() { " u__… = user" } +# ╭──────┬──────╮ +# │ self │ init │ +# ╰──────┴──────╯ + +rwx_self_init() { + # run interactive extras + if rwx_shell_interactive; then + # check format + rwx_log + rwx_shfmt "${RWX_ROOT_SYSTEM}" + # check syntax + rwx_log + rwx_shellcheck "${RWX_ROOT_SYSTEM}" + # help + rwx_log + rwx_self_help + fi +} + +# ╭──────┬─────────╮ +# │ self │ install │ +# ╰──────┴─────────╯ + _rwx_cmd_rwx_install() { rwx_self_install "${@}"; } rwx_self_install() { local target="${1}" @@ -46,6 +81,10 @@ rwx_self_install() { rwx_link "${file}" "${RWX_MAIN_PATH}" } +# ╭──────┬────────╮ +# │ self │ subset │ +# ╰──────┴────────╯ + rwx_self_subset() { local argument path for argument in "${@}"; do @@ -61,6 +100,10 @@ rwx_self_subset() { done } +# ╭──────┬───────╮ +# │ self │ write │ +# ╰──────┴───────╯ + rwx_self_write() { local target="${1}" if [ -n "${target}" ]; then From 020aaa0b9a6f19f88bf45dd4b59adb3d30057c68 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Feb 2025 21:54:51 +0100 Subject: [PATCH 969/969] refactor(history): commit development branch new development branch from root commit --- .forgejo/workflows/main.yaml | 18 + .gitignore | 5 + .shellcheckrc | 4 + build.py | 11 + license.md | 660 +++++++++++++++++++++++++++++++++++ pyproject.toml | 32 ++ readme.md | 74 ++++ rwx/__init__.py | 33 ++ rwx/__main__.py | 19 + rwx/arg/__init__.py | 13 + rwx/cmd/__init__.py | 22 ++ rwx/cmd/squashfs/__init__.py | 26 ++ rwx/deb/__init__.py | 31 ++ rwx/err/__init__.py | 7 + rwx/fs/__init__.py | 159 +++++++++ rwx/grub/__init__.py | 54 +++ rwx/log/__init__.py | 51 +++ rwx/os/__init__.py | 20 ++ rwx/os/abstract.py | 26 ++ rwx/os/debian.py | 14 + rwx/os/pm/__init__.py | 29 ++ rwx/os/pm/apt.py | 22 ++ rwx/prj/__init__.py | 20 ++ rwx/prj/sphinx.py | 39 +++ rwx/ps/__init__.py | 85 +++++ rwx/py.typed | 0 rwx/sw/freetube/__init__.py | 1 + rwx/sw/freetube/authors.py | 31 ++ rwx/sw/freetube/channels.py | 29 ++ rwx/sw/freetube/db.py | 21 ++ rwx/sw/freetube/languages.py | 24 ++ rwx/sw/freetube/playlists.py | 47 +++ rwx/sw/freetube/profiles.py | 45 +++ rwx/sw/freetube/settings.py | 33 ++ rwx/sw/freetube/videos.py | 33 ++ rwx/txt/__init__.py | 3 + sh/alias/apt.sh | 95 +++++ sh/alias/batcat.sh | 5 + sh/alias/btrfs.sh | 73 ++++ sh/alias/byobu.sh | 27 ++ sh/alias/chmod.sh | 15 + sh/alias/chown.sh | 15 + sh/alias/clear.sh | 6 + sh/alias/cp.sh | 7 + sh/alias/emacs.sh | 5 + sh/alias/evince.sh | 5 + sh/alias/git.sh | 548 +++++++++++++++++++++++++++++ sh/alias/gpg.sh | 12 + sh/alias/grep.sh | 9 + sh/alias/kill.sh | 14 + sh/alias/killall.sh | 14 + sh/alias/ls.sh | 32 ++ sh/alias/lsblk.sh | 31 ++ sh/alias/mkdir.sh | 14 + sh/alias/mount.sh | 5 + sh/alias/mv.sh | 7 + sh/alias/nano.sh | 5 + sh/alias/newsboat.sh | 5 + sh/alias/overlay.sh | 140 ++++++++ sh/alias/pass.sh | 14 + sh/alias/pgrep.sh | 7 + sh/alias/pwgen.sh | 17 + sh/alias/rm.sh | 7 + sh/alias/rsync.sh | 27 ++ sh/alias/shell.sh | 29 ++ sh/alias/tar.sh | 31 ++ sh/alias/tmux.sh | 5 + sh/alias/tree.sh | 12 + sh/cryptsetup.sh | 6 + sh/debian.sh | 76 ++++ sh/ffmpeg.sh | 194 ++++++++++ sh/fs.sh | 121 +++++++ sh/gnome.sh | 71 ++++ sh/gpg.sh | 19 + sh/lint/gitlint.sh | 6 + sh/lint/lint.sh | 78 +++++ sh/lint/mypy.sh | 4 + sh/lint/pydoclint.sh | 9 + sh/lint/pylint.sh | 6 + sh/lint/ruff.sh | 28 ++ sh/lint/shellcheck.sh | 34 ++ sh/lint/shfmt.sh | 4 + sh/live.sh | 6 + sh/log/log.sh | 68 ++++ sh/log/step.sh | 25 ++ sh/main.sh | 144 ++++++++ sh/python.sh | 14 + sh/rescue/common.sh | 94 +++++ sh/rescue/hetzner.sh | 129 +++++++ sh/rescue/ovh.sh | 71 ++++ sh/self.sh | 162 +++++++++ sh/shell.sh | 116 ++++++ sh/tmux.sh | 264 ++++++++++++++ sh/util.sh | 76 ++++ 94 files changed, 4804 insertions(+) create mode 100644 .forgejo/workflows/main.yaml create mode 100644 .gitignore create mode 100644 .shellcheckrc create mode 100755 build.py create mode 100644 license.md create mode 100644 pyproject.toml create mode 100644 readme.md create mode 100644 rwx/__init__.py create mode 100755 rwx/__main__.py create mode 100644 rwx/arg/__init__.py create mode 100644 rwx/cmd/__init__.py create mode 100644 rwx/cmd/squashfs/__init__.py create mode 100644 rwx/deb/__init__.py create mode 100644 rwx/err/__init__.py create mode 100644 rwx/fs/__init__.py create mode 100644 rwx/grub/__init__.py create mode 100644 rwx/log/__init__.py create mode 100644 rwx/os/__init__.py create mode 100644 rwx/os/abstract.py create mode 100644 rwx/os/debian.py create mode 100644 rwx/os/pm/__init__.py create mode 100644 rwx/os/pm/apt.py create mode 100644 rwx/prj/__init__.py create mode 100644 rwx/prj/sphinx.py create mode 100644 rwx/ps/__init__.py create mode 100644 rwx/py.typed create mode 100644 rwx/sw/freetube/__init__.py create mode 100644 rwx/sw/freetube/authors.py create mode 100644 rwx/sw/freetube/channels.py create mode 100644 rwx/sw/freetube/db.py create mode 100644 rwx/sw/freetube/languages.py create mode 100644 rwx/sw/freetube/playlists.py create mode 100644 rwx/sw/freetube/profiles.py create mode 100644 rwx/sw/freetube/settings.py create mode 100644 rwx/sw/freetube/videos.py create mode 100644 rwx/txt/__init__.py create mode 100644 sh/alias/apt.sh create mode 100644 sh/alias/batcat.sh create mode 100644 sh/alias/btrfs.sh create mode 100644 sh/alias/byobu.sh create mode 100644 sh/alias/chmod.sh create mode 100644 sh/alias/chown.sh create mode 100644 sh/alias/clear.sh create mode 100644 sh/alias/cp.sh create mode 100644 sh/alias/emacs.sh create mode 100644 sh/alias/evince.sh create mode 100644 sh/alias/git.sh create mode 100644 sh/alias/gpg.sh create mode 100644 sh/alias/grep.sh create mode 100644 sh/alias/kill.sh create mode 100644 sh/alias/killall.sh create mode 100644 sh/alias/ls.sh create mode 100644 sh/alias/lsblk.sh create mode 100644 sh/alias/mkdir.sh create mode 100644 sh/alias/mount.sh create mode 100644 sh/alias/mv.sh create mode 100644 sh/alias/nano.sh create mode 100644 sh/alias/newsboat.sh create mode 100644 sh/alias/overlay.sh create mode 100644 sh/alias/pass.sh create mode 100644 sh/alias/pgrep.sh create mode 100644 sh/alias/pwgen.sh create mode 100644 sh/alias/rm.sh create mode 100644 sh/alias/rsync.sh create mode 100644 sh/alias/shell.sh create mode 100644 sh/alias/tar.sh create mode 100644 sh/alias/tmux.sh create mode 100644 sh/alias/tree.sh create mode 100644 sh/cryptsetup.sh create mode 100644 sh/debian.sh create mode 100644 sh/ffmpeg.sh create mode 100644 sh/fs.sh create mode 100644 sh/gnome.sh create mode 100644 sh/gpg.sh create mode 100644 sh/lint/gitlint.sh create mode 100644 sh/lint/lint.sh create mode 100644 sh/lint/mypy.sh create mode 100644 sh/lint/pydoclint.sh create mode 100644 sh/lint/pylint.sh create mode 100644 sh/lint/ruff.sh create mode 100644 sh/lint/shellcheck.sh create mode 100644 sh/lint/shfmt.sh create mode 100644 sh/live.sh create mode 100644 sh/log/log.sh create mode 100644 sh/log/step.sh create mode 100755 sh/main.sh create mode 100644 sh/python.sh create mode 100644 sh/rescue/common.sh create mode 100644 sh/rescue/hetzner.sh create mode 100644 sh/rescue/ovh.sh create mode 100644 sh/self.sh create mode 100644 sh/shell.sh create mode 100644 sh/tmux.sh create mode 100644 sh/util.sh diff --git a/.forgejo/workflows/main.yaml b/.forgejo/workflows/main.yaml new file mode 100644 index 0000000..bcc505a --- /dev/null +++ b/.forgejo/workflows/main.yaml @@ -0,0 +1,18 @@ +on: [push] +jobs: + job: + container: + image: ${{vars.DOCKER}}debian:bookworm + steps: + - name: spcd + env: + SPCD: ${{vars.SPCD}} + SPCD_SSH_HOSTS: ${{vars.SPCD_SSH_HOSTS}} + SPCD_SSH_KEY: ${{secrets.SPCD_SSH_KEY}} + SPCD_TXT_LOCALE: ${{vars.SPCD_TXT_LOCALE}} + run: ${{vars.SPCD}} + + #- run: spcd-check-project + - run: spcd-build-project + - run: spcd-browse-workspace + - run: spcd-synchronize diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4909e08 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +__pycache__ +/tmp +/.venv +/.vscode +/dist diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 0000000..8e71c00 --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1,4 @@ +disable=3043 +enable=all +external-sources=true +shell=sh diff --git a/build.py b/build.py new file mode 100755 index 0000000..3a0a957 --- /dev/null +++ b/build.py @@ -0,0 +1,11 @@ +#! /usr/bin/env python3 +"""Dummy build.""" + +from pathlib import Path + +from rwx.fs import make_directory, write + +if __name__ == "__main__": + out = Path(__file__).parent / "out" / "web" + make_directory(out) + write(out / "index.html", "rwx.rwx.work") diff --git a/license.md b/license.md new file mode 100644 index 0000000..c6f01c6 --- /dev/null +++ b/license.md @@ -0,0 +1,660 @@ +# GNU AFFERO GENERAL PUBLIC LICENSE + +Version 3, 19 November 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 Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + +The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are 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. + +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. + +Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + +A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + +The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + +An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing +under this license. + +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 Affero 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. Remote Network Interaction; Use with the GNU General Public License. + +Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your +version supports such interaction) an opportunity to receive the +Corresponding Source of your version by providing access to the +Corresponding Source from a network server at no charge, through some +standard or customary means of facilitating copying of software. This +Corresponding Source shall include the Corresponding Source for any +work covered by version 3 of the GNU General Public License that is +incorporated pursuant to the following paragraph. + +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 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 work with which it is combined will remain governed by version +3 of the GNU General Public License. + +### 14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions +of the GNU Affero 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 Affero 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 Affero 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 Affero 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 Affero 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper +mail. + +If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for +the specific requirements. + +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 AGPL, see . diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7a3d9c9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,32 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +authors = [ + { name = "Marc Beninca", email = "git@marc.beninca.link" }, +] +maintainers = [ + { name = "Marc Beninca", email = "git@marc.beninca.link" }, +] +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: GNU Affero General Public License v3", + "Operating System :: OS Independent", +] +dependencies = [] +description = "Read Write eXecute" +dynamic = ["version"] +keywords = [] +license-files = ["license.md"] +name = "rwx" +readme = "readme.md" +requires-python = ">= 3.11" + +[project.scripts] +# command = "package.module:function" + +[project.urls] + +[tool.hatch.version] +path = "rwx/__init__.py" diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..905c975 --- /dev/null +++ b/readme.md @@ -0,0 +1,74 @@ +# Read Write eXecute + +A tiny framework to read, write & execute things. + +--- + +## Why + +--- + +## How + +--- + +## What + +--- + +## Who + +### By + +* [Marc Beninca](https://marc.beninca.link) + +### For + +* myself + +--- + +## Where + +### Chat + +* [Discord](https://discord.com/channels/983145051985154108/1255894474895134761) +* [IRC](ircs://irc.libera.chat/##rwx) + +### Forge + +* [Repository](https://forge.rwx.work/rwx.work/rwx) +* [RSS](https://forge.rwx.work/rwx.work/rwx.rss) +* [Workflows](https://forge.rwx.work/rwx.work/rwx/actions) + +### Deployment + +* [Site](https://rwx.rwx.work) + +--- + +## When + +### Task stack + +#### Python + +* character constants for box drawing +* common __str__ function +* parse pyproject.toml to write commands +* write classes for + * steps bars to log + * system commands to run + * with single call of subprocess.run + * or alternate subprocess method? + +#### Shell + +* git switch signing commits & tags +* shellcheck & shfmt +* python tools +* log +* hetzner +* apt + * apt-file search | grep +* ffmpeg diff --git a/rwx/__init__.py b/rwx/__init__.py new file mode 100644 index 0000000..3dbfd68 --- /dev/null +++ b/rwx/__init__.py @@ -0,0 +1,33 @@ +"""Read Write eXecute.""" + +__version__ = "0.0.1" + +from os import linesep + + +class Object: + """Root object.""" + + def __repr__(self) -> str: + """Return machine-readable state. + + :return: state + :rtype: str + """ + name = self.__class__.__name__ + attributes = [ + f"{k}={v!r}" for k, v in vars(self).items() if not k.startswith("_") + ] + arguments = ", ".join(attributes) + return f"{name}({arguments})" + + def __str__(self) -> str: + """Return human-readable state. + + :return: state + :rtype: str + """ + attributes = [ + f"{k} = {v}" for k, v in vars(self).items() if not k.startswith("_") + ] + return linesep.join(attributes) diff --git a/rwx/__main__.py b/rwx/__main__.py new file mode 100755 index 0000000..e19dea1 --- /dev/null +++ b/rwx/__main__.py @@ -0,0 +1,19 @@ +#! /usr/bin/env python3 + +"""Entry point.""" + +from pathlib import Path + +from rwx import fs + +if __name__ == "__main__": + file_path: Path = Path(__file__).resolve() + root_path: Path = file_path.parent + directory_path: Path = root_path / "tmp" + file_path = directory_path / "file" + + fs.wipe(directory_path) + fs.make_directory(directory_path) + fs.write(file_path, "Martine écrit beaucoup.") + fs.empty_file(file_path) + fs.write(file_path, "Martine écrit moins.") diff --git a/rwx/arg/__init__.py b/rwx/arg/__init__.py new file mode 100644 index 0000000..a35dd4f --- /dev/null +++ b/rwx/arg/__init__.py @@ -0,0 +1,13 @@ +"""Handle system arguments.""" + +import sys + + +def split() -> tuple[str, list[str]]: + """Split command & actual arguments. + + :return: both + :rtype: tuple[str, list[str]] + """ + command, *arguments = sys.argv + return command, arguments diff --git a/rwx/cmd/__init__.py b/rwx/cmd/__init__.py new file mode 100644 index 0000000..be9e540 --- /dev/null +++ b/rwx/cmd/__init__.py @@ -0,0 +1,22 @@ +"""Handle system commands & packages.""" + +commands: list[str] = [] +packages: list[str] = [] + + +def need(command: str) -> None: + """Assert package dependency for a command. + + :param command: name of the requested command + :type command: str + """ + package: str | None + match command: + case "debootstrap": + package = "debootstrap" + case "mksquashfs" | "unsquashfs": + package = "squashfs-tools" + case _: + package = None + if package and package not in packages: + packages.append(package) diff --git a/rwx/cmd/squashfs/__init__.py b/rwx/cmd/squashfs/__init__.py new file mode 100644 index 0000000..b3ec864 --- /dev/null +++ b/rwx/cmd/squashfs/__init__.py @@ -0,0 +1,26 @@ +"""Wrap SquashFS commands.""" + +from pathlib import Path + +from rwx import cmd, ps + +cmd.need("mksquashfs") + + +def mksquashfs(input_root: Path, output_file: Path) -> None: + """Make a SquashFS bootable image file. + + :param input_root: ? + :type input_root: Path + :param output_file: ? + :type output_file: Path + """ + ps.run( + "mksquashfs", + str(input_root), + str(output_file), + "-comp", + "zstd", + "-Xcompression-level", + str(18), + ) diff --git a/rwx/deb/__init__.py b/rwx/deb/__init__.py new file mode 100644 index 0000000..2537321 --- /dev/null +++ b/rwx/deb/__init__.py @@ -0,0 +1,31 @@ +"""Wrap Debian commands.""" + +from pathlib import Path + +from rwx import cmd, ps + +cmd.need("debootstrap") + +BOOTSTRAP_ARCHITECTURE = "amd64" +BOOTSTRAP_VARIANT = "minbase" + + +def bootstrap(root_path: Path, suite: str, mirror_location: str) -> None: + """Boostrap a base operating filesystem. + + :param root_path: target output path + :type root_path: Path + :param suite: target distribution name + :type suite: str + :param mirror_location: source input repository + :type mirror_location: str + """ + command = ( + "debootstrap", + ("--arch", BOOTSTRAP_ARCHITECTURE), + ("--variant", BOOTSTRAP_VARIANT), + suite, + str(root_path), + mirror_location, + ) + ps.run(*command) diff --git a/rwx/err/__init__.py b/rwx/err/__init__.py new file mode 100644 index 0000000..6c473e0 --- /dev/null +++ b/rwx/err/__init__.py @@ -0,0 +1,7 @@ +"""Handle errors.""" + +from rwx import Object + + +class Error(Object, Exception): + """Parent class for all errors.""" diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py new file mode 100644 index 0000000..8a45288 --- /dev/null +++ b/rwx/fs/__init__.py @@ -0,0 +1,159 @@ +"""Operations involving FileSystems.""" + +import os +import shutil +from pathlib import Path + +import tomllib + +from rwx import ps + +CHARSET = "UTF-8" + + +def create_image(file_path: Path, size_bytes: int) -> None: + """Create a virtual device image file. + + :param file_path: target image file + :type file_path: Path + :param size_bytes: virtual volume + :type size_bytes: int + """ + ps.run( + ("qemu-img", "create"), + ("-f", "qcow2"), + (str(file_path), str(size_bytes)), + ) + + +def empty_file(path: Path) -> None: + """Empty the file at provided path. + + :param path: target file to empty + :type path: Path + """ + write(path, "") + + +def get_mount_uuid(path: Path) -> str: + """Return the filesystem UUID of a mountpoint path. + + :param path: mountpoint path + :type path: Path + :rtype: str + """ + return ps.run_line( + "findmnt", + "--noheadings", + ("--output", "UUID"), + str(path), + ) + + +def get_path_mount(path: Path) -> Path: + """Return the mountpoint path of an arbitrary path. + + :param path: arbitrary path + :type path: Path + :rtype: Path + """ + return Path( + ps.run_line( + "stat", + ("--format", "%m"), + str(path), + ), + ) + + +def get_path_uuid(path: Path) -> str: + """Return the filesystem UUID of an arbitrary path. + + :param path: arbitrary path + :type path: Path + :rtype: str + """ + return get_mount_uuid(get_path_mount(path)) + + +def make_directory(path: Path) -> None: + """Make a directory (and its parents) from a path. + + :param path: directory to create + :type path: Path + """ + path.mkdir(exist_ok=True, parents=True) + + +def read_file_bytes(file_path: Path) -> bytes: + """Read whole file bytes. + + :param file_path: source input file + :type file_path: Path + :rtype: bytes + """ + with file_path.open("br") as file_object: + return file_object.read() + + +def read_file_dict(file_path: Path, charset: str = CHARSET) -> dict: + """Read whole file as toml object. + + :param file_path: source input file + :type file_path: Path + :param charset: charset to use for decoding input + :type charset: str + :rtype: dict + """ + text = read_file_text(file_path, charset) + return tomllib.loads(text) + + +def read_file_lines(file_path: Path, charset: str = CHARSET) -> list[str]: + """Read whole file lines. + + :param file_path: source input file + :type file_path: Path + :param charset: charset to use for decoding input + :type charset: str + :rtype: list[str] + """ + return read_file_text(file_path, charset).split(os.linesep) + + +def read_file_text(file_path: Path, charset: str = CHARSET) -> str: + """Read whole file text. + + :param file_path: source input file + :type file_path: Path + :param charset: charset to use for decoding input + :type charset: str + :rtype: str + """ + return read_file_bytes(file_path).decode(charset) + + +def wipe(path: Path) -> None: + """Wipe provided path, whether directory or file. + + :param path: target path + :type path: Path + """ + try: + path.unlink(missing_ok=True) + except IsADirectoryError: + shutil.rmtree(path) + + +def write(file_path: Path, text: str, charset: str = CHARSET) -> None: + """Write text into a file. + + :param file_path: target file path + :type file_path: Path + :param text: content to write + :type text: str + :param charset: charset to use for encoding ouput + :type charset: str + """ + with file_path.open(encoding=charset, mode="w") as file_object: + file_object.write(text) diff --git a/rwx/grub/__init__.py b/rwx/grub/__init__.py new file mode 100644 index 0000000..aa208c3 --- /dev/null +++ b/rwx/grub/__init__.py @@ -0,0 +1,54 @@ +"""Wrap GRUB commands.""" + +from __future__ import annotations + +from rwx import cmd, ps + +cmd.need("grub-mkimage") + +COMPRESSION = "xz" +ENV_BYTES = 1024 +ENV_COMMENT = "#" +ENV_HEADER = f"""{ENV_COMMENT} GRUB Environment Block +""" +MODULES = { + "i386-pc": [ + ("biosdisk",), + ("ntldr",), + ], +} + + +def make_image( + image_format: str, + image_path: str, + modules: list[str], + memdisk_path: str, + pubkey_path: str | None = None, +) -> None: + """Make a binary bootable image. + + :param image_format: output format (x86_64-efi, i386-pc, arm64-efi) + :type image_format: str + :param image_path: output file + :type image_path: str + :param modules: modules to embed + :type modules: list[str] + :param memdisk_path: archive to include + :type memdisk_path: str + :param pubkey_path: extra public key to add + :type pubkey_path: str | None + """ + args: list[str | tuple[str, ...]] = [ + "grub-mkimage", + ("--compress", COMPRESSION), + ("--format", image_format), + ("--output", image_path), + ("--memdisk", memdisk_path), + ] + if pubkey_path: + args.append(("--pubkey", pubkey_path)) + args.extend(modules) + if extra_modules := MODULES.get(image_format): + args.extend(extra_modules) + ps.run(*args) diff --git a/rwx/log/__init__.py b/rwx/log/__init__.py new file mode 100644 index 0000000..53cfebc --- /dev/null +++ b/rwx/log/__init__.py @@ -0,0 +1,51 @@ +"""Handle logging.""" + +import logging +import sys + + +def get_file_logger(name: str) -> logging.Logger: + """Return a file logger. + + :param name: arbitrary name + :type name: str + :rtype: logging.Logger + """ + # formatter + items = [ + "%(name)s: %(asctime)s", + "%(levelname)s", + "%(filename)s:%(lineno)s", + "%(process)d >>> %(message)s", + ] + template = " | ".join(items) + formatter = logging.Formatter(template) + # handler + out_handler = logging.StreamHandler(stream=sys.stdout) + out_handler.setFormatter(formatter) + out_handler.setLevel(logging.INFO) + # logger + logger = logging.getLogger(name) + logger.addHandler(out_handler) + logger.setLevel(logging.INFO) + return logger + + +def get_stream_logger(level: int) -> logging.Logger: + """Return a stream logger. + + :param level: filtering level + :type level: int + :rtype: logging.Logger + """ + # handler + out_handler = logging.StreamHandler(stream=sys.stdout) + out_handler.setLevel(level) + # logger + logger = logging.getLogger() + logger.addHandler(out_handler) + logger.setLevel(level) + return logger + + +stream = get_stream_logger(logging.INFO) diff --git a/rwx/os/__init__.py b/rwx/os/__init__.py new file mode 100644 index 0000000..27c1748 --- /dev/null +++ b/rwx/os/__init__.py @@ -0,0 +1,20 @@ +"""Control Operating Systems.""" + +from os import sep +from pathlib import Path + +from .abstract import OS +from .debian import Debian + + +def from_path(path: Path) -> OS: + """Initialize from an already existing path. + + :param path: source root directory + :type path: Path + :rtype: OS + """ + return Debian(path) + + +up = from_path(Path(sep)) diff --git a/rwx/os/abstract.py b/rwx/os/abstract.py new file mode 100644 index 0000000..98f3f0d --- /dev/null +++ b/rwx/os/abstract.py @@ -0,0 +1,26 @@ +"""Abstract Operating System.""" + +from abc import ABC, abstractmethod +from pathlib import Path + +from rwx import Object + + +class OS(Object, ABC): + """Operating System.""" + + def __init__(self, path: Path) -> None: + """Set root. + + :param path: root directory + :type path: Path + """ + self.root = path + self.name = self.get_name() + + @abstractmethod + def get_name(self) -> str: + """Return mandatory name. + + :rtype: str + """ diff --git a/rwx/os/debian.py b/rwx/os/debian.py new file mode 100644 index 0000000..5cefdaa --- /dev/null +++ b/rwx/os/debian.py @@ -0,0 +1,14 @@ +"""Debian operating system.""" + +from .abstract import OS + + +class Debian(OS): + """Debian operating system.""" + + def get_name(self) -> str: + """Return name. + + :rtype: str + """ + return "Debian" diff --git a/rwx/os/pm/__init__.py b/rwx/os/pm/__init__.py new file mode 100644 index 0000000..785ce74 --- /dev/null +++ b/rwx/os/pm/__init__.py @@ -0,0 +1,29 @@ +"""Package Manager.""" + +from abc import ABC, abstractmethod + +from rwx import Object +from rwx.ps import Command + + +class PM(Object, ABC): + """Package Manager.""" + + def __init__(self) -> None: + """Set commands.""" + self.clean = self.get_clean_command() + self.install = self.get_install_command() + + @abstractmethod + def get_clean_command(self) -> Command: + """Command to clean packages cache. + + :rtype: Command + """ + + @abstractmethod + def get_install_command(self) -> Command: + """Command to install package(s). + + :rtype: Command + """ diff --git a/rwx/os/pm/apt.py b/rwx/os/pm/apt.py new file mode 100644 index 0000000..3e3cb81 --- /dev/null +++ b/rwx/os/pm/apt.py @@ -0,0 +1,22 @@ +"""Advanced Package Tool.""" + +from rwx.os.pm import PM +from rwx.ps import Command + + +class APT(PM): + """Advanced Package Tool.""" + + def get_clean_command(self) -> Command: + """Return clean command. + + :rtype: Command + """ + return Command() + + def get_install_command(self) -> Command: + """Return install command. + + :rtype: Command + """ + return Command() diff --git a/rwx/prj/__init__.py b/rwx/prj/__init__.py new file mode 100644 index 0000000..62d91d9 --- /dev/null +++ b/rwx/prj/__init__.py @@ -0,0 +1,20 @@ +"""Handle projects.""" + +from pathlib import Path + +from rwx import Object + + +class Project(Object): + """Parent class for any type of project.""" + + def __init__(self, file: Path) -> None: + """Set file, root & name. + + :param file: root reference file + :type file: Path + """ + self.raw = file + self.file = self.raw.resolve() + self.root: Path = self.file.parent + self.name: str = self.root.name diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py new file mode 100644 index 0000000..592e6dd --- /dev/null +++ b/rwx/prj/sphinx.py @@ -0,0 +1,39 @@ +"""Project consisting only of a Sphinx documentation.""" + +from typing import TYPE_CHECKING + +from sphinx.cmd.build import build_main + +from rwx.fs import wipe +from rwx.prj import Project + +if TYPE_CHECKING: + from pathlib import Path + + +class SphinxProject(Project): + """Child class for a project based on Sphinx.""" + + def build(self) -> None: + """Build the project.""" + output_root: Path = self.root / "out" + wipe(output_root) + arguments: list[str] = [ + "-E", + "-j", + "2", + "-b", + "html", + "-D", + f"project={self.name}", + "-D", + "master_doc=index", + "-D", + "html_theme=sphinx_rtd_theme", + "-c", + str(self.root), + # "-C", + str(self.root / self.name), + str(output_root / "web"), + ] + build_main(arguments) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py new file mode 100644 index 0000000..3bef50d --- /dev/null +++ b/rwx/ps/__init__.py @@ -0,0 +1,85 @@ +"""Handle processes.""" + +from __future__ import annotations + +import subprocess + +from rwx import Object, txt + + +class Command(Object): + """Command to run.""" + + def __init__(self, *arguments: str | tuple[str, ...]) -> None: + """Set raw & flat arguments. + + :param *arguments: single argument or grouped ones + :type *arguments: str | tuple[str, ...] + """ + self.raw = arguments + self.flat: list[str] = [] + + +def get_tuples_args(*items: str | tuple[str, ...]) -> list[str]: + """Turn arguments tuples into an arguments list. + + :param *items: single item or grouped ones + :type *items: str | tuple[str, ...] + :rtype: list[str] + """ + args: list[str] = [] + for item in items: + match item: + case str(): + args.append(item) + case tuple(): + args.extend(item) + return args + + +def run(*items: str | tuple[str, ...]) -> subprocess.CompletedProcess: + """Run from a list of arguments tuples. + + :param *items: single item or grouped ones + :type *items: str | tuple[str, ...] + :rtype: subprocess.CompletedProcess + """ + return subprocess.run( + get_tuples_args(*items), + capture_output=False, + check=True, + ) + + +def run_line(*items: str | tuple[str, ...], charset: str = txt.CHARSET) -> str: + """Run and return output line. + + :param *items: single item or grouped ones + :type *items: str | tuple[str, ...] + :param charset: charset to use for decoding binary output + :type charset: str + :rtype: str + """ + line, *_ = run_lines(*items, charset=charset) + return line + + +def run_lines( + *items: str | tuple[str, ...], + charset: str = txt.CHARSET, +) -> list[str]: + """Run and return output lines. + + :param *items: single item or grouped ones + :type *items: str | tuple[str, ...] + :param charset: charset to use for decoding binary output + :type charset: str + :rtype: list[str] + """ + process = subprocess.run( + get_tuples_args(*items), + capture_output=True, + check=True, + ) + string = process.stdout.decode(charset) + return string.rstrip().splitlines() diff --git a/rwx/py.typed b/rwx/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/rwx/sw/freetube/__init__.py b/rwx/sw/freetube/__init__.py new file mode 100644 index 0000000..250b9c3 --- /dev/null +++ b/rwx/sw/freetube/__init__.py @@ -0,0 +1 @@ +"""Configure FreeTube.""" diff --git a/rwx/sw/freetube/authors.py b/rwx/sw/freetube/authors.py new file mode 100644 index 0000000..e7cb913 --- /dev/null +++ b/rwx/sw/freetube/authors.py @@ -0,0 +1,31 @@ +"""FreeTube authors.""" + +from typing import TYPE_CHECKING + +from rwx import Object + +if TYPE_CHECKING: + from .playlists import Playlist + + +class Author(Object): + """FreeTube author.""" + + def __init__(self, uid: str, name: str) -> None: + """Set uid & name. + + :param uid: identifier + :type uid: str + :param name: label + :type name: str + """ + self.uid = uid + self.name = name + self.playlist: Playlist + + def to_db(self) -> str: + """Return non-breakable name. + + :rtype: str + """ + return self.name.replace(" ", chr(0xA0)) diff --git a/rwx/sw/freetube/channels.py b/rwx/sw/freetube/channels.py new file mode 100644 index 0000000..556dea7 --- /dev/null +++ b/rwx/sw/freetube/channels.py @@ -0,0 +1,29 @@ +"""FreeTube channels.""" + +from rwx import Object + + +class Channel(Object): + """FreeTube channel.""" + + def __init__(self, uid: str, name: str) -> None: + """Set uid & name. + + :param uid: unique identifier + :type uid: str + :param name: label + :type name: str + """ + self.uid = uid + self.name = name + + def to_db(self) -> str: + """Return identifier as db. + + :rtype: str + """ + return f"""\ +{{\ +"id":"{self.uid}"\ +}}\ +""" diff --git a/rwx/sw/freetube/db.py b/rwx/sw/freetube/db.py new file mode 100644 index 0000000..e3eb31e --- /dev/null +++ b/rwx/sw/freetube/db.py @@ -0,0 +1,21 @@ +"""Output FreeTube db.""" + + +def to_db(value: object) -> str: + """Render value as string. + + :param value: value to render + :type value: object + :rtype: str + """ + match value: + case bool(): + text = str(value).lower() + case dict(): + sub = ",".join([f'"{i}":{to_db(v)}' for i, v in value.items()]) + text = f"{{{sub}}}" + case float() | str(): + text = f'"{value}"' + case _: + text = str(value) + return text diff --git a/rwx/sw/freetube/languages.py b/rwx/sw/freetube/languages.py new file mode 100644 index 0000000..beeb173 --- /dev/null +++ b/rwx/sw/freetube/languages.py @@ -0,0 +1,24 @@ +"""FreeTube languages.""" + +from typing import TYPE_CHECKING + +from rwx import Object + +if TYPE_CHECKING: + from .playlists import Playlist + + +class Language(Object): + """FreeTube language.""" + + def __init__(self, uid: str, name: str) -> None: + """Set uid & name. + + :param uid: identifier + :type uid: str + :param name: label + :type name: str + """ + self.uid = uid + self.name = name + self.playlist: Playlist diff --git a/rwx/sw/freetube/playlists.py b/rwx/sw/freetube/playlists.py new file mode 100644 index 0000000..f4b17de --- /dev/null +++ b/rwx/sw/freetube/playlists.py @@ -0,0 +1,47 @@ +"""FreeTube playlists.""" + +from rwx import Object + +from .videos import Video + + +class Playlist(Object): + """FreeTube playlist.""" + + def __init__(self, uid: str, name: str) -> None: + """Set uid & name. + + :param uid: identifier + :type uid: str + :param name: label + :type name: str + """ + self.uid = uid + self.name = name + self.videos: list[Video] = [] + + def add(self, video: Video) -> None: + """Add video. + + :param video: video to add + :type video: Video + """ + self.videos.append(video) + + def to_db(self) -> str: + """Return identifier, name & videos. + + :rtype: str + """ + videos = ",".join([video.to_db() for video in self.videos]) + return f"""\ +{{\ +"_id":"{self.uid}"\ +,\ +"playlistName":"{self.name}"\ +,\ +"protected":true\ +,\ +"videos":[{videos}]\ +}}\ +""" diff --git a/rwx/sw/freetube/profiles.py b/rwx/sw/freetube/profiles.py new file mode 100644 index 0000000..e164296 --- /dev/null +++ b/rwx/sw/freetube/profiles.py @@ -0,0 +1,45 @@ +"""FreeTube profiles.""" + +from rwx import Object + +from .channels import Channel + + +class Profile(Object): + """FreeTube profile.""" + + def __init__(self, uid: str, name: str) -> None: + """Set uid & name. + + :param uid: unique identifier + :type uid: str + :param name: label + :type name: str + """ + self.id = uid + self.name = name + self.channels: list[Channel] = [] + + def add(self, channel: Channel) -> None: + """Add channel. + + :param channel: channel to add + :type channel: Channel + """ + self.channels.append(channel) + + def to_db(self) -> str: + """Return identifier, name & channels. + + :rtype: str + """ + channels = ",".join([channel.to_db() for channel in self.channels]) + return f"""\ +{{\ +"_id":"{self.id}"\ +,\ +"name":"{self.name}"\ +,\ +"subscriptions":[{channels}]\ +}}\ +""" diff --git a/rwx/sw/freetube/settings.py b/rwx/sw/freetube/settings.py new file mode 100644 index 0000000..621454b --- /dev/null +++ b/rwx/sw/freetube/settings.py @@ -0,0 +1,33 @@ +"""FreeTube settings.""" + +from rwx import Object + +from .db import to_db + + +class Setting(Object): + """FreeTube setting.""" + + def __init__(self, uid: str, value: object) -> None: + """Set uid & value. + + :param uid: unique identifier + :type uid: str + :param value: value + :type value: object + """ + self.uid = uid + self.value = value + + def to_db(self) -> str: + """Return uid & value as db string. + + :rtype: str + """ + return f"""\ +{{\ +"_id":"{self.uid}"\ +,\ +"value":{to_db(self.value)}\ +}}\ +""" diff --git a/rwx/sw/freetube/videos.py b/rwx/sw/freetube/videos.py new file mode 100644 index 0000000..6003c75 --- /dev/null +++ b/rwx/sw/freetube/videos.py @@ -0,0 +1,33 @@ +"""FreeTube videos.""" + +from rwx import Object + + +class Video(Object): + """FreeTube video.""" + + def __init__(self, uid: str, name: str) -> None: + """Set id & name. + + :param uid: identifier + :type uid: str + :param name: label + :type name: str + """ + self.uid = uid + self.name = name + + def to_db(self) -> str: + """Return identifier, zero length & title. + + :rtype: str + """ + return f"""\ +{{\ +"videoId":"{self.uid}"\ +,\ +"lengthSeconds":0\ +,\ +"title":"{self.name}"\ +}}\ +""" diff --git a/rwx/txt/__init__.py b/rwx/txt/__init__.py new file mode 100644 index 0000000..be2f273 --- /dev/null +++ b/rwx/txt/__init__.py @@ -0,0 +1,3 @@ +"""Handle text.""" + +CHARSET = "UTF-8" diff --git a/sh/alias/apt.sh b/sh/alias/apt.sh new file mode 100644 index 0000000..0f3294e --- /dev/null +++ b/sh/alias/apt.sh @@ -0,0 +1,95 @@ +# show package information +acl() { a__apt_cache_list "${@}"; } +a__apt_cache_list() { + apt-cache \ + show \ + "${@}" +} + +# package versions policy +acp() { a__apt_cache_policy "${@}"; } +a__apt_cache_policy() { + apt-cache \ + policy \ + "${@}" +} + +# search package +acs() { a__apt_cache_search "${@}"; } +a__apt_cache_search() { + apt-cache \ + search \ + "${@}" +} + +# +agap() { a__apt_get_auto_purge "${@}"; } +a__apt_get_auto_purge() { + apt-get \ + autopurge \ + "${@}" +} + +# +agar() { a__apt_get_auto_remove "${@}"; } +a__apt_get_auto_remove() { + apt-get \ + autoremove \ + "${@}" +} + +# clean packages cache +agc() { a__apt_get_clean "${@}"; } +a__apt_get_clean() { + apt-get \ + clean \ + "${@}" +} + +# upgrade allowing package installation or removal +agfu() { a__apt_get_full_upgrade "${@}"; } +a__apt_get_full_upgrade() { + apt-get \ + full-upgrade \ + "${@}" +} + +# install packages +agi() { a__apt_get_install "${@}"; } +a__apt_get_install() { + apt-get \ + install \ + "${@}" +} + +# +agp() { a__apt_get_purge "${@}"; } +a__apt_get_purge() { + apt-get \ + purge \ + "${@}" +} + +# +agr() { a__apt_get_remove "${@}"; } +a__apt_get_remove() { + apt-get \ + remove \ + "${@}" +} + +# update packages catalog +agud() { a__apt_get_up_date "${@}"; } +a__apt_get_up_date() { + apt-get \ + update \ + "${@}" +} + +# upgrade forbidding package installation or removal +agug() { a__apt_get_up_grade "${@}"; } +a__apt_get_up_grade() { + apt-get \ + upgrade \ + "${@}" +} diff --git a/sh/alias/batcat.sh b/sh/alias/batcat.sh new file mode 100644 index 0000000..99d8373 --- /dev/null +++ b/sh/alias/batcat.sh @@ -0,0 +1,5 @@ +b() { a__bat "${@}"; } +a__bat() { + batcat \ + "${@}" +} diff --git a/sh/alias/btrfs.sh b/sh/alias/btrfs.sh new file mode 100644 index 0000000..0e4ba62 --- /dev/null +++ b/sh/alias/btrfs.sh @@ -0,0 +1,73 @@ +bfdf() { a__btrfs_filesystem_d_f "${@}"; } +a__btrfs_filesystem_d_f() { + btrfs \ + filesystem \ + df \ + "${@}" +} + +bfdu() { a__btrfs_filesystem_d_u "${@}"; } +a__btrfs_filesystem_d_u() { + btrfs \ + filesystem \ + du \ + --summarize \ + "${@}" +} + +bfu() { a__btrfs_filesystem_usage "${@}"; } +a__btrfs_filesystem_usage() { + btrfs \ + filesystem \ + usage \ + "${@}" +} + +bpg() { a__btrfs_property_get "${@}"; } +a__btrfs_property_get() { + btrfs \ + property \ + get \ + "${@}" +} + +bsc() { a__btrfs_subvolume_create "${@}"; } +a__btrfs_subvolume_create() { + btrfs \ + subvolume \ + create \ + "${@}" +} + +bsd() { a__btrfs_subvolume_delete "${@}"; } +a__btrfs_subvolume_delete() { + btrfs \ + subvolume \ + delete \ + "${@}" +} + +bsl() { a__btrfs_subvolume_list "${@}"; } +a__btrfs_subvolume_list() { + if [ -n "${1}" ]; then + btrfs subvolume list "${1}" | + cut --delimiter " " --fields 9 | + sort + fi +} + +bss() { a__btrfs_subvolume_snapshot "${@}"; } +a__btrfs_subvolume_snapshot() { + btrfs \ + subvolume \ + snapshot \ + "${@}" +} + +bssr() { a__btrfs_subvolume_snapshot_r "${@}"; } +a__btrfs_subvolume_snapshot_r() { + btrfs \ + subvolume \ + snapshot -r \ + "${@}" +} diff --git a/sh/alias/byobu.sh b/sh/alias/byobu.sh new file mode 100644 index 0000000..0f5336e --- /dev/null +++ b/sh/alias/byobu.sh @@ -0,0 +1,27 @@ +bb() { a__byo_bu "${@}"; } +a__byo_bu() { + byobu \ + "${@}" +} + +bba() { a__byo_bu_attach "${@}"; } +a__byo_bu_attach() { + byobu \ + attach-session \ + "${@}" +} + +bbl() { a__byo_bu_ls "${@}"; } +a__byo_bu_ls() { + byobu \ + ls \ + "${@}" +} + +bbnd() { a__byo_bu_new_detach "${@}"; } +a__byo_bu_new_detach() { + byobu \ + new-session \ + -d \ + "${@}" +} diff --git a/sh/alias/chmod.sh b/sh/alias/chmod.sh new file mode 100644 index 0000000..57ec74e --- /dev/null +++ b/sh/alias/chmod.sh @@ -0,0 +1,15 @@ +# change mode to directory +cmd() { a__change_mode_directory "${@}"; } +a__change_mode_directory() { + chmod \ + "755" \ + "${@}" +} + +# change mode to file +cmf() { a__change_mode_file "${@}"; } +a__change_mode_file() { + chmod \ + "644" \ + "${@}" +} diff --git a/sh/alias/chown.sh b/sh/alias/chown.sh new file mode 100644 index 0000000..f4fa865 --- /dev/null +++ b/sh/alias/chown.sh @@ -0,0 +1,15 @@ +# change owner to root +cor() { a__change_owner_root "${@}"; } +a__change_owner_root() { + chown \ + "0:0" \ + "${@}" +} + +# change owner to user +cou() { a__change_owner_user "${@}"; } +a__change_owner_user() { + chown \ + "1000:1000" \ + "${@}" +} diff --git a/sh/alias/clear.sh b/sh/alias/clear.sh new file mode 100644 index 0000000..ae32b30 --- /dev/null +++ b/sh/alias/clear.sh @@ -0,0 +1,6 @@ +# clear terminal +c() { a__clear "${@}"; } +a__clear() { + clear \ + "${@}" +} diff --git a/sh/alias/cp.sh b/sh/alias/cp.sh new file mode 100644 index 0000000..c9e7d6b --- /dev/null +++ b/sh/alias/cp.sh @@ -0,0 +1,7 @@ +# copy interactively +cpi() { a__co_py_interactive "${@}"; } +a__co_py_interactive() { + cp \ + --interactive \ + "${@}" +} diff --git a/sh/alias/emacs.sh b/sh/alias/emacs.sh new file mode 100644 index 0000000..8e26878 --- /dev/null +++ b/sh/alias/emacs.sh @@ -0,0 +1,5 @@ +em() { a__e_macs "${@}"; } +a__e_macs() { + emacs \ + "${@}" +} diff --git a/sh/alias/evince.sh b/sh/alias/evince.sh new file mode 100644 index 0000000..25ac069 --- /dev/null +++ b/sh/alias/evince.sh @@ -0,0 +1,5 @@ +ev() { a__e_vince "${@}"; } +a__e_vince() { + evince \ + "${@}" +} diff --git a/sh/alias/git.sh b/sh/alias/git.sh new file mode 100644 index 0000000..cadd10b --- /dev/null +++ b/sh/alias/git.sh @@ -0,0 +1,548 @@ +RWX_GIT_LOG_FORMAT="\ +%C(auto)%h%d +S %C(red)%GS +A %C(green)%an %ae + %C(green)%ai +C %C(blue)%cn %ce + %C(blue)%ci +%B" + +# add to index +ga() { a__git_add "${@}"; } +a__git_add() { + git \ + add \ + "${@}" +} + +# add all to index +gaa() { a__git_add_all "${@}"; } +a__git_add_all() { + git \ + add \ + --all \ + "${@}" +} + +# add parts of all to index +gaap() { a__git_add_all_patch "${@}"; } +a__git_add_all_patch() { + git \ + add \ + --all \ + --patch \ + "${@}" +} + +# add parts to index +gap() { a__git_add_patch "${@}"; } +a__git_add_patch() { + git \ + add \ + --patch \ + "${@}" +} + +# create a branch +gb() { a__git_branch "${@}"; } +a__git_branch() { + git \ + branch \ + "${@}" +} + +# delete a branch +gbd() { a__git_branch_delete "${@}"; } +a__git_branch_delete() { + git \ + branch \ + --delete \ + "${@}" +} + +# force a branch deletion +gbdf() { a__git_branch_delete_force "${@}"; } +a__git_branch_delete_force() { + git \ + branch \ + --delete \ + --force \ + "${@}" +} + +# list branches +gbl() { a__git_branch_list "${@}"; } +a__git_branch_list() { + git \ + branch \ + --all \ + --list \ + --verbose \ + --verbose \ + "${@}" +} + +# set the link to a remote branch from a local branch +gbsu() { a__git_branch_set_upstream "${@}"; } +a__git_branch_set_upstream() { + git \ + branch \ + --set-upstream-to \ + "${@}" +} + +# switch to a branch or checkout file(s) from a commit +gc() { a__git_checkout "${@}"; } +a__git_checkout() { + git \ + checkout \ + "${@}" +} + +# checkout an orphan branch +gco() { a__git_checkout_orphan "${@}"; } +a__git_checkout_orphan() { + git \ + checkout \ + --orphan \ + "${@}" +} + +# pick a commit +gcp() { a__git_cherry_pick "${@}"; } +a__git_cherry_pick() { + git \ + cherry-pick \ + "${@}" +} + +# abort the commit pick +gcpa() { a__git_cherry_pick_abort "${@}"; } +a__git_cherry_pick_abort() { + git \ + cherry-pick \ + --abort \ + "${@}" +} + +# continue the commit pick +gcpc() { a__git_cherry_pick_continue "${@}"; } +a__git_cherry_pick_continue() { + git \ + cherry-pick \ + --continue \ + "${@}" +} + +# clean untracked files +gcf() { a__git_clean_force "${@}"; } +a__git_clean_force() { + git \ + clean \ + -d \ + --force \ + "${@}" +} + +# redo the last commit with a different message +gcam() { a__git_commit_amend_message "${@}"; } +a__git_commit_amend_message() { + git \ + commit \ + --amend \ + --message \ + "${@}" +} + +# make a root commit +gcem() { a__git_commit_empty_message "${@}"; } +a__git_commit_empty_message() { + git \ + commit \ + --allow-empty \ + --allow-empty-message \ + --message \ + "${@}" +} + +# commit the index +gcm() { a__git_commit_message "${@}"; } +a__git_commit_message() { + git \ + commit \ + --message \ + "${@}" +} + +# configure the user email +gcue() { a__git_config_user_email "${@}"; } +a__git_config_user_email() { + git \ + config \ + "user.email" \ + "${@}" +} + +# configure the user name +gcun() { a__git_config_user_name "${@}"; } +a__git_config_user_name() { + git \ + config \ + "user.name" \ + "${@}" +} + +# differences from last or between commits +gd() { a__git_diff "${@}"; } +a__git_diff() { + git \ + diff \ + "${@}" +} + +# display what is indexed in cache +gdc() { a__git_diff_cached "${@}"; } +a__git_diff_cached() { + git \ + diff \ + --cached \ + "${@}" +} + +# indexed character-level differences +gdcw() { a__git_diff_cached_word "${@}"; } +a__git_diff_cached_word() { + git \ + diff \ + --cached \ + --word-diff-regex "." \ + "${@}" +} + +# differences via external tool +gdt() { a__git_diff_tool "${@}"; } +a__git_diff_tool() { + git \ + difftool \ + --dir-diff \ + "${@}" +} + +# character-level differences +gdw() { a__git_diff_word "${@}"; } +a__git_diff_word() { + git \ + diff \ + --word-diff-regex "." \ + "${@}" +} + +# fetch from the remote repository +gf() { a__git_fetch "${@}"; } +a__git_fetch() { + rwx_gpg_agent_update && + git \ + fetch \ + --tags \ + --verbose \ + "${@}" +} + +# fetch from remote repository and prune local orphan branches +gfp() { a__git_fetch_prune "${@}"; } +a__git_fetch_prune() { + a__git_fetch \ + --prune \ + "${@}" +} + +# garbage collect all orphan commits +ggc() { a__git_garbage_collect "${@}"; } +a__git_garbage_collect() { + git \ + reflog \ + expire \ + --all \ + --expire "all" && + git \ + gc \ + --aggressive \ + --prune="now" +} + +# initialize a new repository +gi() { a__git_init "${@}"; } +a__git_init() { + git \ + init \ + "${@}" +} + +# initialize a new bare repository +gib() { a__git_init_bare "${@}"; } +a__git_init_bare() { + git \ + init \ + --bare \ + "${@}" +} + +# log history +gl() { a__git_log "${@}"; } +a__git_log() { + git \ + log \ + --abbrev=8 \ + --abbrev-commit \ + --format="${RWX_GIT_LOG_FORMAT}" \ + --graph \ + "${@}" +} + +# log all history +gla() { a__git_log_all "${@}"; } +a__git_log_all() { + a__git_log \ + --all \ + "${@}" +} + +# log all history with patches +glap() { a__git_log_all_patch "${@}"; } +a__git_log_all_patch() { + a__git_log \ + --all \ + --patch \ + "${@}" +} + +# log history with patches +glp() { a__git_log_patch "${@}"; } +a__git_log_patch() { + a__git_log \ + --patch \ + "${@}" +} + +# fast-forward merge to remote branch +gm() { a__git_merge "${@}"; } +a__git_merge() { + git \ + merge \ + --ff-only \ + "${@}" +} + +# abort the current merge commit +gma() { a__git_merge_abort "${@}"; } +a__git_merge_abort() { + git \ + merge \ + --abort \ + "${@}" +} + +# do a merge commit +gmc() { a__git_merge_commit "${@}"; } +a__git_merge_commit() { + git \ + merge \ + --no-ff \ + --message \ + "${@}" +} + +# squash a branch and index its modifications +gms() { a__git_merge_squash "${@}"; } +a__git_merge_squash() { + git \ + merge \ + --squash \ + "${@}" +} + +# merge via external tool +gmt() { a__git_merge_tool "${@}"; } +a__git_merge_tool() { + git \ + mergetool \ + "${@}" +} + +# push to the remote repository +gp() { a__git_push "${@}"; } +a__git_push() { + rwx_gpg_agent_update && + git \ + push \ + --tags \ + --verbose \ + "${@}" +} + +# delete from the remote repository +gpd() { a__git_push_delete "${@}"; } +a__git_push_delete() { + git \ + push \ + --delete \ + "${@}" +} + +# force the push to the remote repository +gpf() { a__git_push_force "${@}"; } +a__git_push_force() { + a__git_push \ + --force \ + "${@}" +} + +# rebase current branch onto another +grb() { a__git_re_base "${@}"; } +a__git_re_base() { + git \ + rebase \ + "${@}" +} + +# abort current rebase +grba() { a__git_re_base_abort "${@}"; } +a__git_re_base_abort() { + git \ + rebase \ + --abort \ + "${@}" +} + +# continue current rebase +grbc() { a__git_re_base_continue "${@}"; } +a__git_re_base_continue() { + git \ + rebase \ + --continue \ + "${@}" +} + +# force rebase without fast-forward +grbf() { a__git_re_base_force "${@}"; } +a__git_re_base_force() { + git \ + rebase \ + --force-rebase \ + "${@}" +} + +# rebase interactively +grbi() { a__git_re_base_interactive "${@}"; } +a__git_re_base_interactive() { + git \ + rebase \ + --interactive \ + "${@}" +} + +# add a new remote repository +grma() { a__git_re_mote_add "${@}"; } +a__git_re_mote_add() { + git \ + remote \ + add \ + "${@}" +} + +# list remote repositories +grml() { a__git_re_mote_list "${@}"; } +a__git_re_mote_list() { + git \ + remote \ + --verbose \ + "${@}" +} + +# set the location of a remote repository +grmsu() { a__git_re_mote_set_upstream "${@}"; } +a__git_re_mote_set_upstream() { + git \ + remote \ + set-url \ + "${@}" +} + +# show connection to a remote repository +grms() { a__git_re_mote_show "${@}"; } +a__git_re_mote_show() { + git \ + remote \ + show \ + "${@}" +} + +# remove and add removal to index +grm() { a__git_re_move "${@}"; } +a__git_re_move() { + git \ + rm \ + "${@}" +} + +# remove file(s) from index or move current branch pointer +grs() { a__git_re_set "${@}"; } +a__git_re_set() { + git \ + reset \ + "${@}" +} + +# wipe modifications or reset current branch to another commit +grsh() { a__git_re_set_hard "${@}"; } +a__git_re_set_hard() { + git \ + reset \ + --hard \ + "${@}" +} + +# show a commit +gsc() { a__git_show_commit "${@}"; } +a__git_show_commit() { + git \ + show \ + "${@}" +} + +# current state of repository +gs() { a__git_status "${@}"; } +a__git_status() { + git \ + status \ + --untracked-files="all" \ + "${@}" +} + +# tag a commit +gt() { a__git_tag "${@}"; } +a__git_tag() { + git \ + tag \ + "${@}" +} + +# delete a tag +gtd() { a__git_tag_delete "${@}"; } +a__git_tag_delete() { + git \ + tag \ + --delete \ + "${@}" +} + +# update head ref +gurh() { a__git_update_ref_head "${@}"; } +a__git_update_ref_head() { + if [ -n "${2}" ]; then + git \ + update-ref \ + "refs/heads/${1}" \ + "${2}" + fi +} diff --git a/sh/alias/gpg.sh b/sh/alias/gpg.sh new file mode 100644 index 0000000..eb19651 --- /dev/null +++ b/sh/alias/gpg.sh @@ -0,0 +1,12 @@ +# turn gpg agent off +gak() { a__gpg_agent_kill "${@}"; } +a__gpg_agent_kill() { + gpgconf \ + --kill "gpg-agent" +} + +# bind gpg agent to current tty +gau() { a__gpg_agent_update "${@}"; } +a__gpg_agent_update() { + rwx_gpg_agent_update +} diff --git a/sh/alias/grep.sh b/sh/alias/grep.sh new file mode 100644 index 0000000..5b00ed7 --- /dev/null +++ b/sh/alias/grep.sh @@ -0,0 +1,9 @@ +# grep from current directory with regex +g() { a__grep "${@}"; } +a__grep() { + grep \ + --directories "recurse" \ + --line-number \ + --regexp \ + "${@}" +} diff --git a/sh/alias/kill.sh b/sh/alias/kill.sh new file mode 100644 index 0000000..718a307 --- /dev/null +++ b/sh/alias/kill.sh @@ -0,0 +1,14 @@ +# kill a process by id +k() { a__kill "${@}"; } +a__kill() { + kill \ + "${@}" +} + +# force kill a process by id +kf() { a__kill_force "${@}"; } +a__kill_force() { + kill \ + -9 \ + "${@}" +} diff --git a/sh/alias/killall.sh b/sh/alias/killall.sh new file mode 100644 index 0000000..6658065 --- /dev/null +++ b/sh/alias/killall.sh @@ -0,0 +1,14 @@ +# kill all instances of a process by name +ka() { a__kill_all "${@}"; } +a__kill_all() { + killall \ + "${@}" +} + +# force kill all instances of a process by name +kaf() { a__kill_all_force "${@}"; } +a__kill_all_force() { + killall \ + -9 \ + "${@}" +} diff --git a/sh/alias/ls.sh b/sh/alias/ls.sh new file mode 100644 index 0000000..ad5a809 --- /dev/null +++ b/sh/alias/ls.sh @@ -0,0 +1,32 @@ +export LS_COLORS="\ +di=0;94\ +" + +# list current directory’s entries +l() { a__ls "${@}"; } +a__ls() { + ls \ + --all \ + --color \ + -l \ + -p \ + --time-style "+" \ + "${@}" +} + +# list timestamps +lt() { a__ls_time "${@}"; } +a__ls_time() { + a__ls \ + --time-style "+%Y%m%d-%H%M%S%-:::z" \ + "${@}" +} + +# list timestamps recent last +ltr() { a__ls_time_reverse "${@}"; } +a__ls_time_reverse() { + a__ls_time \ + --reverse \ + -t \ + "${@}" +} diff --git a/sh/alias/lsblk.sh b/sh/alias/lsblk.sh new file mode 100644 index 0000000..43dffc6 --- /dev/null +++ b/sh/alias/lsblk.sh @@ -0,0 +1,31 @@ +# list block devices +lb() { a__list_block "${@}"; } +a__list_block() { + a__list_block_output \ + "SIZE" \ + "TYPE" \ + "FSTYPE" \ + "LABEL" \ + "MOUNTPOINTS" \ + "${@}" +} + +# base arguments +lbne() { a__list_block_no_empty "${@}"; } +a__list_block_no_empty() { + lsblk \ + --noempty \ + "${@}" +} + +# output arguments +lbo() { a__list_block_output "${@}"; } +a__list_block_output() { + local argument + local arguments="NAME" + for argument in "${@}"; do + arguments="${arguments},${argument}" + done + a__list_block_no_empty \ + --output "${arguments}" +} diff --git a/sh/alias/mkdir.sh b/sh/alias/mkdir.sh new file mode 100644 index 0000000..bebc665 --- /dev/null +++ b/sh/alias/mkdir.sh @@ -0,0 +1,14 @@ +# make a directory +md() { a__make_directory "${@}"; } +a__make_directory() { + mkdir \ + "${@}" +} + +# make a directory after making its parents +mdp() { a__make_directory_parents "${@}"; } +a__make_directory_parents() { + mkdir \ + --parents \ + "${@}" +} diff --git a/sh/alias/mount.sh b/sh/alias/mount.sh new file mode 100644 index 0000000..535910e --- /dev/null +++ b/sh/alias/mount.sh @@ -0,0 +1,5 @@ +m() { a__mount "${@}"; } +a__mount() { + mount \ + "${@}" +} diff --git a/sh/alias/mv.sh b/sh/alias/mv.sh new file mode 100644 index 0000000..0630042 --- /dev/null +++ b/sh/alias/mv.sh @@ -0,0 +1,7 @@ +# move interactively +mvi() { a__mo_ve_interactive "${@}"; } +a__mo_ve_interactive() { + mv \ + --interactive \ + "${@}" +} diff --git a/sh/alias/nano.sh b/sh/alias/nano.sh new file mode 100644 index 0000000..7570cda --- /dev/null +++ b/sh/alias/nano.sh @@ -0,0 +1,5 @@ +nn() { a__na_no "${@}"; } +a__na_no() { + nano \ + "${@}" +} diff --git a/sh/alias/newsboat.sh b/sh/alias/newsboat.sh new file mode 100644 index 0000000..6c08c90 --- /dev/null +++ b/sh/alias/newsboat.sh @@ -0,0 +1,5 @@ +nb() { a__news_boat "${@}"; } +a__news_boat() { + newsboat \ + "${@}" +} diff --git a/sh/alias/overlay.sh b/sh/alias/overlay.sh new file mode 100644 index 0000000..6357655 --- /dev/null +++ b/sh/alias/overlay.sh @@ -0,0 +1,140 @@ +obm() { a__overlay_bind_mount "${@}"; } +a__overlay_bind_mount() { + local directory + for directory in "dev" "dev/pts" "proc" "sys"; do + if ! mount --bind "/${directory}" "overlay/mount/${directory}"; then + rwx_log_error "Unable to bind mount directory: ${directory}" + return 1 + fi + done +} + +obu() { a__overlay_bind_unmount "${@}"; } +a__overlay_bind_unmount() { + local directory + for directory in "sys" "proc" "dev/pts" "dev"; do + if ! umount --lazy "overlay/mount/${directory}"; then + rwx_log_error "Unable to bind unmount directory: ${directory}" + return 1 + fi + done +} + +ocr() { a__overlay_command_root "${@}"; } +a__overlay_command_root() { + chroot \ + "overlay/mount" "${@}" +} + +ocu() { a__overlay_command_user "${@}"; } +a__overlay_command_user() { + chroot \ + --userspec "1000:1000" \ + "overlay/mount" "${@}" +} + +omm() { a__overlay_mirror_mount "${@}"; } +a__overlay_mirror_mount() { + mount --make-rslave --rbind "/deb" "overlay/mount/deb" +} + +omu() { a__overlay_mirror_unmount "${@}"; } +a__overlay_mirror_unmount() { + umount --recursive "overlay/mount/deb" +} + +orm() { a__overlay_root_mount "${@}"; } +a__overlay_root_mount() { + local root="${1}" + if [ -z "${root}" ]; then + rwx_log_error "No root target directory" + return 1 + fi + root="$(realpath "${root}")" + if ! mkdir "overlay"; then + rwx_log_error "Unable to make overlay directory" + return 2 + fi + ( + if ! cd "overlay"; then + rwx_log_error "Unable to move into overlay directory" + return 3 + fi + local directory + for directory in "lower" "upper" "work" "mount"; do + if ! mkdir --parents "${directory}"; then + rwx_log_error "Unable to make directory: ${directory}" + return 4 + fi + done + local file="${root}/filesystem.squashfs" + if ! mount "${file}" "lower"; then + rwx_log_error "Unable to lower mount: ${file}" + return 5 + fi + if ! mount \ + -o "lowerdir=lower,upperdir=upper,workdir=work" \ + -t "overlay" \ + "overlay" "mount"; then + rwx_log_error "Unable to overlay mount" + return 6 + fi + ) +} + +ors() { a__overlay_root_squash "${@}"; } +a__overlay_root_squash() { + local directory="${1}" + local file + local level="${2}" + if [ -n "${directory}" ]; then + if mkdir "${directory}"; then + [ -n "${level}" ] || level="18" + for file in "vmlinuz" "initrd.img"; do + cp "overlay/mount/${file}" "${directory}" + done + mksquashfs \ + "overlay/mount" "${directory}/filesystem.squashfs" \ + -noappend \ + -comp "zstd" -Xcompression-level "${level}" + chown --recursive 1000:1000 "${directory}" + fi + fi +} + +oru() { a__overlay_root_unmount "${@}"; } +a__overlay_root_unmount() { + ( + if ! cd "overlay"; then + rwx_log_error "Unable to move into overlay directory" + return 1 + fi + if ! umount "mount"; then + rwx_log_error "Unable to unmount mount directory" + return 2 + fi + if ! rmdir "mount"; then + rwx_log_error "Unable to remove mount directory" + return 3 + fi + local directory + for directory in "upper" "work"; do + if ! rm --force --recursive "${directory}"; then + rwx_log_error "Unable to remove directory: ${directory}" + return 4 + fi + done + if ! umount "lower"; then + rwx_log_error "Unable to unmount lower directory" + return 5 + fi + if ! rmdir "lower"; then + rwx_log_error "Unable to remove lower directory" + return 6 + fi + ) + if ! rmdir "overlay"; then + rwx_log_error "Unable to remove overlay directory" + return 7 + fi +} diff --git a/sh/alias/pass.sh b/sh/alias/pass.sh new file mode 100644 index 0000000..66cad55 --- /dev/null +++ b/sh/alias/pass.sh @@ -0,0 +1,14 @@ +# display pass entry’s content +p() { a__pass "${@}"; } +a__pass() { + pass \ + "${@}" +} + +# copy passphrase into clipboard +pc() { a__pass_clip "${@}"; } +a__pass_clip() { + pass \ + --clip \ + "${@}" +} diff --git a/sh/alias/pgrep.sh b/sh/alias/pgrep.sh new file mode 100644 index 0000000..72de025 --- /dev/null +++ b/sh/alias/pgrep.sh @@ -0,0 +1,7 @@ +# look for a string in processes names +pg() { a__proc_grep "${@}"; } +a__proc_grep() { + pgrep \ + --list-full \ + "${@}" +} diff --git a/sh/alias/pwgen.sh b/sh/alias/pwgen.sh new file mode 100644 index 0000000..3b3dc83 --- /dev/null +++ b/sh/alias/pwgen.sh @@ -0,0 +1,17 @@ +# generate passwords +pwg() { a__pass_word_gen "${@}"; } +a__pass_word_gen() { + pwgen \ + -1 \ + --num-passwords 1048576 \ + --secure \ + "${@}" +} + +# generate passwords with symbols +pwgs() { a__pass_word_gen_symbols "${@}"; } +a__pass_word_gen_symbols() { + a__pass_word_gen \ + --symbols \ + "${@}" +} diff --git a/sh/alias/rm.sh b/sh/alias/rm.sh new file mode 100644 index 0000000..9634c1b --- /dev/null +++ b/sh/alias/rm.sh @@ -0,0 +1,7 @@ +# remove interactively +rmi() { a__re_move_interactive "${@}"; } +a__re_move_interactive() { + rm \ + --interactive \ + "${@}" +} diff --git a/sh/alias/rsync.sh b/sh/alias/rsync.sh new file mode 100644 index 0000000..bdbe4ed --- /dev/null +++ b/sh/alias/rsync.sh @@ -0,0 +1,27 @@ +# synchronize +rs() { a__r_sync "${@}"; } +a__r_sync() { + rsync \ + --archive \ + --no-inc-recursive \ + --partial \ + --progress \ + --verbose \ + "${@}" +} + +# synchronize and delete after +rsda() { a__r_sync_delete_after "${@}"; } +a__r_sync_delete_after() { + a__r_sync \ + --delete-after \ + "${@}" +} + +# synchronize and delete before +rsdb() { a__r_sync_delete_before "${@}"; } +a__r_sync_delete_before() { + a__r_sync \ + --delete-before \ + "${@}" +} diff --git a/sh/alias/shell.sh b/sh/alias/shell.sh new file mode 100644 index 0000000..d6f5801 --- /dev/null +++ b/sh/alias/shell.sh @@ -0,0 +1,29 @@ +# shorten alias +a() { + alias \ + "${@}" +} + +# swap directory (current ↔ previous) +sd() { + cd \ + - || + return +} + +# exit terminal +x() { + exit \ + "${@}" +} + +[ "${RWX_SHELL}" = "bash" ] || return + +# shellcheck disable=SC3033 +..() { + cd .. +} +# shellcheck disable=SC3033 +...() { + cd ../.. +} diff --git a/sh/alias/tar.sh b/sh/alias/tar.sh new file mode 100644 index 0000000..92b8fbf --- /dev/null +++ b/sh/alias/tar.sh @@ -0,0 +1,31 @@ +tc() { a__tar_create "${@}"; } +a__tar_create() { + a__tar_verbose \ + --create \ + --auto-compress \ + --file \ + "${@}" +} + +tl() { a__tar_list "${@}"; } +a__tar_list() { + a__tar_verbose \ + --list \ + --file \ + "${@}" +} + +tv() { a__tar_verbose "${@}"; } +a__tar_verbose() { + tar \ + --verbose \ + "${@}" +} + +tx() { a__tar_xtract "${@}"; } +a__tar_xtract() { + a__tar_verbose \ + --extract \ + --file \ + "${@}" +} diff --git a/sh/alias/tmux.sh b/sh/alias/tmux.sh new file mode 100644 index 0000000..b30dc79 --- /dev/null +++ b/sh/alias/tmux.sh @@ -0,0 +1,5 @@ +tm() { a__t_mux "${@}"; } +a__t_mux() { + tmux \ + "${@}" +} diff --git a/sh/alias/tree.sh b/sh/alias/tree.sh new file mode 100644 index 0000000..03be3de --- /dev/null +++ b/sh/alias/tree.sh @@ -0,0 +1,12 @@ +t() { a__tree "${@}"; } +a__tree() { + tree \ + "${@}" +} + +ta() { a__tree_all "${@}"; } +a__tree_all() { + tree \ + -a \ + "${@}" +} diff --git a/sh/cryptsetup.sh b/sh/cryptsetup.sh new file mode 100644 index 0000000..900083d --- /dev/null +++ b/sh/cryptsetup.sh @@ -0,0 +1,6 @@ +_rwx_cmd_cs() { rwx_crypt_setup "${@}"; } + +rwx_crypt_setup() { + local action="${1}" + echo "cs: ${action}" +} diff --git a/sh/debian.sh b/sh/debian.sh new file mode 100644 index 0000000..88e8b01 --- /dev/null +++ b/sh/debian.sh @@ -0,0 +1,76 @@ +RWX_DEBIAN_CODENAME="$( + grep "VERSION_CODENAME" "/etc/os-release" | + cut --delimiter "=" --fields "2" +)" + +rwx_apt_clean() { + apt-get \ + clean +} + +rwx_apt_conf_write() { + printf "\ +Acquire::AllowInsecureRepositories False; +Acquire::AllowWeakRepositories False; +Acquire::AllowDowngradeToInsecureRepositories False; +Acquire::Check-Valid-Until True; +APT::Install-Recommends False; +APT::Install-Suggests False; +APT::Get::Show-Versions True; +Dir::Etc::SourceParts \"\"; +Dpkg::Progress True; +" >"/etc/apt/apt.conf.d/apt.conf" +} + +rwx_apt_install_backports() { + rwx_apt_install_target "${RWX_DEBIAN_CODENAME}-backports" "${@}" +} + +rwx_apt_install_release() { + rwx_apt_install_target "${RWX_DEBIAN_CODENAME}" "${@}" +} + +rwx_apt_install_target() { + local target="${1}" + shift + local package + for package in "${@}"; do + rwx_log "" \ + "${package} ← ${target}" + apt-get \ + install \ + --assume-yes \ + --target-release "${target}" \ + "${package}" + rwx_apt_clean + done +} + +rwx_apt_sources_write() { + printf "%s" "\ +deb https://deb.debian.org/debian \ +${RWX_DEBIAN_CODENAME} main non-free-firmware contrib non-free +deb https://deb.debian.org/debian \ +${RWX_DEBIAN_CODENAME}-backports main non-free-firmware contrib non-free +deb https://deb.debian.org/debian \ +${RWX_DEBIAN_CODENAME}-updates main non-free-firmware contrib non-free +deb https://deb.debian.org/debian-security \ +${RWX_DEBIAN_CODENAME}-security main non-free-firmware contrib non-free +" >"/etc/apt/sources.list" +} + +rwx_apt_update() { + apt-get \ + update +} + +rwx_apt_upgrade() { + apt-get \ + upgrade \ + --assume-yes + rwx_apt_clean +} + +rwx_debian_frontend_disable() { + export DEBIAN_FRONTEND="noninteractive" +} diff --git a/sh/ffmpeg.sh b/sh/ffmpeg.sh new file mode 100644 index 0000000..bcb3a62 --- /dev/null +++ b/sh/ffmpeg.sh @@ -0,0 +1,194 @@ +# ╭────────┬─────────┬───────╮ +# │ ffmpeg │ devices │ reset │ +# ╰────────┴─────────┴───────╯ + +_rwx_cmd_rwx_ffmpeg_devices_reset() { rwx_ffmpeg_devices_reset "${@}"; } +rwx_ffmpeg_devices_reset() { + local module="uvcvideo" + modprobe --remove "${module}" && + modprobe "${module}" +} + +# ╭────────┬────────┬─────────╮ +# │ ffmpeg │ device │ formats │ +# ╰────────┴────────┴─────────╯ + +rwx_ffmpeg_device_formats() { + local device="${1}" + [ -n "${device}" ] || device="/dev/video0" + ffmpeg \ + -f "v4l2" \ + -list_formats "all" \ + -i "${device}" +} + +# ╭────────┬───────╮ +# │ ffmpeg │ input │ +# ╰────────┴───────╯ + +rwx_ffmpeg_input_blue_yeti() { + local device="alsa_input.\ +usb-Generic_Blue_Microphones_2051BAB04XY8-00.analog-stereo" + set -- \ + -f "pulse" \ + -i "${device}" \ + -ac "2" \ + -ar "48000" + local argument + for argument in "${@}"; do echo "${argument}"; done +} + +rwx_ffmpeg_input_dell_precision() { + local device="alsa_input.\ +pci-0000_00_1f.3.analog-stereo" + set -- \ + -f "pulse" \ + -i "${device}" \ + -ac "2" \ + -ar "48000" + local argument + for argument in "${@}"; do echo "${argument}"; done +} + +rwx_ffmpeg_input_file() { + local file="${1}" + local from="${2}" + local to="${3}" + [ -n "${file}" ] || return + set -- \ + -i "${file}" + if [ -n "${to}" ]; then + set -- "${@}" \ + -ss "${from}" \ + -to "${to}" + fi + local argument + for argument in "${@}"; do echo "${argument}"; done +} + +rwx_ffmpeg_input_hdmi() { + local device="${1}" + [ -n "${device}" ] || device="/dev/video0" + set -- \ + -f "v4l2" \ + -video_size "1920x1080" \ + -framerate "60" \ + -input_format "yuyv422" \ + -i "${device}" + local argument + for argument in "${@}"; do echo "${argument}"; done +} + +# ╭────────┬────────╮ +# │ ffmpeg │ output │ +# ╰────────┴────────╯ + +rwx_ffmpeg_output_audio_fast() { + set -- \ + -codec:a "flac" \ + -compression_level "0" + local argument + for argument in "${@}"; do echo "${argument}"; done +} + +rwx_ffmpeg_output_audio_slow() { + set -- \ + -codec:a "libopus" \ + -b:a "128k" + local argument + for argument in "${@}"; do echo "${argument}"; done +} + +rwx_ffmpeg_output_file() { + local file="${1}" + [ -n "${file}" ] || return + set -- \ + -y "${file}" + local argument + for argument in "${@}"; do echo "${argument}"; done +} + +rwx_ffmpeg_output_video_fast() { + set -- \ + -codec:v "libx264" \ + -preset "ultrafast" \ + -crf "0" + local argument + for argument in "${@}"; do echo "${argument}"; done +} + +rwx_ffmpeg_output_video_slow() { + local crf="${1}" + local codec="${2}" + [ -n "${codec}" ] || codec="libx264" + if [ -z "${crm}" ]; then + case "${codec}" in + "libx264") crf="23" ;; + "libx265") crf="28" ;; + *) ;; + esac + fi + set -- \ + -codec:v "${codec}" \ + -preset "veryslow" \ + -crf "${crf}" \ + -movflags "+faststart" \ + -pix_fmt "yuv420p" + local argument + for argument in "${@}"; do echo "${argument}"; done +} + +# ╭────────┬────────╮ +# │ ffmpeg │ record │ +# ╰────────┴────────╯ + +rwx_ffmpeg_record_hdmi_precision() { + local file="${1}" + [ -n "${file}" ] || return + # LATER alternative + # shellcheck disable=SC2046,SC2312 + set -- \ + $(rwx_ffmpeg_input_hdmi) \ + $(rwx_ffmpeg_input_dell_precision) \ + $(rwx_ffmpeg_output_video_fast) \ + $(rwx_ffmpeg_output_audio_fast) \ + $(rwx_ffmpeg_output_file "${file}") + echo "${@}" + ffmpeg "${@}" +} + +rwx_ffmpeg_record_hdmi_yeti() { + local file="${1}" + [ -n "${file}" ] || return + # LATER alternative + # shellcheck disable=SC2046,SC2312 + set -- \ + $(rwx_ffmpeg_input_hdmi) \ + $(rwx_ffmpeg_input_blue_yeti) \ + $(rwx_ffmpeg_output_video_fast) \ + $(rwx_ffmpeg_output_audio_fast) \ + $(rwx_ffmpeg_output_file "${file}") + echo "${@}" + ffmpeg "${@}" +} + +# ╭────────┬────────╮ +# │ ffmpeg │ reduce │ +# ╰────────┴────────╯ + +rwx_ffmpeg_reduce() { + local input="${1}" + local output="${2}" + local from="${3}" + local to="${4}" + [ -n "${output}" ] || return + # LATER alternative + # shellcheck disable=SC2046,SC2312 + set -- \ + $(rwx_ffmpeg_input_file "${input}" "${from}" "${to}") \ + $(rwx_ffmpeg_output_video_slow) \ + $(rwx_ffmpeg_output_audio_slow) \ + $(rwx_ffmpeg_output_file "${output}") + echo "${@}" + ffmpeg "${@}" +} diff --git a/sh/fs.sh b/sh/fs.sh new file mode 100644 index 0000000..ac46f6d --- /dev/null +++ b/sh/fs.sh @@ -0,0 +1,121 @@ +rwx_fs_make_btrfs() { + local device="${1}" + local label="${2}" + local uuid="${3}" + if [ -b "${device}" ]; then + set -- \ + --force \ + --checksum "sha256" + if [ -n "${label}" ]; then + set -- "${@}" \ + --label "${label}" + fi + if [ -n "${uuid}" ]; then + set -- "${@}" \ + --uuid "${uuid}" + fi + mkfs.btrfs "${@}" "${device}" + fi +} + +rwx_fs_make_btrfs_swap() { + local path="${1}" + local size="${2}" + local uuid="${3}" + if [ -n "${path}" ]; then + set -- filesystem mkswapfile + if [ -n "${size}" ]; then + set -- "${@}" \ + --size "${size}" + fi + if [ -n "${uuid}" ]; then + set -- "${@}" \ + --uuid "${uuid}" + fi + btrfs "${@}" "${path}" + fi +} + +rwx_fs_make_fat() { + local device="${1}" + local name="${2}" + local volid="${3}" + if [ -b "${device}" ]; then + set -- \ + -F 32 \ + -S 4096 + if [ -n "${name}" ]; then + set -- "${@}" \ + -n "${name}" + fi + if [ -n "${volid}" ]; then + set -- "${@}" \ + -i "${volid}" + fi + mkfs.fat "${@}" "${device}" + fi +} + +rwx_fs_raid_create() { + if [ -n "${4}" ]; then + local name="${1}" + local uuid="${2}" + shift 2 + mdadm \ + --create "/dev/md/${name}" \ + --level 0 \ + --metadata 1 \ + --name "md:${name}" \ + --raid-devices ${#} \ + --uuid "${uuid}" \ + "${@}" + fi +} + +rwx_fs_wipe() { + local device="${1}" + local buffer="${2}" + local count="${3}" + if [ -b "${device}" ]; then + set -- \ + status="progress" \ + if="/dev/zero" \ + of="${device}" + if [ -n "${buffer}" ]; then + set -- "${@}" \ + bs="${buffer}" + fi + if [ -n "${count}" ]; then + set -- "${@}" \ + count="${count}" + fi + dd "${@}" + fi +} + +rwx_fs_luks_format() { + local passphrase="${1}" + local device="${2}" + local label="${3}" + local uuid="${4}" + if [ -b "${device}" ]; then + set -- \ + --batch-mode \ + --cipher "aes-xts-plain64" \ + --hash "sha512" \ + --iter-time 4096 \ + --key-size 512 \ + --pbkdf "argon2id" \ + --type "luks2" \ + --use-random \ + --verbose + if [ -n "${label}" ]; then + set -- "${@}" --label "${label}" + fi + if [ -n "${uuid}" ]; then + set -- "${@}" --uuid "${uuid}" + fi + echo "${passphrase}" | + cryptsetup "${@}" luksFormat "${device}" + fi +} diff --git a/sh/gnome.sh b/sh/gnome.sh new file mode 100644 index 0000000..b17a058 --- /dev/null +++ b/sh/gnome.sh @@ -0,0 +1,71 @@ +# ╭───────┬────────────╮ +# │ gnome │ background │ +# ╰───────┴────────────╯ + +rwx_gnome_background_black() { + rwx_gnome_set_background "color-shading-type" "solid" + rwx_gnome_set_background "primary-color" "#000000" +} + +rwx_gnome_background_white() { + rwx_gnome_set_background "color-shading-type" "solid" + rwx_gnome_set_background "primary-color" "#ffffff" +} + +rwx_gnome_background_win3() { + rwx_gnome_set_background "color-shading-type" "vertical" + rwx_gnome_set_background "primary-color" "#000000" + rwx_gnome_set_background "secondary-color" "#0000ff" +} + +# ╭───────┬───────╮ +# │ gnome │ proxy │ +# ╰───────┴───────╯ + +rwx_gnome_proxy() { + local value + case "${1}" in + "on") value="manual" ;; + *) value="none" ;; + esac + gsettings set "org.gnome.system.proxy" "mode" "${value}" +} + +# ╭───────┬─────╮ +# │ gnome │ set │ +# ╰───────┴─────╯ + +rwx_gnome_set() { + local group="${1}" + local key="${2}" + local value="${3}" + [ -n "${value}" ] || return + gsettings set "${group}" "${key}" "${value}" +} + +rwx_gnome_set_background() { + local key="${1}" + local value="${2}" + [ -n "${value}" ] || return + rwx_gnome_set "org.gnome.desktop.background" "${key}" "${value}" +} + +# ╭───────┬────────────╮ +# │ gnome │ workspaces │ +# ╰───────┴────────────╯ + +rwx_gnome_workspaces_primary() { + local bool + local group="org.gnome.mutter" + local name="workspaces-only-on-primary" + local var="${group}/${name}" + # get + bool="$(gsettings get "${group}" "${name}")" + rwx_log_debug "${var}: ${bool}" + # not + bool="$(rwx_not "${bool}")" + rwx_log_debug "bool: ${bool}" + # set + gsettings set "${group}" "${name}" "${bool}" + rwx_log_info "${var}: ${bool}" +} diff --git a/sh/gpg.sh b/sh/gpg.sh new file mode 100644 index 0000000..b5ce07b --- /dev/null +++ b/sh/gpg.sh @@ -0,0 +1,19 @@ +# bind gpg agent to current tty +rwx_gpg_agent_update() { + gpg-connect-agent \ + updatestartuptty \ + /bye +} + +rwx_gpg_ssh_auth_sock() { + local user_id + user_id=$(id --user) + if [ "${user_id}" -ne 0 ]; then + if [ -f "${HOME}/.gnupg/gpg-agent.conf" ]; then + SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" + export SSH_AUTH_SOCK + fi + fi +} + +rwx_gpg_ssh_auth_sock diff --git a/sh/lint/gitlint.sh b/sh/lint/gitlint.sh new file mode 100644 index 0000000..643333c --- /dev/null +++ b/sh/lint/gitlint.sh @@ -0,0 +1,6 @@ +rwx_gitlint() { + local path="${1}" + gitlint \ + --target "${path}" \ + "lint" +} diff --git a/sh/lint/lint.sh b/sh/lint/lint.sh new file mode 100644 index 0000000..365773f --- /dev/null +++ b/sh/lint/lint.sh @@ -0,0 +1,78 @@ +# lint code +rwx_lint() { + local path="${1}" + [ -n "${path}" ] || return 1 + rwx_lint_clean "${path}" + rwx_lint_tasks "${path}" + set \ + "python" \ + "shell" + local code + for code in "${@}"; do + rwx_log "" "${code}" + "rwx_lint_${code}" "${path}" + done + rwx_lint_clean "${path}" +} + +# clean +rwx_lint_clean() { + local path="${1}" + [ -n "${path}" ] || return 1 + rwx_log "" "clean" "" + py3clean "${path}" + set \ + "mypy" \ + "ruff" + local tool + for tool in "${@}"; do + rwx_remove "${path}/.${tool}_cache" + done +} + +# lint python code +rwx_lint_python() { + local path="${1}" + local action + set \ + "pylint" \ + "pydoclint" \ + "mypy" \ + "ruff" + for action in "${@}"; do + rwx_log "" "${action}" + "rwx_${action}" "${path}" + done +} + +# lint shell code +rwx_lint_shell() { + local path="${1}" + local action + set \ + "shellcheck" \ + "shfmt" + for action in "${@}"; do + rwx_log "" "${action}" + "rwx_${action}" "${path}" + done +} + +# lint code tasks +rwx_lint_tasks() { + local path="${1}" + local type + set \ + "LATER" \ + "TODO" \ + "FIXME" + for type in "${@}"; do + rwx_log "" "${type}" + grep \ + --after "1" \ + --directories "recurse" \ + --line-number \ + " ${type}" \ + "${path}" + done +} diff --git a/sh/lint/mypy.sh b/sh/lint/mypy.sh new file mode 100644 index 0000000..586d409 --- /dev/null +++ b/sh/lint/mypy.sh @@ -0,0 +1,4 @@ +rwx_mypy() { + local path="${1}" + mypy "${path}" +} diff --git a/sh/lint/pydoclint.sh b/sh/lint/pydoclint.sh new file mode 100644 index 0000000..d2eb72f --- /dev/null +++ b/sh/lint/pydoclint.sh @@ -0,0 +1,9 @@ +rwx_pydoclint() { + local path="${1}" + pydoclint \ + --allow-init-docstring True \ + --quiet \ + --skip-checking-short-docstrings False \ + --style "sphinx" \ + "${path}" +} diff --git a/sh/lint/pylint.sh b/sh/lint/pylint.sh new file mode 100644 index 0000000..52e1bd1 --- /dev/null +++ b/sh/lint/pylint.sh @@ -0,0 +1,6 @@ +rwx_pylint() { + local path="${1}" + pylint \ + --enable-all-extensions \ + "${path}/**/*.py" +} diff --git a/sh/lint/ruff.sh b/sh/lint/ruff.sh new file mode 100644 index 0000000..e15b701 --- /dev/null +++ b/sh/lint/ruff.sh @@ -0,0 +1,28 @@ +rwx_ruff() { + local path="${1}" + local action + set \ + "check" \ + "format" + for action in "${@}"; do + "rwx_ruff_${action}" "${path}" + done +} + +rwx_ruff_check() { + local path="${1}" + ruff check \ + --ignore "D203,D213" \ + --isolated \ + --select "ALL" \ + "${path}" +} + +rwx_ruff_format() { + local path="${1}" + ruff format \ + --diff \ + --isolated \ + --line-length "80" \ + "${path}" +} diff --git a/sh/lint/shellcheck.sh b/sh/lint/shellcheck.sh new file mode 100644 index 0000000..ac8c700 --- /dev/null +++ b/sh/lint/shellcheck.sh @@ -0,0 +1,34 @@ +rwx_shellcheck() { + local root="${1}" + local file module modules path + file="$(mktemp)" + modules="$(rwx_find_shell "${root}")" + rwx_ifs_set + for module in ${modules}; do + path="${root}/${module}" + echo ". \"${path}\"" >>"${file}" + done + rwx_ifs_unset + rwx_shellcheck_file "${file}" + rwx_remove "${file}" +} + +rwx_shellcheck_file() { + local file="${1}" + shellcheck \ + --check-sourced \ + --enable "all" \ + --exclude "3043" \ + --external-sources \ + --shell "dash" \ + "${file}" +} + +rwx_shellcheck_write() { + rwx_file_write ".shellcheckrc" "\ +disable=3043 +enable=all +external-sources=true +shell=sh +" +} diff --git a/sh/lint/shfmt.sh b/sh/lint/shfmt.sh new file mode 100644 index 0000000..4d6e894 --- /dev/null +++ b/sh/lint/shfmt.sh @@ -0,0 +1,4 @@ +rwx_shfmt() { + local path="${1}" + shfmt --diff "${path}" +} diff --git a/sh/live.sh b/sh/live.sh new file mode 100644 index 0000000..7d82bfc --- /dev/null +++ b/sh/live.sh @@ -0,0 +1,6 @@ +# remount read-only medium in read-write +rwx_live_medium_remount() { + mount \ + -o "remount,rw" \ + "/usr/lib/live/mount/medium" +} diff --git a/sh/log/log.sh b/sh/log/log.sh new file mode 100644 index 0000000..b921d45 --- /dev/null +++ b/sh/log/log.sh @@ -0,0 +1,68 @@ +RWX_LOG_LEVEL_FATAL=0 +RWX_LOG_LEVEL_ERROR=1 +RWX_LOG_LEVEL_WARN=2 +RWX_LOG_LEVEL_INFO=3 +RWX_LOG_LEVEL_DEBUG=4 +RWX_LOG_LEVEL_TRACE=5 + +RWX_LOG_LEVEL=${RWX_LOG_LEVEL_INFO} + +rwx_log() { rwx_log_info "${@}"; } + +rwx_log_debug() { + if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_DEBUG}" ]; then + _rwx_log "[DEBUG]" "${@}" + fi +} + +rwx_log_error() { + local code="${1}" + shift + [ -n "${code}" ] || rwx_log_fatal 1 "No error code" + if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_ERROR}" ]; then + _rwx_log "[ERROR]" "${@}" >&2 + return "${code}" + fi +} + +rwx_log_fatal() { + local code="${1}" + shift + [ -n "${code}" ] || rwx_log_fatal 1 "No error code" + if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_FATAL}" ]; then + _rwx_log "[FATAL]" "${@}" >&2 + exit "${code}" + fi +} + +rwx_log_info() { + if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_INFO}" ]; then + _rwx_log "" "${@}" + fi +} + +rwx_log_trace() { + if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_TRACE}" ]; then + _rwx_log "[TRACE]" "${@}" + fi +} + +rwx_log_warn() { + if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_WARN}" ]; then + _rwx_log "[ WARN]" "${@}" + fi +} + +_rwx_log() { + local prefix="${1}" + shift + [ ${#} -gt 0 ] || set -- "" + local line + for line in "${@}"; do + if [ -n "${prefix}" ]; then + __rwx_log "${prefix} ${line}" + else + __rwx_log "${line}" + fi + done +} diff --git a/sh/log/step.sh b/sh/log/step.sh new file mode 100644 index 0000000..34a5c64 --- /dev/null +++ b/sh/log/step.sh @@ -0,0 +1,25 @@ +# ╭───────────────╮ +# │ __ = internal │ +# ╰───────────────╯ + +# __RWX_BAR_TOP +# __RWX_BAR_MIDDLE +# __RWX_BAR_BOTTOM + +# __RWX_STEP_LEVEL +# __RWX_STEP_level_INDEX +# __RWX_STEP_level_LABEL + +# ╭─────────────╮ +# │ _ = private │ +# ╰─────────────╯ + +_RWX_BOX_DOWN_AND_HORIZONTAL="┬" +_RWX_BOX_DOWN_AND_LEFT="╮" +_RWX_BOX_DOWN_AND_RIGHT="╭" +_RWX_BOX_HORIZONTAL="─" +_RWX_BOX_LEFT="╴" +_RWX_BOX_UP_AND_HORIZONTAL="┴" +_RWX_BOX_UP_AND_LEFT="╯" +_RWX_BOX_UP_AND_RIGHT="╰" +_RWX_BOX_VERTICAL="│" diff --git a/sh/main.sh b/sh/main.sh new file mode 100755 index 0000000..802418f --- /dev/null +++ b/sh/main.sh @@ -0,0 +1,144 @@ +#! /usr/bin/env sh + +# ╭──────┬───────────╮ +# │ main │ constants │ +# ╰──────┴───────────╯ + +RWX_MAIN_NAME="main.sh" +RWX_SELF_NAME="rwx" + +RWX_SELF_COMMAND="_${RWX_SELF_NAME}_cmd_" + +# ╭──────┬───────────╮ +# │ main │ variables │ +# ╰──────┴───────────╯ + +RWX_COMMAND_ARGUMENT="${0}" +RWX_SHELL="$(cat "/proc/${$}/comm")" + +RWX_COMMAND_NAME="$(basename "${RWX_COMMAND_ARGUMENT}" | + sed "s|^-||")" +case "${RWX_COMMAND_NAME}" in +"bash" | "dash" | "sh") unset RWX_COMMAND_NAME ;; +*) ;; +esac +RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}" +RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}" + +RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" + +# ╭──────┬───────╮ +# │ main │ shell │ +# ╰──────┴───────╯ + +# test if active shell is in interactive mode +rwx_shell_interactive() { + case "${-}" in + *i*) ;; + *) return 1 ;; + esac +} + +# ╭──────┬─────╮ +# │ main │ log │ +# ╰──────┴─────╯ + +__rwx_log() { + if rwx_shell_interactive; then + [ ${#} -gt 0 ] || set -- "" + local line + for line in "${@}"; do + echo "${line}" + done + fi +} + +# ╭──────┬──────╮ +# │ main │ find │ +# ╰──────┴──────╯ + +# find directory’s files by extension +rwx_find_extension() { + local extension="${1}" + local root="${2}" + local file="${3}" + set -- \ + "${root}" \ + -name "*.${extension}" \ + -type "f" + [ -n "${file}" ] && + set -- "${@}" \ + -not \ + -name "${file}" + find "${@}" \ + -printf "%P\n" | + sort +} + +# find directory’s sh files +rwx_find_shell() { + rwx_find_extension "sh" "${@}" +} + +# ╭──────┬─────╮ +# │ main │ ifs │ +# ╰──────┴─────╯ + +rwx_ifs_set() { + _RWX_IFS="${IFS}" + IFS=" +" +} + +rwx_ifs_unset() { + IFS="${_RWX_IFS}" + unset RWX_IFS +} + +# ╭──────┬────────╮ +# │ main │ source │ +# ╰──────┴────────╯ + +rwx_source() { + local path="${1}" + [ -d "${path}" ] || + return 1 + local count module + count=0 + __rwx_log "" \ + ". ${path}" + rwx_ifs_set + for module in $(rwx_find_shell "${path}" "${RWX_MAIN_NAME}"); do + count=$((count + 1)) + __rwx_log "$(printf "%02d" "${count}") ${module%.sh}" + module="${path}/${module}" + # shellcheck disable=SC1090 + . "${module}" + done + rwx_ifs_unset +} + +# ╭──────╮ +# │ main │ +# ╰──────╯ + +# run initial steps +rwx_main() { + # system root + if ! rwx_source "${RWX_ROOT_SYSTEM}"; then + __rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}" + return 1 + fi + # user root + rwx_source "${RWX_SELF_USER}" + # context / command + if [ -n "${RWX_COMMAND_NAME}" ]; then + "${RWX_SELF_COMMAND}${RWX_COMMAND_NAME}" "${@}" + # context / shell + else + rwx_self_init + fi +} + +# run main function +rwx_main "${@}" diff --git a/sh/python.sh b/sh/python.sh new file mode 100644 index 0000000..44ea181 --- /dev/null +++ b/sh/python.sh @@ -0,0 +1,14 @@ +# ╭────────╮ +# │ python │ +# ╰────────╯ + +# ╭────────┬──────╮ +# │ python │ venv │ +# ╰────────┴──────╯ + +rwx_python_venv() { + local path="${1}" + [ -d "${path}" ] || return 1 + export VIRTUAL_ENV="${path}" && \ + export PATH="${VIRTUAL_ENV}/bin:${PATH}" +} diff --git a/sh/rescue/common.sh b/sh/rescue/common.sh new file mode 100644 index 0000000..4e2684a --- /dev/null +++ b/sh/rescue/common.sh @@ -0,0 +1,94 @@ +rwx_rescue_configure() { + local hostname="${1}" + # apt / conf + rwx_apt_conf_write + # apt / sources + rwx_apt_sources_write + # bash / rc + main_link_bashrc + mv "${HOME}/.bashrc" "${HOME}/.bashrc.old" + # host name + hostname "${hostname}" + # locales + printf "\ +en_US.UTF-8 UTF-8 +fr_FR.UTF-8 UTF-8 +" >"/etc/locale.gen" + # generate locales + locale-gen + # update catalog + rwx_apt_update + # disable frontend + rwx_debian_frontend_disable + # install backports + rwx_apt_install_backports "tmux" + # install packages + rwx_apt_install_release "apt-file" "mosh" "screen" "byobu" + # update catalog + rwx_apt_update +} + +rwx_rescue_install() { + # update catalog + rwx_apt_update + # disable frontend + rwx_debian_frontend_disable + # upgrade packages + rwx_apt_upgrade + # install packages + rwx_apt_install_release \ + "man-db" \ + "dmidecode" "efibootmgr" "lshw" "pciutils" "usbutils" \ + "parted" "mdadm" "cryptsetup-bin" "lvm2" \ + "btrfs-progs" "dosfstools" "duperemove" "squashfs-tools" \ + "git" "micro" "nano" "python3" "rsync" "vim" \ + "exa" "lf" "ncdu" "nnn" "ranger" "tree" \ + "file" "htop" "iotop" "ipcalc" "libdigest-sha3-perl" "lsof" + # install backports + rwx_apt_install_backports \ + "grub-pc-bin" \ + \ + "grub-efi-amd64-bin" +} + +rwx_rescue_upload() { + local host="${1}" + local hostname="${2}" + if [ -n "${hostname}" ]; then + local user="root" + # + local user_host="${user}@${host}" + # remove fingerprints + ssh-keygen -R "${host}" + # copy ssh id + ssh-copy-id \ + -o "StrictHostKeyChecking=accept-new" \ + "${user_host}" + # upload root + rsync --delete --recursive \ + "$(dirname "${ENV}")" "${user_host}:/etc" + # call setup + # TODO variable + ssh "${user_host}" -- \ + ". \"${ENV}\" ; rwx_rescue_configure \"${hostname}\"" + # create session + ssh "${user_host}" -- byobu new-session -d + # send keys + ssh "${user_host}" -- byobu send-keys "rwx_rescue_install" "C-m" + # attach session + mosh "${user_host}" -- byobu attach-session + else + echo "host & hostname" + return 1 + fi +} + +rwx_rescue_wipe_1_zero() { + rwx_fs_wipe "/dev/mapper/crypt" "512M" +} + +rwx_rescue_wipe_3_close() { + umount "/media/boot" + umount "/media/crypt" && + cryptsetup luksClose "crypt" +} diff --git a/sh/rescue/hetzner.sh b/sh/rescue/hetzner.sh new file mode 100644 index 0000000..24d6bd0 --- /dev/null +++ b/sh/rescue/hetzner.sh @@ -0,0 +1,129 @@ +rwx_rescue_wipe_0_init_hetzner_8_8() { + local device + set \ + "/dev/sda" \ + "/dev/sdb" + local members + local number + local passphrase + # read passphrase + passphrase="$(rwx_read_passphrase)" + # warn + rwx_warn_wipe "${@}" + # + number=0 + for device in "${@}"; do + number=$((number + 1)) + echo + echo "#${number}: ${device}" + # + parted --script "${device}" \ + mktable gpt \ + unit "mib" \ + mkpart "crypt-${number}" 33282 7630885 \ + mkpart "boot-${number}" 514 33282 \ + mkpart "esp-${number}" 2 514 \ + set 3 esp on \ + mkpart "bios-${number}" 1 2 \ + set 4 bios_grub on + done + # + number=0 + for device in "${@}"; do + number=$((number + 1)) + echo + echo "#${number}: ${device}4" + # wipe bios + rwx_fs_wipe "${device}4" + done + # + number=0 + for device in "${@}"; do + number=$((number + 1)) + echo + echo "#${number}: ${device}3" + # format esp + rwx_fs_wipe "${device}3" "1M" + rwx_fs_make_fat "${device}3" "esp-${number}" "0000000${number}" + # mount esp + mkdir --parents "/media/esp/${number}" + mount "${device}3" "/media/esp/${number}" + done + # + number=0 + for device in "${@}"; do + number=$((number + 1)) + echo + echo "#${number}: ${device}2" + # wipe boot + rwx_fs_wipe "${device}2" "1G" 1 + done + # + members="" + for device in "${@}"; do + members="${members} ${device}2" + done + # LATER alternative + # shellcheck disable=SC2086 + rwx_fs_raid_create \ + "boot" "00000000:00000000:00000000:00000002" ${members} + # + rwx_fs_make_btrfs "/dev/md/boot" "boot" \ + "00000000-0000-0000-0000-00000000000b" + # mount boot + mkdir --parents "/media/boot" + mount \ + --options "autodefrag,compress-force=zstd" \ + "/dev/md/boot" "/media/boot" + # + number=0 + for device in "${@}"; do + number=$((number + 1)) + echo + echo "#${number}: ${device}1" + # wipe crypt head + rwx_fs_wipe "${device}1" "1G" 1 + done + # + members="" + for device in "${@}"; do + members="${members} ${device}1" + done + # LATER alternative + # shellcheck disable=SC2086 + rwx_fs_raid_create \ + "crypt" "00000000:00000000:00000000:00000001" ${members} + # encrypt + rwx_fs_luks_format "${passphrase}" "/dev/md/crypt" + # open + echo "${passphrase}" | + cryptsetup luksOpen "/dev/md/crypt" "crypt" + # passphrase + unset passphrase +} + +rwx_rescue_wipe_2_make_hetzner_8_8() { + local passphrase + # close + cryptsetup luksClose "crypt" + # read passphrase + passphrase="$(rwx_read_passphrase)" + # encrypt + rwx_fs_luks_format "${passphrase}" "/dev/md/crypt" + # open + echo "${passphrase}" | + cryptsetup luksOpen "/dev/md/crypt" "crypt" + # passphrase + unset passphrase + # format crypt + rwx_fs_make_btrfs "/dev/mapper/crypt" "crypt" \ + "00000000-0000-0000-0000-00000000000c" + # mount crypt + mkdir --parents "/media/crypt" + mount \ + --options "autodefrag,compress-force=zstd" \ + "/dev/mapper/crypt" "/media/crypt" + # make swap file + rwx_fs_make_btrfs_swap "/media/crypt/swap" "64g" \ + "00000000-0000-0000-0000-000000000005" +} diff --git a/sh/rescue/ovh.sh b/sh/rescue/ovh.sh new file mode 100644 index 0000000..b4120e2 --- /dev/null +++ b/sh/rescue/ovh.sh @@ -0,0 +1,71 @@ +rwx_rescue_wipe_0_init_ovh_vle2() { + local device="/dev/sdb" + local passphrase + # read passphrase + passphrase="$(rwx_read_passphrase)" + # warn + rwx_warn_wipe "${device}" + # + parted --script "${device}" \ + mktable gpt \ + unit "mib" \ + mkpart "crypt" 4610 40959 \ + mkpart "boot" 514 4610 \ + mkpart "esp" 2 514 \ + set 3 esp on \ + mkpart bios 1 2 \ + set 4 bios_grub on + # bios / wipe + rwx_fs_wipe "${device}4" + # esp / wipe + rwx_fs_wipe "${device}3" "1M" + # esp / format + rwx_fs_make_fat "${device}3" "esp" "00000001" + # esp / mount + mkdir --parents "/media/esp" + mount "${device}3" "/media/esp" + # boot / wipe + rwx_fs_wipe "${device}2" "1G" 1 + # boot / format + rwx_fs_make_btrfs "${device}2" "boot" \ + "00000000-0000-0000-0000-00000000000b" + # boot / mount + mkdir --parents "/media/boot" + mount --options "autodefrag,compress-force=zstd" \ + "${device}2" "/media/boot" + # crypt / wipe + rwx_fs_wipe "${device}1" "1G" 1 + # crypt / encrypt + rwx_fs_luks_format "${passphrase}" "${device}1" + # crypt / open + echo "${passphrase}" | + cryptsetup luksOpen "${device}1" "crypt" + # passphrase + unset passphrase +} + +rwx_rescue_wipe_2_make_ovh_vle2() { + local device="/dev/sdb" + local passphrase + # crypt / close + cryptsetup luksClose "crypt" + # read passphrase + passphrase="$(rwx_read_passphrase)" + # crypt / encrypt + rwx_fs_luks_format "${passphrase}" "${device}1" + # crypt / open + echo "${passphrase}" | + cryptsetup luksOpen "${device}1" "crypt" + # passphrase + unset passphrase + # crypt / format + rwx_fs_make_btrfs "/dev/mapper/crypt" "crypt" \ + "00000000-0000-0000-0000-00000000000c" + # crypt / mount + mkdir --parents "/media/crypt" + mount --options "autodefrag,compress-force=zstd" \ + "/dev/mapper/crypt" "/media/crypt" + # crypt / swap + rwx_fs_make_btrfs_swap "/media/crypt/swap" "4g" \ + "00000000-0000-0000-0000-000000000005" +} diff --git a/sh/self.sh b/sh/self.sh new file mode 100644 index 0000000..732e9c2 --- /dev/null +++ b/sh/self.sh @@ -0,0 +1,162 @@ +# meta doc +rwx_doc() { + local name="${1}" + [ -n "${name}" ] || return + local doc line module + rwx_ifs_set + for module in $(rwx_find_shell "${RWX_ROOT_SYSTEM}"); do + while read -r line; do + case "${line}" in + "#"*) doc="${doc}${line}" ;; + "${name}() {") + echo "${doc}" + return + ;; + *) doc="" ;; + esac + done <"${RWX_ROOT_SYSTEM}/${module}" + done + rwx_ifs_unset +} + +# ╭──────┬───────╮ +# │ self │ check │ +# ╰──────┴───────╯ + +# check source code +rwx_self_check() { + # check format + rwx_log + rwx_shfmt "${RWX_ROOT_SYSTEM}" + # check syntax + rwx_log + rwx_shellcheck "${RWX_ROOT_SYSTEM}" +} + +# ╭──────┬──────────╮ +# │ self │ commands │ +# ╰──────┴──────────╯ + +# get commands from root +rwx_self_commands() { + grep \ + --directories "recurse" \ + --no-filename \ + "^${RWX_SELF_COMMAND}" "${RWX_ROOT_SYSTEM}" | + cut --delimiter "(" --fields 1 | + sed "s|^${RWX_SELF_COMMAND}||" +} + +# ╭──────┬───────────╮ +# │ self │ functions │ +# ╰──────┴───────────╯ + +# get functions from root +rwx_self_functions() { + grep \ + --directories "recurse" \ + --no-filename \ + "()" "${RWX_ROOT_SYSTEM}" | + cut --delimiter "(" --fields 1 +} + +# ╭──────┬──────╮ +# │ self │ help │ +# ╰──────┴──────╯ + +# output help message +rwx_self_help() { + rwx_log \ + "rwx_… = functions" \ + " a__… = aliases" \ + " u__… = user" +} + +# ╭──────┬──────╮ +# │ self │ init │ +# ╰──────┴──────╯ + +rwx_self_init() { + # run interactive extras + if rwx_shell_interactive; then + # help + rwx_log + rwx_self_help + fi +} + +# ╭──────┬─────────╮ +# │ self │ install │ +# ╰──────┴─────────╯ + +_rwx_cmd_rwx_install() { rwx_self_install "${@}"; } +rwx_self_install() { + local target="${1}" + local command file root + # code + if [ -n "${target}" ]; then + root="${target}${RWX_ROOT_SYSTEM}" + rwx_remove "${root}" + cp --recursive "${RWX_ROOT_SYSTEM}" "${root}" + fi + # commands + root="${target}/usr/local/bin" + for command in $(rwx_self_commands); do + file="${root}/${command}" + rwx_remove "${file}" + rwx_link "${file}" "${RWX_MAIN_PATH}" + done + # sh + file="${target}/etc/profile.d/${RWX_SELF_NAME}.sh" + rwx_remove "${file}" + rwx_file_write "${file}" "\ +export ENV=\"${RWX_MAIN_PATH}\" +" + # bash + file="${target}/etc/bash.bashrc" + rwx_remove "${file}" + rwx_link "${file}" "${RWX_MAIN_PATH}" +} + +# ╭──────┬────────╮ +# │ self │ subset │ +# ╰──────┴────────╯ + +rwx_self_subset() { + local argument path + for argument in "${@}"; do + path="${RWX_ROOT_SYSTEM}/${argument}" + if [ -d "${path}" ]; then + local file + for file in $(rwx_find_shell "${path}"); do + echo "${argument}/${file}" + done + elif [ -f "${path}" ]; then + echo "${argument}" + fi + done +} + +# ╭──────┬───────╮ +# │ self │ write │ +# ╰──────┴───────╯ + +rwx_self_write() { + local target="${1}" + if [ -n "${target}" ]; then + shift + local file text + text="#! /usr/bin/env sh +" + rwx_ifs_set + for file in $(rwx_self_subset "${@}"); do + text="${text} +$(cat "${RWX_ROOT_SYSTEM}/${file}") +" + done + rwx_ifs_unset + rwx_file_write "${target}" "${text}" + rwx_shfmt "${target}" + rwx_shellcheck_file "${target}" + fi +} diff --git a/sh/shell.sh b/sh/shell.sh new file mode 100644 index 0000000..7e56658 --- /dev/null +++ b/sh/shell.sh @@ -0,0 +1,116 @@ +_rwx_shell_color() { + local code="${1}" + case "${RWX_SHELL}" in + "bash") + printf "\x01\e[0" + if [ -n "${code}" ]; then + printf "%s" ";${code}" + fi + printf "m\x02" + ;; + *) + printf "\033[" + if [ -n "${code}" ]; then + printf "%s" "${code}" + else + printf "0" + fi + printf "m" + ;; + esac +} +RWX_COLOR_BROWN="$(_rwx_shell_color 33)" +RWX_COLOR_CYAN="$(_rwx_shell_color 36)" +RWX_COLOR_DEFAULT="$(_rwx_shell_color)" +RWX_COLOR_GREEN="$(_rwx_shell_color 31)" +RWX_COLOR_MAGENTA="$(_rwx_shell_color 35)" +RWX_COLOR_RED="$(_rwx_shell_color 32)" + +rwx_shell_configure() { + [ -n "${ENV}" ] || ENV="${RWX_MAIN_PATH}" + export ENV + # prompt + PS1="\$(rwx_shell_prompt \${?})" + PS2="├ " + # specific + case "${RWX_SHELL}" in + "bash") + # completion + local root="/usr/share/bash-completion" + local file="bash_completion" + local path="${root}/${file}" + # shellcheck disable=SC1090 + [ -f "${path}" ] && . "${path}" + root="${root}/completions" + if [ -d "${root}" ]; then + set \ + "git" \ + "tar" + for file in "${@}"; do + path="${root}/${file}" + # shellcheck disable=SC1090 + [ -f "${path}" ] && . "${path}" + done + fi + # history + HISTCONTROL="ignorespace" + HISTSIZE=-1 + HISTTIMEFORMAT="%Y%m%d %H%M%S " + ;; + *) ;; + esac +} +rwx_shell_configure + +rwx_shell_prompt() { + local date host id + local code="${1}" + date="$(date +%H:%M:%S)" + local git + host="$(hostname)" + id="$(id --user)" + local path="${PWD}" + local user="${USER}" + local view="╰ " + # code + if [ "${code}" -ne 0 ]; then + view="${view}${RWX_COLOR_GREEN}" + else + view="${view}${RWX_COLOR_RED}" + fi + view="${view}${code}" + # date + view="${view}${RWX_COLOR_DEFAULT} @ " + view="${view}${RWX_COLOR_BROWN}${date}" + # git + if command -v "__git_ps1" >"/dev/null"; then + git="$(__git_ps1)" + if [ -n "${git}" ]; then + view="${view}${RWX_COLOR_DEFAULT} –${RWX_COLOR_MAGENTA}${git}" + fi + fi + # new + view="${view}\\n" + # path + view="${view}${RWX_COLOR_CYAN}${path}" + # new + view="${view}\\n" + # frame + view="${view}${RWX_COLOR_DEFAULT}╭ " + # user + if [ "${id}" -eq 0 ]; then + view="${view}${RWX_COLOR_GREEN}" + else + view="${view}${RWX_COLOR_RED}" + fi + view="${view}${user}" + # host + view="${view}${RWX_COLOR_DEFAULT} @ " + view="${view}${RWX_COLOR_BROWN}${host}" + # new + view="${view}\\n" + # prompt + view="${view}${RWX_COLOR_DEFAULT}${PS2}" + # print + printf "%b" "${view}" +} diff --git a/sh/tmux.sh b/sh/tmux.sh new file mode 100644 index 0000000..d9813e1 --- /dev/null +++ b/sh/tmux.sh @@ -0,0 +1,264 @@ +# ╭──────┬───────╮ +# │ tmux │ setup │ +# ╰──────┴───────╯ + +rwx_tmux_setup() { + local file + file="${HOME}/.tmux.conf" + rwx_file_write "${file}" "\ +# ╭────────╮ +# │ option │ +# ╰────────╯ + +# empty name for windows +set-option -g automatic-rename-format '#{pane_current_command}' +set-option -g automatic-rename on + +# first index number +set-option -g base-index 1 + +# display duration +set-option -g display-time 1536 + +# extend history limit +set-option -g history-limit 1048576 + +# style for messages +set-option -g message-style bg=red,fg=white + +# activity monitoring +set-window-option -g monitor-activity on + +# silence monitoring +set-window-option -g monitor-silence 0 + +# enable mouse actions +set-option -g mouse on + +# prefix with ^B or F12 +set-option -g prefix C-b +set-option -g prefix2 F12 + +# renumber windows after closing one +set-option -g renumber-windows on + +# enable title +set-option -g set-titles on + +# set title to working directory +set-option -g set-titles-string '\ +#{session_name}\ + - \ +#{window_index}∕#{session_windows} #{window_name}\ + - \ +#{pane_index}∕#{window_panes} #{pane_current_command}\ +' + +# ╭────────┬──────╮ +# │ option │ pane │ +# ╰────────┴──────╯ + +# first index number +set-option -g pane-base-index 1 + +# ╭────────┬──────┬────────╮ +# │ option │ pane │ border │ +# ╰────────┴──────┴────────╯ + +# active style +set-option -g pane-active-border-style fg=green + +# regular style +set-option -g pane-border-style fg=blue + +# ╭────────┬────────╮ +# │ option │ status │ +# ╰────────┴────────╯ + +# status lines +set-option -g status 3 + +# background color +set-option -g status-bg '#0D0D0D' + +# foreground color +set-option -g status-fg white + +# line 1 +set-option -g status-format[0] '\ +#{W:\ +#[bg=##202020] #[bg=##303030]\ +#{?window_zoomed_flag,#[fg=magenta][, }\ +#[fg=yellow]#{window_index}\ +#{?window_zoomed_flag,#[fg=magenta]], }\ + \ +#{?window_active,#[fg=green],\ +#{?window_activity_flag,#[fg=red],#[fg=blue]}}\ +#{window_name}\ +#[bg=##303030] #[bg=##202020] \ +#[bg=default] \ +}\ +#[align=right]\ +#[bg=##202020] #[bg=##303030] \ +#[fg=yellow]%H:%M:%S\ +#[bg=##303030] #[bg=##202020]\ +#{?client_prefix,#[fg=green]p, }\ +' + +# line 2 +set-option -g status-format[1] '\ +#{S:\ +#[bg=##202020] #[bg=##303030] \ +#{?session_many_attached,#[fg=red],\ +#{?session_attached,#[fg=magenta],#[fg=blue]}}\ +#{session_name}\ +#[bg=##303030] #[bg=##202020] \ +#[bg=default] \ +}\ +#[fg=yellow]→ #[fg=green]#{session_name} \ +#[align=right]\ +#[bg=##202020] #[bg=##303030] \ +#[fg=yellow]%Y-%m-%d\ +#[bg=##303030] #[bg=##202020] \ +' + +# line 3 +set-option -g status-format[2] '\ +#[fg=cyan]#{pane_current_path}\ +#[align=right]\ +#[bg=##202020] #[bg=##303030] \ +#[fg=yellow]#{host}\ +#[bg=##303030] #[bg=##202020] \ +' + +# line 4 +set-option -g status-format[3] '\ +#{P:\ +#[bg=##202020] #[bg=##303030] \ +#[fg=yellow]#{pane_index}\ + \ +#{?pane_active,#[fg=green],#[fg=blue]}\ +#{pane_current_command}\ +#[bg=##303030] #[bg=##202020] \ +#[bg=default] \ +}\ +#[align=right]\ +#[bg=##202020] #[bg=##303030] \ +#{?uid,#[fg=green],#[fg=red]}\ +#{user}\ +#[bg=##303030] #[bg=##202020] \ +' + +# line 5 +set-option -g status-format[4] '\ +#{P:\ +#[bg=##202020] #[bg=##303030] \ +#[fg=yellow]#{pane_index}\ + \ +#{?pane_active,#[fg=green],#[fg=blue]}\ +#{pane_width}×#{pane_height}\ +#[bg=##303030] #[bg=##202020] \ +#[bg=default] \ +}\ +#[align=right]\ +#[bg=##202020] #[bg=##303030] \ +#[fg=green]#{window_width}×#{window_height}\ +#[bg=##303030] #[bg=##202020] \ +' + +# refresh period +set-option -g status-interval 1 + +# bar location +set-option -g status-position bottom + +# ╭─────╮ +# │ key │ +# ╰─────╯ + +# detach client +bind-key -n F6 detach-client + +# new window +bind-key -n F2 new-window + +# select pane +bind-key -n C-S-Down select-pane -D +bind-key -n C-S-Left select-pane -L +bind-key -n C-S-Right select-pane -R +bind-key -n C-S-Up select-pane -U + +# status lines +bind-key -n C-F10 set-option -g status off +bind-key -n C-F1 set-option -g status on +bind-key -n C-F2 set-option -g status 2 +bind-key -n C-F3 set-option -g status 3 +bind-key -n C-F4 set-option -g status 4 +bind-key -n C-F5 set-option -g status 5 + +# switch session +bind-key -n M-Down switch-client -n +bind-key -n M-Up switch-client -p + +# switch window +bind-key -n M-Left previous-window +bind-key -n M-Right next-window + +# ╭─────┬────────╮ +# │ key │ prefix │ +# ╰─────┴────────╯ + +# rename +bind-key C-s command-prompt { rename-session '%%' } +bind-key C-w command-prompt { rename-window '%%' } + +# split window +bind-key h split-window -h +bind-key v split-window -v + +# toggle mouse +bind-key t set-option -g mouse \\; display-message 'mouse = #{mouse}' + +# reload configuration +bind-key r source-file ${file} \\; display-message 'source-file ${file}' + +# swap window +bind-key M-Left swap-window -t -1 +bind-key M-Right swap-window -t +1 + +# ╭─────────────╮ +# │ default │ +# ╭───────────┬─────────┼─────┬───────┤ +# │ -n │ F12 │ -n │ C-b │ +# ╭───────────────────┼───────────┼─────────┼─────┼───────┤ +# │ command-prompt │ │ │ │ : │ +# │ copy-mode │ │ │ │ PPage │ +# │ detach-client │ │ │ │ d │ +# │ new-session │ │ │ │ │ +# │ new-window │ F2 │ │ │ c │ +# │ next-window │ M-Right │ │ │ n │ +# │ previous-window │ M-Left │ │ │ p │ +# │ rename-session │ │ C-s │ │ │ +# │ rename-window │ │ C-w │ │ │ +# │ resize-pane -Z │ │ │ │ z │ +# │ select-pane -D │ C-S-Down │ │ │ │ +# │ select-pane -L │ C-S-Left │ │ │ │ +# │ select-pane -R │ C-S-Right │ │ │ │ +# │ select-pane -U │ C-S-Up │ │ │ │ +# │ set -g mouse │ │ t │ │ │ +# │ set -g status off │ C-F10 │ │ │ │ +# │ set -g status on │ C-F1 │ │ │ │ +# │ set -g status 2 │ C-F2 │ │ │ │ +# │ set -g status 3 │ C-F3 │ │ │ │ +# │ set -g status 4 │ C-F4 │ │ │ │ +# │ set -g status 5 │ C-F5 │ │ │ │ +# │ source-file │ │ r │ │ │ +# │ split-window -h │ │ h │ │ % │ +# │ split-window -v │ │ v │ │ \" │ +# │ swap-window -t -1 │ │ M-Left │ │ │ +# │ swap-window -t +1 │ │ M-Right │ │ │ +# │ switch-client -n │ M-Down │ │ │ │ +# │ switch-client -p │ M-Up │ │ │ │ +# ╰───────────────────┴───────────┴─────────┴─────┴───────╯ +" +} diff --git a/sh/util.sh b/sh/util.sh new file mode 100644 index 0000000..cbcd67a --- /dev/null +++ b/sh/util.sh @@ -0,0 +1,76 @@ +rwx_file_append() { + local file="${1}" + local text="${2}" + if [ -n "${file}" ]; then + printf "%s" "${text}" >>"${file}" + fi +} + +rwx_file_empty() { + local file="${1}" + if [ -n "${file}" ]; then + rwx_file_write "${file}" "" + fi +} + +rwx_file_write() { + local file="${1}" + local text="${2}" + if [ -n "${file}" ]; then + printf "%s" "${text}" >"${file}" + fi +} + +rwx_link() { + local link="${1}" + local target="${2}" + ln \ + --symbolic \ + "${target}" \ + "${link}" +} + +rwx_list_block_devices() { + lsblk \ + --noempty \ + --output "NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINTS" +} + +rwx_not() { + case "${1}" in + "false") echo "true" ;; + "true") echo "false" ;; + *) ;; + esac +} + +rwx_read_passphrase() { + rwx_read_secret "PassPhrase: " +} + +rwx_read_secret() { + local prompt="${1}" + local secret + printf "%s" "${prompt}" 1>&2 + stty -echo + read -r secret + stty echo + echo >&2 + echo "${secret}" + unset secret +} + +rwx_remove() { + rm \ + --force \ + --recursive \ + "${@}" +} + +rwx_warn_wipe() { + local tmp + rwx_list_block_devices + printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\" + read -r tmp + rwx_log_trace "${tmp}" +}