diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md deleted file mode 100644 index a515b12e9..000000000 --- a/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,23 +0,0 @@ -### Operating System (OS/VERSION): - -Type here, e.g. CentOS 6 - -### VestaCP Version: - -Type here, e.g. 3.14159 - -### Installed Software (what you got with the installer): - -Type here, e.g. php-fpm, apache, nginx, mysql - -### Steps to Reproduce: - -Type here, e.g. install vesta and type rm -rf / --no-preserve-root - -### Related Issues/Forum Threads: - -Found anything that might be related to this? It might help us find the cause. - -### Other Notes: - -Anything else? diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 94a9ed024..000000000 --- a/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/bin/v-acknowledge-user-notification b/bin/v-acknowledge-user-notification deleted file mode 100755 index 19ea65f85..000000000 --- a/bin/v-acknowledge-user-notification +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -# info: update user notification -# options: USER NOTIFICATION -# -# The function updates user notification. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -nid=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER NOTIFICATION' -is_format_valid 'user' 'nid' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Updating notification -update_object_value 'notifications' 'NID' "$nid" '$ACK' 'yes' 2>/dev/null - -# Checking last notification -if [ -e "$USER_DATA/notifications.conf" ]; then - if [ -z "$(grep NID= $USER_DATA/notifications.conf)" ]; then - notice='no' - fi - if [ -z "$(grep "ACK='no'" $USER_DATA/notifications.conf)" ]; then - notice='no' - fi -else - notice='no' -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating notification counter -if [ "$notice" = 'no' ]; then - if [ -z "$(grep NOTIFICATIONS $USER_DATA/user.conf)" ]; then - sed -i "s/^TIME/NOTIFICATIONS='no'\nTIME/g" $USER_DATA/user.conf - else - update_user_value "$user" '$NOTIFICATIONS' "no" - fi -fi - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-activate-vesta-license b/bin/v-activate-vesta-license deleted file mode 100755 index fefed2027..000000000 --- a/bin/v-activate-vesta-license +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -# info: activate vesta license -# options: MODULE LICENSE -# -# The function activates and registers the vesta license - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -module=$(echo $1 | tr '[:lower:]' '[:upper:]') -license=$2 - -# Importing system environment -source /etc/profile - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking arg number -check_args '2' "$#" 'MODULE LICENSE' -is_user_format_valid "$license" "license" - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Activating license -v_host='https://vestacp.com/checkout' -answer=$(curl -s "$v_host/activate.php?licence_key=$license&module=$module") -check_result $? "cant' connect to vestacp.com " $E_CONNECT - -# Checking server answer -if [[ "$answer" != '0' ]]; then - echo "Error: $module license $license is invalid" - exit $E_INVALID -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating vesta.conf -if [ -z "$(grep "${module}_KEY" $VESTA/conf/vesta.conf)" ]; then - echo "${module}_KEY='$license'" >> $VESTA/conf/vesta.conf -else - sed -i "s/${module}_KEY=.*/${module}_KEY='$license'/g" $VESTA/conf/vesta.conf -fi - -# Activating sftpjail -if [ "$module" = 'SFTPJAIL' ]; then - setsid $BIN/v-add-sys-sftp-jail 2>/dev/null -fi - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-backup-host b/bin/v-add-backup-host deleted file mode 100755 index bccaa03ee..000000000 --- a/bin/v-add-backup-host +++ /dev/null @@ -1,200 +0,0 @@ -#!/bin/bash -# info: add backup host -# options: TYPE HOST USERNAME PASSWORD [PATH] [PORT] -# -# This function adds a backup host - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -type=$1 -host=$2 -user=$3 -password=$4; HIDE=4 -path=${5-/backup} -port=$6 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Defining ftp command function -ftpc() { - ftp -p -n $host $port <" { - if {\$count < \$argc} { - set arg [lindex \$argv \$count] - send "\$arg\r" - incr count - } else { - send "exit\r" - set output "Disconnected." - if {[info exists rc] != 1} { - set rc $OK - } - } - exp_continue - } - - timeout { - set output "Connection timeout." - set rc $E_CONNECT - } - } - - if {[info exists output] == 1} { - puts "\$output" - } - - exit \$rc -EOF -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -if [ "$type" != 'local' ];then - check_args '4' "$#" "TYPE HOST USERNAME PASSWORD [PATH] [PORT]" - is_format_valid 'user' 'host' 'path' 'port' - is_password_valid - if [ "$type" = 'sftp' ]; then - which expect >/dev/null 2>&1 - check_result $? "expect command not found" $E_NOTEXIST - fi - host "$host" >/dev/null 2>&1 - check_result $? "host connection failed" "$E_CONNECT" -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking network connection -if [ "$type" = 'ftp' ]; then - if [ -z $port ]; then - port=21 - fi - fconn=$(ftpc 2>&1) - ferror=$(echo $fconn |\ - grep -i -e failed -e error -e "can't" -e "not conn" -e "incorrect") - if [ ! -z "$ferror" ]; then - echo "Error: can't login to ftp $user@$host" - log_event "$E_CONNECT" "$ARGUMENTS" - exit $E_CONNECT - fi - - # Checking write permissions - if [ -z $path ]; then - ftmpdir="vst.bK76A9SUkt" - else - ftpc "mkdir $path" > /dev/null 2>&1 - ftmpdir="$path/vst.bK76A9SUkt" - fi - ftp_result=$(ftpc "mkdir $ftmpdir" "rm $ftmpdir"|grep -v Trying) - if [ ! -z "$ftp_result" ] ; then - echo "$ftp_result" - rm -rf $tmpdir - echo "Error: can't create $ftmpdir folder on the ftp" - log_event "$E_FTP" "$ARGUMENTS" - exit $E_FTP - fi -fi -if [ "$type" = 'sftp' ]; then - if [ -z $port ]; then - port=22 - fi - if [ -z $path ]; then - sftmpdir="vst.bK76A9SUkt" - sftpc "mkdir $sftmpdir" "rmdir $sftmpdir" > /dev/null 2>&1 - else - if sftpc "mkdir $path" > /dev/null 2>&1 ; then - sftmpdir="$path/vst.bK76A9SUkt" - sftpc "mkdir $sftmpdir" "rmdir $sftmpdir" > /dev/null 2>&1 - else - sftmpdir="$path/vst.bK76A9SUkt" - sftpc "mkdir $sftmpdir" "rmdir $sftmpdir" > /dev/null 2>&1 - fi - fi - rc=$? - if [[ "$rc" != 0 ]]; then - case $rc in - $E_CONNECT) echo "Error: can't login to sftp $user@$host";; - $E_FTP) echo "Error: can't create temp folder on the sftp host";; - esac - log_event "$rc" "$ARGUMENTS" - exit "$rc" - fi -fi - - -# Adding backup host -if [ $type != 'local' ]; then - time_n_date=$(date +'%T %F') - time=$(echo "$time_n_date" |cut -f 1 -d \ ) - date=$(echo "$time_n_date" |cut -f 2 -d \ ) - str="HOST='$host'\nUSERNAME='$user'\nPASSWORD='$password'" - str="$str\nBPATH='$path'\nPORT='$port'\nTIME='$time'\nDATE='$date'" - echo -e "$str" > $VESTA/conf/$type.backup.conf - chmod 660 $VESTA/conf/$type.backup.conf -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update vesta.conf -if [ -z "$(grep BACKUP_SYSTEM $VESTA/conf/vesta.conf)" ]; then - echo "BACKUP_SYSTEM='$type'" >> $VESTA/conf/vesta.conf -else - bckp=$(echo "$BACKUP_SYSTEM,$type" |\ - sed "s/,/\n/g"|\ - sort -r -u |\ - sed "/^$/d"|\ - sed ':a;N;$!ba;s/\n/,/g') - sed -i "s/BACKUP_SYSTEM=.*/BACKUP_SYSTEM='$bckp'/g" $VESTA/conf/vesta.conf -fi - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-cron-job b/bin/v-add-cron-job deleted file mode 100755 index 6b67eab43..000000000 --- a/bin/v-add-cron-job +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash -# info: add cron job -# options: USER MIN HOUR DAY MONTH WDAY COMMAND [JOB] [RESTART] -# -# The function adds a job to cron daemon. When executing commands, any output -# is mailed to user's email if parameter REPORTS is set to 'yes'. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -min=$2 -hour=$3 -day=$4 -month=$5 -wday=$6 -command=$(echo $7 |sed "s/'/%quote%/g") -job=$8 -restart=$9 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -HIDE=7 - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '7' "$#" 'USER MIN HOUR DAY MONTH WDAY COMMAND [JOB] [RESTART]' -is_format_valid 'user' 'min' 'hour' 'day' 'month' 'wday' 'command' -is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_package_full 'CRON_JOBS' -get_next_cronjob -is_format_valid 'job' -is_object_new 'cron' 'JOB' "$job" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Concatenating cron string -str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'" -str="$str CMD='$command' SUSPENDED='no' TIME='$time' DATE='$date'" - -# Adding to crontab -echo "$str" >> $VESTA/data/users/$user/cron.conf - -# Changing permissions -chmod 660 $VESTA/data/users/$user/cron.conf - -# Sort jobs by id number -sort_cron_jobs - -# Sync cronjobs with system crond -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing cron value -increase_user_value $user '$U_CRON_JOBS' - -# Restarting crond -$BIN/v-restart-cron -check_result $? "Cron restart failed" >/dev/null - -# Logging -log_history "added cron job $job" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-cron-letsencrypt-job b/bin/v-add-cron-letsencrypt-job deleted file mode 100755 index 19b6de7c8..000000000 --- a/bin/v-add-cron-letsencrypt-job +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# info: add letsencrypt cronjob -# options: NONE -# -# The script for enabling letsencrypt cronjob - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Add cron job -cmd="sudo /usr/local/vesta/bin/v-update-sys-queue letsencrypt" -check_cron=$(grep "$cmd" $VESTA/data/users/admin/cron.conf 2> /dev/null) -if [ -z "$check_cron" ] && [ ! -z "$CRON_SYSTEM" ]; then - $BIN/v-add-cron-job admin '*/5' '*' '*' '*' '*' "$cmd" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-cron-reports b/bin/v-add-cron-reports deleted file mode 100755 index df7859054..000000000 --- a/bin/v-add-cron-reports +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# info: add cron reports -# options: user -# -# The script for enabling reports on cron tasks and administrative -# notifications. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing user report value -update_user_value "$user" '$CRON_REPORTS' 'yes' - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -$BIN/v-restart-cron -check_result $? "Cron restart failed" >/dev/null - -# Logging -log_history "enabled cron reporting" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-cron-restart-job b/bin/v-add-cron-restart-job deleted file mode 100755 index 9b0612655..000000000 --- a/bin/v-add-cron-restart-job +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# info: add cron reports -# options: NONE -# -# The script for enabling restart cron tasks - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Add cron job -cmd="sudo /usr/local/vesta/bin/v-update-sys-queue restart" -check_cron=$(grep "$cmd" $VESTA/data/users/admin/cron.conf 2> /dev/null) -if [ -z "$check_cron" ] && [ ! -z "$CRON_SYSTEM" ]; then - $BIN/v-add-cron-job admin '*' '*' '*' '*' '*' "$cmd" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-cron-vesta-autoupdate b/bin/v-add-cron-vesta-autoupdate deleted file mode 100755 index 8b8d13677..000000000 --- a/bin/v-add-cron-vesta-autoupdate +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash -# info: add cron job for vesta autoupdates -# options: NONE -# -# The function adds cronjob for vesta autoupdate. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=admin - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM' -is_package_full 'CRON_JOBS' -get_next_cronjob -check_cron=$(grep 'v-update-sys-vesta-all' $USER_DATA/cron.conf) -if [ ! -z "$check_cron" ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Define time somewhere at night -min=$(generate_password '012345' '2') -hour=$(generate_password '1234567' '1') -day='*' -month='*' -wday='*' -command='sudo /usr/local/vesta/bin/v-update-sys-vesta-all' - -# Concatenating cron string -str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'" -str="$str CMD='$command' SUSPENDED='no' TIME='$time' DATE='$date'" - -# Adding to crontab -echo "$str" >> $VESTA/data/users/$user/cron.conf - -# Chaning permissions -chmod 660 $VESTA/data/users/$user/cron.conf - -# Sort jobs by id number -sort_cron_jobs - -# Sync cronjobs with system crond -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing cron value -increase_user_value $user '$U_CRON_JOBS' - -# Restarting crond -$BIN/v-restart-cron -check_result $? "Cron restart failed" >/dev/null - -# Logging -log_history "added cron job $job" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-database b/bin/v-add-database deleted file mode 100755 index 438b473ec..000000000 --- a/bin/v-add-database +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash -# info: add database -# options: USER DATABASE DBUSER DBPASS [TYPE] [HOST] [CHARSET] -# -# The function creates the database concatenating username and user_db. -# Supported types of databases you can get using v-list-sys-config script. -# If the host isn't stated and there are few hosts configured on the server, -# then the host will be defined by one of three algorithms. "First" will choose -# the first host in the list. "Random" will chose the host by a chance. -# "Weight" will distribute new database through hosts evenly. Algorithm and -# types of supported databases is designated in the main configuration file. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -database="$user"_"$2" -dbuser="$user"_"$3" -password=$4; HIDE=4 -type=${5-mysql} -host=$6 -charset=${7-UTF8} -charset=$(echo "$charset" |tr '[:lower:]' '[:upper:]') - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/db.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DATABASE DBUSER DBPASS [TYPE] [HOST] [CHARSET]' -is_format_valid 'user' 'database' 'dbuser' 'charset' -is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -is_type_valid "$DB_SYSTEM" "$type" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_new 'db' 'DB' "$database" -get_next_dbhost -is_object_valid "../../../conf/$type" 'HOST' "$host" -is_object_unsuspended "../../../conf/$type" 'DBHOST' "$host" -#is_charset_valid -is_package_full 'DATABASES' -is_password_valid -dbpass="$password" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on db type -case $type in - mysql) add_mysql_database ;; - pgsql) add_pgsql_database ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Adding db to db conf -str="DB='$database' DBUSER='$dbuser' MD5='$md5' HOST='$host' TYPE='$type'" -str="$str CHARSET='$charset' U_DISK='0' SUSPENDED='no' TIME='$time'" -str="$str DATE='$date'" -echo "$str" >> $USER_DATA/db.conf -chmod 660 $USER_DATA/db.conf - -# Increasing counters -increase_dbhost_values -increase_user_value "$user" '$U_DATABASES' - -# Logging -log_history "added $type database $database" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-database-host b/bin/v-add-database-host deleted file mode 100755 index c7b23ddfb..000000000 --- a/bin/v-add-database-host +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash -# info: add new database server -# options: TYPE HOST DBUSER DBPASS [MAX_DB] [CHARSETS] [TEMPLATE] -# -# The function add new database server to the server pool. It supports local -# and remote database servers, which is useful for clusters. By adding a host -# you can set limit for number of databases on a host. Template parameter is -# used only for PostgreSQL and has an default value "template1". You can read -# more about templates in official PostgreSQL documentation. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -type=$1 -host=$2 -dbuser=$3 -password=$4; HIDE=4 -max_db=${6-500} -charsets=${7-UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8} -template=${8-template1} - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/db.sh -source $VESTA/conf/vesta.conf - -is_mysql_host_alive() { - mycnf=$(mktemp) - echo "[client]">$mycnf - echo "host='$HOST'" >> $mycnf - echo "user='$USER'" >> $mycnf - echo "password='$PASSWORD'" >> $mycnf - chmod 600 $mycnf - mysql --defaults-file=$mycnf -e 'SELECT VERSION()' >/dev/null 2>&1 - rm $mycnf - if [ '0' -ne "$?" ]; then - echo "Error: MySQL connection to $host failed" - log_event "$E_CONNECT" "$ARGUMENTS" - exit $E_CONNECT - fi -} - -is_pgsql_host_alive() { - export PGPASSWORD="$dbpass" - psql -h $host -U $dbuser -c "SELECT VERSION()" > /dev/null 2>&1 - if [ '0' -ne "$?" ]; then - echo "Error: PostgreSQL connection to $host failed" - log_event "$E_CONNECT" "$ARGUMENTS" - exit $E_CONNECT - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -args_usage='TYPE HOST DBUSER DBPASS [MAX_DB] [CHARSETS] [TPL]' -check_args '4' "$#" "$args_usage" -is_format_valid 'host' 'dbuser' 'max_db' 'charsets' 'template' -#is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -#is_type_valid "$DB_SYSTEM" "$type" -is_dbhost_new -is_password_valid -dbpass="$password" -case $type in - mysql) is_mysql_host_alive ;; - pgsql) is_pgsql_host_alive ;; -esac - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Concatenating db host string -case $type in - mysql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass'"; - str="$str CHARSETS='$charsets' MAX_DB='$max_db' U_SYS_USERS=''"; - str="$str U_DB_BASES='0' SUSPENDED='no' TIME='$time' DATE='$date'";; - pgsql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass'"; - str="$str CHARSETS='$charsets' TPL='$template' MAX_DB='$max_db'"; - str="$str U_SYS_USERS='' U_DB_BASES='0' SUSPENDED='no'"; - str="$str TIME='$time' DATE='$date'";; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding host to conf -echo "$str" >> $VESTA/conf/$type.conf -chmod 660 $VESTA/conf/$type.conf - -# Updating vesta.conf -if [ -z "$(grep DB_SYSTEM $VESTA/conf/vesta.conf)" ]; then - echo "DB_SYSTEM='$type'" >> $VESTA/conf/vesta.conf -else - db=$(echo "$DB_SYSTEM,$type" |\ - sed "s/,/\n/g"|\ - sort -r -u |\ - sed "/^$/d"|\ - sed ':a;N;$!ba;s/\n/,/g') - sed -i "s/DB_SYSTEM=.*/DB_SYSTEM='$db'/g" $VESTA/conf/vesta.conf -fi - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-dns-domain b/bin/v-add-dns-domain deleted file mode 100755 index 17bdc4ae3..000000000 --- a/bin/v-add-dns-domain +++ /dev/null @@ -1,207 +0,0 @@ -#!/bin/bash -# info: add dns domain -# options: USER DOMAIN IP [NS1] [NS2] [NS3] [..] [NS8] [RESTART] -# -# The function adds DNS zone with records defined in the template. If the exp -# argument isn't stated, the expiration date value will be set to next year. -# The soa argument is responsible for the relevant record. By default the first -# user's NS server is used. TTL is set as common for the zone and for all of -# its records with a default value of 14400 seconds. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -ip=$3 -ns1=$4 -ns2=$5 -ns3=$6 -ns4=$7 -ns5=$8 -ns6=$9 -ns7=${10} -ns8=${11} -restart=${12} - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN IP [NS1] [NS2] [NS3] [..] [NS8] [RESTART]' -is_format_valid 'user' 'domain' 'ip' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_domain_new 'dns' "$domain" -is_package_full 'DNS_DOMAINS' -template=$(get_user_value '$DNS_TEMPLATE') -is_dns_template_valid $template - -if [ ! -z "$ns1" ]; then - ns1=$(echo $4 |sed -e 's/\.*$//g' -e 's/^\.*//g') - is_format_valid 'ns1' -fi -if [ ! -z "$ns2" ]; then - ns2=$(echo $5 |sed -e 's/\.*$//g' -e 's/^\.*//g') - is_format_valid 'ns2' -fi -if [ ! -z "$ns3" ]; then - ns3=$(echo $6 |sed -e 's/\.*$//g' -e 's/^\.*//g') - is_format_valid 'ns3' -fi -if [ ! -z "$ns4" ]; then - ns4=$(echo $7 |sed -e 's/\.*$//g' -e 's/^\.*//g') - is_format_valid 'ns4' -fi -if [ ! -z "$ns5" ]; then - ns5=$(echo $8 |sed -e 's/\.*$//g' -e 's/^\.*//g') - is_format_valid 'ns5' -fi -if [ ! -z "$ns6" ]; then - ns6=$(echo $9 |sed -e 's/\.*$//g' -e 's/^\.*//g') - is_format_valid 'ns6' -fi -if [ ! -z "$ns7" ]; then - ns7=$(echo ${10} |sed -e 's/\.*$//g' -e 's/^\.*//g') - is_format_valid 'ns7' -fi -if [ ! -z "$ns8" ]; then - ns8=$(echo ${11} |sed -e 's/\.*$//g' -e 's/^\.*//g') - is_format_valid 'ns8' -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining NS variables -if [ -z $ns2 ]; then - i=1 - ns=$(get_user_value '$NS') - for nameserver in ${ns//,/ };do - eval ns$i=$nameserver - (( ++i)) - done -fi -soa="$ns1" -exp=$(date +%F -d "+ 1 year") -serial=$(date +'%Y%m%d01') -ttl=14400 - -# Reading template -template_data=$(cat $DNSTPL/$template.tpl) - -# Deleting unused nameservers -if [ -z "$ns3" ]; then - template_data=$(echo "$template_data" |grep -v %ns3%) -fi -if [ -z "$ns4" ]; then - template_data=$(echo "$template_data" |grep -v %ns4%) -fi -if [ -z "$ns5" ]; then - template_data=$(echo "$template_data" |grep -v %ns5%) -fi -if [ -z "$ns6" ]; then - template_data=$(echo "$template_data" |grep -v %ns6%) -fi -if [ -z "$ns7" ]; then - template_data=$(echo "$template_data" |grep -v %ns7%) -fi -if [ -z "$ns8" ]; then - template_data=$(echo "$template_data" |grep -v %ns8%) -fi - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Adding dns zone to the user config -echo "$template_data" |\ - sed -e "s/%ip%/$ip/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%ns1%/$ns1/g" \ - -e "s/%ns2%/$ns2/g" \ - -e "s/%ns3%/$ns3/g" \ - -e "s/%ns4%/$ns4/g" \ - -e "s/%ns5%/$ns5/g" \ - -e "s/%ns6%/$ns6/g" \ - -e "s/%ns7%/$ns7/g" \ - -e "s/%ns8%/$ns8/g" \ - -e "s/%time%/$time/g" \ - -e "s/%date%/$date/g" > $USER_DATA/dns/$domain.conf - -chmod 660 $USER_DATA/dns/$domain.conf -records="$(wc -l $USER_DATA/dns/$domain.conf |cut -f 1 -d ' ')" - -# Adding dns.conf record -dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'" -dns_rec="$dns_rec SOA='$soa' SERIAL='$serial' SRC='' RECORDS='$records'" -dns_rec="$dns_rec SUSPENDED='no' TIME='$time' DATE='$date'" - -echo "$dns_rec" >> $USER_DATA/dns.conf -chmod 660 $USER_DATA/dns.conf - -# Creating system configs -if [[ "$DNS_SYSTEM" =~ named|bind ]]; then - if [ -e '/etc/named.conf' ]; then - dns_conf='/etc/named.conf' - dns_group='named' - else - dns_conf='/etc/bind/named.conf' - dns_group='bind' - fi - - # Adding zone in named.conf - named="zone \"$domain_idn\" {type master; file" - named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" - echo "$named" >> $dns_conf - - # Updating domain dns zone - update_domain_zone - - # Changing permissions - chmod 640 $HOMEDIR/$user/conf/dns/$domain.db - chown root:$dns_group $HOMEDIR/$user/conf/dns/$domain.db -fi - -# Updating dns-cluster queue -if [ ! -z "$DNS_CLUSTER" ]; then - cmd="$BIN/v-add-remote-dns-domain $user $domain yes" - echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing domain value -increase_user_value "$user" '$U_DNS_DOMAINS' -increase_user_value "$user" '$U_DNS_RECORDS' "$records" - -# Restart named -$BIN/v-restart-dns $restart -check_result $? "DNS restart failed" - -# Logging -log_history "added dns domain $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-dns-on-web-alias b/bin/v-add-dns-on-web-alias deleted file mode 100755 index 705594f34..000000000 --- a/bin/v-add-dns-on-web-alias +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# info: add dns domain or dns record after web domain alias -# options: USER ALIAS IP [RESTART] -# -# The function adds dns domain or dns record based on web domain alias. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -alias=$2 -ip=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER ALIAS IP [RESTART]' -is_format_valid 'user' 'alias' 'ip' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -if [ -e "$USER_DATA/dns/$alias.conf" ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -# Define additional vars -sub_domain=$(echo "$alias" |awk -F '.' '{print $1}') -top_domain=$(echo "$alias" |sed -e "s/^$sub_domain.//") -domain_lvl=$(echo "$alias" |grep -o "\." |wc -l) - -# Adding second level domain -if [ "$domain_lvl" -eq 1 ] || [ "${#top_domain}" -le '6' ]; then - $BIN/v-add-dns-domain \ - $user $alias $ip '' '' '' '' '' '' '' '' $restart >> /dev/null - exit -fi - -# Adding top-level domain and then its sub -$BIN/v-add-dns-domain $user $top_domain $ip '' '' '' '' '' '' '' '' $restart >> /dev/null - -# Checking top-level domain -if [ ! -e "$USER_DATA/dns/$top_domain.conf" ]; then - exit -fi - -# Checking subdomain record -if [ "$sub_domain" == '*' ]; then - check_record=$(grep -w "RECORD='\*'" $USER_DATA/dns/$top_domain.conf) -else - check_record=$(grep -w "RECORD='$sub_domain'" $USER_DATA/dns/$top_domain.conf) -fi - -# Adding subdomain record -if [ -z "$check_record" ]; then - $BIN/v-add-dns-record \ - $user $top_domain "$sub_domain" A $ip '' '' $restart >> /dev/null -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No logging - -exit diff --git a/bin/v-add-dns-record b/bin/v-add-dns-record deleted file mode 100755 index bbf8edd8b..000000000 --- a/bin/v-add-dns-record +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/bash -# info: add dns record -# options: USER DOMAIN RECORD TYPE VALUE [PRIORITY] [ID] [RESTART] -# -# The call is used for adding new DNS record. Complex records of TXT, MX and -# SRV types can be used by a filling in the 'value' argument. The function also -# gets an id parameter for definition of certain record identifier or for the -# regulation of records. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -record=$(idn -t --quiet -u "$3" ) -record=$(echo "$record" | tr '[:upper:]' '[:lower:]') -rtype=$(echo "$4"| tr '[:lower:]' '[:upper:]') -dvalue=$(idn -t --quiet -u "$5" ) -priority=$6 -id=$7 -restart=$8 -if [ -z "$priority" ]; then - priority=10 -fi - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Null priority for none MX/SRV records -if [ "$rtype" != 'MX' ] && [ "$rtype" != 'SRV' ]; then - priority='' -fi - -# Add trailing dot at the end of NS/CNAME/MX/PTR/SRV record -if [[ $rtype =~ NS|CNAME|MX|PTR|SRV ]]; then - trailing_dot=$(echo $dvalue | grep "\.$") - if [ -z "$trailing_dot" ]; then - dvalue="$dvalue." - fi -fi - -if [ $rtype != "CAA" ]; then - dvalue=${dvalue//\"/} - - if [[ "$dvalue" =~ [\;[:space:]] ]]; then - dvalue='"'"$dvalue"'"' - fi -fi - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '5' "$#" 'USER DOMAIN RECORD TYPE VALUE [PRIORITY] [ID] [RESTART]' -is_format_valid 'user' 'domain' 'record' 'rtype' 'dvalue' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_package_full 'DNS_RECORDS' -get_next_dnsrecord -is_format_valid 'id' -is_object_new "dns/$domain" 'ID' "$id" -is_dns_fqnd "$rtype" "$dvalue" -is_dns_nameserver_valid "$domain" "$rtype" "$dvalue" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Adding record -zone="$USER_DATA/dns/$domain.conf" -dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' PRIORITY='$priority'" -dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$time' DATE='$date'" -echo "$dns_rec" >> $zone -chmod 660 $zone - -# Sorting records -sort_dns_records - -# Updating zone -if [[ "$DNS_SYSTEM" =~ named|bind ]]; then - update_domain_serial - update_domain_zone -fi - -# Updating dns-cluster queue -if [ ! -z "$DNS_CLUSTER" ]; then - # Check for first sync - dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe) - if [ -z "$dlock" ]; then - cmd="$BIN/v-add-remote-dns-record $user $domain $id" - echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update counters -records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')" -update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" -increase_user_value "$user" '$U_DNS_RECORDS' - -# Restart named -$BIN/v-restart-dns $restart -check_result $? $E_RESTART 'dns failed to restart' - -# Logging -log_history "added $rtype dns record $record for $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-domain b/bin/v-add-domain deleted file mode 100755 index e383481a6..000000000 --- a/bin/v-add-domain +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -# info: add web/dns/mail domain -# options: USER DOMAIN [IP] [RESTART] -# -# The function adds web/dns/mail domain to a server. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -ip=$3 -restart="${4-yes}" - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# -check_args '2' "$#" 'USER DOMAIN [IP] [RESTART]' -is_format_valid 'user' 'domain' -if [ ! -z "$ip" ] ; then - is_format_valid 'ip' -fi -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get ip if it wasn't defined -if [ -z "$ip" ]; then - get_user_ip - if [ -z "$ip" ]; then - check_result $E_NOTEXIST "no avaiable IP address" - fi -fi - -# Working on web domain -if [ ! -z "$WEB_SYSTEM" ]; then - $BIN/v-add-web-domain $user $domain $ip 'no' - check_result $? "can't add web domain" >/dev/null -fi - -# Working on DNS domain -if [ ! -z "$DNS_SYSTEM" ]; then - $BIN/v-add-dns-domain $user $domain $ip "" "" "" "" "" '' '' '' 'no' - check_result $? "can't add dns domain" >/dev/null -fi - -# Working on mail domain -if [ ! -z "$MAIL_SYSTEM" ]; then - $BIN/v-add-mail-domain $user $domain - check_result $? "can't add mail domain" >/dev/null -fi - -# Restarting services -$BIN/v-restart-web $restart -check_result $? "can't restart web" > /dev/null - -$BIN/v-restart-proxy $restart -check_result $? "can't restart proxy" > /dev/null - -$BIN/v-restart-dns $restart -check_result $? "can't restart dns" > /dev/null - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-add-firewall-ban b/bin/v-add-firewall-ban deleted file mode 100755 index a1eed13eb..000000000 --- a/bin/v-add-firewall-ban +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash -# info: add firewall blocking rule -# options: IP CHAIN -# -# The function adds new blocking rule to system firewall - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system variables -source /etc/profile - -# Argument definition -ip=$1 -chain=$(echo $2|tr '[:lower:]' '[:upper:]') - -# Defining absolute path for iptables and modprobe -iptables="/sbin/iptables" - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'IP CHAIN' -is_format_valid 'ip' 'chain' -is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking server ip -if [ -e "$VESTA/data/ips/$ip" ] || [ "$ip" = '127.0.0.1' ]; then - exit -fi - -# Checking ip exclusions -excludes="$VESTA/data/firewall/excludes.conf" -check_excludes=$(grep "^$ip$" $excludes 2>/dev/null) -if [ ! -z "$check_excludes" ]; then - exit -fi - -# Checking ip in banlist -conf="$VESTA/data/firewall/banlist.conf" -check_ip=$(grep "IP='$ip' CHAIN='$chain'" $conf 2>/dev/null) -if [ ! -z "$check_ip" ]; then - exit -fi - -# Adding chain -$BIN/v-add-firewall-chain $chain - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Adding ip to banlist -echo "IP='$ip' CHAIN='$chain' TIME='$time' DATE='$date'" >> $conf -$iptables -I fail2ban-$chain 1 -s $ip \ - -j REJECT --reject-with icmp-port-unreachable 2>/dev/null - -# Changing permissions -chmod 660 $conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-firewall-chain b/bin/v-add-firewall-chain deleted file mode 100755 index 0bac12da7..000000000 --- a/bin/v-add-firewall-chain +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# info: add firewall chain -# options: CHAIN [PORT] [PROTOCOL] [PROTOCOL] -# -# The function adds new rule to system firewall - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system variables -source /etc/profile - -# Argument definition -chain=$(echo $1 | tr '[:lower:]' '[:upper:]') -port=$2 -protocol=${4-TCP} -protocol=$(echo $protocol|tr '[:lower:]' '[:upper:]') - -# Defining absolute path to iptables -iptables="/sbin/iptables" - -# Get vesta port by reading nginx.conf -vestaport=$(grep 'listen' $VESTA/nginx/conf/nginx.conf | awk '{print $2}' | sed "s|;||") -if [ -z "$vestaport" ]; then - vestaport=8083 -fi - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'CHAIN [PORT] [PROTOCOL]' -is_format_valid 'chain' -is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking known chains -case $chain in - SSH) # Get ssh port by reading ssh config file. - sshport=$(grep '^Port ' /etc/ssh/sshd_config | head -1 | cut -d ' ' -f 2) - if [ -z "$sshport" ]; then - sshport=22 - fi - port=$sshport; - protocol=TCP ;; - FTP) port=21; protocol=TCP ;; - MAIL) port='25,465,587,2525,110,995,143,993'; protocol=TCP ;; - DNS) port=53; protocol=UDP ;; - WEB) port='80,443'; protocol=TCP ;; - DB) port='3306,5432'; protocol=TCP ;; - VESTA) port=$vestaport; protocol=TCP ;; - *) check_args '2' "$#" 'CHAIN PORT' ;; -esac - -# Adding chain -$iptables -N fail2ban-$chain 2>/dev/null -if [ $? -eq 0 ]; then - $iptables -A fail2ban-$chain -j RETURN - - # Adding multiport module - if [[ "$port" =~ ,|-|: ]] ; then - port_str="-m multiport --dports $port" - else - port_str="--dport $port" - fi - $iptables -I INPUT -p $protocol $port_str -j fail2ban-$chain -fi - -# Preserving chain -chains=$VESTA/data/firewall/chains.conf -check_chain=$(grep "CHAIN='$chain'" $chains 2>/dev/null) -if [ -z "$check_chain" ]; then - echo "CHAIN='$chain' PORT='$port' PROTOCOL='$protocol'" >> $chains -fi - -# Changing permissions -chmod 660 $chains - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-firewall-rule b/bin/v-add-firewall-rule deleted file mode 100755 index 6fb867d36..000000000 --- a/bin/v-add-firewall-rule +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash -# info: add firewall rule -# options: ACTION IP PORT [PROTOCOL] [COMMENT] [RULE] -# -# The function adds new rule to system firewall - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system variables -source /etc/profile - -# Argument definition -action=$(echo $1|tr '[:lower:]' '[:upper:]') -ip=$2 -port_ext=$3 -protocol=${4-TCP} -protocol=$(echo $protocol|tr '[:lower:]' '[:upper:]') -comment=$5 -rule=$6 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Get next firewall rule id -get_next_fw_rule() { - if [ -z "$rule" ]; then - curr_str=$(grep "RULE=" $VESTA/data/firewall/rules.conf |\ - cut -f 2 -d \' | sort -n | tail -n1) - rule="$((curr_str +1))" - fi -} - -sort_fw_rules() { - cat $VESTA/data/firewall/rules.conf |\ - sort -n -k 2 -t \' > $VESTA/data/firewall/rules.conf.tmp - mv -f $VESTA/data/firewall/rules.conf.tmp \ - $VESTA/data/firewall/rules.conf -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'ACTION IP PORT [PROTOCOL] [COMMENT] [RULE]' -is_format_valid 'action' 'protocol' 'port_ext' 'ip' -is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM' -get_next_fw_rule -is_format_valid 'rule' -is_object_new '../../data/firewall/rules' 'RULE' "$rule" -if [ ! -z "$comment" ]; then - is_format_valid 'comment' -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Concatenating rule -str="RULE='$rule' ACTION='$action' PROTOCOL='$protocol' PORT='$port_ext'" -str="$str IP='$ip' COMMENT='$comment' SUSPENDED='no'" -str="$str TIME='$time' DATE='$date'" - -# Adding to config -echo "$str" >> $VESTA/data/firewall/rules.conf - -# Changing permissions -chmod 660 $VESTA/data/firewall/rules.conf - -# Sorting firewall rules by id number -sort_fw_rules - -# Updating system firewall -$BIN/v-update-firewall - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-fs-archive b/bin/v-add-fs-archive deleted file mode 100755 index 20052b0f8..000000000 --- a/bin/v-add-fs-archive +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -# info: archive directory -# options: USER ARCHIVE SOURCE -# -# The function creates tar archive - -user=$1 -archive=$2 -src0=$3 - -# Checking arguments -if [ -z "$src0" ]; then - echo "Usage: USER ARCHIVE FILE [FILE_2] [FILE_3] [FILE ...]" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking user homedir -homedir=$(grep "^$user:" /etc/passwd |cut -f 6 -d :) -if [ -z $homedir ]; then - echo "Error: user home directory doesn't exist" - exit 12 -fi - -# Checking archive -if [ -e "$archive" ]; then - echo "Error: archive already exist $archive" - exit 1 -fi - -# Checking source path -IFS=$'\n' -i=1 -for src in $*; do - if [ "$i" -gt 2 ]; then - rpath=$(readlink -f "$src") - if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid source path $src" - exit 1 - fi - fi - ((i++)) -done - -i=1 -for src in $*; do - if [ "$i" -gt 2 ]; then - # Deleting leading home path - src=$(echo "$src"| sed -e "s|/home/$user/||") - - # Creating tar.gz archive - sudo -u $user tar -rf "${archive/.gz/}" -C /home/$user $src >\ - /dev/null 2>&1 - if [ "$?" -ne 0 ]; then - echo "Error: archive $archive was not created" - exit 3 - fi - fi - ((i++)) -done - -# Checking gzip -if [[ "$archive" =~ \.gz$ ]]; then - sudo -u $user gzip "${archive/.gz/}" >/dev/null 2>&1 - if [ "$?" -ne 0 ]; then - echo "Error: archive $archive was not gziped" - exit 3 - fi -fi - -exit diff --git a/bin/v-add-fs-directory b/bin/v-add-fs-directory deleted file mode 100755 index e507edf5a..000000000 --- a/bin/v-add-fs-directory +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# info: add directory -# options: USER DIRECTORY -# -# The function creates new directory on the file system - -user=$1 -dst_dir=$2 - -# Checking arguments -if [ -z "$dst_dir" ]; then - echo "Usage: USER DIRECTORY" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking user homedir -homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) -if [ -z $homedir ]; then - echo "Error: user home directory doesn't exist" - exit 12 -fi - -# Checking destination path -rpath=$(readlink -f "$dst_dir") -if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid destination path $dst_dir" - exit 2 -fi - -# Adding directory -sudo -u $user mkdir -p "$dst_dir" >/dev/null 2>&1 -if [ $? -ne 0 ]; then - echo "Error: directory $dst_dir was not created" - exit 3 -fi - -# Extiging -exit diff --git a/bin/v-add-fs-file b/bin/v-add-fs-file deleted file mode 100755 index cc1621ccc..000000000 --- a/bin/v-add-fs-file +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# info: add file -# options: USER FILE -# -# The function creates new files on file system - -user=$1 -dst_file=$2 - -# Checking arguments -if [ -z "$dst_file" ]; then - echo "Usage: USER FILE" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking user homedir -homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) -if [ -z $homedir ]; then - echo "Error: user home directory doesn't exist" - exit 12 -fi - -# Checking destination path -rpath=$(readlink -f "$dst_file") -if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid destination path $dst_dir" - exit 2 -fi - -# Creating file -sudo -u $user touch "$dst_file" >/dev/null 2>&1 -if [ $? -ne 0 ]; then - echo "Error: file $dst_file was not created" - exit 3 -fi - -# Exiting -exit diff --git a/bin/v-add-letsencrypt-domain b/bin/v-add-letsencrypt-domain deleted file mode 100755 index ed6e5e903..000000000 --- a/bin/v-add-letsencrypt-domain +++ /dev/null @@ -1,399 +0,0 @@ -#!/bin/bash -# info: check letsencrypt domain -# options: USER DOMAIN [ALIASES] -# -# The function check and validates domain with Let's Encript - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -aliases=$3 - -# LE API -API='https://acme-v02.api.letsencrypt.org' - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_identifier_idn() { - identifier_idn=$identifier - if [[ "$identifier_idn" = *[![:ascii:]]* ]]; then - identifier_idn=$(idn -t --quiet -a $identifier_idn) - fi -} - -# encode base64 -encode_base64() { - cat |base64 |tr '+/' '-_' |tr -d '\r\n=' -} - -# Let's Encrypt v2 curl function -query_le_v2() { - - protected='{"nonce": "'$3'",' - protected=''$protected' "url": "'$1'",' - protected=''$protected' "alg": "RS256", "kid": "'$KID'"}' - content="Content-Type: application/jose+json" - - payload_=$(echo -n "$2" |encode_base64) - protected_=$(echo -n "$protected" |encode_base64) - signature_=$(printf "%s" "$protected_.$payload_" |\ - openssl dgst -sha256 -binary -sign $USER_DATA/ssl/user.key |\ - encode_base64) - - post_data='{"protected":"'"$protected_"'",' - post_data=$post_data'"payload":"'"$payload_"'",' - post_data=$post_data'"signature":"'"$signature_"'"}' - - # Save http response to file passed as "$4" arg or print to stdout if not provided - # http response headers are always sent to stdout - local save_to_file=${4:-"/dev/stdout"} - curl --silent --dump-header /dev/stdout --data "$post_data" "$1" --header "$content" --output "$save_to_file" -} - - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [ALIASES]' -is_format_valid 'user' 'domain' 'aliases' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -get_domain_values 'web' - -echo "-----------------------------------------------------------------------------------" >> /usr/local/vesta/log/letsencrypt.log -echo "[$(date)] : v-add-letsencrypt-domain $domain [$aliases]" >> /usr/local/vesta/log/letsencrypt.log - -# check if alias is the letsencrypt wildcard domain, if not, make the normal checks -if [[ "$aliases" != "*.$domain" ]]; then - for alias in $(echo "$aliases" |tr ',' '\n' |sort -u); do - check_alias="$(echo $ALIAS |tr ',' '\n' |grep ^$alias$)" - if [ -z "$check_alias" ]; then - echo "[$(date)] : EXIT=domain alias $alias doesn't exist" >> /usr/local/vesta/log/letsencrypt.log - check_result $E_NOTEXIST "domain alias $alias doesn't exist" - fi - done -fi; - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Registering LetsEncrypt user account -echo "[$(date)] : v-add-letsencrypt-user $user" >> /usr/local/vesta/log/letsencrypt.log -$BIN/v-add-letsencrypt-user $user -echo "[$(date)] : result: $?" >> /usr/local/vesta/log/letsencrypt.log -if [ "$?" -ne 0 ]; then - touch $VESTA/data/queue/letsencrypt.pipe - sed -i "/ $domain /d" $VESTA/data/queue/letsencrypt.pipe - send_notice "LETSENCRYPT" "Account registration failed" - echo "[$(date)] : EXIT=LE account registration" >> /usr/local/vesta/log/letsencrypt.log - check_result $E_CONNECT "LE account registration" >/dev/null -fi - -# Parsing LetsEncrypt account data -source $USER_DATA/ssl/le.conf - -# Checking wildcard alias -if [ "$aliases" = "*.$domain" ]; then - echo "[$(date)] : Checking wildcard alias" >> /usr/local/vesta/log/letsencrypt.log - wildcard='yes' - proto="dns-01" - if [ ! -e "$VESTA/data/users/$user/dns/$domain.conf" ]; then - echo "[$(date)] : EXIT=DNS domain $domain doesn't exist" >> /usr/local/vesta/log/letsencrypt.log - check_result $E_NOTEXIST "DNS domain $domain doesn't exist" - fi -else - proto="http-01" -fi - -# Requesting nonce / STEP 1 -echo "[$(date)] : --- Requesting nonce / STEP 1 ---" >> /usr/local/vesta/log/letsencrypt.log -echo "[$(date)] : curl -s -I \"$API/directory\"" >> /usr/local/vesta/log/letsencrypt.log -answer=$(curl -s -I "$API/directory") -echo "[$(date)] : answer=$answer" >> /usr/local/vesta/log/letsencrypt.log -nonce=$(echo "$answer" |grep -i nonce |cut -f2 -d \ |tr -d '\r\n') -echo "[$(date)] : nonce=$nonce" >> /usr/local/vesta/log/letsencrypt.log -status=$(echo "$answer"|grep HTTP/ |tail -n1 |cut -f 2 -d ' ') -echo "[$(date)] : status=$status" >> /usr/local/vesta/log/letsencrypt.log -if [[ "$status" -ne 200 ]]; then - echo "[$(date)] : EXIT=Let's Encrypt nonce request status $status" >> /usr/local/vesta/log/letsencrypt.log - check_result $E_CONNECT "Let's Encrypt nonce request status $status" -fi - -# Placing new order / STEP 2 -echo "[$(date)] : --- Placing new order / STEP 2 ---" >> /usr/local/vesta/log/letsencrypt.log -url="$API/acme/new-order" -payload='{"identifiers":[' -for identifier in $(echo $domain,$aliases |tr ',' '\n' |sort -u); do - format_identifier_idn - payload=$payload'{"type":"dns","value":"'$identifier_idn'"},' -done -payload=$(echo "$payload"|sed "s/,$//") -payload=$payload']}' -echo "[$(date)] : payload=$payload" >> /usr/local/vesta/log/letsencrypt.log -echo "[$(date)] : query_le_v2 \"$url\" \"$payload\" \"$nonce\"" >> /usr/local/vesta/log/letsencrypt.log -answer=$(query_le_v2 "$url" "$payload" "$nonce") -echo "[$(date)] : answer=$answer" >> /usr/local/vesta/log/letsencrypt.log -nonce=$(echo "$answer" |grep -i nonce |cut -f2 -d \ |tr -d '\r\n') -echo "[$(date)] : nonce=$nonce" >> /usr/local/vesta/log/letsencrypt.log -authz=$(echo "$answer" |grep "acme/authz" |cut -f2 -d '"') -echo "[$(date)] : authz=$authz" >> /usr/local/vesta/log/letsencrypt.log -finalize=$(echo "$answer" |grep 'finalize":' |cut -f4 -d '"') -echo "[$(date)] : finalize=$finalize" >> /usr/local/vesta/log/letsencrypt.log -status=$(echo "$answer" |grep HTTP/ |tail -n1 |cut -f2 -d ' ') -echo "[$(date)] : status=$status" >> /usr/local/vesta/log/letsencrypt.log -if [[ "$status" -ne 201 ]]; then - echo "[$(date)] : EXIT=Let's Encrypt new auth status $status" >> /usr/local/vesta/log/letsencrypt.log - check_result $E_CONNECT "Let's Encrypt new auth status $status" -fi - -# Requesting authorization token / STEP 3 -echo "[$(date)] : --- Requesting authorization token / STEP 3 ---" >> /usr/local/vesta/log/letsencrypt.log -for auth in $authz; do - payload='' - echo "[$(date)] : for auth=$auth" >> /usr/local/vesta/log/letsencrypt.log - echo "[$(date)] : query_le_v2 \"$auth\" \"$payload\" \"$nonce\"" >> /usr/local/vesta/log/letsencrypt.log - answer=$(query_le_v2 "$auth" "$payload" "$nonce") - echo "[$(date)] : answer=$answer" >> /usr/local/vesta/log/letsencrypt.log - url=$(echo "$answer" |grep -A3 $proto |grep url |cut -f 4 -d \") - echo "[$(date)] : url=$url" >> /usr/local/vesta/log/letsencrypt.log - token=$(echo "$answer" |grep -A3 $proto |grep token |cut -f 4 -d \") - echo "[$(date)] : token=$token" >> /usr/local/vesta/log/letsencrypt.log - nonce=$(echo "$answer" |grep -i nonce |cut -f2 -d \ |tr -d '\r\n') - echo "[$(date)] : nonce=$nonce" >> /usr/local/vesta/log/letsencrypt.log - status=$(echo "$answer"|grep HTTP/ |tail -n1 |cut -f 2 -d ' ') - echo "[$(date)] : status=$status" >> /usr/local/vesta/log/letsencrypt.log - if [[ "$status" -ne 200 ]]; then - echo "[$(date)] : EXIT=Let's Encrypt acme/authz bad status $status" >> /usr/local/vesta/log/letsencrypt.log - check_result $E_CONNECT "Let's Encrypt acme/authz bad status $status" - fi - - # Configuring challenge / STEP 4 - echo "[$(date)] : --- Configuring challenge / STEP 4 ---" >> /usr/local/vesta/log/letsencrypt.log - echo "[$(date)] : wildcard=$wildcard" >> /usr/local/vesta/log/letsencrypt.log - if [ "$wildcard" = 'yes' ]; then - record=$(printf "%s" "$token.$THUMB" |\ - openssl dgst -sha256 -binary |encode_base64) - old_records=$($BIN/v-list-dns-records $user $domain plain|grep 'TXT') - old_records=$(echo "$old_records" |grep _acme-challenge |cut -f 1) - for old_record in $old_records; do - $BIN/v-delete-dns-record "$user" "$domain" "$old_record" - done - $BIN/v-add-dns-record "$user" "$domain" "_acme-challenge" "TXT" "$record" - exitstatus=$? - echo "[$(date)] : v-add-dns-record \"$user\" \"$domain\" \"_acme-challenge\" \"TXT\" \"$record\"" >> /usr/local/vesta/log/letsencrypt.log - if [ "$exitstatus" -ne 0 ]; then - echo "[$(date)] : EXIT=DNS _acme-challenge record wasn't created" >> /usr/local/vesta/log/letsencrypt.log - fi - check_result $exitstatus "DNS _acme-challenge record wasn't created" - else - if [ "$WEB_SYSTEM" = 'nginx' ] || [ ! -z "$PROXY_SYSTEM" ]; then - if [ -f "/usr/local/vesta/web/inc/nginx_proxy" ]; then - # if vesta is behind main nginx - well_known="$HOMEDIR/$user/web/$domain/public_html/.well-known" - acme_challenge="$well_known/acme-challenge" - mkdir -p $acme_challenge - echo "$token.$THUMB" > $acme_challenge/$token - echo "[$(date)] : in $acme_challenge/$token we put: $token.$THUMB" >> /usr/local/vesta/log/letsencrypt.log - chown -R $user:$user $well_known - else - # default nginx method - conf="$HOMEDIR/$user/conf/web/nginx.$domain.conf_letsencrypt" - sconf="$HOMEDIR/$user/conf/web/snginx.$domain.conf_letsencrypt" - # if [ ! -e "$conf" ]; then - echo 'location ~ "^/\.well-known/acme-challenge/(.*)$" {' \ - > $conf - echo ' default_type text/plain;' >> $conf - echo ' return 200 "$1.'$THUMB'";' >> $conf - echo '}' >> $conf - # fi - echo "[$(date)] : in $conf we put: $THUMB" >> /usr/local/vesta/log/letsencrypt.log - if [ ! -e "$sconf" ]; then - ln -s "$conf" "$sconf" - fi - echo "[$(date)] : v-restart-proxy" >> /usr/local/vesta/log/letsencrypt.log - $BIN/v-restart-proxy - if [ -z "$PROXY_SYSTEM" ]; then - # apache-less variant - echo "[$(date)] : v-restart-web" >> /usr/local/vesta/log/letsencrypt.log - $BIN/v-restart-web - fi - exitstatus=$? - if [ "$exitstatus" -ne 0 ]; then - echo "[$(date)] : EXIT=Proxy restart failed = $exitstatus" >> /usr/local/vesta/log/letsencrypt.log - fi - check_result $exitstatus "Proxy restart failed" >/dev/null - fi - else - well_known="$HOMEDIR/$user/web/$domain/public_html/.well-known" - acme_challenge="$well_known/acme-challenge" - mkdir -p $acme_challenge - echo "$token.$THUMB" > $acme_challenge/$token - chown -R $user:$user $well_known - echo "[$(date)] : in $acme_challenge/$token we put: $token.$THUMB" >> /usr/local/vesta/log/letsencrypt.log - # $BIN/v-restart-web - # check_result $? "Web restart failed" >/dev/null - fi - fi - - # Requesting ACME validation / STEP 5 - echo "[$(date)] : --- Requesting ACME validation / STEP 5 ---" >> /usr/local/vesta/log/letsencrypt.log - validation_check=$(echo "$answer" |grep '"valid"') - echo "[$(date)] : validation_check=$validation_check" >> /usr/local/vesta/log/letsencrypt.log - if [[ ! -z "$validation_check" ]]; then - validation='valid' - else - validation='pending' - fi - - # Doing pol check on status - i=1 - while [ "$validation" = 'pending' ]; do - echo "[$(date)] : - Doing pol check on status" >> /usr/local/vesta/log/letsencrypt.log - payload='{}' - echo "[$(date)] : query_le_v2 \"$url\" \"$payload\" \"$nonce\"" >> /usr/local/vesta/log/letsencrypt.log - answer=$(query_le_v2 "$url" "$payload" "$nonce") - echo "[$(date)] : answer=$answer" >> /usr/local/vesta/log/letsencrypt.log - validation=$(echo "$answer"|grep -A1 $proto |tail -n1|cut -f4 -d \") - echo "[$(date)] : validation=$validation" >> /usr/local/vesta/log/letsencrypt.log - nonce=$(echo "$answer" |grep -i nonce |cut -f2 -d \ |tr -d '\r\n') - echo "[$(date)] : nonce=$nonce" >> /usr/local/vesta/log/letsencrypt.log - status=$(echo "$answer"|grep HTTP/ |tail -n1 |cut -f 2 -d ' ') - echo "[$(date)] : status=$status" >> /usr/local/vesta/log/letsencrypt.log - if [[ "$status" -ne 200 ]]; then - echo "[$(date)] : EXIT=Let's Encrypt validation status $status" >> /usr/local/vesta/log/letsencrypt.log - check_result $E_CONNECT "Let's Encrypt validation status $status" - fi - - i=$((i + 1)) - if [ "$i" -gt 10 ]; then - echo "[$(date)] : EXIT=Let's Encrypt domain validation timeout" >> /usr/local/vesta/log/letsencrypt.log - check_result $E_CONNECT "Let's Encrypt domain validation timeout" - fi - sleeping=$((i*2)) - echo "[$(date)] : sleep $sleeping (i=$i)" >> /usr/local/vesta/log/letsencrypt.log - sleep $sleeping - done - if [ "$validation" = 'invalid' ]; then - echo "[$(date)] : EXIT=Let's Encrypt domain verification failed" >> /usr/local/vesta/log/letsencrypt.log - check_result $E_CONNECT "Let's Encrypt domain verification failed" - fi -done - - -# Generating new ssl certificate -ssl_dir=$($BIN/v-generate-ssl-cert "$domain" "info@$domain" "US" "California"\ - "San Francisco" "Vesta" "IT" "$aliases" |tail -n1 |awk '{print $2}') - -# Sending CSR to finalize order / STEP 6 -echo "[$(date)] : --- Sending CSR to finalize order / STEP 6 ---" >> /usr/local/vesta/log/letsencrypt.log - -csr=$(openssl req -in $ssl_dir/$domain.csr -outform DER |encode_base64) -payload='{"csr":"'$csr'"}' -echo "[$(date)] : query_le_v2 \"$finalize\" \"$payload\" \"$nonce\"" >> /usr/local/vesta/log/letsencrypt.log -answer=$(query_le_v2 "$finalize" "$payload" "$nonce") -echo "[$(date)] : answer=$answer" >> /usr/local/vesta/log/letsencrypt.log -nonce=$(echo "$answer" |grep -i nonce |cut -f2 -d \ |tr -d '\r\n') -echo "[$(date)] : nonce=$nonce" >> /usr/local/vesta/log/letsencrypt.log -status=$(echo "$answer"|grep HTTP/ |tail -n1 |cut -f 2 -d ' ') -echo "[$(date)] : status=$status" >> /usr/local/vesta/log/letsencrypt.log -certificate=$(echo "$answer"|grep 'certificate":' |cut -f4 -d '"') -echo "[$(date)] : certificate=$certificate" >> /usr/local/vesta/log/letsencrypt.log -if [[ "$status" -ne 200 ]]; then - echo "[$(date)] : EXIT=Let's Encrypt finalize bad status $status" >> /usr/local/vesta/log/letsencrypt.log - check_result $E_CONNECT "Let's Encrypt finalize bad status $status" -fi - -# Downloading signed certificate / STEP 7 -echo "[$(date)] : --- Downloading signed certificate / STEP 7 ---" >> /usr/local/vesta/log/letsencrypt.log -echo "[$(date)] : query_le_v2 \"$certificate\" \"\" \"$nonce\"" >> /usr/local/vesta/log/letsencrypt.log -answer=$(query_le_v2 "$certificate" "" "$nonce" "$ssl_dir/$domain.pem") -echo "[$(date)] : answer=$answer" >> /usr/local/vesta/log/letsencrypt.log -status=$(echo "$answer"|grep HTTP/ |tail -n1 |cut -f 2 -d ' ') -echo "[$(date)] : status=$status" >> /usr/local/vesta/log/letsencrypt.log -if [[ "$status" -ne 200 ]]; then - [ -d "$ssl_dir" ] && rm -rf "$ssl_dir" - echo "[$(date)] : EXIT=Let's Encrypt downloading signed cert failed status: $status" >> /usr/local/vesta/log/letsencrypt.log - check_result $E_NOTEXIST "Let's Encrypt downloading signed cert failed status: $status" -fi - -# Splitting up downloaded pem -# echo "[$(date)] : - Splitting up downloaded pem" >> /usr/local/vesta/log/letsencrypt.log -crt_end=$(grep -n 'END CERTIFICATE' $ssl_dir/$domain.pem |head -n1 |cut -f1 -d:) -# echo "[$(date)] : crt_end=$crt_end" >> /usr/local/vesta/log/letsencrypt.log -head -n $crt_end $ssl_dir/$domain.pem > $ssl_dir/$domain.crt - -pem_lines=$(wc -l $ssl_dir/$domain.pem |cut -f 1 -d ' ') -# echo "[$(date)] : pem_lines=$pem_lines" >> /usr/local/vesta/log/letsencrypt.log -ca_end=$(grep -n 'BEGIN CERTIFICATE' $ssl_dir/$domain.pem |tail -n1 |cut -f 1 -d :) -# echo "[$(date)] : ca_end=$ca_end" >> /usr/local/vesta/log/letsencrypt.log -ca_end=$(( pem_lines - crt_end + 1 )) -# echo "[$(date)] : ca_end=$ca_end" >> /usr/local/vesta/log/letsencrypt.log -tail -n $ca_end $ssl_dir/$domain.pem > $ssl_dir/$domain.ca - -# Temporary fix for double "END CERTIFICATE" -if [[ $(head -n 1 $ssl_dir/$domain.ca) = "-----END CERTIFICATE-----" ]]; then - sed -i '1,2d' $ssl_dir/$domain.ca -fi - -# Adding SSL -ssl_home=$(search_objects 'web' 'LETSENCRYPT' 'yes' 'SSL_HOME') -$BIN/v-delete-web-domain-ssl $user $domain >/dev/null 2>&1 -echo "[$(date)] : v-add-web-domain-ssl $user $domain $ssl_dir $ssl_home" >> /usr/local/vesta/log/letsencrypt.log -$BIN/v-add-web-domain-ssl $user $domain $ssl_dir $ssl_home -exitstatus=$? -echo "[$(date)] : v-add-web-domain-ssl status: $exitstatus" >> /usr/local/vesta/log/letsencrypt.log -if [ "$exitstatus" -ne '0' ]; then - touch $VESTA/data/queue/letsencrypt.pipe - sed -i "/ $domain /d" $VESTA/data/queue/letsencrypt.pipe - echo "[$(date)] : EXIT=$domain certificate installation failed" >> /usr/local/vesta/log/letsencrypt.log - send_notice 'LETSENCRYPT' "$domain certificate installation failed" - check_result $exitstatus "SSL install" >/dev/null -fi - -# Adding LE autorenew cronjob -if [ -z "$(grep v-update-lets $VESTA/data/users/admin/cron.conf)" ]; then - min=$(generate_password '012345' '2') - hour=$(generate_password '1234567' '1') - cmd="sudo $BIN/v-update-letsencrypt-ssl" - $BIN/v-add-cron-job admin "$min" "$hour" '*' '*' '*' "$cmd" > /dev/null -fi - -# Updating letsencrypt key -if [ -z "$LETSENCRYPT" ]; then - add_object_key "web" 'DOMAIN' "$domain" 'LETSENCRYPT' 'FTP_USER' -fi -update_object_value 'web' 'DOMAIN' "$domain" '$LETSENCRYPT' 'yes' - -reset_web_counter "$user" "$domain" 'LETSENCRYPT_FAIL_COUNT' - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Deleteing task from queue -touch $VESTA/data/queue/letsencrypt.pipe -sed -i "/ $domain /d" $VESTA/data/queue/letsencrypt.pipe - -# Notifying user -send_notice 'LETSENCRYPT' "$domain SSL has been installed successfully" -echo "[$(date)] : EXIT=***** $domain SSL has been installed successfully *****" >> /usr/local/vesta/log/letsencrypt.log - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-letsencrypt-user b/bin/v-add-letsencrypt-user deleted file mode 100755 index 11aec113b..000000000 --- a/bin/v-add-letsencrypt-user +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/bash -# info: register letsencrypt user account -# options: USER -# -# The function creates and register LetsEncript account - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# LE API -API='https://acme-v02.api.letsencrypt.org' - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# encode base64 -encode_base64() { - cat |base64 |tr '+/' '-_' |tr -d '\r\n=' -} - -# Let's Encrypt v2 curl function -query_le_v2() { - protected='{"nonce": "'$3'",' - protected=''$protected' "url": "'$1'",' - protected=''$protected' "alg": "RS256", "jwk": '$jwk'}' - content="Content-Type: application/jose+json" - - payload_=$(echo -n "$2" |encode_base64) - protected_=$(echo -n "$protected" |encode_base64) - signature_=$(printf "%s" "$protected_.$payload_" |\ - openssl dgst -sha256 -binary -sign $USER_DATA/ssl/user.key |\ - encode_base64) - - post_data='{"protected":"'"$protected_"'",' - post_data=$post_data'"payload":"'"$payload_"'",' - post_data=$post_data'"signature":"'"$signature_"'"}' - - curl -s -i -d "$post_data" "$1" -H "$content" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" -if [ -e "$USER_DATA/ssl/le.conf" ]; then - source "$USER_DATA/ssl/le.conf" -fi -if [ ! -z "$KID" ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - - -# Defining user email -if [[ -z "$EMAIL" ]]; then - EMAIL=$(get_user_value '$CONTACT') -fi - -# Defining user agreement -agreement='' - -# Generating user key -KEY="$USER_DATA/ssl/user.key" -if [ ! -e "$KEY" ]; then - openssl genrsa -out $KEY 4096 >/dev/null 2>&1 - chmod 600 $KEY -fi - -# Defining key exponent -if [ -z "$EXPONENT" ]; then - EXPONENT=$(openssl pkey -inform pem -in "$KEY" -noout -text_pub |\ - grep Exponent: |cut -f 2 -d '(' |cut -f 1 -d ')' |sed -e 's/x//' |\ - xxd -r -p |encode_base64) -fi - -# Defining key modulus -if [ -z "$MODULUS" ]; then - MODULUS=$(openssl rsa -in "$KEY" -modulus -noout |\ - sed -e 's/^Modulus=//' |xxd -r -p |encode_base64) -fi - -# Defining JWK -jwk='{"e":"'$EXPONENT'","kty":"RSA","n":"'"$MODULUS"'"}' - -# Defining key thumbnail -if [ -z "$THUMB" ]; then - THUMB="$(echo -n "$jwk" |openssl dgst -sha256 -binary |encode_base64)" -fi - - -# Requesting ACME nonce -nonce=$(curl -s -I "$API/directory" |grep -i nonce |cut -f2 -d\ |tr -d '\r\n') - -# Creating ACME account -url="$API/acme/new-acct" -payload='{"termsOfServiceAgreed": true}' -answer=$(query_le_v2 "$url" "$payload" "$nonce") -kid=$(echo "$answer" |grep -i location: |cut -f2 -d ' '|tr -d '\r') - -# Checking answer status -status=$(echo "$answer" |grep HTTP/ |tail -n1 |cut -f2 -d ' ') -if [[ "${status:0:2}" -ne "20" ]]; then - check_result $E_CONNECT "Let's Encrypt acc registration failed $status" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding le.conf -if [ ! -e "$USER_DATA/ssl/le.conf" ]; then - echo "EXPONENT='$EXPONENT'" > $USER_DATA/ssl/le.conf - echo "MODULUS='$MODULUS'" >> $USER_DATA/ssl/le.conf - echo "THUMB='$THUMB'" >> $USER_DATA/ssl/le.conf - echo "EMAIL='$EMAIL'" >> $USER_DATA/ssl/le.conf - echo "KID='$kid'" >> $USER_DATA/ssl/le.conf - chmod 660 $USER_DATA/ssl/le.conf -else - sed -i '/^KID=/d' $USER_DATA/ssl/le.conf - echo "KID='$kid'" >> $USER_DATA/ssl/le.conf -fi - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-mail-account b/bin/v-add-mail-account deleted file mode 100755 index 44925680f..000000000 --- a/bin/v-add-mail-account +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/bash -# info: add mail domain account -# options: USER DOMAIN ACCOUNT PASSWORD [QUOTA] -# -# The function add new email account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -account=$3 -password=$4; HIDE=4 -quota=${5-unlimited} - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -if [[ "$account" =~ [[:upper:]] ]]; then - account=$(echo "$account" |tr '[:upper:]' '[:lower:]') -fi - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD [QUOTA]' -is_format_valid 'user' 'domain' 'account' -if [ "$quota" != 'unlimited' ]; then - is_format_valid 'quota' -fi -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_package_full 'MAIL_ACCOUNTS' -is_mail_new "$account" -is_password_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Generating hashed password -salt=$(generate_password "$PW_MATRIX" "8") -md5="{MD5}$($BIN/v-generate-password-hash md5 $salt <<<$password)" - -# Adding account info into password file -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - if [ "$quota" = 'unlimited' ]; then - quota='0' - fi - str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" - echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -if [[ "$quota" -eq '0' ]]; then - quota='unlimited' -fi - -str="ACCOUNT='$account' ALIAS='' AUTOREPLY='no' FWD='' FWD_ONLY=''" -str="$str MD5='$md5' QUOTA='$quota' U_DISK='0' SUSPENDED='no'" -str="$str TIME='$time' DATE='$date'" -echo "$str" >> $USER_DATA/mail/$domain.conf -chmod 660 $USER_DATA/mail/$domain.conf - -# Increase mail accounts counter -accounts=$(wc -l $USER_DATA/mail/$domain.conf | cut -f 1 -d ' ') -increase_user_value "$user" '$U_MAIL_ACCOUNTS' -update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accounts" - -# Logging -log_history "added mail account $account@$domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-mail-account-alias b/bin/v-add-mail-account-alias deleted file mode 100755 index 7c28f88d6..000000000 --- a/bin/v-add-mail-account-alias +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -# info: add mail account alias aka nickname -# options: USER DOMAIN ACCOUNT ALIAS -# -# The function add new email alias. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -account=$3 -malias=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ACCOUNT ALIAS' -is_format_valid 'user' 'domain' 'account' 'malias' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -is_mail_new "$malias" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding exim alias -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - str="$malias@$domain_idn:$account@$domain_idn" - echo "$str" >> $HOMEDIR/$user/conf/mail/$domain/aliases -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding vesta alias -aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') -if [ -z "$aliases" ]; then - aliases="$malias" -else - aliases="$aliases,$malias" -fi -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS' "$aliases" - -# Logging -log_history "added alias $malias to $account@$domain " -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-mail-account-autoreply b/bin/v-add-mail-account-autoreply deleted file mode 100755 index 86c8cf110..000000000 --- a/bin/v-add-mail-account-autoreply +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -# info: add mail account autoreply message -# options: USER DOMAIN ACCOUNT MESSAGE -# -# The function add new email account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -account=$3 -autoreply=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Define mail user -if [ "$MAIL_SYSTEM" = 'exim4' ]; then - MAIL_USER=Debian-exim -else - MAIL_USER=exim -fi - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ACCOUNT MESSAGE' -is_format_valid 'user' 'domain' 'account' 'autoreply' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -# is_object_value_empty "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding exim autoreply -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - msg="$HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg" - echo -e "$autoreply" > $msg - chown $MAIL_USER:mail $msg - chmod 660 $msg -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding autoreply message -echo -e "$autoreply" > $USER_DATA/mail/$account@$domain.msg -chmod 660 $USER_DATA/mail/$account@$domain.msg -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' 'yes' - -# Logging -log_history "added autoreply message on $account@$domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-mail-account-forward b/bin/v-add-mail-account-forward deleted file mode 100755 index 2e25d158d..000000000 --- a/bin/v-add-mail-account-forward +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -# info: add mail account forward address -# options: USER DOMAIN ACCOUNT FORWARD -# -# The function add new email account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -account=$3 -forward=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ACCOUNT FORWARD' -is_format_valid 'user' 'domain' 'account' 'forward' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD') -if [ ! -z "$(echo $fwd | grep -w $forward)" ]; then - echo "Error: forward $forward exists" - log_event "$E_EXISTS $ARGUMENTS" - exit $E_EXISTS -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Define fwd string -if [ -z "$fwd" ]; then - fwd="$forward" -else - fwd="$fwd,$forward" -fi - -# Adding forward to exim -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - sed -i "/^$account@$domain_idn:/ d" $HOMEDIR/$user/conf/mail/$domain/aliases - echo "$account@$domain_idn:$fwd" >> $HOMEDIR/$user/conf/mail/$domain/aliases -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD' "$fwd" - -# Logging -log_history "added forwarding from $account@$domain to $forward" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-mail-account-fwd-only b/bin/v-add-mail-account-fwd-only deleted file mode 100755 index 9a62805c8..000000000 --- a/bin/v-add-mail-account-fwd-only +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# info: add mail account forward-only flag -# options: USER DOMAIN ACCOUNT -# -# The function adds fwd-only flag - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -account=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Define mail user -if [ "$MAIL_SYSTEM" = 'exim4' ]; then - MAIL_USER=Debian-exim -else - MAIL_USER=exim -fi - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ACCOUNT' -is_format_valid 'user' 'domain' 'account' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD') -if [ -z "$fwd" ]; then - echo "Error: forward doesn't exist" - log_event "$E_NOTEXIST $ARGUMENTS" - exit $E_NOTEXIST -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding account to fwd_only -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - echo "$account" >> $HOMEDIR/$user/conf/mail/$domain/fwd_only - chown -R $MAIL_USER:mail $HOMEDIR/$user/conf/mail/$domain/fwd_only -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating config -add_object_key "mail/$domain" 'ACCOUNT' "$account" 'FWD_ONLY' 'MD5' -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD_ONLY' "yes" - -# Logging -log_history "added fwd_only flag for $account@$domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-mail-domain b/bin/v-add-mail-domain deleted file mode 100755 index 6681035ff..000000000 --- a/bin/v-add-mail-domain +++ /dev/null @@ -1,146 +0,0 @@ -#!/bin/bash -# info: add mail domain -# options: USER DOMAIN [ANTISPAM] [ANTIVIRUS] [DKIM] [DKIM_SIZE] -# -# The function adds MAIL domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -antispam=${3-yes} -antivirus=${4-yes} -dkim=${5-yes} -dkim_size=${6-1024} - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Define mail user -if [ "$MAIL_SYSTEM" = 'exim4' ]; then - MAIL_USER=Debian-exim -else - MAIL_USER=exim -fi - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [ANTISPAM] [ANTIVIRUS] [DKIM] [DKIM_SIZE]' -is_format_valid 'user' 'domain' 'antispam' 'antivirus' 'dkim' 'dkim_size' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_domain_new 'mail' "$domain" -is_package_full 'MAIL_DOMAINS' -is_dir_symlink $HOMEDIR/$user/mail - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Adding domain to mail.conf -s="DOMAIN='$domain' ANTIVIRUS='$antivirus' ANTISPAM='$antispam' DKIM='$dkim'" -s="$s CATCHALL='' ACCOUNTS='0' U_DISK='0' SUSPENDED='no' TIME='$time'" -s="$s DATE='$date'" -echo $s >> $USER_DATA/mail.conf -touch $USER_DATA/mail/$domain.conf - -# Generating DKIM keys -if [ "$dkim" = 'yes' ]; then - openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null - openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \ - -out $USER_DATA/mail/$domain.pub &>/dev/null -fi - -# Set permissions -chmod 660 $USER_DATA/mail/$domain.* -chmod 660 $USER_DATA/mail.conf - -# Building exim configs -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - mkdir $HOMEDIR/$user/conf/mail/$domain - mkdir $HOMEDIR/$user/mail/$domain_idn - touch $HOMEDIR/$user/conf/mail/$domain/aliases - touch $HOMEDIR/$user/conf/mail/$domain/passwd - touch $HOMEDIR/$user/conf/mail/$domain/fwd_only - ln -s $HOMEDIR/$user/conf/mail/$domain \ - /etc/$MAIL_SYSTEM/domains/$domain_idn - - # Adding antispam protection - if [ "$antispam" = 'yes' ]; then - touch $HOMEDIR/$user/conf/mail/$domain/antispam - fi - - # Adding antivirus protection - if [ "$antivirus" = 'yes' ]; then - touch $HOMEDIR/$user/conf/mail/$domain/antivirus - fi - - # Adding dkim support - if [ "$dkim" = 'yes' ]; then - cp -f $USER_DATA/mail/$domain.pem \ - $HOMEDIR/$user/conf/mail/$domain/dkim.pem - fi - - # Set permission - chmod 771 $HOMEDIR/$user/conf/mail/$domain - chmod 660 $HOMEDIR/$user/conf/mail/$domain/* - chmod 771 /etc/$MAIL_SYSTEM/domains/$domain_idn - chmod 770 $HOMEDIR/$user/mail/$domain_idn - - # Set ownership - chown -R $MAIL_USER:mail $HOMEDIR/$user/conf/mail/$domain - chown -R dovecot:mail $HOMEDIR/$user/conf/mail/$domain/passwd - chown $user:mail $HOMEDIR/$user/mail/$domain_idn -fi - -# Adding dkim dns records -if [ ! -z "$DNS_SYSTEM" ] && [ "$dkim" = 'yes' ]; then - check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") - if [ "$?" -eq 0 ]; then - p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n') - record='_domainkey' - policy="\"t=y; o=~;\"" - $BIN/v-add-dns-record $user $domain $record TXT "$policy" '' '' 'no' - - record='mail._domainkey' - selector="\"v=DKIM1\; k=rsa\; p=$p\"" - $BIN/v-add-dns-record $user $domain $record TXT "$selector" - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing domain value -increase_user_value "$user" '$U_MAIL_DOMAINS' -if [ "$dkim" = 'yes' ]; then - increase_user_value "$user" '$U_MAIL_DKMI' -fi - -# Logging -log_history "added mail domain $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-mail-domain-antispam b/bin/v-add-mail-domain-antispam deleted file mode 100755 index eb31404fa..000000000 --- a/bin/v-add-mail-domain-antispam +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# info: add mail domain antispam support -# options: USER DOMAIN -# -# The function enables spamassasin for incoming emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_empty 'mail' 'DOMAIN' "$domain" '$ANTISPAM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding antispam flag -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - touch $HOMEDIR/$user/conf/mail/$domain/antispam -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding antispam in config -update_object_value 'mail' 'DOMAIN' "$domain" '$ANTISPAM' 'yes' - -# Logging -log_history "enabled antispam on $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-mail-domain-antivirus b/bin/v-add-mail-domain-antivirus deleted file mode 100755 index 849107566..000000000 --- a/bin/v-add-mail-domain-antivirus +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# info: add mail domain antivirus support -# options: USER DOMAIN -# -# The function enables clamav scan for incoming emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_empty 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding antivirus flag -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - touch $HOMEDIR/$user/conf/mail/$domain/antivirus -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding antivirus in config -update_object_value 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' 'yes' - -# Logging -log_history "enabled antivirus on $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-mail-domain-catchall b/bin/v-add-mail-domain-catchall deleted file mode 100755 index a08976413..000000000 --- a/bin/v-add-mail-domain-catchall +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# info: add mail domain catchall account -# options: USER DOMAIN EMAIL -# -# The function enables catchall account for incoming emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -email="$3" - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN EMAIL' -is_format_valid 'user' 'domain' 'email' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_empty 'mail' 'DOMAIN' "$domain" '$CATCHALL' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding catchall alias -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - sed -i "/*@$domain_idn:/d" $HOMEDIR/$user/conf/mail/$domain/aliases - echo "*@$domain_idn:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding antispam in config -update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' "$email" - -# Logging -log_history "added $email as catchall email for $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-mail-domain-dkim b/bin/v-add-mail-domain-dkim deleted file mode 100755 index 9c643b6e9..000000000 --- a/bin/v-add-mail-domain-dkim +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -# info: add mail domain dkim support -# options: USER DOMAIN [DKIM_SIZE] -# -# The function adds DKIM signature to outgoing domain emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -dkim_size=${3-1024} - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Define mail user -if [ "$MAIL_SYSTEM" = 'exim4' ]; then - MAIL_USER=Debian-exim -else - MAIL_USER=exim -fi - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [DKIM_SIZE]' -is_format_valid 'user' 'domain' 'dkim_size' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_empty 'mail' 'DOMAIN' "$domain" '$DKIM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Generating dkim -openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null -openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \ - -out $USER_DATA/mail/$domain.pub &>/dev/null -chmod 660 $USER_DATA/mail/$domain.* - -# Adding dkim keys -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - cp $USER_DATA/mail/$domain.pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem - chown $MAIL_USER:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem - chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem -fi - -# Adding dns records -if [ ! -z "$DNS_SYSTEM" ] && [ -e "$USER_DATA/dns/$domain.conf" ]; then - p=$(cat $USER_DATA/mail/$domain.pub |grep -v ' KEY---' |tr -d '\n') - record="_domainkey" - policy="\"t=y; o=~;\"" - $BIN/v-add-dns-record $user $domain $record TXT "$policy" '' '' 'no' - - record="mail._domainkey" - selector="\"v=DKIM1\; k=rsa\; p=$p\"" - $BIN/v-add-dns-record $user $domain $record TXT "$selector" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding dkim in config -update_object_value 'mail' 'DOMAIN' "$domain" '$DKIM' 'yes' -increase_user_value "$user" '$U_MAIL_DKIM' - -# Logging -log_history "enabled DKIM support for $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-remote-dns-domain b/bin/v-add-remote-dns-domain deleted file mode 100755 index 2240bafde..000000000 --- a/bin/v-add-remote-dns-domain +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash -# info: add remote dns domain -# options: USER DOMAIN [FLUSH] -# -# The function synchronize dns domain with the remote server. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -flush=$3 - - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/remote.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FLUSH]' -is_format_valid 'user' 'domain' -is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER' -is_procces_running -remote_dns_health_check - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain record -str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf 2>/dev/null) -if [ -z "$str" ]; then - pipe="$VESTA/data/queue/dns-cluster.pipe" - queue_str=$(grep -n "$SCRIPT $1 $2 " $pipe |cut -f1 -d: |head -n1) - if [ ! -z "$queue_str" ]; then - sed -i "$queue_str d" $pipe - fi - exit -fi - -IFS=$'\n' -for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do - - # Parsing remote dns host parameters - eval $cluster - - # Parsing domain parameters - eval $str - - # Syncing domain data - cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME $flush 'no' - check_result $? "$HOST connection failed" $E_CONNECT - - # Syncing domain records - tmp_file="/tmp/vst-sync.$DOMAIN" - cluster_file $USER_DATA/dns/$DOMAIN.conf $tmp_file - check_result $? "$HOST connection failed" $E_CONNECT - - # Inserting synced records - cluster_cmd v-insert-dns-records $DNS_USER $DOMAIN $tmp_file 'no' - check_result $? "$HOST connection failed" $E_CONNECT - - # Rebuilding dns zone - cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no' - check_result $? "$HOST connection failed" $E_CONNECT -done - - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating pipe -rm -f $tmpfile -pipe="$VESTA/data/queue/dns-cluster.pipe" -str=$(grep -n "$SCRIPT $1 $2 " $pipe | cut -f1 -d: | head -n1) -if [ ! -z "$str" ]; then - sed -i "$str d" $pipe -fi - -exit diff --git a/bin/v-add-remote-dns-host b/bin/v-add-remote-dns-host deleted file mode 100755 index 0c52f79b9..000000000 --- a/bin/v-add-remote-dns-host +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -# info: add new remote dns host -# options: HOST PORT USER PASSWORD [TYPE] [DNS_USER] -# -# The function adds remote dns server to the dns cluster. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -host=$1 -HOST=$host -port=$2 -PORT=$port -user=$3 -USER=$user -password=$4; HIDE=4 -PASSWORD=$password -type=${5-api} -TYPE="$type" -dns_user=${6-dns-cluster} -DNS_USER=$dns_user - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/remote.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -args_usage='HOST PORT USER PASSWORD [TYPE] [DNS_USER]' -check_args '4' "$#" "$args_usage" -is_format_valid 'host' 'port' 'user' 'type' 'dns_user' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_password_valid -is_dnshost_new -is_dnshost_alive - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Concatentating dns host string -str="HOST='$host' PORT='$port' USER='$user' PASSWORD='$password'" -str="$str DNS_USER='$dns_user' TYPE='$type' SUSPENDED='no'" -str="$str TIME='$time' DATE='$date'" - -# Adding host to dns-cluster.conf -echo "$str" >> $VESTA/conf/dns-cluster.conf -chmod 660 $VESTA/conf/dns-cluster.conf - -# Enabling DNS_CLUSTER -if [ -z "$(grep DNS_CLUSTER $VESTA/conf/vesta.conf)" ]; then - sed -i "s/^STATS_/DNS_CLUSTER='yes'\nSTATS_/g" $VESTA/conf/vesta.conf -else - sed -i "s/DNS_CLUSTER=.*/DNS_CLUSTER='yes'/g" $VESTA/conf/vesta.conf -fi - -# Enabling remote dns-cluster queue -cluster_cmd v-add-cron-restart-job -check_result $? "$HOST connection failed" $E_CONNECT - -# Syncing all domains -$BIN/v-sync-dns-cluster $host -check_result $? "$HOST sync failed" $E_CONNECT - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding local dns-cluster cron job -cmd="sudo /usr/local/vesta/bin/v-update-sys-queue dns-cluster" -check_cron=$(grep "$cmd" $VESTA/data/users/admin/cron.conf 2> /dev/null) -if [ -z "$check_cron" ] && [ ! -z "$CRON_SYSTEM" ]; then - $BIN/v-add-cron-job admin '*/5' '*' '*' '*' '*' "$cmd" -fi - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-remote-dns-record b/bin/v-add-remote-dns-record deleted file mode 100755 index 91f4b727f..000000000 --- a/bin/v-add-remote-dns-record +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# info: add remote dns domain record -# options: USER DOMAIN ID -# -# The function synchronize dns domain with the remote server. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -id=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/remote.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ID' -is_format_valid 'user' 'domain' 'id' -is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_procces_running -remote_dns_health_check - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing record -str=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) -if [ -z "$str" ]; then - pipe="$VESTA/data/queue/dns-cluster.pipe" - queue_str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1) - if [ ! -z "$queue_str" ]; then - sed -i "$queue_str d" $pipe - fi - exit -fi - -IFS=$'\n' -for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do - - # Parsing remote host parameters - eval $cluster - - # Syncing serial - str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf) - cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'domain' 'no' - check_result $? "$HOST connection failed (soa sync)" $E_CONNECT - - # Syncing record - str=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf | sed 's/"/\\"/g') - cluster_cmd v-insert-dns-record $DNS_USER $domain "$str" 'no' - check_result $? "$HOST connection failed (record sync)" $E_CONNECT - - # Rebuilding dns zone - cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no' - check_result $? "$HOST connection failed (rebuild)" $E_CONNECT - -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating pipe -pipe="$VESTA/data/queue/dns-cluster.pipe" -str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1) -if [ ! -z "$str" ]; then - sed -i "$str d" $pipe -fi - -exit diff --git a/bin/v-add-sys-firewall b/bin/v-add-sys-firewall deleted file mode 100755 index b154c7f09..000000000 --- a/bin/v-add-sys-firewall +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# info: add system firewall -# options: NONE -# -# The script enables firewall - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -if [ "$FIREWALL_SYSTEM" = 'iptables' ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding firewall directory -mkdir -p $VESTA/data/firewall/ - -# Adding default ruleset -if [ ! -e "$VESTA/data/firewall/rules.conf" ]; then - cp $VESTA/install/rhel/7/* $VESTA/data/firewall/ -fi - -# Updating FIREWAL_SYSTEM value -if [ -z "$(grep FIREWALL_SYSTEM $VESTA/conf/vesta.conf)" ]; then - echo "FIREWALL_SYSTEM='iptables'" >> $VESTA/conf/vesta.conf -else - sed -i "s/FIREWALL_SYSTEM.*/FIREWALL_SYSTEM='iptables'/g" \ - $VESTA/conf/vesta.conf -fi - -# Updating firewall rules -$BIN/v-update-firewall - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-sys-ip b/bin/v-add-sys-ip deleted file mode 100755 index 54245bcc2..000000000 --- a/bin/v-add-sys-ip +++ /dev/null @@ -1,194 +0,0 @@ -#!/bin/bash -# info: add system ip address -# options: IP NETMASK [INTERFACE] [USER] [IP_STATUS] [IP_NAME] [NAT_IP] -# -# The function adds ip address into a system. It also creates rc scripts. You -# can specify ip name which will be used as root domain for temporary aliases. -# For example, if you set a1.myhosting.com as name, each new domain created on -# this ip will automatically receive alias $domain.a1.myhosting.com. Of course -# you must have wildcard record *.a1.myhosting.com pointed to ip. This feature -# is very handy when customer wants to test domain before dns migration. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -ip=${1// /} -netmask=$2 -interface="${3-eth0}" -user="${4-admin}" -ip_status="${5-shared}" -ip_name=$6 -nat_ip=$7 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'IP NETMASK [INTERFACE] [USER] [STATUS] [NAME] [NATED_IP]' -is_format_valid 'ip' 'netmask' 'interface' 'user' 'ip_status' -is_ip_free -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -if [ ! -z "$ip_name" ] ; then - is_format_valid 'ip_name' -fi -if [ ! -z "$nat_ip" ] ; then - is_format_valid 'nat_ip' -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -iface=$(get_ip_iface) -cidr=$(convert_netmask $netmask) -broadcast=$(get_broadcast $ip $netmask) - -sys_ip_check=$(/sbin/ip addr | grep "$ip") -if [ -z "$sys_ip_check" ]; then - # Adding sys ip - /sbin/ip addr add $ip/$cidr dev $interface \ - broadcast $broadcast label $iface - - # Adding RHEL/CentOS/Fedora/Amazon startup script - if [ -d "/etc/sysconfig" ]; then - sys_ip="# Added by vesta" - sys_ip="$sys_ip\nDEVICE=$iface" - sys_ip="$sys_ip\nBOOTPROTO=static" - sys_ip="$sys_ip\nONBOOT=yes" - sys_ip="$sys_ip\nIPADDR=$ip" - sys_ip="$sys_ip\nNETMASK=$netmask" - echo -e $sys_ip > /etc/sysconfig/network-scripts/ifcfg-$iface - fi - - # Adding Debian/Ubuntu startup script - if [ -e "/etc/debian_version" ]; then - sys_ip="\n# Added by vesta" - sys_ip="$sys_ip\nauto $iface" - sys_ip="$sys_ip\niface $iface inet static" - sys_ip="$sys_ip\naddress $ip" - sys_ip="$sys_ip\nnetmask $netmask" - echo -e $sys_ip >> /etc/network/interfaces - fi -fi - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Adding vesta ip -echo "OWNER='$user' -STATUS='$ip_status' -NAME='$ip_name' -U_SYS_USERS='' -U_WEB_DOMAINS='0' -INTERFACE='$interface' -NETMASK='$netmask' -NAT='$nat_ip' -TIME='$time' -DATE='$date'" > $VESTA/data/ips/$ip -chmod 660 $VESTA/data/ips/$ip - -# WEB support -if [ ! -z "$WEB_SYSTEM" ]; then - web_conf="/etc/$WEB_SYSTEM/conf.d/$ip.conf" - rm -f $web_conf - - if [ "$WEB_SYSTEM" = 'httpd' ] || [ "$WEB_SYSTEM" = 'apache2' ]; then - if [ -z "$(/usr/sbin/apachectl -v | grep Apache/2.4)" ]; then - echo "NameVirtualHost $ip:$WEB_PORT" > $web_conf - fi - echo "Listen $ip:$WEB_PORT" >> $web_conf - fi - - if [ "$WEB_SSL" = 'mod_ssl' ]; then - if [ -z "$(/usr/sbin/apachectl -v | grep Apache/2.4)" ]; then - echo "NameVirtualHost $ip:$WEB_SSL_PORT" >> $web_conf - fi - echo "Listen $ip:$WEB_SSL_PORT" >> $web_conf - fi -fi - -# Proxy support -if [ ! -z "$PROXY_SYSTEM" ]; then - cat $WEBTPL/$PROXY_SYSTEM/proxy_ip.tpl |\ - sed -e "s/%ip%/$ip/g" \ - -e "s/%web_port%/$WEB_PORT/g" \ - -e "s/%proxy_port%/$PROXY_PORT/g" \ - > /etc/$PROXY_SYSTEM/conf.d/$ip.conf - - # mod_extract_forwarded - fw_conf="/etc/$WEB_SYSTEM/conf.d/mod_extract_forwarded.conf" - if [ -e "$fw_conf" ]; then - ips=$(grep 'MEFaccept ' $fw_conf | grep -v '#' | head -n1) - sed -i "s/$ips/$ips $ip/g" $fw_conf - fi - - # mod_rpaf - rpaf_conf="/etc/$WEB_SYSTEM/mods-enabled/rpaf.conf" - if [ -e "$rpaf_conf" ]; then - rpaf_str=$(grep RPAFproxy_ips $rpaf_conf) - rpaf_str="$rpaf_str $ip" - sed -i "s/.*RPAFproxy_ips.*/$rpaf_str/" $rpaf_conf - fi - - #mod_remoteip - remoteip_conf="/etc/$WEB_SYSTEM/mods-enabled/remoteip.conf" - if [ -e "$remoteip_conf" ]; then - if [ $( grep -ic "$ip" $remoteip_conf ) -eq 0 ]; then - sed -i "s/<\/IfModule>/RemoteIPInternalProxy $ip\n<\/IfModule>/g" $remoteip_conf - fi - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating user counters -increase_user_value "$user" '$IP_OWNED' -if [ "$user" = 'admin' ]; then - if [ "$ip_status" = 'shared' ]; then - for user in $(ls $VESTA/data/users); do - increase_user_value "$user" '$IP_AVAIL' - done - else - increase_user_value 'admin' '$IP_AVAIL' - fi -else - increase_user_value "$user" '$IP_AVAIL' - increase_user_value 'admin' '$IP_AVAIL' -fi - -# Restarting web server -$BIN/v-restart-web -check_result $? "Web restart failed" >/dev/null - -# Restarting proxy server -if [ ! -z "$PROXY_SYSTEM" ]; then - $BIN/v-restart-proxy - check_result $? "Proxy restart failed" >/dev/null -fi - -# Restarting firewall -if [ ! -z "$FIREWALL_SYSTEM" ]; then - $BIN/v-update-firewall -fi - -# Logging -log_history "added system ip address $ip" '' 'admin' -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-sys-mail-ssl b/bin/v-add-sys-mail-ssl deleted file mode 100755 index 1ebffdc35..000000000 --- a/bin/v-add-sys-mail-ssl +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash -# info: copy mail ssl certificate -# options: USER DOMAIN [RESTART] -# -# The function copies user domain SSL to mail SSL directory - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -restart=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [RESTART]' -is_format_valid 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining certificate location -dom_crt="/home/$user/conf/web/ssl.$domain.pem" -dom_key="/home/$user/conf/web/ssl.$domain.key" -vst_crt="$VESTA/ssl/mail.crt" -vst_key="$VESTA/ssl/mail.key" - -# Checking certificate -if [ ! -e "$dom_crt" ] || [ ! -e "$dom_key" ]; then - check_result $E_NOTEXIST "$domain certificate doesn't exist" -fi - -# Checking difference -diff $dom_crt $vst_crt >/dev/null 2>&1 -if [ $? -ne 0 ]; then - rm -f $vst_crt.old $vst_key.old - mv $vst_crt $vst_crt.old >/dev/null 2>&1 - mv $vst_key $vst_key.old >/dev/null 2>&1 - cp $dom_crt $vst_crt 2>/dev/null - cp $dom_key $vst_key 2>/dev/null - chown root:mail $vst_crt $vst_key -else - restart=no -fi - -# Updating mail certificate -case $MAIL_SYSTEM in - exim) conf='/etc/exim/exim.conf';; - exim4) conf='/etc/exim4/exim4.conf.template';; -esac -if [ -e "$conf" ]; then - sed -e "s|^tls_certificate.*|tls_certificate = $vst_crt|" \ - -e "s|^tls_privatekey.*|tls_privatekey = $vst_key|" -i $conf -fi - -# Updating imap certificate -conf="/etc/dovecot/conf.d/10-ssl.conf" -if [ ! -z "$IMAP_SYSTEM" ] && [ -e "$conf" ]; then - sed -e "s|ssl_cert.*|ssl_cert = <$vst_crt|" \ - -e "s|ssl_key.*|ssl_key = <$vst_key|" -i $conf -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting services -if [ "$restart" != 'no' ]; then - if [ ! -z "$MAIL_SYSTEM" ]; then - $BIN/v-restart-service $MAIL_SYSTEM - fi - if [ ! -z "$IMAP_SYSTEM" ]; then - $BIN/v-restart-service $IMAP_SYSTEM - fi -fi - -# Updating vesta.conf -if [ -z "$(grep MAIL_CERTIFICATE $VESTA/conf/vesta.conf)" ]; then - echo "MAIL_CERTIFICATE='$user:$domain'" >> $VESTA/conf/vesta.conf -else - sed -i "s/MAIL_CERTIFICATE.*/MAIL_CERTIFICATE='$user:$domain'/g" \ - $VESTA/conf/vesta.conf -fi - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-sys-quota b/bin/v-add-sys-quota deleted file mode 100755 index 93687e9c6..000000000 --- a/bin/v-add-sys-quota +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash -# info: add system quota -# options: NONE -# -# The script enables filesystem quota on /home partition - - -#----------------------------------------------------------# -# Variable & Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking quota package -quota=$(which --skip-alias --skip-functions quota 2>/dev/null) -if [ $? -ne 0 ]; then - if [ -d "/etc/sysconfig" ]; then - yum -y install quota >/dev/null 2>&1 - check_result $? "quota package installation failed" $E_UPDATE - else - export DEBIAN_FRONTEND=noninteractive - apt-get -y install quota >/dev/null 2>&1 - check_result $? "quota package installation failed" $E_UPDATE - fi -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding group and user quota on /home partition -mnt=$(df -P /home | awk '{print $6}' | tail -n1) -lnr=$(cat -n /etc/fstab | grep -v "#" | awk '{print $1,$3}' | grep "$mnt$" | cut -f 1 -d ' ') -opt=$(sed -n ${lnr}p /etc/fstab | awk '{print $4}') -fnd='usrquota\|grpquota\|usrjquota=aquota.user\|grpjquota=aquota.group\|jqfmt=vfsv0' -if [ $(echo $opt | tr ',' '\n' | grep -x $fnd | wc -l) -ne 5 ]; then - old=$(echo $(echo $opt | tr ',' '\n' | grep -v 'usrquota\|grpquota\|usrjquota=\|grpjquota=\|jqfmt=') | tr ' ' ',') - new='usrquota,grpquota,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0' - sed -i "$lnr s/$opt/$old,$new/" /etc/fstab - mount -o remount $mnt -fi - -# Adding v2 group and user quota index -if [ ! -e "$mnt/aquota.user" ] || [ ! -e "$mnt/aquota.group" ]; then - quotacheck -avcugm >/dev/null 2>&1 -fi - -# Adding quotacheck on reboot -touch /forcequotacheck - -# Adding cron job -echo '#!/bin/bash' > /etc/cron.daily/quotacheck -echo 'touch /forcequotacheck' >> /etc/cron.daily/quotacheck -chmod a+x /etc/cron.daily/quotacheck - -# Enabling group and user quota -if [ ! -z "$(quotaon -pa | grep " $mnt " | grep 'user\|group' | grep 'is off')" ]; then - quotaon -v $mnt - check_result $? "quota can't be enabled in $mnt" $E_DISK -fi - -# Updating vesta.conf value -if [ -z "$(grep DISK_QUOTA $VESTA/conf/vesta.conf)" ]; then - echo "DISK_QUOTA='yes'" >> $VESTA/conf/vesta.conf -else - sed -i "s/DISK_QUOTA=.*/DISK_QUOTA='yes'/g" $VESTA/conf/vesta.conf -fi - -# Rebuilding user quota -for user in $(ls $VESTA/data/users); do - $BIN/v-update-user-quota $user -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-sys-sftp-jail b/bin/v-add-sys-sftp-jail deleted file mode 100755 index 7d5c40352..000000000 --- a/bin/v-add-sys-sftp-jail +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash -# info: add system sftp jail -# options: NONE -# -# The script enables sftp jailed environment - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system environment as we run this script -# mostly by cron which do not read it by itself -source /etc/profile - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -if [ -z "$SFTPJAIL_KEY" ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking sshd directives -config='/etc/ssh/sshd_config' -sftp_n=$(grep -n "Subsystem.*sftp" $config |grep -v internal |grep -v ":#") -sftp_i=$(grep -n "Subsystem.*sftp" $config |grep internal |grep -v ":#") - -# Disabling normal sftp -if [ ! -z "$sftp_n" ]; then - fline=$(echo $sftp_n |cut -f 1 -d :) - sed -i "${fline}s/Subsystem.*sftp/#Subsystem sftp/" $config - restart='yes' -fi - -# Enabling jailed sftp -if [ -z "$sftp_i" ]; then - echo " " >> $config - echo "Subsystem sftp internal-sftp" >> $config - echo "Match Group sftp-only" >> $config - echo "ChrootDirectory /chroot/%u" >> $config - echo " AllowTCPForwarding no" >> $config - echo " X11Forwarding no" >> $config - echo " ForceCommand internal-sftp" >> $config - restart='yes' -fi - -# Validating opensshd config -if [ "$restart" = 'yes' ]; then - subj="OpenSSH restart failed" - email=$(grep CONTACT $VESTA/data/users/admin/user.conf |cut -f 2 -d \') - /usr/sbin/sshd -t >/dev/null 2>&1 - if [ "$?" -ne 0 ]; then - mail_text="OpenSSH can not be restarted. Please check config: - \n\n$(/usr/sbin/sshd -t)" - echo -e "$mail_text" |$SENDMAIL -s "$subj" $email - else - service ssh restart >/dev/null 2>&1 - service sshd restart >/dev/null 2>&1 - fi -fi - -# Adding sftp group -groupadd sftp-only 2>/dev/null - -# Checking users -shells="rssh|nologin" -for user in $(grep "$HOMEDIR" /etc/passwd |egrep "$shells" |cut -f 1 -d:); do - $BIN/v-add-user-sftp-jail $user -done - -# Adding v-add-sys-sftp-jail to startup -if [ -e "/etc/rc.local" ]; then - check_sftp=$(grep $0 /etc/rc.local) - check_exit=$(grep ^exit /etc/rc.local) - if [ -z "$check_sftp" ]; then - if [ -z "$check_exit" ]; then - echo "$BIN/v-add-sys-sftp-jail" >> /etc/rc.local - else - sed -i "s|^exit|$BIN/v-add-sys-sftp-jail\nexit|" /etc/rc.local - fi - fi - chmod +x /etc/rc.local -else - echo "$BIN/v-add-sys-sftp-jail" > /etc/rc.local - chmod +x /etc/rc.local -fi - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-sys-vesta-ssl b/bin/v-add-sys-vesta-ssl deleted file mode 100755 index 32cd6c141..000000000 --- a/bin/v-add-sys-vesta-ssl +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# info: add vesta ssl certificate -# options: USER DOMAIN [RESTART] -# -# The function copies user domain SSL to vesta SSL directory - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -restart=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [RESTART]' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining certificate location -dom_crt="/home/$user/conf/web/ssl.$domain.pem" -dom_key="/home/$user/conf/web/ssl.$domain.key" -vst_crt="$VESTA/ssl/certificate.crt" -vst_key="$VESTA/ssl/certificate.key" - -# Checking certificate -if [ ! -e "$dom_crt" ] || [ ! -e "$dom_key" ]; then - check_result $E_NOTEXIST "$domain certificate doesn't exist" -fi - -# Checking difference -diff $dom_crt $vst_crt >/dev/null 2>&1 -if [ $? -ne 0 ]; then - rm -f $vst_crt.old $vst_key.old - mv $vst_crt $vst_crt.old - mv $vst_key $vst_key.old - cp $dom_crt $vst_crt 2>/dev/null - cp $dom_key $vst_key 2>/dev/null - chown root:mail $vst_crt $vst_key -else - restart=no -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting services -if [ "$restart" != 'no' ]; then - if [ ! -z "$MAIL_SYSTEM" ] && [ -z "$MAIL_CERTIFICATE" ]; then - $BIN/v-restart-service $MAIL_SYSTEM - fi - if [ ! -z "$IMAP_SYSTEM" ] && [ -z "$MAIL_CERTIFICATE" ]; then - $BIN/v-restart-service $IMAP_SYSTEM - fi - if [ ! -z "$FTP_SYSTEM" ]; then - $BIN/v-restart-service "$FTP_SYSTEM" - fi - if [ -e "/var/run/vesta-nginx.pid" ]; then - kill -HUP $(cat /var/run/vesta-nginx.pid) - else - service vesta restart - fi -fi - -# Updating vesta.conf -if [ -z "$(grep VESTA_CERTIFICATE $VESTA/conf/vesta.conf)" ]; then - echo "VESTA_CERTIFICATE='$user:$domain'" >> $VESTA/conf/vesta.conf -else - sed -i "s/VESTA_CERTIFICATE.*/VESTA_CERTIFICATE='$user:$domain'/g" \ - $VESTA/conf/vesta.conf -fi - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-user b/bin/v-add-user deleted file mode 100755 index 025c7e3ee..000000000 --- a/bin/v-add-user +++ /dev/null @@ -1,215 +0,0 @@ -#!/bin/bash -# info: add system user -# options: USER PASSWORD EMAIL [PACKAGE] [FNAME] [LNAME] -# -# The function creates new user account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -password=$2; HIDE=2 -email=$3 -package=${4-default} -fname=$5 -lname=$6 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -is_user_free() { - check_sysuser=$(cut -f 1 -d : /etc/passwd | grep "^$user$" ) - if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then - check_result $E_EXISTS "user $user exists" - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER PASSWORD EMAIL [PACKAGE] [FNAME] [LNAME]' -is_format_valid 'user' 'email' 'package' -if [ ! -z "$fname" ]; then - is_format_valid 'fname' 'lname' -fi -is_user_free "$user" -is_password_valid -is_package_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing package data -pkg_data=$(cat $VESTA/data/packages/$package.pkg |egrep -v "TIME|DATE") - -# Checking shell -shell_conf=$(echo "$pkg_data" | grep 'SHELL' | cut -f 2 -d \') -shell=$(grep -w "$shell_conf" /etc/shells |head -n1) - -# Adding user -/usr/sbin/useradd "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user" -check_result $? "user creation failed" $E_INVALID - -# Adding password -echo "$user:$password" | /usr/sbin/chpasswd - -# Building directory tree -mkdir $HOMEDIR/$user/conf - -if [ ! -z "$WEB_SYSTEM" ]; then - mkdir $HOMEDIR/$user/conf/web $HOMEDIR/$user/web $HOMEDIR/$user/tmp - chmod 751 $HOMEDIR/$user/conf/web - chmod 700 $HOMEDIR/$user/tmp - chown $user:$user $HOMEDIR/$user/web $HOMEDIR/$user/tmp -fi - -if [ ! -z "$MAIL_SYSTEM" ]; then - mkdir $HOMEDIR/$user/conf/mail $HOMEDIR/$user/mail - chmod 751 $HOMEDIR/$user/mail - chmod 755 $HOMEDIR/$user/conf/mail -fi - -if [ ! -z "$DNS_SYSTEM" ]; then - mkdir $HOMEDIR/$user/conf/dns - chmod 751 $HOMEDIR/$user/conf/dns -fi - -# Set permissions -chmod a+x $HOMEDIR/$user -chattr +i $HOMEDIR/$user/conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding user dir -mkdir -p $USER_DATA/ssl $USER_DATA/dns $USER_DATA/mail - -# Creating configuration files and pipes -touch $USER_DATA/backup.conf \ - $USER_DATA/history.log \ - $USER_DATA/stats.log \ - $USER_DATA/web.conf \ - $USER_DATA/dns.conf \ - $USER_DATA/mail.conf \ - $USER_DATA/db.conf \ - $USER_DATA/cron.conf - -chmod 770 $USER_DATA \ - $USER_DATA/ssl \ - $USER_DATA/dns \ - $USER_DATA/mail - -chmod 660 $USER_DATA/backup.conf \ - $USER_DATA/history.log \ - $USER_DATA/stats.log \ - $USER_DATA/web.conf \ - $USER_DATA/dns.conf \ - $USER_DATA/mail.conf \ - $USER_DATA/db.conf \ - $USER_DATA/cron.conf - -# Updating queue pipes -echo "$BIN/v-update-user-disk $user" >> $VESTA/data/queue/disk.pipe -if [ ! -z "$WEB_SYSTEM" ]; then - echo "$BIN/v-update-web-domains-traff $user" \ - >> $VESTA/data/queue/traffic.pipe - echo "$BIN/v-update-web-domains-disk $user" >> $VESTA/data/queue/disk.pipe -fi -if [ ! -z "$MAIL_SYSTEM" ]; then - echo "$BIN/v-update-mail-domains-disk $user" >> $VESTA/data/queue/disk.pipe -fi - -if [ ! -z "$DB_SYSTEM" ]; then - echo "$BIN/v-update-databases-disk $user" >> $VESTA/data/queue/disk.pipe -fi - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Filling user config -if [ "$user" != 'admin' ]; then - ip_avail=$($BIN/v-list-user-ips admin plain |grep -w shared|wc -l) - u_users=0 -else - ip_avail=0 - u_users=1 -fi - -echo "FNAME='$fname' -LNAME='$lname' -PACKAGE='$package' -$pkg_data -CONTACT='$email' -CRON_REPORTS='yes' -MD5='$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow)' -RKEY='$(generate_password)' -SUSPENDED='no' -SUSPENDED_USERS='0' -SUSPENDED_WEB='0' -SUSPENDED_DNS='0' -SUSPENDED_MAIL='0' -SUSPENDED_DB='0' -SUSPENDED_CRON='0' -IP_AVAIL='$ip_avail' -IP_OWNED='0' -U_USERS='$u_users' -U_DISK='0' -U_DISK_DIRS='0' -U_DISK_WEB='0' -U_DISK_MAIL='0' -U_DISK_DB='0' -U_BANDWIDTH='0' -U_WEB_DOMAINS='0' -U_WEB_SSL='0' -U_WEB_ALIASES='0' -U_DNS_DOMAINS='0' -U_DNS_RECORDS='0' -U_MAIL_DOMAINS='0' -U_MAIL_DKIM='0' -U_MAIL_ACCOUNTS='0' -U_DATABASES='0' -U_CRON_JOBS='0' -U_BACKUPS='0' -LANGUAGE='' -NOTIFICATIONS='no' -TIME='$time' -DATE='$date'" > $USER_DATA/user.conf -chmod 660 $USER_DATA/user.conf - -# Updating quota -if [ "$DISK_QUOTA" = 'yes' ]; then - $BIN/v-update-user-quota "$user" -fi - -# Updating admin counter -if [ "$user" != 'admin' ]; then - increase_user_value 'admin' '$U_USERS' -fi - -# Run template trigger -if [ -x "$VESTA/data/packages/$package.sh" ]; then - $VESTA/data/packages/$package.sh "$user" "$email" "$fname" "$lname" -fi - -# Adding jailed sftp env -if [ ! -z "$SFTPJAIL_KEY" ]; then - $BIN/v-add-user-sftp-jail $user -fi - -# Logging -log_history "added system user $user" '' 'admin' -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-user-favourites b/bin/v-add-user-favourites deleted file mode 100755 index 188638290..000000000 --- a/bin/v-add-user-favourites +++ /dev/null @@ -1,125 +0,0 @@ -#!/bin/bash -# info: adding user favourites -# options: USER SYSTEM OBJECT -# -# The function adds object to users favourites - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -system=$(echo "$2" |tr '[:lower:]' '[:upper:]') -object=$3 -email=$3 -id=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER SYSTEM OBJECT' -is_format_valid 'user' 'system' -case $system in - MAIL_ACC) is_format_valid 'email' ;; - CRON) is_format_valid 'id' ;; - DNS_REC) is_format_valid 'id' ;; - *) is_format_valid 'object' -esac -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - -# Checking system -case $system in - USER) check='ok' ;; - WEB) check='ok' ;; - DNS) check='ok' ;; - DNS_REC) check='ok' ;; - MAIL) check='ok' ;; - MAIL_ACC) check='ok' ;; - DB) check='ok' ;; - CRON) check='ok' ;; - BACKUP) check='ok' ;; - IP) check='ok' ;; - PACKAGE) check='ok' ;; - FIREWALL) check='ok' ;; - *) check_args '2' '0' 'USER SYSTEM OBJECT' -esac - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Flushing vars -USER='' -WEB='' -DNS='' -DNS_REC='' -MAIL='' -MAIL_ACC='' -DB='' -CRON='' -BACKUP='' -IP='' -PACKAGE='' -FIREWALL='' - -# Creating config just in case -touch $USER_DATA/favourites.conf - -# Reading current values -source $USER_DATA/favourites.conf - -# Assigning current system value -eval value=\$$system - -# Checking if object is new -check_fav=$(echo "$value" |tr ',' '\n'| grep "^$object$") -if [ ! -z "$check_fav" ]; then - exit 0 -fi - -# Adding object to favorites -if [ -z "$value" ]; then - value="$object" -else - value="$value,$object" -fi - -# Updating sytem -eval $system=$value - -# Updating user favorites -echo "USER='$USER' -WEB='$WEB' -DNS='$DNS' -DNS_REC='$DNS_REC' -MAIL='$MAIL' -MAIL_ACC='$MAIL_ACC' -DB='$DB' -CRON='$CRON' -BACKUP='$BACKUP' -IP='$IP' -PACKAGE='$PACKAGE' -FIREWALL='$FIREWALL'" > $USER_DATA/favourites.conf - -# Changing file permission -chmod 640 $USER_DATA/favourites.conf - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "added starred $object in $system listing" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-user-notification b/bin/v-add-user-notification deleted file mode 100755 index 5945b1923..000000000 --- a/bin/v-add-user-notification +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -# info: add user notification -# options: USER TOPIC NOTICE [TYPE] -# -# The function adds user notification. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -topic=$(echo $2 |sed "s/'/%quote%/g") -notice=$(echo $3 |sed "s/'/%quote%/g") -type=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER TOPIC NOTICE [TYPE]' -is_format_valid 'user' 'topic' 'notice' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining notification id -if [ -e "$USER_DATA/notifications.conf" ]; then - nid=$(grep "NID=" $USER_DATA/notifications.conf |cut -f 2 -d \') - nid=$(echo "$nid" |sort -n |tail -n1) - if [ ! -z "$nid" ]; then - nid="$((nid +1))" - else - nid=1 - fi -else - nid=1 -fi - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Concatenating string -str="NID='$nid' TOPIC='$topic' NOTICE='$notice' TYPE='$type'" -str="$str ACK='no' TIME='$time' DATE='$date'" - -# Adding to config -echo "$str" >> $USER_DATA/notifications.conf - -# Changing permissions -chmod 660 $USER_DATA/notifications.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating notification counter -if [ -z "$(grep NOTIFICATIONS $USER_DATA/user.conf)" ]; then - sed -i "s/^TIME/NOTIFICATIONS='yes'\nTIME/g" $USER_DATA/user.conf -else - update_user_value "$user" '$NOTIFICATIONS' "yes" -fi - -exit diff --git a/bin/v-add-user-package b/bin/v-add-user-package deleted file mode 100755 index 0cab1a3dc..000000000 --- a/bin/v-add-user-package +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/bash -# info: adding user package -# options: PKG_DIR PACKAGE [REWRITE] -# -# The function adds new user package to the system. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -pkg_dir=$1 -package=$2 -rewrite=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Functions -is_package_new() { - if [ -e "$VESTA/data/packages/$package.pkg" ]; then - echo "Error: package $package already exists." - log_event "$E_EXISTS" "$ARGUMENTS" - exit $E_EXISTS - fi -} - -is_package_consistent() { - source $pkg_dir/$package.pkg - if [ "$WEB_DOMAINS" != 'unlimited' ]; then - is_int_format_valid $WEB_DOMAINS 'WEB_DOMAINS' - fi - if [ "$WEB_ALIASES" != 'unlimited' ]; then - is_int_format_valid $WEB_ALIASES 'WEB_ALIASES' - fi - if [ "$DNS_DOMAINS" != 'unlimited' ]; then - is_int_format_valid $DNS_DOMAINS 'DNS_DOMAINS' - fi - if [ "$DNS_RECORDS" != 'unlimited' ]; then - is_int_format_valid $DNS_RECORDS 'DNS_RECORDS' - fi - if [ "$MAIL_DOMAINS" != 'unlimited' ]; then - is_int_format_valid $MAIL_DOMAINS 'MAIL_DOMAINS' - fi - if [ "$MAIL_ACCOUNTS" != 'unlimited' ]; then - is_int_format_valid $MAIL_ACCOUNTS 'MAIL_ACCOUNTS' - fi - if [ "$DATABASES" != 'unlimited' ]; then - is_int_format_valid $DATABASES 'DATABASES' - fi - if [ "$CRON_JOBS" != 'unlimited' ]; then - is_int_format_valid $CRON_JOBS 'CRON_JOBS' - fi - if [ "$DISK_QUOTA" != 'unlimited' ]; then - is_int_format_valid $DISK_QUOTA 'DISK_QUOTA' - fi - if [ "$BANDWIDTH" != 'unlimited' ]; then - is_int_format_valid $BANDWIDTH 'BANDWIDTH' - fi - if [ "$BACKUPS" != 'unlimited' ]; then - is_int_format_valid $BACKUPS 'BACKUPS' - fi - is_format_valid_shell $SHELL -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'PKG_DIR PACKAGE' 'rewrite' -is_format_valid 'pkg_dir' 'package' -if [ "$rewrite" != 'yes' ]; then - is_package_new -fi -is_package_valid "$pkg_dir" -is_package_consistent - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -cp -f $pkg_dir/$package.pkg $VESTA/data/packages/ -chmod 644 $VESTA/data/packages/$package.pkg - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -if [ "$rewrite" != 'yes' ]; then - log_history "added user package $package" '' 'admin' -else - log_history "updated user package $package" '' 'admin' -fi -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-user-sftp-jail b/bin/v-add-user-sftp-jail deleted file mode 100755 index ed96509d9..000000000 --- a/bin/v-add-user-sftp-jail +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -# info: add user sftp jail -# options: USER -# -# The script enables sftp jailed environment - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -if [ -z "$SFTPJAIL_KEY" ]; then - exit -fi -user_str=$(grep "^$user:" /etc/passwd |egrep "rssh|nologin") -if [ -z "$user_str" ]; then - exit -fi - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining user homedir -home="$(echo $user_str |cut -f 6 -d :)" - -# Adding chroot directory -if [ ! -d "/chroot/$user/$home" ]; then - mkdir -p /chroot/$user/$home - chmod 750 /chroot/$user - chmod 775 /chroot/$user/$home - chown root:sftp-only /chroot/$user - chown $user:sftp-only /chroot/$user/$home -fi - -# Adding user to sftp group -usermod -a -G sftp-only $user - -# Mouting home directory -if [ -z "$(mount |grep /chroot/$user/$home)" ]; then - mount -o bind $home /chroot/$user/$home/ -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-vesta-softaculous b/bin/v-add-vesta-softaculous deleted file mode 100755 index b0cca53a5..000000000 --- a/bin/v-add-vesta-softaculous +++ /dev/null @@ -1,133 +0,0 @@ -#!/bin/bash -# info: add vesta softaculous -# options: [TYPE] -# -# The script enables softaculous plugin - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -TYPE=$1 - -# Includes -source /etc/profile -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -if [ "$TYPE" = 'WEB' ]; then - if [ ! -e "$VESTA/softaculous" ] && [ ! -e "$VESTA/ioncube" ]; then - $BIN/v-schedule-vesta-softaculous - exit - fi -else - cmd="v-add-vesta-softaculous" - check_cron=$(grep "$cmd" $VESTA/data/users/admin/cron.conf 2> /dev/null) - if [ ! -z "$check_cron" ]; then - eval $check_cron - $BIN/v-delete-cron-job admin $JOB - fi -fi - -if [ "$SOFTACULOUS" = 'yes' ]; then - exit -fi - - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Cleaning yum cache -if [ -d "/etc/sysconfig" ]; then - yum -q clean all - yum="yum -q -y --noplugins --disablerepo=* --enablerepo=vesta" -else - export DEBIAN_FRONTEND=noninteractive - apt-get update -o Dir::Etc::sourcelist="sources.list.d/vesta.list" \ - -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" -qq -fi - -# Updating php pacakge -if [ -z "$($VESTA/php/bin/php -v|grep 'PHP 5.6')" ]; then - if [ -d "/etc/sysconfig" ]; then - $yum -y update vesta-php - check_result $? "vesta-php package upgrade failed" $E_UPDATE - else - apt-get -y install vesta-php - check_result $? "vesta-php package upgrade failed" $E_UPDATE - fi -fi - -# Adding vesta-ioncube package -if [ -d "/etc/sysconfig" ]; then - rpm -q vesta-ioncube >/dev/null 2>&1 - if [ $? -ne 0 ]; then - $yum -y install vesta-ioncube >/dev/null 2>&1 - check_result $? "vesta-ioncube package installation failed" $E_UPDATE - fi -else - dpkg -l vesta-ioncube |grep ^ii >/dev/null 2>&1 - if [ $? -ne 0 ]; then - apt-get -y install vesta-ioncube >/dev/null 2>&1 - check_result $? "vesta-ioncube package installation failed" $E_UPDATE - fi -fi - -# Adding vesta-softaculous package -if [ -d "/etc/sysconfig" ]; then - rpm -q vesta-softaculous >/dev/null 2>&1 - if [ $? -ne 0 ]; then - $yum -y install vesta-softaculous >/dev/null 2>&1 - check_result $? "vesta-softaculous package installation failed" $E_UPDATE - fi -else - dpkg -l vesta-softaculous |grep ^ii >/dev/null 2>&1 - if [ $? -ne 0 ]; then - apt-get -y install vesta-softaculous >/dev/null 2>&1 - check_result $? "vesta-softaculous package installation failed" $E_UPDATE - fi -fi - -# Installing softaculous -if [ ! -e "$VESTA/softaculous/vst_installed" ]; then - mkdir -p /var/softaculous - chown -R admin:admin /var/softaculous - cd $VESTA/softaculous - wget -q http://c.vestacp.com/3rdparty/softaculous_install.inc - $VESTA/php/bin/php softaculous_install.inc - check_result $? "vesta-softaculous package installation failed" $E_UPDATE - touch $VESTA/softaculous/vst_installed -fi - -# Enabling symlink -if [ -e "$VESTA/disabled_plugins/softaculous" ]; then - if [ ! -e "$VESTA/web/softaculous" ]; then - mv $VESTA/disabled_plugins/softaculous $VESTA/web/softaculous - fi -fi - -# Updating SOFTACULOUS value -if [ -z "$(grep SOFTACULOUS $VESTA/conf/vesta.conf)" ]; then - echo "SOFTACULOUS='yes'" >> $VESTA/conf/vesta.conf -else - sed -i "s/SOFTACULOUS.*/SOFTACULOUS='yes'/g" \ - $VESTA/conf/vesta.conf -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-web-domain b/bin/v-add-web-domain deleted file mode 100755 index 12de353a5..000000000 --- a/bin/v-add-web-domain +++ /dev/null @@ -1,181 +0,0 @@ -#!/bin/bash -# info: add web domain -# options: USER DOMAIN [IP] [ALIASES] [PROXY_EXTENSIONS] [RESTART] -# -# The function adds virtual host to a server. In cases when ip is -# undefined in the script, "default" template will be used. The alias of -# www.domain.tld type will be automatically assigned to the domain unless -# "none" is transmited as argument. If ip have associated dns name, this -# domain will also get the alias domain-tpl.$ipname. An alias with the ip -# name is useful during the site testing while dns isn't moved to server yet. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -ip=$3 -restart=$4 # will be moved to the end soon -aliases=$5 -proxy_ext=$6 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -format_aliases - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -check_args '2' "$#" 'USER DOMAIN [IP] [RESTART] [ALIASES] [PROXY_EXTENSIONS]' -is_format_valid 'user' 'domain' 'aliases' 'ip' 'proxy_ext' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_package_full 'WEB_DOMAINS' 'WEB_ALIASES' -is_domain_new 'web' "$domain,$aliases" -is_dir_symlink $HOMEDIR/$user/web -if_dir_exists $HOMEDIR/$user/web/$domain -is_dir_symlink $HOMEDIR/$user/web/$domain -if [ ! -z "$ip" ]; then - is_ip_valid "$ip" "$user" -else - get_user_ip -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Reading user values -source $USER_DATA/user.conf - -# Creating domain directories -sudo -u $user mkdir -p $HOMEDIR/$user/web/$domain \ - $HOMEDIR/$user/web/$domain/public_html \ - $HOMEDIR/$user/web/$domain/public_shtml \ - $HOMEDIR/$user/web/$domain/document_errors \ - $HOMEDIR/$user/web/$domain/cgi-bin \ - $HOMEDIR/$user/web/$domain/private \ - $HOMEDIR/$user/web/$domain/stats \ - $HOMEDIR/$user/web/$domain/logs - -# Creating domain logs -touch /var/log/$WEB_SYSTEM/domains/$domain.bytes \ - /var/log/$WEB_SYSTEM/domains/$domain.log \ - /var/log/$WEB_SYSTEM/domains/$domain.error.log -ln -f -s /var/log/$WEB_SYSTEM/domains/$domain.*log \ - $HOMEDIR/$user/web/$domain/logs/ - -# Adding domain skeleton -sudo -u $user cp -r $WEBTPL/skel/* $HOMEDIR/$user/web/$domain/ >/dev/null 2>&1 -for file in $(find "$HOMEDIR/$user/web/$domain/" -type f); do - sed -i "s/%domain%/$domain/g" $file -done - -# Changing file owner & permission -chown -R $user:$user $HOMEDIR/$user/web/$domain -chown root:$user /var/log/$WEB_SYSTEM/domains/$domain.* $conf -chmod 640 /var/log/$WEB_SYSTEM/domains/$domain.* -sudo -u $user chmod 751 $HOMEDIR/$user/web/$domain $HOMEDIR/$user/web/$domain/* -sudo -u $user chmod 551 $HOMEDIR/$user/web/$domain/stats $HOMEDIR/$user/web/$domain/logs -sudo -u $user chmod 644 $HOMEDIR/$user/web/$domain/public_*html/*.* - -# Addding PHP-FPM backend -if [ ! -z "$WEB_BACKEND" ]; then - if [ -z "$BACKEND_TEMPLATE" ]; then - BACKEND_TEMPLATE='default' - if [ -z "$(grep BACKEND_TEMPLATE $USER_DATA/user.conf)" ]; then - sed -i "s/^DNS_TEMPL/BACKEND_TEMPLATE='default'\nDNS_TEMPL/g" \ - $USER_DATA/user.conf - else - update_user_value "$user" '$BACKEND_TEMPLATE' "default" - fi - fi - $BIN/v-add-web-domain-backend "$user" "$domain" $BACKEND_TEMPLATE - check_result $? "Backend error" >/dev/null -fi - -# Preparing domain aliases -if [ "$aliases" = 'none' ]; then - ALIAS='' -else - ALIAS="www.$domain" - if [ -z "$aliases" ]; then - ALIAS="www.$domain" - else - ALIAS="$aliases" - fi - - ip_alias=$(get_ip_alias $domain) - if [ ! -z "$ip_alias" ]; then - ALIAS="$ALIAS,$ip_alias" - fi -fi - -# Preparing domain variables -prepare_web_domain_values - -# Adding web server config -add_web_config "$WEB_SYSTEM" "$WEB_TEMPLATE.tpl" - -# Adding proxy config -if [ ! -z "$PROXY_SYSTEM" ]; then - PROXY_EXT="$proxy_ext" - if [ -z "$proxy_ext" ]; then - PROXY_EXT="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls" - PROXY_EXT="$PROXY_EXT,exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp" - PROXY_EXT="$PROXY_EXT,rtf,js,mp3,avi,mpeg,flv,html,htm" - fi - add_web_config "$PROXY_SYSTEM" "$PROXY_TEMPLATE.tpl" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing counters -increase_ip_value "$local_ip" -increase_user_value "$user" '$U_WEB_DOMAINS' -increase_user_value "$user" '$U_WEB_ALIASES' "$alias_number" - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Adding domain in web.conf -echo "DOMAIN='$domain' IP='$ip' IP6='' ALIAS='$ALIAS' TPL='$WEB_TEMPLATE'\ - SSL='no' SSL_HOME='same' LETSENCRYPT='no' FTP_USER='' FTP_MD5=''\ - BACKEND='$BACKEND_TEMPLATE' PROXY='$PROXY_TEMPLATE' PROXY_EXT='$PROXY_EXT'\ - STATS='' STATS_USER='' STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0'\ - SUSPENDED='no' TIME='$time' DATE='$date'" >> $USER_DATA/web.conf - -# Restarting web server -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -# Restarting proxy server -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Logging -log_history "added web domain $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-web-domain-alias b/bin/v-add-web-domain-alias deleted file mode 100755 index e5676af4e..000000000 --- a/bin/v-add-web-domain-alias +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash -# info: add web domain alias -# options: USER DOMAIN ALIASES [RESTART] -# -# The call is intended for adding aliases to a domain (it is also called -# "domain parking"). The function supports wildcards *.domain.tpl. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -aliases=$3 -restart="$4" - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? -format_aliases - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ALIASES [RESTART]' -is_format_valid 'user' 'domain' 'dom_alias' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_domain_new 'web' "$aliases" -is_package_full 'WEB_ALIASES' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' - -# Preparing domain values for the template substitution -local_ip=$(get_real_ip $IP) -if [ -z "$ALIAS" ]; then - ALIAS="$aliases" -else - ALIAS="$ALIAS,$aliases" -fi -prepare_web_domain_values - -# Rebuilding vhost -del_web_config "$WEB_SYSTEM" "$TPL.tpl" -add_web_config "$WEB_SYSTEM" "$TPL.tpl" -if [ "$SSL" = 'yes' ]; then - del_web_config "$WEB_SYSTEM" "$TPL.stpl" - add_web_config "$WEB_SYSTEM" "$TPL.stpl" -fi - -# Rebuilding proxy configuration -if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.tpl" - add_web_config "$PROXY_SYSTEM" "$PROXY.tpl" - if [ "$SSL" = 'yes' ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.stpl" - add_web_config "$PROXY_SYSTEM" "$PROXY.stpl" - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding new alias -update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS" -increase_user_value "$user" '$U_WEB_ALIASES' - -# Restarting web server -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -# Restarting proxy server -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - - -log_history "added $aliases for $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-web-domain-backend b/bin/v-add-web-domain-backend deleted file mode 100755 index 8cafa987f..000000000 --- a/bin/v-add-web-domain-backend +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -# info: add web domain backend -# options: USER DOMAIN [TEMPLATE] [RESTART] -# -# The call is used for adding web backend configuration. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -template=${3-default} -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [TEMPLATE] [RESTART]' -is_system_enabled "$WEB_BACKEND" 'WEB_BACKEND' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_backend_template_valid "$template" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining pool directory -prepare_web_backend - -# Checking backend configuration -if [ -e "$pool/$backend_type.conf" ]; then - exit -fi - -# Allocating backend port -backend_port=9000 -ports=$(grep listen $pool/* 2>/dev/null |grep -o :[0-9].*) -ports=$(echo "$ports" |sed "s/://" |sort -n) -for port in $ports; do - if [ "$backend_port" -eq "$port" ]; then - backend_port=$((backend_port + 1)) - fi -done - -# Adding backend config -cat $WEBTPL/$WEB_BACKEND/$template.tpl |\ - sed -e "s|%backend_port%|$backend_port|" \ - -e "s|%user%|$user|g"\ - -e "s|%domain%|$domain|g"\ - -e "s|%backend%|$backend_type|g" > $pool/$backend_type.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart backend server -$BIN/v-restart-web-backend $restart -check_result $? "Web backend restart failed" >/dev/null - -# Logging -log_history "added $WEB_BACKEND backend configuration for $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-web-domain-ftp b/bin/v-add-web-domain-ftp deleted file mode 100755 index 089991243..000000000 --- a/bin/v-add-web-domain-ftp +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash -# info: add ftp account for web domain. -# options: USER DOMAIN FTP_USER FTP_PASSWORD [FTP_PATH] -# -# The function creates additional ftp account for web domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -ftp_user=${1}_${3} -password=$4; HIDE=4 -ftp_path=$5 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD [FTP_PATH]' -is_format_valid 'user' 'domain' 'ftp_user' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -check_ftp_user=$(grep "^$ftp_user:" /etc/passwd) -if [ ! -z "$check_ftp_user" ] && [ "$FTP_USER" != "$ftp_user" ]; then - echo "Error: ftp user $ftp_user already exists" - log_event "$E_EXISTS" "$ARGUMENTS" - exit $E_EXISTS -fi -is_password_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get domain values -get_domain_values 'web' - -# Defining ftp user shell -shell=$(which nologin) -if [ ! -z "$FTP_SHELL" ]; then - shell=$FTP_SHELL -fi - -# Defining path -if [ -z "$ftp_path" ]; then - ftp_path_a="$HOMEDIR/$user/web/$domain" -else - # Validating absolute path - ftp_path_a=$(readlink -f "$HOMEDIR/$user/web/$domain/$ftp_path") - if [ -z "$(echo $ftp_path_a |grep $HOMEDIR/$user/web/$domain)" ]; then - echo "Error: absolute path $ftp_path_a is invalid" - log_event "$E_INVALID" "$ARGUMENTS" - exit $E_INVALID - fi - # Creating ftp user home directory - if [ ! -e "$ftp_path_a" ]; then - mkdir -p $ftp_path_a - chown $user:$user "$ftp_path_a" - chmod 751 "$ftp_path_a" - fi -fi - -# Adding ftp user -/usr/sbin/useradd $ftp_user \ - -s $shell \ - -o -u $(id -u $user) \ - -g $(id -g $user) \ - -M -d "$ftp_path_a" > /dev/null 2>&1 - -# Set ftp user password -echo "$ftp_user:$password" | /usr/sbin/chpasswd -ftp_md5=$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow) - -# Adding jailed sftp env -if [ ! -z "$SFTPJAIL_KEY" ]; then - $BIN/v-add-user-sftp-jail $ftp_user -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Transforming absolute path to relative -ftp_path_r=$(echo $ftp_path_a |sed "s%$HOMEDIR/$user/web/$domain%%") - -# Concatenating ftp variables -if [ ! -z "$FTP_USER" ]; then - ftp_user="$FTP_USER:$ftp_user" - ftp_md5="$FTP_MD5:$ftp_md5" - ftp_path="$FTP_PATH:$ftp_path_r" -fi - -# Adding new key into web.conf -add_object_key "web" 'DOMAIN' "$domain" 'FTP_PATH' 'PROXY' - -# Updating config -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user" -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5" -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_PATH' "$ftp_path" - -# Logging -log_history "added ftp account ${1}_${3}@$domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-web-domain-httpauth b/bin/v-add-web-domain-httpauth deleted file mode 100755 index e99384c10..000000000 --- a/bin/v-add-web-domain-httpauth +++ /dev/null @@ -1,115 +0,0 @@ -#!/bin/bash -# info: add password protection for web domain -# options: USER DOMAIN AUTH_USER AUTH_PASSWORD [RESTART] -# -# The call is used for securing web domain with http auth - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -auth_user=$3 -password=$4; HIDE=4 -restart=${5-yes} - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Defining htpasswd file -htaccess="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.conf_htaccess" -htpasswd="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.htpasswd" -shtaccess="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.conf_htaccess" -shtpasswd="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.htpasswd" -docroot="$HOMEDIR/$user/web/$domain/public_html" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN AUTH_USER AUTH_PASSWORD [RESTART]' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_password_valid -get_domain_values 'web' -if [ ! -z "$(echo "$AUTH_USER" |tr : '\n' |grep ^$auth_user$)" ]; then - echo "Error: auth user $auth_user already exists" - log_event "$E_EXISTS" "$ARGUMENTS" - exit $E_EXISTS -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding htaccess password protection -if [ ! -e "$htaccess" ]; then - if [ "$WEB_SYSTEM" != 'nginx' ]; then - echo "" > $htaccess - echo " AuthUserFile $htpasswd" >> $htaccess - echo " AuthName \"$domain access\"" >> $htaccess - echo " AuthType Basic" >> $htaccess - echo " Require valid-user" >> $htaccess - echo "" >> $htaccess - else - echo "auth_basic \"$domain password access\";" > $htaccess - echo "auth_basic_user_file $htpasswd;" >> $htaccess - fi - restart_required='yes' -fi - -# Adding httpasswd user -auth_hash=$($BIN/v-generate-password-hash htpasswd htpasswd $password) -touch $htpasswd -chmod 640 $htpasswd $htaccess -chgrp $user $htpasswd $htaccess -sed -i "/^$auth_user:/d" $htpasswd -echo "$auth_user:$auth_hash" >> $htpasswd - -# Symbolic link for secure web templates -if [ ! -L $shtpasswd ]; then - ln -s $htpasswd $shtpasswd -fi -if [ ! -L $shtaccess ]; then - ln -s $htaccess $shtaccess -fi - -# Restarting web server -if [ "$restart" != 'no' ] && [ "$restart_required" = 'yes' ]; then - $BIN/v-restart-web -fi - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Preparing web.conf keys -if [ ! -z "$AUTH_USER" ]; then - auth_user="$AUTH_USER:$auth_user" - auth_hash="$AUTH_HASH:$auth_hash" -else - # Adding new key into web.conf - add_object_key "web" 'DOMAIN' "$domain" 'AUTH_USER' 'U_DISK' - add_object_key "web" 'DOMAIN' "$domain" 'AUTH_HASH' 'U_DISK' -fi - -# Updating config -update_object_value 'web' 'DOMAIN' "$domain" '$AUTH_USER' "$auth_user" -update_object_value 'web' 'DOMAIN' "$domain" '$AUTH_HASH' "$auth_hash" - -# Logging -log_history "added http auth user $httpauth_user on $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-web-domain-proxy b/bin/v-add-web-domain-proxy deleted file mode 100755 index 9bd42746d..000000000 --- a/bin/v-add-web-domain-proxy +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -# info: add webdomain proxy support -# options: USER DOMAIN [TEMPLATE] [EXTENTIONS] [RESTART] -# -# The function enables proxy support for a domain. This can significantly -# improve website speed. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -template=$3 -default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\ -exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm" -extentions=${4-$default_extentions} -restart="$5" - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [TEMPLATE] [EXTENTIONS] [RESTART]' -is_format_valid 'user' 'domain' 'extentions' -is_system_enabled "$PROXY_SYSTEM" 'PROXY_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_empty 'web' 'DOMAIN' "$domain" '$PROXY' -if [ -z $template ]; then - template=$(get_user_value '$PROXY_TEMPLATE') -fi -is_proxy_template_valid $template - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining domain parameters -get_domain_values 'web' -prepare_web_domain_values -local_ip=$(get_real_ip $IP) - -# Preparing domain values for the template substitution -PROXY_EXT="$extentions" -add_web_config "$PROXY_SYSTEM" "$template.tpl" - -# Adding proxy for ssl -if [ "$SSL" = 'yes' ]; then - add_web_config "$PROXY_SYSTEM" "$template.stpl" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$template" -update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions" - -# Restarting web server -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -log_history "enabled proxy support for $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-web-domain-ssl b/bin/v-add-web-domain-ssl deleted file mode 100755 index 2c0f78aef..000000000 --- a/bin/v-add-web-domain-ssl +++ /dev/null @@ -1,156 +0,0 @@ -#!/bin/bash -# info: adding ssl for domain -# options: USER DOMAIN SSL_DIR [SSL_HOME] [RESTART] -# -# The function turns on SSL support for a domain. Parameter ssl_dir is a path -# to directory where 2 or 3 ssl files can be found. Certificate file -# domain.tld.crt and its key domain.tld.key are mandatory. Certificate -# authority domain.tld.ca file is optional. If home directory parameter -# (ssl_home) is not set, https domain uses public_shtml as separate -# documentroot directory. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -ssl_dir=$3 -ssl_home=${4-same} -restart="$5" - -# Additional argument formatting -if [[ "$domain" =~ [[:upper:]] ]]; then - domain=$(echo "$domain" |tr '[:upper:]' '[:lower:]') -fi -if [[ "$domain" =~ ^www\..* ]]; then - domain=$(echo "$domain" |sed -e "s/^www.//") -fi -if [[ "$domain" =~ .*\.$ ]]; then - domain=$(echo "$domain" |sed -e "s/\.$//") -fi - -domain=$(idn -t --quiet -u "$domain" ) -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN SSL_DIR [SSL_HOME] [RESTART]' -is_format_valid 'user' 'domain' 'ssl_dir' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_system_enabled "$WEB_SSL" 'SSL_SUPPORT' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_empty 'web' 'DOMAIN' "$domain" '$SSL' -is_web_domain_cert_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding certificate to user data directory -cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt -cp -f $ssl_dir/$domain.key $USER_DATA/ssl/$domain.key -cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem -if [ -e "$ssl_dir/$domain.ca" ]; then - cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca - echo >> $USER_DATA/ssl/$domain.pem - cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem -fi -chmod 660 $USER_DATA/ssl/$domain.* - -# Adding certificate to user dir -cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/web/ssl.$domain.crt -cp -f $USER_DATA/ssl/$domain.key $HOMEDIR/$user/conf/web/ssl.$domain.key -cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/web/ssl.$domain.pem -if [ -e "$USER_DATA/ssl/$domain.ca" ]; then - cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/web/ssl.$domain.ca -fi - -# Parsing domain values -get_domain_values 'web' -local_ip=$(get_real_ip $IP) - -# Preparing domain values for the template substitution -SSL_HOME="$ssl_home" -prepare_web_domain_values - -# Adding domain to the web config -add_web_config "$WEB_SYSTEM" "$TPL.stpl" - -# Checking proxy config -if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then - add_web_config "$PROXY_SYSTEM" "$PROXY.stpl" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing domain value -increase_user_value "$user" '$U_WEB_SSL' - -# Adding ssl values -update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME" -update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes" - -# Restarting web server -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Updating system ssl dependencies -if [ ! -z "$VESTA_CERTIFICATE" ]; then - crt_user=$(echo "$VESTA_CERTIFICATE" |cut -f 1 -d :) - crt_domain=$(echo "$VESTA_CERTIFICATE" |cut -f 2 -d :) - if [ "$user" = "$crt_user" ] && [ "$domain" = "$crt_domain" ]; then - $BIN/v-add-sys-vesta-ssl $user $domain >/dev/null 2>&1 - fi -fi -if [ ! -z "$MAIL_CERTIFICATE" ]; then - crt_user=$(echo "$MAIL_CERTIFICATE" |cut -f 1 -d :) - crt_domain=$(echo "$MAIL_CERTIFICATE" |cut -f 2 -d :) - if [ "$user" = "$crt_user" ] && [ "$domain" = "$crt_domain" ]; then - $BIN/v-add-sys-mail-ssl $user $domain >/dev/null 2>&1 - fi -fi - -if [ ! -z "$UPDATE_HOSTNAME_SSL" ] && [ "$UPDATE_HOSTNAME_SSL" = "yes" ]; then - hostname=$(hostname) - if [ "$hostname" = "$domain" ]; then - $BIN/v-update-host-certificate $user $domain - fi -fi - -UPDATE_SSL_SCRIPT='' -source $VESTA/conf/vesta.conf -if [ ! -z "$UPDATE_SSL_SCRIPT" ]; then - eval "$UPDATE_SSL_SCRIPT $user $domain" -fi - -# Logging -log_history "enabled ssl support for $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-add-web-domain-stats b/bin/v-add-web-domain-stats deleted file mode 100755 index 8da1451f8..000000000 --- a/bin/v-add-web-domain-stats +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/bash -# info: add log analyzer to generate domain statitics -# options: USER DOMAIN TYPE -# -# The call is used for enabling log analyzer system to a domain. At this time -# two types of these system is supported - awstats and webalizer. For viewing -# the domain statistics use http://domain.tld/vstats/ link. Access this page -# is not protected by default. If you want to secure it with passwords you -# should use v-add-web-domain_stat_auth script. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -type=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN TYPE' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_type_valid "$STATS_SYSTEM" "$type" -is_object_valid 'user' 'USER' "$user" "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_empty 'web' 'DOMAIN' "$domain" '$STATS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parse aliases -get_domain_values 'web' - -# Adding statistic config -prepare_web_domain_values -cat $WEBTPL/$type/$type.tpl |\ - sed -e "s|%ip%|$ip|g" \ - -e "s|%web_port%|$WEB_PORT|g" \ - -e "s|%web_system%|$WEB_SYSTEM|g" \ - -e "s|%web_ssl_port%|$WEB_SSL_PORT|g" \ - -e "s|%rgroups%|$WEB_RGROUPs|g" \ - -e "s|%proxy_system%|$PROXY_SYSTEM|g" \ - -e "s|%proxy_port%|$PROXY_PORT|g" \ - -e "s|%proxy_ssl_port%|$PROXY_SSL_PORT|g" \ - -e "s|%domain_idn%|$domain_idn|g" \ - -e "s|%domain%|$domain|g" \ - -e "s|%user%|$user|g" \ - -e "s|%home%|$HOMEDIR|g" \ - -e "s|%alias%|${aliases//,/ }|g" \ - -e "s|%alias_idn%|${aliases_idn//,/ }|g" \ - > $HOMEDIR/$user/conf/web/$type.$domain.conf - -if [ "$type" == 'awstats' ]; then - rm -f /etc/awstats/$type.$domain_idn.conf - ln -s $HOMEDIR/$user/conf/web/$type.$domain.conf \ - /etc/awstats/$type.$domain_idn.conf -else - mkdir -p /var/lib/webalizer -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Schedule statistic processing -echo "$BIN/v-update-web-domain-stat $user $domain" >> \ - $VESTA/data/queue/webstats.pipe - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type" - -# Logging -log_history "enabled web log analyzer for $domain" -log_event "$OK" "$ARGUMENTS" - -# Build stats -exec $BIN/v-update-web-domain-stat $user $domain - -exit diff --git a/bin/v-add-web-domain-stats-user b/bin/v-add-web-domain-stats-user deleted file mode 100755 index 1de3ba590..000000000 --- a/bin/v-add-web-domain-stats-user +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash -# info: add password protection to web domain statistics -# options: USER DOMAIN STATS_USER STATS_PASSWORD [RESTART] -# -# The call is used for securing the web statistics page. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -stats_user=$3 -password=$4; HIDE=4 -restart=$5 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN STATS_USER STATS_PASS [RESTART]' -is_format_valid 'user' 'domain' 'stats_user' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_password_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining statistic dir -stats_dir="$HOMEDIR/$user/web/$domain/stats" -conf_dir="$HOMEDIR/$user/conf/web" - -# Adding htaccess file -if [ "$WEB_SYSTEM" = 'nginx' ]; then - echo "auth_basic \"Web Statistics\";" > $conf_dir/$domain.auth - echo "auth_basic_user_file $stats_dir/.htpasswd;" >> $conf_dir/$domain.auth -else - echo "AuthUserFile $stats_dir/.htpasswd" > $stats_dir/.htaccess - echo "AuthName \"Web Statistics\"" >> $stats_dir/.htaccess - echo "AuthType Basic" >> $stats_dir/.htaccess - echo "Require valid-user" >> $stats_dir/.htaccess -fi - -# Generating htaccess user and password -salt=$(generate_password "$PW_MATRIX" "8") -stats_pass=$($BIN/v-generate-password-hash md5 $salt $password) -echo "$stats_user:$stats_pass" > $stats_dir/.htpasswd - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding stats user in config -update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' "$stats_user" -update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' "$stats_pass" - -# Restarting web server -if [ "$WEB_SYSTEM" = 'nginx' ]; then - $BIN/v-restart-web $restart - check_result $? "Web restart failed" >/dev/null -fi - -# Logging -log_history "added password protection for web stats on $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-backup-user b/bin/v-backup-user deleted file mode 100755 index 4bb857eaf..000000000 --- a/bin/v-backup-user +++ /dev/null @@ -1,942 +0,0 @@ -#!/bin/bash -# info: backup system user with all its objects -# options: USER NOTIFY -# -# The call is used for backing up user with all its domains and databases. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system variables -source /etc/profile - -# Argument definition -user=$1 -notify=${2-no} - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/db.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [NOTIFY]' -is_format_valid 'user' -is_system_enabled "$BACKUP_SYSTEM" 'BACKUP_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_backup_enabled - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Set backup directory if undefined -if [ -z "$BACKUP" ]; then - BACKUP=/backup -fi -mkdir -p $BACKUP - -# Get current time -start_time=$(date '+%s') - -# Set notification email and subject -subj="$user → backup failed" -email=$(grep CONTACT $VESTA/data/users/admin/user.conf |cut -f 2 -d \') - -# Checking load average -la=$(cat /proc/loadavg |cut -f 1 -d ' ' |cut -f 1 -d '.') -i=0 -while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do - echo -e "$(date "+%F %T") Load Average $la" - sleep 60 - if [ "$i" -ge "15" ]; then - la_error="LoadAverage $la is above threshold" - echo "$la_error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result $E_LA "$la_error" - fi - la=$(cat /proc/loadavg |cut -f 1 -d ' ' |cut -f 1 -d '.') - (( ++i)) -done - -if [ -z "$BACKUP_TEMP" ]; then - BACKUP_TEMP=$BACKUP -fi - -# Creating temporary directory -tmpdir=$(mktemp -p $BACKUP_TEMP -d) - -if [ "$?" -ne 0 ]; then - echo "Can't create tmp dir $tmpdir" |$SENDMAIL -s "$subj" $email $notify - check_result $E_NOTEXIST "can't create tmp dir" -fi - -# Backup sys configs -echo "-- SYSTEM --" |tee $BACKUP/$user.log -mkdir $tmpdir/vesta - -echo -e "$(date "+%F %T") $user.conf" |tee -a $BACKUP/$user.log -cp -r $USER_DATA/user.conf $tmpdir/vesta/ -cp -r $USER_DATA/ssl $tmpdir/vesta/ - -if [ -e "$USER_DATA/stats.log" ]; then - echo -e "$(date "+%F %T") stats.log" |tee -a $BACKUP/$user.log - cp -r $USER_DATA/stats.log $tmpdir/vesta/ -fi - -if [ -e "$USER_DATA/history.log" ]; then - echo -e "$(date "+%F %T") history.log" |tee -a $BACKUP/$user.log - cp -r $USER_DATA/history.log $tmpdir/vesta/ -fi - -if [ -e "$USER_DATA/backup-excludes.conf" ]; then - echo -e "$(date "+%F %T") backup-excludes.conf" |tee -a $BACKUP/$user.log - cp -r $USER_DATA/backup-excludes.conf $tmpdir/vesta/ -fi - -# Backup PAM -mkdir $tmpdir/pam -echo -e "$(date "+%F %T") pam" |tee -a $BACKUP/$user.log -grep "^$user:" /etc/passwd > $tmpdir/pam/passwd -grep "^$user:" /etc/shadow > $tmpdir/pam/shadow -grep "^$user:" /etc/group > $tmpdir/pam/group -echo - -# Parsing excludes -if [ -e "$USER_DATA/backup-excludes.conf" ]; then - source $USER_DATA/backup-excludes.conf -fi - -# WEB domains -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then - echo -e "\n-- WEB --" |tee -a $BACKUP/$user.log - mkdir $tmpdir/web/ - - # Parsing domain exclusions - conf="$USER_DATA/web.conf" - for domain in $(search_objects 'web' 'SUSPENDED' "*" 'DOMAIN'); do - exclusion=$(echo -e "$WEB" |tr ',' '\n' |grep "^$domain$") - if [ -z "$exclusion" ]; then - web_list="$web_list $domain" - else - echo "$(date "+%F %T") excluding $domain"|tee -a $BACKUP/$user.log - fi - done - web_list=$(echo "$web_list" |sed -e "s/ */\ /g" -e "s/^ //") - - i=0 - - for domain in $web_list; do - ((i ++)) - echo -e "$(date "+%F %T") $domain" |tee -a $BACKUP/$user.log - mkdir -p $tmpdir/web/$domain/conf - mkdir -p $tmpdir/web/$domain/vesta - - # Get domain variables - domain_idn=$domain - format_domain_idn - get_domain_values 'web' - - # Backup web.conf - cd $tmpdir/web/$domain/ - conf="$USER_DATA/web.conf" - grep "DOMAIN='$domain'" $conf > vesta/web.conf - - # Backup vhost config - conf=$HOMEDIR/$user/conf/web/$domain.$WEB_SYSTEM.conf - if [ -e "$conf" ]; then - cp $conf conf/$WEB_SYSTEM.conf - else - # old style configs - tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl" - conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf" - get_web_config_lines $tpl_file $conf - sed -n "$top_line,$bottom_line p" $conf > conf/$WEB_SYSTEM.conf - fi - - # Backup ssl vhost - if [ "$SSL" = 'yes' ]; then - conf=$HOMEDIR/$user/conf/web/$domain.$WEB_SYSTEM.ssl.conf - if [ -e "$conf" ]; then - cp $conf conf/$WEB_SYSTEM.ssl.conf - else - tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf" - get_web_config_lines $tpl_file $conf - sed -n "$top_line,$bottom_line p" $conf > \ - conf/s$WEB_SYSTEM.conf - fi - fi - - # Backup proxy config - if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then - conf=$HOMEDIR/$user/conf/web/$domain.$PROXY_SYSTEM.conf - if [ -e "$conf" ]; then - cp $conf conf/$PROXY_SYSTEM.conf - else - tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl" - conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf" - get_web_config_lines $tpl_file $conf - sed -n "$top_line,$bottom_line p" $conf > \ - conf/$PROXY_SYSTEM.conf - fi - fi - - # Backup ssl proxy config - if [ ! -z "$PROXY_SYSTEM" ] && [ "$SSL" = 'yes' ]; then - conf=$HOMEDIR/$user/conf/web/$domain.$PROXY_SYSTEM.ssl.conf - if [ -e "$conf" ]; then - cp $conf conf/$PROXY_SYSTEM.ssl.conf - else - tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl" - conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf" - get_web_config_lines $tpl_file $conf - sed -n "$top_line,$bottom_line p" $conf >\ - conf/s$PROXY_SYSTEM.conf - fi - fi - - # Backup custom config / backup LE config - for sconfig in $(ls $HOMEDIR/$user/conf/web/|grep ".$domain.conf"); do - cp $HOMEDIR/$user/conf/web/$sconfig conf/ - done - - # Backup ssl certificates - if [ "$SSL" = 'yes' ] ; then - cp $HOMEDIR/$user/conf/web/ssl.$domain.* conf/ - cp $USER_DATA/ssl/$domain.* vesta/ - fi - - # Changin dir to documentroot - cd $HOMEDIR/$user/web/$domain - - # Define exclude arguments - exlusion=$(echo -e "$WEB" |tr ',' '\n' |grep "^$domain:") - set -f - fargs=() - fargs+=(--exclude='./logs/*') - if [ ! -z "$exlusion" ]; then - xdirs="$(echo -e "$exlusion" |tr ':' '\n' |grep -v $domain)" - for xpath in $xdirs; do - if [ -d "$xpath" ]; then - fargs+=(--exclude=$xpath/*) - echo "$(date "+%F %T") excluding directory $xpath" - msg="$msg\n$(date "+%F %T") excluding directory $xpath" - else - echo "$(date "+%F %T") excluding file $xpath" - msg="$msg\n$(date "+%F %T") excluding file $xpath" - fargs+=(--exclude=$xpath) - fi - done - fi - set +f - - # Backup files - tar --anchored -cpf- ${fargs[@]} * |gzip -$BACKUP_GZIP - > $tmpdir/web/$domain/domain_data.tar.gz - done - - # Print total - if [ "$i" -eq 1 ]; then - echo -e "$(date "+%F %T") *** $i domain ***" |tee -a $BACKUP/$user.log - else - echo -e "$(date "+%F %T") *** $i domains ***"|tee -a $BACKUP/$user.log - fi -fi - -# DNS domains -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS" != '*' ]; then - echo -e "\n-- DNS --" |tee -a $BACKUP/$user.log - mkdir $tmpdir/dns/ - - # Parsing domain exclusions - for domain in $(search_objects 'dns' 'SUSPENDED' "*" 'DOMAIN'); do - exclusion=$(echo "$DNS" |tr ',' '\n' |grep "^$domain$") - if [ -z "$exclusion" ]; then - dns_list="$dns_list $domain" - else - echo "$(date "+%F %T") excluding $domain" - msg="$msg\n$(date "+%F %T") excluding $domain" - fi - done - dns_list=$(echo "$dns_list" |sed -e "s/ */\ /g" -e "s/^ //") - - i=0 - for domain in $dns_list; do - ((i ++)) - echo -e "$(date "+%F %T") $domain" |tee -a $BACKUP/$user.log - - # Building directory tree - mkdir -p $tmpdir/dns/$domain/conf - mkdir -p $tmpdir/dns/$domain/vesta - - # Backup dns.conf - cd $tmpdir/dns/$domain/ - conf="$USER_DATA/dns.conf" - grep "DOMAIN='$domain'" $conf > vesta/dns.conf - - # Backup dns recods - cp $USER_DATA/dns/$domain.conf vesta/$domain.conf - if [ "$DNS_SYSTEM" != 'remote' ]; then - cp $HOMEDIR/$user/conf/dns/$domain.db conf/$domain.db - fi - done - - # Print total - if [ "$i" -eq 1 ]; then - echo -e "$(date "+%F %T") *** $i domain ***" |tee -a $BACKUP/$user.log - else - echo -e "$(date "+%F %T") *** $i domains ***"|tee -a $BACKUP/$user.log - fi -fi - -# Mail domains -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then - echo -e "\n-- MAIL --" |tee -a $BACKUP/$user.log - mkdir $tmpdir/mail/ - - # Parsing domain exclusions - conf="$USER_DATA/mail.conf" - for domain in $(search_objects 'mail' 'SUSPENDED' "*" 'DOMAIN'); do - check_exl=$(echo "$MAIL" |tr ',' '\n' |grep "^$domain$") - if [ -z "$check_exl" ]; then - mail_list="$mail_list $domain" - else - echo "$(date "+%F %T") excluding $domain"|tee -a $BACKUP/$user.log - fi - done - mail_list=$(echo "$mail_list" |sed -e "s/ */\ /g" -e "s/^ //") - - i=0 - for domain in $mail_list; do - ((i ++)) - echo -e "$(date "+%F %T") $domain" |tee -a $BACKUP/$user.log - mkdir -p $tmpdir/mail/$domain/conf - mkdir -p $tmpdir/mail/$domain/vesta - domain_idn=$domain - format_domain_idn - - # Backup exim config - if [[ "$MAIL_SYSTEM" =~ exim ]]; then - cd $tmpdir/mail/$domain/ - cp $HOMEDIR/$user/conf/mail/$domain/* conf/ - fi - - # Backup mail.conf - conf="$USER_DATA/mail.conf" - grep "DOMAIN='$domain'" $conf > vesta/mail.conf - cp $USER_DATA/mail/$domain.* vesta/ - if [ ! -z "$(ls $USER_DATA/mail/|grep *@$domain)" ]; then - cp $USER_DATA/mail/*@$domain.* vesta/ - fi - - # Backup emails - cd $HOMEDIR/$user/mail/$domain_idn - accounts=() - for account in $(ls); do - exclusion=$(echo "$MAIL" |tr ',' '\n' |grep "$domain:") - exclusion=$(echo "$exclusion" |tr ':' '\n' |grep "^$account$") - - # Checking exlusions - if [ -z "$exclusion" ] && [[ "$MAIL_SYSTEM" =~ exim ]]; then - accounts+=($account) - else - echo "$(date "+%F %T") excluding mail account $account" |\ - tee -a $BACKUP/$user.log - fi - done - - # Compress archive - if [ ${#accounts[@]} -gt 0 ]; then - tar -cpf- ${accounts[@]} |gzip -$BACKUP_GZIP - > $tmpdir/mail/$domain/accounts.tar.gz - fi - done - - # Print total - if [ "$i" -eq 1 ]; then - echo -e "$(date "+%F %T") *** $i domain ***" |tee -a $BACKUP/$user.log - else - echo -e "$(date "+%F %T") *** $i domains ***"|tee -a $BACKUP/$user.log - fi -fi - - -# Databases -if [ ! -z "$DB_SYSTEM" ] && [ "$DB" != '*' ]; then - echo -e "\n-- DB --" |tee -a $BACKUP/$user.log - mkdir $tmpdir/db/ - - # Parsing database exclusions - for database in $(search_objects 'db' 'SUSPENDED' "*" 'DB'); do - exclusion=$(echo "$DB" |tr ',' '\n' |grep "^$database$") - if [ -z "$exclusion" ]; then - db_list="$db_list $database" - else - echo "$(date "+%F %T") excluding $database" |\ - tee -a $BACKUP/$user.log - fi - done - - i=0 - conf="$USER_DATA/db.conf" - db_list=$(echo "$db_list" |sed -e "s/ */\ /g" -e "s/^ //") - for database in $db_list; do - ((i ++)) - get_database_values - - echo -e "$(date "+%F %T") $database ($TYPE)" |tee -a $BACKUP/$user.log - mkdir -p $tmpdir/db/$database/conf - mkdir -p $tmpdir/db/$database/vesta - - cd $tmpdir/db/$database/ - grep "DB='$database'" $conf > vesta/db.conf - - dump="$tmpdir/db/$database/$database.$TYPE.sql" - dumpgz="$tmpdir/db/$database/$database.$TYPE.sql.gz" - grants="$tmpdir/db/$database/conf/$database.$TYPE.$DBUSER" - if [ ! -f "$dumpgz" ]; then - case $TYPE in - mysql) dump_mysql_database ;; - pgsql) dump_pgsql_database ;; - esac - - # Compress dump - gzip -$BACKUP_GZIP $dump - fi - done - - # Print total - if [ "$i" -eq 1 ]; then - echo -e "$(date "+%F %T") *** $i database ***" |\ - tee -a $BACKUP/$user.log - else - echo -e "$(date "+%F %T") *** $i databases ***"|\ - tee -a $BACKUP/$user.log - fi -fi - -# Cron jobs -if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON" != '*' ]; then - echo -e "\n-- CRON --" |tee -a $BACKUP/$user.log - mkdir $tmpdir/cron/ - - # Backup cron.conf - cp $USER_DATA/cron.conf $tmpdir/cron/ - cron_record=$(wc -l $USER_DATA/cron.conf|cut -f 1 -d ' ') - - if [ -e "/var/spool/cron/$user" ]; then - cron_list="$cron_record" - cp /var/spool/cron/$user $tmpdir/cron/ - fi - - # Print total - if [ "$cron_record" -eq 1 ]; then - echo -e "$(date "+%F %T") *** $cron_record job ***" |\ - tee -a $BACKUP/$user.log - else - echo -e "$(date "+%F %T") *** $cron_record jobs ***" |\ - tee -a $BACKUP/$user.log - fi -fi - -# User Directories -if [ "$USER" != '*' ]; then - echo -e "\n-- User Dir --" |tee -a $BACKUP/$user.log - mkdir $tmpdir/user_dir - cd $HOMEDIR/$user - - # Parsing directory exlusions - USER='' - if [ -e "$USER_DATA/backup-excludes.conf" ]; then - source $USER_DATA/backup-excludes.conf - fi - fargs=() - for xpath in $(echo "$USER" |tr ',' '\n'); do - if [ -d "$xpath" ]; then - fargs+=(--exclude=$xpath/*) - echo "$(date "+%F %T") excluding directory $xpath" |\ - tee -a $BACKUP/$user.log - else - echo "$(date "+%F %T") excluding file $xpath" |\ - tee -a $BACKUP/$user.log - fargs+=(--exclude=$xpath) - fi - done - - IFS=$'\n' - set -f - i=0 - - for udir in $(ls -a |egrep -v "^conf$|^web$|^dns$|^mail$|^\.\.$|^\.$"); do - exclusion=$(echo "$USER" |tr ',' '\n' |grep "^$udir$") - if [ -z "$exclusion" ]; then - ((i ++)) - udir_str=$(echo "$udir" |sed -e "s|'|\\\'|g") - udir_list="$udir_list $udir_str" - echo -e "$(date "+%F %T") adding $udir" |tee -a $BACKUP/$user.log - - # Backup files and dirs - tar --anchored -cpf- ${fargs[@]} $udir |gzip -$BACKUP_GZIP - > $tmpdir/user_dir/$udir.tar.gz - fi - done - set +f - udir_list=$(echo "$udir_list" |sed -e "s/ */\ /g" -e "s/^ //") - - # Print total - if [ "$i" -eq 1 ]; then - echo -e "$(date "+%F %T") *** $i user directory ***" |\ - tee -a $BACKUP/$user.log - else - echo -e "$(date "+%F %T") *** $i directories ***" |\ - tee -a $BACKUP/$user.log - fi -fi - -# Get backup size -size="$(du -shm $tmpdir |cut -f 1)" - -# Get current time -end_time=$(date '+%s') -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) -backup_new_date=$(date +"%Y-%m-%d_%H-%M-%S") - -# Defining local storage function -local_backup(){ - - rm -f $BACKUP/$user.$backup_new_date.tar - - # Checking retention - backup_list=$(ls -lrt $BACKUP/ |awk '{print $9}' |grep "^$user\." | grep ".tar") - backups_count=$(echo "$backup_list" |wc -l) - if [ "$BACKUPS" -le "$backups_count" ]; then - backups_rm_number=$((backups_count - BACKUPS + 1)) - - # Removing old backup - for backup in $(echo "$backup_list" |head -n $backups_rm_number); do - backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar$//") - echo -e "$(date "+%F %T") Rotated: $backup_date" |\ - tee -a $BACKUP/$user.log - rm -f $BACKUP/$backup - done - fi - - # Checking disk space - disk_usage=$(df $BACKUP |tail -n1 |tr ' ' '\n' |grep % |cut -f 1 -d %) - if [ "$disk_usage" -ge "$BACKUP_DISK_LIMIT" ]; then - rm -rf $tmpdir - rm -f $BACKUP/$user.log - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - echo "Not enough disk space" |$SENDMAIL -s "$subj" $email $notify - check_result "$E_DISK" "Not enough dsk space" - fi - - # Creating final tarball - cd $tmpdir - tar -cf $BACKUP/$user.$backup_new_date.tar . - chmod 640 $BACKUP/$user.$backup_new_date.tar - chown admin:$user $BACKUP/$user.$backup_new_date.tar - localbackup='yes' - echo -e "$(date "+%F %T") Local: $BACKUP/$user.$backup_new_date.tar" |\ - tee -a $BACKUP/$user.log -} - - -# Defining ftp command function -ftpc() { - /usr/bin/ftp -np $HOST $PORT < /dev/null 2>&1 - ftmpdir="$BPATH/vst.bK76A9SUkt" - fi - ftpc "mkdir $ftmpdir" "rm $ftmpdir" - ftp_result=$(ftpc "mkdir $ftmpdir" "rm $ftmpdir" |grep -v Trying) - if [ ! -z "$ftp_result" ] ; then - error="Can't create ftp backup folder ftp://$HOST$BPATH" - rm -rf $tmpdir - rm -f $BACKUP/$user.log - echo "$error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_FTP" "$error" - fi - - # Checking retention - if [ -z $BPATH ]; then - backup_list=$(ftpc "ls" |awk '{print $9}' |grep "^$user\.") - else - backup_list=$(ftpc "cd $BPATH" "ls" |awk '{print $9}' |grep "^$user\.") - fi - backups_count=$(echo "$backup_list" |wc -l) - if [ "$backups_count" -ge "$BACKUPS" ]; then - backups_rm_number=$((backups_count - BACKUPS + 1)) - for backup in $(echo "$backup_list" |head -n $backups_rm_number); do - backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar$//") - echo -e "$(date "+%F %T") Rotated ftp backup: $backup_date" |\ - tee -a $BACKUP/$user.log - if [ -z $BPATH ]; then - ftpc "delete $backup" - else - ftpc "cd $BPATH" "delete $backup" - fi - done - fi - - # Uploading backup archive - if [ "$localbackup" = 'yes' ]; then - cd $BACKUP - if [ -z $BPATH ]; then - ftpc "put $user.$backup_new_date.tar" - else - ftpc "cd $BPATH" "put $user.$backup_new_date.tar" - fi - else - cd $tmpdir - tar -cf $BACKUP/$user.$backup_new_date.tar . - cd $BACKUP/ - if [ -z $BPATH ]; then - ftpc "put $user.$backup_new_date.tar" - else - ftpc "cd $BPATH" "put $user.$backup_new_date.tar" - fi - rm -f $user.$backup_new_date.tar - fi -} - -# sftp command function -sftpc() { - expect -f "-" <" { - if {\$count < \$argc} { - set arg [lindex \$argv \$count] - send "\$arg\r" - incr count - } else { - send "exit\r" - set output "Disconnected." - if {[info exists rc] != 1} { - set rc $OK - } - } - exp_continue - } - - timeout { - set output "Connection timeout." - set rc $E_CONNECT - } - } - - if {[info exists output] == 1} { - puts "\$output" - } - - exit \$rc -EOF -} - -sftp_backup() { - - # Checking config - if [ ! -e "$VESTA/conf/sftp.backup.conf" ]; then - error="Can't open sftp.backup.conf" - rm -rf $tmpdir - rm -f $BACKUP/$user.log - echo "$error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_NOTEXIST" "$error" - fi - - # Parse config - source $VESTA/conf/sftp.backup.conf - - # Set default port - if [ -z "$(grep 'PORT=' $VESTA/conf/sftp.backup.conf)" ]; then - PORT='22' - fi - - # Checking variables - if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then - error="Can't parse sftp backup configuration" - rm -rf $tmpdir - rm -f $BACKUP/$user.log - echo "$error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_PARSING" "$error" - fi - - # Debug info - echo -e "$(date "+%F %T") Remote: sftp://$HOST/$BPATH/$user.$backup_new_date.tar" |\ - tee -a $BACKUP/$user.log - - # Checking network connection and write permissions - if [ -z $BPATH ]; then - sftmpdir="vst.bK76A9SUkt" - else - sftmpdir="$BPATH/vst.bK76A9SUkt" - fi - sftpc "mkdir $BPATH" > /dev/null 2>&1 - sftpc "mkdir $sftmpdir" "rmdir $sftmpdir" > /dev/null 2>&1 - rc=$? - if [[ "$rc" != 0 ]]; then - case $rc in - $E_CONNECT) error="Can't login to sftp host $HOST" ;; - $E_FTP) error="Can't create temp folder on sftp $HOST" ;; - esac - rm -rf $tmpdir - rm -f $BACKUP/$user.log - echo "$error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$rc" "$error" - fi - - # Checking retention - if [ -z $BPATH ]; then - backup_list=$(sftpc "ls -l" |awk '{print $9}'|grep "^$user\.") - else - backup_list=$(sftpc "cd $BPATH" "ls -l" |awk '{print $9}'|grep "^$user\.") - fi - backups_count=$(echo "$backup_list" |wc -l) - if [ "$backups_count" -ge "$BACKUPS" ]; then - backups_rm_number=$((backups_count - BACKUPS + 1)) - for backup in $(echo "$backup_list" |head -n $backups_rm_number); do - backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar.*$//") - echo -e "$(date "+%F %T") Rotated sftp backup: $backup_date" |\ - tee -a $BACKUP/$user.log - if [ -z $BPATH ]; then - sftpc "rm $backup" > /dev/null 2>&1 - else - sftpc "cd $BPATH" "rm $backup" > /dev/null 2>&1 - fi - done - fi - - # Uploading backup archive - echo "$(date "+%F %T") Uploading $user.$backup_new_date.tar"|tee -a $BACKUP/$user.log - if [ "$localbackup" = 'yes' ]; then - cd $BACKUP - if [ -z $BPATH ]; then - sftpc "put $user.$backup_new_date.tar" "chmod 0600 $user.$backup_new_date.tar" > /dev/null 2>&1 - else - sftpc "cd $BPATH" "put $user.$backup_new_date.tar" "chmod 0600 $user.$backup_new_date.tar" > /dev/null 2>&1 - fi - else - cd $tmpdir - tar -cf $BACKUP/$user.$backup_new_date.tar . - cd $BACKUP/ - if [ -z $BPATH ]; then - sftpc "put $user.$backup_new_date.tar" "chmod 0600 $user.$backup_new_date.tar" > /dev/null 2>&1 - else - sftpc "cd $BPATH" "put $user.$backup_new_date.tar" "chmod 0600 $user.$backup_new_date.tar" > /dev/null 2>&1 - fi - rm -f $user.$backup_new_date.tar - fi -} - -google_backup() { - - # Defining google settings - source $VESTA/conf/google.backup.conf - gsutil="$VESTA/3rdparty/gsutil/gsutil" - export BOTO_CONFIG="$VESTA/conf/.google.backup.boto" - - # Debug info - echo -e "$(date "+%F %T") Remote: gs://$BUCKET/$BPATH/$user.$backup_new_date.tar" - - # Checking retention - backup_list=$(${gsutil} ls gs://$BUCKET/$BPATH/$user.* 2>/dev/null) - backups_count=$(echo "$backup_list" |wc -l) - if [ "$backups_count" -ge "$BACKUPS" ]; then - backups_rm_number=$((backups_count - BACKUPS)) - for backup in $(echo "$backup_list" |head -n $backups_rm_number); do - echo -e "$(date "+%F %T") Rotated gcp backup: $backup" - $gsutil rm $backup > /dev/null 2>&1 - done - fi - - # Uploading backup archive - echo -e "$(date "+%F %T") Uploading $user.$backup_new_date.tar ..." - if [ "$localbackup" = 'yes' ]; then - cd $BACKUP - ${gsutil} cp $user.$backup_new_date.tar gs://$BUCKET/$BPATH/ > /dev/null 2>&1 - else - cd $tmpdir - tar -cf $BACKUP/$user.$backup_new_date.tar . - cd $BACKUP/ - ${gsutil} cp $user.$backup_new_date.tar gs://$BUCKET/$BPATH/ > /dev/null 2>&1 - rc=$? - rm -f $user.$backup_new_date.tar - if [ "$rc" -ne 0 ]; then - check_result "$E_CONNECT" "gsutil failed to upload $user.$backup_new_date.tar" - fi - fi -} - - -echo -e "\n-- SUMMARY --" |tee -a $BACKUP/$user.log - -# Switching on backup system types -for backup_type in $(echo -e "${BACKUP_SYSTEM//,/\\n}"); do - case $backup_type in - local) local_backup ;; - ftp) ftp_backup ;; - sftp) sftp_backup ;; - google) google_backup ;; - esac -done - -# Removing tmpdir -rm -rf $tmpdir - -# Calculation run time -run_time=$((end_time - start_time)) -run_time=$((run_time / 60)) -current_time=$(date "+%T") -if [ "$run_time" -lt 1 ]; then - run_time=1 -fi -min=minutes -if [ "$run_time" -eq 1 ]; then - min=minute -fi - -echo "$(date "+%F %T") Size: $size MB" |tee -a $BACKUP/$user.log -echo "$(date "+%F %T") Runtime: $run_time $min" |tee -a $BACKUP/$user.log - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Removing duplicate -touch $USER_DATA/backup.conf -sed -i "/$user.$backup_new_date.tar/d" $USER_DATA/backup.conf - -# Registering new backup -backup_str="BACKUP='$user.$backup_new_date.tar'" -backup_str="$backup_str TYPE='$BACKUP_SYSTEM' SIZE='$size'" -backup_str="$backup_str WEB='${web_list// /,}'" -backup_str="$backup_str DNS='${dns_list// /,}'" -backup_str="$backup_str MAIL='${mail_list// /,}'" -backup_str="$backup_str DB='${db_list// /,}'" -backup_str="$backup_str CRON='$cron_list'" -backup_str="$backup_str UDIR='${udir_list// /,}'" -backup_str="$backup_str RUNTIME='$run_time' TIME='$time' DATE='$date'" -echo "$backup_str" >> $USER_DATA/backup.conf - -# Removing old backups -tail -n $BACKUPS $USER_DATA/backup.conf > $USER_DATA/backup.conf_ -mv -f $USER_DATA/backup.conf_ $USER_DATA/backup.conf -chmod 660 $USER_DATA/backup.conf - -# Deleting task from queue -sed -i "/v-backup-user $user /d" $VESTA/data/queue/backup.pipe - -U_BACKUPS=$(grep BACKUP $USER_DATA/backup.conf |wc -l) -update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS" - -# Send notification -if [ -e "$BACKUP/$user.log" ]; then - cd $BACKUP - subj="$user → backup has been completed" - email=$(get_user_value '$CONTACT') - cat $BACKUP/$user.log |$SENDMAIL -s "$subj" $email $notify - rm $BACKUP/$user.log -fi - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-backup-users b/bin/v-backup-users deleted file mode 100755 index bbabf3dbc..000000000 --- a/bin/v-backup-users +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# info: backup all users -# options: NONE -# -# The function backups all system users. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system environment as we run this script -# mostly by cron which not read it by itself -source /etc/profile - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -$BIN/v-check-vesta-license >/dev/null - -if [ -z "$BACKUP_SYSTEM" ]; then - exit -fi -for user in $(grep '@' /etc/passwd |cut -f1 -d:); do - if [ ! -f "$VESTA/data/users/$user/user.conf" ]; then - continue; - fi - check_suspend=$(grep "SUSPENDED='no'" $VESTA/data/users/$user/user.conf) - log=$VESTA/log/backup.log - if [ ! -z "$check_suspend" ]; then - echo -e "================================" >> $log - echo -e "$user" >> $log - echo -e "--------------------------------\n" >> $log - $BIN/v-backup-user $user >> $log 2>&1 - echo -e "\n--------------------------------\n\n" >> $log - fi -done - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging -#log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-cron-job b/bin/v-change-cron-job deleted file mode 100755 index 7a30a2585..000000000 --- a/bin/v-change-cron-job +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# info: change cron job -# options: USER JOB MIN HOUR DAY MONTH WDAY COMMAND -# -# The function is used for changing existing job. It fully replace job -# parameters with new one but with same id. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -job=$2 -min=$3 -hour=$4 -day=$5 -month=$6 -wday=$7 -command=$8 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '7' "$#" 'USER JOB MIN HOUR DAY MONTH WDAY COMMAND' -is_format_valid 'user' 'job' 'min' 'hour' 'day' 'month' 'wday' 'command' -is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'cron' 'JOB' "$job" -is_object_unsuspended 'cron' 'JOB' "$job" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Concatenating cron string -command=$(echo $command | sed -e "s/'/%quote%/g") -str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'" -str="$str CMD='$command' SUSPENDED='no' TIME='$time' DATE='$date'" - -# Deleting old job -sed -i "/JOB='$job' /d" $USER_DATA/cron.conf - -# Adding new -echo "$str" >> $USER_DATA/cron.conf - -# Sorting jobs by id -sort_cron_jobs - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting crond -$BIN/v-restart-cron -check_result $? "Cron restart failed" >/dev/null - -# Logging -log_history "changed cron job $job" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-database-host-password b/bin/v-change-database-host-password deleted file mode 100755 index a55a86bcd..000000000 --- a/bin/v-change-database-host-password +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -# info: change database server password -# options: TYPE HOST USER PASSWORD -# -# The function changes database server password. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -type=$1 -host=$2 -dbuser=$3 -password=$4; HIDE=4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/db.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -args_usage='TYPE HOST DBUSER DBPASS' -check_args '4' "$#" "$args_usage" -is_format_valid 'host' 'dbuser' -is_object_valid "../../conf/$type" 'HOST' "$host" -dbpass="$password" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Define email -email=$(grep CONTACT $VESTA/data/users/admin/user.conf |cut -f2 -d \') -subj="v-change-database-host-password $*" - -case $type in - mysql) mysql_connect $host; - query="USE mysql; UPDATE user SET" - query="$query password=PASSWORD('$dbpass')" - query="$query WHERE User='$dbuser';" - query="$query FLUSH PRIVILEGES;" - mysql_query "$query" ; - if [ "$dbuser" == "root" ]; then - echo -e "[client]\npassword='$dbpass'\n" > /root/.my.cnf - chmod 600 /root/.my.cnf - fi;; - pgsql) echo "TBD" >/dev/null;; -esac - -update_object_value "../../conf/$type" 'HOST' "$host" '$USER' "$dbuser" -update_object_value "../../conf/$type" 'HOST' "$host" '$PASSWORD' "$dbpass" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-database-owner b/bin/v-change-database-owner deleted file mode 100755 index d84d8eb2d..000000000 --- a/bin/v-change-database-owner +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/bash -# info: change database owner -# options: DATABASE USER -# -# The function for changing database owner. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -database=$1 -user=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/db.sh -source $VESTA/func/rebuild.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'DATABASE USER' -is_format_valid 'database' 'user' -is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - -# Check owner existance -owner=$(echo $database | cut -f 1 -d '_') -if [ ! -e "$VESTA/data/users/$owner" ]; then - echo "Error: database owner doesn't exist" - log_event "$E_NOTEXIST" "$ARGUMENTS" - exit $E_NOTEXIST -fi - -# Check if owner is the same as the dst user -if [ "$owner" = "$user" ]; then - exit -fi - -# Check db existance -db_data=$(grep "DB='$database'" $VESTA/data/users/$owner/db.conf) -if [ -z "$db_data" ]; then - echo "Error: database $database doesn't exist" - log_event "$E_NOTEXIST" "$ARGUMENTS" - exit $E_NOTEXIST -fi - -# Check if datbase name is uniq -new_db=$(echo $database | sed "s/^${owner}_/${user}_/") -check_db=$(grep "DB='$new_db'" $VESTA/data/users/$user/db.conf) -if [ ! -z "$check_db" ]; then - echo "Error: $new_db database exists" - log_event "$E_EXISTS" "$ARGUMENTS" - exit $E_EXISTS -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Creating temporary directory -tmpdir=$(mktemp -p $BACKUP -d) -if [ "$?" -ne 0 ]; then - echo "Error: can't create $tmpdir" - log_event "$E_NOTEXIST" "$ARGUMENTS" - exit $E_NOTEXIST -fi - -# Suspend database -$BIN/v-suspend-database $owner $database > /dev/null 2>&1 - -# Dump database -eval $db_data -dump="$tmpdir/$database.$TYPE.sql" -grants="$tmpdir/$database.$TYPE.$DBUSER" -case $TYPE in - mysql) dump_mysql_database ;; - pgsql) dump_pgsql_database ;; -esac - -# Import configuration -db_data=$(echo "$db_data" | sed "s/'${owner}_/'${user}_/g") -echo "$db_data" >> $VESTA/data/users/$user/db.conf -eval $db_data - -# Unsuspend db -$BIN/v-unsuspend-database $user $new_db > /dev/null 2>&1 - -# Rebuild databases -$BIN/v-rebuild-databases $user - -# Import dump -case $TYPE in - mysql) import_mysql_database $dump ;; - pgsql) import_pgsql_database $dump ;; -esac - -# Deleting tmpdir -rm -rf $tmpdir - -# Remove old database -$BIN/v-unsuspend-database $owner $database > /dev/null 2>&1 -$BIN/v-delete-database $owner $database > /dev/null 2>&1 - -# Update counters -$BIN/v-update-user-counters $owner -$BIN/v-update-user-counters $user - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-database-password b/bin/v-change-database-password deleted file mode 100755 index b911747c9..000000000 --- a/bin/v-change-database-password +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash -# info: change database password -# options: USER DATABASE DBPASS -# -# The function for changing database user password to a database. It uses the -# full name of database as argument. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -database=$2 -password=$3; HIDE=3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/db.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DATABASE DBPASS' -is_format_valid 'user' 'database' -is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" -is_object_unsuspended 'db' 'DB' "$database" -is_password_valid -dbpass="$password" - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -# Get database values -get_database_values - -case $TYPE in - mysql) change_mysql_password ;; - pgsql) change_pgsql_password ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config value -update_object_value 'db' 'DB' "$database" '$MD5' "$md5" - -# Logging -log_history "changed $database database password" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-database-user b/bin/v-change-database-user deleted file mode 100755 index 752a79327..000000000 --- a/bin/v-change-database-user +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash -# info: change database username -# options: USER DATABASE DBUSER [DBPASS] -# -# The function for changing database user. It uses the - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -database=$2 -dbuser="$user"_"$3" -password=$4; HIDE=4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/db.sh -source $VESTA/func/rebuild.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DATABASE DBUSER [DBPASS]' -is_format_valid 'user' 'database' 'dbuser' -is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" -is_object_unsuspended 'db' 'DB' "$database" -is_password_valid -dbpass="$password" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Compare old and new user -old_dbuser=$(get_object_value 'db' 'DB' "$database" '$DBUSER') -if [ "$old_dbuser" = "$dbuser" ]; then - exit -fi - -# Set new dbuser -update_object_value 'db' 'DB' "$database" '$DBUSER' "$dbuser" - -# Get database values -get_database_values - -# Rebuild datbase -case $TYPE in - mysql) rebuild_mysql_database ;; - pgsql) rebuild_pgsql_database ;; -esac - -# Change password -if [ ! -z "$dbpass" ]; then - case $TYPE in - mysql) change_mysql_password ;; - pgsql) change_pgsql_password ;; - esac - - # Update config value - update_object_value 'db' 'DB' "$database" '$MD5' "$md5" -fi - -# Remove old user -check_old_dbuser=$(grep "DBUSER='$old_dbuser'" $USER_DATA/db.conf) -if [ -z "$check_old_dbuser" ]; then - case $TYPE in - mysql) delete_mysql_user ;; - pgsql) delete_pgsql_user ;; - esac -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed $database database user to $dbuser" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-dns-domain-exp b/bin/v-change-dns-domain-exp deleted file mode 100755 index 23abb6f4d..000000000 --- a/bin/v-change-dns-domain-exp +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -# info: change dns domain expiration date -# options: USER DOMAIN EXP -# -# The function of changing the term of expiration domain's registration. The -# serial number will be refreshed automatically during update. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -exp=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN EXP' -is_format_valid 'user' 'domain' 'exp' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing exp -update_object_value 'dns' 'DOMAIN' "$domain" '$EXP' "$exp" - -# Updating dns-cluster queue -if [ ! -z "$DNS_CLUSTER" ]; then - # Check for first sync - dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe) - if [ -z "$dlock" ]; then - cmd="$BIN/v-change-remote-dns-domain-exp $user $domain $exp" - echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed whois expiration date for $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-dns-domain-ip b/bin/v-change-dns-domain-ip deleted file mode 100755 index 175268e37..000000000 --- a/bin/v-change-dns-domain-ip +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash -# info: change dns domain ip address -# options: USER DOMAIN IP -# -# The function for changing the main ip of DNS zone. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -ip=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN IP' -is_format_valid 'user' 'domain' 'ip' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get old ip -get_domain_values 'dns' -old=$IP - -# Changing ip -update_object_value 'dns' 'DOMAIN' "$domain" '$IP' "$ip" - -# Changing records -sed -i "s/$old/$ip/g" $USER_DATA/dns/$domain.conf - -# Updating zone -if [[ "$DNS_SYSTEM" =~ named|bind ]]; then - update_domain_serial - update_domain_zone -fi - -# Updating dns-cluster queue -if [ ! -z "$DNS_CLUSTER" ]; then - # Check for first sync - dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe) - if [ -z "$dlock" ]; then - cmd="$BIN/v-add-remote-dns-domain $user $domain domain yes" - echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting named -$BIN/v-restart-dns $restart -check_result $? "DNS restart failed" >/dev/null - -# Logging -log_history "changed dns ip for $domain to $ip" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-dns-domain-soa b/bin/v-change-dns-domain-soa deleted file mode 100755 index 8bb213708..000000000 --- a/bin/v-change-dns-domain-soa +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# info: change dns domain soa record -# options: USER DOMAIN SOA -# -# The function for changing SOA record. This type of records can not be -# modified by v-change-dns-record call. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -soa=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g') -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN SOA' -is_format_valid 'user' 'domain' 'soa' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing soa -update_object_value 'dns' 'DOMAIN' "$domain" '$SOA' "$soa" - -# Updating zone -if [[ "$DNS_SYSTEM" =~ named|bind ]]; then - update_domain_serial - update_domain_zone -fi - -# Updating dns-cluster queue -if [ ! -z "$DNS_CLUSTER" ]; then - # Check for first sync - dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe) - if [ -z "$dlock" ]; then - cmd="$BIN/v-change-remote-dns-domain-soa $user $domain $soa" - echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting named -$BIN/v-restart-dns $restart -check_result $? "DNS restart failed" >/dev/null - -# Logging -log_history "changed soa record for $domain to $soa" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-dns-domain-tpl b/bin/v-change-dns-domain-tpl deleted file mode 100755 index 7f4d17b1f..000000000 --- a/bin/v-change-dns-domain-tpl +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/bash -# info: change dns domain template -# options: USER DOMAIN TEMPLATE [RESTART] -# -# The function for changing the template of records. By updating old records -# will be removed and new records will be generated in accordance with -# parameters of new template. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -template=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN TEMPLATE [RESTART]' -is_format_valid 'user' 'domain' 'template' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_dns_template_valid "$template" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining variables -get_domain_values 'dns' -i=1 -ns=$(get_user_value '$NS') -for nameserver in ${ns//,/ };do - eval ns$i=$nameserver - (( ++i)) -done - -# Reading template -template_data=$(cat $DNSTPL/$template.tpl) - -# Deleting unused nameservers -if [ -z "$ns3" ]; then - template_data=$(echo "$template_data" |grep -v %ns3%) -fi -if [ -z "$ns4" ]; then - template_data=$(echo "$template_data" |grep -v %ns4%) -fi -if [ -z "$ns5" ]; then - template_data=$(echo "$template_data" |grep -v %ns5%) -fi -if [ -z "$ns6" ]; then - template_data=$(echo "$template_data" |grep -v %ns6%) -fi -if [ -z "$ns7" ]; then - template_data=$(echo "$template_data" |grep -v %ns7%) -fi -if [ -z "$ns8" ]; then - template_data=$(echo "$template_data" |grep -v %ns8%) -fi - -# Changing tpl -echo "$template_data" |\ - sed -e "s/%ip%/$IP/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%ns1%/$ns1/g" \ - -e "s/%ns2%/$ns2/g" \ - -e "s/%ns3%/$ns3/g" \ - -e "s/%ns4%/$ns4/g" \ - -e "s/%ns5%/$ns5/g" \ - -e "s/%ns6%/$ns6/g" \ - -e "s/%ns7%/$ns7/g" \ - -e "s/%ns8%/$ns8/g" \ - -e "s/%time%/$TIME/g" \ - -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf -records="$(wc -l $USER_DATA/dns/$domain.conf |cut -f 1 -d ' ')" - -# Updating zone -if [[ "$DNS_SYSTEM" =~ named|bind ]]; then - update_domain_serial - update_domain_zone -fi - -# Updating dns-cluster queue -if [ ! -z "$DNS_CLUSTER" ]; then - # Check for first sync - dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe) - if [ -z "$dlock" ]; then - cmd="$BIN/v-add-remote-dns-domain $user $domain domain" - echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating vesta config -update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template" -update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" - -# Restarting named -$BIN/v-restart-dns $restart -check_result $? "DNS restart failed" >/dev/null - -# Logging -log_history "changed dns template for $domain to $template" '' 'admin' -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-dns-domain-ttl b/bin/v-change-dns-domain-ttl deleted file mode 100755 index c2e29553c..000000000 --- a/bin/v-change-dns-domain-ttl +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -# info: change dns domain ttl -# options: USER DOMAIN TTL -# -# The function for changing the time to live TTL parameter for all records. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -ttl=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN TTL' -is_format_valid 'user' 'domain' 'ttl' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing ttl -update_object_value 'dns' 'DOMAIN' "$domain" '$TTL' "$ttl" - -# Updating zone -if [[ "$DNS_SYSTEM" =~ named|bind ]]; then - update_domain_serial - update_domain_zone -fi - -# Updating dns-cluster queue -if [ ! -z "$DNS_CLUSTER" ]; then - # Check for first sync - dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe) - if [ -z "$dlock" ]; then - cmd="$BIN/v-change-remote-dns-domain-ttl $user $domain $ttl" - echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting named -$BIN/v-restart-dns $restart -check_result $? "DNS restart failed" >/dev/null - -# Logging -log_history "changed TTL for $domain to $ttl" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-dns-record b/bin/v-change-dns-record deleted file mode 100755 index 12f2454bd..000000000 --- a/bin/v-change-dns-record +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash -# info: change dns domain record -# options: USER DOMAIN ID VALUE [PRIORITY] [RESTART] -# -# The function for changing DNS record. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -id=$3 -dvalue=$(idn -t --quiet -u "$4" ) -priority=$5 -restart=$6 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ID VALUE [PRIORITY] [RESTART]' -is_format_valid 'user' 'domain' 'id' 'dvalue' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_object_valid "dns/$domain" 'ID' "$id" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain config -line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) -eval $line - -# Null priority for none MX/SRV records -if [ "$TYPE" != 'MX' ] && [ "$TYPE" != 'SRV' ]; then - priority='' -fi - -# Add trailing dot at the end of NS/CNAME/MX/PTR/SRV record -if [[ $TYPE =~ NS|CNAME|MX|PTR|SRV ]]; then - trailing_dot=$(echo $dvalue | grep "\.$") - if [ -z $trailing_dot ]; then - dvalue="$dvalue." - fi -fi - -# Additional verifications -is_dns_fqnd "$TYPE" "$dvalue" -is_dns_nameserver_valid "$domain" "$TYPE" "$dvalue" - -# Deleting old record -sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Adding record -dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$priority'" -dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$time' DATE='$date'" -echo "$dns_rec" >> $USER_DATA/dns/$domain.conf - -# Sorting records -sort_dns_records - -# Updating zone -if [[ "$DNS_SYSTEM" =~ named|bind ]]; then - update_domain_serial - update_domain_zone -fi - -# Updating dns-cluster queue -if [ ! -z "$DNS_CLUSTER" ]; then - # Check for first sync - dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe) - if [ -z "$dlock" ]; then - cmd="$BIN/v-add-remote-dns-domain $user $domain records" - echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting named -$BIN/v-restart-dns $restart -check_result $? "DNS restart failed" >/dev/null - -# Logging -log_history "changed dns record on $domain to $dvalue" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-dns-record-id b/bin/v-change-dns-record-id deleted file mode 100755 index 90ca28aee..000000000 --- a/bin/v-change-dns-record-id +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# info: change dns domain record id -# options: USER DOMAIN ID NEWID [RESTART] -# -# The function for changing internal record id. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -id=$3 -newid=$4 -restart=$5 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ID NEWID [RESTART]' -is_format_valid 'user' 'domain' 'id' 'newid' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_object_valid "dns/$domain" 'ID' "$id" -is_object_new "dns/$domain" 'ID' "$newid" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Change id -sed -i "s/^ID='$id'/ID='$newid'/" $USER_DATA/dns/$domain.conf - -# Sorting records -sort_dns_records - -# Updating zone -if [[ "$DNS_SYSTEM" =~ named|bind ]]; then - update_domain_serial - update_domain_zone -fi - -# Updating dns-cluster queue -if [ ! -z "$DNS_CLUSTER" ]; then - # Check for first sync - dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe) - if [ -z "$dlock" ]; then - cmd="$BIN/v-add-remote-dns-domain $user $domain records" - echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting named -$BIN/v-restart-dns $restart -check_result $? "DNS restart failed" >/dev/null - -# Logging -log_history "changed dns record id on $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-domain-owner b/bin/v-change-domain-owner deleted file mode 100755 index 8f2673073..000000000 --- a/bin/v-change-domain-owner +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash -# info: change domain owner -# options: DOMAIN USER -# -# The function of changing domain ownership. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -domain=$1 -user=$2 - -# Includes -source $VESTA/func/ip.sh -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'DOMAIN USER' -is_format_valid 'domain' 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -owner=$($BIN/v-search-domain-owner $domain) -if [ -z "$owner" ]; then - check_result $E_NOTEXIST "domain $domain doesn't exist" -fi -if [ "$owner" = "$user" ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# WEB domain -web_data=$(grep "DOMAIN='$domain'" $VESTA/data/users/$owner/web.conf) -if [ ! -z "$web_data" ]; then - $BIN/v-suspend-web-domain $owner $domain >> /dev/null 2>&1 - eval $web_data - - # Change IP - if [ ! -z "$ip" ]; then - web_data=$(echo "$web_data" | sed "s/IP='$IP'/IP='$ip'/") - fi - - # Check SSL - if [ "$SSL" = 'yes' ]; then - ssl_crt=$VESTA/data/users/$owner/ssl/$domain.crt - ssl_key=$VESTA/data/users/$owner/ssl/$domain.key - ssl_ca=$VESTA/data/users/$owner/ssl/$domain.ca - ssl_pem=$VESTA/data/users/$owner/ssl/$domain.pem - mv $ssl_crt $VESTA/data/users/$user/ssl/ - mv $ssl_key $VESTA/data/users/$user/ssl/ - mv $ssl_ca $VESTA/data/users/$user/ssl/ >> /dev/null 2>&1 - mv $ssl_pem $VESTA/data/users/$user/ssl/ >> /dev/null 2>&1 - rm -f $HOMEDIR/$owner/conf/web/ssl.$domain.* - fi - - # Check ftp user account - if [ ! -z "$FTP_USER" ]; then - /usr/sbin/userdel -f $FTP_USER >> /dev/null 2>&1 - old_str="FTP_USER='$FTP_USER'" - new_str=$(echo "$old_str" | sed "s/${owner}_/${user}_/") - web_data=$(echo "$web_data" | sed "s/$old_str/$new_str/") - fi - - # Move config - sed -i "/DOMAIN='$domain'/d" $VESTA/data/users/$owner/web.conf - echo "$web_data" >> $VESTA/data/users/$user/web.conf - - # Move data - mv $HOMEDIR/$owner/web/$domain $HOMEDIR/$user/web/ - - # Change ownership - find $HOMEDIR/$user/web/$domain -user $owner \ - -exec chown -h $user:$user {} \; - - # Rebuild config - $BIN/v-unsuspend-web-domain $user $domain no >> /dev/null 2>&1 - $BIN/v-rebuild-web-domains $owner no - $BIN/v-rebuild-web-domains $user -fi - -# DNS domain -dns_data=$(grep "DOMAIN='$domain'" $VESTA/data/users/$owner/dns.conf) -if [ ! -z "$dns_data" ]; then - eval $dns_data - - # Change IP - if [ ! -z "$ip" ]; then - dns_data=$(echo "$dns_data" | sed "s/IP='$IP'/IP='$ip'/") - sed -i "s/$IP/$ip/g" $VESTA/data/users/$owner/dns/$domain.conf - fi - - # Move config - sed -i "/DOMAIN='$domain'/d" $VESTA/data/users/$owner/dns.conf - echo "$dns_data" >> $VESTA/data/users/$user/dns.conf - - # Move dns records - mv $VESTA/data/users/$owner/dns/$domain.conf \ - $VESTA/data/users/$user/dns/ - - # Rebuild config - $BIN/v-unsuspend-dns-domain $user $domain no >> /dev/null 2>&1 - $BIN/v-rebuild-dns-domains $owner no - $BIN/v-rebuild-dns-domains $user - - # Resync dns cluster - if [ ! -z "$DNS_CLUSTER" ]; then - v-sync-dns-cluster - fi -fi - -# MAIL domain -mail_data=$(grep "DOMAIN='$domain'" $VESTA/data/users/$owner/mail.conf) -if [ ! -z "$mail_data" ]; then - - # Move config - sed -i "/DOMAIN='$domain'/d" $VESTA/data/users/$owner/mail.conf - echo "$mail_data" >> $VESTA/data/users/$user/mail.conf - mv -f $VESTA/data/users/$owner/mail/$domain.conf \ - $VESTA/data/users/$user/mail/ - - # Move DKIM - if [ -e "$VESTA/data/users/$owner/mail/$domain.pem" ]; then - mv -f $VESTA/data/users/$owner/mail/$domain.pem \ - $VESTA/data/users/$user/mail/ - mv -f $VESTA/data/users/$owner/mail/$domain.pub \ - $VESTA/data/users/$user/mail/ - fi - - # Move data - mv $HOMEDIR/$owner/mail/$domain $HOMEDIR/$user/mail/ - - # Change ownership - find $HOMEDIR/$user/mail/$domain -user $owner \ - -exec chown -h $user {} \; - - # Rebuild config - $BIN/v-unsuspend-mail-domain $user $domain no >> /dev/null 2>&1 - $BIN/v-rebuild-mail-domains $owner no - $BIN/v-rebuild-mail-domains $user - - # Checking exim username for later chowning - exim_user="exim"; - check_exim_username=$(grep -c '^Debian-exim:' /etc/passwd) - if [ "$check_exim_username" -eq 1 ]; then - exim_user="Debian-exim" - fi - # Chowning mail conf files to exim user - if [ -d "$HOMEDIR/$user/conf/mail/$domain" ]; then - find $HOMEDIR/$user/conf/mail/$domain -user root \ - -exec chown $exim_user {} \; - fi -fi - -# Update counters -$BIN/v-update-user-counters $owner -$BIN/v-update-user-counters $user - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-firewall-rule b/bin/v-change-firewall-rule deleted file mode 100755 index d2502bce7..000000000 --- a/bin/v-change-firewall-rule +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# info: change firewall rule -# options: RULE ACTION IP PORT [PROTOCOL] [COMMENT] -# -# The function is used for changing existing firewall rule. -# It fully replace rule with new one but keeps same id. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system variables -source /etc/profile - -# Argument definition -rule=$1 -action=$(echo $2|tr '[:lower:]' '[:upper:]') -ip=$3 -port_ext=$4 -protocol=${5-TCP} -protocol=$(echo $protocol|tr '[:lower:]' '[:upper:]') -comment=$6 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Sort function -sort_fw_rules() { - cat $VESTA/data/firewall/rules.conf |\ - sort -n -k 2 -t \' > $VESTA/data/firewall/rules.conf.tmp - mv -f $VESTA/data/firewall/rules.conf.tmp \ - $VESTA/data/firewall/rules.conf -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '5' "$#" 'RULE ACTION IP PORT [PROTOCOL] [COMMENT]' -is_format_valid 'rule' 'action' 'protocol' 'port_ext' 'ip' -if [ ! -z "$comment" ]; then - is_format_valid 'comment' -fi -is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM' -is_object_valid '../../data/firewall/rules' 'RULE' "$rule" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Concatenating firewall rule -str="RULE='$rule' ACTION='$action' PROTOCOL='$protocol' PORT='$port_ext'" -str="$str IP='$ip' COMMENT='$comment' SUSPENDED='no'" -str="$str TIME='$time' DATE='$date'" - -# Deleting old rule -sed -i "/RULE='$rule' /d" $VESTA/data/firewall/rules.conf - -# Adding new -echo "$str" >> $VESTA/data/firewall/rules.conf - -# Sorting firewall rules by id number -sort_fw_rules - -# Updating system firewall -$BIN/v-update-firewall - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-fs-file-permission b/bin/v-change-fs-file-permission deleted file mode 100755 index 3e6ae6b54..000000000 --- a/bin/v-change-fs-file-permission +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# info: change file permission -# options: USER FILE PERMISSIONS -# -# The function changes file access permissions on the file system - -user=$1 -src_file=$2 -permissions=$3 - -# Checking arguments -if [ -z "$permissions" ]; then - echo "Usage: USER FILE PERMISSIONS" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking user homedir -homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) -if [ -z $homedir ]; then - echo "Error: user home directory doesn't exist" - exit 12 -fi - -# Checking source file -if [ ! -fe "$src_file" ]; then - echo "Error: source file doesn't exist $src_file" - exit 3 -fi - -# Checking source path -rpath=$(readlink -f "$src_file") -if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid source path $src_file" - exit 2 -fi - -# Changing file permissions -sudo -u $user chmod -R $permissions "$src_file" >/dev/null 2>&1 -if [ $? -ne 0 ]; then - echo "Error: access permission on $src_file was not changed" - exit 3 -fi - -# Exiting -exit \ No newline at end of file diff --git a/bin/v-change-mail-account-password b/bin/v-change-mail-account-password deleted file mode 100755 index 5c01ffbd8..000000000 --- a/bin/v-change-mail-account-password +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -# info: change mail account password -# options: USER DOMAIN ACCOUNT PASSWORD -# -# The function changes email account password. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -account=$3 -password=$4; HIDE=4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD' -is_format_valid 'user' 'domain' 'account' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -is_password_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Generating hashed password -salt=$(generate_password "$PW_MATRIX" "8") -md5="{MD5}$($BIN/v-generate-password-hash md5 $salt <<<$password)" - -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - quota=$(grep $account $VESTA/data/users/${user}/mail/${domain}.conf) - quota=$(echo $quota | awk '{ print $7 }' | sed -e "s/'//g" ) - quota=$(echo $quota | cut -d "=" -f 2 | sed -e "s/unlimited/0/g") - sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd - str="$account:$md5:$user:mail::$HOMEDIR/$user:${quota}M" - echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update md5 -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5' "$md5" - -# Logging -log_history "changed password for $account@$domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-mail-account-quota b/bin/v-change-mail-account-quota deleted file mode 100755 index 842169494..000000000 --- a/bin/v-change-mail-account-quota +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash -# info: change mail account quota -# options: USER DOMAIN ACCOUNT QUOTA -# -# The function changes email account disk quota. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -account=$3 -quota=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ACCOUNT QUOTA' -is_format_valid 'user' 'domain' 'account' -if [ "$quota" != 'unlimited' ]; then - is_format_valid 'quota' -fi -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5') -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - if [ "$quota" = 'unlimited' ]; then - quota=0 - fi - sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd - str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" - echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [[ "$quota" -eq 0 ]]; then - quota='unlimited' -fi - -# Update quota -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA' "$quota" - -# Logging -log_history "changed mail quota for $account@$domain to $quota" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-mail-domain-catchall b/bin/v-change-mail-domain-catchall deleted file mode 100755 index 080e6a10c..000000000 --- a/bin/v-change-mail-domain-catchall +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# info: change mail domain catchall email -# options: USER DOMAIN EMAIL -# -# The function changes mail domain catchall. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -email=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN EMAIL' -is_format_valid 'user' 'domain' 'email' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Change cathcall alias -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - sed -i "/*@$domain_idn:/d" $HOMEDIR/$user/conf/mail/$domain/aliases - echo "*@$domain_idn:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Change catchall in config -update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' "$email" - -# Logging -log_history "changed catchall email for $domain to $email" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-remote-dns-domain-exp b/bin/v-change-remote-dns-domain-exp deleted file mode 100755 index 0bb4685dd..000000000 --- a/bin/v-change-remote-dns-domain-exp +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# info: change remote dns domain expiration date -# options: USER DOMAIN -# -# The function synchronize dns domain with the remote server. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/remote.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_procces_running -remote_dns_health_check - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -IFS=$'\n' -for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do - - # Parsing remote host parameters - eval $cluster - - # Syncing domain - str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf) - cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'no' - check_result $? "$HOST connection failed (exp insert)" $E_CONNECT - -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating pipe -pipe="$VESTA/data/queue/dns-cluster.pipe" -str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1) -if [ ! -z "$str" ]; then - sed -i "$str d" $pipe -fi - -exit diff --git a/bin/v-change-remote-dns-domain-soa b/bin/v-change-remote-dns-domain-soa deleted file mode 100755 index c522b4312..000000000 --- a/bin/v-change-remote-dns-domain-soa +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -# info: change remote dns domain SOA -# options: USER DOMAIN -# -# The function synchronize dns domain with the remote server. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/remote.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_procces_running -remote_dns_health_check - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -IFS=$'\n' -for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do - - # Parsing remote host parameters - eval $cluster - - # Syncing SOA - str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf) - cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'domain' 'no' - check_result $? "$HOST connection failed (sync)" $E_CONNECT - - # Rebuilding dns zone - cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no' - check_result $? "$HOST connection failed (rebuild)" $E_CONNECT - -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating pipe -pipe="$VESTA/data/queue/dns-cluster.pipe" -str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1) -if [ ! -z "$str" ]; then - sed -i "$str d" $pipe -fi - -exit diff --git a/bin/v-change-remote-dns-domain-ttl b/bin/v-change-remote-dns-domain-ttl deleted file mode 100755 index 77bc235fe..000000000 --- a/bin/v-change-remote-dns-domain-ttl +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -# info: change remote dns domain TTL -# options: USER DOMAIN -# -# The function synchronize dns domain with the remote server. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/remote.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_procces_running -remote_dns_health_check - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -IFS=$'\n' -for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do - - # Parsing remote host parameters - eval $cluster - - # Syncing TTL - str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf) - cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'domain' 'no' - check_result $? "$HOST connection failed (sync)" $E_CONNECT - - # Rebuilding dns zone - cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no' - check_result $? "$HOST connection failed (rebuild)" $E_CONNECT - -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating pipe -pipe="$VESTA/data/queue/dns-cluster.pipe" -str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1) -if [ ! -z "$str" ]; then - sed -i "$str d" $pipe -fi - -exit diff --git a/bin/v-change-sys-config-value b/bin/v-change-sys-config-value deleted file mode 100755 index 3681075c3..000000000 --- a/bin/v-change-sys-config-value +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -# info: change sysconfig value -# options: KEY VALUE -# -# The function is for changing main config settings such as COMPANY_NAME or -# COMPANY_EMAIL and so on. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -key=$(echo "$1" | tr '[:lower:]' '[:upper:]' ) -value=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'KEY VALUE' -is_format_valid 'key' - -format_no_quotes "$value" 'value' - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Updating conf -check_ckey=$(grep "^$key='" $VESTA/conf/vesta.conf) -if [ -z "$check_ckey" ]; then - echo "$key='$value'" >> $VESTA/conf/vesta.conf -else - sed -i "s|$key=.*|$key='$value'|g" $VESTA/conf/vesta.conf -fi - -if [ "$key" = "BACKUP" ] && [ "$value" != '/backup' ]; then - rm /backup - ln -s $value /backup -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-sys-hostname b/bin/v-change-sys-hostname deleted file mode 100755 index c5a6adb17..000000000 --- a/bin/v-change-sys-hostname +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# info: change hostname -# options: HOSTNAME -# -# The function for changing system hostname. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -domain=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'HOSTNAME' -is_format_valid 'domain' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -hostname $domain - -if [ -d "/etc/sysconfig" ]; then - # RHEL/CentOS/Amazon - touch /etc/sysconfig/network - if [ -z "$(grep HOSTNAME /etc/sysconfig/network)" ]; then - echo "HOSTNAME='$domain'" >> /etc/sysconfig/network - else - sed -i "s/HOSTNAME=.*/HOSTNAME='$domain'/" /etc/sysconfig/network - fi -else - # Debian/Ubuntu - echo "$domain" > /etc/hostname -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-sys-ip-name b/bin/v-change-sys-ip-name deleted file mode 100755 index 78da096a4..000000000 --- a/bin/v-change-sys-ip-name +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# info: change ip name -# options: IP NAME -# -# The function for changing dns domain associated with ip. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -ip=$1 -ip_name=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'IP IP_NAME' -is_format_valid 'ip' -is_format_valid 'ip_name' -is_ip_valid "$ip" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing ip name -update_ip_value '$NAME' "$ip_name" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed associated dns on $ip to $ip_name" '' 'admin' -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-sys-ip-nat b/bin/v-change-sys-ip-nat deleted file mode 100755 index a3b248301..000000000 --- a/bin/v-change-sys-ip-nat +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash -# info: change ip nat address -# options: IP NAT_IP [RESTART] -# -# The function for changing nat ip associated with ip. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -ip=$1 -nat_ip=$2 -restart=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'IP NAT_IP [RESTART]' -is_format_valid 'ip' -is_format_valid 'nat_ip' -is_ip_valid "$ip" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Updating IP -if [ -z "$(grep NAT= $VESTA/data/ips/$ip)" ]; then - sed -i "s/^TIME/NAT='$nat_ip'\nTIME/g" $VESTA/data/ips/$ip - old='' - new=$nat_ip -else - old=$(get_ip_value '$NAT') - new=$nat_ip - sed -i "s/NAT=.*/NAT='$new'/" $VESTA/data/ips/$ip - if [ -z "$nat_ip" ]; then - new=$ip - fi -fi - -# Updating WEB configs -if [ ! -z "$old" ] && [ ! -z "$WEB_SYSTEM" ]; then - sed -i "s/$old/$new/" $VESTA/data/users/*/web.conf - for user in $(ls $VESTA/data/users/); do - $BIN/v-rebuild-web-domains $user no - done - $BIN/v-restart-dns $restart -fi - -# Updating DNS configs -if [ ! -z "$old" ] && [ ! -z "$DNS_SYSTEM" ]; then - sed -i "s/$old/$new/" $VESTA/data/users/*/dns.conf - sed -i "s/$old/$new/" $VESTA/data/users/*/dns/*.conf - for user in $(ls $VESTA/data/users/); do - $BIN/v-rebuild-dns-domains $user no - done - $BIN/v-restart-dns $restart -fi - -# Updating FTP -if [ ! -z "$old" ] && [ ! -z "$FTP_SYSTEM" ]; then - conf=$(find /etc -name $FTP_SYSTEM.conf) - if [ -e "$conf" ]; then - sed -i "s/$old/$new/g" $conf - if [ "$FTP_SYSTEM" = 'vsftpd' ]; then - check_pasv=$(grep pasv_address $conf) - if [ -z "$check_pasv" ] && [ ! -z "$nat_ip" ]; then - echo "pasv_address=$nat_ip" >> $conf - fi - if [ ! -z "$check_pasv" ] && [ -z "$nat_ip" ]; then - sed -i "/pasv_address/d" $conf - fi - if [ ! -z "$check_pasv" ] && [ ! -z "$nat_ip" ]; then - sed -i "s/pasv_address=.*/pasv_address='$nat_ip'/g" $conf - fi - fi - fi - $BIN/v-restart-ftp $restart -fi - -# Updating firewall -if [ ! -z "$old" ] && [ ! -z "$FIREWALL_SYSTEM" ]; then - sed -i "s/$old/$new/g" $VESTA/data/firewall/*.conf - $BIN/v-update-firewall -fi - - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed associated nat address on $ip to $nat_ip" '' 'admin' -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-sys-ip-owner b/bin/v-change-sys-ip-owner deleted file mode 100755 index 5ea71c348..000000000 --- a/bin/v-change-sys-ip-owner +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -# info: change ip owner -# options: IP USER -# -# The function of changing ip address ownership. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -ip=$1 -user=$2 - -# Includes -source $VESTA/func/ip.sh -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'IP USER' -is_format_valid 'ip' 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_ip_valid "$ip" -is_ip_key_empty '$U_WEB_DOMAINS' -is_ip_key_empty '$U_SYS_USERS' - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing ip owner -ip_owner=$(get_ip_value '$OWNER') -if [ "$ip_owner" != "$user" ]; then - ip_status="$(get_ip_value '$STATUS')" - update_ip_value '$OWNER' "$user" - decrease_user_value "$ip_owner" '$IP_OWNED' - if [ "$ip_owner" = 'admin' ]; then - if [ "$ip_status" = 'shared' ]; then - for vesta_user in $(ls $VESTA/data/users); do - decrease_user_value "$vesta_user" '$IP_AVAIL' - done - else - decrease_user_value 'admin' '$IP_AVAIL' - fi - else - decrease_user_value "$ip_owner" '$IP_AVAIL' - decrease_user_value 'admin' '$IP_AVAIL' - fi - - increase_user_value "$user" '$IP_OWNED' - if [ "$user" = 'admin' ]; then - if [ "$ip_status" = 'shared' ]; then - for user in $(ls $VESTA/data/users); do - increase_user_value "$user" '$IP_AVAIL' - done - else - increase_user_value 'admin' '$IP_AVAIL' - fi - else - increase_user_value "$user" '$IP_AVAIL' - increase_user_value 'admin' '$IP_AVAIL' - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed owner of $ip to $user" '' 'admin' -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-sys-ip-status b/bin/v-change-sys-ip-status deleted file mode 100755 index 7f834065f..000000000 --- a/bin/v-change-sys-ip-status +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# info: change ip status -# options: IP IP_STATUS -# -# The function of changing an ip address's status. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -ip=$1 -ip_status=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'IP IP_STATUS' -is_format_valid 'ip' 'ip_status' -is_ip_valid "$ip" -if [ "$ip_status" = "$(get_ip_value '$STATUS')" ]; then - check_result "$E_EXISTS" "status $ip_status is already set" -fi -web_domains=$(get_ip_value '$U_WEB_DOMAINS') -sys_user=$(get_ip_value '$U_SYS_USERS') -ip_owner=$(get_ip_value '$OWNER') -if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then - check_result "$E_INUSE" "ip $ip is used" -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing ip name -update_ip_value '$STATUS' "$ip_status" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed $ip status to $ip_status" '' 'admin' -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-sys-language b/bin/v-change-sys-language deleted file mode 100755 index 6f27a9020..000000000 --- a/bin/v-change-sys-language +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# info: change sys language -# options: LANGUAGE -# -# The function for changing system language. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -language=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -is_language_valid() { - if [ ! -e "$VESTA/web/inc/i18n/$language.php" ]; then - echo "Error: language file $language doesn't exist" - log_event "$E_NOTEXIST $ARGUMENTS" - exit $E_NOTEXIST - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'LANGUAGE' -is_format_valid 'language' -is_language_valid $language - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Change language -if [ -z "$(grep LANGUAGE $VESTA/conf/vesta.conf)" ]; then - echo "LANGUAGE='$language'" >> $VESTA/conf/vesta.conf -else - sed -i "s/LANGUAGE=.*/LANGUAGE='$language'/g" $VESTA/conf/vesta.conf -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-sys-service-config b/bin/v-change-sys-service-config deleted file mode 100755 index f90326b72..000000000 --- a/bin/v-change-sys-service-config +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/bash -# info: change service config -# options: CONFIG SERVICE [RESTART] -# -# The function for changing service confguration. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -src=$1 -service=$2 -restart=$3 -echo "$0 $*" >/tmp/t.log - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'CONFIG SERVICE [RESTART]' -if [ ! -e "$src" ]; then - check_result "$E_NOTEXIST" "$src config doesn't exist" -fi - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining dst config path -case $service in - nginx) dst='/etc/nginx/nginx.conf';; - httpd) dst='/etc/httpd/conf/httpd.conf';; - apache2) dst='/etc/apache2/apache2.conf';; - exim) dst='/etc/exim/exim.conf';; - exim4) dst='/etc/exim4/exim4.conf.template';; - vsftpd) dst=$(find /etc/vsftpd* -name 'vsftpd.conf');; - proftpd) dst=$(find /etc/proftpd* -name 'proftpd.conf');; - php) dst=$(find /etc/php* -name php.ini);; - mysql) dst=$(find /etc/my* -name my.cnf);; - mysqld) dst=$(find /etc/my* -name my.cnf);; - mariadb) dst=$(find /etc/my* -name my.cnf);; - postgresql) dst=$($BIN/v-list-sys-pgsql-config plain |cut -f 1);; - postgresql-hba) dst=$($BIN/v-list-sys-pgsql-config plain |cut -f 2);; - dovecot) dst=$(find /etc/dovecot* -name dovecot.conf);; - dovecot-1) dst='/etc/dovecot/conf.d/10-auth.conf';; - dovecot-2) dst='/etc/dovecot/conf.d/10-logging.conf';; - dovecot-3) dst='/etc/dovecot/conf.d/10-mail.conf';; - dovecot-4) dst='/etc/dovecot/conf.d/10-master.conf';; - dovecot-5) dst='/etc/dovecot/conf.d/10-ssl.conf';; - dovecot-6) dst='/etc/dovecot/conf.d/20-imap.conf';; - dovecot-7) dst='/etc/dovecot/conf.d/20-pop3.conf';; - dovecot-8) dst='/etc/dovecot/conf.d/auth-passwdfile.conf.ext';; - named) dst='/etc/named.conf';; - bind9) dst='/etc/bind/named.conf';; - bind9-opt) dst='/etc/bind/named.conf.options';; - spamd) dst=$($BIN/v-list-sys-spamd-config plain);; - spamassassin) dst=$($BIN/v-list-sys-spamd-config plain);; - clamd) dst=$($BIN/v-list-sys-clamd-config plain);; - clamd.scan) dst=$($BIN/v-list-sys-clamd-config plain);; - cron) dst='/etc/crontab';; - crond) dst='/etc/crontab';; - fail2ban) dst='/etc/fail2ban/jail.local';; - *) check_result $E_NOTEXIST "service $service doesn't exist" -esac - -# Checking config path -for config in $dst; do - if [ ! -e "$config" ]; then - check_result $E_NOTEXIST "$service config doesn't exist" - fi -done - -# Checking diff between src and dst configs -for config in $dst; do - diff -q $src $config >/dev/null - - if [ $? -ne 0 ]; then - cp $config $config.vst.back - cp $src $config - update="yes" - fi -done - -# Restarting service -if [ "$update" = 'yes' ] && [ "$restart" != 'no' ]; then - if [[ "$service" =~ - ]]; then - service=$(echo ${service%-*}) - fi - - if [ "$service" = 'php' ]; then - if [ "$WEB_SYSTEM" = "nginx" ]; then - if [ $(ps --no-headers -o comm 1) == systemd ]; then - service=$(systemctl | grep -o -E "php.*fpm.*\.service") - service=${service//.service/} - else - service=$(ls /etc/init.d/php*fpm* |cut -f 4 -d /) - fi - else - service=$WEB_SYSTEM - fi - fi - - for single_service in $service; do - service $single_service restart >/dev/null 2>&1 - done <<< "$service" - - if [ $? -ne 0 ]; then - for config in $dst; do - cat $config.vst.back > $config - rm -f $config.vst.back - done - check_result $E_RESTART "$service failed to start with new config" - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-sys-timezone b/bin/v-change-sys-timezone deleted file mode 100755 index bfd4e5bc8..000000000 --- a/bin/v-change-sys-timezone +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# info: change system timezone -# options: TIMEZONE -# -# The function for changing system timezone. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -timezone=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -is_timezone_valid() { - if [ ! -e "/usr/share/zoneinfo/$timezone" ]; then - echo "Error: tz file $timezone doesn't exist" - log_event $E_NOTEXIST "$ARGUMENTS" - exit $E_NOTEXIST - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'TIMEZONE' -is_timezone_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing system timezone -which timedatectls >/dev/null 2>&1 -if [ "$?" -eq 0 ]; then - timedatectl set-timezone $timezone -else - if [ -e "/etc/sysconfig/clock" ]; then - sed -i "s/ZONE.*//" /etc/sysconfig/clock - echo "ZONE=\"$timezone\"" >> /etc/sysconfig/clock - fi - if [ -e "/etc/timezone" ]; then - echo "$timezone" > /etc/timezone - fi - rm -f /etc/localtime - ln -sf /usr/share/zoneinfo/$timezone /etc/localtime -fi - -# Chaning php timezone -if [ ! -z "$WEB_SYSTEM" ]; then - for conf in $(find /etc/php* -name php.ini); do - sed -i "s|;date.timezone =|date.timezone =|" $conf - sed -i "s|date.timezone =.*|date.timezone = $timezone|" $conf - done -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-sys-vesta-ssl b/bin/v-change-sys-vesta-ssl deleted file mode 100755 index 2531714e0..000000000 --- a/bin/v-change-sys-vesta-ssl +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -# info: change vesta ssl certificate -# options: SSL_DIR [RESTART] -# -# The function changes vesta SSL certificate and the key. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -domain='certificate' -ssl_dir=$1 -restart=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'SSL_DIR [RESTART]' -is_format_valid 'ssl_dir' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking new certificate -certificate=$(cat $ssl_dir/$domain.crt |grep -n END) -certificate_count=$(echo "$certificate" |wc -l) -if [ "$certificate_count" -gt 1 ]; then - crt_end=$(echo "$certificate" |head -n1 |cut -f 1 -d :) - crt_lines=$(wc -l $ssl_dir/$domain.crt |cut -f1 -d ' ') - pem_begin=$((crt_lines - crt_end)) - mv $ssl_dir/$domain.crt $ssl_dir/$domain.crt_full - head -n $crt_end $ssl_dir/$domain.crt_full > $ssl_dir/$domain.crt - tail -n $pem_begin $ssl_dir/$domain.crt_full > $ssl_dir/$domain.ca - is_web_domain_cert_valid - mv -f $ssl_dir/$domain.crt_full $ssl_dir/$domain.crt - rm -f $ssl_dir/$domain.ca -else - is_web_domain_cert_valid -fi - -# Moving old certificate -mv $VESTA/ssl/certificate.crt $VESTA/ssl/certificate.crt.back -mv $VESTA/ssl/certificate.key $VESTA/ssl/certificate.key.back - -# Adding new certificate -cp -f $ssl_dir/certificate.crt $VESTA/ssl/certificate.crt -cp -f $ssl_dir/certificate.key $VESTA/ssl/certificate.key - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting web server -if [ "$restart" != 'no' ]; then - kill -HUP $(cat /var/run/vesta-nginx.pid) - $BIN/v-restart-mail - if [ ! -z "$IMAP_SYSTEM" ]; then - v-restart-service "$IMAP_SYSTEM" - fi -fi - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-user-contact b/bin/v-change-user-contact deleted file mode 100755 index bbbb2d168..000000000 --- a/bin/v-change-user-contact +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# info: change user contact email -# options: USER EMAIL -# -# The function for changing of e-mail associated with a certain user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -email=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER EMAIL' -is_format_valid 'user' 'email' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing user contact email -old_email=$(get_user_value '$CONTACT') -update_user_value "$user" '$CONTACT' "$email" -pw_str=$(grep -n "^$user:" /etc/passwd) -str=$(echo "$pw_str" | cut -f 1 -d :) -sed -i "$str s/$old_email/$email/g" /etc/passwd - -# Update crontab email -$BIN/v-rebuild-cron-jobs $user > /dev/null 2>&1 - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed contact email to $email" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-user-language b/bin/v-change-user-language deleted file mode 100755 index 38084ccc3..000000000 --- a/bin/v-change-user-language +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -# info: change user language -# options: USER LANGUAGE -# -# The function for changing language. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -language=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -is_language_valid() { - if ! [[ "$1" =~ ^[[:alnum:]_-]+$ ]]; then - echo "Error: language $1 is not valid" - log_event "$E_INVALID" "$ARGUMENTS" - exit $E_INVALID - fi - if [ ! -e "$VESTA/web/inc/i18n/$1.php" ]; then - echo "Error: language $1 doesn't exist" - log_event "$E_NOTEXIST" "$ARGUMENTS" - exit $E_NOTEXIST - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER LANGUAGE' -is_format_valid 'user' 'language' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_language_valid $language - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Change language -if [ -z "$(grep LANGUAGE $USER_DATA/user.conf)" ]; then - sed -i "s/^TIME/LANGUAGE='$language'\nTIME/g" $USER_DATA/user.conf -else - update_user_value "$user" '$LANGUAGE' "$language" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed language to $language" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-user-name b/bin/v-change-user-name deleted file mode 100755 index 2776b4cb5..000000000 --- a/bin/v-change-user-name +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# info: change user full name -# options: USER FNAME LNAME -# -# The function allow to change user's full name. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -fname=$2 -lname=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER FNAME LNAME' -is_format_valid 'user' 'fname' 'lname' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get old values -old_fname=$(get_user_value '$FNAME') -old_lname=$(get_user_value '$LNAME') - -# Changing ns values -update_user_value "$user" '$FNAME' "$fname" -update_user_value "$user" '$LNAME' "$lname" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed user name to $fname $lname" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-user-ns b/bin/v-change-user-ns deleted file mode 100755 index 0e28766cf..000000000 --- a/bin/v-change-user-ns +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# info: change user nameservers -# options: USER NS1 NS2 [NS3] [NS4] [NS5] [NS6] [NS7] [NS8] -# -# The function for changing default nameservers for specific user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -ns1=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') -ns2=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g') -ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g') -ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g') -ns5=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g') -ns6=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g') -ns7=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g') -ns8=$(echo $9 | sed -e 's/\.*$//g' -e 's/^\.*//g') - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking args -check_args '3' "$#" 'USER NS1 NS2 [NS3] [NS4] [NS5] [NS6] [NS7] [NS8]' - -# Checking argument format -is_format_valid 'user' 'ns1' 'ns2' -if [ ! -z "$ns3" ]; then - ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g') - is_format_valid 'ns3' -fi -if [ ! -z "$ns4" ]; then - ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g') - is_format_valid 'ns4' -fi -if [ ! -z "$ns5" ]; then - ns5=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g') - is_format_valid 'ns5' -fi -if [ ! -z "$ns6" ]; then - ns6=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g') - is_format_valid 'ns6' -fi -if [ ! -z "$ns7" ]; then - ns7=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g') - is_format_valid 'ns7' -fi -if [ ! -z "$ns8" ]; then - ns8=$(echo $9 | sed -e 's/\.*$//g' -e 's/^\.*//g') - is_format_valid 'ns8' -fi -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Merging values -ns="$ns1,$ns2,$ns3,$ns4,$ns5,$ns6,$ns7,$ns8" -ns=$(echo "$ns" | sed -e "s/,,//g" -e "s/,$//") - -# Changing ns values -update_user_value "$user" '$NS' "$ns" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "updated nameservers $ns1 $ns2 $ns3 $ns4 $ns5 $ns6 $ns7 $ns8" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-user-package b/bin/v-change-user-package deleted file mode 100755 index b358fb13c..000000000 --- a/bin/v-change-user-package +++ /dev/null @@ -1,194 +0,0 @@ -#!/bin/bash -# info: change user package -# options: USER PACKAGE [FORCE] -# -# The function changes user's hosting package. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -package=$2 -force=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -is_package_avalable() { - - source $USER_DATA/user.conf - WEB_DOMAINS='0' - DATABASES='0' - MAIL_DOMAINS='0' - DNS_DOMAINS='0' - DISK_QUOTA='0' - BANDWIDTH='0' - - pkg_data=$(cat $VESTA/data/packages/$package.pkg| egrep -v "TIME|DATE") - IFS=$'\n' - for str in $pkg_data; do - key=$(echo $str |cut -f 1 -d =) - value=$(echo $str |cut -f 2 -d \') - eval $key="$value" - done - - # Checking usage agains package limits - if [ "$WEB_DOMAINS" != 'unlimited' ]; then - if [ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ]; then - check_result $E_LIMIT "Package doesn't cover WEB_DOMAIN usage" - fi - fi - if [ "$DNS_DOMAINS" != 'unlimited' ]; then - if [ "$DNS_DOMAINS" -lt "$U_DNS_DOMAINS" ]; then - check_result $E_LIMIT "Package doesn't cover DNS_DOMAIN usage" - fi - fi - if [ "$MAIL_DOMAINS" != 'unlimited' ]; then - if [ "$MAIL_DOMAINS" -lt "$U_MAIL_DOMAINS" ]; then - check_result $E_LIMIT "Package doesn't cover MAIL_DOMAIN usage" - fi - fi - if [ "$DATABASES" != 'unlimited' ]; then - if [ "$DATABASES" -lt "$U_DATABASES" ]; then - check_result $E_LIMIT "Package doesn't cover DATABASE usage" - fi - fi - if [ "$CRON_JOBS" != 'unlimited' ]; then - if [ "$CRON_JOBS" -lt "$U_CRON_JOBS" ]; then - check_result $E_LIMIT "Package doesn't cover CRON usage" - fi - fi - if [ "$DISK_QUOTA" != 'unlimited' ]; then - if [ "$DISK_QUOTA" -lt "$U_DISK" ]; then - check_result $E_LIMIT "Package doesn't cover DISK usage" - fi - fi - if [ "$BANDWIDTH" != 'unlimited' ]; then - if [ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]; then - check_result $E_LIMIT "Package doesn't cover BANDWIDTH usage" - fi - fi - - # Checking templates - is_web_template_valid $WEB_TEMPLATE - is_dns_template_valid $DNS_TEMPLATE - is_proxy_template_valid $PROXY_TEMPLATE -} - -change_user_package() { - source $USER_DATA/user.conf - pkg_data=$(cat $VESTA/data/packages/$package.pkg| egrep -v "TIME|DATE") - IFS=$'\n' - for str in $pkg_data; do - key=$(echo $str |cut -f 1 -d =) - value=$(echo $str |cut -f 2 -d \') - eval $key="$value" - done - echo "FNAME='$FNAME' -LNAME='$LNAME' -PACKAGE='$package' -WEB_TEMPLATE='$WEB_TEMPLATE' -PROXY_TEMPLATE='$PROXY_TEMPLATE' -DNS_TEMPLATE='$DNS_TEMPLATE' -WEB_DOMAINS='$WEB_DOMAINS' -WEB_ALIASES='$WEB_ALIASES' -DNS_DOMAINS='$DNS_DOMAINS' -DNS_RECORDS='$DNS_RECORDS' -MAIL_DOMAINS='$MAIL_DOMAINS' -MAIL_ACCOUNTS='$MAIL_ACCOUNTS' -DATABASES='$DATABASES' -CRON_JOBS='$CRON_JOBS' -DISK_QUOTA='$DISK_QUOTA' -BANDWIDTH='$BANDWIDTH' -NS='$NS' -SHELL='$SHELL' -BACKUPS='$BACKUPS' -CONTACT='$CONTACT' -CRON_REPORTS='$CRON_REPORTS' -MD5='$MD5' -RKEY='$RKEY' -SUSPENDED='$SUSPENDED' -SUSPENDED_USERS='$SUSPENDED_USERS' -SUSPENDED_WEB='$SUSPENDED_WEB' -SUSPENDED_DNS='$SUSPENDED_DNS' -SUSPENDED_MAIL='$SUSPENDED_MAIL' -SUSPENDED_DB='$SUSPENDED_DB' -SUSPENDED_CRON='$SUSPENDED_CRON' -IP_AVAIL='$IP_AVAIL' -IP_OWNED='$IP_OWNED' -U_USERS='$U_USERS' -U_DISK='$U_DISK' -U_DISK_DIRS='$U_DISK_DIRS' -U_DISK_WEB='$U_DISK_WEB' -U_DISK_MAIL='$U_DISK_MAIL' -U_DISK_DB='$U_DISK_DB' -U_BANDWIDTH='$U_BANDWIDTH' -U_WEB_DOMAINS='$U_WEB_DOMAINS' -U_WEB_SSL='$U_WEB_SSL' -U_WEB_ALIASES='$U_WEB_ALIASES' -U_DNS_DOMAINS='$U_DNS_DOMAINS' -U_DNS_RECORDS='$U_DNS_RECORDS' -U_MAIL_DOMAINS='$U_MAIL_DOMAINS' -U_MAIL_DKIM='$U_MAIL_DKIM' -U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS' -U_DATABASES='$U_DATABASES' -U_CRON_JOBS='$U_CRON_JOBS' -U_BACKUPS='$U_BACKUPS' -LANGUAGE='$LANGUAGE' -NOTIFICATIONS='$NOTIFICATIONS' -TIME='$TIME' -DATE='$DATE'" > $USER_DATA/user.conf -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER PACKAGE [FORCE]' -is_format_valid 'user' 'package' -is_object_valid 'user' 'USER' "$user" -is_package_valid -if [ "$force" != 'yes' ];then - is_package_avalable -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing user package -change_user_package - -# Update user shell -shell_conf=$(echo "$pkg_data" |grep 'SHELL' |cut -f 2 -d \') -shell=$(grep -w "$shell_conf" /etc/shells |head -n1) -/usr/bin/chsh -s "$shell" "$user" &>/dev/null - -# Run template trigger -if [ -x "$VESTA/data/packages/$package.sh" ]; then - $VESTA/data/packages/$package.sh "$user" "$CONTACT" "$FNAME" "$LNAME" -fi - -# Update disk quota -source $VESTA/conf/vesta.conf -if [ "$DISK_QUOTA" = 'yes' ]; then - $BIN/v-update-user-quota $user -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed $user package to $package" '' 'admin' -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-user-password b/bin/v-change-user-password deleted file mode 100755 index 30328641f..000000000 --- a/bin/v-change-user-password +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# info: change user password -# options: USER PASSWORD -# -# The function changes user's password and updates RKEY value. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -password=$2; HIDE=2 - -# Importing system enviroment as we run this script -# mostly by cron wich not read it by itself -source /etc/profile - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -if [ "$user" = "root" ]; then - check_result $E_FORBIDEN "Changing root password is forbiden" -fi -check_args '2' "$#" 'USER PASSWORD' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_password_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing user password -echo "$user:$password" | /usr/sbin/chpasswd -md5=$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow) - -if [ "$user" = 'admin' ] && [ -e "$VESTA/web/reset.admin" ]; then - rm -f $VESTA/web/reset.admin -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Changing RKEY value -update_user_value "$user" '$RKEY' "$(generate_password)" -update_user_value "$user" '$MD5' "$md5" - -# Logging -log_history "changed password" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-user-shell b/bin/v-change-user-shell deleted file mode 100755 index 6a079c0ad..000000000 --- a/bin/v-change-user-shell +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# info: change user shell -# options: USER SHELL -# -# The function changes system shell of a user. Shell gives ability to use ssh. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -shell=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER SHELL' -is_format_valid 'user' 'shell' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get shell full path -shell_path=$(grep -w "$shell" /etc/shells | head -n1) - -# Changing passwd file -/usr/bin/chsh -s "$shell_path" "$user" >/dev/null 2>&1 -shell=$(basename $shell_path) - -# Adding jailed sftp env -if [ ! -z "$SFTPJAIL_KEY" ]; then - if [[ "$shell" =~ nologin ]] || [[ "$shell" =~ rssh ]]; then - $BIN/v-add-user-sftp-jail $user >/dev/null 2>&1 - else - $BIN/v-delete-user-sftp-jail $user >/dev/null 2>&1 - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Changing user shell -update_user_value "$user" '$SHELL' "$shell" - -# Logging -log_history "changed $user shell to $shell" '' 'admin' -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-user-template b/bin/v-change-user-template deleted file mode 100755 index 5a3295352..000000000 --- a/bin/v-change-user-template +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# info: change user default template -# options: USER TYPE TEMPLATE -# -# The function changes default user web template. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -type=$(echo "$2" | tr '[:lower:]' '[:upper:]') -template=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER TYPE TEMPLATE' -is_format_valid 'user' 'template' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -case $type in - WEB) is_web_template_valid $template; - update_user_value "$user" '$WEB_TEMPLATE' "$template";; - PROXY) is_proxy_template_valid $template; - update_user_value "$user" '$PROXY_TEMPLATE' "$template";; - DNS) is_dns_template_valid $template; - update_user_value "$user" '$DNS_TEMPLATE' "$template";; - *) check_args '1' '0' 'USER TYPE TEMPLATE' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed $type template to $template" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-vesta-port b/bin/v-change-vesta-port deleted file mode 100644 index 3f3866549..000000000 --- a/bin/v-change-vesta-port +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# info: change vesta port -# options: port -# -# Function will change vesta port - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -port=$1 - -if [ -z "$VESTA" ]; then - VESTA="/usr/local/vesta" -fi - -# Get current vesta port by reading nginx.conf -oldport=$(grep 'listen' $VESTA/nginx/conf/nginx.conf | awk '{print $2}' | sed "s|;||") -if [ -z "$oldport" ]; then - oldport=8083 -fi - -# Includes -source $VESTA/func/main.sh - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking permissions -if [ "$(id -u)" != '0' ]; then - check_result $E_FORBIDEN "You must be root to execute this script" -fi - -check_args '1' "$#" 'PORT' -is_int_format_valid "$port" 'port number' - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -sed -i "s|$oldport;|$port;|g" $VESTA/nginx/conf/nginx.conf -if [ -f "/etc/roundcube/plugins/password/config.inc.php" ]; then - sed -i "s|'$oldport'|'$port'|g" /etc/roundcube/plugins/password/config.inc.php -fi -sed -i "s|'$oldport'|'$port'|g" $VESTA/data/firewall/rules.conf -$VESTA/bin/v-update-firewall -systemctl restart fail2ban.service -sed -i "s| $oldport | $port |g" /etc/iptables.rules -systemctl restart vesta - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit 0; diff --git a/bin/v-change-web-domain-backend-tpl b/bin/v-change-web-domain-backend-tpl deleted file mode 100755 index 71dc9fd63..000000000 --- a/bin/v-change-web-domain-backend-tpl +++ /dev/null @@ -1,159 +0,0 @@ -#!/bin/bash -# info: change web domain backend template -# options: USER DOMAIN TEMPLATE [RESTART] -# -# The function changes backend template - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -template=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN TEMPLATE [RESTART]' -is_format_valid 'user' 'domain' 'template' -is_system_enabled "$WEB_BACKEND" 'WEB_BACKEND' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_backend_template_valid $template - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -prepare_web_backend - -# Deleting backend -rm -f $pool/$backend_type.conf - -# Allocating backend port -backend_port=9000 -ports=$(grep listen $pool/* 2>/dev/null |grep -o :[0-9].*) -ports=$(echo "$ports" |sed "s/://" |sort -n) -for port in $ports; do - if [ "$backend_port" -eq "$port" ]; then - backend_port=$((backend_port + 1)) - fi -done - -# Changing backend config -cat $WEBTPL/$WEB_BACKEND/$template.tpl |\ - sed -e "s|%backend_port%|$backend_port|" \ - -e "s|%user%|$user|g"\ - -e "s|%domain%|$domain|g"\ - -e "s|%domain_idn%|$domain_idn|"\ - -e "s|%backend%|$backend_type|g" > $pool/$backend_type.conf - -# Checking backend pool configuration -if [ "$backend_type" = "$user" ]; then - conf=$USER_DATA/web.conf - fields='$DOMAIN' - nohead=1 - - for domain in $(shell_list); do - get_domain_values 'web' - local_ip=$(get_real_ip $IP) - prepare_web_domain_values - - # Rebuilding vhost - del_web_config "$WEB_SYSTEM" "$TPL.tpl" - add_web_config "$WEB_SYSTEM" "$TPL.tpl" - if [ "$SSL" = 'yes' ]; then - del_web_config "$WEB_SYSTEM" "$TPL.stpl" - add_web_config "$WEB_SYSTEM" "$TPL.stpl" - fi - - # Rebuilding proxy configuration - if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.tpl" - add_web_config "$PROXY_SYSTEM" "$PROXY.tpl" - if [ "$SSL" = 'yes' ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.stpl" - add_web_config "$PROXY_SYSTEM" "$PROXY.stpl" - fi - fi - - # Update config - add_object_key "web" 'DOMAIN' "$domain" 'BACKEND' 'PROXY' - update_object_value 'web' 'DOMAIN' "$domain" '$BACKEND' "$template" - done - - # Chaning template in user config - old_template=$(grep BACKEND_TEMPLATE $USER_DATA/user.conf) - if [ -z "$old_template" ]; then - sed -i "s/^WEB_DOMAINS/BACKEND_TEMPLATE='$template'\nWEB_DOMAINS/g" \ - $USER_DATA/user.conf - else - update_user_value "$user" '$BACKEND_TEMPLATE' "$template" - fi -else - # Parsing domain values - get_domain_values 'web' - local_ip=$(get_real_ip $IP) - prepare_web_domain_values - - # Rebuilding vhost - del_web_config "$WEB_SYSTEM" "$TPL.tpl" - add_web_config "$WEB_SYSTEM" "$TPL.tpl" - if [ "$SSL" = 'yes' ]; then - del_web_config "$WEB_SYSTEM" "$TPL.stpl" - add_web_config "$WEB_SYSTEM" "$TPL.stpl" - fi - - # Rebuilding proxy configuration - if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.tpl" - add_web_config "$PROXY_SYSTEM" "$PROXY.tpl" - if [ "$SSL" = 'yes' ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.stpl" - add_web_config "$PROXY_SYSTEM" "$PROXY.stpl" - fi - fi - - # Update config - add_object_key "web" 'DOMAIN' "$domain" 'BACKEND' 'PROXY' - update_object_value 'web' 'DOMAIN' "$domain" '$BACKEND' "$template" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - - -# Restarting web -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -$BIN/v-restart-web-backend $restart -check_result $? "Web backend restart failed" >/dev/null - -# Logging -log_history "changed backend template for $domain to $template" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-web-domain-ftp-password b/bin/v-change-web-domain-ftp-password deleted file mode 100755 index 6e74fd9e9..000000000 --- a/bin/v-change-web-domain-ftp-password +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -# info: change ftp user password. -# options: USER DOMAIN FTP_USER FTP_PASSWORD -# -# The function changes ftp user password. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -ftp_user=$3 -password=$4; HIDE=4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD' -is_format_valid 'user' 'domain' 'ftp_user' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_password_valid -get_domain_values 'web' -if [ -z "$(echo $FTP_USER | tr ':' '\n' | grep ^$ftp_user$)" ]; then - echo "Error: account $ftp_user doesn't exist" - log_event "$E_NOTEXIST" "$ARGUMENTS" - exit $E_NOTEXIST -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing ftp user password -echo "$ftp_user:$password" | /usr/sbin/chpasswd -ftp_md5=$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow) - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Rebuilding FTP variables -position=$(echo $FTP_USER |tr ':' '\n' |grep -n '' |grep ":$ftp_user$" |\ - cut -f 1 -d:) -ftp_md5=$(echo $FTP_MD5 |tr ':' '\n' |grep -n '' |\ - sed -e "s%^$position:.*%$position:$ftp_md5%" |\ - cut -f 2 -d :| sed -e "/^$/d"| sed -e ':a;N;$!ba;s/\n/:/g') - -# Updating config -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5" - -# Logging -log_history "changed password for $ftp_user on $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-web-domain-ftp-path b/bin/v-change-web-domain-ftp-path deleted file mode 100755 index 61e1aa80c..000000000 --- a/bin/v-change-web-domain-ftp-path +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash -# info: change path for ftp user. -# options: USER DOMAIN FTP_USER FTP_PATH -# -# The function changes ftp user path. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -ftp_user=$3 -ftp_path=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PATH' -is_format_valid 'user' 'domain' 'ftp_user' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -get_domain_values 'web' -if [ -z "$(echo $FTP_USER | tr ':' '\n' | grep ^$ftp_user$)" ]; then - echo "Error: account $ftp_user doesn't exist" - log_event "$E_NOTEXIST" "$ARGUMENTS" - exit $E_NOTEXIST -fi -ftp_path_a=$(readlink -f "$HOMEDIR/$user/web/$domain/$ftp_path") -if [ -z "$(echo $ftp_path_a |grep $HOMEDIR/$user/web/$domain)" ]; then - echo "Error: absolute path $ftp_path_a is invalid" - log_event "$E_INVALID" "$ARGUMENTS" - exit $E_INVALID -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# MKDIR if path doesn't exist -if [ ! -e "$ftp_path_a" ]; then - mkdir -p "$ftp_path_a" - chown $user:$user "$ftp_path_a" - chmod 751 "$ftp_path_a" -fi - -# Chaning ftp user path -pw_str=$(grep -n "^$ftp_user:" /etc/passwd) -str=$(echo "$pw_str" | cut -f 1 -d :) -old_path=$(echo "$pw_str" | cut -f 7 -d :) -sed -i "$str s%$old_path%$ftp_path_a%g" /etc/passwd - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Transforming absolute path to relative -ftp_path_r=$(echo $ftp_path_a |sed "s%$HOMEDIR/$user/web/$domain%%") - -# Rebuilding FTP variables -position=$(echo $FTP_USER |tr ':' '\n' |grep -n '' |grep ":$ftp_user$" |\ - cut -f 1 -d:) -ftp_path=$(echo $FTP_PATH |tr ':' '\n' |grep -n '' |\ - sed -e "s%^$position:.*%$position:$ftp_path_r%" |\ - cut -f 2 -d :| sed -e ':a;N;$!ba;s/\n/:/g') - -# Updating config -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_PATH' "$ftp_path" - -# Logging -log_history "changed path to $ftp_path_a for $ftp_user@$domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-web-domain-httpauth b/bin/v-change-web-domain-httpauth deleted file mode 100755 index 91ed166d4..000000000 --- a/bin/v-change-web-domain-httpauth +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -# info: change password for http auth user -# options: USER DOMAIN AUTH_USER AUTH_PASSWORD -# -# The call is used for changing http auth user password - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -auth_user=$3 -password=$4; HIDE=4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Defining htpasswd file -htpasswd="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.htpasswd" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN AUTH_USER AUTH_PASSWORD [RESTART]' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_password_valid -get_domain_values 'web' -if [ -z "$(echo "$AUTH_USER" |tr : '\n' |grep ^$auth_user$)" ]; then - echo "Error: auth user $auth_user doesn't exist" - log_event "$E_NOTEXIST" "$ARGUMENTS" - exit $E_NOTEXIST -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding httpasswd user -auth_hash=$($BIN/v-generate-password-hash htpasswd htpasswd $password) -touch $htpasswd -sed -i "/^$auth_user:/d" $htpasswd -echo "$auth_user:$auth_hash" >> $htpasswd - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Rebuilding AUTH_HASH variable -position=$(echo $AUTH_USER |tr ':' '\n' |grep -n '' |grep ":$auth_user$" |\ - cut -f 1 -d:) -auth_hash=$(echo $AUTH_HASH |tr ':' '\n' |grep -n '' |\ - sed -e "s%^$position:.*%$position:$auth_hash%" |\ - cut -f 2 -d :| sed -e "/^$/d"| sed -e ':a;N;$!ba;s/\n/:/g') - -# Updating config -update_object_value 'web' 'DOMAIN' "$domain" '$AUTH_HASH' "$auth_hash" - -# Logging -log_history "changed auth user $httpauth_user password on $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-web-domain-ip b/bin/v-change-web-domain-ip deleted file mode 100755 index 5b2ab31b0..000000000 --- a/bin/v-change-web-domain-ip +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash -# info: change web domain ip -# options: USER DOMAIN DOMAIN [RESTART] -# -# The call is used for changing domain ip - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -ip=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN IP [RESTART]' -is_format_valid 'user' 'domain' 'ip' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_ip_valid "$ip" "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Preparing variables for vhost replace -get_domain_values 'web' -old=$(get_real_ip $IP) -new=$(get_real_ip $ip) - -# Replacing vhost -replace_web_config "$WEB_SYSTEM" "$TPL.tpl" -if [ "$SSL" = 'yes' ]; then - replace_web_config "$WEB_SYSTEM" "$TPL.stpl" -fi - -# Replacing proxy vhost -if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then - replace_web_config "$PROXY_SYSTEM" "$PROXY.tpl" - if [ "$SSL" = 'yes' ]; then - replace_web_config "$PROXY_SYSTEM" "$PROXY.stpl" - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update counters -increase_ip_value "$new" -decrease_ip_value "$old" - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$IP' "$3" - -# Restart web server -$BIN/v-restart-web $restart -check_result $? "WEB restart failed" >/dev/null - -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Logging -log_history "changed web domain $domain ip to $3" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-web-domain-name b/bin/v-change-web-domain-name deleted file mode 100755 index 6cbd1d999..000000000 --- a/bin/v-change-web-domain-name +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# info: change web domain name -# options: USER DOMAIN NEW_DOMAIN [RESTART] -# -# The call is used for changing the domain name. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -domain_idn=$2 -new_domain=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN NEW_DOMAIN [RESTART]' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -check_new_domain=$(grep "DOMAIN='$new_domain'" $VESTA/data/users/*/web.conf) -if [ ! -z "$check_new_domain" ]; then - check_result $E_EXISTS "$new_domain already exists" -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Fetching domain variables -get_domain_values 'web' - -# Changing domain in web.conf -sed -i "s/DOMAIN='$domain'/DOMAIN='$new_domain'/" $USER_DATA/web.conf -new_alias=$(echo "$ALIAS,$domain" |\ - sed -e "s/,/\n/g"|\ - sed -e "s/^$new_domain$//g"|\ - sed -e "/^$/d"|\ - sed -e ':a;N;$!ba;s/\n/,/g') - -# Updating domain alias -if [ "$ALIAS" != "$new_alias" ]; then - sed -i "s/ALIAS='$ALIAS'/ALIAS='$new_alias'/" $USER_DATA/web.conf -fi - -# Moving document root and domain logs -mv $HOMEDIR/$user/web/$domain $HOMEDIR/$user/web/$new_domain/ -cd /var/log/$WEB_SYSTEM/domains -mv $domain.log $new_domain.log -mv $domain.error.log $new_domain.error.log -mv $domain.bytes $new_domain.bytes -rm -f $HOMEDIR/$user/web/$new_domain/logs/$domain.* - -# Updating domain certificates -if [ -e "$USER_DATA/ssl/$domain.crt" ]; then - cd $USER_DATA/ssl - mv $domain.crt $new_domain.crt - mv $domain.ca $new_domain.ca - mv $domain.pem $new_domain.pem - mv $domain.key $new_domain.key - rm -f $HOMEDIR/$user/conf/web/ssl.$domain.* -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Rebuilding vhosts -$BIN/v-rebuild-web-domains $user $restart - -# Logging -log_history "changed web domain name $old_domain to $new_domain" -log_event "$OK" "$EVENT" - -exit diff --git a/bin/v-change-web-domain-proxy-tpl b/bin/v-change-web-domain-proxy-tpl deleted file mode 100755 index 4d022cb9d..000000000 --- a/bin/v-change-web-domain-proxy-tpl +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash -# info: change web domain proxy template -# options: USER DOMAIN TEMPLATE [EXTENTIONS] [RESTART] -# -# The function changes proxy template - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -template=$3 -default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\ -exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm" -extentions=${4-$default_extentions} -restart="$5" - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN TEMPLATE [EXTENTIONS] [RESTART]' -is_format_valid 'user' 'domain' 'template' -is_system_enabled "$PROXY_SYSTEM" 'PROXY_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$PROXY' -is_proxy_template_valid $template - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -local_ip=$(get_real_ip $IP) - -# Delete old vhost -del_web_config "$PROXY_SYSTEM" "$PROXY.tpl" -if [ "$SSL" = 'yes' ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.stpl" -fi - -# Add new vhost -PROXY="$template" -PROXY_EXT="$extentions" -prepare_web_domain_values -add_web_config "$PROXY_SYSTEM" "$PROXY.tpl" -if [ "$SSL" = 'yes' ]; then - add_web_config "$PROXY_SYSTEM" "$PROXY.stpl" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating config -update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$PROXY" -update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions" - -# Restarting proxy -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Logging -log_history "changed proxy template for $domain to $template" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-web-domain-sslcert b/bin/v-change-web-domain-sslcert deleted file mode 100755 index f60a4eb0f..000000000 --- a/bin/v-change-web-domain-sslcert +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash -# info: change domain ssl certificate -# options: USER DOMAIN SSL_DIR [RESTART] -# -# The function changes SSL domain certificate and the key. If ca file present -# it will be replaced as well. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -ssl_dir=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN SSL_DIR [RESTART]' -is_format_valid 'user' 'domain' 'ssl_dir' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' -is_web_domain_cert_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting old certificate -tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d) -rm -f $HOMEDIR/$user/conf/web/ssl.$domain.* -mv $USER_DATA/ssl/$domain.* $tmpdir -chown -R $user:$user $tmpdir - -# Adding new certificate to user data directory -cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt -cp -f $ssl_dir/$domain.key $USER_DATA/ssl/$domain.key -cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem -if [ -e "$ssl_dir/$domain.ca" ]; then - cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca - cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem -fi - -# Adding new certificate to user dir -cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/web/ssl.$domain.crt -cp -f $USER_DATA/ssl/$domain.key $HOMEDIR/$user/conf/web/ssl.$domain.key -cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/web/ssl.$domain.pem -if [ -e "$USER_DATA/ssl/$domain.ca" ]; then - cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/web/ssl.$domain.ca -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting web server -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Logging -log_history "changed ssl certificate for $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-web-domain-sslhome b/bin/v-change-web-domain-sslhome deleted file mode 100755 index 06b4c563a..000000000 --- a/bin/v-change-web-domain-sslhome +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# info: changing domain ssl home - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -ssl_home=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN SSL_HOME [RESTART]' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get domain values -get_domain_values 'web' -old_ssl_home=$SSL_HOME -SSL_HOME=$ssl_home - -# Parsing tpl_option -case $SSL_HOME in - single) new="$HOMEDIR/$user/web/$domain/public_shtml" ; - old="$HOMEDIR/$user/web/$domain/public_html" ;; - same) new="$HOMEDIR/$user/web/$domain/public_html" ; - old="$HOMEDIR/$user/web/$domain/public_shtml" ;; - *) check_args '3' "2" 'USER DOMAIN SSLHOME' -esac - -# Changing sslhome directory -replace_web_config "$WEB_SYSTEM" "$TPL.stpl" - -# Changing proxy vhost -if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then - replace_web_config "$PROXY_SYSTEM" "$PROXY.stpl" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME" - -# Restarting web server -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Logging -log_history "changed ssl home for $domain to $ssl_home" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-change-web-domain-stats b/bin/v-change-web-domain-stats deleted file mode 100755 index 6355e4a1b..000000000 --- a/bin/v-change-web-domain-stats +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/bash -# info: change web domain statistics -# options: USER DOMAIN TYPE -# -# The function of deleting site's system of statistics. Its type is -# automatically chooses from client's configuration file. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -type=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN TYPE' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_type_valid "$STATS_SYSTEM" "$type" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining statistic type -get_domain_values 'web' - -# Comparing stats types -if [ "$STATS" == $type ]; then - log_event "$OK" "$ARGUMENTS" - exit 0 -fi - -# Defining statistic dir -stats_dir="$HOMEDIR/$user/web/$domain/stats" - -# Deleting dir content -rm -rf $stats_dir/* - -# Deleting config -rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf - -# Adding statistic config -prepare_web_domain_values -cat $WEBTPL/$type/$type.tpl |\ - sed -e "s/%ip%/$ip/g" \ - -e "s/%web_port%/$WEB_PORT/g" \ - -e "s/%web_system%/$WEB_SYSTEM/g" \ - -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ - -e "s/%rgroups%/$WEB_RGROUPS/g" \ - -e "s/%proxy_system%/$PROXY_SYSTEM/g" \ - -e "s/%proxy_port%/$PROXY_PORT/g" \ - -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%user%/$user/g" \ - -e "s/%home%/${HOMEDIR////\/}/g" \ - -e "s/%alias%/${aliases//,/ }/g" \ - -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ - > $HOMEDIR/$user/conf/web/$type.$domain.conf - -if [ "$type" == 'awstats' ]; then - rm -f /etc/awstats/$type.$domain_idn.conf - ln -s $HOMEDIR/$user/conf/web/$type.$domain.conf \ - /etc/awstats/$type.$domain_idn.conf -else - mkdir -p /var/lib/webalizer -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type" - -# Logging -log_history "changed web log stats for $domain to $type" -log_event "$OK" "$ARGUMENTS" - -# Build stats -exec $BIN/v-update-web-domain-stat $user $domain - -exit diff --git a/bin/v-change-web-domain-tpl b/bin/v-change-web-domain-tpl deleted file mode 100755 index 9b9623bb1..000000000 --- a/bin/v-change-web-domain-tpl +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash -# info: change web domain template -# options: USER DOMAIN TEMPLATE [RESTART] -# -# The function changes template of the web configuration file. The content -# of webdomain directories remains untouched. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -template=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN TEMPLATE [RESTART]' -is_format_valid 'user' 'domain' 'template' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_web_template_valid "$template" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -local_ip=$(get_real_ip $IP) - -# Deleting domain -del_web_config "$WEB_SYSTEM" "$TPL.tpl" -if [ "$SSL" = 'yes' ]; then - del_web_config "$WEB_SYSTEM" "$TPL.stpl" -fi - -# Defining variables for new vhost config -prepare_web_domain_values -add_web_config "$WEB_SYSTEM" "$template.tpl" -if [ "$SSL" = 'yes' ]; then - add_web_config "$WEB_SYSTEM" "$template.stpl" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Changing tpl in config -update_object_value 'web' 'DOMAIN' "$domain" '$TPL' "$template" - -# Restarting web -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -# Logging -log_history "changed web domain template for $domain to $template" '' 'admin' -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-check-api-key b/bin/v-check-api-key deleted file mode 100755 index 8d0d409e1..000000000 --- a/bin/v-check-api-key +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# info: check api key -# options: KEY -# -# The function checks a key file in /usr/local/vesta/data/keys/ - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -if [ -z "$1" ]; then - echo "Error: key missmatch" - exit 9 -fi -key=$(basename $1) -ip=${2-127.0.0.1} -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ ! -e $VESTA/data/keys/$key ]; then - echo "Error: key missmatch" - echo "$date $time api $ip failed to login" >> $VESTA/log/auth.log - exit 9 -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -echo "$date $time api $ip successfully launched" >> $VESTA/log/auth.log - -exit diff --git a/bin/v-check-fs-permission b/bin/v-check-fs-permission deleted file mode 100755 index 00e5482af..000000000 --- a/bin/v-check-fs-permission +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# info: open file -# options: USER FILE -# -# The function opens/reads files on the file system - -user=$1 -src=$2 - -# Checking arguments -if [ -z "$src" ]; then - echo "Usage: USER FILE" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking user homedir -homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) -if [ -z $homedir ]; then - echo "Error: user home directory doesn't exist" - exit 12 -fi - -# Checking path -if [ ! -z "$src" ]; then - rpath=$(readlink -f "$src") - if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid source path $user $src" - exit 2 - fi -fi - -# Checking if file has readable permission -sudo -u $user ls "$src" > /dev/null 2>&1 -if [ $? -ne 0 ]; then - echo "Error: can't read $src" - exit 1 -fi - -# Exiting -exit diff --git a/bin/v-check-user-hash b/bin/v-check-user-hash deleted file mode 100755 index a18aba0ea..000000000 --- a/bin/v-check-user-hash +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/bash -# info: check user hash -# options: USER HASH [IP] -# -# The function verifies user hash - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -hash=$2; HIDE=2 -ip=${3-127.0.0.1} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - - -check_args '2' "$#" 'USER HASH' -is_format_valid 'user' - -# Checking user -if [ ! -d "$VESTA/data/users/$user" ] && [ "$user" != 'root' ]; then - echo "Error: password missmatch" - echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log - exit 9 -fi - -# Checking user hash -is_hash_valid - -# Checking empty hash -if [[ -z "$hash" ]]; then - echo "Error: password missmatch" - echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log - exit 9 -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - - -# Parsing user's salt -shadow=$(grep "^$user:" /etc/shadow | cut -f 2 -d :) - -if echo "$shadow" | grep -qE '^\$[0-9a-z]+\$[^\$]+\$' -then - salt=$(echo "$shadow" |cut -f 3 -d \$) - method=$(echo "$shadow" |cut -f 2 -d \$) - if [ "$method" -eq '1' ]; then - method='md5' - elif [ "$method" -eq '6' ]; then - method='sha-512' - else - echo "Error: password missmatch" - echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log - exit 9 - fi -else - salt=${shadow:0:2} - method='des' -fi - -# Checking salt -if [ -z "$salt" ]; then - echo "Error: password missmatch" - echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log - exit 9 -fi - -# Comparing hashes -if [[ "$shadow" != "$hash" ]]; then - echo "Error: password missmatch" - echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log - exit 9 -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -echo "$date $time $user $ip successfully logged in" >> $VESTA/log/auth.log - -exit diff --git a/bin/v-check-user-password b/bin/v-check-user-password deleted file mode 100755 index fbb0221e3..000000000 --- a/bin/v-check-user-password +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/bash -# info: check user password -# options: USER PASSWORD [IP] -# -# The function verifies user password from file - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -password=$2; HIDE=2 -ip=${3-127.0.0.1} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - - -check_args '2' "$#" 'USER PASSWORD' -is_format_valid 'user' - -# Checking user -if [ ! -d "$VESTA/data/users/$user" ] && [ "$user" != 'root' ]; then - echo "Error: password missmatch" - echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log - exit 9 -fi - -# Checking user password -is_password_valid - -# Checking empty password -if [[ -z "$password" ]]; then - echo "Error: password missmatch" - echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log - exit 9 -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - - -# Parsing user's salt -shadow=$(grep "^$user:" /etc/shadow | cut -f 2 -d :) - -if echo "$shadow" | grep -qE '^\$[0-9a-z]+\$[^\$]+\$' -then - salt=$(echo "$shadow" |cut -f 3 -d \$) - method=$(echo "$shadow" |cut -f 2 -d \$) - if [ "$method" -eq '1' ]; then - method='md5' - elif [ "$method" -eq '6' ]; then - method='sha-512' - else - echo "Error: password missmatch" - echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log - exit 9 - fi -else - salt=${shadow:0:2} - method='des' -fi - -if [ -z "$salt" ]; then - echo "Error: password missmatch" - echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log - exit 9 -fi - -# Generating hash -set -o noglob -hash=$($BIN/v-generate-password-hash $method $salt <<< "$password") -if [[ -z "$hash" ]]; then - echo "Error: password missmatch" - echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log - exit 9 -fi - -# Checking hash -result=$(grep "^$user:$hash:" /etc/shadow 2>/dev/null) -if [[ -z "$result" ]]; then - echo "Error: password missmatch" - echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log - exit 9 -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -echo "$date $time $user $ip successfully logged in" >> $VESTA/log/auth.log - -exit diff --git a/bin/v-check-vesta-license b/bin/v-check-vesta-license deleted file mode 100755 index 7fa1a12cd..000000000 --- a/bin/v-check-vesta-license +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# info: check vesta license -# options: [MODULE] -# -# The function activates and register vesta license - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -module=$(echo $1 | tr '[:lower:]' '[:upper:]') - -# Importing system environment -source /etc/profile - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking module -if [ -z "$module" ]; then - modules=$(grep _KEY= $VESTA/conf/vesta.conf) -else - modules=$(grep "${module}_KEY" $VESTA/conf/vesta.conf) -fi - -IFS=$'\n' -for str in $modules; do - module=$(echo "$str" |cut -f 1 -d _) - license=$(echo "$str" |cut -f 2 -d \') - if [ ! -z "$license" ]; then - v_host='https://vestacp.com/checkout' - answer=$(curl -s "$v_host/check.php?licence_key=$license&module=$module") - check_result $? "cant' connect to vestacp.com " 0 - echo "$module $license $answer" - if [[ "$answer" != '0' ]]; then - if [ "$module" = 'SFTPJAIL' ]; then - setsid $BIN/v-delete-sys-sftp-jail 2>/dev/null - fi - sed -i "s/${module}_KEY=.*/${module}_KEY=''/g" \ - $VESTA/conf/vesta.conf - fi - fi -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-copy-fs-directory b/bin/v-copy-fs-directory deleted file mode 100755 index 11c647ed7..000000000 --- a/bin/v-copy-fs-directory +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -# info: copy directory -# options: USER SRC_DIRECTORY DST_DIRECTORY -# -# The function copies directory on the file system - -user=$1 -src_dir=$2 -dst_dir=$3 - -# Checking arguments -if [ -z "$dst_dir" ]; then - echo "Usage: USER SRC_DIRECTORY DST_DIRECTORY" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking user homedir -homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) -if [ -z $homedir ]; then - echo "Error: user home directory doesn't exist" - exit 12 -fi - -# Checking source dir -if [ ! -e "$src_dir" ]; then - echo "Error: source directory $src_dir doesn't exist" - exit 3 -fi - -# Checking source path -rpath=$(readlink -f "$src_dir") -if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid source path $src_dir" - exit 2 -fi - -# Checking destination path -rpath=$(readlink -f "$dst_dir") -if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid destination path $dst_dir" - exit 2 -fi - -# Copying directory -sudo -u $user cp -r "$src_dir" "$dst_dir" >/dev/null 2>&1 -if [ $? -ne 0 ]; then - echo "Error: directory $src_dir was not copied" - exit 3 -fi - -# Exiting -exit diff --git a/bin/v-copy-fs-file b/bin/v-copy-fs-file deleted file mode 100755 index 792956ecf..000000000 --- a/bin/v-copy-fs-file +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -# info: copy file -# options: USER SRC_FILE DST_FLE -# -# The function copies file on the file system - -user=$1 -src_file=$2 -dst_file=$3 - -# Checking arguments -if [ -z "$dst_file" ]; then - echo "Usage: USER SRC_FILE DST_FILE" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking user homedir -homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) -if [ -z $homedir ]; then - echo "Error: user home directory doesn't exist" - exit 12 -fi - -# Checking source file -if [ ! -f "$src_file" ]; then - echo "Error: $src_file doesn't exist" - exit 3 -fi - -# Checking source path -rpath=$(readlink -f "$src_file") -if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid source path $src_file" - exit 2 -fi - -# Checking destination path -rpath=$(readlink -f "$dst_file") -if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: ivalid destination path $dst_file" - exit 2 -fi - -# Copying file -sudo -u $user cp "$src_file" "$dst_file" >/dev/null 2>&1 -if [ $? -ne 0 ]; then - echo "Error: file $src_file was not copied" - exit 3 -fi - -# Exiting -exit diff --git a/bin/v-deactivate-vesta-license b/bin/v-deactivate-vesta-license deleted file mode 100755 index c7279e456..000000000 --- a/bin/v-deactivate-vesta-license +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# info: deactivate vesta license -# options: MODULE LICENSE -# -# The function deactivates vesta license - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -module=$(echo $1 | tr '[:lower:]' '[:upper:]') -license=$2 - -# Importing system environment -source /etc/profile - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking arg number -check_args '2' "$#" 'MODULE LICENSE' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Activating license -v_host='https://vestacp.com/checkout' -answer=$(curl -s "$v_host/cancel.php?licence_key=$license&module=$module") -check_result $? "cant' connect to vestacp.com " $E_CONNECT - -# Checking server answer -if [[ "$answer" != '0' ]]; then - echo "Error: $module license $license is invalid" - exit $E_INVALID -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating vesta.conf -if [ ! -z "$(grep "${module}_KEY" $VESTA/conf/vesta.conf)" ]; then - sed -i "s/${module}_KEY=.*/${module}_KEY=''/g" $VESTA/conf/vesta.conf -fi - -# Deactivating sftpjail -if [ "$module" = 'SFTPJAIL' ]; then - setsid $BIN/v-delete-sys-sftp-jail 2>/dev/null -fi - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-backup-host b/bin/v-delete-backup-host deleted file mode 100755 index d5d447565..000000000 --- a/bin/v-delete-backup-host +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# info: delete backup ftp server -# options: TYPE -# -# The function deletes ftp backup host - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -type=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'TYPE [HOST]' -types=$(echo "$BACKUP_SYSTEM" |sed "s/,/\n/g" |grep "^$type$") -if [ -z "$types" ]; then - echo "Error: invalid backup type" - log_event "$E_INVALID" "$ARGUMENTS" - exit $E_INVALID -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting host config -rm -f $VESTA/conf/$type.backup.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating vesta.conf -bckp=$(echo "$BACKUP_SYSTEM" |\ - sed "s/,/\n/g"|\ - sed "s/^$type$//" |\ - sed "/^$/d"|\ - sed ':a;N;$!ba;s/\n/,/g') -sed -i "s/BACKUP_SYSTEM=.*/BACKUP_SYSTEM='$bckp'/g" $VESTA/conf/vesta.conf - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-cron-job b/bin/v-delete-cron-job deleted file mode 100755 index 77668e17f..000000000 --- a/bin/v-delete-cron-job +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# info: delete cron job -# options: USER JOB -# -# The function deletes cron job. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -job=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER JOB' -is_format_valid 'user' 'job' -is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'cron' 'JOB' "$job" -is_object_unsuspended 'cron' 'JOB' "$job" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting job -sed -i "/JOB='$job' /d" $USER_DATA/cron.conf - -# Sorting jobs by id -sort_cron_jobs - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Decreasing cron value -decrease_user_value "$user" '$U_CRON_JOBS' - -# Restarting crond -$BIN/v-restart-cron -check_result $? "Restart restart failed" >/dev/null - -# Logging -log_history "deleted cron job $job" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-cron-reports b/bin/v-delete-cron-reports deleted file mode 100755 index 45fd88cab..000000000 --- a/bin/v-delete-cron-reports +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# info: delete cron reports -# options: USER -# -# The script for disabling reports on cron tasks and administrative -# notifications. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing user report value -update_user_value "$user" '$CRON_REPORTS' 'no' - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting crond -$BIN/v-restart-cron -check_result $? "Cron restart failed" >/dev/null - -# Logging -log_history "disabled cron reporting" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-cron-restart-job b/bin/v-delete-cron-restart-job deleted file mode 100755 index 33c8c5661..000000000 --- a/bin/v-delete-cron-restart-job +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# info: delete restart job -# options: NONE -# -# The script for disabling restart cron tasks - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Add cron job -cmd="sudo /usr/local/vesta/bin/v-update-sys-queue restart" -check_cron=$(grep "$cmd" $VESTA/data/users/admin/cron.conf 2> /dev/null) -if [ ! -z "$check_cron" ]; then - eval $check_cron - $BIN/v-delete-cron-job admin "$JOB" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-cron-vesta-autoupdate b/bin/v-delete-cron-vesta-autoupdate deleted file mode 100755 index 051bc7649..000000000 --- a/bin/v-delete-cron-vesta-autoupdate +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash -# info: delete vesta autoupdate cron job -# options: NONE -# -# The function deletes vesta autoupdate cron job. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=admin - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM' -check_cron=$(grep 'v-update-sys-vesta-all' $USER_DATA/cron.conf) -if [ -z "$check_cron" ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - - -# Deleting job -job=$(echo $check_cron|tr ' ' "\n"|grep JOB|cut -f 2 -d "'") -sed -i "/JOB='$job' /d" $USER_DATA/cron.conf - -# Sorting jobs by id -sort_cron_jobs - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Decreasing cron value -decrease_user_value "$user" '$U_CRON_JOBS' - -# Restarting crond -$BIN/v-restart-cron -check_result $? "Cron restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-database b/bin/v-delete-database deleted file mode 100755 index 33ed53f14..000000000 --- a/bin/v-delete-database +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# info: delete database -# options: USER DATABASE -# -# The function for deleting the database. If database user have access to -# another database, he will not be deleted. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -database=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/db.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DATABASE' -is_format_valid 'user' 'database' -is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" -is_object_unsuspended 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get database values -get_database_values - -# Switching on db type -case $TYPE in - mysql) delete_mysql_database ;; - pgsql) delete_pgsql_database ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Deleting database -sed -i "/DB='$database' /d" $USER_DATA/db.conf - -# Decreasing counters -decrease_dbhost_values -decrease_user_value "$user" '$U_DATABASES' - -# Logging -log_history "deleted $database database" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-database-host b/bin/v-delete-database-host deleted file mode 100755 index 4a52be10f..000000000 --- a/bin/v-delete-database-host +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# info: delete database server -# options: TYPE HOST -# -# The function for deleting the database host from vesta configuration. It will -# be deleted if there are no databases created on it only. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -type=$1 -host=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/db.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'TYPE HOST' -is_format_valid 'type' 'host' -is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -is_type_valid "$DB_SYSTEM" "$type" -is_object_valid "../../conf/$type" 'HOST' "$host" -is_dbhost_free - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -# Deleting server -sed -i "/HOST='$host' /d" $VESTA/conf/$type.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "deleted $type database server $host" '' 'admin' -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-databases b/bin/v-delete-databases deleted file mode 100755 index d771bba35..000000000 --- a/bin/v-delete-databases +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# info: delete user databases -# options: USER -# -# The function deletes all user databases. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting delete loop -for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do - $BIN/v-delete-database "$user" "$database" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-dns-domain b/bin/v-delete-dns-domain deleted file mode 100755 index c82b0c00d..000000000 --- a/bin/v-delete-dns-domain +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash -# info: delete dns domain -# options: USER DOMAIN -# -# The function for deleting DNS domain. By deleting it all records will also be -# deleted. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -restart="$3" - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ') - -# Deleting system configs -if [[ "$DNS_SYSTEM" =~ named|bind ]]; then - if [ -e '/etc/named.conf' ]; then - dns_conf='/etc/named.conf' - else - dns_conf='/etc/bind/named.conf' - fi - - sed -i "/\/$user\/conf\/dns\/$domain.db\"/d" $dns_conf - rm -f $HOMEDIR/$user/conf/dns/$domain.db -fi - -# Updating dns-cluster queue -if [ ! -z "$DNS_CLUSTER" ]; then - cmd="$BIN/v-delete-remote-dns-domain $user $domain" - echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Deleting domain -sed -i "/DOMAIN='$domain'/ d" $USER_DATA/dns.conf -rm -f $USER_DATA/dns/$domain.conf - -# Decreasing domain value -decrease_user_value "$user" '$U_DNS_DOMAINS' -decrease_user_value "$user" '$U_DNS_RECORDS' "$records" - -# Restarting named -$BIN/v-restart-dns $restart -check_result $? "Bind restart failed" >/dev/null - -# Logging -log_history "deleted dns domain $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-dns-domains b/bin/v-delete-dns-domains deleted file mode 100755 index a98b31408..000000000 --- a/bin/v-delete-dns-domains +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# info: delete dns domains -# options: USER -# -# The function for deleting all users DNS domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -restart=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting delete loop -for domain in $(search_objects 'dns' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-delete-dns-domain "$user" "$domain" 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting named -$BIN/v-restart-dns $restart -check_result $? "Bind restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-dns-domains-src b/bin/v-delete-dns-domains-src deleted file mode 100755 index 85a6c147c..000000000 --- a/bin/v-delete-dns-domains-src +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# info: delete dns domains based on SRC field -# options: USER SRC [RESTART] -# -# The function for deleting DNS domains related to a certain host. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -src=$2 -restart=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER SRC [RESTART]' -is_format_valid 'user' 'src' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting delete loop -for domain in $(search_objects 'dns' 'SRC' "$src" 'DOMAIN'); do - $BIN/v-delete-dns-domain "$user" "$domain" 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -$BIN/v-restart-dns $restart -check_result $? "Bind restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-dns-on-web-alias b/bin/v-delete-dns-on-web-alias deleted file mode 100755 index 87e688493..000000000 --- a/bin/v-delete-dns-on-web-alias +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -# info: delete dns domain or dns record based on web domain alias -# options: USER DOMAIN -# -# The function deletes dns domain or dns record based on web domain alias. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -dom_alias=$(idn -t --quiet -u "$3" ) -dom_alias=$(echo $dom_alias |sed -e 's/\.*$//g' -e 's/^\.*//g') -dom_alias=$(echo $dom_alias |tr '[:upper:]' '[:lower:]') -dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) -restart="$4" - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ALIAS' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' - -# Check if it a simple domain -if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then - if [ -e "$USER_DATA/dns/$dom_alias.conf" ]; then - $BIN/v-delete-dns-domain $user $dom_alias $IP $restart - fi -else - # Check subdomain - sub=$(echo "$dom_alias" | cut -f1 -d . -s) - root=$(echo "$dom_alias" | sed "s/^$sub.//" ) - if [ -e "$USER_DATA/dns/$root.conf" ]; then - if [ "$sub" == '*' ]; then - rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$root.conf) - else - rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$root.conf) - fi - if [ ! -z "$rec" ]; then - eval "$rec" - $BIN/v-delete-dns-record $user "$root" "$ID" $restart - fi - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-dns-record b/bin/v-delete-dns-record deleted file mode 100755 index 4b4555dfa..000000000 --- a/bin/v-delete-dns-record +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# info: delete dns record -# options: USER DOMAIN ID [RESTART] -# -# The function for deleting a certain record of DNS zone. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -id=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ID [RESTART]' -is_format_valid 'user' 'domain' 'id' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_object_valid "dns/$domain" 'ID' "$id" -is_dns_record_critical - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting record -sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf - -# Updating zone -if [[ "$DNS_SYSTEM" =~ named|bind ]]; then - update_domain_serial - update_domain_zone -fi - -# Updating dns-cluster queue -if [ ! -z "$DNS_CLUSTER" ]; then - # Check for first sync - dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe) - if [ -z "$dlock" ]; then - cmd="$BIN/v-delete-remote-dns-record $user $domain $id" - echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Upddate counters -records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')" -update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" -decrease_user_value "$user" '$U_DNS_RECORDS' - -# Restarting named -$BIN/v-restart-dns $restart -check_result $? "Bind restart failed" >/dev/null - -# Logging -log_history "deleted dns record $id on $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-domain b/bin/v-delete-domain deleted file mode 100755 index b6294679a..000000000 --- a/bin/v-delete-domain +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash -# info: delete web/dns/mail domain -# options: USER DOMAIN -# -# The function deletes web/dns/mail domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -restart="${3-yes}" - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Working on Web domain -if [ ! -z "$WEB_SYSTEM" ]; then - str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf) - if [ ! -z "$str" ]; then - domain_found='yes' - $BIN/v-delete-web-domain $user $domain 'no' - check_result $? "can't suspend web" > /dev/null - fi -fi - -# Working on DNS domain -if [ ! -z "$DNS_SYSTEM" ]; then - str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf) - if [ ! -z "$str" ]; then - domain_found='yes' - $BIN/v-delete-dns-domain $user $domain 'no' - check_result $? "can't suspend dns" > /dev/null - fi -fi - -# Working on Mail domain -if [ ! -z "$MAIL_SYSTEM" ]; then - str=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf) - if [ ! -z "$str" ]; then - domain_found='yes' - $BIN/v-delete-mail-domain $user $domain - check_result $? "can't suspend mail" > /dev/null - fi -fi - -# Checking domain search result -if [ -z "$domain_found" ]; then - check_result $E_NOTEXISTS "domain $domain doesn't exist" -fi - -# Restarting services -$BIN/v-restart-web $restart -check_result $? "can't restart web" > /dev/null - -$BIN/v-restart-proxy $restart -check_result $? "can't restart proxy" > /dev/null - -$BIN/v-restart-dns $restart -check_result $? "can't restart dns" > /dev/null - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-delete-firewall-ban b/bin/v-delete-firewall-ban deleted file mode 100755 index 52f3403d8..000000000 --- a/bin/v-delete-firewall-ban +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# info: delete firewall blocking rule -# options: IP CHAIN -# -# The function deletes blocking rule from system firewall - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system variables -source /etc/profile - -# Argument definition -ip=$1 -chain=$(echo $2|tr '[:lower:]' '[:upper:]') - -# Defining absolute path for iptables and modprobe -iptables="/sbin/iptables" - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'IP CHAIN' -is_format_valid 'ip' 'chain' -is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking ip in banlist -conf="$VESTA/data/firewall/banlist.conf" -check_ip=$(grep "IP='$ip' CHAIN='$chain'" $conf 2>/dev/null) -if [ -z "$check_ip" ]; then - exit -fi - -# Deleting ip from banlist -sip=$(echo "$ip"| sed "s|/|\\\/|g") -sed -i "/IP='$sip' CHAIN='$chain'/d" $conf -b=$($iptables -L fail2ban-$chain --line-number -n|grep $ip|awk '{print $1}') -$iptables -D fail2ban-$chain $b 2>/dev/null - -# Changing permissions -chmod 660 $conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-firewall-chain b/bin/v-delete-firewall-chain deleted file mode 100755 index 7e510d80f..000000000 --- a/bin/v-delete-firewall-chain +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -# info: delete firewall chain -# options: CHAIN -# -# The function adds new rule to system firewall - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system variables -source /etc/profile - -# Argument definition -chain=$(echo $1 | tr '[:lower:]' '[:upper:]') - -# Defining absolute path to iptables -iptables="/sbin/iptables" - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'CHAIN' -is_format_valid 'chain' -is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting chain -chains=$VESTA/data/firewall/chains.conf -banlist=$VESTA/data/firewall/banlist.conf -chain_param=$(grep "CHAIN='$chain'" $chains 2>/dev/null) -if [ ! -z "$chain_param" ]; then - eval $chain_param - sed -i "/CHAIN='$chain'/d" $chains - sed -i "/CHAIN='$chain'/d" $banlist - $iptables -D INPUT -p $PROTOCOL \ - --dport $PORT -j fail2ban-$CHAIN 2>/dev/null -fi - -# Deleting iptables chain -$iptables -F fail2ban-$CHAIN 2>/dev/null -$iptables -X fail2ban-$CHAIN 2>/dev/null - -# Changing permissions -chmod 660 $chains - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-firewall-rule b/bin/v-delete-firewall-rule deleted file mode 100755 index 8f646644b..000000000 --- a/bin/v-delete-firewall-rule +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# info: delete firewall rule -# options: RULE -# -# The function deletes firewall rule. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system variables -source /etc/profile - -# Argument definition -rule=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'RULE' -is_format_valid 'rule' -is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM' -is_object_valid '../../data/firewall/rules' 'RULE' "$rule" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting rule -sed -i "/RULE='$rule' /d" $VESTA/data/firewall/rules.conf - -# Updating system firewall -$BIN/v-update-firewall - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-fs-directory b/bin/v-delete-fs-directory deleted file mode 100755 index b1cedde7e..000000000 --- a/bin/v-delete-fs-directory +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# info: delete directory -# options: USER DIRECTORY -# -# The function deletes directory on the file system - - -user=$1 -dst_dir=$2 - -# Checking arguments -if [ -z "$dst_dir" ]; then - echo "Usage: USER DIRECTORY" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking user homedir -homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) -if [ -z $homedir ]; then - echo "Error: user home directory doesn't exist" - exit 12 -fi - -# Checking destination path -rpath=$(readlink -f "$dst_dir") -if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid destination path $dst_dir" - exit 1 -fi - -# Deleting directory -sudo -u $user rm -rf "$dst_dir" # >/dev/null 2>&1 -if [ $? -ne 0 ]; then - echo "Error: directory $dst_dir was not deleted" - exit 3 -fi - -# Exiting -exit diff --git a/bin/v-delete-fs-file b/bin/v-delete-fs-file deleted file mode 100755 index bca18ff06..000000000 --- a/bin/v-delete-fs-file +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# info: delete file -# options: USER FILE -# -# The function deletes file on the file system - - -user=$1 -dst_file=$2 - -# Checking arguments -if [ -z "$dst_file" ]; then - echo "Usage: USER FILE" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking user homedir -homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) -if [ -z $homedir ]; then - echo "Error: user home directory doesn't exist" - exit 12 -fi - -# Checking destination path -rpath=$(readlink -f "$dst_file") -if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid destination path $dst_file" - exit 2 -fi - -# Deleting file -sudo -u $user rm -f "$dst_file" >/dev/null 2>&1 -if [ $? -ne 0 ]; then - echo "Error: file $dst_file was not deleted" - exit 3 -fi - -# Exiting -exit diff --git a/bin/v-delete-letsencrypt-domain b/bin/v-delete-letsencrypt-domain deleted file mode 100755 index 4dad88b97..000000000 --- a/bin/v-delete-letsencrypt-domain +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -# info: deleting letsencrypt ssl cetificate for domain -# options: USER DOMAIN [RESTART] -# -# The function turns off letsencrypt SSL support for a domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -restart=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [RESTART]' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_system_enabled "$WEB_SSL" 'SSL_SUPPORT' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$LETSENCRYPT' - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Delete SSL -$BIN/v-delete-web-domain-ssl $user $domain $restart >/dev/null 2>&1 -check_result $? "SSL delete" >/dev/null - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating letsencrypt flag -update_object_value 'web' 'DOMAIN' "$domain" '$LETSENCRYPT' 'no' - -# Restarting web -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -# Restarting proxy -if [ ! -z "$PROXY_SYSTEM" ]; then - $BIN/v-restart-web $restart >/dev/null - check_result $? "Proxy restart failed" >/dev/null -fi - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-mail-account b/bin/v-delete-mail-account deleted file mode 100755 index f0da423cb..000000000 --- a/bin/v-delete-mail-account +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -# info: delete mail account -# options: USER DOMAIN ACCOUNT -# -# The function deletes email account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -account=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ACCOUNT' -is_format_valid 'user' 'domain' 'account' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') - for al in ${aliases//,/ }; do - sed -i "/^$al@$domain_idn:$account/d" \ - $HOMEDIR/$user/conf/mail/$domain/aliases - done - - sed -i "/^$account@$domain_idn:/d" $HOMEDIR/$user/conf/mail/$domain/aliases - sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd - rm -rf $HOMEDIR/$user/mail/$domain/$account -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -sed -i "/ACCOUNT='$account'/d" $USER_DATA/mail/$domain.conf - -# Decrease mail accounts counter -accounts=$(wc -l $USER_DATA/mail/$domain.conf | cut -f 1 -d ' ') -decrease_user_value "$user" '$U_MAIL_ACCOUNTS' -update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accounts" - -# Logging -log_history "deleted $account@$domain mail account" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-mail-account-alias b/bin/v-delete-mail-account-alias deleted file mode 100755 index 9d5f902f3..000000000 --- a/bin/v-delete-mail-account-alias +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -# info: delete mail account alias aka nickname -# options: USER DOMAIN ACCOUNT ALIAS -# -# The function deletes email account alias. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -account=$3 -malias=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ACCOUNT ALIAS' -is_format_valid 'user' 'domain' 'account' 'malias' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') -if [ -z "$(echo $aliases | grep -w $malias)" ]; then - echo "Error: alias $malias doesn't exist" - log_event "$E_NOTEXIST $ARGUMENTS" - exit $E_NOTEXIST -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - sed -i "/^$malias@$domain_idn:$account/d" \ - $HOMEDIR/$user/conf/mail/$domain/aliases -fi - -aliases=$(echo "$aliases" |\ - sed "s/,/\n/g"|\ - sed "s/^$malias$//g"|\ - sed "/^$/d"|\ - sed ':a;N;$!ba;s/\n/,/g') - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS' "$aliases" - -# Logging -log_history "deleted alias $malias on $account@$domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-mail-account-autoreply b/bin/v-delete-mail-account-autoreply deleted file mode 100755 index d4cb02133..000000000 --- a/bin/v-delete-mail-account-autoreply +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# info: delete mail account autoreply message -# options: USER DOMAIN ACCOUNT ALIAS -# -# The function delete email account autoreply. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -account=$3 -malias=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ACCOUNT' -is_format_valid 'user' 'domain' 'account' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -is_object_value_exist "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting exim autoreply message -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - rm -f $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Deleting autoreply message -rm -f $USER_DATA/mail/$domain/$account@$domain.msg - -# Update config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' 'no' - -# Logging -log_history "$ARGUMENTS" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-mail-account-forward b/bin/v-delete-mail-account-forward deleted file mode 100755 index bb2096514..000000000 --- a/bin/v-delete-mail-account-forward +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -# info: delete mail account forward -# options: USER DOMAIN ACCOUNT EMAIL -# -# The function add delete email account forward address. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -account=$3 -forward=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ACCOUNT FORWARD' -is_format_valid 'user' 'domain' 'account' 'forward' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD') -if [ -z "$(echo $fwd | grep -w $forward)" ]; then - check_result $E_NOTEXIST "forward $forward doesn't exist" -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Define new fwd string -fwd=$(echo "$fwd" |\ - sed "s/,/\n/g"|\ - sed "s/^$forward$//g"|\ - sed "/^$/d"|\ - sed ':a;N;$!ba;s/\n/,/g') - -# Deleting exim forward -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - sed -i "/^$account@$domain_idn:/ d" $HOMEDIR/$user/conf/mail/$domain/aliases - echo "$account@$domain_idn:$fwd" >> $HOMEDIR/$user/conf/mail/$domain/aliases -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD' "$fwd" - -# Logging -log_history "deleted $forward forward on $account@$domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-mail-account-fwd-only b/bin/v-delete-mail-account-fwd-only deleted file mode 100755 index 820164ed8..000000000 --- a/bin/v-delete-mail-account-fwd-only +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# info: delete mail account forward-only flag -# options: USER DOMAIN ACCOUNT -# -# The function deletes fwd-only flag - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -account=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ACCOUNT' -is_format_valid 'user' 'domain' 'account' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting account from fwd_only -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - sed -i "/^$account$/d" $HOMEDIR/$user/conf/mail/$domain/fwd_only -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD_ONLY' '' - -# Logging -log_history "deleted fwd_only flag for $account@$domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-mail-domain b/bin/v-delete-mail-domain deleted file mode 100755 index ee727aa96..000000000 --- a/bin/v-delete-mail-domain +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -# info: delete mail domain -# options: USER DOMAIN -# -# The function for deleting MAIL domain. By deleting it all accounts will -# also be deleted. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get domain values -get_domain_values 'mail' -accounts=$(wc -l $USER_DATA/mail/$domain.conf|cut -f 1 -d ' ') - -# Deleting exim configuration files -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - rm -f /etc/$MAIL_SYSTEM/domains/$domain_idn - rm -rf $HOMEDIR/$user/conf/mail/$domain - rm -rf $HOMEDIR/$user/mail/$domain_idn -fi - -# Deleting dkim dns record -if [ "$DKIM" = 'yes' ] && [ -e "$USER_DATA/dns/$domain.conf" ]; then - records=$($BIN/v-list-dns-records $user $domain plain) - dkim_records=$(echo "$records" |grep -w '_domainkey' |cut -f 1) - for id in $dkim_records; do - $BIN/v-delete-dns-record $user $domain $id - done -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Delete domain config -sed -i "/DOMAIN='$domain'/ d" $USER_DATA/mail.conf -rm -f $USER_DATA/mail/$domain.conf -rm -f $USER_DATA/mail/$domain.pem -rm -f $USER_DATA/mail/$domain.pub -rm -f $USER_DATA/mail/*@$domain.msg - -# Decreasing domain value -decrease_user_value "$user" '$U_MAIL_DOMAINS' -if [ "$DKIM" = 'yes' ]; then - decrease_user_value "$user" '$U_MAIL_DKMI' -fi -decrease_user_value "$user" '$U_MAIL_ACCOUNTS' "$accounts" - -# Logging -log_history "deleted mail domain $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-mail-domain-antispam b/bin/v-delete-mail-domain-antispam deleted file mode 100755 index 455ed9caa..000000000 --- a/bin/v-delete-mail-domain-antispam +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# info: delete mail domain antispam support -# options: USER DOMAIN -# -# The function disable spamassasin for incoming emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_exist 'mail' 'DOMAIN' "$domain" '$ANTISPAM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Delete antispam flag -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - rm -f $HOMEDIR/$user/conf/mail/$domain/antispam -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Delete antispam in config -update_object_value 'mail' 'DOMAIN' "$domain" '$ANTISPAM' 'no' - -# Logging -log_history "disabled antispam support for $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-mail-domain-antivirus b/bin/v-delete-mail-domain-antivirus deleted file mode 100755 index 312120f77..000000000 --- a/bin/v-delete-mail-domain-antivirus +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# info: delete mail domain antivirus support -# options: USER DOMAIN -# -# The function disables clamav scan for incoming emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_exist 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Delete antivirus flag -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - rm -f $HOMEDIR/$user/conf/mail/$domain/antivirus -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Delete antivirus in config -update_object_value 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' 'no' - -# Logging -log_history "disabled antivirus support on $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-mail-domain-catchall b/bin/v-delete-mail-domain-catchall deleted file mode 100755 index 7a30175d0..000000000 --- a/bin/v-delete-mail-domain-catchall +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -# info: delete mail domain catchall email -# options: USER DOMAIN -# -# The function disables mail domain cathcall. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_exist 'mail' 'DOMAIN' "$domain" '$CATCHALL' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Delete cathcall alias -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - sed -i "/*@$domain_idn:/d" $HOMEDIR/$user/conf/mail/$domain/aliases -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Delete catchall in config -update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' '' - -# Logging -log_history "deleted catchall email on $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-mail-domain-dkim b/bin/v-delete-mail-domain-dkim deleted file mode 100755 index f11e48d4f..000000000 --- a/bin/v-delete-mail-domain-dkim +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# info: delete mail domain dkim support -# options: USER DOMAIN [DKIM_SIZE] -# -# The function delete DKIM domain pem. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_exist 'mail' 'DOMAIN' "$domain" '$DKIM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting dkim -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - rm -f $USER_DATA/mail/$domain.pem - rm -f $USER_DATA/mail/$domain.pub - rm -f $HOMEDIR/$user/conf/mail/$domain/dkim.pem -fi - -# Deleting dns record -if [ ! -z "$DNS_SYSTEM" ] && [ -e "$USER_DATA/dns/$domain.conf" ]; then - records=$($BIN/v-list-dns-records $user $domain plain) - dkim_records=$(echo "$records" |grep -w '_domainkey' | cut -f 1 -d ' ') - for id in $dkim_records; do - $BIN/v-delete-dns-record $user $domain $id - done -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updatoing config -update_object_value 'mail' 'DOMAIN' "$domain" '$DKIM' 'no' -decrease_user_value "$user" '$U_MAIL_DKIM' - -# Logging -log_history "disabled DKIM support on $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-mail-domains b/bin/v-delete-mail-domains deleted file mode 100755 index e734f8449..000000000 --- a/bin/v-delete-mail-domains +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# info: delete mail domains -# options: USER -# -# The function for deleting all users mail domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting delete loop -for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-delete-mail-domain "$user" "$domain" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-remote-dns-domain b/bin/v-delete-remote-dns-domain deleted file mode 100755 index bd8f46dd5..000000000 --- a/bin/v-delete-remote-dns-domain +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# info: delete remote dns domain -# options: USER DOMAIN -# -# The function synchronize dns with the remote server. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/remote.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER' -is_procces_running -remote_dns_health_check - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting cluster loop -IFS=$'\n' -for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do - - # Parsing remote host parameters - eval $cluster - - # Syncing domain - cluster_cmd v-delete-dns-domain $DNS_USER $domain 'yes' - rc=$? - if [ "$rc" -ne 0 ] && [ $rc -ne 3 ]; then - check_result $rc "$HOST connection failed (sync)" $E_CONNECT - fi - -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating pipe -pipe="$VESTA/data/queue/dns-cluster.pipe" -str=$(grep -n "$SCRIPT $1 $2$" $pipe | cut -f1 -d: | head -n1) -if [ ! -z "$str" ]; then - sed -i "$str d" $pipe -fi - -exit diff --git a/bin/v-delete-remote-dns-domains b/bin/v-delete-remote-dns-domains deleted file mode 100755 index 3c3b8fd3d..000000000 --- a/bin/v-delete-remote-dns-domains +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash -# info: delete remote dns domains -# options: [HOST] -# The function deletes remote dns domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -host=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/remote.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER' -is_procces_running -remote_dns_health_check - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -IFS=$'\n' - -if [ -z $host ]; then - hosts=$(cat $VESTA/conf/dns-cluster.conf) -else - hosts=$(grep "HOST='$host'" $VESTA/conf/dns-cluster.conf) -fi - -# Starting cluster loop -for cluster in $hosts; do - - # Parsing remote host parameters - eval $cluster - - # Deleting source records - cluster_cmd v-delete-dns-domains-src $DNS_USER $HOSTNAME 'no' - check_result $? "$HOST connection failed (cleanup)" $E_CONNECT - - # Rebuilding dns zones - $send_cmd v-rebuild-dns-domains $DNS_USER 'yes' - check_result $? "$HOST connection failed (rebuild)" $E_CONNECT - -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating pipe -pipe="$VESTA/data/queue/dns-cluster.pipe" -str=$(grep -n "$SCRIPT $1 $2$" $pipe | cut -f1 -d: | head -n1) -if [ ! -z "$str" ]; then - sed -i "$str d" $pipe -fi - -exit diff --git a/bin/v-delete-remote-dns-host b/bin/v-delete-remote-dns-host deleted file mode 100755 index e65867390..000000000 --- a/bin/v-delete-remote-dns-host +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# info: delete remote dns host -# options: HOST -# -# The function for deleting the remote dns host from vesta configuration. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -host=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/remote.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'HOST' -is_format_valid 'host' -is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER' -is_object_valid "../../conf/dns-cluster" 'HOST' "$host" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting remote domains -$BIN/v-delete-remote-dns-domains $host >>/dev/null 2>&1 - -# Deleting server -sed -i "/HOST='$host' /d" $VESTA/conf/dns-cluster.conf - -# Deleting DNS_CLUSTER key -check_cluster=$(grep HOST $VESTA/conf/dns-cluster.conf |wc -l) -if [ "$check_cluster" -eq '0' ]; then - rm -f $VESTA/conf/dns-cluster.conf - sed -i "/DNS_CLUSTER=/d" $VESTA/conf/vesta.conf - - # Delete cron job - cmd="sudo /usr/local/vesta/bin/v-update-sys-queue dns-cluster" - check_cron=$(grep "$cmd" $VESTA/data/users/admin/cron.conf 2> /dev/null) - if [ ! -z "$check_cron" ]; then - eval $check_cron - $BIN/v-delete-cron-job admin "$JOB" - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "deleted remote dns server $host" '' 'admin' -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-remote-dns-record b/bin/v-delete-remote-dns-record deleted file mode 100755 index a4732a2d4..000000000 --- a/bin/v-delete-remote-dns-record +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -# info: delete remote dns domain record -# options: USER DOMAIN ID -# -# The function synchronize dns with the remote server. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -id=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/remote.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ID' -is_format_valid 'user' 'domain' 'id' -is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER' -is_procces_running -remote_dns_health_check - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - - -# Starting cluster loop -IFS=$'\n' -for cluster in $(cat $VESTA/conf/dns-cluster.conf); do - - # Parsing remote host parameters - eval $cluster - - # Syncing serial - str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf) - cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'domain' 'no' - check_result $? "$HOST connection failed (soa sync)" $E_CONNECT - - # Sync domain - cluster_cmd v-delete-dns-record $DNS_USER $domain $id 'no' - #check_result $? "$HOST connection failed (delete)" $E_CONNECT - - # Rebuilding dns zone - cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no' - check_result $? "$HOST connection failed (rebuild)" $E_CONNECT - -done - - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating pipe -pipe="$VESTA/data/queue/dns-cluster.pipe" -str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1) -if [ ! -z "$str" ]; then - sed -i "$str d" $pipe -fi - -exit diff --git a/bin/v-delete-sys-firewall b/bin/v-delete-sys-firewall deleted file mode 100755 index 75b787945..000000000 --- a/bin/v-delete-sys-firewall +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# info: delete system firewall -# options: NONE -# -# The script disables firewall support - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -if [ -z "$FIREWALL_SYSTEM" ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Stopping firewall -$BIN/v-stop-firewall - -# Updating FIREWALL_SYSTEM value -if [ -z "$(grep FIREWALL_SYSTEM $VESTA/conf/vesta.conf)" ]; then - echo "FIREWALL_SYSTEM=''" >> $VESTA/conf/vesta.conf -else - sed -i "s/FIREWALL_SYSTEM=.*/FIREWALL_SYSTEM=''/g" $VESTA/conf/vesta.conf -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-sys-ip b/bin/v-delete-sys-ip deleted file mode 100755 index 9692cc8cf..000000000 --- a/bin/v-delete-sys-ip +++ /dev/null @@ -1,149 +0,0 @@ -#!/bin/bash -# info: delete system ip -# options: IP -# -# The function for deleting a system ip. It does not allow to delete first ip -# on interface and do not allow to delete ip which is used by a web domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -ip=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'IP' -is_format_valid 'ip' -is_ip_valid "$ip" -is_ip_key_empty '$U_WEB_DOMAINS' -is_ip_key_empty '$U_SYS_USERS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Import ip variables -source $VESTA/data/ips/$ip -cidr=$(convert_netmask $NETMASK) - -# Checking main ip on the interface -interface=$(/sbin/ip addr | grep "$ip/$cidr" | awk '{print $NF}') -if [ ! -z "$interface" ] && [ -z "$(echo $interface |cut -s -f2 -d :)" ]; then - echo "Error: can't delete main IP address" - log_event "$E_FORBIDEN" "$ARGUMENTS" - exit $E_FORBIDEN -fi - -# Deleting system ip -if [ ! -z "$interface" ]; then - /sbin/ip addr del $ip/$cidr dev $INTERFACE - if [ "$?" -ne 0 ]; then - echo "Error: can't delete system ip" - log_event "$E_FORBIDEN" "$ARGUMENTS" - exit $E_FORBIDEN - fi -fi - -# Deleting startup conf on RHEL/CentOS/Fedora -if [ -e "/etc/sysconfig/network-scripts/ifcfg-$interface" ]; then - rm -f /etc/sysconfig/network-scripts/ifcfg-$interface -fi - -# Deleting startup conf on Debian/Ubuntu -if [ -e "/etc/network/interfaces" ]; then - ip_str=$(grep -n $ip$ /etc/network/interfaces |cut -f1 -d:) - if [ ! -z "$ip_str" ]; then - first_str=$((ip_str - 3)) - last_str=$((ip_str + 1)) - sed -i "$first_str,$last_str d" /etc/network/interfaces - fi -fi - -# Deleting vesta ip -rm -f $VESTA/data/ips/$ip - -# Deleting web config -if [ ! -z "$WEB_SYSTEM" ]; then - rm -f /etc/$WEB_SYSTEM/conf.d/$ip.conf -fi - -# Deleting proxy config -if [ ! -z "$PROXY_SYSTEM" ]; then - rm -f /etc/$PROXY_SYSTEM/conf.d/$ip.conf - - # mod_extract_forwarded - fw_conf="/etc/$WEB_SYSTEM/conf.d/mod_extract_forwarded.conf" - if [ -e "$fw_conf" ]; then - ips=$(grep 'MEFaccept 127.0.0.1' $fw_conf) - new_ips=$(echo "$ips" | sed "s/$ip//" ) - sed -i "s/$ips/$new_ips/g" $fw_conf - fi - - # mod_rpaf - rpaf_conf="/etc/$WEB_SYSTEM/mods-enabled/rpaf.conf" - if [ -e "$rpaf_conf" ]; then - ips=$(grep RPAFproxy_ips $rpaf_conf) - new_ips=$(echo "$rpaf_str" | sed "s/$ip//") - sed -i "s/$ips/$new_ips/g" $rpaf_conf - fi - - #mod_remoteip - remoteip_conf="/etc/$WEB_SYSTEM/mods-enabled/remoteip.conf" - if [ -e "$remoteip_conf" ]; then - sed -i "s/RemoteIPInternalProxy $ip//g" $remoteip_conf - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating user conf -if [ ! -z "$OWNER" ]; then - decrease_user_value "$OWNER" '$IP_OWNED' -fi - -if [ "$OWNER" = 'admin' ]; then - if [ "$STATUS" = 'shared' ]; then - for user in $(ls $VESTA/data/users/); do - decrease_user_value "$user" '$IP_AVAIL' - done - fi -else - decrease_user_value "$OWNER" '$IP_AVAIL' -fi - -# Restarting web server -$BIN/v-restart-web -check_result $? "Web restart failed" >/dev/null - -# Restarting proxy server -if [ ! -z "$PROXY_SYSTEM" ]; then - $BIN/v-restart-proxy - check_result $? "Proxy restart failed" >/dev/null -fi - -# Restarting firewall -if [ ! -z "$FIREWALL_SYSTEM" ]; then - $BIN/v-update-firewall -fi - -# Logging -log_history "deleted system ip address $ip" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-sys-mail-ssl b/bin/v-delete-sys-mail-ssl deleted file mode 100755 index 06dab82ba..000000000 --- a/bin/v-delete-sys-mail-ssl +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -# info: delete sys vesta user ssl certificate -# options: NONE -# -# The script disables user domain ssl synchronization - - -#----------------------------------------------------------# -# Variable & Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -vst_crt="$VESTA/ssl/certificate.crt" -vst_key="$VESTA/ssl/certificate.key" - -# Updating mail certificate -case $MAIL_SYSTEM in - exim) conf='/etc/exim/exim.conf';; - exim4) conf='/etc/exim4/exim4.conf.template';; -esac -if [ -e "$conf" ]; then - sed -e "s|^tls_certificate.*|tls_certificate = $vst_crt|" \ - -e "s|^tls_privatekey.*|tls_privatekey = $vst_key|" -i $conf -fi - -# Updating imap certificate -conf="/etc/dovecot/conf.d/10-ssl.conf" -if [ ! -z "$IMAP_SYSTEM" ] && [ -e "$conf" ]; then - sed -e "s|ssl_cert.*|ssl_cert = <$vst_crt|" \ - -e "s|ssl_key.*|ssl_key = <$vst_key|" -i $conf -fi - -# Moving old certificates -if [ -e "$VESTA/ssl/mail.crt" ]; then - mv -f $VESTA/ssl/mail.crt $VESTA/ssl/mail.crt.old -fi -if [ -e "VESTA/ssl/mail.key" ]; then - mv $VESTA/ssl/mail.key VESTA/ssl/mail.key.old -fi - -# Updating vesta.conf value -sed -i "/MAIL_CERTIFICATE=/ d" $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting services -if [ "$restart" != 'no' ]; then - if [ ! -z "$MAIL_SYSTEM" ]; then - $BIN/v-restart-service $MAIL_SYSTEM - fi - if [ ! -z "$IMAP_SYSTEM" ]; then - $BIN/v-restart-service $IMAP_SYSTEM - fi -fi - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-sys-quota b/bin/v-delete-sys-quota deleted file mode 100755 index 4b8913bfe..000000000 --- a/bin/v-delete-sys-quota +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -# info: delete system quota -# options: NONE -# -# The script disables filesystem quota on /home partition - - -#----------------------------------------------------------# -# Variable & Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting group and user quota on /home partition -mnt=$(df -P /home | awk '{print $6}' | tail -n1) -lnr=$(cat -n /etc/fstab | awk '{print $1,$3}' | grep "$mnt$" | cut -f 1 -d ' ') -opt=$(sed -n ${lnr}p /etc/fstab | awk '{print $4}') -fnd='usrquota\|grpquota\|usrjquota=\|grpjquota=\|jqfmt=' -if [ ! -z "$(echo $opt | grep $fnd)" ]; then - rep=$(echo $(echo $opt | tr ',' '\n' | grep -v $fnd) | tr ' ' ',') - sed -i "$lnr s/$opt/$rep/" /etc/fstab - mount -o remount $mnt -fi - -# Disabling group and user quota -quotaoff=$(which --skip-alias --skip-functions quotaoff 2>/dev/null) -if [ $? -eq 0 ]; then - if [ ! -z "$(quotaon -pa | grep " $mnt " | grep 'user\|group' | grep 'is on')" ]; then - $quotaoff $mnt - fi -fi - -# Deleting v1 + v2 group and user quota index -for idx in $(echo 'quota.user quota.group aquota.user aquota.group'); do - [ -e "$mnt/$idx" ] && rm -f $mnt/$idx -done - -# Deleting cron job -rm -f /etc/cron.daily/quotacheck - -# Updating vesta.conf value -if [ -z "$(grep DISK_QUOTA $VESTA/conf/vesta.conf)" ]; then - echo "DISK_QUOTA='no'" >> $VESTA/conf/vesta.conf -else - sed -i "s/DISK_QUOTA=.*/DISK_QUOTA='no'/g" $VESTA/conf/vesta.conf -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-sys-sftp-jail b/bin/v-delete-sys-sftp-jail deleted file mode 100755 index 464f147fb..000000000 --- a/bin/v-delete-sys-sftp-jail +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -# info: delete system sftp jail -# options: NONE -# -# The script disables sftp jailed environment - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system environment as we run this script -# mostly by cron which do not read it by itself -source /etc/profile - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -#if [ -z "$SFTPJAIL_KEY" ]; then -# exit -#fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking users -for user in $(grep "$HOMEDIR" /etc/passwd |cut -f 1 -d:); do - $BIN/v-delete-user-sftp-jail $user -done - -# Checking sshd directives -config='/etc/ssh/sshd_config' -sftp_n=$(grep -n "Subsystem.*sftp" $config |grep -v internal |grep ":#") -sftp_i=$(grep -n "Subsystem.*sftp" $config |grep internal |grep -v ":#") - -# Backing up config -cp $config $config.bak-$(date +%s) - -# Enabling normal sftp -if [ ! -z "$sftp_n" ]; then - fline=$(echo $sftp_n |cut -f 1 -d :) - sed -i "${fline}s/#Subsystem/Subsystem sftp/" $config - restart='yes' -fi - -# Disabling jailed sftp -if [ ! -z "$sftp_i" ]; then - fline=$(echo $sftp_i |cut -f 1 -d :) - lline=$((fline + 5)) - sed -i "${fline},${lline}d" $config - restart='yes' -fi - -# Validating opensshd config -if [ "$restart" = 'yes' ]; then - subj="OpenSSH restart failed" - email=$(grep CONTACT $VESTA/data/users/admin/user.conf |cut -f 2 -d \') - /usr/sbin/sshd -t >/dev/null 2>&1 - if [ "$?" -ne 0 ]; then - mail_text="OpenSSH can not be restarted. Please check config: - \n\n$(/usr/sbin/sshd -t)" - echo -e "$mail_text" |$SENDMAIL -s "$subj" $email - else - service ssh restart >/dev/null 2>&1 - service sshd restart >/dev/null 2>&1 - fi -fi - -# Deleting v-add-sys-sftp-jail from startup -sed -i "/v-add-sys-sftp-jail/d" /etc/rc.local 2>/dev/null - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-sys-vesta-ssl b/bin/v-delete-sys-vesta-ssl deleted file mode 100755 index e90f32b9b..000000000 --- a/bin/v-delete-sys-vesta-ssl +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# info: delete sys vesta user ssl certificate -# options: NONE -# -# The script disables user domain ssl synchronization - - -#----------------------------------------------------------# -# Variable & Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Updating vesta.conf value -sed -i "/VESTA_CERTIFICATE=/ d" $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-user b/bin/v-delete-user deleted file mode 100755 index c452f0a0e..000000000 --- a/bin/v-delete-user +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash -# info: delete user -# options: USER -# -# This function deletes a certain user and all his resources such as domains, -# databases, cron jobs, etc. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -restart=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/db.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -if [ "$user" = 'admin' ]; then - exit -fi - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting web domains -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-web-domains $user $restart - $BIN/v-delete-web-domains $user $restart - check_result "$?" "web domain deletion failed" -fi - -# Deleting dns domains -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-dns-domains $user $restart - $BIN/v-delete-dns-domains $user $restart - check_result "$?" "dns domain deletion failed" -fi - -# Deleting mail domains -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-mail-domains $user - $BIN/v-delete-mail-domains $user - check_result "$?" "mail domain deletion failed" -fi - -# Deleting databases -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-databases $user - $BIN/v-delete-databases $user - check_result "$?" "database deletion failed" -fi - -# Releasing user ips -$BIN/v-delete-user-ips "$user" -check_result "$?" "user ip release failed" - -# Deleteing user pipes -sed -i "/ $user$/d" $VESTA/data/queue/disk.pipe -sed -i "/ $user$/d" $VESTA/data/queue/traffic.pipe - -# Deleting sftp jail -if [ ! -z "$SFTPJAIL_KEY" ]; then - $BIN/v-delete-user-sftp-jail $user -fi - -# Deleting system user -/usr/sbin/userdel -f $user >> /dev/null 2>&1 -if [ $? -ne 0 ]; then - sed -i "/^$user:/d" /etc/passwd - sed -i "/^$user:/d" /etc/shadow -fi - -/usr/sbin/groupdel $user >> /dev/null 2>&1 -if [ $? -ne 0 ]; then - sed -i "/^$user:/d" /etc/group -fi - -# Deleting user directories -chattr -i $HOMEDIR/$user/conf -rm -rf $HOMEDIR/$user -rm -f /var/spool/mail/$user -rm -f /var/spool/cron/$user -rm -f /var/spool/cron/crontabs/$user -rm -rf $USER_DATA - -# Updating admin counter -if [ "$user" != 'admin' ]; then - decrease_user_value 'admin' '$U_USERS' -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "deleted system user $user" '' 'admin' -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-user-backup b/bin/v-delete-user-backup deleted file mode 100755 index 0166be0a9..000000000 --- a/bin/v-delete-user-backup +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# info: delete user backup -# options: USER BACKUP -# -# The function deletes user backup. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -backup=$(echo $2| cut -f 2 -d \.) - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER BACKUP' -is_format_valid 'user' 'backup' -is_system_enabled "$BACKUP_SYSTEM" 'BACKUP_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'backup' 'BACKUP' "$2" - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting backup -rm -f $BACKUP/$2 -sed -i "/BACKUP='$2' /d" $USER_DATA/backup.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update counter -U_BACKUPS=$(ls $BACKUP/|grep "^$user."|wc -l) -update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS" - -# Logging -log_history "deleted backup archive $backup" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-user-backup-exclusions b/bin/v-delete-user-backup-exclusions deleted file mode 100755 index 0b1a1e330..000000000 --- a/bin/v-delete-user-backup-exclusions +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -# info: delete backup exclusion -# options: USER [SYSTEM] -# -# The function for deleting backup exclusion - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -system=$(echo $2 | tr '[:lower:]' '[:upper:]') - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [SYSTEM]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Delete system exclusion -if [ -z "$system" ]; then - WEB='' - DNS='' - MAIL='' - DB='' - CRON='' - USER='' -else - touch $USER_DATA/backup-excludes.conf - source $USER_DATA/backup-excludes.conf - case $system in - WEB) WEB='';; - DNS) DNS='';; - MAIL) MAIL='';; - DB) DB='';; - CRON) CRON='';; - USER) USER='';; - esac -fi - -# Updating exlusion list -echo "WEB='$WEB'" > $USER_DATA/backup-excludes.conf -echo "DNS='$DNS'" >> $USER_DATA/backup-excludes.conf -echo "MAIL='$MAIL'" >> $USER_DATA/backup-excludes.conf -echo "DB='$DB'" >> $USER_DATA/backup-excludes.conf -echo "CRON='$DB'" >> $USER_DATA/backup-excludes.conf -echo "USER='$USER'" >> $USER_DATA/backup-excludes.conf -chmod 660 $USER_DATA/backup-excludes.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -if [ -z "$system" ]; then - log_history "deleted all exlusions" -else - log_history "deleted $system exlusion" -fi -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-user-favourites b/bin/v-delete-user-favourites deleted file mode 100755 index 28a8dd971..000000000 --- a/bin/v-delete-user-favourites +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash -# info: deleting user favourites -# options: USER SYSTEM OBJECT -# -# The function deletes object from users favourites - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -system=$(echo "$2" |tr '[:lower:]' '[:upper:]') -object=$3 -email=$3 -id=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER SYSTEM OBJECT' -case $system in - MAIL_ACC) is_format_valid 'email' ;; - CRON) is_format_valid 'id' ;; - DNS_REC) is_format_valid 'id' ;; - *) is_format_valid 'object' -esac - -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - -# Checking system -case $system in - USER) check='ok' ;; - WEB) check='ok' ;; - DNS) check='ok' ;; - DNS_REC) check='ok' ;; - MAIL) check='ok' ;; - MAIL_ACC) check='ok' ;; - DB) check='ok' ;; - CRON) check='ok' ;; - BACKUP) check='ok' ;; - IP) check='ok' ;; - PACKAGE) check='ok' ;; - FIREWALL) check='ok' ;; - *) check_args '2' '0' 'USER SYSTEM OBJECT' -esac - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Flushing vars -USER='' -WEB='' -DNS='' -DNS_REC='' -MAIL='' -MAIL_ACC='' -DB='' -CRON='' -BACKUP='' -IP='' -PACKAGE='' -FIREWALL='' - -# Creating config just in case -touch $USER_DATA/favourites.conf - -# Reading current values -source $USER_DATA/favourites.conf - -# Assigning current system value -eval value=\$$system - -# Checking if object is new -check_fav=$(echo "$value" |tr ',' '\n'| grep "^$object$") -if [ -z "$check_fav" ]; then - exit 0 -fi - -# Deleting object from favorites -value=$(echo "$value" |\ - sed -e "s/,/\n/g"|\ - sed -e "s/^$object$//g"|\ - sed -e "/^$/d"|\ - sed -e ':a;N;$!ba;s/\n/,/g') - -# Updating sytem -eval $system=$value - -# Updating user favorites -echo "USER='$USER' -WEB='$WEB' -DNS='$DNS' -DNS_REC='$DNS_REC' -MAIL='$MAIL' -MAIL_ACC='$MAIL_ACC' -DB='$DB' -CRON='$CRON' -BACKUP='$BACKUP' -IP='$IP' -PACKAGE='$PACKAGE' -FIREWALL='$FIREWALL'" > $USER_DATA/favourites.conf - -# Changing file permission -chmod 640 $USER_DATA/favourites.conf - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "deleted starred $object from $system listing" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-user-ips b/bin/v-delete-user-ips deleted file mode 100755 index 7f8e32241..000000000 --- a/bin/v-delete-user-ips +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# info: delete user ips -# options: USER -# -# The function deletes all user's ip addresses. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -if [ "$user" = 'admin' ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing user ips -ip_list=$(grep -H "OWNER='$user'" $VESTA/data/ips/* | cut -f 1 -d:) - -for ip in $ip_list; do - ip=$(basename $ip) - - # Checking webdomains and users - is_ip_key_empty '$U_WEB_DOMAINS' - is_ip_key_empty '$U_SYS_USERS' - - # Assig ip to main account - update_ip_value '$OWNER' 'admin' - update_ip_value '$STATUS' 'dedicated' - increase_user_value 'admin' '$IP_OWNED' - increase_user_value 'admin' '$IP_AVAIL' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-user-notification b/bin/v-delete-user-notification deleted file mode 100755 index 6b223e0b4..000000000 --- a/bin/v-delete-user-notification +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -# info: delete user notification -# options: USER NOTIFICATION -# -# The function deletes user notification. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -nid=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER NOTIFICATION' -is_format_valid 'user' 'nid' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting notification -sed -i "/NID='$nid' /d" $USER_DATA/notifications.conf 2>/dev/null - -# Checking last notification -if [ -e "$USER_DATA/notifications.conf" ]; then - if [ -z "$(grep NID= $USER_DATA/notifications.conf)" ]; then - notice='no' - fi - if [ -z "$(grep "ACK='no'" $USER_DATA/notifications.conf)" ]; then - notice='no' - fi -else - notice='no' -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating notification counter -if [ "$notice" = 'no' ]; then - if [ -z "$(grep NOTIFICATIONS $USER_DATA/user.conf)" ]; then - sed -i "s/^TIME/NOTIFICATIONS='no'\nTIME/g" $USER_DATA/user.conf - else - update_user_value "$user" '$NOTIFICATIONS' "no" - fi -fi - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-user-package b/bin/v-delete-user-package deleted file mode 100755 index dbd75a861..000000000 --- a/bin/v-delete-user-package +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# info: delete user package -# options: PACKAGE -# -# The function for deleting user package. It does not allow to delete package -# if it is in use. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -package=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Functions -is_package_in_use() { - check_package=$(grep "PACKAGE='$package'" $USER_DATA/*/user.conf) - if [ ! -z "$check_package" ]; then - echo "Error: package $package is in use" - log_event "$E_INUSE" "$ARGUMENTS" - exit $E_INUSE - fi -} - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'PACKAGE' -is_format_valid 'package' -is_package_valid -is_package_in_use - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting user package -rm -f $VESTA/data/packages/$package.pkg - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -log_history "deleted user package $package" '' 'admin' -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-user-sftp-jail b/bin/v-delete-user-sftp-jail deleted file mode 100755 index 7fc863f48..000000000 --- a/bin/v-delete-user-sftp-jail +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# info: delete user sftp jail -# options: USER -# -# The script disables sftp jailed environment for USER - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -user_str=$(grep "^$user:" /etc/passwd) -if [ -z "$user_str" ]; then - exit -fi - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining user homedir -home="$(echo $user_str |cut -f 6 -d :)" - -# Unmounting home directory -mount_dir=$(mount |grep /chroot/$user/ |awk '{print $3}') -if [ ! -z "$mount_dir" ]; then - umount -f $mount_dir 2>/dev/null - if [ $? -ne 0 ]; then - gpasswd -d $user sftp-only >/dev/null 2>&1 - exit 1 - fi -fi - -# Deleting chroot dir -rmdir $mount_dir 2>/dev/null -rm -rf /chroot/$user - -# Deleting user from sftp group -gpasswd -d $user sftp-only >/dev/null 2>&1 - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -#log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-vesta-softaculous b/bin/v-delete-vesta-softaculous deleted file mode 100755 index c15d68c1a..000000000 --- a/bin/v-delete-vesta-softaculous +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# info: delete vesta softaculous -# options: NONE -# -# The script disables softaculous plugin - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -if [ "$SOFTACULOUS" = 'no' ] || [ -z "$SOFTACULOUS" ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting symlink -if [ -e "$VESTA/web/softaculous" ]; then - mkdir -p $VESTA/disabled_plugins - mv $VESTA/web/softaculous $VESTA/disabled_plugins -fi - -# Updating SOFTACULOUS value -sed -i "s/SOFTACULOUS.*/SOFTACULOUS='no'/g" \ - $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-web-domain b/bin/v-delete-web-domain deleted file mode 100755 index 529f5d09e..000000000 --- a/bin/v-delete-web-domain +++ /dev/null @@ -1,137 +0,0 @@ -#!/bin/bash -# info: delete web domain -# options: USER DOMAIN -# -# The call of function leads to the removal of domain and all its components -# (statistics, folders contents, ssl certificates, etc.). This operation is -# not fully supported by "undo" function, so the data recovery is possible -# only with a help of reserve copy. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -restart=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting web backend -if [ ! -z "$WEB_BACKEND" ]; then - $BIN/v-delete-web-domain-backend $user $domain $restart -fi - -# Parsing domain values -get_domain_values 'web' -local_ip=$(get_real_ip $IP) - -# Deleting domain from web.conf -sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf - -# Deleting vhost configuration -del_web_config "$WEB_SYSTEM" "$TPL.tpl" - -# Deleting SSL configuration and certificates -if [ "$SSL" = 'yes' ]; then - del_web_config "$WEB_SYSTEM" "$TPL.stpl" - rm -f $HOMEDIR/$user/conf/web/ssl.$domain.* - rm -f $USER_DATA/ssl/$domain.* -fi - -# Deleting proxy -if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.tpl" - if [ "$SSL" = 'yes' ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.stpl" - fi - if [ -e "/etc/$PROXY_SYSTEM/conf.d/01_caching_pool.conf" ]; then - sed -i "/=$domain:/d" /etc/$PROXY_SYSTEM/conf.d/01_caching_pool.conf - fi -fi - -# Deleting web stats -if [ ! -z "$STATS" ] && [ "$STATS" != 'no' ]; then - sed -i "/ $domain$/d" $VESTA/data/queue/webstats.pipe - rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf - rm -f /etc/awstats/$STATS.$domain.conf -fi - -# Deleting ftp users -if [ ! -z "$FTP_USER" ]; then - for ftp_user in ${FTP_USER//:/ }; do - /usr/sbin/userdel $ftp_user >> /dev/null 2>&1 - if [ "$?" != 0 ]; then - sed -i "/^$ftp_user:/d" /etc/passwd - sed -i "/^$ftp_user:/d" /etc/shadow - fi - done -fi - -# Deleting logs -rm -f /var/log/$WEB_SYSTEM/domains/$domain.log* -rm -f /var/log/$WEB_SYSTEM/domains/$domain.bytes -rm -f /var/log/$WEB_SYSTEM/domains/$domain.error* - -# Deleting directory -rm -rf $HOMEDIR/$user/web/$domain - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Decreasing user counters -decrease_ip_value "$local_ip" -decrease_user_value "$user" '$U_WEB_DOMAINS' -if [ "$SSL" = 'yes' ]; then - decrease_user_value "$user" '$U_WEB_SSL' -fi -if [ ! -z "$ALIAS" ]; then - aliases=$(echo $ALIAS | tr ',' '\n' | wc -l ) - decrease_user_value "$user" '$U_WEB_ALIASES' "$aliases" -fi - -# Restarting web server -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -# Restartinh proxy server -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Logging -log_history "deleted web domain $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-web-domain-alias b/bin/v-delete-web-domain-alias deleted file mode 100755 index 45bef00b9..000000000 --- a/bin/v-delete-web-domain-alias +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash -# info: delete web domain alias -# options: USER DOMAIN ALIAS [RESTART] -# -# The function of deleting the alias domain (parked domain). By this call -# default www aliase can be removed as well. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -dom_alias=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN DOM_ALIAS [RESTART]' -is_format_valid 'user' 'domain' 'dom_alias' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -get_domain_values 'web' -if [ -z "$(echo $ALIAS |tr ',' '\n' |grep ^$dom_alias$)" ]; then - check_result $E_NOTEXIST "alias $dom_alias doesn't exist" -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Preparing domain values for the template substitution -local_ip=$(get_real_ip $IP) -ALIAS=$(echo "$ALIAS" |\ - sed -e "s/,/\n/g"|\ - sed -e "s/^$dom_alias$//g"|\ - sed -e "/^$/d"|\ - sed -e ':a;N;$!ba;s/\n/,/g') -prepare_web_domain_values - -# Rebuilding vhost -del_web_config "$WEB_SYSTEM" "$TPL.tpl" -add_web_config "$WEB_SYSTEM" "$TPL.tpl" -if [ "$SSL" = 'yes' ]; then - del_web_config "$WEB_SYSTEM" "$TPL.stpl" - add_web_config "$WEB_SYSTEM" "$TPL.stpl" -fi - -# Rebuilding proxy configuration -if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.tpl" - add_web_config "$PROXY_SYSTEM" "$PROXY.tpl" - if [ "$SSL" = 'yes' ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.stpl" - add_web_config "$PROXY_SYSTEM" "$PROXY.stpl" - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS" -decrease_user_value "$user" '$U_WEB_ALIASES' - -# Restarting web server -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Logging -log_history "deleted alias $dom_alias on $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-web-domain-backend b/bin/v-delete-web-domain-backend deleted file mode 100755 index 935b55bbc..000000000 --- a/bin/v-delete-web-domain-backend +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -# info: deleting web domain backend configuration -# options: USER DOMAIN [RESTART] -# -# The function of deleting the virtualhost backend configuration. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining pool directory -pool=$(find -L /etc/php* -type d \( -name "pool.d" -o -name "*fpm.d" \)) -if [ ! -e "$pool" ]; then - check_result $E_NOTEXIST "php-fpm pool doesn't exist" -fi - -# Defining backend type -backend_type="$domain" -if [ "$WEB_BACKEND_POOL" = 'user' ]; then - backend_type="$user" -fi - -# Checking last webdomain -if [ "$WEB_BACKEND_POOL" = 'user' ]; then - domains=$(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'|wc -l) - if [ "$backend" = "$user" ] && [ "$domains" -gt 1 ]; then - exit - fi -fi - -# Deleting backend -rm -f $pool/$backend_type.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting backend server -$BIN/v-restart-web-backend $restart -check_result $? "Backend restart failed" >/dev/null - -# Logging -log_history "deleting backend support for $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-web-domain-ftp b/bin/v-delete-web-domain-ftp deleted file mode 100755 index 218f4d55f..000000000 --- a/bin/v-delete-web-domain-ftp +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -# info: delete webdomain ftp account -# options: USER DOMAIN FTP_USER -# -# The function deletes additional ftp account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -ftp_user=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN FTP_USER' -is_format_valid 'user' 'domain' 'ftp_user' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -get_domain_values 'web' -if [ -z "$(echo $FTP_USER | tr ':' '\n' | grep ^$ftp_user$)" ]; then - echo "Error: account $ftp_user doesn't exist" - log_event "$E_NOTEXIST" "$ARGUMENTS" - exit $E_NOTEXIST -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting ftp user -/usr/sbin/userdel $ftp_user >> /dev/null 2>&1 -if [ "$?" != 0 ]; then - sed -i "/^$ftp_user:/d" /etc/passwd - sed -i "/^$ftp_user:/d" /etc/shadow -fi - -# Deleting sftp jail -if [ ! -z "$SFTPJAIL_KEY" ]; then - $BINv-delete-user-sftp-jail $ftp_user -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Rebuilding FTP variables -position=$(echo $FTP_USER |tr ':' '\n' |grep -n '' |grep ":$ftp_user$" |\ - cut -f 1 -d:) -ftp_user=$(echo $FTP_USER |tr ':' '\n' |grep -n '' |grep -v "^$position:" |\ - cut -f 2 -d :| sed -e "/^$/d"| sed -e ':a;N;$!ba;s/\n/:/g') -ftp_md5=$(echo $FTP_MD5 |tr ':' '\n' |grep -n '' |grep -v "^$position:" |\ - cut -f 2 -d :| sed -e ':a;N;$!ba;s/\n/:/g') -ftp_path=$(echo $FTP_PATH |tr ':' '\n' |grep -n '' |grep -v "^$position:" |\ - cut -f 2 -d :| sed -e ':a;N;$!ba;s/\n/:/g') - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user" -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5" -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_PATH' "$ftp_path" - -# Logging -log_history "deleted ftp account ${3} for $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-web-domain-httpauth b/bin/v-delete-web-domain-httpauth deleted file mode 100755 index 3fbc85da2..000000000 --- a/bin/v-delete-web-domain-httpauth +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -# info: delete http auth user -# options: USER DOMAIN AUTH_USER [RESTART] -# -# The call is used for deleting http auth user - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -auth_user=$3 -restart=${4-yes} - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Defining htpasswd file -htaccess="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.conf_htaccess" -htpasswd="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.htpasswd" -shtaccess="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.conf_htaccess" -shtpasswd="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.htpasswd" - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN AUTH_USER [RESTART]' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_password_valid -get_domain_values 'web' -if [ -z "$(echo "$AUTH_USER" |tr : '\n' |grep ^$auth_user$)" ]; then - echo "Error: auth user $auth_user doesn't exist" - log_event "$E_NOTEXIST" "$ARGUMENTS" - exit $E_NOTEXIST -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting auth user -sed -i "/^$auth_user:/d" $htpasswd - -# Deleting password protection -if [ "$(echo "$AUTH_USER" |tr : '\n' |wc -l)" -le 1 ]; then - rm -f $htaccess $htpasswd $shtaccess $shtpasswd - restart_required='yes' -fi - -# Restarting web server -if [ "$restart" != 'no' ] && [ "$restart_required" = 'yes' ]; then - $BIN/v-restart-web -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Rebuilding FTP variables -position=$(echo $AUTH_USER |tr ':' '\n' |grep -n '' |grep ":$auth_user$" |\ - cut -f 1 -d:) -auth_user=$(echo $AUTH_USER |tr ':' '\n' |grep -n '' |grep -v "^$position:" |\ - cut -f 2 -d :| sed -e "/^$/d"| sed -e ':a;N;$!ba;s/\n/:/g') -auth_hash=$(echo $AUTH_HASH |tr ':' '\n' |grep -n '' |grep -v "^$position:" |\ - cut -f 2 -d :| sed -e ':a;N;$!ba;s/\n/:/g') - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$AUTH_USER' "$auth_user" -update_object_value 'web' 'DOMAIN' "$domain" '$AUTH_HASH' "$auth_hash" - -# Logging -log_history "changed auth user $httpauth_user password on $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-web-domain-proxy b/bin/v-delete-web-domain-proxy deleted file mode 100755 index 73eeabb73..000000000 --- a/bin/v-delete-web-domain-proxy +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# info: deleting web domain proxy configuration -# options: USER DOMAIN -# -# The function of deleting the virtualhost proxy configuration. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -restart=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$PROXY_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$PROXY' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining domain parameters -get_domain_values 'web' -del_web_config "$PROXY_SYSTEM" "$PROXY.tpl" - -# Checking SSL -if [ "$SSL" = 'yes' ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.stpl" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' '' -update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' '' - -# Restart proxy server -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Logging -log_history "disabled proxy support for $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-web-domain-ssl b/bin/v-delete-web-domain-ssl deleted file mode 100755 index 160b07cce..000000000 --- a/bin/v-delete-web-domain-ssl +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/bash -# info: delete web domain SSL support -# options: USER DOMAIN -# -# The function disable https support and deletes SSL certificates. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -restart=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' - -# Deleting domain -del_web_config "$WEB_SYSTEM" "$TPL.stpl" - -# Checking proxy -if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.stpl" -fi - -# Deleting old certificate -tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d) - -# remove certificate files - do not use wildcard, as this might remove other domains -rm -f $HOMEDIR/$user/conf/web/ssl.$domain.ca -rm -f $HOMEDIR/$user/conf/web/ssl.$domain.crt -rm -f $HOMEDIR/$user/conf/web/ssl.$domain.key -rm -f $HOMEDIR/$user/conf/web/ssl.$domain.pem - -mv $USER_DATA/ssl/$domain.* $tmpdir -chown -R $user:$user $tmpdir - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -if [ ! -z "$LETSENCRYPT" ]; then - update_object_value 'web' 'DOMAIN' "$domain" '$LETSENCRYPT' 'no' -fi -update_object_value 'web' 'DOMAIN' "$domain" '$SSL' 'no' - -# Decreasing domain value -decrease_user_value "$user" '$U_WEB_SSL' - -# Restarting web server -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Logging -log_history "disabled ssl support for $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-web-domain-stats b/bin/v-delete-web-domain-stats deleted file mode 100755 index 33a22dca6..000000000 --- a/bin/v-delete-web-domain-stats +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -# info: delete web domain statistics -# options: USER DOMAIN -# -# The function of deleting site's system of statistics. Its type is -# automatically chooses from client's configuration file. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining statistic type -get_domain_values 'web' - -# Defining statistic dir -stats_dir="$HOMEDIR/$user/web/$domain/stats" - -# Deleting dir content -rm -rf $stats_dir/* - -# Deleting config -rm -f /etc/awstats/$STATS.$domain_idn.conf -rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Deleting pipe command -sed -i "/ $domain$/d" $VESTA/data/queue/webstats.pipe - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$STATS' '' - -# Logging -log_history "disabled web log analyzer for $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-web-domain-stats-user b/bin/v-delete-web-domain-stats-user deleted file mode 100755 index dd7a4f33a..000000000 --- a/bin/v-delete-web-domain-stats-user +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# info: disable webdomain stats authentication support -# options: USER DOMAIN [RESTART] -# -# The function removes authentication of statistics system. If the script is -# called without naming a certain user, all users will be removed. After -# deleting all of them statistics will be accessible for view without an -# authentication. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -restart=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [RESTART]' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS_USER' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining statistic dir -rm -f $HOMEDIR/$user/web/$domain/stats/.htpasswd -rm -f $HOMEDIR/$user/web/$domain/stats/.htaccess - -# Deleting nginx auth config -if [ "$WEB_SYSTEM" = 'nginx' ]; then - conf_dir="$HOMEDIR/$user/conf/web" - rm -f $conf_dir/$domain.auth 2>/dev/null - $BIN/v-restart-web $restart - check_result $? "Web restart failed" >/dev/null -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' '' -update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' '' - - -# Logging -log_history "disabled web stats password protection for $domain" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-delete-web-domains b/bin/v-delete-web-domains deleted file mode 100755 index 8822ab0af..000000000 --- a/bin/v-delete-web-domains +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# info: delete web domains -# options: USER [RESTART] -# -# The function deletes all user's webdomains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -restart=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -is_format_valid 'user' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting delete loop -for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-delete-web-domain "$user" "$domain" 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting web server -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-extract-fs-archive b/bin/v-extract-fs-archive deleted file mode 100755 index 1ea608af9..000000000 --- a/bin/v-extract-fs-archive +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash -# info: archive to directory -# options: USER ARCHIVE DIRECTORY -# -# The function extracts archive into directory on the file system - -user=$1 -src_file=$2 -dst_dir=$3 - -# Checking arguments -if [ -z "$dst_dir" ]; then - echo "Usage: USER ARCHIVE DIRECTORY" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking user homedir -homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) -if [ -z $homedir ]; then - echo "Error: user home directory doesn't exist" - exit 12 -fi - -# Checking source dir -if [ ! -e "$src_file" ]; then - echo "Error: source file $src_file doesn't exist" - exit 3 -fi - -# Checking source path -rpath=$(readlink -f "$src_file") -if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid source path $src_file" - exit 2 -fi - -# Checking destination path -rpath=$(readlink -f "$dst_dir") -if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid destination path $dst_dir" - exit 2 -fi - -# Extracting gziped archive -if [ ! -z "$(echo $src_file |egrep -i '.tgz|.tar.gz')" ]; then - x='yes' - sudo -u $user mkdir -p "$dst_dir" >/dev/null 2>&1 - sudo -u $user tar -xzf "$src_file" -C "$dst_dir" >/dev/null 2>&1 - rc=$? -fi - -# Extracting bziped archive -if [ ! -z "$(echo $src_file |egrep -i '.tbz|.tar.bz')" ]; then - x='yes' - sudo -u $user mkdir -p "$dst_dir" >/dev/null 2>&1 - sudo -u $user tar -xjf "$src_file" -C "$dst_dir" >/dev/null 2>&1 - rc=$? -fi - -# Extracting gziped file -if [ ! -z "$(echo $src_file |grep -i '.gz')" ] && [ -z "$x" ]; then - sudo -u $user mkdir -p "$dst_dir" >/dev/null 2>&1 - sudo -u $user mv "$src_file" "$dst_dir" >/dev/null 2>&1 - sudo -u $user gzip -d "$dst_dir/$(basename $src_file)" >/dev/null 2>&1 - rc=$? -fi - -# Extracting bziped file -if [ ! -z "$(echo $src_file |grep -i '.bz')" ] && [ -z "$x" ]; then - sudo -u $user mkdir -p "$dst_dir" >/dev/null 2>&1 - sudo -u $user mv "$src_file" "$dst_dir"# >/dev/null 2>&1 - sudo -u $user bzip2 -d "$dst_dir/$(basename $src_file)" >/dev/null 2>&1 - rc=$? -fi - -# Extracting ziped archive -if [ ! -z "$(echo $src_file |grep -i '.zip')" ]; then - sudo -u $user mkdir -p "$dst_dir" >/dev/null 2>&1 - sudo -u $user unzip -o "$src_file" -d "$dst_dir" >/dev/null 2>&1 - rc=$? -fi - -# Extracting ziped archive -if [ ! -z "$(echo $src_file |grep -i '.7z')" ]; then - sudo -u $user mkdir -p "$dst_dir" >/dev/null 2>&1 - sudo -u $user mv "$src_file" "$dst_dir" >/dev/null 2>&1 - sudo -u $user p7zip -d "$src_file" >/dev/null 2>&1 - rc=$? -fi - -# Extracting tared archive -if [ ! -z "$(echo $src_file |grep -i '.tar')" ] && [ -z "$x" ]; then - x='yes' - sudo -u $user mkdir -p "$dst_dir" >/dev/null 2>&1 - sudo -u $user tar -xf "$src_file" -C "$dst_dir" >/dev/null 2>&1 - rc=$? -fi - -# Extracting rared archive -if [ ! -z "$(echo $src_file |grep -i '.rar')" ]; then - sudo -u $user mkdir -p "$dst_dir" >/dev/null 2>&1 - sudo -u $user unrar "$src_file" "$dst_dir" >/dev/null 2>&1 - rc=$? -fi - -# Checking result -if [ $rc -ne 0 ]; then - echo "Error: $src_file was not extracted" - exit 3 -fi - -# Exiting -exit diff --git a/bin/v-generate-api-key b/bin/v-generate-api-key deleted file mode 100755 index ba60b92fc..000000000 --- a/bin/v-generate-api-key +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# info: generate api key -# options: none -# -# The function creates a key file in /usr/local/vesta/data/keys/ - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -keygen() -{ - < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo; -} -KEYS='/usr/local/vesta/data/keys/' -HASH=$(keygen) - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ ! -d ${KEYS} ]; then - mkdir ${KEYS} -fi - -if [[ -e ${KEYS}${HASH} ]] ; then - while [[ -e ${KEYS}${HASH} ]] ; do - HASH=$(keygen) - done -fi - -touch ${KEYS}${HASH} -echo ${HASH} - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-generate-password-hash b/bin/v-generate-password-hash deleted file mode 100755 index 78a551fe0..000000000 --- a/bin/v-generate-password-hash +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/local/vesta/php/bin/php - $domain.key 2>/dev/null - -# Generate the CSR -subj="/C=$country/ST=$state/localityName=$city/O=$org" -subj="$subj/organizationalUnitName=$org_unit/commonName=$domain_idn" -subj="$subj/emailAddress=$email" -if [ -z "$aliases" ]; then - openssl req -sha256\ - -new \ - -batch \ - -subj "$subj" \ - -key $domain.key \ - -out $domain.csr #>/dev/null 2>&1 -else - for alias in $(echo $domain,$aliases |tr ',' '\n' |sort -u); do - if [[ "$alias" = *[![:ascii:]]* ]]; then - alias=$(idn -t --quiet -a $alias) - fi - dns_aliases="${dns_aliases}DNS:$alias," - done - dns_aliases=$(echo $dns_aliases |sed "s/,$//") - if [ -e "/etc/ssl/openssl.cnf" ]; then - ssl_conf='/etc/ssl/openssl.cnf' - else - ssl_conf="/etc/pki/tls/openssl.cnf" - fi - - openssl req -sha256\ - -new \ - -batch \ - -subj "$subj" \ - -key $domain.key \ - -reqexts SAN \ - -config <(cat $ssl_conf \ - <(printf "[SAN]\nsubjectAltName=$dns_aliases")) \ - -out $domain.csr >/dev/null 2>&1 -fi - -# Generate the cert 1 year -openssl x509 -req -sha256 \ - -days $DAYS \ - -in $domain.csr \ - -signkey $domain.key \ - -out $domain.crt >/dev/null 2>&1 - - -# Listing certificates -if [ -e "$domain.crt" ]; then - crt=$(cat $domain.crt |sed ':a;N;$!ba;s/\n/\\n/g' ) -fi - -if [ -e "$domain.key" ]; then - key=$(cat $domain.key |sed ':a;N;$!ba;s/\n/\\n/g' ) -fi - -if [ -e "$domain.csr" ]; then - csr=$(cat $domain.csr |sed ':a;N;$!ba;s/\n/\\n/g' ) -fi - -case $format in - json) json_list_ssl ;; - plain) nohead=1; shell_list_ssl ;; - shell) shell_list_ssl ;; - *) check_args '1' '0' '[FORMAT]' -esac - -# Delete tmp dir -#rm -rf $workdir - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-get-dns-domain-value b/bin/v-get-dns-domain-value deleted file mode 100755 index b530588a1..000000000 --- a/bin/v-get-dns-domain-value +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# info: get dns domain value -# options: USER DOMAIN KEY -# -# The function for getting a certain DNS domain parameter. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -key=$(echo "$3"| tr '[:lower:]' '[:upper:]' | sed "s/^/$/") - -# Includes -source $VESTA/func/main.sh - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN KEY' -is_format_valid 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Print -get_object_value 'dns' 'DOMAIN' "$domain" "$key" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-get-fs-file-type b/bin/v-get-fs-file-type deleted file mode 100755 index ba2b7a660..000000000 --- a/bin/v-get-fs-file-type +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# info: get file type -# options: USER FILE -# -# The function shows file type - -user=$1 -path=$2 - -# Checking arguments -if [ -z "$path" ]; then - echo "Usage: USER FILE" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking user homedir -homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) -if [ -z $homedir ]; then - echo "Error: user home directory doesn't exist" - exit 12 -fi - -# Checking path -rpath=$(readlink -f "$path") -if [ -z "$(echo $rpath |grep $homedir)" ]; then - echo "Error: invalid path $path" - exit 2 -fi - -# Listing file type -sudo -u $user file -i -b "$path" 2>/dev/null - -# Exiting -exit $? diff --git a/bin/v-get-mail-account-value b/bin/v-get-mail-account-value deleted file mode 100755 index abff06a53..000000000 --- a/bin/v-get-mail-account-value +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# info: get mail account value -# options: USER DOMAIN ACCOUNT KEY -# -# The function for getting a certain mail account parameter. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -account=$3 -key=$(echo "$4"| tr '[:lower:]' '[:upper:]' | sed "s/^/$/") - -# Includes -source $VESTA/func/main.sh - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN KEY' -is_format_valid 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Print -get_object_value "mail/$domain" 'ACCOUNT' "$account" "$key" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-get-mail-domain-value b/bin/v-get-mail-domain-value deleted file mode 100755 index 97a1a3e46..000000000 --- a/bin/v-get-mail-domain-value +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# info: get mail domain value -# options: USER DOMAIN KEY -# -# The function for getting a certain mail domain parameter. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -key=$(echo "$3"| tr '[:lower:]' '[:upper:]' | sed "s/^/$/") - -# Includes -source $VESTA/func/main.sh - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN KEY' -is_format_valid 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Print -get_object_value 'mail' 'DOMAIN' "$domain" "$key" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-get-sys-timezone b/bin/v-get-sys-timezone deleted file mode 100755 index ced92ba47..000000000 --- a/bin/v-get-sys-timezone +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -# info: get system timezone -# options: [FORMAT] -# -# The function to get system timezone - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking timesonze on RHEL/CentOS -if [ -f "/etc/sysconfig/clock" ]; then - source /etc/sysconfig/clock - -# Checking timezone on Debian/Ubuntu -elif [ -f "/etc/timezone" ]; then - ZONE=$(cat /etc/timezone) - -# Checking symlynks -elif [ -h /etc/localtime ]; then - ZONE=$(readlink /etc/localtime | sed "s%.*share/zoneinfo/%%") - -# Parsing zoneinfo (very slow) -else - checksum=$(md5sum /etc/localtime | cut -d' ' -f1) - ZONE=$(find /usr/share/zoneinfo/ -type f -exec md5sum {} \; |\ - grep "^$checksum" | sed "s/.*\/usr\/share\/zoneinfo\///" | head -n 1) -fi - -echo $ZONE - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-get-sys-timezones b/bin/v-get-sys-timezones deleted file mode 100755 index 2799fccb9..000000000 --- a/bin/v-get-sys-timezones +++ /dev/null @@ -1,476 +0,0 @@ -#!/bin/bash -# info: list system timezone -# options: [FORMAT] -# -# The function checks system timezone settings - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -Zones="Africa/Abidjan -Africa/Accra -Africa/Addis_Ababa -Africa/Algiers -Africa/Asmara -Africa/Bamako -Africa/Bangui -Africa/Banjul -Africa/Bissau -Africa/Blantyre -Africa/Brazzaville -Africa/Bujumbura -Africa/Cairo -Africa/Casablanca -Africa/Ceuta -Africa/Conakry -Africa/Dakar -Africa/Dar_es_Salaam -Africa/Djibouti -Africa/Douala -Africa/El_Aaiun -Africa/Freetown -Africa/Gaborone -Africa/Harare -Africa/Johannesburg -Africa/Juba -Africa/Kampala -Africa/Khartoum -Africa/Kigali -Africa/Kinshasa -Africa/Lagos -Africa/Libreville -Africa/Lome -Africa/Luanda -Africa/Lubumbashi -Africa/Lusaka -Africa/Malabo -Africa/Maputo -Africa/Maseru -Africa/Mbabane -Africa/Mogadishu -Africa/Monrovia -Africa/Nairobi -Africa/Ndjamena -Africa/Niamey -Africa/Nouakchott -Africa/Ouagadougou -Africa/Porto-Novo -Africa/Sao_Tome -Africa/Tripoli -Africa/Tunis -Africa/Windhoek -America/Adak -America/Anchorage -America/Anguilla -America/Antigua -America/Araguaina -America/Argentina/Buenos_Aires -America/Argentina/Catamarca -America/Argentina/Cordoba -America/Argentina/Jujuy -America/Argentina/La_Rioja -America/Argentina/Mendoza -America/Argentina/Rio_Gallegos -America/Argentina/Salta -America/Argentina/San_Juan -America/Argentina/San_Luis -America/Argentina/Tucuman -America/Argentina/Ushuaia -America/Aruba -America/Asuncion -America/Atikokan -America/Bahia -America/Bahia_Banderas -America/Barbados -America/Belem -America/Belize -America/Blanc-Sablon -America/Boa_Vista -America/Bogota -America/Boise -America/Cambridge_Bay -America/Campo_Grande -America/Cancun -America/Caracas -America/Cayenne -America/Cayman -America/Chicago -America/Chihuahua -America/Costa_Rica -America/Creston -America/Cuiaba -America/Curacao -America/Danmarkshavn -America/Dawson -America/Dawson_Creek -America/Denver -America/Detroit -America/Dominica -America/Edmonton -America/Eirunepe -America/El_Salvador -America/Fortaleza -America/Glace_Bay -America/Godthab -America/Goose_Bay -America/Grand_Turk -America/Grenada -America/Guadeloupe -America/Guatemala -America/Guayaquil -America/Guyana -America/Halifax -America/Havana -America/Hermosillo -America/Indiana/Indianapolis -America/Indiana/Knox -America/Indiana/Marengo -America/Indiana/Petersburg -America/Indiana/Tell_City -America/Indiana/Vevay -America/Indiana/Vincennes -America/Indiana/Winamac -America/Inuvik -America/Iqaluit -America/Jamaica -America/Juneau -America/Kentucky/Louisville -America/Kentucky/Monticello -America/Kralendijk -America/La_Paz -America/Lima -America/Los_Angeles -America/Lower_Princes -America/Maceio -America/Managua -America/Manaus -America/Marigot -America/Martinique -America/Matamoros -America/Mazatlan -America/Menominee -America/Merida -America/Metlakatla -America/Mexico_City -America/Miquelon -America/Moncton -America/Monterrey -America/Montevideo -America/Montserrat -America/Nassau -America/New_York -America/Nipigon -America/Nome -America/Noronha -America/North_Dakota/Beulah -America/North_Dakota/Center -America/North_Dakota/New_Salem -America/Ojinaga -America/Panama -America/Pangnirtung -America/Paramaribo -America/Phoenix -America/Port-au-Prince -America/Port_of_Spain -America/Porto_Velho -America/Puerto_Rico -America/Rainy_River -America/Rankin_Inlet -America/Recife -America/Regina -America/Resolute -America/Rio_Branco -America/Santa_Isabel -America/Santarem -America/Santiago -America/Santo_Domingo -America/Sao_Paulo -America/Scoresbysund -America/Sitka -America/St_Barthelemy -America/St_Johns -America/St_Kitts -America/St_Lucia -America/St_Thomas -America/St_Vincent -America/Swift_Current -America/Tegucigalpa -America/Thule -America/Thunder_Bay -America/Tijuana -America/Toronto -America/Tortola -America/Vancouver -America/Whitehorse -America/Winnipeg -America/Yakutat -America/Yellowknife -Antarctica/Casey -Antarctica/Davis -Antarctica/DumontDUrville -Antarctica/Macquarie -Antarctica/Mawson -Antarctica/McMurdo -Antarctica/Palmer -Antarctica/Rothera -Antarctica/Syowa -Antarctica/Troll -Antarctica/Vostok -Arctic/Longyearbyen -Asia/Aden -Asia/Almaty -Asia/Amman -Asia/Anadyr -Asia/Aqtau -Asia/Aqtobe -Asia/Ashgabat -Asia/Baghdad -Asia/Bahrain -Asia/Baku -Asia/Bangkok -Asia/Beirut -Asia/Bishkek -Asia/Brunei -Asia/Chita -Asia/Choibalsan -Asia/Colombo -Asia/Damascus -Asia/Dhaka -Asia/Dili -Asia/Dubai -Asia/Dushanbe -Asia/Gaza -Asia/Hebron -Asia/Ho_Chi_Minh -Asia/Hong_Kong -Asia/Hovd -Asia/Irkutsk -Asia/Jakarta -Asia/Jayapura -Asia/Jerusalem -Asia/Kabul -Asia/Kamchatka -Asia/Karachi -Asia/Kathmandu -Asia/Khandyga -Asia/Kolkata -Asia/Krasnoyarsk -Asia/Kuala_Lumpur -Asia/Kuching -Asia/Kuwait -Asia/Macau -Asia/Magadan -Asia/Makassar -Asia/Manila -Asia/Muscat -Asia/Nicosia -Asia/Novokuznetsk -Asia/Novosibirsk -Asia/Omsk -Asia/Oral -Asia/Phnom_Penh -Asia/Pontianak -Asia/Pyongyang -Asia/Qatar -Asia/Qyzylorda -Asia/Rangoon -Asia/Riyadh -Asia/Sakhalin -Asia/Samarkand -Asia/Seoul -Asia/Shanghai -Asia/Singapore -Asia/Srednekolymsk -Asia/Taipei -Asia/Tashkent -Asia/Tbilisi -Asia/Tehran -Asia/Thimphu -Asia/Tokyo -Asia/Ulaanbaatar -Asia/Urumqi -Asia/Ust-Nera -Asia/Vientiane -Asia/Vladivostok -Asia/Yakutsk -Asia/Yekaterinburg -Asia/Yerevan -Atlantic/Azores -Atlantic/Bermuda -Atlantic/Canary -Atlantic/Cape_Verde -Atlantic/Faroe -Atlantic/Madeira -Atlantic/Reykjavik -Atlantic/South_Georgia -Atlantic/St_Helena -Atlantic/Stanley -Australia/Adelaide -Australia/Brisbane -Australia/Broken_Hill -Australia/Currie -Australia/Darwin -Australia/Eucla -Australia/Hobart -Australia/Lindeman -Australia/Lord_Howe -Australia/Melbourne -Australia/Perth -Australia/Sydney -Europe/Amsterdam -Europe/Andorra -Europe/Athens -Europe/Belgrade -Europe/Berlin -Europe/Bratislava -Europe/Brussels -Europe/Bucharest -Europe/Budapest -Europe/Busingen -Europe/Chisinau -Europe/Copenhagen -Europe/Dublin -Europe/Gibraltar -Europe/Guernsey -Europe/Helsinki -Europe/Isle_of_Man -Europe/Istanbul -Europe/Jersey -Europe/Kaliningrad -Europe/Kiev -Europe/Lisbon -Europe/Ljubljana -Europe/London -Europe/Luxembourg -Europe/Madrid -Europe/Malta -Europe/Mariehamn -Europe/Minsk -Europe/Monaco -Europe/Moscow -Europe/Oslo -Europe/Paris -Europe/Podgorica -Europe/Prague -Europe/Riga -Europe/Rome -Europe/Samara -Europe/San_Marino -Europe/Sarajevo -Europe/Simferopol -Europe/Skopje -Europe/Sofia -Europe/Stockholm -Europe/Tallinn -Europe/Tirane -Europe/Uzhgorod -Europe/Vaduz -Europe/Vatican -Europe/Vienna -Europe/Vilnius -Europe/Volgograd -Europe/Warsaw -Europe/Zagreb -Europe/Zaporozhye -Europe/Zurich -Indian/Antananarivo -Indian/Chagos -Indian/Christmas -Indian/Cocos -Indian/Comoro -Indian/Kerguelen -Indian/Mahe -Indian/Maldives -Indian/Mauritius -Indian/Mayotte -Indian/Reunion -Pacific/Apia -Pacific/Auckland -Pacific/Bougainville -Pacific/Chatham -Pacific/Chuuk -Pacific/Easter -Pacific/Efate -Pacific/Enderbury -Pacific/Fakaofo -Pacific/Fiji -Pacific/Funafuti -Pacific/Galapagos -Pacific/Gambier -Pacific/Guadalcanal -Pacific/Guam -Pacific/Honolulu -Pacific/Johnston -Pacific/Kiritimati -Pacific/Kosrae -Pacific/Kwajalein -Pacific/Majuro -Pacific/Marquesas -Pacific/Midway -Pacific/Nauru -Pacific/Niue -Pacific/Norfolk -Pacific/Noumea -Pacific/Pago_Pago -Pacific/Palau -Pacific/Pitcairn -Pacific/Pohnpei -Pacific/Port_Moresby -Pacific/Rarotonga -Pacific/Saipan -Pacific/Tahiti -Pacific/Tarawa -Pacific/Tongatapu -Pacific/Wake -Pacific/Wallis" - -# Check timesonze -if [ -f /etc/timezone ]; then - TZ=$(cat /etc/timezone) -elif [ -h /etc/localtime ]; then - TZ=$(readlink /etc/localtime | sed "s/\/usr\/share\/zoneinfo\///") -else - checksum=$(md5sum /etc/localtime | cut -d' ' -f1) - TZ=$(find /usr/share/zoneinfo/ -type f -exec md5sum {} \; |\ - grep "^$checksum" | sed "s/.*\/usr\/share\/zoneinfo\///" | head -n 1) -fi - -echo $TZ - -exit -# Defining config -echo -e "$str" > $tmp_file -conf=$tmp_file - -# Defining fileds to select -fields="\$SYS \$HOSTNAME \$OS \$VERSION \$ARCH \$UPTIME \$LOADAVERAGE" - -# Listing services -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields="\$HOSTNAME \$OS \$VERSION \$ARCH \$UPTIME \$LOADAVERAGE" - shell_list | column -t ;; - *) check_args '1' '0' 'USER [FORMAT]' -esac - -rm -f $tmp_file - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-get-user-salt b/bin/v-get-user-salt deleted file mode 100755 index 08ee5a9ca..000000000 --- a/bin/v-get-user-salt +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash -# info: get user salt -# options: USER [IP] [FORMAT] -# -# The function provides users salt - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -ip=${2-127.0.0.1} -format=${3-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# JSON list function -json_list() { - echo '{' - echo ' "'$user'": { - "METHOD": "'$method'", - "SALT": "'$salt'", - "TIME": "'$time'", - "DATE": "'$date'" - }' - echo '}' -} - -# SHELL list function -shell_list() { - echo "METHOD: $method" - echo "SALT: $salt" -} - -# PLAIN list function -plain_list() { - echo -e "$method\t$salt" -} - -# CSV list function -csv_list() { - echo "METHOD,SALT" - echo "$method, $salt" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - - -check_args '1' "$#" 'USER [IP] [SALT]' -is_format_valid 'user' - -# Checking user -if [ ! -d "$VESTA/data/users/$user" ] && [ "$user" != 'root' ]; then - echo "Error: password missmatch" - echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log - exit 9 -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing user's salt -shadow=$(grep "^$user:" /etc/shadow | cut -f 2 -d :) - -if echo "$shadow" | grep -qE '^\$[0-9a-z]+\$[^\$]+\$' -then - salt=$(echo "$shadow" |cut -f 3 -d \$) - method=$(echo "$shadow" |cut -f 2 -d \$) - if [ "$method" -eq '1' ]; then - method='md5' - elif [ "$method" -eq '6' ]; then - method='sha-512' - else - echo "Error: password missmatch" - echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log - exit 9 - fi -else - salt=${shadow:0:2} - method='des' -fi - -if [ -z "$salt" ]; then - echo "Error: password missmatch" - echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log - exit 9 -fi - - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging - -exit diff --git a/bin/v-get-user-value b/bin/v-get-user-value deleted file mode 100755 index a832801ac..000000000 --- a/bin/v-get-user-value +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# info: get user value -# options: USER KEY -# -# The function for obtaining certain user's parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -key=$(echo "$2"| tr '[:lower:]' '[:upper:]' | sed "s/^/$/") - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER KEY' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking key -value=$(get_user_value "$key") - -# Printing value -echo "$value" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-get-web-domain-value b/bin/v-get-web-domain-value deleted file mode 100755 index 68745401f..000000000 --- a/bin/v-get-web-domain-value +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# info: get web domain value -# options: USER DOMAIN KEY -# -# The function is intended for obtaining a domain value by the key. This call -# is useful for arranging composite queries. The answer is displayed only in -# raw form; output formats aren't supported. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Say goodbye -echo "This script is not used anymore" -exit - -# Argument definition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -key=$(echo "$3"| tr '[:lower:]' '[:upper:]' | sed "s/^/$/") - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN KEY' -is_format_valid 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -get_domain_values 'web' -eval echo $key - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-insert-dns-domain b/bin/v-insert-dns-domain deleted file mode 100755 index 9e6874df5..000000000 --- a/bin/v-insert-dns-domain +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash -# info: insert dns domain -# options: USER DATA [SRC] [FLUSH] [RESTART] -# -# The function inserts raw record to the dns.conf - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -data=$2 -src=$3 -flush=$4 -restart=$5 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DATA [SRC] [FLUSH] [RESTART]' -is_format_valid 'user' 'data' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -eval $data -domain="$DOMAIN" -if [ "$flush" = 'no' ]; then - is_domain_new 'dns' $domain -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Flush records -if [ "$flush" = 'records' ]; then - rm -f $USER_DATA/dns/$DOMAIN.conf - touch $USER_DATA/dns/$DOMAIN.conf - chmod 660 $USER_DATA/dns/$DOMAIN.conf -fi - -# Flush domain -if [ "$flush" != 'no' ]; then - sed -i "/DOMAIN='$DOMAIN'/d" $USER_DATA/dns.conf 2> /dev/null -fi - -# Generating timestamp -time_n_date=$(date +'%T %F') -time=$(echo "$time_n_date" |cut -f 1 -d \ ) -date=$(echo "$time_n_date" |cut -f 2 -d \ ) - -# Prepare values for the insert -dns_rec="DOMAIN='$DOMAIN' IP='$IP' TPL='$TPL' TTL='$TTL' EXP='$EXP'" -dns_rec="$dns_rec SOA='$SOA' SERIAL="$SERIAL" SRC='$src' RECORDS='$RECORDS'" -dns_rec="$dns_rec SUSPENDED='$SUSPENDED' TIME='$time' DATE='$date'" -echo "$dns_rec" >> $USER_DATA/dns.conf - -# Set permission -chmod 660 $USER_DATA/dns.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting named -$BIN/v-restart-dns $restart -check_result $? "Bind restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-insert-dns-record b/bin/v-insert-dns-record deleted file mode 100755 index 1afdd5202..000000000 --- a/bin/v-insert-dns-record +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# info: insert dns record -# options: USER DOMAIN DATA [RESTART] -# -# The function inserts raw dns record to the domain conf - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -data=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN DATA [RESTART]' -is_format_valid 'user' 'domain' 'data' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Insert values -echo "$data" >> $USER_DATA/dns/$domain.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting named -$BIN/v-restart-dns $restart -check_result $? "Bind restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-insert-dns-records b/bin/v-insert-dns-records deleted file mode 100755 index 52c72c66a..000000000 --- a/bin/v-insert-dns-records +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# info: inserts dns records -# options: USER DOMAIN DATA_FILE [RESTART] -# -# The function copy dns record to the domain conf - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -data_file=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN DATAFILE [RESTART]' -is_format_valid 'user' 'domain' 'data_file' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Insert values -if [ -e "$data_file" ]; then - mv -f $data_file $USER_DATA/dns/$domain.conf - chmod 660 $USER_DATA/dns/$domain.conf -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting named -$BIN/v-restart-dns $restart -check_result $? "Bind restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-list-backup-host b/bin/v-list-backup-host deleted file mode 100755 index 60e80fa17..000000000 --- a/bin/v-list-backup-host +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# info: list backup host -# options: TYPE HOST [FORMAT] -# -# The function for obtaining the list of backup host parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -type=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{' - echo ' "'$type'": { - "HOST": "'$HOST'", - "USERNAME": "'$USERNAME'", - "PORT": "'$PORT'", - "TYPE": "'$type'", - "BPATH": "'$BPATH'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - echo '}' -} - -# SHELL list function -shell_list() { - echo "HOST: $HOST" - echo "USERNAME: $USERNAME" - echo "PORT: $PORT" - echo "TYPE: $type" - echo "PATH: $BPATH" - echo "TIME: $TIME" - echo "DATE: $DATE" -} - -# PLAIN list function -plain_list() { - echo -e "$HOST\t$USERNAME\t$PORT\t$type\t$BPATH\t$TIME\t$DATE" -} - -# CSV list function -csv_list() { - echo "HOST,USERNAME,PORT,TYPE,PATH,TIME,DATE" - echo "$HOST,$USERNAME,$PORT,$type,$BPATH,$TIME,$DATE" -} - -# Type format validator -is_type_format_valid() { - exclude="[!|#|$|^|&|(|)|+|=|{|}|:|@|<|>|?|/|\|\"|'|;|%|\`| ]|\." - if [[ "$1" =~ $exclude ]]; then - check_result $E_INVALID "invalid type extention format :: $1" - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'TYPE [FORMAT]' -is_type_format_valid "$type" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking backup config -if [ ! -e "$VESTA/conf/$type.backup.conf" ]; then - exit -fi - -# Parsing backup config -source "$VESTA/conf/$type.backup.conf" - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-cron-job b/bin/v-list-cron-job deleted file mode 100755 index 18592a52e..000000000 --- a/bin/v-list-cron-job +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash -# info: list cron job -# options: USER JOB [FORMAT] -# -# The function of obtaining cron job parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -job=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo "{" - echo -n ' "'$job'": { - "MIN": "'$MIN'", - "HOUR": "'$HOUR'", - "DAY": "'$DAY'", - "MONTH": "'$MONTH'", - "WDAY": "'$WDAY'", - "CMD": "'$CMD'", - "JOB": "'$JOB'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - echo - echo '}' -} - -# SHELL list function -shell_list() { - echo "MINUTE: $MIN" - echo "HOUR: $HOUR" - echo "DAY: $DAY" - echo "DAY OF WEEK: $WDAY" - echo "COMMAND: $CMD" - echo "SUSPENDED: $SUSPENDED" - echo "TIME: $TIME" - echo "DATE: $DATE" -} - -# PLAIN list function -plain_list() { - echo -e "$MIN\t$HOUR\t$DAY\t$WDAY\t$CMD\t$SUSPENDED\t$TIME\t$DATE" -} - -# CSV list function -csv_list() { - echo "MIN,HOUR,DAY,WDAY,CMD,SUSPENDED,TIME,DATE" - echo "$MIN,$HOUR,$DAY,$WDAY,\"$CMD\",$SUSPENDED,$TIME,$DATE'" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER JOB [FORMAT]' -is_format_valid 'user' -is_number_format_valid "$job" "job_id" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/cron.conf - -# Checking job id -cron_line=$(grep "JOB='$job'" $conf) -if [ -z "$cron_line" ]; then - check_result $E_NOTEXIST "cron job $job doesn't exist" -fi - -# Parsing cron job -eval $cron_line - -# Replacing quoted and backslahed text -CMD=$(echo "$CMD" |sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-cron-jobs b/bin/v-list-cron-jobs deleted file mode 100755 index d9b5c3791..000000000 --- a/bin/v-list-cron-jobs +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/bash -# info: list user cron jobs -# options: USER [FORMAT] -# -# The function for obtaining the list of all users cron jobs. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(grep JOB $USER_DATA/cron.conf |wc -l) - echo "{" - while read str; do - eval $str - CMD=$(echo "$CMD" |sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - echo -n ' "'$JOB'": { - "MIN": "'$MIN'", - "HOUR": "'$HOUR'", - "DAY": "'$DAY'", - "MONTH": "'$MONTH'", - "WDAY": "'$WDAY'", - "CMD": "'$CMD'", - "JOB": "'$JOB'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(cat $USER_DATA/cron.conf) - echo '}' -} - - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "JOB^MIN^HOUR^MONTH^WDAY^COMMAND" - echo "---^---^----^-----^----^-------" - while read str; do - eval $str - CMD=$(echo "$CMD" |sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - echo "$JOB^$MIN^$HOUR^$MONTH^$WDAY^$CMD" - done < <(cat $USER_DATA/cron.conf) -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - while read str; do - eval $str - CMD=$(echo "$CMD" |sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - echo -ne "$JOB\t$MIN\t$HOUR\t$MONTH\t$WDAY\t$CMD\t" - echo -e "$SUSPENDED\t$TIME\t$DATE" - done < <(cat $USER_DATA/cron.conf) -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo "MIN,HOUR,DAY,WDAY,CMD,SUSPENDED,TIME,DATE" - while read str; do - eval $str - CMD=$(echo "$CMD" |sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - echo -n "$JOB,$MIN,$HOUR,$MONTH,$WDAY,\"$CMD\"," - echo "$SUSPENDED,$TIME,$DATE" - done < <(cat $USER_DATA/cron.conf) -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t -s '^';; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-database b/bin/v-list-database deleted file mode 100755 index 420d0e692..000000000 --- a/bin/v-list-database +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -# info: list database -# options: USER DATABASE [FORMAT] -# -# The function for obtaining of all database's parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -database=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{' - echo ' "'$database'": { - "DATABASE": "'$DB'", - "DBUSER": "'$DBUSER'", - "HOST": "'$HOST'", - "TYPE": "'$TYPE'", - "CHARSET": "'$CHARSET'", - "U_DISK": "'$U_DISK'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - echo '}' -} - -# SHELL list function -shell_list() { - echo "DATABASE: $DB" - echo "DB USER: $DBUSER" - echo "HOST: $HOST" - echo "TYPE: $TYPE" - echo "CHARSET: $CHARSET" - echo "DISK: $U_DISK" - echo "SUSPENDED: $SUSPENDED" - echo "TIME: $TIME" - echo "DATE: $DATE" -} - -# PLAIN list function -plain_list() { - echo -ne "$DB\t$DBUSER\t$HOST\t$TYPE\t$CHARSET\t$U_DISK\t" - echo -e "$SUSPENDED\t$TIME\t$DATE" -} - -# CSV list function -csv_list() { - echo "DATABASE,DBUSER,HOST,TYPE,CHARSET,U_DISK,SUSPENDED,TIME,DATE" - echo "$DB,$DBUSER,$HOST,$TYPE,$CHARSET,$U_DISK,$SUSPENDED,$TIME,$DATE" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DATABASE [FORMAT]' -is_format_valid 'user' 'database' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing database -eval $(grep "DB='$database'" $USER_DATA/db.conf) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-database-host b/bin/v-list-database-host deleted file mode 100755 index 326764af1..000000000 --- a/bin/v-list-database-host +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/bash -# info: list database host -# options: TYPE HOST [FORMAT] -# -# The function for obtaining database host parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -type=$1 -host=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{' - echo ' "'$HOST'": { - "HOST": "'$HOST'", - "TYPE": "'$type'", - "CHARSETS": "'$CHARSETS'", - "MAX_DB": "'$MAX_DB'", - "U_SYS_USERS": "'$U_SYS_USERS'", - "U_DB_BASES": "'$U_DB_BASES'", - "TPL": "'$TPL'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - echo '}' -} - -# SHELL list function -shell_list() { - echo "HOST: $HOST" - echo "TYPE: $type" - echo "CHARSETS: $CHARSETS" - echo "MAX_DB: $MAX_DB" - echo "U_DB_BASES: $U_DB_BASES" - echo "U_SYS_USERS: $U_SYS_USERS" - echo "TPL: $TPL" - echo "SUSPENDED: $SUSPENDED" - echo "TIME: $TIME" - echo "DATE: $DATE" -} - -# PLAIN list function -plain_list() { - echo -ne "$HOST\t$type\t$CHARSETS\t$MAX_DB\t$U_SYS_USERS\t" - echo -e "$U_DB_BASES\t$TPL\t$SUSPENDED\t$TIME\t$DATE" -} - -# CSV list function -csv_list() { - echo -n "HOST,TYPE,CHARSETS,MAX_DB,U_SYS_USERS," - echo "U_DB_BASES,TPL,SUSPENDED,TIME,DATE'" - echo -n "$HOST,$type,\"$CHARSETS\",$MAX_DB,\"$U_SYS_USERS\"," - echo "$U_DB_BASES,$TPL,$SUSPENDED,$TIME,$DATE" -} - -# Type format validator -is_type_format_valid() { - exclude="[!|#|$|^|&|(|)|+|=|{|}|:|@|<|>|?|/|\|\"|'|;|%|\`| ]|\." - if [[ "$1" =~ $exclude ]]; then - check_result $E_INVALID "invalid type extention format :: $1" - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'TYPE HOST [FORMAT]' -is_type_format_valid "$type" -is_object_valid "../../conf/$type" 'HOST' "$host" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing hosts -eval $(grep "HOST='$host'" $VESTA/conf/$type.conf) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-database-hosts b/bin/v-list-database-hosts deleted file mode 100755 index 1355a5a48..000000000 --- a/bin/v-list-database-hosts +++ /dev/null @@ -1,136 +0,0 @@ -#!/bin/bash -# info: list database hosts -# options: [FORMAT] -# -# The function for obtaining the list of all configured database hosts. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=0 - for type in $(echo $DB_SYSTEM |sed -e 's/,/\n/'); do - if [ -e "$VESTA/conf/$type.conf" ]; then - db_hosts=$(grep HOST $VESTA/conf/$type.conf |wc -l) - objects=$((objects + db_hosts)) - fi - done - - echo "[" - for type in $(echo $DB_SYSTEM |sed -e 's/,/\n/'); do - if [ -e "$VESTA/conf/$type.conf" ]; then - for str in $(cat $VESTA/conf/$type.conf); do - eval $str - echo -n ' { - "HOST": "'$HOST'", - "TYPE": "'$type'", - "CHARSETS": "'$CHARSETS'", - "MAX_DB": "'$MAX_DB'", - "U_SYS_USERS": "'$U_SYS_USERS'", - "U_DB_BASES": "'$U_DB_BASES'", - "TPL": "'$TPL'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done - fi - done - echo ']' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "HOST TYPE MAX_DB DB_USED SPND TIME DATE" - echo "---- ---- ------ ------- ---- ---- ----" - for type in $(echo $DB_SYSTEM |sed -e 's/,/\n/'); do - if [ -e "$VESTA/conf/$type.conf" ]; then - for str in $(cat $VESTA/conf/$type.conf); do - eval $str - echo "$HOST $type $MAX_DB $U_DB_BASES $SUSPENDED $TIME $DATE" - done - fi - done -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - for type in $(echo $DB_SYSTEM |sed -e 's/,/\n/'); do - if [ -e "$VESTA/conf/$type.conf" ]; then - for str in $(cat $VESTA/conf/$type.conf); do - eval $str - echo -ne "$HOST\t$type\t$CHARSETS\t$MAX_DB\t$U_SYS_USERS\t" - echo -e "$U_DB_BASES\t$TPL\t$SUSPENDED\t$TIME\t$DATE" - done - fi - done -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo -n "HOST,TYPE,CHARSETS,MAX_DB,U_SYS_USERS," - echo "U_DB_BASES,TPL,SUSPENDED,TIME,DATE" - for type in $(echo $DB_SYSTEM |sed -e 's/,/\n/'); do - if [ -e "$VESTA/conf/$type.conf" ]; then - for str in $(cat $VESTA/conf/$type.conf); do - eval $str - echo -n "$HOST,$type,\"$CHARSETS\",$MAX_DB,\"$U_SYS_USERS\"," - echo "$U_DB_BASES,$TPL,$SUSPENDED,$TIME,$DATE" - done - fi - done -} - -# Type format validator -is_type_format_valid() { - exclude="[!|#|$|^|&|(|)|+|=|{|}|:|@|<|>|?|/|\|\"|'|;|%|\`| ]|\." - if [[ "$1" =~ $exclude ]]; then - check_result $E_INVALID "invalid type extention format :: $1" - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-database-types b/bin/v-list-database-types deleted file mode 100755 index 13f8edadb..000000000 --- a/bin/v-list-database-types +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -# info: list supported database types -# options: [FORMAT] -# -# The function for obtaining the list of database types. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# JSON list function -json_list() { - objects=$(echo "${DB_SYSTEM//,/ }" |wc -w) - i=1 - echo '[' - for type in ${DB_SYSTEM//,/ }; do - echo -n ' "'$type'"' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done - echo "]" -} - -# SHELL list function -shell_list() { - echo -e "TYPE\n----" - echo "$DB_SYSTEM" |sed -e "s/,/\n/" -} - -# PLAIN list function -plain_list() { - for type in ${DB_SYSTEM//,/ }; do - echo "$type" - done -} - -# CSV list function -csv_list() { - echo "TYPE" - for type in ${DB_SYSTEM//,/ }; do - echo "$type" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-databases b/bin/v-list-databases deleted file mode 100755 index b3e83b1d8..000000000 --- a/bin/v-list-databases +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash -# info: listing databases -# options: USER [FORMAT] -# -# The function for obtaining the list of all user's databases. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(grep "DB=" $USER_DATA/db.conf |wc -l) - echo "{" - while read str; do - eval $str - echo -n ' "'$DB'": { - "DATABASE": "'$DB'", - "DBUSER": "'$DBUSER'", - "HOST": "'$HOST'", - "TYPE": "'$TYPE'", - "CHARSET": "'$CHARSET'", - "U_DISK": "'$U_DISK'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(cat $USER_DATA/db.conf) - echo '}' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "DATABASE USER HOST TYPE DISK SPND DATE" - echo "-------- ---- ---- ---- ---- ---- ----" - while read str; do - eval $str - echo "$DB $DBUSER $HOST $TYPE $U_DISK $SUSPENDED $DATE" - done < <(cat $USER_DATA/db.conf) -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - while read str; do - eval $str - echo -ne "$DB\t$DBUSER\t$HOST\t$TYPE\t$CHARSET\t$U_DISK\t" - echo -e "$SUSPENDED\t$TIME\t$DATE" - done < <(cat $USER_DATA/db.conf) -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo "DATABASE,DBUSER,HOST,TYPE,CHARSET,U_DISK,SUSPENDED,TIME,DATE" - while read str; do - eval $str - echo "$DB,$DBUSER,$HOST,$TYPE,$CHARSET,$U_DISK,$SUSPENDED,$TIME,$DATE" - done < <(cat $USER_DATA/db.conf) -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-dns-domain b/bin/v-list-dns-domain deleted file mode 100755 index c9c3f1ea6..000000000 --- a/bin/v-list-dns-domain +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash -# info: list dns domain -# options: USER DOMAIN [FORMAT] -# -# The function of obtaining the list of dns domain parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{' - echo ' "'$DOMAIN'": { - "IP": "'$IP'", - "TPL": "'$TPL'", - "TTL": "'$TTL'", - "EXP": "'$EXP'", - "SOA": "'$SOA'", - "SERIAL": "'$SERIAL'", - "SRC": "'$SRC'", - "RECORDS": "'$RECORDS'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - echo '}' -} - -# SHELL list function -shell_list() { - echo "DOMAIN: $DOMAIN" - echo "IP: $IP" - echo "TEMPLATE: $TPL" - echo "TTL: $TTL" - echo "EXP: $EXP" - echo "SOA: $SOA" - echo "SERIAL: $SERIAL" - echo "RECORDS: $RECORDS" - echo "SUSPENDED: $SUSPENDED" - echo "TIME: $TIME" - echo "DATE: $DATE" -} - - -# PLAIN list function -plain_list() { - echo -ne "$DOMAIN\t$IP\t$TPL\t$TTL\t$EXP\t$SOA\t$SERIAL\t$RECORDS\t" - echo -e "$SUSPENDED\t$TIME\t$DATE" -} - -# CSV list function -csv_list() { - echo "DOMAIN,IP,TPL,TTL,EXP,SOA,SERIAL,RECORDS,SUSPENDED,TIME,DATE" - echo -n "$DOMAIN,$IP,$TPL,$TTL,$EXP,$SOA,$SERIAL,$RECORDS,$SUSPENDED," - echo "$TIME,$DATE" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FORMAT]' -is_format_valid 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain -eval $(grep "DOMAIN='$domain'" $USER_DATA/dns.conf) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-dns-domains b/bin/v-list-dns-domains deleted file mode 100755 index 337760e39..000000000 --- a/bin/v-list-dns-domains +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/bash -# info: list dns domains -# options: USER [FORMAT] -# -# The function for obtaining all DNS domains of a user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(grep DOMAIN $USER_DATA/dns.conf |wc -l) - echo "{" - while read str; do - eval $str - echo -n ' "'$DOMAIN'": { - "IP": "'$IP'", - "TPL": "'$TPL'", - "TTL": "'$TTL'", - "EXP": "'$EXP'", - "SOA": "'$SOA'", - "SERIAL": "'$SERIAL'", - "SRC": "'$SRC'", - "RECORDS": "'$RECORDS'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(cat $USER_DATA/dns.conf) - echo '}' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "DOMAIN IP TPL TTL REC SPND DATE" - echo "------ -- --- --- --- ---- ----" - while read str; do - eval $str - echo "$DOMAIN $IP $TPL $TTL $RECORDS $SUSPENDED $DATE" - done < <(cat $USER_DATA/dns.conf) -} - - -# PLAIN list function -plain_list() { - IFS=$'\n' - while read str; do - eval $str - echo -ne "$DOMAIN\t$IP\t$TPL\t$TTL\t$EXP\t$SOA\t$SERIAL\t" - echo -e "$SRC\t$RECORDS\t$SUSPENDED\t$TIME\t$DATE" - done < <(cat $USER_DATA/dns.conf) -} - - -# CSV list function -csv_list() { - IFS=$'\n' - echo "DOMAIN,IP,TPL,TTL,EXP,SOA,SERIAL,SRC,RECORDS,SUSPENDED,TIME,DATE" - while read str; do - eval $str - echo -n "$DOMAIN,$IP,$TPL,$TTL,$EXP,$SOA,$SERIAL," - echo "$SRC,$RECORDS,$SUSPENDED,$TIME,$DATE" - done < <(cat $USER_DATA/dns.conf) -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-dns-records b/bin/v-list-dns-records deleted file mode 100755 index d23634d6b..000000000 --- a/bin/v-list-dns-records +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/bash -# info: list dns domain records -# options: USER DOMAIN [FORMAT] -# -# The function for getting all DNS domain records. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(grep ID $USER_DATA/dns/$domain.conf |wc -l) - echo "{" - while read str; do - eval $str - VALUE=$(echo "$VALUE" |sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - echo -n ' "'$ID'": { - "RECORD": "'$RECORD'", - "TYPE": "'$TYPE'", - "PRIORITY": "'$PRIORITY'", - "VALUE": "'$VALUE'", - "ID": "'$ID'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(cat $USER_DATA/dns/$domain.conf) - echo '}' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "ID^RECORD^TYPE^VALUE^DATE" - echo "--^------^----^-----^----" - while read str; do - eval $str - echo "$ID^$RECORD^$TYPE^${VALUE:0:30}^$DATE" - done < <(cat $USER_DATA/dns/$domain.conf) -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - while read str; do - eval $str - VALUE=$(echo "$VALUE" |sed -e "s/%quote%/\\'/g") - echo -ne "$ID\t$RECORD\t$TYPE\t$PRIORITY\t$VALUE\t" - echo -e "$SUSPENDED\t$TIME\t$DATE" - done < <(cat $USER_DATA/dns/$domain.conf) -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo "ID,RECORD,TYPE,PRIORITY,VALUE,SUSPENDED,TIME,DATE" - while read str; do - eval $str - VALUE=$(echo "$VALUE" |sed -e "s/%quote%/\\'/g") - echo -n "$ID,$RECORD,$TYPE,$PRIORITY,\"$VALUE\"," - echo "$SUSPENDED,$TIME,$DATE" - done < <(cat $USER_DATA/dns/$domain.conf) -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FORMAT]' -is_format_valid 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t -s '^';; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-dns-template b/bin/v-list-dns-template deleted file mode 100755 index 2697c1750..000000000 --- a/bin/v-list-dns-template +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash -# info: list dns template -# options: TEMPLATE [FORMAT] -# -# The function for obtaining the DNS template parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -template=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(grep ID $DNSTPL/$template.tpl |wc -l) - echo "{" - while read str; do - eval $str - VALUE=$(echo "$VALUE" |sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - echo -n ' "'$ID'": { - "RECORD": "'$RECORD'", - "TYPE": "'$TYPE'", - "PRIORITY": "'$PRIORITY'", - "VALUE": "'$VALUE'", - "ID": "'$ID'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(cat $DNSTPL/$template.tpl) - echo '}' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "ID^RECORD^TYPE^VALUE" - echo "--^------^----^-----" - while read str; do - eval $str - echo "$ID^$RECORD^$TYPE^$VALUE" - done < <(cat $DNSTPL/$template.tpl) -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - while read str; do - eval $str - VALUE=$(echo "$VALUE" |sed -e "s/%quote%/\\'/g") - echo -e "$ID\t$RECORD\t$TYPE\t$PRIORITY\t$VALUE" - done < <(cat $DNSTPL/$template.tpl) -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo "ID,RECORD,TYPE,PRIORITY,VALUE" - while read str; do - eval $str - VALUE=$(echo "$VALUE" |sed -e "s/%quote%/\\'/g") - echo "$ID,$RECORD,$TYPE,$PRIORITY,\"$VALUE\"" - done < <(cat $DNSTPL/$template.tpl) -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'TEMPLATE [FORMAT]' -is_format_valid 'template' -is_dns_template_valid "$template" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t -s '^';; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-dns-templates b/bin/v-list-dns-templates deleted file mode 100755 index dffdf482c..000000000 --- a/bin/v-list-dns-templates +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -# info: list dns templates -# options: [FORMAT] -# -# The function for obtaining the list of all DNS templates available. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - objects=$(echo "$templates" |wc -l) - i=1 - echo "[" - for template in $templates; do - echo -n ' "'$template'"' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done - echo "]" - -} - -# SHELL list function -shell_list() { - echo "TEMPLATE" - echo "--------" - ls -t $DNSTPL |grep '\.tpl' |cut -f 1 -d '.' -} - -# PLAIN list function -plain_list() { - for template in $templates; do - echo "$template" - done -} - -# CSV list function -csv_list() { - echo "TEMPLATE" - for template in $templates; do - echo "$template" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining template list -templates=$(ls -t $DNSTPL |grep '\.tpl' |cut -f 1 -d '.') - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-firewall b/bin/v-list-firewall deleted file mode 100755 index 5b0537c12..000000000 --- a/bin/v-list-firewall +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash -# info: list iptables rules -# options: [FORMAT] -# -# The function of obtaining the list of all iptables rules. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(grep RULE $VESTA/data/firewall/rules.conf |wc -l) - echo "{" - while read str; do - eval $str - echo -n ' "'$RULE'": { - "ACTION": "'$ACTION'", - "PROTOCOL": "'$PROTOCOL'", - "PORT": "'$PORT'", - "IP": "'$IP'", - "COMMENT": "'$COMMENT'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(cat $VESTA/data/firewall/rules.conf) - echo '}' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "RULE^ACTION^PROTO^PORT^IP^SPND^DATE" - echo "----^------^-----^----^--^----^----" - while read str; do - eval $str - echo "$RULE^$ACTION^$PROTOCOL^$PORT^$IP^$SUSPENDED^$DATE" - done < <(cat $VESTA/data/firewall/rules.conf) -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - while read str; do - eval $str - echo -ne "$RULE\t$ACTION\t$PROTOCOL\t$PORT\t$IP\t$COMMENT\t" - echo -e "$SUSPENDED\t$TIME\t$DATE" - done < <(cat $VESTA/data/firewall/rules.conf) -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo "RULE,ACTION,PROTOCOL,PORT,IP,COMMENT,SUSPENDED,TIME,DATE" - while read str; do - eval $str - echo -n "$RULE,$ACTION,$PROTOCOL,$PORT,$IP,\"$COMMENT\"," - echo "$SUSPENDED,$TIME,$DATE" - done < <(cat $VESTA/data/firewall/rules.conf) -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t -s '^' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-firewall-ban b/bin/v-list-firewall-ban deleted file mode 100755 index 62a081201..000000000 --- a/bin/v-list-firewall-ban +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash -# info: list firewall block list -# options: [FORMAT] -# -# The function of obtaining the list of currently blocked ips. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(grep IP $VESTA/data/firewall/banlist.conf |wc -l) - echo "{" - while read str; do - eval $str - echo -n ' "'$IP'": { - "IP": "'$IP'", - "CHAIN": "'$CHAIN'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(cat $VESTA/data/firewall/banlist.conf) - echo '}' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "IP CHAIN TIME DATE" - echo "-- ----- ---- ----" - while read str; do - eval $str - echo "$IP $CHAIN $TIME $DATE" - done < <(cat $VESTA/data/firewall/banlist.conf) -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - while read str; do - eval $str - echo -e "$IP\t$CHAIN\t$TIME\t$DATE" - done < <(cat $VESTA/data/firewall/banlist.conf) -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo "IP,CHAIN,TIME,DATE" - while read str; do - eval $str - echo "$IP,$CHAIN,$TIME,$DATE" - done < <(cat $VESTA/data/firewall/banlist.conf) -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-firewall-rule b/bin/v-list-firewall-rule deleted file mode 100755 index e7c7f6b1a..000000000 --- a/bin/v-list-firewall-rule +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -# info: list firewall rule -# options: RULE [FORMAT] -# -# The function of obtaining firewall rule parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -rule=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -json_list() { - echo '{' - echo ' "'$RULE'": { - "ACTION": "'$ACTION'", - "PROTOCOL": "'$PROTOCOL'", - "PORT": "'$PORT'", - "IP": "'$IP'", - "COMMENT": "'$COMMENT'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - echo '}' -} - -# SHELL list function -shell_list() { - echo "ACTION: $ACTION" - echo "PROTOCOL: $PROTOCOL" - echo "PORT: $PORT" - echo "IP: $IP" - echo "COMMENT: $COMMENT" - echo "SUSPENDED: $SUSPENDED" - echo "TIME: $TIME" - echo "DATE: $DATE" -} - -# PLAIN list function -plain_list() { - echo -ne "$RULE\t$ACTION\t$PROTOCOL\t$PORT\t$IP\t$COMMENT\t" - echo -e "$SUSPENDED\t$TIME\t$DATE" -} - -# CSV list function -csv_list() { - echo "RULE,ACTION,PROTOCOL,PORT,IP,COMMENT,SUSPENDED,TIME,DATE" - echo "$RULE,$ACTION,$PROTOCOL,$PORT,$IP,$COMMENT,$SUSPENDED,$TIME,$DATE" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'RULE [FORMAT]' -is_number_format_valid "$rule" "rule id" -is_object_valid '../../data/firewall/rules' 'RULE' "$rule" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing rules -eval $(grep "RULE='$rule'" $VESTA/data/firewall/rules.conf) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-fs-directory b/bin/v-list-fs-directory deleted file mode 100755 index 57a2c7c32..000000000 --- a/bin/v-list-fs-directory +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# info: list directory -# options: USER DIRECTORY -# -# The function lists directory on the file system - -user=$1 -path=$2 - -# Checking arguments -if [ -z "$user" ]; then - echo "Usage: USER [PATH]" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking user homedir -homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) -if [ -z $homedir ]; then - echo "Error: user home directory doesn't exist" - exit 12 -fi - -# Checking path -if [ ! -z "$path" ]; then - rpath=$(readlink -f "$path") - if [ -z "$(echo $rpath |grep $homedir)" ]; then - echo "Error: invalid path $dst_dir" - exit 2 - fi -else - path=$homedir -fi - -# Listing directory -sudo -u $user find "$path" -maxdepth 1 \ - -printf "%y|%m|%TY-%Tm-%Td|%TH:%TM|%u|%g|%s|%P\n" 2>/dev/null - -# Exiting -exit $? diff --git a/bin/v-list-letsencrypt-user b/bin/v-list-letsencrypt-user deleted file mode 100755 index f6e2c774d..000000000 --- a/bin/v-list-letsencrypt-user +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# info: list letsencrypt key -# options: USER [FORMAT] -# -# The function for obtaining the letsencrypt key thumbprint - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{' - echo ' "'$user'": { - "EMAIL": "'$EMAIL'", - "EXPONENT": "'$EXPONENT'", - "MODULUS": "'$MODULUS'", - "THUMB": "'$THUMB'", - "KID": "'$KID'" - }' - echo '}' -} - -# SHELL list function -shell_list() { - echo "USER: $user" - echo "EMAIL: $EMAIL" - echo "THUMB: $THUMB" - echo "EXPONENT: $EXPONENT" - echo "MODULUS: $MODULUS" - echo "KID: $KID" -} - -# PLAIN list function -plain_list() { - echo -e "$user\t$EMAIL\t$EXPONENT\t$MODULUS\t$THUMB\t$KID" -} - -# CSV list function -csv_list() { - echo "USER,EMAIL,EXPONENT,MODULUS,THUMB,KID" - echo "$user,$EMAIL,$EXPONENT,$MODULUS,$THUMB,$KID" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" -if [ ! -e "$USER_DATA/ssl/le.conf" ]; then - check_result $E_NOTEXIST "LetsEncrypt user account doesn't exist" -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -source $USER_DATA/ssl/le.conf - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-mail-account b/bin/v-list-mail-account deleted file mode 100755 index 65cc5b907..000000000 --- a/bin/v-list-mail-account +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash -# info: list mail domain account -# options: USER DOMAIN ACCOUNT [FORMAT] -# -# The function of obtaining the list of account parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -account=$3 -format=${4-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{' - echo ' "'$account'": { - "ALIAS": "'$ALIAS'", - "FWD": "'$FWD'", - "FWD_ONLY": "'$FWD_ONLY'", - "AUTOREPLY": "'$AUTOREPLY'", - "QUOTA": "'$QUOTA'", - "U_DISK": "'$U_DISK'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - echo '}' -} - -# SHELL list function -shell_list() { - echo "ACCOUNT: $account" - echo "ALIAS: $ALIAS" - echo "FORWARD: $FWD" - echo "FORWARD_ONLY: $FWD_ONLY" - echo "AUTOREPLY: $AUTOREPLY" - echo "QUOTA: $QUOTA" - echo "DISK: $U_DISK" - echo "SUSPENDED: $SUSPENDED" - echo "TIME: $TIME" - echo "DATE: $DATE" -} - -# PLAIN list function -plain_list() { - echo -ne "$account\t$ALIAS\t$FWD\t$FWD_ONLY\t$AUTOREPLY\t$QUOTA\t" - echo -e "$U_DISK\t$SUSPENDED\t$TIME\t$DATE" -} - -# CSV list function -csv_list() { - echo -n "ACCOUNT,ALIAS,FWD,FWD_ONLY,AUTOREPLY,QUOTA,U_DISK" - echo "SUSPENDED,TIME,DATE" - echo -n "$ACCOUNT,\"$ALIAS\",\"$FWD\",$FWD_ONLY,$AUTOREPLY,$QUOTA," - echo "$U_DISK,$SUSPENDED,$TIME,$DATE" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ACCOUNT [FORMAT]' -is_format_valid 'user' 'domain' 'account' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" - - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing mail account -eval $(grep "ACCOUNT='$account'" $USER_DATA/mail/$domain.conf) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-mail-account-autoreply b/bin/v-list-mail-account-autoreply deleted file mode 100755 index 4d5b17cab..000000000 --- a/bin/v-list-mail-account-autoreply +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -# info: list mail account autoreply -# options: USER DOMAIN ACCOUNT [FORMAT] -# -# The function of obtaining mail account autoreply message. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -account=$3 -format=${4-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - TO_ESCAPE='\\'; - msg=$(echo "$msg" |sed -e "s|${TO_ESCAPE}|${TO_ESCAPE}${TO_ESCAPE}|g" -e 's/"/\\"/g' -e "s/%quote%/'/g") - i='1' # iterator - echo '{' - echo -e "\t\"$account\": {" - echo " \"MSG\": \"$msg\"" - echo -e "\t}\n}" -} - -# SHELL list function -shell_list() { - echo "$msg" -} - -# PLAIN list function -plain_list() { - echo "$msg" -} - -# CSV list function -csv_list() { - echo "MSG" - echo "$msg" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ACCOUNT [FORMAT]' -is_format_valid 'user' 'domain' 'account' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ -e "$USER_DATA/mail/$account@$domain.msg" ]; then - msg=$(cat $USER_DATA/mail/$account@$domain.msg |\ - sed ':a;N;$!ba;s/\n/\\n/g' ) -fi - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-mail-accounts b/bin/v-list-mail-accounts deleted file mode 100755 index 9d4ef41b9..000000000 --- a/bin/v-list-mail-accounts +++ /dev/null @@ -1,125 +0,0 @@ -#!/bin/bash -# info: list mail domain accounts -# options: USER DOMAIN [FORMAT] -# -# The function of obtaining the list of all user domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(grep ACCOUNT $USER_DATA/mail/$domain.conf |wc -l) - echo "{" - while read str; do - eval $str - echo -n ' "'$ACCOUNT'": { - "ALIAS": "'$ALIAS'", - "FWD": "'$FWD'", - "FWD_ONLY": "'$FWD_ONLY'", - "AUTOREPLY": "'$AUTOREPLY'", - "QUOTA": "'$QUOTA'", - "U_DISK": "'$U_DISK'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(cat $USER_DATA/mail/$domain.conf) - echo '}' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "ACCOUNT ALIAS FWD DISK DATE" - echo "------- ----- --- ---- ----" - while read str; do - eval $str - if [ -z "$ALIAS" ]; then - ALIAS='no' - else - if [ "${#ALIAS}" -gt 12 ]; then - ALIAS="${ALIAS:0:12}..." - fi - fi - if [ -z "$FWD" ]; then - FWD='no' - else - if [ "${#FWD}" -gt 20 ]; then - FWD="${FWD:0:20}..." - fi - fi - echo "$ACCOUNT $ALIAS $FWD $U_DISK $DATE" - done < <(cat $USER_DATA/mail/$domain.conf) -} - - -# PLAIN list function -plain_list() { - IFS=$'\n' - while read str; do - eval $str - echo -ne "$ACCOUNT\t$ALIAS\t$FWD\t$FWD_ONLY\t$AUTOREPLY\t" - echo -e "$QUOTA\t$U_DISK\t$SUSPENDED\t$TIME\t$DATE" - done < <(cat $USER_DATA/mail/$domain.conf) -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo -n "ACCOUNT,ALIAS,FWD,FWD_ONLY,AUTOREPLY,QUOTA,U_DISK," - echo "SUSPENDED,TIME,DATE" - while read str; do - eval $str - echo -n "$ACCOUNT,\"$ALIAS\",\"$FWD\",$FWD_ONLY,$AUTOREPLY," - echo "$QUOTA,$U_DISK,$SUSPENDED,$TIME,$DATE" - done < <(cat $USER_DATA/mail/$domain.conf) -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FORMAT]' -is_format_valid 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-mail-domain b/bin/v-list-mail-domain deleted file mode 100755 index 25dab90c2..000000000 --- a/bin/v-list-mail-domain +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# info: list mail domain -# options: USER DOMAIN [FORMAT] -# -# The function of obtaining the list of domain parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - eval $(grep "DOMAIN='$domain'" $USER_DATA/mail.conf) - echo '{' - echo ' "'$DOMAIN'": { - "ANTIVIRUS": "'$ANTIVIRUS'", - "ANTISPAM": "'$ANTISPAM'", - "DKIM": "'$DKIM'", - "CATCHALL": "'$CATCHALL'", - "ACCOUNTS": "'$ACCOUNTS'", - "U_DISK": "'$U_DISK'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - echo '}' -} - -# SHELL list function -shell_list() { - echo "DOMAIN: $DOMAIN" - echo "ANTIVIRUS: $ANTIVIRUS" - echo "ANTISPAM: $ANTISPAM" - echo "DKIM: $DKIM" - echo "CATCHALL: $CATCHALL" - echo "ACCOUNTS: $ACCOUNTS" - echo "DISK: $U_DISK" - echo "SUSPENDED: $SUSPENDED" - echo "TIME: $TIME" - echo "DATE: $DATE" -} - -# PLAIN list function -plain_list() { - echo -ne "$DOMAIN\t$ANTIVIRUS\t$ANTISPAM\t$DKIM\t$CATCHALL\t" - echo -e "$ACCOUNTS\t$U_DISK\t$SUSPENDED\t$TIME\t$DATE" -} - -# CSV list function -csv_list() { - echo -n "DOMAIN,ANTIVIRUS,ANTISPAM,DKIM,CATCHALL,ACCOUNTS,U_DISK," - echo "SUSPENDED,TIME,DATE" - echo -n "$DOMAIN,$ANTIVIRUS,$ANTISPAM,$DKIM,$CATCHALL,$ACCOUNTS,$U_DISK" - echo "$SUSPENDED,$TIME,$DATE" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FORMAT]' -is_format_valid 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing mail domain -eval $(grep "DOMAIN='$domain'" $USER_DATA/mail.conf) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-mail-domain-dkim b/bin/v-list-mail-domain-dkim deleted file mode 100755 index 37088ee0b..000000000 --- a/bin/v-list-mail-domain-dkim +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash -# info: list mail domain dkim -# options: USER DOMAIN [FORMAT] -# -# The function of obtaining domain dkim files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{' - echo -e "\t\"$domain\": {" - echo " \"PEM\": \"$pem\"," - echo " \"PUB\": \"$pub\"," - echo -e "\t}\n}" -} - -# SHELL list function -shell_list() { - echo -e "$pem" - echo -e "\n$pub" -} - -# PLAIN list function -plain_list() { - echo "$pem\t$pub" -} - -# CSV list function -csv_list() { - echo "PEM,PUB" - echo "\"$pem\",\"$pub\"" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FORMAT]' -is_format_valid 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain keys -if [ -e "$USER_DATA/mail/$domain.pem" ]; then - pem=$(cat $USER_DATA/mail/$domain.pem |sed ':a;N;$!ba;s/\n/\\n/g') -fi - -if [ -e "$USER_DATA/mail/$domain.pub" ]; then - pub=$(cat $USER_DATA/mail/$domain.pub |sed ':a;N;$!ba;s/\n/\\n/g') -fi - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-mail-domain-dkim-dns b/bin/v-list-mail-domain-dkim-dns deleted file mode 100755 index d9f9d5bac..000000000 --- a/bin/v-list-mail-domain-dkim-dns +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash -# info: list mail domain dkim dns records -# options: USER DOMAIN [FORMAT] -# -# The function of obtaining domain dkim dns records for proper setup. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{' - echo -e "\t\"_domainkey\": {" - echo " \"TTL\": \"3600\"," - echo " \"TXT\": \"'t=y; o=~;'\"" - echo -e "\t}," - echo -e "\n\t\"mail._domainkey\": {" - echo " \"TTL\": \"3600\"," - echo " \"TXT\": \"\\\"$pub\\\"\"" - echo -e "\t}\n}" -} - -# SHELL list function -shell_list() { - echo "RECORD TTL TYPE VALUE" - echo "------ --- ---- -----" - echo "_domainkey 3600 IN TXT \"t=y; o=~;\"" - echo "mail._domainkey 3600 IN TXT \"k=rsa; p=$pub\"" -} - -# PLAIN list function -plain_list() { - echo -e "_domainkey\t3600\tIN\tTXT\t\"t=y; o=~;\"" - echo -e "mail._domainkey\t3600\tIN\tTXT\t\"k=rsa; p=$pub\"" -} - -# CSV list function -csv_list() { - echo "RECORD,TTL,IN,TYPE,VALUE" - echo "_domainkey,3600,IN,TXT,\"\"t=y; o=~;\"\"" - echo "mail._domainkey,3600,IN,TXT,\"\"k=rsa; p=$pub\"\"" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FORMAT]' -is_format_valid 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain keys -if [ -e "$USER_DATA/mail/$domain.pub" ]; then - pub=$(cat $USER_DATA/mail/$domain.pub |grep -v "KEY-----" |tr -d "\n\r") - pub=$(echo "$pub" |sed ':a;N;$!ba;s/\n/\\n/g') -else - pub="DKIM-SUPPORT-IS-NOT-ACTIVATED" -fi - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t -s '^';; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-mail-domains b/bin/v-list-mail-domains deleted file mode 100755 index f6a803b93..000000000 --- a/bin/v-list-mail-domains +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash -# info: list mail domains -# options: USER [FORMAT] -# -# The function of obtaining the list of all user domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(grep DOMAIN $USER_DATA/mail.conf |wc -l) - echo "{" - while read str; do - eval $str - echo -n ' "'$DOMAIN'": { - "ANTIVIRUS": "'$ANTIVIRUS'", - "ANTISPAM": "'$ANTISPAM'", - "DKIM": "'$DKIM'", - "CATCHALL": "'$CATCHALL'", - "ACCOUNTS": "'$ACCOUNTS'", - "U_DISK": "'$U_DISK'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(cat $USER_DATA/mail.conf) - echo '}' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "DOMAIN ANTIVIRUS ANTISPAM DKIM ACC DISK SPND DATE" - echo "------ --------- -------- ---- --- ---- --- ----" - while read str; do - eval $str - echo -n "$DOMAIN $ANTIVIRUS $ANTISPAM $DKIM $ACCOUNTS $U_DISK " - echo "$SUSPENDED $DATE" - done < <(cat $USER_DATA/mail.conf) -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - while read str; do - eval $str - echo -ne "$DOMAIN\t$ANTIVIRUS\t$ANTISPAM\t$DKIM\t$CATCHALL\t" - echo -e "$ACCOUNTS\t$U_DISK\t$SUSPENDED\t$TIME\t$DATE" - done < <(cat $USER_DATA/mail.conf) -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo -n "DOMAIN,ANTIVIRUS,ANTISPAM,DKIM,CATCHALL,ACCOUNTS,U_DISK," - echo "SUSPENDED,TIME,DATE" - while read str; do - eval $str - echo -n "$DOMAIN,$ANTIVIRUS,$ANTISPAM,$DKIM,$CATCHALL,$ACCOUNTS," - echo "'$U_DISK,$SUSPENDED,$TIME,$DATE" - echo - done < <(cat $USER_DATA/mail.conf) -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-remote-dns-hosts b/bin/v-list-remote-dns-hosts deleted file mode 100755 index 63249af23..000000000 --- a/bin/v-list-remote-dns-hosts +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash -# info: list remote dns host -# options: [FORMAT] -# -# The function for obtaining the list of remote dns host. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(grep HOST $VESTA/conf/dns-cluster.conf |wc -l) - echo "{" - while read str; do - eval $str - echo -n ' "'$HOST'": { - "PORT": "'$PORT'", - "TYPE": "'$TYPE'", - "USER": "'$USER'", - "DNS_USER": "'$DNS_USER'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(cat $VESTA/conf/dns-cluster.conf) - echo '}' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "HOST PORT TYPE USER DNS_USER SPND DATE" - echo "---- ---- ---- ---- -------- ---- ----" - while read str; do - eval $str - echo "$HOST $PORT $TYPE $USER $DNS_USER $SUSPENDED $DATE" - done < <(cat $VESTA/conf/dns-cluster.conf) -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - while read str; do - eval $str - echo -ne "$HOST\t$PORT\t$TYPE\t$USER\t$DNS_USER\t" - echo -e "$SUSPENDED\t$TIME\t$DATE" - done < <(cat $VESTA/conf/dns-cluster.conf) -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo "HOST,PORT,TYPE,USER,DNS_USER,SUSPENDED,TIME,DATE" - while read str; do - eval $str - echo "$HOST,$PORT,$TYPE,$USER,$DNS_USER,$SUSPENDED,$TIME,$DATE" - done < <(cat $VESTA/conf/dns-cluster.conf) -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-clamd-config b/bin/v-list-sys-clamd-config deleted file mode 100755 index 1bb614b96..000000000 --- a/bin/v-list-sys-clamd-config +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# info: list clamd config parameters -# options: [FORMAT] -# -# The function for obtaining the list of clamd config parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{ - "CONFIG": { - "config_path": "'$config_path'" - } -}' -} - -# SHELL list function -shell_list() { - echo "config_path: $config_path" -} - -# PLAIN list function -plain_list() { - echo "$config_path" -} - -# CSV list function -csv_list() { - echo "config_path" - echo "$config_path" -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config path -if [ -e '/etc/clamav/clamd.conf' ]; then - config_path='/etc/clamav/clamd.conf' -else - if [ -e '/etc/clamd.conf' ]; then - config_path='/etc/clamd.conf' - fi - if [ -e '/etc/clamd.d/clamd.conf' ]; then - config_path='/etc/clamav/clamd.conf' - fi -fi - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-config b/bin/v-list-sys-config deleted file mode 100755 index 7764af29c..000000000 --- a/bin/v-list-sys-config +++ /dev/null @@ -1,211 +0,0 @@ -#!/bin/bash -# info: list system configuration -# options: [FORMAT] -# -# The function for obtaining the list of system parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -source $VESTA/conf/vesta.conf - -# JSON list function -json_list() { - echo '{ - "config": { - "WEB_SYSTEM": "'$WEB_SYSTEM'", - "WEB_RGROUPS": "'$WEB_RGROUPS'", - "WEB_PORT": "'$WEB_PORT'", - "WEB_SSL": "'$WEB_SSL'", - "WEB_SSL_PORT": "'$WEB_SSL_PORT'", - "WEB_BACKEND": "'$WEB_BACKEND'", - "PROXY_SYSTEM": "'$PROXY_SYSTEM'", - "PROXY_PORT": "'$PROXY_PORT'", - "PROXY_SSL_PORT": "'$PROXY_SSL_PORT'", - "FTP_SYSTEM": "'$FTP_SYSTEM'", - "MAIL_SYSTEM": "'$MAIL_SYSTEM'", - "IMAP_SYSTEM": "'$IMAP_SYSTEM'", - "ANTIVIRUS_SYSTEM": "'$ANTIVIRUS_SYSTEM'", - "ANTISPAM_SYSTEM": "'$ANTISPAM_SYSTEM'", - "DB_SYSTEM": "'$DB_SYSTEM'", - "DNS_SYSTEM": "'$DNS_SYSTEM'", - "DNS_CLUSTER": "'$DNS_CLUSTER'", - "STATS_SYSTEM": "'$STATS_SYSTEM'", - "BACKUP_SYSTEM": "'$BACKUP_SYSTEM'", - "CRON_SYSTEM": "'$CRON_SYSTEM'", - "DISK_QUOTA": "'$DISK_QUOTA'", - "FIREWALL_SYSTEM": "'$FIREWALL_SYSTEM'", - "FIREWALL_EXTENSION": "'$FIREWALL_EXTENSION'", - "FILEMANAGER_KEY": "'$FILEMANAGER_KEY'", - "SFTPJAIL_KEY": "'$SFTPJAIL_KEY'", - "REPOSITORY": "'$REPOSITORY'", - "VERSION": "'$VERSION'", - "LANGUAGE": "'$LANGUAGE'", - "BACKUP_GZIP": "'$BACKUP_GZIP'", - "BACKUP": "'$BACKUP'", - "MAIL_URL": "'$MAIL_URL'", - "DB_PMA_URL": "'$DB_PMA_URL'", - "DB_PGA_URL": "'$DB_PGA_URL'", - "SOFTACULOUS": "'$SOFTACULOUS'", - "MAIL_CERTIFICATE": "'$MAIL_CERTIFICATE'", - "VESTA_CERTIFICATE": "'$VESTA_CERTIFICATE'" - } -}' -} - -# Shell list -shell_list() { - if [ ! -z "$WEB_SYSTEM" ]; then - echo "WEB Server: $WEB_SYSTEM:$WEB_PORT ($WEB_RGROUPS)" - echo "SSL Support: $WEB_SSL:$WEB_SSL_PORT" - fi - if [ ! -z "$WEB_BACKEND" ]; then - echo "WEB Backend: $WEB_BACKEND" - fi - if [ ! -z "$PROXY_SYSTEM" ]; then - echo "Proxy Server: $PROXY_SYSTEM:$PROXY_PORT" - echo "Proxy SSL: $PROXY_SYSTEM:$PROXY_SSL_PORT" - fi - if [ ! -z "$STATS_SYSTEM" ]; then - echo "Web Stats: ${STATS_SYSTEM//,/, }" - fi - if [ ! -z "$FTP_SYSTEM" ]; then - echo "FTP Server: $FTP_SYSTEM" - fi - if [ ! -z "$MAIL_SYSTEM" ]; then - echo -n "Mail Server: $MAIL_SYSTEM" - if [ ! -z "$IMAP_SYSTEM" ]; then - echo -n " + $IMAP_SYSTEM" - fi - if [ ! -z "$ANTIVIRUS_SYSTEM" ]; then - echo -n " + $ANTIVIRUS_SYSTEM" - fi - if [ ! -z "$ANTISPAM_SYSTEM" ]; then - echo -n " + $ANTISPAM_SYSTEM" - fi - echo - if [ ! -z "$MAIL_URL" ]; then - echo "Web Mail: hostname + $MAIL_URL" - fi - fi - if [ ! -z "$DB_SYSTEM" ]; then - echo "Database: ${DB_SYSTEM//,/, }" - if [ ! -z "$DB_PMA_URL" ]; then - echo "PMA URL: $DB_PMA_URL" - fi - if [ ! -z "$DB_PGA_URL" ]; then - echo "PGA URL: $DB_PGA_URL" - fi - fi - if [ ! -z "$DNS_SYSTEM" ]; then - echo -n "DNS server: $DNS_SYSTEM" - if [ ! -z "$DNS_CLUSTER" ]; then - echo -n " (cluster)" - fi - echo - fi - if [ ! -z "$CRON_SYSTEM" ]; then - echo "CRON: $CRON_SYSTEM" - fi - if [ ! -z "$FIREWALL_SYSTEM" ]; then - echo -n "Firewall: $FIREWALL_SYSTEM" - if [ ! -z "$FIREWALL_EXTENSION" ]; then - echo -n "+ $FIREWALL_EXTENSION" - fi - echo - fi - if [ ! -z "$BACKUP_SYSTEM" ]; then - echo "Backups: ${BACKUP_SYSTEM//,/, }" - if [ ! -z "$BACKUP" ]; then - echo "Backup Dir: $BACKUP" - fi - fi - if [ ! -z "$DISK_QUOTA" ]; then - echo "Disk Quota: $DISK_QUOTA" - fi - if [ ! -z "$FILEMANAGER_KEY" ]; then - echo "FileManager: $FILEMANAGER_KEY" - fi - if [ ! -z "$SFTPJAIL_KEY" ]; then - echo "SFTP Chroot: $SFTPJAIL_KEY" - fi - if [ ! -z "$SOFTACULOUS" ]; then - echo "Softaculous: $SOFTACULOUS" - fi - if [ ! -z "$LANGUAGE" ] && [ "$LANGUAGE" != 'en' ]; then - echo "Language: $LANGUAGE" - fi - if [ ! -z "$MAIL_CERTIFICATE" ]; then - echo "Mail SSL: $MAIL_CERTIFICATE" - fi - if [ ! -z "$VESTA_CERTIFICATE" ]; then - echo "Vesta SSL: $VESTA_CERTIFICATE" - fi - echo "Version: $VERSION" -} - -# PLAIN list function -plain_list() { - echo -ne "$WEB_SYSTEM\t$WEB_RGROUPS\t$WEB_PORT\t$WEB_SSL\t" - echo -ne "$WEB_SSL_PORT\t$WEB_BACKEND\t$PROXY_SYSTEM\t$PROXY_PORT\t" - echo -ne "$PROXY_SSL_PORT\t$FTP_SYSTEM\t$MAIL_SYSTEM\t$IMAP_SYSTEM\t" - echo -ne "$ANTIVIRUS_SYSTEM\t$ANTISPAM_SYSTEM\t$DB_SYSTEM\t" - echo -ne "$DNS_SYSTEM\t$DNS_CLUSTER\t$STATS_SYSTEM\t$BACKUP_SYSTEM\t" - echo -ne "$CRON_SYSTEM\t$DISK_QUOTA\t$FIREWALL_SYSTEM\t" - echo -ne "$FIREWALL_EXTENSION\t$FILEMANAGER_KEY\t$SFTPJAIL_KEY\t" - echo -ne "$REPOSITORY\t$VERSION\t$LANGUAGE\t$BACKUP_GZIP\t$BACKUP\t" - echo -ne "$MAIL_URL\t$DB_PMA_URL\t$DB_PGA_URL\t$MAIL_CERTIFICATE\t" - echo -e "$VESTA_CERTIFICATE" -} - - -# CSV list -csv_list() { - echo -n "'WEB_SYSTEM','WEB_RGROUPS','WEB_PORT','WEB_SSL'," - echo -n "'WEB_SSL_PORT','WEB_BACKEND','PROXY_SYSTEM','PROXY_PORT'," - echo -n "'PROXY_SSL_PORT','FTP_SYSTEM','MAIL_SYSTEM','IMAP_SYSTEM'," - echo -n "'ANTIVIRUS_SYSTEM','ANTISPAM_SYSTEM','DB_SYSTEM'," - echo -n "'DNS_SYSTEM','DNS_CLUSTER','STATS_SYSTEM','BACKUP_SYSTEM'," - echo -n "'CRON_SYSTEM','DISK_QUOTA','FIREWALL_SYSTEM'," - echo -n "'FIREWALL_EXTENSION','FILEMANAGER_KEY','SFTPJAIL_KEY'," - echo -n "'REPOSITORY','VERSION','LANGUAGE','BACKUP_GZIP','BACKUP'," - echo -n "'MAIL_URL','DB_PMA_URL','DB_PGA_URL', 'SOFTACULOUS'," - echo -n "'MAIL_CERTIFICATE','VESTA_CERTIFICATE'" - echo - echo -n "'$WEB_SYSTEM','$WEB_RGROUPS','$WEB_PORT','$WEB_SSL'," - echo -n "'$WEB_SSL_PORT','$WEB_BACKEND','$PROXY_SYSTEM','$PROXY_PORT'," - echo -n "'$PROXY_SSL_PORT','$FTP_SYSTEM','$MAIL_SYSTEM','$IMAP_SYSTEM'," - echo -n "'$ANTIVIRUS_SYSTEM','$ANTISPAM_SYSTEM','$DB_SYSTEM'," - echo -n "'$DNS_SYSTEM','$DNS_CLUSTER','$STATS_SYSTEM','$BACKUP_SYSTEM'," - echo -n "'$CRON_SYSTEM','$DISK_QUOTA','$FIREWALL_SYSTEM'," - echo -n "'$FIREWALL_EXTENSION','$FILEMANAGER_KEY','$SFTPJAIL_KEY'," - echo -n "'$REPOSITORY','$VERSION','$LANGUAGE','$BACKUP_GZIP','$BACKUP'," - echo -n "'$MAIL_URL','$DB_PMA_URL','$DB_PGA_URL', '$SOFTACULOUS'" - echo -n "'$MAIL_CERTIFICATE','$VESTA_CERTIFICATE'" - echo -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-cpu-status b/bin/v-list-sys-cpu-status deleted file mode 100755 index 290ad5b24..000000000 --- a/bin/v-list-sys-cpu-status +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -# info: list system cpu info -# options: [FORMAT] -# -# The function lists cpu information - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -#format=${1-shell} - -# Includes -#source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Displaying top 30 -top -b -n1 | head -n 37 -echo -en "\n-------------------------------------" -echo -en "-------------------------------------\n\n" - -# Displaying process tree -pstree -s -echo -en "\n-------------------------------------" -echo -en "-------------------------------------\n\n" - -# Displaying CPU information -grep 'model name' /proc/cpuinfo|cut -f 2 -d : | sed "s/ //" -echo -lscpu 2>/dev/null - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-db-status b/bin/v-list-sys-db-status deleted file mode 100755 index d3dbe2f7b..000000000 --- a/bin/v-list-sys-db-status +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash -# info: list db status -# options: [FORMAT] -# -# The function lists db server status - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -#format=${1-shell} - -# Includes -#source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking db system -if [ -z "$DB_SYSTEM" ]; then - exit -fi - -# Checking supported database systems -for db in $(echo $DB_SYSTEM| tr ',' '\n'); do - OLD_IFS="$IFS" - IFS=$'\n' - - # Checking database config - if [ -e "$VESTA/conf/$db.conf" ]; then - - # Checking server status - for host_str in $(cat $VESTA/conf/$db.conf); do - eval $host_str - - # Checking MySQL - if [ "$db" = 'mysql' ]; then - mycnf="$VESTA/conf/.mysql.$HOST" - if [ ! -e "$mycnf" ]; then - echo "[client]">$mycnf - echo "host='$HOST'" >> $mycnf - echo "user='$USER'" >> $mycnf - echo "password='$PASSWORD'" >> $mycnf - chmod 600 $mycnf - else - mypw=$(grep password $mycnf|cut -f 2 -d \') - if [ "$mypw" != "$PASSWORD" ]; then - echo "[client]">$mycnf - echo "host='$HOST'" >> $mycnf - echo "user='$USER'" >> $mycnf - echo "password='$PASSWORD'" >> $mycnf - chmod 660 $mycnf - fi - fi - echo "MySQL $HOST status" - mysqladmin --defaults-file=$mycnf status |sed -e "s/ /\n/g" - echo - mysqladmin --defaults-file=$mycnf processlist - echo -en "\n-------------------------------------" - echo -en "-------------------------------------\n\n" - fi - - # Checking PostgreSQL - if [ "$db" = 'pgsql' ] && [ ! -z "$(which psql)" ]; then - echo "PostgreSQL $HOST status" - export PGPASSWORD="$PASSWORD" - psql -h $HOST -U $USER -c "SELECT * FROM pg_stat_activity" - fi - done - fi - IFS="$OLD_IFS" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-disk-status b/bin/v-list-sys-disk-status deleted file mode 100755 index 5596a449c..000000000 --- a/bin/v-list-sys-disk-status +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# info: list disk information -# options: [FORMAT] -# -# The function lists disk information - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -#format=${1-shell} - -# Includes -#source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Displaying disk usage -df -h -echo -en "\n-------------------------------------" -echo -en "-------------------------------------\n\n" - -# Displaying I/O usage -iostat -m -echo -en "\n-------------------------------------" -echo -en "-------------------------------------\n\n" - -# Displaying disk information -fdisk -l - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-dns-status b/bin/v-list-sys-dns-status deleted file mode 100755 index b657bc891..000000000 --- a/bin/v-list-sys-dns-status +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -# info: list dns status -# options: [FORMAT] -# -# The function lists dns server status - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -#format=${1-shell} - -# Includes -#source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking dns system -if [ -z "$DNS_SYSTEM" ]; then - exit -fi - -# Checking statistics-file on RHEL/CentOS -if [ -e "/etc/named/named.conf" ]; then - conf="/etc/named/named.conf" - dump_file='/var/named/data/named_stats.txt' - dump_option=" dump-file \"$dump_file\";" - opt_check=$(grep $dump_file $conf |grep -v //) - if [ -z "$opt_check" ]; then - sed -i "s|options {|options {\n$dump_option|" $conf - service named restart >/dev/null 2>&1 - fi -fi -if [ -e "/etc/named.conf" ]; then - conf="/etc/named.conf" - dump_file='/var/named/data/named_stats.txt' - dump_option=" dump-file \"$dump_file\";" - opt_check=$(grep $dump_file $conf |grep -v //) - if [ -z "$opt_check" ]; then - sed -i "s|options {|options {\n$dump_option|" $conf - service named restart >/dev/null 2>&1 - fi -fi - -# Checking statistics-file on Debian/Ubuntu -if [ -e "/etc/bind/named.conf" ]; then - conf="/etc/bind/named.conf.options" - dump_file='/var/cache/bind/named.stats' - #dump_option=" dump-file \"$dump_file\";" - #opt_check=$(grep $dump_file $conf |grep -v //) - #if [ -z "$opt_check" ]; then - # sed -i "s|options {|options {\n$dump_option|" $conf - # service named restart >/dev/null 2>&1 - #fi -fi - -# Generating dns stats -rm -f $dump_file 2>/dev/null -/usr/sbin/rndc stats 2>/dev/null - -# Displaying dns status -if [ -e "$dump_file" ]; then - cat $dump_file -fi - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-dovecot-config b/bin/v-list-sys-dovecot-config deleted file mode 100755 index 873755866..000000000 --- a/bin/v-list-sys-dovecot-config +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash -# info: list dovecot config parameters -# options: [FORMAT] -# -# The function for obtaining the list of dovecot config parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{ - "CONFIG": { - "config_path": "'$config_path'", - "config_path1": "'$config_path1'", - "config_path2": "'$config_path2'", - "config_path3": "'$config_path3'", - "config_path4": "'$config_path4'", - "config_path5": "'$config_path5'", - "config_path6": "'$config_path6'", - "config_path7": "'$config_path7'", - "config_path8": "'$config_path8'" - } -}' -} - -# SHELL list function -shell_list() { - echo "config_path: $config_path" - echo "config_path1: $config_path1" - echo "config_path2: $config_path2" - echo "config_path3: $config_path3" - echo "config_path4: $config_path4" - echo "config_path5: $config_path5" - echo "config_path6: $config_path6" - echo "config_path7: $config_path7" - echo "config_path8: $config_path8" -} - -# PLAIN list function -plain_list() { - echo -en "$config_path\t" - echo -en "$config_path1\t" - echo -en "$config_path2\t" - echo -en "$config_path3\t" - echo -en "$config_path4\t" - echo -en "$config_path5\t" - echo -en "$config_path6\t" - echo -en "$config_path7\t" - echo -e "$config_path8\t" -} - -# CSV list function -csv_list() { - echo -n "config_path,config_path1,config_path2,config_path3," - echo "config_path4,config_path5,config_path6,config_path7,config_path8" - echo -n "$config_path,$config_path1,$config_path2,$config_path3," - echo -n "$config_path4,$config_path5,$config_path6,$config_path7," - echo "$config_path8" -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config path -if [ -e '/etc/dovecot.conf' ]; then - config_path='/etc/dovecot.conf' -else - config_path='/etc/dovecot/dovecot.conf' - config_path1='/etc/dovecot/conf.d/10-auth.conf' - config_path2='/etc/dovecot/conf.d/10-logging.conf' - config_path3='/etc/dovecot/conf.d/10-mail.conf' - config_path4='/etc/dovecot/conf.d/10-master.conf' - config_path5='/etc/dovecot/conf.d/10-ssl.conf' - config_path6='/etc/dovecot/conf.d/20-imap.conf' - config_path7='/etc/dovecot/conf.d/20-pop3.conf' - config_path8='/etc/dovecot/conf.d/auth-passwdfile.conf.ext' -fi - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-info b/bin/v-list-sys-info deleted file mode 100755 index 0072b82b7..000000000 --- a/bin/v-list-sys-info +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash -# info: list system os -# options: [FORMAT] -# -# The function checks available updates for vesta packages. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{' - echo ' "sysinfo": { - "HOSTNAME": "'$HOSTNAME'", - "OS": "'$OS'", - "VERSION": "'$VERSION'", - "ARCH": "'$ARCH'", - "UPTIME": "'$UPTIME'", - "LOADAVERAGE": "'$LOADAVERAGE'" - }' - echo '}' -} - -# SHELL list function -shell_list() { - echo "HOSTNAME OS VER ARCH UPTIME LA" - echo "-------- -- --- ---- ------ --" - echo "$HOSTNAME $OS $VERSION $ARCH $UPTIME $LOADAVERAGE" -} - -# PLAIN list function -plain_list() { - echo -e "$HOSTNAME\t$OS\t$VERSION\t$ARCH\t$UPTIME\t$LOADAVERAGE" -} - -# CSV list function -csv_list() { - echo "HOSTNAME,OS,VERSION,ARCH,UPTIME,LOADAVERAGE" - echo "$HOSTNAME,$OS,$VERSION,$ARCH,$UPTIME,$LOADAVERAGE" -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Check hostname -HOSTNAME=$(hostname) - -# Check OS/Release -if [ -d '/etc/sysconfig' ]; then - if [ -e '/etc/redhat-release' ]; then - OS='CentOS' - VERSION=$(cat /etc/redhat-release |tr ' ' '\n' |grep [0-9]) - else - OS="Amazon" - VERSION=$(cat /etc/issue |tr ' ' '\n' |grep [0-9]) - fi -else - if [ "$(lsb_release -si)" == "Ubuntu" ] && [ -e '/etc/debian_version' ]; then - OS="Ubuntu" - VERSION=$(grep DISTRIB_RELEASE /etc/lsb-release |cut -f 2 -d '=') - else - distro=$(head -n1 /etc/issue |cut -f 1 -d ' ') - if [ "$distro" = 'Debian' ]; then - OS="Debian" - VERSION=$(cat /etc/debian_version) - else - OS='UNKNOWN' - VERSION='UNKNOWN' - fi - fi -fi - -# Check architecture -ARCH=$(arch) - -# Check uptime -UPTIME=$(cat /proc/uptime |cut -f 1 -d ' '|cut -f 1 -d .) -UPTIME="$(echo $UPTIME / 60 |bc)" - -# Check LoadAverage -LOADAVERAGE=$(cat /proc/loadavg |cut -f 1 -d ' ') - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-interfaces b/bin/v-list-sys-interfaces deleted file mode 100755 index 990d9cfd8..000000000 --- a/bin/v-list-sys-interfaces +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# info: list system interfaces -# options: [FORMAT] -# -# The function for obtaining the list of network interfaces. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - objects=$(echo "$interfaces" |wc -l) - i=1 - echo '[' - for interface in $interfaces; do - echo -n ' "'$interface'"' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done - echo ']' -} - -# SHELL list function -shell_list() { - echo "INTERFACE" - echo "---------" - for interface in $interfaces; do - echo "$interface" - done -} - -# PLAIN list function -plain_list() { - for interface in $interfaces; do - echo "$interface" - done -} - -# CSV list function -csv_list() { - echo "INTERFACE" - for interface in $interfaces; do - echo "$interface" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining interface list -interfaces=$(cat /proc/net/dev |grep : |cut -f 1 -d : |tr -d ' ' |grep -v lo) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-ip b/bin/v-list-sys-ip deleted file mode 100755 index 3a7658c5a..000000000 --- a/bin/v-list-sys-ip +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash -# info: list system ip -# options: IP [FORMAT] -# -# The function for getting the list of system ip parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -ip=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh - -# JSON list function -json_list() { - echo '{' - echo ' "'$ip'": { - "OWNER": "'$OWNER'", - "STATUS": "'$STATUS'", - "NAME": "'$NAME'", - "U_SYS_USERS": "'$U_SYS_USERS'", - "U_WEB_DOMAINS": "'$U_WEB_DOMAINS'", - "INTERFACE": "'$INTERFACE'", - "NETMASK": "'$NETMASK'", - "NAT": "'$NAT'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - echo '}' -} - -# SHELL list function -shell_list() { - echo "IP: $ip" - echo "NETMASK: $NETMASK" - echo "INTERFACE: $INTERFACE" - echo "NAT: $NAT" - echo "OWNER: $OWNER" - echo "STATUS: $STATUS" - echo "NAME: $NAME" - echo "USERS: $U_SYS_USERS" - echo "DOMAINS: $U_WEB_DOMAINS" - echo "TIME: $TIME" - echo "DATE: $DATE" -} - -# PLAIN list function -plain_list() { - echo -ne "$IP\t$OWNER\t$STATUS\t$NAME\t$U_SYS_USERS\t$U_WEB_DOMAINS\t" - echo -e "$INTERFACE\t$NETMASK\t$NAT\t$TIME\t$DATE" -} - -# CSV list function -csv_list() { - echo -n "IP,OWNER,STATUS,NAME,U_SYS_USERS,U_WEB_DOMAINS,INTERFACE" - echo "NETMASK,NAT,TIME,DATE" - echo -n "$IP,$OWNER,$STATUS,$NAME,\"$U_SYS_USERS\",$U_WEB_DOMAINS," - echo "$INTERFACE, $NETMASK,$NAT,$TIME,$DATE" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'IP [FORMAT]' -is_format_valid 'ip' -if [ ! -e "$VESTA/data/ips/$ip" ]; then - check_result $E_NOTEXIST "ip $ip doesn't exist" -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing ip -source $VESTA/data/ips/$ip - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-ips b/bin/v-list-sys-ips deleted file mode 100755 index c4f3a8c0c..000000000 --- a/bin/v-list-sys-ips +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# info: list system ips -# options: [FORMAT] -# -# The function for obtaining the list of system ip adresses. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{' - ip_count=$(ls $VESTA/data/ips/ |wc -l) - i=1 - while read IP; do - source $VESTA/data/ips/$IP - echo -n ' "'$IP'": { - "OWNER": "'$OWNER'", - "STATUS": "'$STATUS'", - "NAME": "'$NAME'", - "U_SYS_USERS": "'$U_SYS_USERS'", - "U_WEB_DOMAINS": "'$U_WEB_DOMAINS'", - "INTERFACE": "'$INTERFACE'", - "NETMASK": "'$NETMASK'", - "NAT": "'$NAT'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$ip_count" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(ls $VESTA/data/ips/) - echo '}' -} - -# SHELL list function -shell_list() { - echo "IP MASK NAT STATUS WEB DATE" - echo "-- ---- --- ------ --- ----" - while read IP; do - source $VESTA/data/ips/$IP - if [ -z "$NAT" ]; then - NAT='no' - fi - echo "$IP $NETMASK $NAT $STATUS $U_WEB_DOMAINS $DATE" - done < <(ls $VESTA/data/ips/) -} - -# PLAIN list function -plain_list() { - while read IP; do - source $VESTA/data/ips/$IP - echo -ne "$IP\t$OWNER\t$STATUS\t$NAME\t$U_SYS_USERS\t$U_WEB_DOMAINS\t" - echo -e "$INTERFACE\t$NETMASK\t$NAT\t$TIME\t$DATE" - done < <(ls $VESTA/data/ips/) -} - -# CSV list function -csv_list() { - echo -n "IP,OWNER,STATUS,NAME,U_SYS_USERS,U_WEB_DOMAINS,INTERFACE" - echo "NETMASK,NAT,TIME,DATE" - while read IP; do - source $VESTA/data/ips/$IP - echo -n "$IP,$OWNER,$STATUS,$NAME,\"$U_SYS_USERS\",$U_WEB_DOMAINS," - echo "$INTERFACE, $NETMASK,$NAT,$TIME,$DATE" - done < <(ls $VESTA/data/ips/) -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-languages b/bin/v-list-sys-languages deleted file mode 100755 index 041bc1236..000000000 --- a/bin/v-list-sys-languages +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# info: list system users -# options: [FORMAT] -# -# The function for obtaining the list of system users without -# detailed information. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - objects=$(echo "$languages" |wc -l) - i=1 - echo '[' - for lang in $languages; do - if [ "$i" -lt "$objects" ]; then - echo -e "\t\"$lang\"," - else - echo -e "\t\"$lang\"" - fi - (( ++i)) - done - echo "]" -} - -# SHELL list function -shell_list() { - echo "LANGUAGE" - echo "--------" - for lang in $languages; do - echo "$lang" - done -} - -# PLAIN list function -plain_list() { - for lang in $languages; do - echo "$lang" - done -} - -# CSV list function -csv_list() { - echo "LANGUAGE" - for lang in $languages; do - echo "$lang" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining language list -languages=$(ls $VESTA/web/inc/i18n/ |cut -f 1 -d .) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-mail-ssl b/bin/v-list-sys-mail-ssl deleted file mode 100755 index 5da74e080..000000000 --- a/bin/v-list-sys-mail-ssl +++ /dev/null @@ -1,135 +0,0 @@ -#!/bin/bash -# info: list mail ssl certificate -# options: [FORMAT] -# -# The function of obtaining mail ssl files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{' - echo -e "\t\"MAIL\": {" - echo " \"CRT\": \"$crt\"," - echo " \"KEY\": \"$key\"," - echo " \"CA\": \"$ca\"," - echo " \"SUBJECT\": \"$subj\"," - echo " \"ALIASES\": \"$alt_dns\"," - echo " \"NOT_BEFORE\": \"$before\"," - echo " \"NOT_AFTER\": \"$after\"," - echo " \"SIGNATURE\": \"$signature\"," - echo " \"PUB_KEY\": \"$pub_key\"," - echo " \"ISSUER\": \"$issuer\"" - echo -e "\t}\n}" -} - -# SHELL list function -shell_list() { - if [ ! -z "$crt" ]; then - echo -e "$crt" - fi - if [ ! -z "$key" ]; then - echo -e "\n$key" - fi - if [ ! -z "$crt" ]; then - echo - echo - echo "SUBJECT: $subj" - if [ ! -z "$alt_dns" ]; then - echo "ALIASES: ${alt_dns//,/ }" - fi - echo "VALID FROM: $before" - echo "VALID TIL: $after" - echo "SIGNATURE: $signature" - echo "PUB_KEY: $pub_key" - echo "ISSUER: $issuer" - fi -} - -# PLAIN list function -plain_list() { - if [ ! -z "$crt" ]; then - echo -e "$crt" - fi - if [ ! -z "$key" ]; then - echo -e "\n$key" - fi - if [ ! -z "$ca" ]; then - echo -e "\n$ca" - fi - if [ ! -z "$crt" ]; then - echo "$subj" - echo "${alt_dns//,/ }" - echo "$before" - echo "$after" - echo "$signature" - echo "$pub_key" - echo "$issuer" - fi - -} - -# CSV list function -csv_list() { - echo -n "CRT,KEY,CA,SUBJECT,ALIASES,NOT_BEFORE,NOT_AFTER,SIGNATURE," - echo "PUB_KEY,ISSUER" - echo -n "\"$crt\",\"$key\",\"$ca\",\"$subj\",\"${alt_dns//,/ }\"," - echo "\"$before\",\"$after\",\"$signature\",\"$pub_key\",\"$issuer\"" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing SSL certificate -if [ ! -e "$VESTA/ssl/mail.crt" ] || [ ! -e "$VESTA/ssl/mail.key" ]; then - exit -fi - -crt=$(cat $VESTA/ssl/mail.crt |sed ':a;N;$!ba;s/\n/\\n/g') -key=$(cat $VESTA/ssl/mail.key |sed ':a;N;$!ba;s/\n/\\n/g') - - -# Parsing SSL certificate details without CA -info=$(openssl x509 -text -in $VESTA/ssl/mail.crt) -subj=$(echo "$info" |grep Subject: |cut -f 2 -d =) -before=$(echo "$info" |grep Before: |sed -e "s/.*Before: //") -after=$(echo "$info" |grep "After :" |sed -e "s/.*After : //") -signature=$(echo "$info" |grep "Algorithm:" |head -n1 ) -signature=$(echo "$signature"| sed -e "s/.*Algorithm: //") -pub_key=$(echo "$info" |grep Public-Key: |cut -f2 -d \( | tr -d \)) -issuer=$(echo "$info" |grep Issuer: |sed -e "s/.*Issuer: //") -alt_dns=$(echo "$info" |grep DNS |sed -e 's/DNS:/\n/g' |tr -d ',') -alt_dns=$(echo "$alt_dns" |tr -d ' ' |sed -e "/^$/d") -alt_dns=$(echo "$alt_dns" |sed -e ':a;N;$!ba;s/\n/,/g') - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-mail-status b/bin/v-list-sys-mail-status deleted file mode 100755 index fcf5fbc4b..000000000 --- a/bin/v-list-sys-mail-status +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# info: list mail status -# options: [FORMAT] -# -# The function lists mail server status - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -#format=${1-shell} - -# Includes -#source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking mail system -if [ -z "$MAIL_SYSTEM" ]; then - exit -fi - -# Displaying exim queue status -echo "Exim queue status" -exim -bp -echo -en "\n-------------------------------------" -echo -en "-------------------------------------\n\n" - -# Displaying exim stats -if [ -e "/var/log/exim4/mainlog" ]; then - eximstats /var/log/exim4/mainlog 2>/dev/null -else - eximstats /var/log/exim/main.log 2>/dev/null -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-memory-status b/bin/v-list-sys-memory-status deleted file mode 100755 index 25b7ebff6..000000000 --- a/bin/v-list-sys-memory-status +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# info: list virtual memory info -# options: [FORMAT] -# -# The function lists virtual memory information - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -#format=${1-shell} - -# Includes -#source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Displaying memory and swap usage -free -t -m -echo -en "\n-------------------------------------" -echo -en "-------------------------------------\n\n" - -# Displaying memory stats -vmstat -S m -s -echo -en "\n-------------------------------------" -echo -en "-------------------------------------\n\n" - -# Displaying ram information -dmidecode -t 17 2>/dev/null - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-mysql-config b/bin/v-list-sys-mysql-config deleted file mode 100755 index bf297aab0..000000000 --- a/bin/v-list-sys-mysql-config +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash -# info: list mysql config parameters -# options: [FORMAT] -# -# The function for obtaining the list of mysql config parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# JSON list function -json_list() { - eval $(echo "$config"|egrep "$keys"|\ - sed -e "s/[ ]*=/=/" -e "s/=[ ]*/=\'/" -e "s/$/'/") - echo '{ - "CONFIG": { - "max_user_connections": "'$max_user_connections'", - "max_connections": "'$max_connections'", - "wait_timeout": "'$wait_timeout'", - "interactive_timeout": "'$interactive_timeout'", - "max_allowed_packet": "'$max_allowed_packet'", - "config_path": "'$config_path'" - } -}' -} - -# SHELL list function -shell_list() { - echo "$config" |egrep "$keys" |tr '=' ' ' - echo "config_path $config_path" -} - -# PLAIN list function -plain_list() { - echo "$config" |egrep "$keys" |tr '=' ' ' - echo "config_path $config_path" -} - -# CSV list function -csv_list() { - echo "$keys" |sed "s/|/,/g" - echo "$config" |egrep "$keys" |tr '=' ' ' |awk '{print $2}' |tr '\n' ',' - echo -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config path -config_path=$(find /etc/my* -name my.cnf) - -# Defining keys -keys="max_user_connections|max_connections|wait_timeout|interactive_timeout" -keys="${keys}|max_allowed_packet" - -# Reading config -config=$(cat $config_path|grep -v "^;") - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-network-status b/bin/v-list-sys-network-status deleted file mode 100755 index 8414f8009..000000000 --- a/bin/v-list-sys-network-status +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# info: list system network status -# options: [FORMAT] -# -# The function lists network status - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -#format=${1-shell} - -# Includes -#source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Displaying network stats -ss -s -echo -en "\n-------------------------------------" -echo -en "-------------------------------------\n\n" - -# Displaying network usage -lsof -itcp -n -P -echo -en "\n-------------------------------------" -echo -en "-------------------------------------\n\n" - -# Displaying network interfaces -ifconfig - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-nginx-config b/bin/v-list-sys-nginx-config deleted file mode 100755 index c365caa78..000000000 --- a/bin/v-list-sys-nginx-config +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -# info: list nginx config parameters -# options: [FORMAT] -# -# The function for obtaining the list of nginx config parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - eval $(echo "$config" |egrep "$keys" |tr -d ';'| awk '{print $1"="$2}') - echo '{ - "CONFIG": { - "worker_processes": "'$worker_processes'", - "worker_connections": "'$worker_connections'", - "send_timeout": "'$send_timeout'", - "proxy_connect_timeout": "'$proxy_connect_timeout'", - "proxy_send_timeout": "'$proxy_send_timeout'", - "proxy_read_timeout": "'$proxy_read_timeout'", - "client_max_body_size": "'$client_max_body_size'", - "gzip": "'$gzip'", - "gzip_comp_level": "'$gzip_comp_level'", - "charset": "'$charset'", - "config_path": "'$config_path'" - } -}' -} - -# SHELL list function -shell_list() { - echo "$config" |egrep "$keys" |tr -d ';' - echo "config_path $config_path" -} - -# PLAIN list function -plain_list() { - echo "$config" |egrep "$keys" |tr -d ';' - echo "config_path $config_path" -} - -# CSV list function -csv_list() { - echo "$keys" |sed "s/ |/,/g" - echo "$config" |egrep "$keys" |awk '{print $2}' |tr -d ';' |tr '\n' ',' - echo -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config path -config_path='/etc/nginx/nginx.conf' - -# Defining keys -keys="worker_processes |worker_connections |send_timeout" -keys="$keys |proxy_connect_timeout |proxy_send_timeout" -keys="$keys |proxy_read_timeout |client_max_body_size" -keys="$keys |gzip |gzip_comp_level |charset " - - -# Reading nginx config -config=$(cat $config_path) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-pgsql-config b/bin/v-list-sys-pgsql-config deleted file mode 100755 index f568f1079..000000000 --- a/bin/v-list-sys-pgsql-config +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# info: list postgresql config parameters -# options: [FORMAT] -# -# The function for obtaining the list of postgresql config parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{ - "CONFIG": { - "pg_hba_path": "'$pg_hba_path'", - "config_path": "'$config_path'" - } -}' -} - -# SHELL list function -shell_list() { - echo "config_path: $config_path" - echo "pg_hba_path: $pg_hba_path" -} - -# PLAIN list function -plain_list() { - echo -e "$config_path\t$pg_hba_path" -} - -# CSV list function -csv_list() { - echo "config_path,pg_hba_path" - echo "$config_path,$pg_hba_path" -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config path -config_path=$(find /etc/postgresql /var/lib/pgsql/data -name \ - postgresql.conf 2>/dev/null) -pg_hba_path=$(find /etc/postgresql /var/lib/pgsql/data -name \ - pg_hba.conf 2>/dev/null) - - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-php-config b/bin/v-list-sys-php-config deleted file mode 100755 index b00902719..000000000 --- a/bin/v-list-sys-php-config +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash -# info: list php config parameters -# options: [FORMAT] -# -# The function for obtaining the list of php config parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# JSON list function -json_list() { - eval $(echo "$config"|egrep "$keys"|\ - sed -e "s/[ ]*=/=/" -e "s/=[ ]*/=\'/" -e "s/$/'/") - echo '{ - "CONFIG": { - "memory_limit": "'$memory_limit'", - "max_execution_time": "'$max_execution_time'", - "max_input_time": "'$max_input_time'", - "upload_max_filesize": "'$upload_max_filesize'", - "post_max_size": "'$post_max_size'", - "display_errors": "'$display_errors'", - "error_reporting": "'$error_reporting'", - "config_path": "'$config_path'" - } -}' -} - -# SHELL list function -shell_list() { - echo "$config" |egrep "$keys" |tr -d '=' - echo "config_path $config_path" -} - -# PLAIN list function -plain_list() { - echo "$config" |egrep "$keys" |tr -d '=' - echo "config_path $config_path" -} - -# CSV list function -csv_list() { - echo "$keys" |sed "s/ |/,/g" - echo "$config" |egrep "$keys" |tr -d '=' |awk '{print $2}' |tr '\n' ',' - echo -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config path -config_path=$(find /etc/php* -name php.ini) -config_count=$(echo "$config_path" |wc -l) -if [ "$config_count" -gt 1 ]; then - if [ "$WEB_SYSTEM" = "nginx" ]; then - config_path=$(echo "$config_path"| grep fpm) - else - config_path=$(echo "$config_path"| grep apache) - fi -fi - - -# Defining keys -keys="memory_limit |max_execution_time |max_input_time" -keys="$keys |upload_max_filesize |post_max_size" -keys="$keys |display_errors |error_reporting " - -# Reading config -config=$(cat $config_path|grep -v "^;") - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-proftpd-config b/bin/v-list-sys-proftpd-config deleted file mode 100755 index f0b35502f..000000000 --- a/bin/v-list-sys-proftpd-config +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# info: list proftpd config parameters -# options: [FORMAT] -# -# The function for obtaining the list of proftpd config parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{ - "CONFIG": { - "config_path": "'$config_path'" - } -}' -} - -# SHELL list function -shell_list() { - echo "config_path: $config_path" -} - -# PLAIN list function -plain_list() { - echo "$config_path" -} - -# CSV list function -csv_list() { - echo "config_path" - echo "$config_path" -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config path -config_path=$(find /etc/proftpd* -name proftpd.conf 2>/dev/null) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-rrd b/bin/v-list-sys-rrd deleted file mode 100755 index d746896c4..000000000 --- a/bin/v-list-sys-rrd +++ /dev/null @@ -1,162 +0,0 @@ -#!/bin/bash -# info: list system rrd charts -# options: [FORMAT] -# -# List available rrd graphics, its titles and paths. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# JSON list function -json_list() { - i=1 - echo "{" - - # Generating timestamp - time_n_date=$(date +'%T %F') - TIME=$(echo "$time_n_date" |cut -f 1 -d \ ) - DATE=$(echo "$time_n_date" |cut -f 2 -d \ ) - - for type in $rrd_types; do - for rrd in $(ls $RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do - if [ "$i" -ne 1 ]; then - echo -e "\t}," - fi - if [ "$type" = 'la' ]; then - title="Load Average" - fi - if [ "$type" = 'mem' ]; then - title="Memory Usage" - fi - if [ "$type" = 'net' ]; then - title="Bandwidth Usage $rrd" - fi - if [ "$type" = 'web' ] || [ "$type" = 'ftp' ] ||\ - [ "$type" = 'ssh' ]; then - title="$(echo $rrd| tr '[:lower:]' '[:upper:]') Usage" - fi - if [ "$type" = 'mail' ]; then - title="Exim Usage" - fi - if [ "$type" = 'db' ]; then - db_type=$(echo $rrd|cut -f 1 -d _ |sed -e 's/mysql/MySQL/g' \ - -e 's/pgsql/PostgreSQL/g' ) - db_host=$(echo $rrd|cut -f 2 -d _ ) - title="$db_type Usage on $db_host" - fi - echo -e "\t\"$i\": {" - echo -e "\t\t\"TYPE\": \"$type\"", - echo -e "\t\t\"RRD\": \"$rrd\"", - echo -e "\t\t\"TITLE\": \"$title\"," - echo -e "\t\t\"TIME\": \"$TIME\"," - echo -e "\t\t\"DATE\": \"$DATE\"" - (( ++i)) - done - done - if [ "$i" -gt 1 ]; then - echo -e "\t}" - fi - echo "}" -} - -# SHELL list function -shell_list() { - echo "TYPE VAL_1 VAL_2 VAL_3 TIME DATE" - echo "---- ----- ----- ----- ---- ----" - for type in $rrd_types; do - for rrd in $(ls $RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do - rrd_type=$(echo "$rrd" |tr '[:lower:]' '[:upper:]') - rrd_data=$(rrdtool fetch "$RRD/$type/$rrd.rrd" AVERAGE -e 0 -s 0) - rrd_data=$(echo "$rrd_data" |tail -n 1) - rrd_timestamp=$(echo "$rrd_data" |cut -f 1 -d :) - rrd_time=$(date -d "@$rrd_timestamp" +%F) - rrd_date=$(date -d "@$rrd_timestamp" +%T) - rrd_val1=$(echo "$rrd_data" |awk '{print $2}' |cut -d. -f1) - rrd_val2=$(echo "$rrd_data" |awk '{print $3}' |cut -d. -f1) - rrd_val3=$(echo "$rrd_data" |awk '{print $4}' |cut -d. -f1) - if [ -z "$rrd_val1" ]; then - rrd_val1="-nan" - fi - if [ -z "$rrd_val2" ]; then - rrd_val2="-nan" - fi - if [ -z "$rrd_val3" ]; then - rrd_val3="-nan" - fi - echo "$rrd_type $rrd_val1 $rrd_val2 $rrd_val3 $rrd_time $rrd_date" - done - done -} - -# PLAIN list function -plain_list() { - for type in $rrd_types; do - for rrd in $(ls $RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do - echo "$RRD/$type/$rrd.rrd" - done - done -} - -# CSV list function -csv_list() { - for type in $rrd_types; do - echo "RRD" - for rrd in $(ls $RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do - echo "$RRD/$type/$rrd.rrd" - done - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Definng rrd charts -rrd_types="la mem net" - -# Checking web system -if [ ! -z "$WEB_SYSTEM" ]; then - rrd_types="$rrd_types web" -fi - -# Checking mail system -if [ ! -z "$MAIL_SYSTEM" ]; then - rrd_types="$rrd_types mail" -fi - -# Checking db system -if [ ! -z "$DB_SYSTEM" ]; then - rrd_types="$rrd_types db" -fi - -# Checking ftp system -if [ ! -z "$FTP_SYSTEM" ]; then - rrd_types="$rrd_types ftp" -fi - -# Adding ssh -rrd_types="$rrd_types ssh" - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-services b/bin/v-list-sys-services deleted file mode 100755 index 3718c1719..000000000 --- a/bin/v-list-sys-services +++ /dev/null @@ -1,293 +0,0 @@ -#!/bin/bash -# info: list system services -# options: [FORMAT] -# -# The function for obtaining the list of configured system services. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -export PATH=$PATH:/sbin - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(echo -e "$data" |grep NAME |wc -l) - echo "{" - while read str; do - eval $str - echo -n ' "'$NAME'": { - "SYSTEM": "'$SYSTEM'", - "STATE": "'$STATE'", - "CPU": "'$CPU'", - "MEM": "'$MEM'", - "RTIME": "'$RTIME'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(echo -e "$data" |grep NAME) - echo '}' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "NAME STATE CPU MEM UPTIME" - echo "---- ----- --- --- ------" - while read str; do - eval $str - echo "$NAME $STATE $CPU $MEM $RTIME" - done < <(echo -e "$data" |grep NAME) -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - while read str; do - eval $str - echo -e "$NAME\t$SYSTEM\t$STATE\t$CPU\t$MEM\t$RTIME" - done < <(echo -e "$data" |grep NAME) -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo "NAME,SYSTEM,STATE,CPU,MEM,RTIME" - while read str; do - eval $str - echo "$NAME,\"$SYSTEM\",$STATE,$CPU,$MEM,$RTIME" - done < <(echo -e "$data" |grep NAME) -} - -# Get service state function -get_srv_state() { - srv=$1 - name=${2-$1} - state='running' - - # Searching related pids - if [ -z $3 ]; then - pids=$(pidof $name |tr ' ' '|') - else - pids=$(pidof -x $name |tr ' ' '|') - fi - if [ -z "$pids" ] && [ "$name" != 'nginx' ]; then - pids=$(pgrep $name |tr '\n' '|') - fi - - # Checking pid - if [ ! -z "$pids" ]; then - pid=$(echo "$pids" |cut -f 1 -d '|') - pids=$(egrep "$pids" $tmp_file) - - # Calculating CPU usage - cpu=$(echo "$pids" |awk '{ sum += $2} END {print sum}') - - # Calculating memory usage - mem=$(echo "$pids" |awk '{sum += $3} END {print sum/1024 }') - mem=$(echo "${mem%%.*}") - - # Searching pid file - pid_file='' - if [ -e "/var/run/$srv.pid" ]; then - pid_file="/var/run/$srv.pid" - fi - if [ -z "$pid_file" ] && [ -e "/var/run/$srv/$srv.pid" ]; then - pid_file="/var/run/$srv/$srv.pid" - fi - if [ -z "$pid_file" ] && [ -e "/var/run/$name/$name.pid" ]; then - pid_file="/var/run/$name/$name.pid" - fi - if [ -z "$pid_file" ] && [ -e "/proc/$pid" ]; then - pid_file="/proc/$pid" - fi - - # Calculating uptime - if [ ! -z "$pid_file" ]; then - mtime=$(stat -c "%Y" $pid_file) - rtime=$((ctime - mtime)) - rtime=$((rtime / 60)) - else - rtime=0 - fi - else - state='stopped' - mem=0 - cpu=0 - rtime="0" - fi -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Saving current proccess list -tmp_file=$(mktemp) -ps -eo pid,pcpu,size > $tmp_file - -# Checking current time -ctime=$(date +%s) - -# Checking WEB system -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'remote' ]; then - get_srv_state $WEB_SYSTEM - data="NAME='$WEB_SYSTEM' SYSTEM='web server' STATE='$state' CPU='$cpu'" - data="$data MEM='$mem' RTIME='$rtime'" -fi - -# Checking WEB Backend -if [ ! -z "$WEB_BACKEND" ] && [ "$WEB_BACKEND" != 'remote' ]; then - proc_name=$(ls /usr/sbin/php*fpm* | rev | cut -d'/' -f 1 | rev) - get_srv_state $proc_name - data="$data\nNAME='$WEB_BACKEND' SYSTEM='backend server' STATE='$state'" - data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'" -fi - -# Checking WEB Proxy -if [ ! -z "$PROXY_SYSTEM" ] && [ "$PROXY_SYSTEM" != 'remote' ]; then - get_srv_state $PROXY_SYSTEM - data="$data\nNAME='$PROXY_SYSTEM' SYSTEM='reverse proxy' STATE='$state'" - data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'" -fi - -# DNS -service=$DNS_SYSTEM -if [ ! -z "$service" ] && [ "$service" != 'remote' ]; then - proc_name='named' - get_srv_state $service $proc_name - data="$data\nNAME='$service' SYSTEM='dns server' STATE='$state'" - data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'" -fi - -# Checking MAIL system -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'remote' ]; then - get_srv_state $MAIL_SYSTEM - data="$data\nNAME='$MAIL_SYSTEM' SYSTEM='mail server' STATE='$state'" - data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'" -fi - -# Checking MAIL IMAP -if [ ! -z "$IMAP_SYSTEM" ] && [ "$IMAP_SYSTEM" != 'remote' ]; then - get_srv_state $IMAP_SYSTEM - data="$data\nNAME='$IMAP_SYSTEM' SYSTEM='pop/imap server' STATE='$state'" - data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'" -fi - -# Checking MAIL ANTIVIRUS -if [ ! -z "$ANTIVIRUS_SYSTEM" ] && [ "$ANTIVIRUS_SYSTEM" != 'remote' ]; then - if [ -d "/etc/sysconfig" ]; then - if [ "$ANTIVIRUS_SYSTEM" == 'clamav' ];then - ANTIVIRUS_SYSTEM='clamd' - fi - get_srv_state $ANTIVIRUS_SYSTEM - else - if [ "$ANTIVIRUS_SYSTEM" == 'clamav-daemon' ];then - proc_name='clamd' - fi - get_srv_state $ANTIVIRUS_SYSTEM $proc_name - fi - data="$data\nNAME='$ANTIVIRUS_SYSTEM' SYSTEM='email antivirus'" - data="$data STATE='$state' CPU='$cpu' MEM='$mem' RTIME='$rtime'" - proc_name='' -fi - -# Checking MAIL ANTISPAM -if [ ! -z "$ANTISPAM_SYSTEM" ] && [ "$ANTISPAM_SYSTEM" != 'remote' ]; then - get_srv_state $ANTISPAM_SYSTEM spamd - data="$data\nNAME='$ANTISPAM_SYSTEM' SYSTEM='email antispam'" - data="$data STATE='$state' CPU='$cpu' MEM='$mem' RTIME='$rtime'" -fi - -# Checking DB system -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'remote' ]; then - for db in ${DB_SYSTEM//,/ }; do - proc_name='' - service="$db" - if [ "$service" = 'mysql' ]; then - if [ -d "/etc/sysconfig" ]; then - service='mysqld' - proc_name='mysqld' - if [ -e "/usr/lib/systemd/system/mariadb.service" ]; then - service='mariadb' - fi - fi - fi - if [ "$service" == 'pgsql' ]; then - service='postgresql' - proc_name='postmaster' - if [ ! -d "/etc/sysconfig" ]; then - proc_name='postgres' - fi - if [ ! -e '/etc/init.d/postgresql' ]; then - proc_name='postgres' - fi - fi - get_srv_state $service $proc_name - data="$data\nNAME='$service' SYSTEM='database server' STATE='$state'" - data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'" - proc_name='' - done -fi - -# Checking FTP system -if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'remote' ]; then - get_srv_state $FTP_SYSTEM - data="$data\nNAME='$FTP_SYSTEM' SYSTEM='ftp server' STATE='$state'" - data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'" -fi - -# Checking CRON system -if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'remote' ]; then - get_srv_state $CRON_SYSTEM - data="$data\nNAME='$CRON_SYSTEM' SYSTEM='job scheduler' STATE='$state'" - data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'" -fi - -# Checking FIREWALL system -if [ ! -z "$FIREWALL_SYSTEM" ] && [ "$FIREWALL_SYSTEM" != 'remote' ]; then - state="stopped" - /sbin/iptables -L vesta >/dev/null 2>&1 - if [ "$?" -eq 0 ]; then - state="running" - fi - data="$data\nNAME='$FIREWALL_SYSTEM' SYSTEM='firewall'" - data="$data STATE='$state' CPU='0' MEM='0' RTIME='0'" -fi - -# Checking FIREWALL Fail2ban extention -if [ ! -z "$FIREWALL_EXTENSION" ]; then - get_srv_state $FIREWALL_EXTENSION fail2ban-server script - data="$data\nNAME='$FIREWALL_EXTENSION' SYSTEM='brute-force monitor'" - data="$data STATE='$state' CPU='$cpu' MEM='$mem' RTIME='$rtime'" -fi - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-shells b/bin/v-list-sys-shells deleted file mode 100755 index dec180f5c..000000000 --- a/bin/v-list-sys-shells +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -# info: list system shells -# options: [FORMAT] -# -# The function for obtaining the list of system shells. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - sh_counter=$(echo "$shells" | wc -l) - i=1 - echo '[' - for shell in $shells; do - if [ "$i" -lt "$sh_counter" ]; then - echo -e "\t\"$shell\"," - else - echo -e "\t\"$shell\"" - fi - (( ++i)) - done - echo "]" -} - -# SHELL list function -shell_list() { - echo "SHELL" - echo "-----" - for shell in $shells; do - echo "$shell" - done -} - -# PLAIN list function -plain_list() { - for shell in $shells; do - echo "$shell" - done -} - -# CSV list function -csv_list() { - echo "SHELL" - for shell in $shells; do - echo "$shell" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining system shells -shells=$(grep -v '#' /etc/shells |awk -F '/' '{print $NF}' |sort -u) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-spamd-config b/bin/v-list-sys-spamd-config deleted file mode 100755 index 04d82c731..000000000 --- a/bin/v-list-sys-spamd-config +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# info: list spamassassin config parameters -# options: [FORMAT] -# -# The function for obtaining the list of spamassassin config parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{ - "CONFIG": { - "config_path": "'$config_path'" - } -}' -} - -# SHELL list function -shell_list() { - echo "config_path: $config_path" -} - -# PLAIN list function -plain_list() { - echo "$config_path" -} - -# CSV list function -csv_list() { - echo "config_path" - echo "$config_path" -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config path -config_path=$(find /etc/spamassassin /etc/mail -name local.cf 2>/dev/null) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-users b/bin/v-list-sys-users deleted file mode 100755 index cd297338b..000000000 --- a/bin/v-list-sys-users +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -# info: list system users -# options: [FORMAT] -# -# The function for obtaining the list of system users without -# detailed information. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - objects=$(grep @ /etc/passwd |wc -l) - i=1 - echo '[' - while read user; do - if [ "$i" -lt "$objects" ]; then - echo -e "\t\"$user\"," - else - echo -e "\t\"$user\"" - fi - (( ++i)) - done < <(grep @ /etc/passwd |cut -f 1 -d :) - echo "]" -} - -# SHELL list function -shell_list() { - echo "USER" - echo "----" - while read user; do - echo "$user" - done < <(grep @ /etc/passwd |cut -f 1 -d :) -} - -# PLAIN list function -plain_list() { - while read user; do - echo "$user" - done < <(grep @ /etc/passwd |cut -f 1 -d :) -} - -# CSV list function -csv_list() { - echo "USER" - while read user; do - echo "$user" - done < <(grep @ /etc/passwd |cut -f 1 -d :) -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-vesta-autoupdate b/bin/v-list-sys-vesta-autoupdate deleted file mode 100755 index f94570180..000000000 --- a/bin/v-list-sys-vesta-autoupdate +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -# info: list vesta autoupdate settings -# options: [FORMAT] -# -# The function for obtaining autoupdate setings. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user='admin' -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '[' - if [ -z "$check_cron" ]; then - echo -e "\t\"Disabled\"," - else - echo -e "\t\"Enabled\"" - fi - echo "]" -} - -# SHELL list function -shell_list() { - echo -n "AUTOUPDATE: " - if [ -z "$check_cron" ]; then - echo "Disabled" - else - echo "Enabled" - fi -} - -# PLAIN list function -plain_list() { - if [ -z "$check_cron" ]; then - echo "Disabled" - else - echo "Enabled" - fi -} - -# CSV list function -csv_list() { - echo "AUTOUPDATE" - if [ -z "$check_cron" ]; then - echo "Disabled" - else - echo "Enabled" - fi -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Check cron tab -check_cron=$(grep 'v-update-sys-vesta-all' $USER_DATA/cron.conf) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list;; -esac - - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-vesta-ssl b/bin/v-list-sys-vesta-ssl deleted file mode 100755 index fe6eea474..000000000 --- a/bin/v-list-sys-vesta-ssl +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/bash -# info: list vesta ssl certificate -# options: [FORMAT] -# -# The function of obtaining vesta ssl files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{' - echo -e "\t\"VESTA\": {" - echo " \"CRT\": \"$crt\"," - echo " \"KEY\": \"$key\"," - echo " \"CA\": \"$ca\"," - echo " \"SUBJECT\": \"$subj\"," - echo " \"ALIASES\": \"$alt_dns\"," - echo " \"NOT_BEFORE\": \"$before\"," - echo " \"NOT_AFTER\": \"$after\"," - echo " \"SIGNATURE\": \"$signature\"," - echo " \"PUB_KEY\": \"$pub_key\"," - echo " \"ISSUER\": \"$issuer\"" - echo -e "\t}\n}" -} - -# SHELL list function -shell_list() { - if [ ! -z "$crt" ]; then - echo -e "$crt" - fi - if [ ! -z "$key" ]; then - echo -e "\n$key" - fi - if [ ! -z "$crt" ]; then - echo - echo - echo "SUBJECT: $subj" - if [ ! -z "$alt_dns" ]; then - echo "ALIASES: ${alt_dns//,/ }" - fi - echo "VALID FROM: $before" - echo "VALID TIL: $after" - echo "SIGNATURE: $signature" - echo "PUB_KEY: $pub_key" - echo "ISSUER: $issuer" - fi -} - -# PLAIN list function -plain_list() { - if [ ! -z "$crt" ]; then - echo -e "$crt" - fi - if [ ! -z "$key" ]; then - echo -e "\n$key" - fi - if [ ! -z "$ca" ]; then - echo -e "\n$ca" - fi - if [ ! -z "$crt" ]; then - echo "$subj" - echo "${alt_dns//,/ }" - echo "$before" - echo "$after" - echo "$signature" - echo "$pub_key" - echo "$issuer" - fi - -} - -# CSV list function -csv_list() { - echo -n "CRT,KEY,CA,SUBJECT,ALIASES,NOT_BEFORE,NOT_AFTER,SIGNATURE," - echo "PUB_KEY,ISSUER" - echo -n "\"$crt\",\"$key\",\"$ca\",\"$subj\",\"${alt_dns//,/ }\"," - echo "\"$before\",\"$after\",\"$signature\",\"$pub_key\",\"$issuer\"" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing SSL certificate -crt=$(cat $VESTA/ssl/certificate.crt |sed ':a;N;$!ba;s/\n/\\n/g') -key=$(cat $VESTA/ssl/certificate.key |sed ':a;N;$!ba;s/\n/\\n/g') - -# Parsing SSL certificate details without CA -info=$(openssl x509 -text -in $VESTA/ssl/certificate.crt) -subj=$(echo "$info" |grep Subject: |cut -f 2 -d =) -before=$(echo "$info" |grep Before: |sed -e "s/.*Before: //") -after=$(echo "$info" |grep "After :" |sed -e "s/.*After : //") -signature=$(echo "$info" |grep "Algorithm:" |head -n1 ) -signature=$(echo "$signature"| sed -e "s/.*Algorithm: //") -pub_key=$(echo "$info" |grep Public-Key: |cut -f2 -d \( | tr -d \)) -issuer=$(echo "$info" |grep Issuer: |sed -e "s/.*Issuer: //") -alt_dns=$(echo "$info" |grep DNS |sed -e 's/DNS:/\n/g' |tr -d ',') -alt_dns=$(echo "$alt_dns" |tr -d ' ' |sed -e "/^$/d") -alt_dns=$(echo "$alt_dns" |sed -e ':a;N;$!ba;s/\n/,/g') - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-vesta-updates b/bin/v-list-sys-vesta-updates deleted file mode 100755 index adcd6a1a5..000000000 --- a/bin/v-list-sys-vesta-updates +++ /dev/null @@ -1,181 +0,0 @@ -#!/bin/bash -# info: list system updates -# options: [FORMAT] -# -# The function checks available updates for vesta packages. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf -fields="\$NAME \$VERSION \$RELEASE \$ARCH \$UPDATED \$DESCR \$TIME \$DATE" - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(echo -e "$data" |grep NAME |wc -l) - echo "{" - for str in $(echo -e "$data"); do - eval $str - echo -n ' "'$NAME'": { - "VERSION": "'$VERSION'", - "RELEASE": "'$RELEASE'", - "ARCH": "'$ARCH'", - "UPDATED": "'$UPDATED'", - "DESCR": "'$DESCR'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done - echo '}' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "PKG VER REL ARCH UPDT DATE" - echo "--- --- --- ---- ---- ----" - for str in $(echo -e "$data"); do - eval $str - echo "$NAME $VERSION $RELEASE $ARCH $UPDATED $DATE" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking official latest version -latest=$(wget -q -T 1 -t 1 http://c.vestacp.com/latest.txt -O -) - -# Checking installed vesta version -if [ -d "/etc/sysconfig" ]; then - rpm_format="VERSION='%{VERSION}'" - rpm_format="$rpm_format RELEASE='%{RELEASE}'" - rpm_format="$rpm_format ARCH='%{ARCH}'" - rpm_format="$rpm_format UTIME='%{INSTALLTIME}'\n" - eval $(rpm --queryformat="$rpm_format" -q vesta) - DATE=$(date -d @$UTIME +%F) - TIME=$(date -d @$UTIME +%T) -else - dpkg_data=$(dpkg-query -s vesta) - pkg_date=$(stat -c "%Y" /var/lib/dpkg/info/vesta.list) - ARCH=$(echo "$dpkg_data"|grep Architecture |cut -f 2 -d ' ') - VERSION=$(echo "$dpkg_data"|grep ^Version |cut -f 2 -d ' '|cut -f 1 -d \-) - RELEASE=$(echo "$dpkg_data"|grep ^Version |cut -f 2 -d ' '|cut -f 2 -d \-) - DATE=$(date -d @$pkg_date +"%F") - TIME=$(date -d @$pkg_date +"%T") -fi -UPDATED='yes' -if [ ! -z "$latest" ] && [ "$latest" \> "vesta-$VERSION-$RELEASE" ]; then - UPDATED='no' -fi -data="NAME='vesta' VERSION='$VERSION' RELEASE='$RELEASE' ARCH='$ARCH'" -data="$data UPDATED='$UPDATED' DESCR='core package' TIME='$TIME' DATE='$DATE'" - -# Checking installed vesta-php version -if [ -d "/etc/sysconfig" ]; then - eval $(rpm --queryformat="$rpm_format" -q vesta-php) - DATE=$(date -d @$UTIME +%F) - TIME=$(date -d @$UTIME +%T) -else - dpkg_data=$(dpkg-query -s vesta-php) - pkg_date=$(stat -c "%Y" /var/lib/dpkg/info/vesta-php.list) - ARCH=$(echo "$dpkg_data"|grep Architecture | cut -f 2 -d ' ') - VERSION=$(echo "$dpkg_data"|grep ^Version |cut -f 2 -d ' '|cut -f 1 -d \-) - RELEASE=$(echo "$dpkg_data"|grep ^Version |cut -f 2 -d ' '|cut -f 2 -d \-) - DATE=$(date -d @$pkg_date +"%F") - TIME=$(date -d @$pkg_date +"%T") -fi -data="$data\nNAME='vesta-php' VERSION='$VERSION' RELEASE='$RELEASE'" -data="$data ARCH='$ARCH' UPDATED='$UPDATED' DESCR='php interpreter'" -data="$data TIME='$TIME' DATE='$DATE'" - -# Checking installed vesta-nginx version -if [ -d "/etc/sysconfig" ]; then - eval $(rpm --queryformat="$rpm_format" -q vesta-nginx) - DATE=$(date -d @$UTIME +%F) - TIME=$(date -d @$UTIME +%T) -else - dpkg_data=$(dpkg-query -s vesta-nginx) - pkg_date=$(stat -c "%Y" /var/lib/dpkg/info/vesta-nginx.list) - ARCH=$(echo "$dpkg_data"|grep Architecture | cut -f 2 -d ' ') - VERSION=$(echo "$dpkg_data"|grep ^Version |cut -f 2 -d ' '|cut -f 1 -d \-) - RELEASE=$(echo "$dpkg_data"|grep ^Version |cut -f 2 -d ' '|cut -f 2 -d \-) - DATE=$(date -d @$pkg_date +"%F") - TIME=$(date -d @$pkg_date +"%T") -fi -data="$data\nNAME='vesta-nginx' VERSION='$VERSION' RELEASE='$RELEASE'" -data="$data ARCH='$ARCH' UPDATED='$UPDATED' DESCR='internal web server'" -data="$data TIME='$TIME' DATE='$DATE'" - -# Checking installed vesta-ioncube version -if [ "$SOFTACULOUS" = 'yes' ]; then - if [ -d "/etc/sysconfig" ]; then - eval $(rpm --queryformat="$rpm_format" -q vesta-ioncube) - DATE=$(date -d @$UTIME +%F) - TIME=$(date -d @$UTIME +%T) - else - dpkg_data=$(dpkg-query -s vesta-ioncube) - pkg_date=$(stat -c "%Y" /var/lib/dpkg/info/vesta-php.list) - ARCH=$(echo "$dpkg_data"|grep Architecture | cut -f 2 -d ' ') - VERSION=$(echo "$dpkg_data"|grep ^Vers |cut -f2 -d ' '|cut -f1 -d \-) - RELEASE=$(echo "$dpkg_data"|grep ^Vers |cut -f2 -d ' '|cut -f2 -d \-) - DATE=$(date -d @$pkg_date +"%F") - TIME=$(date -d @$pkg_date +"%T") - fi - data="$data\nNAME='vesta-ioncube' VERSION='$VERSION' RELEASE='$RELEASE'" - data="$data ARCH='$ARCH' UPDATED='$UPDATED' DESCR='php encoder'" - data="$data TIME='$TIME' DATE='$DATE'" -fi - -# Checking installed vesta-softaculous version -if [ "$SOFTACULOUS" = 'yes' ]; then - if [ -d "/etc/sysconfig" ]; then - eval $(rpm --queryformat="$rpm_format" -q vesta-softaculous) - DATE=$(date -d @$UTIME +%F) - TIME=$(date -d @$UTIME +%T) - else - dpkg_data=$(dpkg-query -s vesta-softaculous) - pkg_date=$(stat -c "%Y" /var/lib/dpkg/info/vesta-php.list) - ARCH=$(echo "$dpkg_data"|grep Architecture | cut -f 2 -d ' ') - VERSION=$(echo "$dpkg_data"|grep ^Vers |cut -f2 -d ' '|cut -f1 -d \-) - RELEASE=$(echo "$dpkg_data"|grep ^Vers |cut -f2 -d ' '|cut -f2 -d \-) - DATE=$(date -d @$pkg_date +"%F") - TIME=$(date -d @$pkg_date +"%T") - fi - data="$data\nNAME='vesta-softaculous' VERSION='$VERSION' RELEASE='$RELEASE'" - data="$data ARCH='$ARCH' UPDATED='$UPDATED' DESCR='app installer'" - data="$data TIME='$TIME' DATE='$DATE'" -fi - - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-vsftpd-config b/bin/v-list-sys-vsftpd-config deleted file mode 100755 index 060d88422..000000000 --- a/bin/v-list-sys-vsftpd-config +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# info: list vsftpd config parameters -# options: [FORMAT] -# -# The function for obtaining the list of vsftpd config parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{ - "CONFIG": { - "config_path": "'$config_path'" - } -}' -} - -# SHELL list function -shell_list() { - echo "config_path: $config_path" -} - -# PLAIN list function -plain_list() { - echo "$config_path" -} - -# CSV list function -csv_list() { - echo "config_path" - echo "$config_path" -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config path -config_path=$(find /etc/vsftpd* -name vsftpd.conf 2>/dev/null) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-sys-web-status b/bin/v-list-sys-web-status deleted file mode 100755 index eb58c81ce..000000000 --- a/bin/v-list-sys-web-status +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -# info: list web status -# options: [FORMAT] -# -# The function lists web server status - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -#format=${1-shell} - -# Includes -#source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking web system -if [ -z "$WEB_SYSTEM" ]; then - exit -fi - -# Displaying proxy status -if [ "$PROXY_SYSTEM" = 'nginx' ]; then - echo "

$PROXY_SYSTEM STATUS

"| tr '[:lower:]' '[:upper:]' - wget -qO- http://localhost:8084/ - echo "


" -fi - -# Displaying web server status -echo "

$WEB_SYSTEM STATUS

"| tr '[:lower:]' '[:upper:]' -if [ "$WEB_SYSTEM" != 'nginx' ]; then - wget -qO- http://localhost:8081/server-status/ |\ - egrep -v "html|DOCTYPE|h1>|title|head" -else - wget -qO- http://localhost:8084/ -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-user b/bin/v-list-user deleted file mode 100755 index 57b48bb3a..000000000 --- a/bin/v-list-user +++ /dev/null @@ -1,183 +0,0 @@ -#!/bin/bash -# info: list user parameters -# options: USER [FORMAT] -# -# The function to obtain user parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{ - "'$USER'": { - "FNAME": "'$FNAME'", - "LNAME": "'$LNAME'", - "PACKAGE": "'$PACKAGE'", - "WEB_TEMPLATE": "'$WEB_TEMPLATE'", - "BACKEND_TEMPLATE": "'$BACKEND_TEMPLATE'", - "PROXY_TEMPLATE": "'$PROXY_TEMPLATE'", - "DNS_TEMPLATE": "'$DNS_TEMPLATE'", - "WEB_DOMAINS": "'$WEB_DOMAINS'", - "WEB_ALIASES": "'$WEB_ALIASES'", - "DNS_DOMAINS": "'$DNS_DOMAINS'", - "DNS_RECORDS": "'$DNS_RECORDS'", - "MAIL_DOMAINS": "'$MAIL_DOMAINS'", - "MAIL_ACCOUNTS": "'$MAIL_ACCOUNTS'", - "DATABASES": "'$DATABASES'", - "CRON_JOBS": "'$CRON_JOBS'", - "DISK_QUOTA": "'$DISK_QUOTA'", - "BANDWIDTH": "'$BANDWIDTH'", - "HOME": "'$HOME'", - "NS": "'$NS'", - "SHELL": "'$SHELL'", - "BACKUPS": "'$BACKUPS'", - "CONTACT": "'$CONTACT'", - "CRON_REPORTS": "'$CRON_REPORTS'", - "RKEY": "'$RKEY'", - "SUSPENDED": "'$SUSPENDED'", - "SUSPENDED_USERS": "'$SUSPENDED_USERS'", - "SUSPENDED_WEB": "'$SUSPENDED_WEB'", - "SUSPENDED_DNS": "'$SUSPENDED_DNS'", - "SUSPENDED_MAIL": "'$SUSPENDED_MAIL'", - "SUSPENDED_DB": "'$SUSPENDED_DB'", - "SUSPENDED_CRON": "'$SUSPENDED_CRON'", - "IP_AVAIL": "'$IP_AVAIL'", - "IP_OWNED": "'$IP_OWNED'", - "U_USERS": "'$U_USERS'", - "U_DISK": "'$U_DISK'", - "U_DISK_DIRS": "'$U_DISK_DIRS'", - "U_DISK_WEB": "'$U_DISK_WEB'", - "U_DISK_MAIL": "'$U_DISK_MAIL'", - "U_DISK_DB": "'$U_DISK_DB'", - "U_BANDWIDTH": "'$U_BANDWIDTH'", - "U_WEB_DOMAINS": "'$U_WEB_DOMAINS'", - "U_WEB_SSL": "'$U_WEB_SSL'", - "U_WEB_ALIASES": "'$U_WEB_ALIASES'", - "U_DNS_DOMAINS": "'$U_DNS_DOMAINS'", - "U_DNS_RECORDS": "'$U_DNS_RECORDS'", - "U_MAIL_DOMAINS": "'$U_MAIL_DOMAINS'", - "U_MAIL_DKIM": "'$U_MAIL_DKIM'", - "U_MAIL_ACCOUNTS": "'$U_MAIL_ACCOUNTS'", - "U_DATABASES": "'$U_DATABASES'", - "U_CRON_JOBS": "'$U_CRON_JOBS'", - "U_BACKUPS": "'$U_BACKUPS'", - "LANGUAGE": "'$LANGUAGE'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - } -}' -} - -# SHELL list function -shell_list() { - echo "USERNAME: $USER" - echo "FULL NAME: $FNAME $LNAME" - echo "EMAIL: $CONTACT" - echo "LANGUAGE: $LANGUAGE" - echo "SUSPENDED: $SUSPENDED" - echo "PACKAGE: $PACKAGE" - echo "SHELL: $SHELL" - echo "WEB DOMAINS: $U_WEB_DOMAINS/$WEB_DOMAINS" - echo "WEB ALIASES: $U_WEB_ALIASES/$WEB_ALIASES" - echo "DNS DOMAINS: $U_DNS_DOMAINS/$DNS_DOMAINS" - echo "DNS RECORDS: $U_DNS_RECORDS/$DNS_RECORDS" - echo "MAIL DOMAINS: $U_MAIL_DOMAINS/$MAIL_DOMAINS" - echo "MAIL ACCOUNTS: $U_MAIL_ACCOUNTS/$MAIL_ACCOUNTS" - echo "BACKUPS: $U_BACKUPS/$BACKUPS" - echo "DATABASES: $U_DATABASES/$DATABASES" - echo "CRON_JOBS: $U_CRON_JOBS/$CRON_JOBS" - echo "DISK: $U_DISK/$DISK_QUOTA" - echo "BANDWIDTH: $U_BANDWIDTH/$BANDWIDTH" - echo "IP ADDRESSES $IP_AVAIL/$IP_OWNED" - echo "TIME: $TIME" - echo "DATE: $DATE" -} - -# PLAIN list function -plain_list() { - echo -ne "$USER\t$FNAME\t$LNAME\t$PACKAGE\t$WEB_TEMPLATE\t" - echo -ne "$BACKEND_TEMPLATE\t$PROXY_TEMPLATE\t$DNS_TEMPLATE\t" - echo -ne "$WEB_DOMAINS\t$WEB_ALIASES\t$DNS_DOMAINS\t$DNS_RECORDS\t" - echo -ne "$MAIL_DOMAINS\t$MAIL_ACCOUNTS\t$DATABASES\t$CRON_JOBS\t" - echo -ne "$DISK_QUOTA\t$BANDWIDTH\t$NS\t$HOME\t$SHELL\t$BACKUPS\t" - echo -ne "$CONTACT\t$CRON_REPORTS\t$RKEY\t$SUSPENDED\t" - echo -ne "$SUSPENDED_USERS\t$SUSPENDED_WEB\t$SUSPENDED_DNS\t" - echo -ne "$SUSPENDED_MAIL\t$SUSPENDED_DB\t$SUSPENDED_CRON\t" - echo -ne "$IP_AVAIL\t$IP_OWNED\t$U_USERS\t$U_DISK\t$U_DISK_DIRS\t" - echo -ne "$U_DISK_WEB\t$U_DISK_MAIL\t$U_DISK_DB\t$U_BANDWIDTH\t" - echo -ne "$U_WEB_DOMAINS\t$U_WEB_SSL\t$U_WEB_ALIASES\t" - echo -ne "$U_DNS_DOMAINS\t$U_DNS_RECORDS\t$U_MAIL_DOMAINS\t" - echo -ne "$U_MAIL_DKIM\t$U_MAIL_ACCOUNTS\t$U_DATABASES\t" - echo -e "'$U_CRON_JOBS\t$U_BACKUPS\t$LANGUAGE\t$TIME\t$DATE" -} - -# CSV list function -csv_list() { - echo -n "USER,FNAME,LNAME,PACKAGE,WEB_TEMPLATE,BACKEND_TEMPLATE," - echo -n "PROXY_TEMPLATE,DNS_TEMPLATE,WEB_DOMAINS,WEB_ALIASES," - echo -n "DNS_DOMAINS,DNS_RECORDS,MAIL_DOMAINS,MAIL_ACCOUNTS," - echo -n "DATABASES,CRON_JOBS,DISK_QUOTA,BANDWIDTH,NS,HOME,SHELL," - echo -n "BACKUPS,CONTACT,CRON_REPORTS,RKEY,SUSPENDED,SUSPENDED_USERS," - echo -n "SUSPENDED_WEB,SUSPENDED_DNS,SUSPENDED_MAIL,SUSPENDED_DB," - echo -n "SUSPENDED_CRON,IP_AVAIL,IP_OWNED,U_USERS,U_DISK,U_DISK_DIRS," - echo -n "U_DISK_WEB,U_DISK_MAIL,U_DISK_DB,U_BANDWIDTH,U_WEB_DOMAINS," - echo -n "U_WEB_SSL,U_WEB_ALIASES,U_DNS_DOMAINS,U_DNS_RECORDS," - echo -n "U_MAIL_DOMAINS,U_MAIL_DKIM,U_MAIL_ACCOUNTS,U_DATABASES" - echo "U_CRON_JOBS,U_BACKUPS,LANGUAGE,TIME,DATE" - echo -n "$USER,\"$FNAME\",\"$LNAME\",$PACKAGE,$WEB_TEMPLATE," - echo -n "$BACKEND_TEMPLATE,$PROXY_TEMPLATE,$DNS_TEMPLATE,$WEB_DOMAINS," - echo -n "$WEB_ALIASES,$DNS_DOMAINS,$DNS_RECORDS,$MAIL_DOMAINS," - echo -n "$MAIL_ACCOUNTS,$DATABASES,$CRON_JOBS,$DISK_QUOTA,$BANDWIDTH," - echo -n "\"$NS\",$HOME,$SHELL,$BACKUPS,$CONTACT,$CRON_REPORTS,\"$RKEY\"," - echo -n "$SUSPENDED,$SUSPENDED_USERS,$SUSPENDED_WEB,$SUSPENDED_DNS," - echo -n "$SUSPENDED_MAIL,$SUSPENDED_DB,$SUSPENDED_CRON,$IP_AVAIL," - echo -n "$IP_OWNED,$U_USERS,$U_DISK,$U_DISK_DIRS,$U_DISK_WEB," - echo -n "$U_DISK_MAIL,$U_DISK_DB,$U_BANDWIDTH,$U_WEB_DOMAINS,$U_WEB_SSL," - echo -n "$U_WEB_ALIASES,$U_DNS_DOMAINS,$U_DNS_RECORDS,$U_MAIL_DOMAINS," - echo -n "$U_MAIL_DKIM,$U_MAIL_ACCOUNTS,$U_DATABASES,$U_CRON_JOBS," - echo "$U_BACKUPS,$LANGUAGE,$TIME,$DATE" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -USER=$user -HOME=$HOMEDIR/$user -source $VESTA/data/users/$user/user.conf - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-user-backup b/bin/v-list-user-backup deleted file mode 100755 index 8ee8a41b5..000000000 --- a/bin/v-list-user-backup +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash -# info: list user backup -# options: USER BACKUP [FORMAT] -# -# The function of obtaining the list of backup parameters. This call, just as -# all v_list_* calls, supports 3 formats - json, shell and plain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -backup=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -fields="\$BACKUP \$TYPE \$SIZE \$WEB \$DNS \$DB \$MAIL \$CRON \$UDIR" -fields="$fields \$RUNTIME \$TIME \$DATE" - -# JSON list function -json_list() { - echo '{' - echo ' "'$BACKUP'": { - "TYPE": "'$TYPE'", - "SIZE": "'$SIZE'", - "WEB": "'$WEB'", - "DNS": "'$DNS'", - "MAIL": "'$MAIL'", - "DB": "'$DB'", - "CRON": "'$CRON'", - "UDIR": "'$UDIR'", - "RUNTIME": "'$RUNTIME'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - echo '}' -} - -# SHELL list function -shell_list() { - echo "BACKUP: $BACKUP" - echo "TYPE: $TYPE" - echo "SIZE: $SIZE mb" - echo "RUNTIME: $RUNTIME min" - echo "WEB: ${WEB//,/ }" - echo "DNS: ${DNS//,/ }" - echo "MAIL: ${MAIL//,/ }" - echo "DB: ${DB//,/ }" - echo "CRON: $CRON" - echo "UDIR: ${UDIR//,/ }" - echo "TIME: $TIME" - echo "DATE: $DATE" -} - -# PLAIN list function -plain_list() { - echo -ne "$BACKUP\t$TYPE\t$SIZE\t$WEB\t$DNS\t$MAIL\t$DB\t$CRON\t" - echo -e "$UDIR\t$RUNTIME\t$TIME\t$DATE" -} - -# CSV list function -csv_list() { - echo "BACKUP,TYPE,SIZE,WEB,DNS,MAIL,DB,CRON,UDIR,RUNTIME,TIME,DATE" - echo -n "$BACKUP,$TYPE,$SIZE,\"$WEB\",\"$DNS\",\"$MAIL\",\"$DB\"," - echo "\"$CRON\",\"$UDIR\",$RUNTIME,$TIME,$DATE" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER BACKUP [FORMAT]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'backup' 'BACKUP' "$backup" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing backup config -eval $(grep "BACKUP='$backup'" $USER_DATA/backup.conf) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-user-backup-exclusions b/bin/v-list-user-backup-exclusions deleted file mode 100755 index 4ef75bf77..000000000 --- a/bin/v-list-user-backup-exclusions +++ /dev/null @@ -1,184 +0,0 @@ -#!/bin/bash -# info: list backup exclusions -# options: USER [FORMAT] -# -# The function for obtaining the backup exclusion list - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - set -f - i=1 - echo '{' - echo ' "WEB": {' - objects=$(echo "${WEB//,/ }" |wc -w) - for object in $(echo "${WEB//,/ }"); do - j=1 - object_keys=$(echo ${object//:/ } |wc -w) - for key in $(echo "${object/:/ }"); do - if [ "$j" -eq 1 ]; then - echo -n " \"${key}\": " - if [ "$object_keys" -eq 1 ]; then - echo -n '""' - fi - else - echo -n "\"${key//:/,}\"" - fi - ((j++)) - done - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done - echo ' },' - i=1 - echo ' "MAIL": {' - objects=$(echo "${MAIL//,/ }" |wc -w) - for object in $(echo "${MAIL//,/ }"); do - j=1 - object_keys=$(echo ${object//:/ } |wc -w) - for key in $(echo "${object/:/ }"); do - if [ "$j" -eq 1 ]; then - echo -n " \"$key\": " - if [ "$object_keys" -eq 1 ]; then - echo -n '""' - fi - else - echo -n "\"${key//:/,}\"" - fi - ((j++)) - done - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done - echo ' },' - i=1 - echo ' "DB": {' - objects=$(echo "${DB//,/ }" |wc -w) - for object in $(echo "${DB//,/ }"); do - j=1 - object_keys=$(echo ${object//:/ } |wc -w) - for key in $(echo "${object/:/ }"); do - if [ "$j" -eq 1 ]; then - echo -n " \"$key\": " - if [ "$object_keys" -eq 1 ]; then - echo -n '""' - fi - else - echo -n "\"${key//:/,}\"" - fi - ((j++)) - done - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done - echo ' },' - i=1 - echo ' "USER": {' - objects=$(echo "${USER//,/ }" |wc -w) - for object in $(echo "${USER//,/ }"); do - j=1 - object_keys=$(echo ${object//:/ } |wc -w) - for key in $(echo "${object/:/ }"); do - if [ "$j" -eq 1 ]; then - echo -n " \"$key\": " - if [ "$object_keys" -eq 1 ]; then - echo -n '""' - fi - else - echo -n "\"${key//:/,}\"" - fi - ((j++)) - done - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done - echo ' }' - echo '}' - -} - -# SHELL list function -shell_list() { - echo "WEB: $WEB" - echo "MAIL: $MAIL" - echo "DB: $DB" - echo "USER DIRS: $USER" -} - -# PLAIN list function -plain_list() { - echo "$WEB\t$MAIL\t$DB\t$USER" -} - -# CSV list function -csv_list() { - echo "WEB,MAIL,DB,USER" - echo "\"$WEB\",\"$MAIL\",\"$DB\",\"$USER\"" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Flushing variables -WEB='' -MAIL='' -DB='' -USER='' - -# Parsing backup exclusion list -if [ -e "$USER_DATA/backup-excludes.conf" ]; then - source $USER_DATA/backup-excludes.conf -fi - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-user-backups b/bin/v-list-user-backups deleted file mode 100755 index 7e7e284e3..000000000 --- a/bin/v-list-user-backups +++ /dev/null @@ -1,115 +0,0 @@ -#!/bin/bash -# info: list user backups -# options: USER [FORMAT] -# -# The function for obtaining the list of available user backups. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(grep BACKUP $USER_DATA/backup.conf |wc -l) - echo "{" - while read -r str; do - eval $str - echo -n ' "'$BACKUP'": { - "TYPE": "'$TYPE'", - "SIZE": "'$SIZE'", - "WEB": "'$WEB'", - "DNS": "'$DNS'", - "MAIL": "'$MAIL'", - "DB": "'$DB'", - "CRON": "'$CRON'", - "UDIR": "'$UDIR'", - "RUNTIME": "'$RUNTIME'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(cat $USER_DATA/backup.conf) - echo '}' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "BACKUP TYPE SIZE TIME DATE" - echo "------ ---- --- ---- ----" - while read str; do - eval $str - echo "$BACKUP $TYPE $SIZE $RUNTIME $DATE" - done < <(cat $USER_DATA/backup.conf) -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - while read str; do - eval $str - echo -ne "$BACKUP\t$TYPE\t$SIZE\t$WEB\t$DNS\t$MAIL\t$CRON\t$UDIR\t" - echo -e "$RUNTIME\t$TIME\t$DATE" - done < <(cat $USER_DATA/backup.conf) -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo "BACKUP,TYPE,SIZE,WEB,DNS,MAIL,CRON,UDIR,RUNTIME,TIME,DATE" - while read str; do - eval $str - echo -n "$BACKUP,$TYPE,$SIZE,\"$WEB\",\"$DNS\",\"$MAIL\",\"$CRON\"," - echo "\"$UDIR\",$RUNTIME,$TIME,$DATE" - done < <(cat $USER_DATA/backup.conf) -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking config -conf=$USER_DATA/backup.conf -if [ ! -e "$conf" ]; then - touch $conf -fi - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-user-favourites b/bin/v-list-user-favourites deleted file mode 100755 index ceb2ba2c8..000000000 --- a/bin/v-list-user-favourites +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/bash -# info: list user favourites -# options: USER [FORMAT] -# -# The function for getting the list of favourite user objects - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{' - echo ' "Favourites": { - "USER": "'$USER'", - "WEB": "'$WEB'", - "DNS": "'$DN'", - "DNS_REC": "'$DNS_REC'", - "MAIL": "'$MAIL'", - "MAIL_ACC": "'$MAIL_ACC'", - "DB": "'$DB'", - "CRON": "'$CRON'", - "BACKUP": "'$BACKUP'", - "IP": "'$IP'", - "PACKAGE": "'$PACKAGE'", - "FIREWALL": "'$FIREWALL'" - }' - echo '}' -} - -# SHELL list function -shell_list() { - echo "USER: $USER" - echo "WEB: $WEB" - echo "DNS: $DNS" - echo "DNS RECORD: $DNS_REC" - echo "MAIL: $MAIL" - echo "MAIL USER: $MAIL_ACC" - echo "DATABASE: $DB" - echo "CRON: $CRON" - echo "BACKUP: $BACKUP" - echo "IP: $IP" - echo "PACKAGE: $PACKAGE" - echo "FIREWALL: $FIREWALL" -} - -# PLAIN list function -plain_list() { - echo -ne "$USER\t$WEB\t$DNS\t$DNS_REC\t$MAIL\t$MAIL_ACC\t$DB\t$CRON\t" - echo -e "$BACKUP\t$IP\t$PACKAGE\t$FIREWALL" -} - -# CSV list function -csv_list() { - echo -n "USER,WEB,DNS,DNS_REC,MAIL,MAIL_ACC,DB,CRON,BACKUP,IP," - echo "PACKAGE,FIREWALL" - echo -n "\"$USER\",\"$WEB\",\"$DNS\",\"$DNS_REC\",\"$MAIL\"," - echo -n "\"$MAIL_ACC\",\"$DB\",\"$CRON\",\"$BACKUP\",\"$IP\"," - echo "\"$PACKAGE\",\"$FIREWALL\"" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking args -check_args '1' "$#" 'USER [FORMAT]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Flushing vars -USER='' -WEB='' -DNS='' -DNS_REC='' -MAIL='' -MAIL_ACC='' -DB='' -CRON='' -BACKUP='' -IP='' -PACKAGE='' -FIREWALL='' - -# Parsing user favourites -if [ -e "$VESTA/data/users/$user/favourites.conf" ]; then - source $VESTA/data/users/$user/favourites.conf -fi - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-user-ips b/bin/v-list-user-ips deleted file mode 100755 index dad6f6f8c..000000000 --- a/bin/v-list-user-ips +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/bash -# info: list user ips -# options: USER [FORMAT] -# -# The function for obtaining the list of available ip addresses. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{' - ip_count=$(echo "$ips" |wc -l) - i=1 - for IP in $ips; do - source $VESTA/data/ips/$IP - echo -n ' "'$IP'": { - "OWNER": "'$OWNER'", - "STATUS": "'$STATUS'", - "NAME": "'$NAME'", - "NAT": "'$NAT'" - }' - if [ "$i" -lt "$ip_count" ]; then - echo ',' - else - echo - fi - ((i++)) - done - echo '}' -} - -# SHELL list function -shell_list() { - echo "IP NAT OWNER STATUS NAME" - echo "-- --- ----- ------ ---" - for IP in $ips; do - source $VESTA/data/ips/$IP - if [ -z "$NAT" ]; then - NAT='no' - fi - if [ -z "$NAME" ]; then - NAME='no' - fi - echo "$IP $NAT $OWNER $STATUS $NAME" - done -} - -# PLAIN list function -plain_list() { - for IP in $ips; do - source $VESTA/data/ips/$IP - echo -e "$IP\t$OWNER\t$STATUS\t$NAME\t$NAT" - done -} - -# CSV list function -csv_list() { - echo "IP,OWNER,STATUS,NAME,NAT" - for IP in $ips; do - source $VESTA/data/ips/$IP - echo "$IP,$OWNER,$STATUS,$NAME,$NAT" - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -owner='admin' -owner_ips=$(grep -A 1 -H "OWNER='$owner'" $VESTA/data/ips/*) -owner_ips=$(echo "$owner_ips" |grep "STATUS='shared'") -owner_ips=$(echo "$owner_ips" |cut -f 7 -d / |cut -f 1 -d -) -user_ips=$(grep -H "OWNER='$user'" $VESTA/data/ips/*) -user_ips=$(echo "$user_ips" |cut -f 7 -d / |cut -f 1 -d :) -ips=$(echo -e "$user_ips\n$owner_ips" |sort -u |sed "/^$/d") -fields='$IP $OWNER $STATUS $NAME $NAT' - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-user-log b/bin/v-list-user-log deleted file mode 100755 index ca317f7d6..000000000 --- a/bin/v-list-user-log +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash -# info: list user log -# options: USER [FORMAT] -# -# The function of obtaining the list of 100 last users commands. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(echo "$logs" |wc -l) - echo "{" - for str in $logs; do - ID=$(echo "$str" |cut -f 2 -d \') - DATE=$(echo "$str" |cut -f 4 -d \') - TIME=$(echo "$str" |cut -f 6 -d \') - CMD=$(echo "$str" |cut -f 8 -d \') - CMD=${CMD//\"/\\\"} - echo -n ' "'$ID'": { - "CMD": "'$CMD'", - "UNDO": "'$UNDO'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done - echo '}' -} - -shell_list() { - IFS=$'\n' - echo "DATE~TIME~CMD" - echo "----~----~---" - for str in $logs; do - DATE=$(echo "$str" |cut -f 4 -d \') - TIME=$(echo "$str" |cut -f 6 -d \') - CMD=$(echo "$str" |cut -f 8 -d \') - echo "$DATE~$TIME~$CMD" - done -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - for str in $logs; do - DATE=$(echo "$str" |cut -f 4 -d \') - TIME=$(echo "$str" |cut -f 6 -d \') - CMD=$(echo "$str" |cut -f 8 -d \') - echo -e "$ID\t$CMD\t$UNDO\t$TIME\t$DATE" - done -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo "ID,CMD,UNDO,TIME,DATE" - for str in $logs; do - DATE=$(echo "$str" |cut -f 4 -d \') - TIME=$(echo "$str" |cut -f 6 -d \') - CMD=$(echo "$str" |cut -f 8 -d \') - echo "$ID,\"$CMD\",\"$UNDO\",$TIME,$DATE" - done -} - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing history log -logs=$(tail -n 300 $USER_DATA/history.log 2>/dev/null) - -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t -s '~';; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-user-notifications b/bin/v-list-user-notifications deleted file mode 100755 index 1d9a976a6..000000000 --- a/bin/v-list-user-notifications +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/bash -# info: list user notifications -# options: USER [FORMAT] -# -# The function for getting the list notifications - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(grep NID $USER_DATA/notifications.conf |wc -l) - echo "{" - while read str; do - eval $str - TOPIC=$(echo "$TOPIC" |sed -e "s/%quote%/'/g") - NOTICE=$(echo "$NOTICE" |sed -e "s/%quote%/'/g") - echo -n ' "'$NID'": { - "TOPIC": "'$TOPIC'", - "NOTICE": "'$NOTICE'", - "TYPE": "'$TYPE'", - "ACK": "'$ACK'", - "TPL": "'$TPL'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(cat $USER_DATA/notifications.conf) - echo '}' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - while read str; do - eval $str - echo "$TOPIC" |sed -e "s/%quote%/'/g" - echo "$NOTICE" |sed -e "s/%quote%/'/g" - echo "$DATE $TIME" - echo "--" - echo - done < <(cat $USER_DATA/notifications.conf) -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - while read str; do - eval $str - TOPIC=$(echo "$TOPIC" |sed -e "s/%quote%/'/g") - NOTICE=$(echo "$NOTICE" |sed -e "s/%quote%/'/g") - echo -e "$NID\t$TOPIC\t$NOTICE\t$TIME\t$DATE" - done < <(cat $USER_DATA/notifications.conf) -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo "NID,TOPIC,NOTICE,TIME,DATE" - while read str; do - eval $str - TOPIC=$(echo "$TOPIC" |sed -e "s/%quote%/'/g") - NOTICE=$(echo "$NOTICE" |sed -e "s/%quote%/'/g") - echo "$NID,\"$TOPIC\",\"$NOTICE\",$TIME,$DATE" - done < <(cat $USER_DATA/notifications.conf) -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking args -check_args '1' "$#" 'USER [FORMAT]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-user-ns b/bin/v-list-user-ns deleted file mode 100755 index 7754285d6..000000000 --- a/bin/v-list-user-ns +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash -# info: list user nameservers -# options: USER [FORMAT] -# -# Function for obtaining the list of user's DNS servers. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - i=1 - objects=$(echo -e "${ns//,/\\n}" |wc -l) - echo '[' - for nameserver in ${ns//,/ };do - if [ "$i" -ne "$objects" ]; then - echo -e "\t\"$nameserver\"," - else - echo -e "\t\"$nameserver\"" - fi - (( ++i)) - done - echo ']' -} - -# SHELL list function -shell_list() { - echo "NS" - echo "--" - for nameserver in ${ns//,/ };do - echo "$nameserver" - done -} - -# PLAIN list function -plain_list() { - for nameserver in ${ns//,/ };do - echo "$nameserver" - done -} - -# CSV list function -csv_list() { - echo "NAMESERVER" - for nameserver in ${ns//,/ };do - echo "$nameserver" - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing name servers -ns=$(grep "^NS='" $USER_DATA/user.conf |cut -f 2 -d \') - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-user-package b/bin/v-list-user-package deleted file mode 100755 index 74ce4b145..000000000 --- a/bin/v-list-user-package +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/bash -# info: list user package -# options: PACKAGE [FORMAT] -# -# The function for getting the list of system ip parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -package=$1 -PACKAGE=$package -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{' - echo ' "'$PACKAGE'": { - "WEB_TEMPLATE": "'$WEB_TEMPLATE'", - "BACKEND_TEMPLATE": "'$BACKEND_TEMPLATE'", - "PROXY_TEMPLATE": "'$PROXY_TEMPLATE'", - "DNS_TEMPLATE": "'$DNS_TEMPLATE'", - "WEB_DOMAINS": "'$WEB_DOMAINS'", - "WEB_ALIASES": "'$WEB_ALIASES'", - "DNS_DOMAINS": "'$DNS_DOMAINS'", - "DNS_RECORDS": "'$DNS_RECORDS'", - "MAIL_DOMAINS": "'$MAIL_DOMAINS'", - "MAIL_ACCOUNTS": "'$MAIL_ACCOUNTS'", - "DATABASES": "'$DATABASES'", - "CRON_JOBS": "'$CRON_JOBS'", - "DISK_QUOTA": "'$DISK_QUOTA'", - "BANDWIDTH": "'$BANDWIDTH'", - "NS": "'$NS'", - "SHELL": "'$SHELL'", - "BACKUPS": "'$BACKUPS'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - echo '}' -} - -# SHELL list function -shell_list() { - echo "PACKAGE: $PACKAGE" - echo "WEB TEMPLATE: $WEB_TEMPLATE" - echo "BACKEND_TEMPLATE: $BACKEND_TEMPLATE" - echo "PROXY TEMPLATE: $PROXY_TEMPLATE" - echo "DNS TEMPLATE: $DNS_TEMPLATE" - echo "WEB DOMAINS: $WEB_DOMAINS" - echo "WEB ALIASES: $WEB_ALIASES" - echo "DNS DOMAINS: $DNS_DOMAINS" - echo "DNS RECORDS: $DNS_RECORDS" - echo "MAIL DOMAINS: $MAIL_DOMAINS" - echo "MAIL ACCOUNTS: $MAIL_ACCOUNTS" - echo "DATABASES: $DATABASES" - echo "CRON JOBS: $CRON_JOBS" - echo "DISK QUOTA: $DISK_QUOTA" - echo "BANDWIDTH: $BANDWIDTH" - echo "NS: $NS" - echo "SHELL: $SHELL" - echo "BACKUPS: $BACKUPS" - echo "TIME: $TIME" - echo "DATE: $DATE" -} - -# PLAIN list function -plain_list() { - echo -ne "$PACKAGE\t$WEB_TEMPLATE\t$BACKEND_TEMPLATE\t$PROXY_TEMPLATE\t$DNS_TEMPLATE\t" - echo -ne "$WEB_DOMAINS\t$WEB_ALIASES\t$DNS_DOMAINS\t$DNS_RECORDS\t" - echo -ne "$MAIL_DOMAINS\t$MAIL_ACCOUNTS\t$DATABASES\t$CRON_JOBS\t" - echo -e "$DISK_QUOTA\t$BANDWIDTH\t$NS\t$SHELL\t$BACKUPS\t$TIME\t$DATE" -} - -# CSV list function -csv_list() { - echo -n "PACKAGE,WEB_TEMPLATE,BACKEND_TEMPLATE,PROXY_TEMPLATE,DNS_TEMPLATE," - echo -n "WEB_DOMAINS,WEB_ALIASES,DNS_DOMAINS,DNS_RECORDS," - echo -n "MAIL_DOMAINS,MAIL_ACCOUNTS,DATABASES,CRON_JOBS," - echo "DISK_QUOTA,BANDWIDTH,NS,SHELL,BACKUPS,TIME,DATE" - echo -n "$PACKAGE,$WEB_TEMPLATE,$BACKEND_TEMPLATE,$PROXY_TEMPLATE,$DNS_TEMPLATE," - echo -n "$WEB_DOMAINS,$WEB_ALIASES,$DNS_DOMAINS,$DNS_RECORDS," - echo -n "$MAIL_DOMAINS,$MAIL_ACCOUNTS,$DATABASES,$CRON_JOBS," - echo "$DISK_QUOTA,$BANDWIDTH,\"$NS\",$SHELL,$BACKUPS,$TIME,$DATE" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking args -check_args '1' "$#" 'PACKAGE [FORMAT]' -is_format_valid 'package' -is_package_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing package -source $VESTA/data/packages/$PACKAGE.pkg - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-user-packages b/bin/v-list-user-packages deleted file mode 100755 index 6808022cd..000000000 --- a/bin/v-list-user-packages +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/bash -# info: list user packages -# options: [FORMAT] -# -# The function for obtaining the list of available hosting packages. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(echo "$packages" |wc -l) - echo "{" - for package in $packages; do - PACKAGE=${package/.pkg/} - source $VESTA/data/packages/$package - echo -n ' "'$PACKAGE'": { - "WEB_TEMPLATE": "'$WEB_TEMPLATE'", - "BACKEND_TEMPLATE": "'$BACKEND_TEMPLATE'", - "PROXY_TEMPLATE": "'$PROXY_TEMPLATE'", - "DNS_TEMPLATE": "'$DNS_TEMPLATE'", - "WEB_DOMAINS": "'$WEB_DOMAINS'", - "WEB_ALIASES": "'$WEB_ALIASES'", - "DNS_DOMAINS": "'$DNS_DOMAINS'", - "DNS_RECORDS": "'$DNS_RECORDS'", - "MAIL_DOMAINS": "'$MAIL_DOMAINS'", - "MAIL_ACCOUNTS": "'$MAIL_ACCOUNTS'", - "DATABASES": "'$DATABASES'", - "CRON_JOBS": "'$CRON_JOBS'", - "DISK_QUOTA": "'$DISK_QUOTA'", - "BANDWIDTH": "'$BANDWIDTH'", - "NS": "'$NS'", - "SHELL": "'$SHELL'", - "BACKUPS": "'$BACKUPS'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done - echo '}' -} - -# SHELL list function -shell_list() { - echo "PKG TPL WEB DNS MAIL DB SHELL DISK BW" - echo "--- --- --- --- ---- -- ----- ---- --" - for package in $packages; do - source $VESTA/data/packages/$package - PACKAGE=${package/.pkg/} - package_data=$(cat $VESTA/data/packages/$package) - package_data=$(echo "$package_data" |sed -e 's/unlimited/unlim/g') - eval $package_data - echo -n "$PACKAGE $WEB_TEMPLATE $BACKEND_TEMPLATE $WEB_DOMAINS $DNS_DOMAINS " - echo "$MAIL_DOMAINS $DATABASES $SHELL $DISK_QUOTA $BANDWIDTH" - done -} - -# PLAIN list function -plain_list() { - for package in $packages; do - source $VESTA/data/packages/$package - PACKAGE=${package/.pkg/} - echo -ne "$PACKAGE\t$WEB_TEMPLATE\t$BACKEND_TEMPLATE\t$PROXY_TEMPLATE\t$DNS_TEMPLATE\t" - echo -ne "$WEB_DOMAINS\t$WEB_ALIASES\t$DNS_DOMAINS\t$DNS_RECORDS\t" - echo -ne "$MAIL_DOMAINS\t$MAIL_ACCOUNTS\t$DATABASES\t$CRON_JOBS\t" - echo -e "$DISK_QUOTA\t$BANDWIDTH\t$NS\t$SHELL\t$BACKUPS\t$TIME\t$DATE" - done -} - -# CSV list function -csv_list() { - echo -n "PACKAGE,WEB_TEMPLATE,BACKEND_TEMPLATE,PROXY_TEMPLATE,DNS_TEMPLATE," - echo -n "WEB_DOMAINS,WEB_ALIASES,DNS_DOMAINS,DNS_RECORDS," - echo -n "MAIL_DOMAINS,MAIL_ACCOUNTS,DATABASES,CRON_JOBS," - echo "DISK_QUOTA,BANDWIDTH,NS,SHELL,BACKUPS,TIME,DATE" - for package in $packages; do - PACKAGE=${package/.pkg/} - echo -n "$PACKAGE,$WEB_TEMPLATE,$BACKEND_TEMPLATE,$PROXY_TEMPLATE,$DNS_TEMPLATE," - echo -n "$WEB_DOMAINS,$WEB_ALIASES,$DNS_DOMAINS,$DNS_RECORDS," - echo -n "$MAIL_DOMAINS,$MAIL_ACCOUNTS,$DATABASES,$CRON_JOBS," - echo "$DISK_QUOTA,$BANDWIDTH,\"$NS\",$SHELL,$BACKUPS,$TIME,$DATE" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing packages -packages=$(ls --sort=time $VESTA/data/packages |grep .pkg) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-user-stats b/bin/v-list-user-stats deleted file mode 100755 index 0fa7dc900..000000000 --- a/bin/v-list-user-stats +++ /dev/null @@ -1,145 +0,0 @@ -#!/bin/bash -# info: list user stats -# options: [FORMAT] -# -# The function for listing user statistics - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(grep DATE $USER_DATA/stats.log |wc -l) - echo "{" - while read str; do - eval $str - echo -n ' "'$DATE'": { - "TIME": "'$TIME'", - "PACKAGE": "'$PACKAGE'", - "IP_OWNED": "'$IP_OWNED'", - "DISK_QUOTA": "'$DISK_QUOTA'", - "U_DISK": "'$U_DISK'", - "U_DISK_DIRS": "'$U_DISK_DIRS'", - "U_DISK_WEB": "'$U_DISK_WEB'", - "U_DISK_MAIL": "'$U_DISK_MAIL'", - "U_DISK_DB": "'$U_DISK_DB'", - "BANDWIDTH": "'$BANDWIDTH'", - "U_BANDWIDTH": "'$U_BANDWIDTH'", - "U_WEB_DOMAINS": "'$U_WEB_DOMAINS'", - "U_WEB_SSL": "'$U_WEB_SSL'", - "U_WEB_ALIASES": "'$U_WEB_ALIASES'", - "U_DNS_DOMAINS": "'$U_DNS_DOMAINS'", - "U_DNS_RECORDS": "'$U_DNS_RECORDS'", - "U_MAIL_DOMAINS": "'$U_MAIL_DOMAINS'", - "U_MAIL_DKIM": "'$U_MAIL_DKIM'", - "U_MAIL_ACCOUNTS": "'$U_MAIL_ACCOUNTS'", - "U_DATABASES": "'$U_DATABASES'", - "U_CRON_JOBS": "'$U_CRON_JOBS'", - "U_BACKUPS": "'$U_BACKUPS'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(cat $USER_DATA/stats.log) - echo '}' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "DATE WEB DNS MAIL DB BACKUPS IP DISK BW" - echo "---- --- --- ---- -- ------- -- ---- --" - while read str; do - eval $str - if [ -z "$U_USERS" ]; then - U_USERS=1 - fi - echo -n "$DATE $U_WEB_DOMAINS $U_DNS_DOMAINS " - echo -n "$U_MAIL_DOMAINS $U_DATABASES $U_BACKUPS $IP_OWNED " - echo "$U_DISK $U_BANDWIDTH" - done < <(cat $USER_DATA/stats.log) -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - while read str; do - eval $str - echo -ne "$DATE\t$TIME\t$PACKAGE\t$IP_OWNED\t$DISK_QUOTA\t$U_DISK\t" - echo -ne "$U_DISK_DIRS\t$U_DISK_WEB\t$U_DISK_MAIL\t$U_DISK_DB\t" - echo -ne "$BANDWIDTH\t$U_BANDWIDTH\t$U_WEB_DOMAINS\t$U_WEB_SSL\t" - echo -ne "$U_WEB_ALIASES\t$U_DNS_DOMAINS\t$U_DNS_RECORDS\t" - echo -ne "$U_MAIL_DOMAINS\t$U_MAIL_DKIM\t$U_MAIL_ACCOUNTS\t" - echo -e "$U_DATABASES\t$U_CRON_JOBS\t$U_BACKUPS" - done < <(cat $USER_DATA/stats.log) -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo -n "DATE,TIME,PACKAGE,IP_OWNED,DISK_QUOTA,U_DISK," - echo -n "U_DISK_DIRS,U_DISK_WEB,U_DISK_MAIL,U_DISK_DB," - echo -n "BANDWIDTH,U_BANDWIDTH,U_WEB_DOMAINS,U_WEB_SSL," - echo -n "U_WEB_ALIASES,U_DNS_DOMAINS,U_DNS_RECORDS," - echo -n "U_MAIL_DOMAINS,U_MAIL_DKIM,U_MAIL_ACCOUNTS," - echo "U_DATABASES,U_CRON_JOBS,U_BACKUPS" - - while read str; do - eval $str - echo -n "$DATE,$TIME,$PACKAGE,$IP_OWNED,$DISK_QUOTA,$U_DISK," - echo -n "$U_DISK_DIRS,$U_DISK_WEB,$U_DISK_MAIL,$U_DISK_DB," - echo -n "$BANDWIDTH,$U_BANDWIDTH,$U_WEB_DOMAINS,$U_WEB_SSL," - echo -n "$U_WEB_ALIASES,$U_DNS_DOMAINS,$U_DNS_RECORDS," - echo -n "$U_MAIL_DOMAINS,$U_MAIL_DKIM,$U_MAIL_ACCOUNTS," - echo "$U_DATABASES,$U_CRON_JOBS,$U_BACKUPS" - done < <(cat $USER_DATA/stats.log) -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/stats.log -if [ ! -e "$conf" ]; then - touch $conf -fi - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-users b/bin/v-list-users deleted file mode 100755 index 32a947366..000000000 --- a/bin/v-list-users +++ /dev/null @@ -1,188 +0,0 @@ -#!/bin/bash -# info: list users -# options: [FORMAT] -# -# The function to obtain the list of all system users. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# JSON list function -json_list() { - echo '{' - i=1 - while read USER; do - if [ ! -f "$VESTA/data/users/$USER/user.conf" ]; then - continue; - fi - if [ $i -gt 1 ]; then - echo "," - fi - source $VESTA/data/users/$USER/user.conf - echo -n ' "'$USER'": { - "FNAME": "'$FNAME'", - "LNAME": "'$LNAME'", - "PACKAGE": "'$PACKAGE'", - "WEB_TEMPLATE": "'$WEB_TEMPLATE'", - "BACKEND_TEMPLATE": "'$BACKEND_TEMPLATE'", - "PROXY_TEMPLATE": "'$PROXY_TEMPLATE'", - "DNS_TEMPLATE": "'$DNS_TEMPLATE'", - "WEB_DOMAINS": "'$WEB_DOMAINS'", - "WEB_ALIASES": "'$WEB_ALIASES'", - "DNS_DOMAINS": "'$DNS_DOMAINS'", - "DNS_RECORDS": "'$DNS_RECORDS'", - "MAIL_DOMAINS": "'$MAIL_DOMAINS'", - "MAIL_ACCOUNTS": "'$MAIL_ACCOUNTS'", - "DATABASES": "'$DATABASES'", - "CRON_JOBS": "'$CRON_JOBS'", - "DISK_QUOTA": "'$DISK_QUOTA'", - "BANDWIDTH": "'$BANDWIDTH'", - "NS": "'$NS'", - "SHELL": "'$SHELL'", - "BACKUPS": "'$BACKUPS'", - "CONTACT": "'$CONTACT'", - "CRON_REPORTS": "'$CRON_REPORTS'", - "RKEY": "'$RKEY'", - "SUSPENDED": "'$SUSPENDED'", - "SUSPENDED_USERS": "'$SUSPENDED_USERS'", - "SUSPENDED_WEB": "'$SUSPENDED_WEB'", - "SUSPENDED_DNS": "'$SUSPENDED_DNS'", - "SUSPENDED_MAIL": "'$SUSPENDED_MAIL'", - "SUSPENDED_DB": "'$SUSPENDED_DB'", - "SUSPENDED_CRON": "'$SUSPENDED_CRON'", - "IP_AVAIL": "'$IP_AVAIL'", - "IP_OWNED": "'$IP_OWNED'", - "U_USERS": "'$U_USERS'", - "U_DISK": "'$U_DISK'", - "U_DISK_DIRS": "'$U_DISK_DIRS'", - "U_DISK_WEB": "'$U_DISK_WEB'", - "U_DISK_MAIL": "'$U_DISK_MAIL'", - "U_DISK_DB": "'$U_DISK_DB'", - "U_BANDWIDTH": "'$U_BANDWIDTH'", - "U_WEB_DOMAINS": "'$U_WEB_DOMAINS'", - "U_WEB_SSL": "'$U_WEB_SSL'", - "U_WEB_ALIASES": "'$U_WEB_ALIASES'", - "U_DNS_DOMAINS": "'$U_DNS_DOMAINS'", - "U_DNS_RECORDS": "'$U_DNS_RECORDS'", - "U_MAIL_DOMAINS": "'$U_MAIL_DOMAINS'", - "U_MAIL_DKIM": "'$U_MAIL_DKIM'", - "U_MAIL_ACCOUNTS": "'$U_MAIL_ACCOUNTS'", - "U_DATABASES": "'$U_DATABASES'", - "U_CRON_JOBS": "'$U_CRON_JOBS'", - "U_BACKUPS": "'$U_BACKUPS'", - "LANGUAGE": "'$LANGUAGE'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - ((i++)) - done < <(grep '@' /etc/passwd |cut -f1 -d:) - echo '}' -} - -# SHELL list function -shell_list() { - echo "USER PKG WEB DNS MAIL DB DISK BW SPND DATE" - echo "---- --- --- --- --- -- ---- -- ---- ----" - while read USER; do - if [ ! -f "$VESTA/data/users/$USER/user.conf" ]; then - continue; - fi - source $VESTA/data/users/$USER/user.conf - echo -n "$USER $PACKAGE $U_WEB_DOMAINS $U_DNS_DOMAINS $U_MAIL_DOMAINS" - echo " $U_DATABASES $U_DISK $U_BANDWIDTH $SUSPENDED $DATE" - done < <(grep '@' /etc/passwd |cut -f1 -d:) -} - -# PLAIN list function -plain_list() { - while read USER; do - if [ ! -f "$VESTA/data/users/$USER/user.conf" ]; then - continue; - fi - source $VESTA/data/users/$USER/user.conf - echo -ne "$USER\t$FNAME\t$LNAME\t$PACKAGE\t$WEB_TEMPLATE\t" - echo -ne "$BACKEND_TEMPLATE\t$PROXY_TEMPLATE\t$DNS_TEMPLATE\t" - echo -ne "$WEB_DOMAINS\t$WEB_ALIASES\t$DNS_DOMAINS\t$DNS_RECORDS\t" - echo -ne "$MAIL_DOMAINS\t$MAIL_ACCOUNTS\t$DATABASES\t$CRON_JOBS\t" - echo -ne "$DISK_QUOTA\t$BANDWIDTH\t$NS\t$SHELL\t$BACKUPS\t" - echo -ne "$CONTACT\t$CRON_REPORTS\t$RKEY\t$SUSPENDED\t" - echo -ne "$SUSPENDED_USERS\t$SUSPENDED_WEB\t$SUSPENDED_DNS\t" - echo -ne "$SUSPENDED_MAIL\t$SUSPENDED_DB\t$SUSPENDED_CRON\t" - echo -ne "$IP_AVAIL\t$IP_OWNED\t$U_USERS\t$U_DISK\t$U_DISK_DIRS\t" - echo -ne "$U_DISK_WEB\t$U_DISK_MAIL\t$U_DISK_DB\t$U_BANDWIDTH\t" - echo -ne "$U_WEB_DOMAINS\t$U_WEB_SSL\t$U_WEB_ALIASES\t" - echo -ne "$U_DNS_DOMAINS\t$U_DNS_RECORDS\t$U_MAIL_DOMAINS\t" - echo -ne "$U_MAIL_DKIM\t$U_MAIL_ACCOUNTS\t$U_DATABASES\t" - echo -e "$U_CRON_JOBS\t$U_BACKUPS\t$LANGUAGE\t$TIME\t$DATE\t" - done < <(grep '@' /etc/passwd |cut -f1 -d:) -} - -# CSV list function -csv_list() { - echo -n "USER,FNAME,LNAME,PACKAGE,WEB_TEMPLATE,BACKEND_TEMPLATE," - echo -n "PROXY_TEMPLATE,DNS_TEMPLATE,WEB_DOMAINS,WEB_ALIASES," - echo -n "DNS_DOMAINS,DNS_RECORDS,MAIL_DOMAINS,MAIL_ACCOUNTS," - echo -n "DATABASES,CRON_JOBS,DISK_QUOTA,BANDWIDTH,NS,HOME,SHELL," - echo -n "BACKUPS,CONTACT,CRON_REPORTS,RKEY,SUSPENDED,SUSPENDED_USERS," - echo -n "SUSPENDED_WEB,SUSPENDED_DNS,SUSPENDED_MAIL,SUSPENDED_DB," - echo -n "SUSPENDED_CRON,IP_AVAIL,IP_OWNED,U_USERS,U_DISK,U_DISK_DIRS," - echo -n "U_DISK_WEB,U_DISK_MAIL,U_DISK_DB,U_BANDWIDTH,U_WEB_DOMAINS," - echo -n "U_WEB_SSL,U_WEB_ALIASES,U_DNS_DOMAINS,U_DNS_RECORDS," - echo -n "U_MAIL_DOMAINS,U_MAIL_DKIM,U_MAIL_ACCOUNTS,U_DATABASES" - echo "U_CRON_JOBS,U_BACKUPS,LANGUAGE,TIME,DATE" - while read USER; do - if [ ! -f "$VESTA/data/users/$USER/user.conf" ]; then - continue; - fi - source $VESTA/data/users/$USER/user.conf - echo -n "$USER,\"$FNAME\",\"$LNAME\",$PACKAGE,$WEB_TEMPLATE," - echo -n "$BACKEND_TEMPLATE,$PROXY_TEMPLATE,$DNS_TEMPLATE," - echo -n "$WEB_DOMAINS,$WEB_ALIASES,$DNS_DOMAINS,$DNS_RECORDS," - echo -n "$MAIL_DOMAINS,$MAIL_ACCOUNTS,$DATABASES,$CRON_JOBS," - echo -n "$DISK_QUOTA,$BANDWIDTH,\"$NS\",$HOME,$SHELL,$BACKUPS," - echo -n "$CONTACT,$CRON_REPORTS,\"$RKEY\",$SUSPENDED," - echo -n "$SUSPENDED_USERS,$SUSPENDED_WEB,$SUSPENDED_DNS," - echo -n "$SUSPENDED_MAIL,$SUSPENDED_DB,$SUSPENDED_CRON,$IP_AVAIL," - echo -n "$IP_OWNED,$U_USERS,$U_DISK,$U_DISK_DIRS,$U_DISK_WEB," - echo -n "$U_DISK_MAIL,$U_DISK_DB,$U_BANDWIDTH,$U_WEB_DOMAINS," - echo -n "$U_WEB_SSL,$U_WEB_ALIASES,$U_DNS_DOMAINS,$U_DNS_RECORDS," - echo -n "$U_MAIL_DOMAINS,$U_MAIL_DKIM,$U_MAIL_ACCOUNTS,$U_DATABASES," - echo "$U_CRON_JOBS,$U_BACKUPS,$LANGUAGE,$TIME,$DATE" - done < <(grep '@' /etc/passwd |cut -f1 -d:) -} - -# Raw list function -raw_list() { - while read USER; do - if [ ! -f "$VESTA/data/users/$USER/user.conf" ]; then - continue; - fi - echo $VESTA/data/users/$USER/user.conf - cat $VESTA/data/users/$USER/user.conf - done < <(grep '@' /etc/passwd |cut -f1 -d:) -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-users-stats b/bin/v-list-users-stats deleted file mode 100755 index 2a267964c..000000000 --- a/bin/v-list-users-stats +++ /dev/null @@ -1,143 +0,0 @@ -#!/bin/bash -# info: list overall user stats -# options: [FORMAT] -# -# The function for listing overall user statistics - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(grep DATE $VESTA/data/users/admin/overall_stats.log |wc -l) - echo "{" - while read str; do - eval $str - echo -n ' "'$DATE'": { - "TIME": "'$TIME'", - "PACKAGE": "'$PACKAGE'", - "IP_OWNED": "'$IP_OWNED'", - "DISK_QUOTA": "'$DISK_QUOTA'", - "U_DISK": "'$U_DISK'", - "U_DISK_DIRS": "'$U_DISK_DIRS'", - "U_DISK_WEB": "'$U_DISK_WEB'", - "U_DISK_MAIL": "'$U_DISK_MAIL'", - "U_DISK_DB": "'$U_DISK_DB'", - "BANDWIDTH": "'$BANDWIDTH'", - "U_BANDWIDTH": "'$U_BANDWIDTH'", - "U_WEB_DOMAINS": "'$U_WEB_DOMAINS'", - "U_WEB_SSL": "'$U_WEB_SSL'", - "U_WEB_ALIASES": "'$U_WEB_ALIASES'", - "U_DNS_DOMAINS": "'$U_DNS_DOMAINS'", - "U_DNS_RECORDS": "'$U_DNS_RECORDS'", - "U_MAIL_DOMAINS": "'$U_MAIL_DOMAINS'", - "U_MAIL_DKIM": "'$U_MAIL_DKIM'", - "U_MAIL_ACCOUNTS": "'$U_MAIL_ACCOUNTS'", - "U_DATABASES": "'$U_DATABASES'", - "U_CRON_JOBS": "'$U_CRON_JOBS'", - "U_BACKUPS": "'$U_BACKUPS'", - "U_USERS": "'$U_USERS'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(cat $VESTA/data/users/admin/overall_stats.log) - echo '}' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "DATE USER WEB DNS MAIL DB BACKUPS IP DISK BW" - echo "---- ---- --- --- ---- -- ------- -- ---- --" - while read str; do - eval $str - if [ -z "$U_USERS" ]; then - U_USERS=1 - fi - echo -n "$DATE $U_USERS $U_WEB_DOMAINS $U_DNS_DOMAINS " - echo -n "$U_MAIL_DOMAINS $U_DATABASES $U_BACKUPS $IP_OWNED " - echo "$U_DISK $U_BANDWIDTH" - done < <(cat $VESTA/data/users/admin/overall_stats.log) -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - while read str; do - eval $str - echo -ne "$DATE\t$TIME\t$PACKAGE\t$IP_OWNED\t$DISK_QUOTA\t$U_DISK\t" - echo -ne "$U_DISK_DIRS\t$U_DISK_WEB\t$U_DISK_MAIL\t$U_DISK_DB\t" - echo -ne "$BANDWIDTH\t$U_BANDWIDTH\t$U_WEB_DOMAINS\t$U_WEB_SSL\t" - echo -ne "$U_WEB_ALIASES\t$U_DNS_DOMAINS\t$U_DNS_RECORDS\t" - echo -ne "$U_MAIL_DOMAINS\t$U_MAIL_DKIM\t$U_MAIL_ACCOUNTS\t" - echo -e "$U_DATABASES\t$U_CRON_JOBS\t$U_BACKUPS\t$U_USERS" - done < <(cat $VESTA/data/users/admin/overall_stats.log) -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo -n "DATE,TIME,PACKAGE,IP_OWNED,DISK_QUOTA,U_DISK," - echo -n "U_DISK_DIRS,U_DISK_WEB,U_DISK_MAIL,U_DISK_DB," - echo -n "BANDWIDTH,U_BANDWIDTH,U_WEB_DOMAINS,U_WEB_SSL," - echo -n "U_WEB_ALIASES,U_DNS_DOMAINS,U_DNS_RECORDS," - echo -n "U_MAIL_DOMAINS,U_MAIL_DKIM,U_MAIL_ACCOUNTS," - echo "U_DATABASES,U_CRON_JOBS,U_BACKUPS,U_USERS" - - while read str; do - eval $str - echo -n "$DATE,$TIME,$PACKAGE,$IP_OWNED,$DISK_QUOTA,$U_DISK," - echo -n "$U_DISK_DIRS,$U_DISK_WEB,$U_DISK_MAIL,$U_DISK_DB," - echo -n "$BANDWIDTH,$U_BANDWIDTH,$U_WEB_DOMAINS,$U_WEB_SSL," - echo -n "$U_WEB_ALIASES,$U_DNS_DOMAINS,$U_DNS_RECORDS," - echo -n "$U_MAIL_DOMAINS,$U_MAIL_DKIM,$U_MAIL_ACCOUNTS," - echo "$U_DATABASES,$U_CRON_JOBS,$U_BACKUPS,$U_USERS" - done < <(cat $VESTA/data/users/admin/overall_stats.log) -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '0' "$#" '[FORMAT]' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$VESTA/data/users/admin/overall_stats.log -if [ ! -e "$conf" ]; then - touch $conf -fi - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-web-domain b/bin/v-list-web-domain deleted file mode 100755 index 7e33a4ab0..000000000 --- a/bin/v-list-web-domain +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/bash -# info: list web domain parameters -# options: USER DOMAIN [FORMAT] -# -# The function to obtain web domain parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - echo '{' - echo ' "'$DOMAIN'": { - "IP": "'$IP'", - "IP6": "'$IP6'", - "U_DISK": "'$U_DISK'", - "U_BANDWIDTH": "'$U_BANDWIDTH'", - "TPL": "'$TPL'", - "ALIAS": "'$ALIAS'", - "STATS": "'$STATS'", - "STATS_USER": "'$STATS_USER'", - "SSL": "'$SSL'", - "SSL_HOME": "'$SSL_HOME'", - "LETSENCRYPT": "'$LETSENCRYPT'", - "FTP_USER": "'$FTP_USER'", - "FTP_PATH": "'$FTP_PATH'", - "AUTH_USER": "'$AUTH_USER'", - "BACKEND": "'$BACKEND'", - "PROXY": "'$PROXY'", - "PROXY_EXT": "'$PROXY_EXT'", - "DOCUMENT_ROOT": "'$HOMEDIR/$user/web/$domain/public_html'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - echo '}' -} - -# SHELL list function -shell_list() { - source $VESTA/conf/vesta.conf - echo "DOMAIN: $DOMAIN" - echo "ALIAS: ${ALIAS//,/ }" - echo "IP: $IP" - if [ ! -z "$IP6" ]; then - echo "IP6: $IP6" - fi - if [ ! -z "$SSL" ] && [ "$SSL" != 'no' ]; then - echo "SSL: $SSL / $SSL_HOME" - if [ ! -z "$LETSENCRYPT" ] && [ "$LETSENCRYPT" != 'no' ]; then - echo "LETSENCRYPT: $LETSENCRYPT" - fi - fi - echo "TEMPLATE: $TPL" - if [ ! -z "$WEB_BACKEND" ]; then - echo "BACKEND: $BACKEND" - fi - if [ ! -z "$PROXY_SYSTEM" ]; then - echo "PROXY: $PROXY" - echo "PROXY EXT: ${PROXY_EXT//,/ }" - fi - if [ ! -z "$STATS" ]; then - echo "STATS: $STATS" - fi - if [ ! -z "$FTP_USER" ]; then - echo "FTP_USER: ${FTP_USER//,/, }" - fi - if [ ! -z "$AUTH_USER" ]; then - echo "HTTP_AUTH: $AUTH_USER" - fi - echo "DISK: $U_DISK" - echo "BW: $U_BANDWIDTH" - echo "SUSPENDED: $SUSPENDED" - echo "TIME: $TIME" - echo "DATE: $DATE" -} - -# PLAIN list function -plain_list() { - echo -ne "$DOMAIN\t$IP\t$IP6\t$U_DISK\t$U_BANDWIDTH\t$TPL\t" - echo -ne "$ALIAS\t$STATS\t$STATS_USER\t$SSL\t$SSL_HOME\t,$LETSENCRYPT" - echo -ne "$FTP_USER\t$FTP_PATH\t$AUTH_USER\t$BACKEND\t$PROXY\t" - echo -e "$PROXY_EXT\t$SUSPENDED\t$TIME\t$DATE" -} - -# CSV list function -csv_list() { - echo -n "DOMAIN,IP,IP6,U_DISK,U_BANDWIDTH,TPL,ALIAS,STATS,STATS_USER,SSL," - echo -n "SSL_HOME,LETSENCRYPT,FTP_USER,FTP_PATH,AUTH_USER,BACKEND,PROXY,PROXY_EXT," - echo "SUSPENDED,TIME,DATE" - echo -n "$DOMAIN,$IP,$IP6,$U_DISK,$U_BANDWIDTH,$TPL,\"$ALIAS\",$STATS" - echo -n "\"$STATS_USER\",$SSL,$SSL_HOME,$LETSENCRYPT,\"$FTP_USER\",\"$FTP_PATH\"," - echo -n "\"$AUTH_USER\",$BACKEND,$PROXY,\"$PROXY_EXT\",$SUSPENDED,$TIME," - echo "$DATE" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FORMAT]' -is_format_valid 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain -eval $(grep "DOMAIN='$domain'" $USER_DATA/web.conf) - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-web-domain-accesslog b/bin/v-list-web-domain-accesslog deleted file mode 100755 index 24362596c..000000000 --- a/bin/v-list-web-domain-accesslog +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -# info: list web domain access log -# options: USER DOMAIN [LINES] [FORMAT] -# -# The function of obtaining raw access web domain logs. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -ttl=${3-70} -format=${4-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# JSON list function -json_list() { - i=1 - objects=$(echo "$lines" |wc -l) - echo '[' - for str in $lines; do - str=$(echo "$str" |sed -e 's/"/\\"/g') - if [ "$i" -lt "$objects" ]; then - echo -e "\t\"$str\"," - else - echo -e "\t\"$str\"" - fi - (( ++i)) - done - echo "]" -} - -# SHELL list function -shell_list() { - echo "$lines" -} - -# PLAIN list function -plain_list() { - echo "$lines" -} - -# CSV list function -csv_list() { - echo "LOG" - echo "$lines" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [LINES] [FORMAT]' -is_format_valid 'user' 'domain' 'ttl' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Check number of output lines -if [ "$ttl" -gt '3000' ]; then - read_cmd="cat" -else - read_cmd="tail -n $ttl" -fi - -lines=$($read_cmd /var/log/$WEB_SYSTEM/domains/$domain.log) -IFS=$'\n' - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-web-domain-errorlog b/bin/v-list-web-domain-errorlog deleted file mode 100755 index 3e23ecfa1..000000000 --- a/bin/v-list-web-domain-errorlog +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -# info: list web domain error log -# options: USER DOMAIN [LINES] [FORMAT] -# -# The function of obtaining raw error web domain logs. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -ttl=${3-70} -format=${4-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# JSON list function -json_list() { - i=1 - objects=$(echo "$lines" |wc -l) - echo '[' - for str in $lines; do - str=$(echo "$str" |sed -e 's/"/\\"/g') - if [ "$i" -lt "$objects" ]; then - echo -e "\t\"$str\"," - else - echo -e "\t\"$str\"" - fi - (( ++i)) - done - echo "]" -} - -# SHELL list function -shell_list() { - echo "$lines" -} - -# PLAIN list function -plain_list() { - echo "$lines" -} - -# CSV list function -csv_list() { - echo "LOG" - echo "$lines" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [LINES] [FORMAT]' -is_format_valid 'user' 'domain' 'ttl' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Check number of output lines -if [ "$ttl" -gt '3000' ]; then - read_cmd="cat" -else - read_cmd="tail -n $ttl" -fi - -lines=$($read_cmd /var/log/$WEB_SYSTEM/domains/$domain.error.log) -IFS=$'\n' - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-web-domain-ssl b/bin/v-list-web-domain-ssl deleted file mode 100755 index bf69e3624..000000000 --- a/bin/v-list-web-domain-ssl +++ /dev/null @@ -1,148 +0,0 @@ -#!/bin/bash -# info: list web domain ssl certificate -# options: USER DOMAIN [FORMAT] -# -# The function of obtaining domain ssl files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - issuer=$(echo "$issuer" |sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - echo '{' - echo -e "\t\"$domain\": {" - echo " \"CRT\": \"$crt\"," - echo " \"KEY\": \"$key\"," - echo " \"CA\": \"$ca\"," - echo " \"SUBJECT\": \"$subj\"," - echo " \"ALIASES\": \"$alt_dns\"," - echo " \"NOT_BEFORE\": \"$before\"," - echo " \"NOT_AFTER\": \"$after\"," - echo " \"SIGNATURE\": \"$signature\"," - echo " \"PUB_KEY\": \"$pub_key\"," - echo " \"ISSUER\": \"$issuer\"" - echo -e "\t}\n}" -} - -# SHELL list function -shell_list() { - if [ ! -z "$crt" ]; then - echo -e "$crt" - fi - if [ ! -z "$key" ]; then - echo -e "\n$key" - fi - if [ ! -z "$ca" ]; then - echo -e "\n$ca" - fi - if [ ! -z "$crt" ]; then - echo - echo - echo "SUBJECT: $subj" - if [ ! -z "$alt_dns" ]; then - echo "ALIASES: ${alt_dns//,/ }" - fi - echo "VALID FROM: $before" - echo "VALID TIL: $after" - echo "SIGNATURE: $signature" - echo "PUB_KEY: $pub_key" - echo "ISSUER: $issuer" - fi -} - -# PLAIN list function -plain_list() { - if [ ! -z "$crt" ]; then - echo -e "$crt" - fi - if [ ! -z "$key" ]; then - echo -e "\n$key" - fi - if [ ! -z "$ca" ]; then - echo -e "\n$ca" - fi - if [ ! -z "$crt" ]; then - echo "$subj" - echo "${alt_dns//,/ }" - echo "$before" - echo "$after" - echo "$signature" - echo "$pub_key" - echo "$issuer" - fi - -} - -# CSV list function -csv_list() { - echo -n "CRT,KEY,CA,SUBJECT,ALIASES,NOT_BEFORE,NOT_AFTER,SIGNATURE," - echo "PUB_KEY,ISSUER" - echo -n "\"$crt\",\"$key\",\"$ca\",\"$subj\",\"${alt_dns//,/ }\"," - echo "\"$before\",\"$after\",\"$signature\",\"$pub_key\",\"$issuer\"" -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FORMAT]' -is_format_valid 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain SSL certificate -if [ -e "$USER_DATA/ssl/$domain.crt" ]; then - crt=$(cat $USER_DATA/ssl/$domain.crt |sed ':a;N;$!ba;s/\n/\\n/g') - - info=$(openssl x509 -text -in $USER_DATA/ssl/$domain.crt) - subj=$(echo "$info" |grep Subject: |cut -f 2 -d =|cut -f 2 -d \") - before=$(echo "$info" |grep Before: |sed -e "s/.*Before: //") - after=$(echo "$info" |grep "After :" |sed -e "s/.*After : //") - signature=$(echo "$info" |grep "Algorithm:" |head -n1 ) - signature=$(echo "$signature"| sed -e "s/.*Algorithm: //") - pub_key=$(echo "$info" |grep Public-Key: |cut -f2 -d \( | tr -d \)) - issuer=$(echo "$info" |grep Issuer: |sed -e "s/.*Issuer: //") - alt_dns=$(echo "$info" |grep DNS |sed -e 's/DNS:/\n/g' |tr -d ',') - alt_dns=$(echo "$alt_dns" |tr -d ' ' |sed -e "/^$/d") - alt_dns=$(echo "$alt_dns" |sed -e ':a;N;$!ba;s/\n/,/g') -fi - -if [ -e "$USER_DATA/ssl/$domain.key" ]; then - key=$(cat $USER_DATA/ssl/$domain.key |sed ':a;N;$!ba;s/\n/\\n/g') -fi - -if [ -e "$USER_DATA/ssl/$domain.ca" ]; then - ca=$(cat $USER_DATA/ssl/$domain.ca |sed ':a;N;$!ba;s/\n/\\n/g') -fi - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-web-domains b/bin/v-list-web-domains deleted file mode 100755 index 23de5fb4f..000000000 --- a/bin/v-list-web-domains +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/bash -# info: list web domains -# options: USER [FORMAT] -# -# The function to obtain the list of all user web domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - IFS=$'\n' - i=1 - objects=$(grep DOMAIN $USER_DATA/web.conf |wc -l) - echo "{" - while read str; do - eval $str - echo -n ' "'$DOMAIN'": { - "IP": "'$IP'", - "IP6": "'$IP6'", - "U_DISK": "'$U_DISK'", - "U_BANDWIDTH": "'$U_BANDWIDTH'", - "TPL": "'$TPL'", - "ALIAS": "'$ALIAS'", - "STATS": "'$STATS'", - "STATS_USER": "'$STATS_USER'", - "SSL": "'$SSL'", - "SSL_HOME": "'$SSL_HOME'", - "LETSENCRYPT": "'$LETSENCRYPT'", - "FTP_USER": "'$FTP_USER'", - "FTP_PATH": "'$FTP_PATH'", - "AUTH_USER": "'$AUTH_USER'", - "BACKEND": "'$BACKEND'", - "PROXY": "'$PROXY'", - "PROXY_EXT": "'$PROXY_EXT'", - "SUSPENDED": "'$SUSPENDED'", - "TIME": "'$TIME'", - "DATE": "'$DATE'" - }' - if [ "$i" -lt "$objects" ]; then - echo ',' - else - echo - fi - ((i++)) - done < <(cat $USER_DATA/web.conf) - echo '}' -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "DOMAIN IP TPL SSL DISK BW SPND DATE" - echo "------ -- --- --- ---- -- ---- -----" - while read str; do - eval $str - echo "$DOMAIN $IP $TPL $SSL $U_DISK $U_BANDWIDTH $SUSPENDED $DATE" - done < <(cat $USER_DATA/web.conf) -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - while read str; do - eval $str - echo -ne "$DOMAIN\t$IP\t$IP6\t$U_DISK\t$U_BANDWIDTH\t$TPL\t" - echo -ne "$ALIAS\t$STATS\t$STATS_USER\t$SSL\t$SSL_HOME\t$LETSENCRYPT\t" - echo -ne "$FTP_USER\t$FTP_PATH\t$AUTH_USER\t$BACKEND\t$PROXY\t" - echo -e "$PROXY_EXT\t$SUSPENDED\t$TIME\t$DATE" - done < <(cat $USER_DATA/web.conf) -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo -n "DOMAIN,IP,IP6,U_DISK,U_BANDWIDTH,TPL,ALIAS,STATS,STATS_USER," - echo -n "SSL,SSL_HOME,LETSENCRYPT,FTP_USER,FTP_PATH,AUTH_USER,BACKEND,PROXY," - echo "PROXY_EXT,SUSPENDED,TIME,DATE" - while read str; do - eval $str - echo -n "$DOMAIN,$IP,$IP6,$U_DISK,$U_BANDWIDTH,$TPL," - echo -n "\"$ALIAS\",$STATS,\"$STATS_USER\",$SSL,$SSL_HOME,$LETSENCRYPT," - echo -n "\"$FTP_USER\",\"$FTP_PATH\",\"$AUTH_USER\",$BACKEND,$PROXY," - echo "\"$PROXY_EXT\",$SUSPENDED,$TIME,$DATE" - done < <(cat $USER_DATA/web.conf) -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-web-stats b/bin/v-list-web-stats deleted file mode 100755 index b48419d67..000000000 --- a/bin/v-list-web-stats +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# info: list web statistics -# options: [FORMAT] -# -# The function for obtaining the list of web statistics analyzer. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# JSON list function -json_list() { - objects=$(echo "$stats" | wc -w) - i=1 - echo '[' - for str in $stats; do - if [ "$i" -lt "$objects" ]; then - echo -e "\t\"$str\"," - else - echo -e "\t\"$str\"" - fi - (( ++i)) - done - echo "]" -} - -# SHELL list function -shell_list() { - echo "PARSER" - echo "------" - for parser in $stats; do - echo "$parser" - done -} - -# PLAIN list function -plain_list() { - for parser in $stats; do - echo "$parser" - done -} - -# CSV list function -csv_list() { - echo "PARSER" - for parser in $stats; do - echo "$parser" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing stats system -stats=$(echo "none ${STATS_SYSTEM//,/ }") - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-web-templates b/bin/v-list-web-templates deleted file mode 100755 index ec02c710f..000000000 --- a/bin/v-list-web-templates +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -# info: list web templates -# options: USER [FORMAT] -# -# The function for obtaining the list of web templates available to a user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# JSON list function -json_list() { - objects=$(echo "$templates" |wc -w) - i=1 - echo '[' - for template in $templates; do - if [ "$i" -lt "$objects" ]; then - echo -e "\t\"$template\"," - else - echo -e "\t\"$template\"" - fi - (( ++i)) - done - echo "]" -} - -# SHELL list function -shell_list() { - echo "TEMPLATE" - echo "--------" - for template in $templates; do - echo "$template" - done -} - -# PLAIN list function -plain_list() { - for template in $templates; do - echo "$template" - done -} - -# CSV list function -csv_list() { - echo "TEMPLATE" - for template in $templates; do - echo "$template" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing templates -templates=$(ls -v $WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/) -templates=$(echo "$templates" |grep '\.tpl' |sed 's/\.tpl$//') - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-web-templates-backend b/bin/v-list-web-templates-backend deleted file mode 100755 index 5536b7e83..000000000 --- a/bin/v-list-web-templates-backend +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# info: listing backend templates -# options: [FORMAT] -# -# The function for obtaining the list of available backend templates. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# JSON list function -json_list() { - i=1 - objects=$(echo "$templates" |wc -w) - echo '[' - for template in $templates; do - if [ "$i" -lt "$objects" ]; then - echo -e "\t\"$template\"," - else - echo -e "\t\"$template\"" - fi - (( ++i)) - done - echo "]" -} - -# SHELL list function -shell_list() { - echo "TEMPLATE" - echo "--------" - for template in $templates; do - echo "$template" - done -} - -# PLAIN list function -plain_list() { - for template in $templates; do - echo "$template" - done -} - -# CSV list function -csv_list() { - echo "TEMPLATE" - for template in $templates; do - echo "$template" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing backend templates -if [ ! -z "$WEB_BACKEND" ]; then - templates=$(ls -t $WEBTPL/$WEB_BACKEND |\ - cut -f1 -d . |\ - grep -v proxy_ip |\ - sort -u ) -fi - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-list-web-templates-proxy b/bin/v-list-web-templates-proxy deleted file mode 100755 index 0d827fc5a..000000000 --- a/bin/v-list-web-templates-proxy +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash -# info: listing proxy templates -# options: [FORMAT] -# -# The function for obtaining the list of proxy templates available to a user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# JSON list function -json_list() { - objects=$(echo "$templates" |wc -w) - i=1 - echo '[' - for template in $templates; do - if [ "$i" -lt "$objects" ]; then - echo -e "\t\"$template\"," - else - echo -e "\t\"$template\"" - fi - (( ++i)) - done - echo "]" -} - -# SHELL list function -shell_list() { - echo "TEMPLATE" - echo "--------" - for template in $templates; do - echo "$template" - done -} - -# PLAIN list function -plain_list() { - for template in $templates; do - echo "$template" - done -} - -# CSV list function -csv_list() { - echo "TEMPLATE" - for template in $templates; do - echo "$template" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing proxy templates -if [ ! -z "$PROXY_SYSTEM" ]; then - templates=$(ls -t $WEBTPL/$PROXY_SYSTEM |\ - grep ".tpl$" |\ - cut -f1 -d . |\ - grep -v proxy_ip |\ - sort -u ) -fi - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-move-fs-directory b/bin/v-move-fs-directory deleted file mode 100755 index f101d9955..000000000 --- a/bin/v-move-fs-directory +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -# info: move file -# options: USER SRC_DIRECTORY DST_DIRECTORY -# -# The function moved file or directory on the file system. This function -# can also be used to rename files just like normal mv command. - -user=$1 -src_dir=$2 -dst_dir=$3 - -# Checking arguments -if [ -z "$dst_dir" ]; then - echo "Usage: USER SRC_DIRECTORY DST_DIRECTORY" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking user homedir -homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) -if [ -z $homedir ]; then - echo "Error: user home directory doesn't exist" - exit 12 -fi - -# Checking source file -if [ ! -d "$src_dir" ]; then - echo "Error: source directory $src_dir doesn't exist" - exit 3 -fi - -# Checking source path -rpath=$(readlink -f "$src_dir") -if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid source path $src_dir" - exit 2 -fi - -# Checking destination path -rpath=$(readlink -f "$dst_dir") -if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid destination path $dst_dir" - exit 2 -fi - -# Moving directory -sudo -u $user mv "$src_dir" "$dst_dir" >/dev/null 2>&1 -if [ $? -ne 0 ]; then - echo "Error: directory $src_dir was not moved" - exit 3 -fi - -# Exiting -exit diff --git a/bin/v-move-fs-file b/bin/v-move-fs-file deleted file mode 100755 index 3671e0e58..000000000 --- a/bin/v-move-fs-file +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -# info: move file -# options: USER SRC_FILE DST_FLE -# -# The function moved file or directory on the file system. This function -# can also be used to rename files just like normal mv command. - -user=$1 -src_file=$2 -dst_file=$3 - -# Checking arguments -if [ -z "$dst_file" ]; then - echo "Usage: USER SRC_FILE DST_FILE" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking user homedir -homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) -if [ -z $homedir ]; then - echo "Error: user home directory doesn't exist" - exit 12 -fi - -# Checking source file -if [ ! -f "$src_file" ]; then - echo "Error: source file $src_file doesn't exist" - exit 3 -fi - -# Checking source path -rpath=$(readlink -f "$src_file") -if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid source path $src_file" - exit 2 -fi - -# Checking destination path -rpath=$(readlink -f "$dst_file") -if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid destination path $dst_file" - exit 2 -fi - -# Moving file -sudo -u $user mv "$src_file" "$dst_file" >/dev/null 2>&1 -if [ $? -ne 0 ]; then - echo "Error: file $src_file was not moved" - exit 3 -fi - -# Exiting -exit diff --git a/bin/v-open-fs-config b/bin/v-open-fs-config deleted file mode 100755 index 720df86a7..000000000 --- a/bin/v-open-fs-config +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# info: open config -# options: CONFIG -# -# The function opens/reads config files on the file system - -src_file=$1 - -# Checking arguments -if [ -z "$src_file" ]; then - echo "Usage: CONFIG" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking file on fs -if [ ! -e "$src_file" ]; then - echo "Error: $src_file file doesn't exist" - exit 3 -fi - -# Checking path -if [ ! -z "$src_file" ]; then - rpath=$(readlink -f "$src_file") - services="nginx|apache|httpd|php|ftp|bind|named|exim|dovecot|spamassassin" - services="$services|clam|mysql|postgresql|pgsql|cron|fail2ban|iptables" - services="$services|my.cnf" - spath=$(echo "$rpath" |egrep "$services") - if [ -z "$spath" ]; then - echo "Error: invalid source path $src_file" - exit 2 - fi - spath=$(echo "$rpath" |egrep "/etc|/var/lib") - if [ -z "$spath" ]; then - echo "Error: invalid source path $src_file" - exit 2 - fi -fi - -# Reading conf -cat "$src_file" 2>/dev/null -if [ $? -ne 0 ]; then - echo "Error: file $src_file was not opened" - exit 3 -fi - -# Exiting -exit diff --git a/bin/v-open-fs-file b/bin/v-open-fs-file deleted file mode 100755 index c51cd0b9f..000000000 --- a/bin/v-open-fs-file +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# info: open file -# options: USER FILE -# -# The function opens/reads files on the file system - -user=$1 -src_file=$2 - -# Checking arguments -if [ -z "$src_file" ]; then - echo "Usage: USER FILE" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking user homedir -homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) -if [ -z $homedir ]; then - echo "Error: user home directory doesn't exist" - exit 12 -fi - -# Checking path -if [ ! -z "$src_file" ]; then - rpath=$(readlink -f "$src_file") - if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then - echo "Error: invalid source path $src_file" - exit 2 - fi - - if [ ! -f "$src_file" ]; then - echo "Error: file not found $src_file" - exit 2 - fi -fi - -# Reading file -sudo -u $user cat "$src_file" 2>/dev/null -if [ $? -ne 0 ]; then - echo "Error: file $src_file was not opened" - exit 3 -fi - -# Exiting -exit diff --git a/bin/v-rebuild-cron-jobs b/bin/v-rebuild-cron-jobs deleted file mode 100755 index 40192b63d..000000000 --- a/bin/v-rebuild-cron-jobs +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# info: rebuild cron jobs -# options: USER [RESTART] -# -# The function rebuilds system cron config file for specified user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -restart=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -is_format_valid 'user' -is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Rebuild cron jobs -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting crond -$BIN/v-restart-cron $restart -check_result $? "Cron restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-rebuild-databases b/bin/v-rebuild-databases deleted file mode 100755 index 0b8f4a2d2..000000000 --- a/bin/v-rebuild-databases +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# info: rebuild databases -# options: USER -# -# The function for rebuilding of all databases of a single user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/db.sh -source $VESTA/func/rebuild.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Flush counters -U_DATABASES=0 -SUSPENDED_DB=0 -U_DISK_DB=0 - -# Starting rebuild loop -for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do - - # Get database values - get_database_values - - # Switching on db type - case $TYPE in - mysql) rebuild_mysql_database ;; - pgsql) rebuild_pgsql_database ;; - esac - - U_DISK_DB=$((U_DISK_DB + U_DISK)) - U_DATABASES=$((U_DATABASES + 1)) - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_DB=$((SUSPENDED_DB + 1)) - fi -done - -update_user_value "$user" '$SUSPENDED_DB' "$SUSPENDED_DB" -update_user_value "$user" '$U_DATABASES' "$U_DATABASES" -update_user_value "$user" '$U_DISK_DB' "$U_DISK_DB" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-rebuild-dns-domain b/bin/v-rebuild-dns-domain deleted file mode 100755 index 536392687..000000000 --- a/bin/v-rebuild-dns-domain +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash -# info: rebuild dns domain -# options: USER DOMAIN [RESTART] [UPDATE_SERIAL] -# -# The function rebuilds DNS configuration files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -restart=$3 -update_serial=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/rebuild.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [RESTART] [UPDATE_SERIAL]' -is_format_valid 'user' 'domain' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -user_domains=0 -user_records=0 -suspended_dns=0 -conf="$USER_DATA/dns.conf" - -# Defining user name servers -ns=$(get_user_value '$NS') -i=1 -for nameserver in ${ns//,/ };do - eval ns$i="$nameserver" - i=$((i + 1)) -done - -# Get dns config path -if [ -e '/etc/named.conf' ]; then - dns_conf='/etc/named.conf' -fi - -if [ -e '/etc/bind/named.conf' ]; then - dns_conf='/etc/bind/named.conf' -fi - -# Deleting old user's zone -sed -i "/\/$user\/conf\/dns\/$domain/d" $dns_conf - -# Updating zone serial -if [ "$update_serial" != 'no' ]; then - update_domain_serial -fi - -# Rebuiling zone config -rebuild_dns_domain_conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating counters -update_user_value "$user" '$U_DNS_DOMAINS' "$user_domains" -update_user_value "$user" '$U_DNS_RECORDS' "$user_records" -update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns" - -# Restarting named -$BIN/v-restart-dns $restart -check_result $? "Bind restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-rebuild-dns-domains b/bin/v-rebuild-dns-domains deleted file mode 100755 index 0b03e8191..000000000 --- a/bin/v-rebuild-dns-domains +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -# info: rebuild dns domains -# options: USER [RESTART] [UPDATE_SERIAL] -# -# The function rebuilds DNS configuration files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -restart=$2 -update_serial=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/rebuild.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART] [UPDATE_SERIAL]' -is_format_valid 'user' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -if [ "$DNS_SYSTEM" = 'remote' ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -user_domains=0 -user_records=0 -suspended_dns=0 -conf="$USER_DATA/dns.conf" - -# Defining user name servers -ns=$(get_user_value '$NS') -i=1 -for nameserver in ${ns//,/ };do - eval ns$i="$nameserver" - i=$((i + 1)) -done - -# Get dns config path -if [ -e '/etc/named.conf' ]; then - dns_conf='/etc/named.conf' -fi - -if [ -e '/etc/bind/named.conf' ]; then - dns_conf='/etc/bind/named.conf' -fi - -# Remove old user's zone -sed -i "/\/$user\/conf\/dns/d" $dns_conf - -# Starting loop -for domain in $(search_objects 'dns' 'DOMAIN' "*" 'DOMAIN'); do - if [ "$update_serial" != 'no' ]; then - update_domain_serial - fi - rebuild_dns_domain_conf -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating counters -update_user_value "$user" '$U_DNS_DOMAINS' "$user_domains" -update_user_value "$user" '$U_DNS_RECORDS' "$user_records" -update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns" - -# Restarting named -$BIN/v-restart-dns $restart -check_result $? "Bind restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-rebuild-mail-domains b/bin/v-rebuild-mail-domains deleted file mode 100755 index 82b7fa144..000000000 --- a/bin/v-rebuild-mail-domains +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -# info: rebuild mail domains -# options: USER -# -# The function rebuilds EXIM configuration files for all mail domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/rebuild.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -if [ "$MAIL_SYSTEM" = 'remote' ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Reset counters -U_MAIL_DOMAINS=0 -U_MAIL_DKMI=0 -U_MAIL_ACCOUNTS=0 -SUSPENDED_MAIL=0 -U_DISK_MAIL=0 - -# Checking mail folder -if [ ! -d "$USER_DATA/mail" ]; then - rm -f $USER_DATA/mail - mkdir $USER_DATA/mail -fi - -# Starting loop -for domain in $(search_objects 'mail' 'SUSPENDED' "*" 'DOMAIN'); do - rebuild_mail_domain_conf -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating counters -update_user_value "$user" '$U_MAIL_DOMAINS' "$U_MAIL_DOMAINS" -update_user_value "$user" '$U_MAIL_DKMI' "$U_MAIL_DKMI" -update_user_value "$user" '$U_MAIL_ACCOUNTS' "$U_MAIL_ACCOUNTS" -update_user_value "$user" '$SUSPENDED_MAIL' "$SUSPENDED_MAIL" -update_user_value "$user" '$U_DISK_MAIL' "$U_DISK_MAIL" - -recalc_user_disk_usage - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-rebuild-user b/bin/v-rebuild-user deleted file mode 100755 index 6a2b4d037..000000000 --- a/bin/v-rebuild-user +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# info: rebuild system user -# options: USER [RESTART] -# -# The function rebuilds system user account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -restart=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/rebuild.sh -source $VESTA/conf/vesta.conf - -# Export sbin -export PATH=$PATH:/usr/sbin - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Update disk quota -if [ "$DISK_QUOTA" = 'yes' ]; then - $BIN/v-update-user-quota $user -fi - -# Rebuild user -rebuild_user_conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-rebuild-web-domains b/bin/v-rebuild-web-domains deleted file mode 100755 index 2094d19c1..000000000 --- a/bin/v-rebuild-web-domains +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash -# info: rebuild web domains -# options: USER [RESTART] -# -# The function rebuilds web configuration files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -restart=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh -source $VESTA/func/rebuild.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -is_format_valid 'user' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting old web configs -sed -i "/.*\/$user\/conf\/web\//d" /etc/$WEB_SYSTEM/conf.d/vesta.conf -if [ -e "$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf" ]; then - rm $HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf -fi -if [ -e "$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf" ]; then - rm $HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf -fi - -# Deleting old proxy configs -if [ ! -z "$PROXY_SYSTEM" ]; then - sed -i "/.*\/$user\/conf\/web\//d" /etc/$PROXY_SYSTEM/conf.d/vesta.conf - - if [ -e "$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf" ]; then - rm $HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf - fi - - if [ -e "$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf" ]; then - rm $HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf - fi -fi - -# Deleting backend configs -if [ ! -z "$WEB_BACKEND" ]; then - if [ "$WEB_BACKEND_POOL" = 'user' ]; then - prepare_web_backend - rm -f $pool/$backend_type.conf - else - for domain in $($BIN/v-list-web-domains $user plain |cut -f 1); do - prepare_web_backend - rm -f $pool/$backend_type.conf - done - fi -fi - -# Starting rebuild loop for each web domain -for domain in $($BIN/v-list-web-domains $user plain |cut -f 1); do - if [ ! -z "$WEB_BACKEND" ]; then - template=$(get_object_value 'web' 'DOMAIN' "$domain" '$BACKEND') - $BIN/v-add-web-domain-backend $user $domain $template $restart - fi - rebuild_web_domain_conf -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating user counters -$BIN/v-update-user-counters $user - -# Restarting web server -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-restart-cron b/bin/v-restart-cron deleted file mode 100755 index ac9ea8b1a..000000000 --- a/bin/v-restart-cron +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# info: restart cron service -# options: NONE -# -# The function tells crond service to reread its configuration files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf -PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin" - -send_email_report() { - email=$(grep CONTACT $VESTA/data/users/admin/user.conf) - email=$(echo "$email" | cut -f 2 -d "'") - tmpfile=$(mktemp) - subj="$(hostname): $CRON_SYSTEM restart failed" - service $CRON_SYSTEM configtest >> $tmpfile 2>&1 - service $CRON_SYSTEM restart >> $tmpfile 2>&1 - cat $tmpfile |$SENDMAIL -s "$subj" $email - rm -f $tmpfile -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Exit -if [ "$1" = "no" ]; then - exit -fi - -# Schedule restart -if [ "$1" = 'scheduled' ]; then - echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe - exit -fi -if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then - echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe - exit -fi - -if [ -z "$CRON_SYSTEM" ] || [ "$CRON_SYSTEM" = 'remote' ]; then - exit -fi - -# Restart system -service $CRON_SYSTEM reload >/dev/null 2>&1 -if [ $? -ne 0 ]; then - service $CRON_SYSTEM restart >/dev/null 2>&1 - if [ $? -ne 0 ]; then - send_email_report - check_result $E_RESTART "$CRON_SYSTEM restart failed" - fi -fi - -# Update restart queue -if [ -e "$VESTA/data/queue/restart.pipe" ]; then - sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-restart-dns b/bin/v-restart-dns deleted file mode 100755 index 4e7712a7c..000000000 --- a/bin/v-restart-dns +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -# info: restart dns service -# options: NONE -# -# The function tells BIND service to reload dns zone files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf -PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin" - -send_email_report() { - if [ -e '/etc/named.conf' ]; then - dns_conf='/etc/named.conf' - else - dns_conf='/etc/bind/named.conf' - fi - email=$(grep CONTACT $VESTA/data/users/admin/user.conf) - email=$(echo "$email" | cut -f 2 -d "'") - tmpfile=$(mktemp) - subj="$(hostname): $DNS_SYSTEM restart failed" - /usr/sbin/named-checkconf $dns_conf >> $tmpfile 2>&1 - service $DNS_SYSTEM restart >> $tmpfile 2>&1 - cat $tmpfile |$SENDMAIL -s "$subj" $email - rm -f $tmpfile -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Exit -if [ "$1" = "no" ]; then - exit -fi - -# Schedule restart -if [ "$1" = 'scheduled' ]; then - echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe - exit -fi -if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then - echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe - exit -fi - -if [ -z "$DNS_SYSTEM" ] || [ "$DNS_SYSTEM" = 'remote' ] ; then - exit -fi - -# Restart system -service $DNS_SYSTEM reload >/dev/null 2>&1 -if [ $? -ne 0 ]; then - service $DNS_SYSTEM restart >/dev/null 2>&1 - if [ $? -ne 0 ]; then - send_email_report - check_result $E_RESTART "$DNS_SYSTEM restart failed" - fi -fi - -# Update restart queue -if [ -e "$VESTA/data/queue/restart.pipe" ]; then - sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-restart-ftp b/bin/v-restart-ftp deleted file mode 100755 index 2f1eab35d..000000000 --- a/bin/v-restart-ftp +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash -# info: restart ftp service -# options: NONE -# -# The function tells ftp server to reread its configuration. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf -PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin" - -send_email_report() { - email=$(grep CONTACT $VESTA/data/users/admin/user.conf) - email=$(echo "$email" | cut -f 2 -d "'") - tmpfile=$(mktemp) - subj="$(hostname): $FTP_SYSTEM restart failed" - service $FTP_SYSTEM configtest >> $tmpfile 2>&1 - service $FTP_SYSTEM restart >> $tmpfile 2>&1 - cat $tmpfile |$SENDMAIL -s "$subj" $email - rm -f $tmpfile -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Exit -if [ "$1" = "no" ]; then - exit -fi - -# Schedule restart -if [ "$1" = 'scheduled' ]; then - echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe - exit -fi -if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then - echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe - exit -fi - -if [ -z "$FTP_SYSTEM" ] || [ "$FTP_SYSTEM" = 'remote' ]; then - exit -fi - -# Restart system -service $FTP_SYSTEM restart >/dev/null 2>&1 -if [ $? -ne 0 ]; then - send_email_report - check_result $E_RESTART "$FTP_SYSTEM restart failed" -fi - -# Update restart queue -if [ -e "$VESTA/data/queue/restart.pipe" ]; then - sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-restart-mail b/bin/v-restart-mail deleted file mode 100755 index 920297227..000000000 --- a/bin/v-restart-mail +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash -# info: restart mail service -# options: NONE -# -# The function tells Exim service to reload configuration files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf -PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin" - -send_email_report() { - email=$(grep CONTACT $VESTA/data/users/admin/user.conf) - email=$(echo "$email" | cut -f 2 -d "'") - tmpfile=$(mktemp) - subj="$(hostname): $MAIL_SYSTEM restart failed" - service $MAIL_SYSTEM configtest >> $tmpfile 2>&1 - service $MAIL_SYSTEM restart >> $tmpfile 2>&1 - cat $tmpfile |$SENDMAIL -s "$subj" $email - rm -f $tmpfile -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Exit -if [ "$1" = "no" ]; then - exit -fi - -# Schedule restart -if [ "$1" = 'scheduled' ]; then - echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe - exit -fi -if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then - echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe - exit -fi - -if [ -z "$MAIL_SYSTEM" ] || [ "$MAIL_SYSTEM" = 'remote' ]; then - exit -fi - -# Restart system -service $MAIL_SYSTEM restart >/dev/null 2>&1 -if [ $? -ne 0 ]; then - send_email_report - check_result $E_RESTART "$MAIL_SYSTEM restart failed" -fi - -# Update restart queue -if [ -e "$VESTA/data/queue/restart.pipe" ]; then - sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-restart-proxy b/bin/v-restart-proxy deleted file mode 100755 index 7dcfad120..000000000 --- a/bin/v-restart-proxy +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -# info: restart proxy server -# options: NONE -# -# The function reloads proxy server configuration. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf -PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin" - -send_email_report() { - email=$(grep CONTACT $VESTA/data/users/admin/user.conf) - email=$(echo "$email" | cut -f 2 -d "'") - tmpfile=$(mktemp) - subj="$(hostname): $PROXY_SYSTEM restart failed" - service $PROXY_SYSTEM configtest >> $tmpfile 2>&1 - service $PROXY_SYSTEM restart >> $tmpfile 2>&1 - cat $tmpfile |$SENDMAIL -s "$subj" $email - rm -f $tmpfile -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Exit -if [ "$1" = "no" ]; then - exit -fi - -# Schedule restart -if [ "$1" = 'scheduled' ]; then - echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe - exit -fi -if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then - echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe - exit -fi - -if [ -z "$PROXY_SYSTEM" ] || [ "$PROXY_SYSTEM" = 'remote' ]; then - exit -fi - -# Restart system -if [ ! -f "/etc/debian_version" ]; then - service $PROXY_SYSTEM restart >/dev/null 2>&1 -else - systemctl reset-failed $PROXY_SYSTEM - systemctl restart $PROXY_SYSTEM > /dev/null 2>&1 -fi - -if [ $? -ne 0 ]; then - send_email_report - check_result $E_RESTART "$PROXY_SYSTEM restart failed" -fi - -# Update restart queue -if [ -e "$VESTA/data/queue/restart.pipe" ]; then - sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-restart-service b/bin/v-restart-service deleted file mode 100755 index e46339f92..000000000 --- a/bin/v-restart-service +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -# info: restart service -# options: service -# -# The function restarts system service. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -service=$1 - -# Includes -source $VESTA/func/main.sh -PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'SERVICE' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ "$service" != "iptables" ]; then - service $service restart >/dev/null 2>&1 - if [ $? -ne 0 ]; then - check_result $E_RESTART "$service restart failed" - fi -else - $BIN/v-stop-firewall - $BIN/v-update-firewall - if [ $? -ne 0 ]; then - check_result $E_RESTART "$service restart failed" - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-restart-system b/bin/v-restart-system deleted file mode 100755 index 40767acec..000000000 --- a/bin/v-restart-system +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# info: restart operating system -# options: restart -# -# The function restarts operating system. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -restart=$1 - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'RESTART' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ "$restart" = 'yes' ]; then - /sbin/reboot -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-restart-web b/bin/v-restart-web deleted file mode 100755 index ab1afe6ce..000000000 --- a/bin/v-restart-web +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -# info: restart web server -# options: NONE -# -# The function reloads web server configuration. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf -PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin" - -send_email_report() { - email=$(grep CONTACT $VESTA/data/users/admin/user.conf) - email=$(echo "$email" | cut -f 2 -d "'") - tmpfile=$(mktemp) - subj="$(hostname): $WEB_SYSTEM restart failed" - service $WEB_SYSTEM configtest >> $tmpfile 2>&1 - service $WEB_SYSTEM restart >> $tmpfile 2>&1 - cat $tmpfile |$SENDMAIL -s "$subj" $email - rm -f $tmpfile -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Exit -if [ "$1" = "no" ]; then - exit -fi - -# Schedule restart -if [ "$1" = 'scheduled' ]; then - echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe - exit -fi -if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then - echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe - exit -fi - -if [ -z "$WEB_SYSTEM" ] || [ "$WEB_SYSTEM" = 'remote' ]; then - exit -fi - -# Reload web system -service $WEB_SYSTEM reload >/dev/null 2>&1 -rc=$? - -# Workaround for Ubuntu 12.04 -if [ "$WEB_SYSTEM" == 'apache2' ]; then - pid1='/var/run/apache2.pid' - pid2='/var/run/apache2/apache2.pid' - if [ ! -e "$pid1" ] && [ ! -e "$pid2" ]; then - rc=1 - fi -fi - -# Resart web system if reload didn't work -if [ "$rc" -ne 0 ]; then - service $WEB_SYSTEM restart >/dev/null 2>&1 - if [ $? -ne 0 ]; then - send_email_report - check_result $E_RESTART "$WEB_SYSTEM restart failed" - fi -fi - -# Update restart queue -if [ -e "$VESTA/data/queue/restart.pipe" ]; then - sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-restart-web-backend b/bin/v-restart-web-backend deleted file mode 100755 index e1d8ebe94..000000000 --- a/bin/v-restart-web-backend +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -# info: restart backend server -# options: NONE -# -# The function reloads backend server configuration. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf -PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin" - -send_email_report() { - email=$(grep CONTACT $VESTA/data/users/admin/user.conf) - email=$(echo "$email" | cut -f 2 -d "'") - tmpfile=$(mktemp) - subj="$(hostname): $WEB_BACKEND restart failed" - service $WEB_BACKEND configtest >> $tmpfile 2>&1 - service $WEB_BACKEND restart >> $tmpfile 2>&1 - cat $tmpfile |$SENDMAIL -s "$subj" $email - rm -f $tmpfile -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Exit -if [ "$1" = "no" ]; then - exit -fi - -# Schedule restart -if [ "$1" = 'scheduled' ]; then - echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe - exit -fi -if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then - echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe - exit -fi - -if [ -z "$WEB_BACKEND" ] || [ "$WEB_BACKEND" = 'remote' ]; then - exit -fi - -# Restart system -php_fpm=$(ls /etc/init.d/php*-fpm* 2>/dev/null |cut -f 4 -d / |head -n 1) -if [ -z "$php_fpm" ]; then - service $WEB_BACKEND restart >/dev/null 2>&1 -else - service $php_fpm restart >/dev/null 2>&1 -fi - -if [ $? -ne 0 ]; then - send_email_report - check_result $E_RESTART "$WEB_BACKEND restart failed" -fi - -# Update restart queue -if [ -e "$VESTA/data/queue/restart.pipe" ]; then - sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-restore-user b/bin/v-restore-user deleted file mode 100755 index cb77f7434..000000000 --- a/bin/v-restore-user +++ /dev/null @@ -1,790 +0,0 @@ -#!/bin/bash -# info: restore user -# options: USER BACKUP [WEB] [DNS] [MAIL] [DB] [CRON] [UDIR] [NOTIFY] -# -# The function for resotring user from backup. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Import VESTA variable for cron launch -source /etc/profile - -# Argument definition -user=$1 -backup=$2 -web=$3 -dns=$4 -mail=$5 -db=$6 -cron=$7 -udir=$8 -notify=${9-no} - -# Define backup dir -if [ -z "$BACKUP" ]; then - BACKUP=/backup -fi - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh -source $VESTA/func/db.sh -source $VESTA/func/rebuild.sh -source $VESTA/conf/vesta.conf - -# Check backup ownership function -is_backup_available() { - passed=false - if [[ $2 =~ ^$1.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]_[0-9][0-9]-[0-9][0-9]-[0-9][0-9].tar$ ]]; then - passed=true - elif [[ $2 =~ ^$1.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9].tar$ ]]; then - passed=true - fi - - if [ $passed = false ]; then - check_result $E_FORBIDEN "permission denied" - fi -} - -# Defining ftp command function -ftpc() { - /usr/bin/ftp -n $HOST $PORT <" { - if {\$count < \$argc} { - set arg [lindex \$argv \$count] - send "\$arg\r" - incr count - } else { - send "exit\r" - set output "Disconnected." - if {[info exists rc] != 1} { - set rc $OK - } - } - exp_continue - } - timeout { - set output "Connection timeout." - set rc $E_CONNECT - } - } - - if {[info exists output] == 1} { - puts "\$output" - } - - exit \$rc -EOF -} - -# SFTP backup download function -sftp_download() { - source $VESTA/conf/sftp.backup.conf - if [ -z "$PORT" ]; then - PORT='22' - fi - cd $BACKUP - if [ -z $BPATH ]; then - sftpc "get $1" > /dev/null 2>&1 - else - sftpc "cd $BPATH" "get $1" > /dev/null 2>&1 - fi - -} - -# Google backup download function -google_download() { - source $VESTA/conf/google.backup.conf - gsutil="$VESTA/3rdparty/gsutil/gsutil" - export BOTO_CONFIG="$VESTA/conf/.google.backup.boto" - ${gsutil} cp gs://$BUCKET/$BPATH/$1 $BACKUP/ > /dev/null 2>&1 - if [ "$?" -ne 0 ]; then - check_result "$E_CONNECT" "gsutil failed to download $1" - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -args_usage='USER BACKUP [WEB] [DNS] [MAIL] [DB] [CRON] [UDIR] [NOTIFY]' -check_args '2' "$#" "$args_usage" -is_format_valid 'user' 'backup' -is_backup_available "$user" "$backup" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking local backup -if [ ! -e "$BACKUP/$backup" ]; then - if [[ "$BACKUP_SYSTEM" =~ "google" ]]; then - google_download $backup - downloaded='yes' - fi - if [[ "$BACKUP_SYSTEM" =~ "sftp" ]] && [ -z "$downloaded" ]; then - sftp_download $backup - downloaded='yes' - fi - if [[ "$BACKUP_SYSTEM" =~ "ftp" ]] && [ -z "$downloaded" ]; then - ftp_download $backup - downloaded='yes' - fi - if [ -z "$downloaded" ]; then - check_result $E_NOTEXIST "backup $backup doesn't exist" - fi -fi - -# Checking user existance on the server -check_user=$(is_object_valid 'user' 'USER' "$user") -if [ -z "$check_user" ]; then - is_object_unsuspended 'user' 'USER' "$user" - subj="$user → restore failed" - email=$(get_user_value '$CONTACT') -else - create_user="yes" - email=$(grep CONTACT $VESTA/data/users/admin/user.conf | cut -f2 -d \') -fi - - -# Checking avaiable disk space -disk_usage=$(df $BACKUP |tail -n1 |tr ' ' '\n' |grep % |cut -f 1 -d %) -if [ "$disk_usage" -ge "$BACKUP_DISK_LIMIT" ]; then - echo "Error: Not enough disk space" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result $E_DISK "Not enough disk space" -fi - -# Checking load average -la=$(cat /proc/loadavg |cut -f 1 -d ' ' |cut -f 1 -d '.') -i=0 -while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do - echo -e "$(date "+%F %T") Load Average $la" - sleep 60 - if [ "$i" -ge "15" ]; then - la_error="LoadAverage $la is above threshold" - echo "Error: $la_error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result $E_LA "$la_error" - fi - la=$(cat /proc/loadavg |cut -f 1 -d ' ' |cut -f 1 -d '.') - (( ++i)) -done - -if [ -z "$BACKUP_TEMP" ]; then - BACKUP_TEMP=$BACKUP -fi - -# Creating temporary directory -tmpdir=$(mktemp -p $BACKUP_TEMP -d) -if [ "$?" -ne 0 ]; then - echo "Can't create tmp dir $tmpdir" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_NOTEXIST" "can't create tmp dir" -fi - -# Restoring user account -if [ "$create_user" = 'yes' ]; then - echo "-- USER --" |tee $tmpdir/restore.log - echo -e "$(date "+%F %T") $user" |tee -a $tmpdir/restore.log - - # Unpacking user container - tar xf $BACKUP/$backup -C $tmpdir ./vesta - if [ "$?" -ne 0 ]; then - rm -rf $tmpdir - echo "Can't unpack user contaner" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_PARSING" "can't unpack user contaner" - fi - - # Restoring user.conf - mkdir $USER_DATA - cp $tmpdir/vesta/user.conf $USER_DATA/ - cp -r $tmpdir/vesta/ssl $USER_DATA/ >/dev/null 2>&1 - cp $tmpdir/vesta/backup-excludes.conf $USER_DATA/ >/dev/null 2>&1 - - # Rebuilding user - rebuild_user_conf -fi - -# Unpacking pam container -tar xf $BACKUP/$backup -C $tmpdir ./pam -if [ "$?" -ne 0 ]; then - rm -rf $tmpdir - echo "Can't unpack PAM contaner" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_PARSING" "can't unpack PAM contaner" -fi -old_user=$(cut -f 1 -d : $tmpdir/pam/passwd) -old_uid=$(cut -f 3 -d : $tmpdir/pam/passwd) -new_uid=$(grep "^$user:" /etc/passwd |cut -f 3 -d :) - - -# Restoring web domains -if [ "$web" != 'no' ] && [ ! -z "$WEB_SYSTEM" ]; then - echo -e "\n-- WEB --" |tee -a $tmpdir/restore.log - - # Creating web domain restore list - backup_domains=$(tar -tf $BACKUP/$backup |grep "^./web") - backup_domains=$(echo "$backup_domains" |grep domain_data.tar.gz) - backup_domains=$(echo "$backup_domains" |cut -f 3 -d /) - if [ -z "$web" ] || [ "$web" = '*' ]; then - domains="$backup_domains" - else - echo "$web" | tr ',' '\n' | sed -e "s/^/^/" > $tmpdir/selected.txt - domains=$(echo "$backup_domains" |egrep -f $tmpdir/selected.txt) - fi - - # Restoring web domain - for domain in $domains; do - echo -e "$(date "+%F %T") $domain" |tee -a $tmpdir/restore.log - - # Checking domain existance - check_config=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf) - if [ -z "$check_config" ]; then - check_new=$(is_domain_new 'web' $domain) - if [ ! -z "$check_new" ]; then - rm -rf $tmpdir - error="$domain belongs to another user" - echo "$error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_PARSING" "$error" - fi - fi - - # Unpacking domain container - tar xf $BACKUP/$backup -C $tmpdir ./web/$domain - if [ "$?" -ne 0 ]; then - rm -rf $tmpdir - error="Can't unpack $domain web container" - echo "$error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_PARSING" "$error" - fi - - # Restoring web.conf - if [ -z "$check_config" ]; then - eval $(cat $tmpdir/web/$domain/vesta/web.conf) - - # Deleting conflicting aliases - for dom_alias in ${ALIAS//,/ }; do - check_new=$(is_domain_new 'web' $dom_alias) - if [ ! -z "$check_new" ]; then - ALIAS=$(echo "$ALIAS" |\ - sed "s/,/\n/g"|\ - sed "s/^$dom_alias$//g"|\ - sed "/^$/d"|\ - sed ':a;N;$!ba;s/\n/,/g') - fi - done - - # Checking ip address - check_ip=$(is_ip_valid $IP $user) - if [ ! -z "$check_ip" ]; then - local_ip='' - get_user_ip $user - old_ip=$IP - IP=$ip - fi - - # Checking web template - check_tpl=$(is_web_template_valid $TPL) - if [ ! -z "$check_tpl" ]; then - TPL='default' - fi - - # Checking proxy template - check_proxy_tpl=$(is_proxy_template_valid $PROXY) - if [ ! -z "$check_proxy_tpl" ]; then - PROXY='default' - fi - - # Checking backend template - check_backend_tpl=$(is_backend_template_valid $BACKEND) - if [ ! -z "$check_proxy_tpl" ]; then - BACKEND='default' - fi - - # Converting ftp users - if [ ! -z "$FTP_USER" ]; then - FTP_USER=$(echo "$FTP_USER" |sed -e "s/${old_user}_//") - FTP_USER="${user}_${FTP_USER}" - fi - - # Converting stats users - if [ ! -z "$STATS_USER" ]; then - STATS_USER=$(echo "$STATS_USER" |sed -e "s/${old_user}_//") - STATS_USER="${user}_${STATS_USER}" - fi - - # Copying ssl certificates - if [ "$SSL" = 'yes' ]; then - certificates=$(ls $tmpdir/web/$domain/conf| grep ssl) - certificates=$(echo "$certificates" |grep $domain) - for crt in $certificates; do - crt=$(echo $crt|sed -e "s/ssl.//") - cp -f $tmpdir/web/$domain/conf/ssl.$crt $USER_DATA/ssl/$crt - done - fi - - # Concatenating web.conf keys - str="DOMAIN='$domain' IP='$IP' IP6='$IP6' ALIAS='$ALIAS'" - str="$str TPL='$TPL' SSL='$SSL' SSL_HOME='$SSL_HOME'" - str="$str LETSENCRYPT='$LETSENCRYPT' FTP_USER='$FTP_USER'" - str="$str FTP_MD5='$FTP_MD5' BACKEND='$BACKEND' PROXY='$PROXY'" - str="$str PROXY_EXT='$PROXY_EXT' STATS='$STATS'" - str="$str STATS_USER='$STATS_USER' STATS_CRYPT='$STATS_CRYPT'" - str="$str U_DISK='$U_DISK' U_BANDWIDTH='0' SUSPENDED='no'" - str="$str TIME='$(date +%T)' DATE='$(date +%F)'" - echo $str >> $USER_DATA/web.conf - - # Rebuilding backend - if [ ! -z "$WEB_BACKEND" ]; then - $BIN/v-add-web-domain-backend $user $domain $BACKEND - fi - - # Rebuilding vhost - rebuild_web_domain_conf - fi - - # Restoring web domain data - chown $user $tmpdir - chmod u+w $HOMEDIR/$user/web/$domain - sudo -u $user tar -xzpf $tmpdir/web/$domain/domain_data.tar.gz \ - -C $HOMEDIR/$user/web/$domain/ --exclude=./logs/* \ - 2> $HOMEDIR/$user/web/$domain/restore_errors.log - if [ -e "$HOMEDIR/$user/web/$domain/restore_errors.log" ]; then - chown $user:$user $HOMEDIR/$user/web/$domain/restore_errors.log - fi - #if [ "$?" -ne 0 ]; then - # rm -rf $tmpdir - # error="can't unpack $domain data tarball" - # echo "$error" |$SENDMAIL -s "$subj" $email $notify - # sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - # check_result "$E_PARSING" "$error" - #fi - - # Applying Fix for tar < 1.24 - find $HOMEDIR/$user/web/$domain -type d \ - -exec chown -h $user:$user {} \; - - # Re-chowning files if uid differs - if [ "$old_uid" -ne "$new_uid" ]; then - find $HOMEDIR/$user/web/$domain/ -user $old_uid \ - -exec chown -h $user:$user {} \; - fi - done - - # Adding user to traff queue - sed -i "/ $user /d" $VESTA/data/queue/traffic.pipe - echo "$BIN/v-update-web-domains-traff $user" >>\ - $VESTA/data/queue/traffic.pipe - - # Restarting web server - $BIN/v-restart-web - check_result $? "Web restart failed" - if [ ! -z "$PROXY_SYSTEM" ]; then - $BIN/v-restart-proxy - check_result $? "Proxy restart failed" - fi -fi - -# Restoring dns domains -if [ "$dns" != 'no' ] && [ ! -z "$DNS_SYSTEM" ]; then - echo -e "\n-- DNS --" |tee -a $tmpdir/restore.log - - # Creating dns domain restore list - backup_domains=$(tar -tf $BACKUP/$backup |grep "^./dns") - backup_domains=$(echo "$backup_domains" |grep "dns.conf$") - backup_domains=$(echo "$backup_domains" |cut -f 3 -d /) - if [ -z "$dns" ] || [ "$dns" = '*' ]; then - domains="$backup_domains" - else - echo "$dns" | tr ',' '\n' | sed -e "s/^/^/" > $tmpdir/selected.txt - domains=$(echo "$backup_domains" |egrep -f $tmpdir/selected.txt) - fi - - # Restoring dns domain - for domain in $domains; do - echo -e "$(date "+%F %T") $domain" |tee -a $tmpdir/restore.log - - # Checking domain existance - check_config=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf) - if [ -z "$check_config" ]; then - check_new=$(is_domain_new 'dns' $domain) - if [ ! -z "$check_new" ]; then - rm -rf $tmpdir - error="$domain belongs to another user" - echo "$error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_PARSING" "$error" - fi - fi - - # Unpacking domain container - tar xf $BACKUP/$backup -C $tmpdir ./dns/$domain - if [ "$?" -ne 0 ]; then - rm -rf $tmpdir - error="Can't unpack $domain dns container" - echo "$error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_PARSING" "$error" - fi - - # Restoring dns.conf - if [ -z "$check_config" ]; then - eval $(cat $tmpdir/dns/$domain/vesta/dns.conf) - - # Checking ip address - check_ip=$(is_ip_valid $IP $user) - if [ ! -z "$check_ip" ]; then - local_ip='' - get_user_ip $user - old_ip=$IP - IP=$ip - fi - - # Checking dns template - check_tpl=$(is_dns_template_valid $TPL) - if [ ! -z "$check_tpl" ]; then - TPL='default' - fi - - # Concatenating dns.conf keys - str="DOMAIN='$domain' IP='$IP' TPL='$TPL' TTL='$TTL' EXP='$EXP'" - str="$str SOA='$SOA' RECORDS='$RECORDS' SUSPENDED='no'" - str="$str TIME='$(date +%T)' DATE='$(date +%F)'" - echo $str >> $USER_DATA/dns.conf - fi - - # Restoring dns records - cp -f $tmpdir/dns/$domain/vesta/$domain.conf $USER_DATA/dns/ - - # Rebuilding dns domain - rebuild_dns_domain_conf - done - - # Restarting DNS - $BIN/v-restart-dns - check_result $? "DNS restart failed" -fi - -# Restoring mail domains -if [ "$mail" != 'no' ] && [ ! -z "$MAIL_SYSTEM" ]; then - echo -e "\n-- MAIL --" |tee -a $tmpdir/restore.log - - # Creating mail domain restore list - backup_domains=$(tar -tf $BACKUP/$backup |grep "^./mail") - backup_domains=$(echo "$backup_domains" |grep "mail.conf$") - backup_domains=$(echo "$backup_domains" |cut -f 3 -d /) - if [ -z "$mail" ] || [ "$mail" = '*' ]; then - domains="$backup_domains" - else - echo "$mail" | tr ',' '\n' | sed -e "s/^/^/" > $tmpdir/selected.txt - domains=$(echo "$backup_domains" |egrep -f $tmpdir/selected.txt) - fi - - # Checking exim username for later chowning - exim_user="exim"; - check_exim_username=$(grep -c '^Debian-exim:' /etc/passwd) - if [ "$check_exim_username" -eq 1 ]; then - exim_user="Debian-exim" - fi - - # Restoring dns domain - for domain in $domains; do - echo -e "$(date "+%F %T") $domain" |tee -a $tmpdir/restore.log - - # Checking domain existance - check_config=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf) - if [ -z "$check_config" ]; then - check_new=$(is_domain_new 'mail' $domain) - if [ ! -z "$check_new" ]; then - rm -rf $tmpdir - error="$domain belongs to another user" - echo "$error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_PARSING" "$error" - fi - fi - - # Unpacking domain container - tar xf $BACKUP/$backup -C $tmpdir ./mail/$domain - if [ "$?" -ne 0 ]; then - rm -rf $tmpdir - error="Can't unpack $domain mail container" - echo "$error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_PARSING" "$error" - fi - - # Restoring mail.conf - if [ -z "$check_config" ]; then - cat $tmpdir/mail/$domain/vesta/mail.conf >> $USER_DATA/mail.conf - fi - - # Restoring DKIM - if [ -e "$tmpdir/mail/$domain/vesta/$domain.pem" ]; then - cp -f $tmpdir/mail/$domain/vesta/$domain.pem $USER_DATA/mail/ - cp -f $tmpdir/mail/$domain/vesta/$domain.pub $USER_DATA/mail/ - fi - - # Restoring email accounts - cp -f $tmpdir/mail/$domain/vesta/$domain.conf $USER_DATA/mail/ - - # Rebuilding mail config - rebuild_mail_domain_conf - - domain_idn=$domain - format_domain_idn - - # Restoring emails - if [ -e "$tmpdir/mail/$domain/accounts.tar.gz" ]; then - chown $user $tmpdir - chmod u+w $HOMEDIR/$user/mail/$domain_idn - sudo -u $user tar -xzpf $tmpdir/mail/$domain/accounts.tar.gz \ - -C $HOMEDIR/$user/mail/$domain_idn/ - if [ "$?" -ne 0 ]; then - rm -rf $tmpdir - error="Can't unpack $domain mail account container" - echo "$error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_PARSING" "$error" - fi - - # Re-chowning files if uid differs - if [ "$old_uid" -ne "$new_uid" ]; then - find $HOMEDIR/$user/mail/$domain_idn -user $old_uid \ - -exec chown -h $user:mail {} \; - fi - fi - - # Chowning mail conf files to exim user - find $HOMEDIR/$user/conf/mail/$domain_idn -user root \ - -exec chown $exim_user {} \; - - done -fi - -# Restoring databases -if [ "$db" != 'no' ] && [ ! -z "$DB_SYSTEM" ]; then - echo -e "\n-- DB --" |tee -a $tmpdir/restore.log - - # Creating database restore list - backup_databases=$(tar -tf $BACKUP/$backup |grep "^./db") - backup_databases=$(echo "$backup_databases" |grep db.conf) - backup_databases=$(echo "$backup_databases" |cut -f 3 -d / |sort -u) - if [ -z "$db" ] || [ "$db" = '*' ]; then - databases="$backup_databases" - else - echo "$db" |tr ',' '\n' | sed -e "s/$/$/" > $tmpdir/selected.txt - databases=$(echo "$backup_databases" |egrep -f $tmpdir/selected.txt) - fi - - # Restoring database - for database in $databases; do - echo -e "$(date "+%F %T") $database" |tee -a $tmpdir/restore.log - - # Checking database existance - check_config=$(grep "DB='$database'" $USER_DATA/db.conf) - - # Unpacking database container - tar xf $BACKUP/$backup -C $tmpdir ./db/$database - if [ "$?" -ne 0 ]; then - rm -rf $tmpdir - error="Can't unpack $database database container" - echo "$error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_PARSING" "$error" - fi - - # Restore database config - if [ -z "$check_config" ]; then - eval $(cat $tmpdir/db/$database/vesta/db.conf) - DB=$(echo "$DB" |sed -e "s/${old_user}_//") - DB="${user}_${DB}" - DBUSER=$(echo "$DBUSER" |sed -e "s/${old_user}_//") - DBUSER="${user}_${DBUSER}" - str="DB='$DB' DBUSER='$DBUSER' MD5='$MD5' HOST='$HOST'" - str="$str TYPE='$TYPE' CHARSET='$CHARSET' U_DISK='$U_DISK'" - str="$str SUSPENDED='no' TIME='$(date +%T)' DATE='$(date +%F)'" - echo $str >> $USER_DATA/db.conf - else - eval $(grep "DB='$database'" $USER_DATA/db.conf) - fi - - # Unziping database dump - gzip -d $tmpdir/db/$database/$database.*.sql.gz - - # Importing database dump - database_dump="$tmpdir/db/$database/$database.$TYPE.sql" - case $TYPE in - mysql) rebuild_mysql_database; - import_mysql_database $database_dump ;; - pgsql) rebuild_pgsql_database; - import_pgsql_database $database_dump ;; - esac - done -fi - -# Restoring cron jobs -if [ "$cron" != 'no' ] && [ ! -z "CRON_SYSTEM" ]; then - echo -e "\n-- CRON --" |tee -a $tmpdir/restore.log - - # Unpacking cron container - tar xf $BACKUP/$backup -C $tmpdir ./cron - if [ "$?" -ne 0 ]; then - rm -rf $tmpdir - error="Can't unpack cron container" - echo "$error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_PARSING" "$error" - fi - - jobs=$(wc -l $tmpdir/cron/cron.conf |cut -f 1 -d' ') - if [ "$jobs" -eq 1 ]; then - echo -e "$(date "+%F %T") $jobs cron job" |tee -a $tmpdir/restore.log - else - echo -e "$(date "+%F %T") $jobs cron jobs"|tee -a $tmpdir/restore.log - fi - - # Restoring cron jobs - cp $tmpdir/cron/cron.conf $USER_DATA/cron.conf - - # Rebuilding cron jobs - sync_cron_jobs - - # Restarting cron - $BIN/v-restart-cron - check_result $? "CRON restart failed" -fi - -# Restoring user files and directories -if [ "$udir" != 'no' ]; then - echo -e "\n-- USER FILES --" |tee -a $tmpdir/restore.log - - # Unpacking user dir container - if [ ! -z "$(tar -tf $BACKUP/$backup |grep './user_dir')" ]; then - - # Creating user dir restore list - backup_dirs=$(tar -tf $BACKUP/$backup |grep "^./user_dir") - backup_dirs=$(echo "$backup_dirs" |grep tar.gz) - backup_dirs=$(echo "$backup_dirs" |cut -f 3 -d /) - backup_dirs=$(echo "$backup_dirs" |sed "s/.tar.gz//") - if [ -z "$udir" ] || [ "$udir" = '*' ]; then - user_dirs="$backup_dirs" - else - echo "$udir" |tr ',' '\n' > $tmpdir/selected.txt - user_dirs=$(echo "$backup_dirs" |egrep -f $tmpdir/selected.txt) - fi - - for user_dir in $user_dirs; do - echo -e "$(date "+%F %T") $user_dir" |tee -a $tmpdir/restore.log - tar xf $BACKUP/$backup -C $tmpdir ./user_dir/$user_dir.tar.gz - if [ "$?" -ne 0 ]; then - error="can't unpack $user_dir user dir contaner" - echo "$error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_PARSING" "$error" - fi - - tar xzf $tmpdir/user_dir/$user_dir.tar.gz -C $HOMEDIR/$user - if [ "$?" -ne 0 ]; then - error="can't unpack $user_dir user dir contaner" - echo "$error" |$SENDMAIL -s "$subj" $email $notify - sed -i "/ $user /d" $VESTA/data/queue/backup.pipe - check_result "$E_PARSING" "$error" - fi - - # Re-chowning files if uid differs - if [ "$old_uid" -ne "$new_uid" ]; then - find $HOMEDIR/$user/$user_dir -user $old_uid \ - -exec chown -h $user:$user {} \; - fi - done - fi -fi - -# Sending mail notification -subj="$user → restore has been completed" -cat $tmpdir/restore.log |$SENDMAIL -s "$subj" $email $notify - -# Deleting temporary data -rm -rf $tmpdir - -# Cleaning restore queue -sed -i "/v-restore-user $user /d" $VESTA/data/queue/backup.pipe - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update user counters -$BIN/v-update-user-counters $user -$BIN/v-update-user-counters admin -$BIN/v-update-sys-ip-counters - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-schedule-letsencrypt-domain b/bin/v-schedule-letsencrypt-domain deleted file mode 100755 index 3877b6ef4..000000000 --- a/bin/v-schedule-letsencrypt-domain +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -# info: adding cronjob for letsencrypt cetificate installation -# options: USER DOMAIN [ALIASES] -# -# The function adds cronjob for letsencrypt ssl certificate installation - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -aliases=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [ALIASES]' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_system_enabled "$WEB_SSL" 'SSL_SUPPORT' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain aliases -if [ -z "$aliases" ]; then - get_domain_values 'web' - aliases="$ALIAS" -fi - -# Adding cronjob scheduler for LE -$BIN/v-add-cron-letsencrypt-job - -# Adding LE task -echo "$BIN/v-add-letsencrypt-domain $user $domain '$aliases' yes yes" \ - >> $VESTA/data/queue/letsencrypt.pipe - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-schedule-user-backup b/bin/v-schedule-user-backup deleted file mode 100755 index dcbcedb61..000000000 --- a/bin/v-schedule-user-backup +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -# info: schedule user backup creation -# options: USER -# -# The function for scheduling user backup creation. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_system_enabled "$BACKUP_SYSTEM" 'BACKUP_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_backup_enabled -is_backup_scheduled 'backup' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding backup task to the queue -log=$VESTA/log/backup.log -echo "$BIN/v-backup-user $user yes >> $log 2>&1" >>\ - $VESTA/data/queue/backup.pipe - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-schedule-user-restore b/bin/v-schedule-user-restore deleted file mode 100755 index 0fbb8546e..000000000 --- a/bin/v-schedule-user-restore +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# info: schedule user backup restoration -# options: USER BACKUP [WEB] [DNS] [MAIL] [DB] [CRON] [UDIR] -# -# The function for scheduling user backup restoration. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -backup=$2 -web=$3 -dns=$4 -mail=$5 -db=$6 -cron=$7 -udir=$8 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Check backup ownership function -is_backup_available() { - passed=false - if [[ $2 =~ ^$1.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]_[0-9][0-9]-[0-9][0-9]-[0-9][0-9].tar$ ]]; then - passed=true - elif [[ $2 =~ ^$1.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9].tar$ ]]; then - passed=true - fi - - if [ $passed = false ]; then - check_result $E_FORBIDEN "permission denied" - fi -} - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER BACKUP [WEB] [DNS] [MAIL] [DB] [CRON] [UDIR]' -is_format_valid 'user' -is_system_enabled "$BACKUP_SYSTEM" 'BACKUP_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_backup_enabled -is_backup_scheduled 'restore' -is_backup_available "$user" "$backup" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding restore task to the queue -log=$VESTA/log/restore.log -options="'$web' '$dns' '$mail' '$db' '$cron' '$udir'" -echo "$BIN/v-restore-user $user $backup $options yes >> $log 2>&1" >>\ - $VESTA/data/queue/backup.pipe - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-schedule-vesta-softaculous b/bin/v-schedule-vesta-softaculous deleted file mode 100755 index 9474f50ff..000000000 --- a/bin/v-schedule-vesta-softaculous +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# info: adding cronjob for vesta-softaculous installation -# options: NONE -# -# The function adds cronjob for letsencrypt ssl certificate installation - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - - -# Adding cronjob for vesta-softaculous -cmd="sudo /usr/local/vesta/bin/v-add-vesta-softaculous" -check_cron=$(grep "$cmd" $VESTA/data/users/admin/cron.conf 2> /dev/null) -if [ -z "$check_cron" ] && [ ! -z "$CRON_SYSTEM" ]; then - $BIN/v-add-cron-job admin '*/1' '*' '*' '*' '*' "$cmd" -fi - - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-search-domain-owner b/bin/v-search-domain-owner deleted file mode 100755 index 5b88f4959..000000000 --- a/bin/v-search-domain-owner +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# info: search domain owner -# options: DOMAIN [TYPE] -# -# The function that allows to find user objects. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -domain=$(idn -t --quiet -u "$1" ) -type=${2-any} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'DOMAIN [TYPE]' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Define conf -case $type in - web) conf="$VESTA/data/users/*/web.conf" ;; - dns) conf="$VESTA/data/users/*/dns.conf" ;; - mail) conf="$VESTA/data/users/*/mail.conf" ;; - *) conf="$VESTA/data/users/*/*.conf" -esac - - -owner=$(grep -H "DOMAIN='$domain'" $conf | head -n 1 | cut -f7 -d '/') -if [ -z "$owner" ]; then - exit $E_NOTEXIST -fi - -echo $owner - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -#log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-search-fs-object b/bin/v-search-fs-object deleted file mode 100755 index 3c7785682..000000000 --- a/bin/v-search-fs-object +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# info: search file or directory -# options: USER OBJECT [PATH] -# -# The function search files and directories on the file system - -user=$1 -object=$2 -path=$3 - -# Checking arguments -if [ -z "$object" ]; then - echo "Usage: USER OBJECT [PATH]" - exit 1 -fi - -# Checking vesta user -if [ ! -e "$VESTA/data/users/$user" ]; then - echo "Error: vesta user $user doesn't exist" - exit 3 -fi - -# Checking user homedir -homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) -if [ -z $homedir ]; then - echo "Error: user home directory doesn't exist" - exit 12 -fi - -# Checking path -if [ ! -z "$path" ]; then - rpath=$(readlink -f "$path") - if [ -z "$(echo $rpath |grep $homedir)" ]; then - echo "Error: invalid path $dst_dir" - exit 2 - fi -else - path=$homedir -fi - -# Listing directory -sudo -u $user find "$path" -name "$object" \ - -printf "%y|%m|%TY-%Tm-%Td|%TH:%TM|%u|%g|%s|%P\n" 2>/dev/null -# -printf "%y|%m|%TY-%Tm-%Td|%TH:%TM:%TS|%u|%g|%s|%P\n" 2>/dev/null - -# Exiting -exit $? diff --git a/bin/v-search-object b/bin/v-search-object deleted file mode 100755 index 939cbafc2..000000000 --- a/bin/v-search-object +++ /dev/null @@ -1,275 +0,0 @@ -#!/bin/bash -# info: search objects -# options: OBJECT [FORMAT] -# -# The function that allows to find system objects. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -object=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Json list function -json_list_search() { - echo '{' - fileds_count=$(echo $fields| wc -w ) - while read line; do - eval $line - if [ -n "$list_data" ]; then - echo -e ' },' - fi - i=1 - IFS=' ' - for field in $fields; do - eval value=\"$field\" - value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - list_data=1 - fi - fi - done - done < $conf - if [ -n "$list_data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell list function -shell_list_search() { - if [ -z "$nohead" ] ; then - echo "${fields//$/}" - for a in $fields; do - echo -e "------ \c" - done - echo - fi - while read line ; do - eval $line - eval echo "$fields" | sed "s/%quote%/'/g" - done < $conf -} - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'OBJECT [FORMAT]' -is_format_valid 'object' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -conf=$(mktemp) -i=0 -OLD_IFS=$IFS -IFS=$'\n' - -# User loop -search_user=$(ls -1 $VESTA/data/users |grep $object) -for user in $search_user; do - if [ -e "$VESTA/data/users/$user/user.conf" ]; then - source $VESTA/data/users/$user/user.conf - ((i ++)) - type=$(echo $type|cut -f1 -d \.) - str="ID='$i' USER='$user' TYPE='user' KEY='$user'" - str="$str RESULT='$user' ALIAS=''" - str="$str LINK='$user' PARENT=''" - str="$str SUSPENDED='$SUSPENDED' TIME='$TIME'" - str="$str DATE='$DATE'" - echo $str >> $conf - fi -done - -# User data loop -for user in $(ls $VESTA/data/users/); do - # Search query - search=$(grep "$object" \ - $VESTA/data/users/$user/web.conf \ - $VESTA/data/users/$user/dns.conf \ - $VESTA/data/users/$user/dns/*.conf \ - $VESTA/data/users/$user/mail.conf \ - $VESTA/data/users/$user/mail/*.conf \ - $VESTA/data/users/$user/db.conf \ - $VESTA/data/users/$user/cron.conf 2> /dev/null) - - for row in $search; do - # Initialise variable - key='' - result='' - dom_alias='' - suspended='' - object_link='' - object_parent='' - object_time='' - object_date='' - - # Parsing result - type=$(echo $row |cut -f 1 -d : |cut -f 8 -d /) - data=$(echo $row |cut -f 2,3,4,5 -d :) - eval "$data" - - # Check WEB domain - if [ "$type" = 'web.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - # Check domain alias - check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" - if [ ! -z "$check_alias" ];then - dom_alias=$(echo $check_alias | tr ' ' ',') - fi - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - else - check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" - if [ ! -z "$check_alias" ];then - key="DOMAIN" - result="$DOMAIN" - object_parent="$DOMAIN" - dom_alias=$(echo $check_alias | tr ' ' ',') - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - fi - - # DNS - if [ "$type" = 'dns.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # DNS Records - if [ "$type" = 'dns' ]; then - if [ -n "$(echo $RECORD $VALUE |grep $object)" ]; then - dom="$(echo $row|cut -f 1 -d :|cut -f 9 -d /|sed 's/.conf//')" - key="RECORD" - result="$RECORD.$dom" - suspended=$SUSPENDED - object_link=$ID - object_parent=$dom - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # MAIL - if [ "$type" = 'mail.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # Mail Accounts - if [ "$type" = 'mail' ]; then - type='mail' - if [ -n "$(echo $ACCOUNT |grep $object)" ]; then - key="ACCOUNT" - dom="$(echo $row|cut -f 1 -d :|cut -f 9 -d /|sed 's/.conf//')" - result="$ACCOUNT@$dom" - suspended=$SUSPENDED - object_link=$ACCOUNT - object_parent=$dom - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # DB - if [ "$type" = 'db.conf' ]; then - if [ -n "$(echo $DB |grep $object)" ]; then - key="DATABASE" - result="$DB" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # Cron Jobs - if [ "$type" = 'cron.conf' ]; then - if [ -n "$(echo $CMD |grep $object)" ]; then - key="JOB" - result="$CMD" - suspended=$SUSPENDED - object_link=$JOB - object_parent=$JOB - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - if [ ! -z "$result" ]; then - type=$(echo $type|cut -f1 -d \.) - str="ID='$i' USER='$user' TYPE='$type' KEY='$key'" - str="$str RESULT='$result' ALIAS='$dom_alias'" - str="$str LINK='$object_link' PARENT='$object_parent'" - str="$str SUSPENDED='$suspended' TIME='$object_time'" - str="$str DATE='$object_date'" - echo $str >> $conf - fi - done -done -IFS=$OLD_IFS - -# Defining fileds to select -fields='$ID $USER $TYPE $KEY $RESULT $ALIAS $LINK $PARENT $SUSPENDED $TIME' -fields="$fields \$DATE" - -# Listing domains -case $format in - json) json_list_search ;; - plain) nohead=1; shell_list_search ;; - shell) fields='$USER~$TYPE~$KEY~$RESULT~$ALIAS'; - shell_list |column -t -s '~' ;; - *) check_args '1' '0' 'OBJECT [FORMAT]' -esac - -rm $conf - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -#log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-search-ssl-certificates b/bin/v-search-ssl-certificates deleted file mode 100755 index c9208830b..000000000 --- a/bin/v-search-ssl-certificates +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -# info: search ssl certificates -# options: [FORMAT] -# -# The function to obtain the list of available ssl certificates. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# JSON list function -json_list() { - IFS=$'\n' - objects=$(echo "$search_cmd" |wc -l) - i=1 - echo '[' - for str in $search_cmd; do - eval $str - if [ "$i" -lt "$objects" ]; then - echo -e "\t\"$USER:$DOMAIN\"," - else - echo -e "\t\"$USER:$DOMAIN\"" - fi - (( ++i)) - done - echo "]" -} - -# SHELL list function -shell_list() { - IFS=$'\n' - echo "USER DOMAIN" - echo "---- ------" - for str in $search_cmd; do - eval $str - echo "$USER $DOMAIN" - done -} - -# PLAIN list function -plain_list() { - IFS=$'\n' - for str in $search_cmd; do - eval $str - echo -e "$USER\t$DOMAIN" - done -} - -# CSV list function -csv_list() { - IFS=$'\n' - echo "USER,DOMAIN" - for str in $search_cmd; do - eval $str - echo "$USER,$DOMAIN" - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -search_cmd=$(grep -H "SSL='yes'" $VESTA/data/users/*/web.conf |\ - cut -f 1 -d ' ' |\ - sed -e "s|$VESTA/data/users/|USER='|" -e "s|/web.conf:|' |") - -# Listing data -case $format in - json) json_list ;; - plain) plain_list ;; - csv) csv_list ;; - shell) shell_list |column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-search-user-object b/bin/v-search-user-object deleted file mode 100755 index 3e25372df..000000000 --- a/bin/v-search-user-object +++ /dev/null @@ -1,258 +0,0 @@ -#!/bin/bash -# info: search objects -# options: USER OBJECT [FORMAT] -# -# The function that allows to find user objects. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -object=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Json list function -json_list_search() { - echo '{' - fileds_count=$(echo $fields| wc -w ) - while read line; do - eval $line - if [ -n "$list_data" ]; then - echo -e ' },' - fi - i=1 - IFS=' ' - for field in $fields; do - eval value=\"$field\" - value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - list_data=1 - fi - fi - done - done < $conf - if [ -n "$list_data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell list function -shell_list_search() { - if [ -z "$nohead" ] ; then - echo "${fields//$/}" - for a in $fields; do - echo -e "------ \c" - done - echo - fi - while read line ; do - eval $line - eval echo "$fields" | sed "s/%quote%/'/g" - done < $conf -} - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER OBJECT [FORMAT]' -is_format_valid 'user' 'object' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -conf=$(mktemp) -i=0 -OLD_IFS=$IFS -IFS=$'\n' - -# Search query -search=$(grep "$object" \ - $VESTA/data/users/$user/web.conf \ - $VESTA/data/users/$user/dns.conf \ - $VESTA/data/users/$user/dns/*.conf \ - $VESTA/data/users/$user/mail.conf \ - $VESTA/data/users/$user/mail/*.conf \ - $VESTA/data/users/$user/db.conf \ - $VESTA/data/users/$user/cron.conf 2> /dev/null) - -for row in $search; do - # Initialise variable - key='' - result='' - dom_alias='' - suspended='' - object_link='' - object_parent='' - object_time='' - object_date='' - - # Parsing result - type=$(echo $row |cut -f 1 -d : |cut -f 8 -d /) - data=$(echo $row |cut -f 2,3,4,5 -d :) - eval "$data" - - # Check WEB domain - if [ "$type" = 'web.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - # Check domain alias - check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" - if [ ! -z "$check_alias" ];then - dom_alias=$(echo $check_alias | tr ' ' ',') - fi - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - else - check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" - if [ ! -z "$check_alias" ];then - key="DOMAIN" - result="$DOMAIN" - object_parent="$DOMAIN" - dom_alias=$(echo $check_alias | tr ' ' ',') - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - fi - - # DNS - if [ "$type" = 'dns.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # DNS Records - if [ "$type" = 'dns' ]; then - if [ -n "$(echo $RECORD |grep $object)" ]; then - key="RECORD" - result="$RECORD.$DOMAIN" - suspended=$SUSPENDED - object_link=$ID - object_parent=$DOMAIN - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # MAIL - if [ "$type" = 'mail.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # Mail Accounts - if [ "$type" = 'mail' ]; then - type='mail' - if [ -n "$(echo $ACCOUNT |grep $object)" ]; then - key="ACCOUNT" - dom="$(echo $row|cut -f 1 -d :|cut -f 9 -d /|sed 's/.conf//')" - result="$ACCOUNT@$dom" - suspended=$SUSPENDED - object_link=$ACCOUNT - object_parent=$dom - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # DB - if [ "$type" = 'db.conf' ]; then - if [ -n "$(echo $DB |grep $object)" ]; then - key="DATABASE" - result="$DB" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # Cron Jobs - if [ "$type" = 'cron.conf' ]; then - if [ -n "$(echo $CMD |grep $object)" ]; then - key="JOB" - result="$CMD" - suspended=$SUSPENDED - object_link=$JOB - object_parent=$JOB - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - if [ ! -z "$result" ]; then - type=$(echo $type|cut -f1 -d \.) - str="ID='$i' USER='$user' TYPE='$type' KEY='$key'" - str="$str RESULT='$result' ALIAS='$dom_alias'" - str="$str LINK='$object_link' PARENT='$object_parent'" - str="$str SUSPENDED='$suspended' TIME='$object_time'" - str="$str DATE='$object_date'" - echo $str >> $conf - fi -done - -IFS=$OLD_IFS - -# Defining fileds to select -fields='$ID $USER $TYPE $KEY $RESULT $ALIAS $LINK $PARENT $SUSPENDED $TIME' -fields="$fields \$DATE" - -# Listing domains -case $format in - json) json_list_search ;; - plain) nohead=1; shell_list_search ;; - shell) fields='$USER~$TYPE~$KEY~$RESULT~$ALIAS'; - shell_list |column -t -s '~' ;; - *) check_args '2' '0' 'USER OBJECT [FORMAT]' -esac - -rm $conf - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -#log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-start-service b/bin/v-start-service deleted file mode 100755 index 0e5c9b895..000000000 --- a/bin/v-start-service +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# info: start service -# options: service -# -# The function starts system service. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -service=$1 - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'SERVICE' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ "$service" != 'iptables' ]; then - service $service start >/dev/null 2>&1 - check_result $? "$service start failed" $E_RESTART -else - $BIN/v-update-firewall - check_result $? "$service start failed" $E_RESTART -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-stop-firewall b/bin/v-stop-firewall deleted file mode 100755 index 2cd653a61..000000000 --- a/bin/v-stop-firewall +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# info: stop system firewall -# options: NONE -# -# The function stops iptables - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Defining absolute path for iptables and modprobe -iptables="/sbin/iptables" -modprobe="/sbin/modprobe" - -# Includes -source /etc/profile.d/vesta.sh -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -#is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Creating temporary file -tmp=$(mktemp) - -# Flushing INPUT chain -echo "$iptables -P INPUT ACCEPT" >> $tmp -echo "$iptables -F INPUT" >> $tmp - -# Deleting vesta chain -echo "$iptables -X vesta" >> $tmp - -# Deleting custom chains -chains=$(cat $VESTA/data/firewall/chains.conf 2>/dev/null) -IFS=$'\n' -for chain in $chains; do - eval $chain - echo "$iptables -F fail2ban-$CHAIN" >> $tmp - echo "$iptables -X fail2ban-$CHAIN" >> $tmp -done - -# Applying rules -bash $tmp 2>/dev/null - -# Deleting temporary file -rm -f $tmp - -# Saving rules to the master iptables file -if [ -d "/etc/sysconfig" ]; then - /sbin/iptables-save > /etc/sysconfig/iptables - if [ -z "$(ls /etc/rc3.d/S*iptables 2>/dev/null)" ]; then - /sbin/chkconfig iptables off - fi -else - /sbin/iptables-save > /etc/iptables.rules - preup="/etc/network/if-pre-up.d/iptables" - if [ ! -e "$preup" ]; then - echo '#!/bin/sh' > $preup - echo "/sbin/iptables-restore < /etc/iptables.rules" >> $preup - echo "exit 0" >> $preup - chmod +x $preup - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-stop-service b/bin/v-stop-service deleted file mode 100755 index 68f4009ed..000000000 --- a/bin/v-stop-service +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# info: stop service -# options: service -# -# The function stops system service. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -service=$1 - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'SERVICE' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ "$service" != 'iptables' ]; then - service $service stop >/dev/null 2>&1 - check_result $? "$service stop failed" $E_RESTART -else - $BIN/v-stop-firewall - check_result $? "$service stop failed" $E_RESTART -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-suspend-cron-job b/bin/v-suspend-cron-job deleted file mode 100755 index 43074ef14..000000000 --- a/bin/v-suspend-cron-job +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# info: suspend cron job -# options: USER JOB [RESTART] -# -# The function suspends a certain job of the cron scheduler. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -job=$2 -restart=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER JOB [RESTART]' -is_format_valid 'user' 'job' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'cron' 'JOB' "$job" -is_object_unsuspended 'cron' 'JOB' "$job" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Suspending job -update_object_value 'cron' 'JOB' "$job" '$SUSPENDED' 'yes' -increase_user_value "$user" '$SUSPENDED_CRON' - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting crond -$BIN/v-restart-cron $restart -check_result $? "Cron restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-suspend-cron-jobs b/bin/v-suspend-cron-jobs deleted file mode 100755 index 8b3f4ad8b..000000000 --- a/bin/v-suspend-cron-jobs +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# info: Suspending sys cron jobs -# options: USER [RESTART] -# -# The function suspends all user cron jobs. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -restart=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Suspendn all jobs -for job in $(search_objects 'cron' 'SUSPENDED' 'no' 'JOB'); do - $BIN/v-suspend-cron-job $user $job 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting crond -$BIN/v-restart-cron $restart -check_result $? "Cron restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-suspend-database b/bin/v-suspend-database deleted file mode 100755 index ac736ea17..000000000 --- a/bin/v-suspend-database +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# info: suspend database -# options: USER DATABASE -# -# The function for suspending a certain user database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -database=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/db.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DATABASE' -is_format_valid 'user' 'database' -is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" -is_object_unsuspended 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get database values -get_database_values - -# Switching on db type -case $TYPE in - mysql) suspend_mysql_database ;; - pgsql) suspend_pgsql_database ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating db value -update_object_value 'db' 'DB' "$database" '$SUSPENDED' 'yes' -increase_user_value "$user" '$SUSPENDED_DB' - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-suspend-database-host b/bin/v-suspend-database-host deleted file mode 100755 index daf39adc6..000000000 --- a/bin/v-suspend-database-host +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# info: suspend database server -# options: TYPE HOST -# -# The function for suspending a database server. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -type=$1 -host=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'TYPE HOST' -is_format_valid 'type' 'host' -is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -is_object_valid "../../conf/$type" 'HOST' "$host" -is_object_unsuspended "../../conf/$type" 'HOST' "$host" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Suspend database creation on a server -update_object_value "../../conf/$type" 'HOST' "$host" '$SUSPENDED' 'yes' - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-suspend-databases b/bin/v-suspend-databases deleted file mode 100755 index 6c15b014e..000000000 --- a/bin/v-suspend-databases +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# info: suspend databases -# options: USER -# -# The function for suspending of all databases of a single user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting suspend loop -for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do - $BIN/v-suspend-database "$user" "$database" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-suspend-dns-domain b/bin/v-suspend-dns-domain deleted file mode 100755 index bfe30f0bc..000000000 --- a/bin/v-suspend-dns-domain +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -# info: suspend dns domain -# options: USER DOMAIN [RESTART] -# -# The function suspends a certain user's domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -restart="$3" - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [RESTART]' -is_format_valid 'user' 'domain' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting system configs -if [[ "$DNS_SYSTEM" =~ named|bind ]]; then - if [ -e '/etc/named.conf' ]; then - dns_conf='/etc/named.conf' - else - dns_conf='/etc/bind/named.conf' - fi - - sed -i "/\/$user\/conf\/dns\/$domain.db\"/d" $dns_conf -fi - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding suspend in config -update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'yes' -sed -i "s/SUSPENDED='no'/SUSPENDED='yes'/g" $USER_DATA/dns/$domain.conf -increase_user_value "$user" '$SUSPENDED_DNS' - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-suspend-dns-domains b/bin/v-suspend-dns-domains deleted file mode 100755 index c38e4336d..000000000 --- a/bin/v-suspend-dns-domains +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# info: suspend dns domains -# options: USER [RESTART] -# -# The function suspends all user's DNS domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -restart=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -is_format_valid 'user' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting suspend loop -for domain in $(search_objects 'dns' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-suspend-dns-domain "$user" "$domain" 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-suspend-dns-record b/bin/v-suspend-dns-record deleted file mode 100755 index 003f8d757..000000000 --- a/bin/v-suspend-dns-record +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -# info: suspend dns domain record -# options: USER DOMAIN ID [RESTART] -# -# The function suspends a certain domain record. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -id=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ID [RESTART]' -is_format_valid 'user' 'domain' 'id' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_object_valid "dns/$domain" 'ID' "$id" -is_object_unsuspended "dns/$domain" 'ID' "$id" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) -eval $line -sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf - -# Adding record -dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'" -dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='yes' TIME='$TIME' DATE='$DATE'" -echo "$dns_rec" >> $USER_DATA/dns/$domain.conf - -# Sorting records -sort_dns_records - -# Updating zone -if [[ "$DNS_SYSTEM" =~ named|bind ]]; then - update_domain_serial - update_domain_zone -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-suspend-domain b/bin/v-suspend-domain deleted file mode 100755 index 74e17f196..000000000 --- a/bin/v-suspend-domain +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -# info: suspend web/dns/mail domain -# options: USER DOMAIN -# -# The function suspends web/dns/mail domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -restart="${3-yes}" - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Working on Web domain -if [ ! -z "$WEB_SYSTEM" ]; then - str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf |grep "SUSPENDED='no") - if [ ! -z "$str" ]; then - domain_found='yes' - $BIN/v-suspend-web-domain $user $domain 'no' - check_result $? "can't suspend web" > /dev/null - fi -fi - -# Working on DNS domain -if [ ! -z "$DNS_SYSTEM" ]; then - str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf |grep "SUSPENDED='no") - if [ ! -z "$str" ]; then - domain_found='yes' - $BIN/v-suspend-dns-domain $user $domain 'no' - check_result $? "can't suspend dns" > /dev/null - fi -fi - -# Working on Mail domain -if [ ! -z "$MAIL_SYSTEM" ]; then - str=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf |grep "SUSPENDED='no") - if [ ! -z "$str" ]; then - domain_found='yes' - $BIN/v-suspend-mail-domain $user $domain - check_result $? "can't suspend mail" > /dev/null - fi -fi - -# Checking domain search result -if [ -z "$domain_found" ]; then - echo "Error: domain $domain doesn't exist" - log_event "$E_NOTEXIST" "$ARGUMENTS" - exit $E_NOTEXIST -fi - -# Restarting services -$BIN/v-restart-web $restat -check_result $? "can't restart web" > /dev/null - -$BIN/v-restart-proxy $restart -check_result $? "can't restart proxy" > /dev/null - -$BIN/v-restart-dns $restart -check_result $? "can't restart dns" > /dev/null - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-suspend-firewall-rule b/bin/v-suspend-firewall-rule deleted file mode 100755 index 67f14cecb..000000000 --- a/bin/v-suspend-firewall-rule +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -# info: suspend firewall rule -# options: RULE -# -# The function suspends a certain firewall rule. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -rule=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'RULE' -is_format_valid 'rule' -is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM' -is_object_valid '../../data/firewall/rules' 'RULE' "$rule" -is_object_unsuspended '../../data/firewall/rules' 'RULE' "$rule" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Suspending rule -update_object_value ../../data/firewall/rules RULE $rule '$SUSPENDED' yes - -# Updating system firewall -$BIN/v-update-firewall - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-suspend-mail-account b/bin/v-suspend-mail-account deleted file mode 100755 index 913e1c4cd..000000000 --- a/bin/v-suspend-mail-account +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash -# info: suspend mail account -# options: USER DOMAIN ACCOUNT -# -# The function suspends mail account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -account=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ACCOUNT' -is_format_valid 'user' 'domain' 'account' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - quota=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA') - if [ "$quota" = 'unlimited' ]; then - quota=0 - fi - sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd - str="$account:SUSPENDED:$user:mail::$HOMEDIR/$user:$quota" - echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$SUSPENDED' 'yes' - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-suspend-mail-accounts b/bin/v-suspend-mail-accounts deleted file mode 100755 index ab8c440fa..000000000 --- a/bin/v-suspend-mail-accounts +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# info: suspend all mail domain accounts -# options: USER DOMAIN -# -# The function suspends all mail domain accounts. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting suspend loop -for account in $(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT'); do - $BIN/v-suspend-mail-account "$user" "$domain" "$account" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging -#log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-suspend-mail-domain b/bin/v-suspend-mail-domain deleted file mode 100755 index 201dc7f3d..000000000 --- a/bin/v-suspend-mail-domain +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# info: suspend mail domain -# options: USER DOMAIN -# -# The function suspends mail domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting symbolic link -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - rm -f /etc/$MAIL_SYSTEM/domains/$domain -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating config -update_object_value 'mail' 'DOMAIN' "$domain" '$SUSPENDED' 'yes' -sed -i "s/SUSPENDED='no'/SUSPENDED='yes'/g" $USER_DATA/mail/$domain.conf -increase_user_value "$user" '$SUSPENDED_MAIL' - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-suspend-mail-domains b/bin/v-suspend-mail-domains deleted file mode 100755 index 333228ee1..000000000 --- a/bin/v-suspend-mail-domains +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# info: suspend mail domains -# options: USER -# -# The function suspends all user's MAIL domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting suspend loop -for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-suspend-mail-domain "$user" "$domain" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-suspend-remote-dns-host b/bin/v-suspend-remote-dns-host deleted file mode 100755 index f83b61720..000000000 --- a/bin/v-suspend-remote-dns-host +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# info: suspend remote dns server -# options: HOST -# -# The function for suspending remote dns server. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -host=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'HOST' -is_format_valid 'host' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid "../../conf/dns-cluster" 'HOST' "$host" -is_object_unsuspended "../../conf/dns-cluster" 'HOST' "$host" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Unsuspend remote dns server -update_object_value "../../conf/dns-cluster" 'HOST' "$host" '$SUSPENDED' 'yes' - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-suspend-user b/bin/v-suspend-user deleted file mode 100755 index 6276ce5ab..000000000 --- a/bin/v-suspend-user +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -# info: suspend user -# options: USER [RESTART] -# -# The function suspends a certain user and all his objects. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -restart=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -if [ "$user" = 'admin' ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding '!' in front of the password -/usr/sbin/usermod --lock $user - -# Suspending ftp accounts -for ftp in $(grep "^${user}_" /etc/passwd |cut -f 1 -d : ); do - /usr/sbin/usermod --lock $ftp 2>/dev/null -done - -# Suspending web domains -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - $BIN/v-suspend-web-domains $user $restart -fi - -# Suspending dns domains -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - $BIN/v-suspend-dns-domains $user $restart -fi - -# Suspending mail domains -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - $BIN/v-suspend-mail-domains $user -fi - -# Suspending datbabases -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - $BIN/v-suspend-databases $user -fi - -# Suspending cron jobs -if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then - $BIN/v-suspend-cron-jobs $user $restart -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting system services -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -$BIN/v-restart-dns $restart -check_result $? "DNS restart failed" >/dev/null - -$BIN/v-restart-cron $restart -check_result $? "Cron restart failed" >/dev/null - -# Changing suspend value -update_user_value "$user" '$SUSPENDED' 'yes' -increase_user_value 'admin' '$SUSPENDED_USERS' - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-suspend-web-domain b/bin/v-suspend-web-domain deleted file mode 100755 index 7bd658ceb..000000000 --- a/bin/v-suspend-web-domain +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -# info: suspend web domain -# options: USER DOMAIN -# -# The function for suspending the site's operation. After blocking it all -# visitors will be redirected to a web page explaining the reason of suspend. -# By blocking the site the content of all its directories remains untouched. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -restart=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [RESTART]' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -SUSPENDED='yes' -local_ip=$(get_real_ip $IP) - -# Preparing domain values for the template substitution -prepare_web_domain_values - -# Rebuilding vhost -del_web_config "$WEB_SYSTEM" "$TPL.tpl" -add_web_config "$WEB_SYSTEM" "$TPL.tpl" -if [ "$SSL" = 'yes' ]; then - del_web_config "$WEB_SYSTEM" "$TPL.stpl" - add_web_config "$WEB_SYSTEM" "$TPL.stpl" -fi - -# Rebuilding proxy configuration -if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.tpl" - add_web_config "$PROXY_SYSTEM" "$PROXY.tpl" - if [ "$SSL" = 'yes' ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.stpl" - add_web_config "$PROXY_SYSTEM" "$PROXY.stpl" - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating config -update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'yes' -increase_user_value "$user" '$SUSPENDED_WEB' - -# Restarting web server -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-suspend-web-domains b/bin/v-suspend-web-domains deleted file mode 100755 index de8b178da..000000000 --- a/bin/v-suspend-web-domains +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# info: suspend web domains -# options: USER [RESTART] -# -# The function of suspending all user's sites. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -restart=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -is_format_valid 'user' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting suspend loop -for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-suspend-web-domain "$user" "$domain" 'no' -done - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting web server -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-sync-dns-cluster b/bin/v-sync-dns-cluster deleted file mode 100755 index 207ecf91a..000000000 --- a/bin/v-sync-dns-cluster +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash -# info: synchronize dns domains -# options: HOST -# The function synchronize all dns domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -host=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/remote.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER' -is_procces_running -remote_dns_health_check 'no_email' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Selecting remote hosts -IFS=$'\n' -if [ -z $host ]; then - hosts=$(cat $VESTA/conf/dns-cluster.conf |grep "SUSPENDED='no'") -else - hosts=$(grep "HOST='$host'" $VESTA/conf/dns-cluster.conf) -fi - -# Starting cluster loop -for cluster in $hosts; do - - # Parsing host values - eval $cluster - - # Wiping remote domains - cluster_cmd v-delete-dns-domains-src $DNS_USER $HOSTNAME no - check_result $? "$HOST connection failed" $E_CONNECT - - # Syncing user domains - user_list=$(ls -d $VESTA/data/users/*/ | sed "s#$VESTA/data/users/##" | sed s"/.$//" | grep -v "dns-cluster") - for user in $user_list; do - for str in $(cat $VESTA/data/users/$user/dns.conf); do - - # Syncing domain index - eval $str - cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME ' ' no - check_result $? "$HOST connection failed" $E_CONNECT - - # Syncing domain records - tmp_file="/tmp/vst-sync.$DOMAIN" - cluster_file $USER_DATA/$user/dns/$DOMAIN.conf $tmp_file - check_result $? "$HOST connection failed" $E_CONNECT - - cluster_cmd v-insert-dns-records $DNS_USER $DOMAIN $tmp_file 'no' - check_result $? "$HOST connection failed" $E_CONNECT - done - done - - # Rebuilding dns zones - cluster_cmd v-rebuild-dns-domains $DNS_USER - check_result $? "$TYPE connection to $HOST failed" $E_CONNECT - -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Flushing dns-cluster queue -rm -f $VESTA/data/queue/dns-cluster.pipe -touch $VESTA/data/queue/dns-cluster.pipe -chmod 660 $VESTA/data/queue/dns-cluster.pipe - -exit diff --git a/bin/v-unsuspend-cron-job b/bin/v-unsuspend-cron-job deleted file mode 100755 index 0e40a6eca..000000000 --- a/bin/v-unsuspend-cron-job +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# info: unsuspend cron job -# options: USER JOB [RESTART] -# -# The function unsuspend certain cron job. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -job=$2 -restart="${3-yes}" - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER JOB [RESTART]' -is_format_valid 'user' 'job' 'restart' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'cron' 'JOB' "$job" -is_object_suspended 'cron' 'JOB' "$job" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Unsuspending job -update_object_value 'cron' 'JOB' "$job" '$SUSPENDED' 'no' -decrease_user_value "$user" '$SUSPENDED_CRON' - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting crond -$BIN/v-restart-cron $restart -check_result $? "Cron restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-unsuspend-cron-jobs b/bin/v-unsuspend-cron-jobs deleted file mode 100755 index 2f2d740ec..000000000 --- a/bin/v-unsuspend-cron-jobs +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# info: unsuspend sys cron -# options: USER [RESTART] -# -# The function unsuspends all suspended cron jobs. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -restart=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Unsuspendning jobs -for job in $(search_objects 'cron' 'SUSPENDED' 'yes' 'JOB'); do - $BIN/v-unsuspend-cron-job $user $job 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting crond -$BIN/v-restart-cron $restart -check_result $? "Cron restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-unsuspend-database b/bin/v-unsuspend-database deleted file mode 100755 index 89892cb76..000000000 --- a/bin/v-unsuspend-database +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -# info: unsuspend database -# options: USER DATABASE -# -# The function for unsuspending database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -database=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/db.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DATABASE' -is_format_valid 'user' 'database' -is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" -is_object_suspended 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get database values -get_database_values - -# Switching on db type -case $TYPE in - mysql) unsuspend_mysql_database ;; - pgsql) unsuspend_pgsql_database ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating db value -update_object_value 'db' 'DB' "$database" '$SUSPENDED' 'no' -decrease_user_value "$user" '$SUSPENDED_DB' - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-unsuspend-database-host b/bin/v-unsuspend-database-host deleted file mode 100755 index 928776a56..000000000 --- a/bin/v-unsuspend-database-host +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# info: unsuspend database server -# options: TYPE HOST -# -# The function for unsuspending a database server. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -type=$1 -host=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'TYPE HOST' -is_format_valid 'type' 'host' -is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -is_object_valid "../../conf/$type" 'HOST' "$host" -is_object_suspended "../../conf/$type" 'HOST' "$host" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Unsuspend database creation on a server -update_object_value "../../conf/$type" 'HOST' "$host" '$SUSPENDED' 'no' - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-unsuspend-databases b/bin/v-unsuspend-databases deleted file mode 100755 index 30525c869..000000000 --- a/bin/v-unsuspend-databases +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# info: unsuspend databases -# options: USER -# -# The function for unsuspending all user's databases. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/db.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting unsuspend loop -for database in $(search_objects 'db' 'SUSPENDED' "yes" 'DB'); do - $BIN/v-unsuspend-database "$user" "$database" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-unsuspend-dns-domain b/bin/v-unsuspend-dns-domain deleted file mode 100755 index 38008d2fc..000000000 --- a/bin/v-unsuspend-dns-domain +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# info: unsuspend dns domain -# options: USER DOMAIN -# -# The function unsuspends a certain user's domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_suspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Creating system configs -if [[ "$DNS_SYSTEM" =~ named|bind ]]; then - if [ -e '/etc/named.conf' ]; then - dns_conf='/etc/named.conf' - dns_group='named' - else - dns_conf='/etc/bind/named.conf' - dns_group='bind' - fi - - # Adding zone in named.conf - named="zone \"$domain_idn\" {type master; file" - named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" - echo "$named" >> $dns_conf -fi - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Unsuspending domain in config -update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'no' -decrease_user_value "$user" '$SUSPENDED_DNS' -sed -i "s/SUSPENDED='yes'/SUSPENDED='no'/g" $USER_DATA/dns/$domain.conf - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-unsuspend-dns-domains b/bin/v-unsuspend-dns-domains deleted file mode 100755 index eb27ba2ec..000000000 --- a/bin/v-unsuspend-dns-domains +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# info: unsuspend dns domains -# options: USER [RESTART] -# -# The function unsuspends all user's DNS domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -restart=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -is_format_valid 'user' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting unsuspend loop -for domain in $(search_objects 'dns' 'SUSPENDED' "yes" 'DOMAIN'); do - $BIN/v-unsuspend-dns-domain "$user" "$domain" 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-unsuspend-dns-record b/bin/v-unsuspend-dns-record deleted file mode 100755 index f1bc163f4..000000000 --- a/bin/v-unsuspend-dns-record +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# info: unsuspend dns domain record -# options: USER DOMAIN ID [RESTART] -# -# The function unsuspends a certain domain record. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -id=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ID [RESTART]' -is_format_valid 'user' 'domain' 'id' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_object_valid "dns/$domain" 'ID' "$id" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) -eval $line -sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf - -# Adding record -dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'" -dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" -echo "$dns_rec" >> $USER_DATA/dns/$domain.conf - -# Sorting records -sort_dns_records - -# Updating zone -if [[ "$DNS_SYSTEM" =~ named|bind ]]; then - update_domain_serial - update_domain_zone -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-unsuspend-domain b/bin/v-unsuspend-domain deleted file mode 100755 index a0a3b4597..000000000 --- a/bin/v-unsuspend-domain +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash -# info: unsuspend web/dns/mail domain -# options: USER DOMAIN -# -# The function unsuspends web/dns/mail domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -restart="${3-yes}" - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Working on Web domain -if [ ! -z "$WEB_SYSTEM" ]; then - str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf |grep "SUSPENDED='yes") - if [ ! -z "$str" ]; then - domain_found='yes' - $BIN/v-unsuspend-web-domain $user $domain 'no' - check_result $? "can't suspend web" > /dev/null - fi -fi - -# Working on DNS domain -if [ ! -z "$DNS_SYSTEM" ]; then - str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf |grep "SUSPENDED='yes") - if [ ! -z "$str" ]; then - domain_found='yes' - $BIN/v-unsuspend-dns-domain $user $domain 'no' - check_result $? "can't suspend dns" > /dev/null - fi -fi - -# Working on Mail domain -if [ ! -z "$MAIL_SYSTEM" ]; then - str=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf |grep "SUSPENDED='yes") - if [ ! -z "$str" ]; then - domain_found='yes' - $BIN/v-unsuspend-mail-domain $user $domain - check_result $? "can't suspend mail" > /dev/null - fi -fi - -# Checking domain search result -if [ -z "$domain_found" ]; then - echo "Error: domain $domain doesn't exist" - log_event "$E_NOTEXIST" "$ARGUMENTS" - exit $E_NOTEXIST -fi - -# Restarting services -$BIN/v-restart-web $restart -check_result $? "can't restart web" > /dev/null - -$BIN/v-restart-proxy $restart -check_result $? "can't restart proxy" > /dev/null - -$BIN/v-restart-dns $restart -check_result $? "can't restart dns" > /dev/null - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-unsuspend-firewall-rule b/bin/v-unsuspend-firewall-rule deleted file mode 100755 index be6320d41..000000000 --- a/bin/v-unsuspend-firewall-rule +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -# info: unsuspend firewall rule -# options: RULE -# -# The function unsuspends a certain firewall rule. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -rule=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'RULE' -is_format_valid 'rule' -is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM' -is_object_valid '../../data/firewall/rules' 'RULE' "$rule" -is_object_suspended '../../data/firewall/rules' 'RULE' "$rule" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Suspending rule -update_object_value ../../data/firewall/rules RULE $rule '$SUSPENDED' no - -# Updating system firewall -$BIN/v-update-firewall - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-unsuspend-mail-account b/bin/v-unsuspend-mail-account deleted file mode 100755 index 57e54af50..000000000 --- a/bin/v-unsuspend-mail-account +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# info: unsuspend mail account -# options: USER DOMAIN ACCOUNT -# -# The function unsuspends mail account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -account=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ACCOUNT' -is_format_valid 'user' 'domain' 'account' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_suspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5') - quota=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA') - if [ "$quota" = 'unlimited' ]; then - quota=0 - fi - sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd - str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" - echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$SUSPENDED' 'no' - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-unsuspend-mail-accounts b/bin/v-unsuspend-mail-accounts deleted file mode 100755 index 420bcf050..000000000 --- a/bin/v-unsuspend-mail-accounts +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# info: unsuspend all mail domain accounts -# options: USER DOMAIN -# -# The function unsuspends all mail domain accounts. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting unsuspend loop -for account in $(search_objects "mail/$domain" 'SUSPENDED' 'yes' 'ACCOUNT'); do - $BIN/v-unsuspend-mail-account "$user" "$domain" "$account" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging -#log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-unsuspend-mail-domain b/bin/v-unsuspend-mail-domain deleted file mode 100755 index 935865d70..000000000 --- a/bin/v-unsuspend-mail-domain +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -# info: unsuspend mail domain -# options: USER DOMAIN -# -# The function unsuspends mail domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_suspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Add symbolic link -if [[ "$MAIL_SYSTEM" =~ exim ]]; then - ln -s $HOMEDIR/$user/conf/mail/$domain /etc/$MAIL_SYSTEM/domains/ -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating config -update_object_value 'mail' 'DOMAIN' "$domain" '$SUSPENDED' 'no' -sed -i "s/SUSPENDED='yes'/SUSPENDED='no'/g" $USER_DATA/mail/$domain.conf -decrease_user_value "$user" '$SUSPENDED_MAIL' - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-unsuspend-mail-domains b/bin/v-unsuspend-mail-domains deleted file mode 100755 index 6e319c944..000000000 --- a/bin/v-unsuspend-mail-domains +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# info: unsuspend mail domains -# options: USER -# -# The function unsuspends all user's MAIL domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting unsuspend loop -for domain in $(search_objects 'mail' 'SUSPENDED' "yes" 'DOMAIN'); do - $BIN/v-unsuspend-mail-domain "$user" "$domain" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-unsuspend-remote-dns-host b/bin/v-unsuspend-remote-dns-host deleted file mode 100755 index 8e3308bfa..000000000 --- a/bin/v-unsuspend-remote-dns-host +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# info: unsuspend remote dns server -# options: HOST -# -# The function for unsuspending remote dns server. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -host=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'HOST' -is_format_valid 'host' -is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' -is_object_valid "../../conf/dns-cluster" 'HOST' "$host" -is_object_suspended "../../conf/dns-cluster" 'HOST' "$host" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Unsuspend remote dns server -update_object_value "../../conf/dns-cluster" 'HOST' "$host" '$SUSPENDED' 'no' - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-unsuspend-user b/bin/v-unsuspend-user deleted file mode 100755 index 17c6683d6..000000000 --- a/bin/v-unsuspend-user +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -# info: unsuspend user -# options: USER [RESTART] -# -# The function unsuspends user and all his objects. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -restart=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" -if [ "$user" = 'admin' ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting '!' in front of the password -/usr/sbin/usermod --unlock $user - -# Unsuspending ftp accounts -for ftp in $(grep "^${user}_" /etc/passwd |cut -f 1 -d : ); do - /usr/sbin/usermod --unlock $ftp 2>/dev/null -done - -# Unsuspending web domains -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-web-domains $user $restart -fi - -# Unsuspending dns domains -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-dns-domains $user $restart -fi - -# Unsuspending mail domains -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-mail-domains $user -fi - -# Unsuspending datbabases -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-databases $user -fi - -# Unsuspending cron jobs -if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-cron-jobs $user $restart -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Changing suspend value -update_user_value "$user" '$SUSPENDED' 'no' -decrease_user_value 'admin' '$SUSPENDED_USERS' - -# Restarting system services -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -$BIN/v-restart-dns $restart -check_result $? "DNS restart failed" >/dev/null - -$BIN/v-restart-cron $restart -check_result $? "Cron restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-unsuspend-web-domain b/bin/v-unsuspend-web-domain deleted file mode 100755 index 91bc1e16b..000000000 --- a/bin/v-unsuspend-web-domain +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash -# info: unsuspend web domain -# options: USER DOMAIN -# -# The function of unsuspending the domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -restart=$3 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [RESTART]' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_suspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -SUSPENDED='no' -local_ip=$(get_real_ip $IP) - -# Preparing domain values for the template substitution -prepare_web_domain_values - -# Rebuilding vhost -del_web_config "$WEB_SYSTEM" "$TPL.tpl" -add_web_config "$WEB_SYSTEM" "$TPL.tpl" -if [ "$SSL" = 'yes' ]; then - del_web_config "$WEB_SYSTEM" "$TPL.stpl" - add_web_config "$WEB_SYSTEM" "$TPL.stpl" -fi - -# Rebuilding proxy configuration -if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.tpl" - add_web_config "$PROXY_SYSTEM" "$PROXY.tpl" - if [ "$SSL" = 'yes' ]; then - del_web_config "$PROXY_SYSTEM" "$PROXY.stpl" - add_web_config "$PROXY_SYSTEM" "$PROXY.stpl" - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating config -update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'no' -decrease_user_value "$user" '$SUSPENDED_WEB' - -# Restarting web server -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-unsuspend-web-domains b/bin/v-unsuspend-web-domains deleted file mode 100755 index 2d2676d06..000000000 --- a/bin/v-unsuspend-web-domains +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# info: unsuspend web domains -# options: USER [RESTART] -# -# The function of unsuspending all user's sites. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -restart=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -is_format_valid 'user' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting unsuspend loop -for domain in $(search_objects 'web' 'SUSPENDED' "yes" 'DOMAIN'); do - $BIN/v-unsuspend-web-domain "$user" "$domain" 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting web server -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-update-database-disk b/bin/v-update-database-disk deleted file mode 100755 index 5365177a3..000000000 --- a/bin/v-update-database-disk +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# info: update database disk usage -# options: USER DATABASE -# -# The function recalculates disk usage for specific database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -database=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/db.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DATABASE' -is_format_valid 'user' 'database' -is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" -is_object_unsuspended 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get database values -get_database_values - -# Switching on db type -case $TYPE in - mysql) get_mysql_disk_usage ;; - pgsql) get_pgsql_disk_usage ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating disk usage -update_object_value 'db' 'DB' "$database" '$U_DISK' "$usage" -recalc_user_disk_usage - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-update-databases-disk b/bin/v-update-databases-disk deleted file mode 100755 index fd2c34748..000000000 --- a/bin/v-update-databases-disk +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# info: update databases disk usage -# options: USER -# -# The function recalculates disk usage for all user databases. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting update loop -for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do - $BIN/v-update-database-disk "$user" "$database" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-update-dns-templates b/bin/v-update-dns-templates deleted file mode 100755 index 31361d001..000000000 --- a/bin/v-update-dns-templates +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# info: update dns templates -# options: [RESTART] -# -# The function for obtaining updated pack of dns templates. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -restart=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get new archive -tmpdir=$(mktemp -d --dry-run) -mkdir $tmpdir -cd $tmpdir -wget http://c.vestacp.com/rhel/7/templates.tar.gz -q -if [ "$?" -ne 0 ]; then - echo "Error: can't download template.tar.gz" - log_event "$E_CONNECT" "$ARGUMENTS" - rm -rf $tmpdir - exit $E_CONNECT -fi - -# Update templates -tar -xzpf templates.tar.gz -C $VESTA/data/ templates/dns - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Clean tmpdir -rm -rf $tmpdir - -exit diff --git a/bin/v-update-firewall b/bin/v-update-firewall deleted file mode 100755 index 46e2073a3..000000000 --- a/bin/v-update-firewall +++ /dev/null @@ -1,184 +0,0 @@ -#!/bin/bash -# info: update system firewall rules -# options: NONE -# -# The function updates iptables rules - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Defining absolute path for iptables and modprobe -iptables="/sbin/iptables" -modprobe="/sbin/modprobe" -sysctl="/sbin/sysctl" - -# Includes -source /etc/profile.d/vesta.sh -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking local IPv4 rules -rules="$VESTA/data/firewall/rules.conf" -ports="$VESTA/data/firewall/ports.conf" - -if [ ! -e "$rules" ]; then - exit -fi - -$sysctl net.netfilter.nf_conntrack_max >/dev/null 2>&1 -if [ $? -ne 0 ]; then - conntrack='no' -fi - -# Checking conntrack module avaiabilty -$modprobe nf_conntrack >/dev/null 2>&1 -$modprobe nf_conntrack_ftp >/dev/null 2>&1 -if [ $? -ne 0 ]; then - conntrack_ftp='no' -fi - - -# Creating temporary file -tmp=$(mktemp) - -# Flushing INPUT chain -echo "$iptables -P INPUT ACCEPT" >> $tmp -echo "$iptables -F INPUT" >> $tmp - -# Enabling stateful support -if [ "$conntrack" != 'no' ]; then - str="$iptables -A INPUT -m state" - str="$str --state ESTABLISHED,RELATED -j ACCEPT" - echo "$str" >> $tmp -fi - -# Handling local traffic -for ip in $(ls $VESTA/data/ips); do - echo "$iptables -A INPUT -s $ip -j ACCEPT" >> $tmp -done -echo "$iptables -A INPUT -s 127.0.0.1 -j ACCEPT" >> $tmp - -# Pasring iptables rules -IFS=$'\n' -for line in $(sort -r -n -k 2 -t \' $rules); do - eval $line - if [ "$SUSPENDED" = 'no' ]; then - proto="-p $PROTOCOL" - port="--dport $PORT" - ip="-s $IP" - state="" - action="-j $ACTION" - - # Adding multiport module - if [[ "$PORT" =~ ,|-|: ]] ; then - port="-m multiport --dports ${PORT//-/:}" - fi - - # Accepting all dst ports - if [[ "$PORT" = "0" ]] || [ "$PROTOCOL" = 'ICMP' ]; then - port="" - fi - - # Checking FTP for contrack module - if [ "$TYPE" = "FTP" ] || [ "$PORT" = '21' ]; then - if [ "$conntrack_ftp" != 'no' ]; then - state="-m conntrack --ctstate NEW" - else - port="-m multiport --dports 20,21,12000:12100" - fi - ftp="yes" - fi - - # Adding firewall rule - echo "$iptables -A INPUT $proto $port $ip $state $action" >> $tmp - fi -done - -# Switching chain policy to DROP -echo "$iptables -P INPUT DROP" >> $tmp - -# Adding vesta chain -echo "$iptables -N vesta" >> $tmp - -# Applying rules -bash $tmp 2>/dev/null - -# Deleting temporary file -rm -f $tmp - -# Checking custom trigger -if [ -x "$VESTA/data/firewall/custom.sh" ]; then - bash $VESTA/data/firewall/custom.sh -fi - -# Checking fail2ban support -if [ ! -z "$FIREWALL_EXTENSION" ]; then - for chain in $(cat $VESTA/data/firewall/chains.conf 2>/dev/null); do - eval $chain - if [[ "$PORT" =~ ,|-|: ]] ; then - port="-m multiport --dports $PORT" - else - port="--dport $PORT" - fi - echo "$iptables -N fail2ban-$CHAIN" >> $tmp - echo "$iptables -F fail2ban-$CHAIN" >> $tmp - echo "$iptables -I fail2ban-$CHAIN -s 0.0.0.0/0 -j RETURN" >> $tmp - echo "$iptables -I INPUT -p $PROTOCOL $port -j fail2ban-$CHAIN" >>$tmp - done - bash $tmp 2>/dev/null - rm -f $tmp - - for ban in $(cat $VESTA/data/firewall/banlist.conf 2>/dev/null); do - eval $ban - echo -n "$iptables -I fail2ban-$CHAIN 1 -s $IP" >> $tmp - echo " -j REJECT --reject-with icmp-port-unreachable" >> $tmp - done - bash $tmp 2>/dev/null - rm -f $tmp -fi - -# Saving rules to the master iptables file -if [ -d "/etc/sysconfig" ]; then - /sbin/iptables-save > /etc/sysconfig/iptables - if [ -z "$(ls /etc/rc3.d/S*iptables 2>/dev/null)" ]; then - /sbin/chkconfig iptables on - fi -else - /sbin/iptables-save > /etc/iptables.rules - preup="/etc/network/if-pre-up.d/iptables" - if [ ! -e "$preup" ]; then - echo '#!/bin/sh' > $preup - echo "/sbin/iptables-restore < /etc/iptables.rules" >> $preup - echo "exit 0" >> $preup - chmod +x $preup - fi -fi - -# Worarkound for OpenVZ -if [ -e "/proc/vz/veinfo" ]; then - dig @8.8.8.8 google.com +time=1 +tries=1 >/dev/null 2>&1 - if [ "$?" -ne 0 ]; then - $BIN/v-stop-firewall - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-update-host-certificate b/bin/v-update-host-certificate deleted file mode 100755 index 71a87709a..000000000 --- a/bin/v-update-host-certificate +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -# info: update hosts certificates for exim, dovecot & vesta-nginx -# options: user -# options: hostname -# -# Function updates certificates for vesta - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -whoami=$(whoami) -if [ "$whoami" != "root" ] && [ "$whoami" != "admin" ] ; then - echo "You must be root or admin to execute this script"; - exit 1; -fi - - -# Argument definition -user=$1 -hostname=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" '[USER] [HOSTNAME]' -is_format_valid 'user' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_system_enabled "$WEB_SSL" 'SSL_SUPPORT' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$hostname" -is_object_unsuspended 'web' 'DOMAIN' "$hostname" - -if [ ! -f "/home/$user/conf/web/ssl.$hostname.pem" ]; then - echo "This domain does not have certificate"; - exit 1; -fi - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get current datetime for backup of old files -backup_datetime=`date '+%Y-%m-%d_%H-%M-%S'` - -# Keep a backup of the old certificate - todo: remove in production -#mv $VESTA/ssl/certificate.crt $VESTA/ssl/certificate.crt_backup_$backup_datetime -#mv $VESTA/ssl/certificate.key $VESTA/ssl/certificate.key_backup_$backup_datetime - -# Copy hostnames certificates from user dir -cp /home/$user/conf/web/ssl.$hostname.pem $VESTA/ssl/certificate.crt -cp /home/$user/conf/web/ssl.$hostname.key $VESTA/ssl/certificate.key - -# Checking exim username for later chowning -exim_user="exim"; -check_exim_username=$(grep -c '^Debian-exim:' /etc/passwd) -if [ "$check_exim_username" -eq 1 ]; then - exim_user="Debian-exim" -fi - -# Assign exim permissions -chown $exim_user:mail $VESTA/ssl/certificate.crt -chown $exim_user:mail $VESTA/ssl/certificate.key - -# Restart exim, dovecot & vesta -$BIN/v-restart-mail -if [ ! -z "$IMAP_SYSTEM" ]; then - $BIN/v-restart-service "$IMAP_SYSTEM" -fi -if [ ! -z "$FTP_SYSTEM" ]; then - $BIN/v-restart-service "$FTP_SYSTEM" -fi -if [ -f "/var/run/vesta-nginx.pid" ]; then - kill -HUP $(cat /var/run/vesta-nginx.pid) -fi - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit 0; diff --git a/bin/v-update-letsencrypt-ssl b/bin/v-update-letsencrypt-ssl deleted file mode 100755 index ac3e2eda9..000000000 --- a/bin/v-update-letsencrypt-ssl +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -# info: update letsencrypt ssl certificates -# options: NONE -# -# The function for renew letsencrypt expired ssl certificate for all users - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system enviroment as we run this script -# mostly by cron wich not read it by itself -source /etc/profile - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -lecounter=0 -hostname=$(hostname) - -echo "[$(date)] : -----------------------------------------------------------------------------------" >> /usr/local/vesta/log/letsencrypt_cron.log - -# Checking user certificates -for user in $($BIN/v-list-users plain |cut -f 1); do - USER_DATA=$VESTA/data/users/$user - - for domain in $(search_objects 'web' 'LETSENCRYPT' 'yes' 'DOMAIN'); do - - limit_check=1 - fail_counter=$(get_web_counter "$user" "$domain" 'LETSENCRYPT_FAIL_COUNT') - - if [[ "$hostname" = "$domain" ]]; then - if [[ "$fail_counter" -eq 7 ]]; then - limit_check=0 - fi - if [[ "$fail_counter" -eq 8 ]]; then - fail_counter=$(alter_web_counter "$user" "$domain" 'LETSENCRYPT_FAIL_COUNT') - send_email_to_admin "LetsEncrypt renewing hostname $hostname" "Warning: hostname $domain failed for LetsEncrypt renewing" - fi - fi - - if [[ "$fail_counter" -ge 7 ]] && [[ "$limit_check" -eq 1 ]]; then - # echo "$domain failed $fail_counter times for LetsEncrypt renewing, skipping" - echo "[$(date)] : $domain failed $fail_counter times for LetsEncrypt renewing, skipping" >> /usr/local/vesta/log/letsencrypt_cron.log - continue; - fi - crt_data=$(openssl x509 -text -in $USER_DATA/ssl/$domain.crt) - not_after=$(echo "$crt_data" |grep "Not After" |cut -f 2,3,4 -d :) - expiration=$(date -d "$not_after" +%s) - now=$(date +%s) - seconds_valid=$((expiration - now)) - days_valid=$((seconds_valid / 86400)) - if [[ "$days_valid" -lt 31 ]]; then - if [ $lecounter -gt 0 ]; then - sleep 120 - fi - ((lecounter++)) - aliases=$(echo "$crt_data" |grep DNS:) - aliases=$(echo "$aliases" |sed -e "s/DNS://g" -e "s/,//g") - aliases=$(echo "$aliases" |tr ' ' '\n' |sed "/^$/d") - aliases=$(echo "$aliases" |egrep -v "^$domain,?$") - aliases=$(echo "$aliases" |sed -e ':a;N;$!ba;s/\n/,/g') - msg=$($BIN/v-add-letsencrypt-domain $user $domain $aliases) - if [ $? -ne 0 ]; then - if [[ $msg == *"is suspended" ]]; then - echo "[$(date)] : SUSPENDED: $domain $msg" >> /usr/local/vesta/log/letsencrypt_cron.log - else - echo "[$(date)] : $domain $msg" >> /usr/local/vesta/log/letsencrypt_cron.log - echo "$domain $msg" - fail_counter=$(alter_web_counter "$user" "$domain" 'LETSENCRYPT_FAIL_COUNT') - echo "[$(date)] : fail_counter = $fail_counter" >> /usr/local/vesta/log/letsencrypt_cron.log - echo "fail_counter = $fail_counter" - fi - fi - fi - done -done - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging -#log_event "$OK" "$EVENT" - -exit diff --git a/bin/v-update-mail-domain-disk b/bin/v-update-mail-domain-disk deleted file mode 100755 index 451dbd37d..000000000 --- a/bin/v-update-mail-domain-disk +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# info: update mail domain disk usage -# options: USER DOMAIN -# -# The function updates domain disk usage. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -if [ -z "$MAIL_SYSTEM" ] || [ "$MAIL_SYSTEM" = 'remote' ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting loop -dom_diks=0 -for account in $(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT'); do - home_dir=$HOMEDIR/$user/mail/$domain/$account - if [ -e "$home_dir" ]; then - udisk=$(nice -n 19 du -shm $home_dir | cut -f 1 ) - else - udisk=0 - fi - update_object_value "mail/$domain" 'ACCOUNT' "$account" '$U_DISK' "$udisk" - dom_diks=$((dom_diks + udisk)) -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks" -recalc_user_disk_usage - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-update-mail-domains-disk b/bin/v-update-mail-domains-disk deleted file mode 100755 index ca93627f3..000000000 --- a/bin/v-update-mail-domains-disk +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# info: calculate disk usage for all mail domains -# options: USER -# -# The function calculates disk usage for all mail domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -if [ -z "$MAIL_SYSTEM" ] || [ "$MAIL_SYSTEM" = 'remote' ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting loop -for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do - dom_diks=0 - accounts=$(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT') - for account in $accounts; do - home_dir=$HOMEDIR/$user/mail/$domain/$account - if [ -e "$home_dir" ]; then - udisk=$(nice -n 19 du -shm $home_dir | cut -f 1 ) - else - udisk=0 - fi - update_object_value "mail/$domain" 'ACCOUNT' "$account" '$U_DISK' "$udisk" - dom_diks=$((dom_diks + udisk)) - done - update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - - -recalc_user_disk_usage - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-update-sys-ip b/bin/v-update-sys-ip deleted file mode 100755 index 6c07edc6f..000000000 --- a/bin/v-update-sys-ip +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash -# info: update system ip -# options: [NONE] -# -# The function scans configured ip in the system and register them with vesta -# internal database. This call is intended for use on vps servers, where ip is -# set by hypervizor. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system variables -source /etc/profile - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing system ip addresses -ips=$(/sbin/ip addr |grep 'inet ' |grep global |awk '{print $2}' |cut -f1 -d/) -v_ips=$(ls $VESTA/data/ips/) -ip_num=$(echo "$ips" |wc -l) -v_ip_num=$(echo "$v_ips" |wc -l) - -# Checking primary IP change -if [[ "$ip_num" -eq '1' ]] && [[ "$v_ip_num" -eq 1 ]]; then - if [ "$ips" != "$v_ips" ]; then - new=$ips - old=$v_ips - fi -fi - -# Updating configs -if [ ! -z "$old" ]; then - mv $VESTA/data/ips/$old $VESTA/data/ips/$new - - # Updating PROXY - if [ ! -z "$PROXY_SYSTEM" ]; then - cd /etc/$PROXY_SYSTEM/conf.d - if [ -e "$old.conf" ]; then - mv $old.conf $new.conf - sed -i "s/$old/$new/g" $new.conf - fi - fi - - # Updating WEB - if [ ! -z "$WEB_SYSTEM" ]; then - cd /etc/$WEB_SYSTEM/conf.d - if [ -e "$old.conf" ]; then - mv $old.conf $new.conf - sed -i "s/$old/$new/g" $new.conf - fi - sed -i "s/$old/$new/g" $VESTA/data/users/*/web.conf - for user in $(ls $VESTA/data/users/); do - $BIN/v-rebuild-web-domains $user no - done - $BIN/v-restart-proxy - $BIN/v-restart-web - fi - - # Updating DNS - if [ ! -z "$DNS_SYSTEM" ]; then - sed -i "s/$old/$new/g" $VESTA/data/users/*/dns.conf - sed -i "s/$old/$new/g" $VESTA/data/users/*/dns/*.conf - for user in $(ls $VESTA/data/users/); do - $BIN/v-rebuild-dns-domains $user no - done - $BIN/v-restart-dns - fi - - # Updating FTP - if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" = 'vsftpd' ]; then - conf=$(find /etc/ -maxdepth 2 -name $FTP_SYSTEM.conf) - if [ ! -z "$conf" ]; then - sed -i "s/$old/$new/g" $conf - $BIN/v-restart-ftp - fi - fi - - # Updating firewall - if [ ! -z "$FIREWALL_SYSTEM" ]; then - sed -i "s/$old/$new/g" $VESTA/data/firewall/*.conf - $BIN/v-update-firewall - fi -fi - -# Adding system IP -for ip in $ips; do - check_ifconfig=$(/sbin/ifconfig |grep "$ip") - if [ ! -e "$VESTA/data/ips/$ip" ] && [ ! -z "$check_ifconfig" ]; then - interface=$(/sbin/ip addr |grep $ip |awk '{print $NF}' |uniq) - interface=$(echo "$interface" |cut -f 1 -d : |head -n 1) - netmask=$(/sbin/ip addr |grep $ip |cut -f 2 -d / |cut -f 1 -d \ ) - netmask=$(convert_cidr $netmask) - $BIN/v-add-sys-ip $ip $netmask $interface - fi -done - -# Updating NAT -pub_ip=$(curl -s vestacp.com/what-is-my-ip/) -if [ ! -e "$VESTA/data/ips/$pub_ip" ]; then - if [ -z "$(grep -R "$pub_ip" $VESTA/data/ips/)" ]; then - ip=$(ls -t $VESTA/data/ips/ |head -n1) - $BIN/v-change-sys-ip-nat $ip $pub_ip - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-update-sys-ip-counters b/bin/v-update-sys-ip-counters deleted file mode 100755 index 54711f924..000000000 --- a/bin/v-update-sys-ip-counters +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# info: update IP usage counters -# options: IP -# -# Function updates usage U_WEB_ADOMAINS and U_SYS_USERS counters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -ip=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '0' "$#" 'IP' -if [ ! -z "$ip" ]; then - is_format_valid 'ip' - is_ip_valid -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Creating user_list -if [ -z "$ip" ]; then - ip_list=$(ls $VESTA/data/ips) -else - ip_list="$ip" -fi - -# Updating user stats -for ip in $ip_list; do - - # Calculate usage - ip_usage=$(grep -H $ip $VESTA/data/users/*/web.conf) - web_domains=$(echo "$ip_usage" | sed '/^$/d' | wc -l) - sys_users=$(echo "$ip_usage" | cut -f7 -d/ | sort -u |\ - tr '\n' ',' | sed "s/,$//g") - - # Update counters - update_ip_value '$U_WEB_DOMAINS' "$web_domains" - update_ip_value '$U_SYS_USERS' "$sys_users" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-update-sys-queue b/bin/v-update-sys-queue deleted file mode 100755 index 08e940ecd..000000000 --- a/bin/v-update-sys-queue +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash -# info: update system queue -# options: PIPE -# -# This function is responsible queue processing. Restarts of services, -# scheduled backups, web log parsing and other heavy resource consuming -# operations are handled by this script. It helps to optimize system behaviour. -# In a nutshell Apache will be restarted only once even if 10 domains are -# added or deleted. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# -# Argument definition -queue=$1 - -# Importing system environment as we run this script -# mostly by cron wich not read it by itself -source /etc/profile - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Export PATH for cron -PATH=$PATH:$BIN - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'QUEUE' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -b_task=$(ps auxf |grep -v "grep" |grep "$VESTA/bin/v-update-sys-queue backup") -b_task=$(echo "$b_task" |grep -v sudo |wc -l) -d_task=$(ps auxf |grep -v "grep" |grep "$VESTA/bin/v-update-sys-queue dns") -d_task=$(echo "$d_task" |grep -v sudo |wc -l) -if [ "$b_task" -gt 2 ] || [ "$d_task" -gt 2 ]; then - exit -fi - -# Defining pipe functions -case $queue in - restart) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1;; - webstats) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1 ;; - backup) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1 ;; - disk) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1;; - traffic) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1;; - dns-cluster) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1 ;; - letsencrypt) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1 ;; - *) check_args '1' '0' 'QUEUE' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging -#log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-update-sys-rrd b/bin/v-update-sys-rrd deleted file mode 100755 index 77412eaf1..000000000 --- a/bin/v-update-sys-rrd +++ /dev/null @@ -1,143 +0,0 @@ -#!/bin/bash -# info: update system rrd charts -# options: NONE -# -# The script is wrapper for all rrd functions. It updates all -# v-update-sys-rrd_* at once. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system environment as we run this script -# mostly by cron wich do not read it by itself -source /etc/profile - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Another workaround for cron environment -PATH="$PATH:$BIN" -export PATH - -# Checking rrddir -if [ ! -d "$RRD" ]; then - mkdir -p $RRD -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking daily period -if [ -e "$RRD/daily.rrd" ]; then - mtime=$(stat -c "%Y" $RRD/daily.rrd) - ctime=$(date +%s) - dtime=$((ctime - mtime)) - # Update every 5 minute - if [ "$dtime" -gt '290' ]; then - touch $RRD/daily.rrd - periods="$periods daily" - fi -else - touch $RRD/daily.rrd - periods="$periods daily" -fi - -# Checking weekly period -if [ -e "$RRD/weekly.rrd" ]; then - mtime=$(stat -c "%Y" $RRD/weekly.rrd) - ctime=$(date +%s) - dtime=$((ctime - mtime)) - # Update every hour - if [ "$dtime" -gt '3590' ]; then - touch $RRD/weekly.rrd - periods="$periods weekly" - fi -else - touch $RRD/weekly.rrd - periods="$periods weekly" -fi - -# Checking monthly period -if [ -e "$RRD/monthly.rrd" ]; then - mtime=$(stat -c "%Y" $RRD/monthly.rrd) - ctime=$(date +%s) - dtime=$((ctime - mtime)) - # Update every 6 hours - if [ "$dtime" -gt '21590' ]; then - touch $RRD/monthly.rrd - periods="$periods monthly" - fi -else - touch $RRD/monthly.rrd - periods="$periods monthly" -fi - -# Checking yearly period -if [ -e "$RRD/yearly.rrd" ]; then - mtime=$(stat -c "%Y" $RRD/yearly.rrd) - ctime=$(date +%s) - dtime=$((ctime - mtime)) - # Update every 12 hours - if [ "$dtime" -gt '43190' ]; then - touch $RRD/yearly.rrd - periods="$periods yearly" - fi -else - touch $RRD/yearly.rrd - periods="$periods yearly" -fi - - -# Updateing system stats -for period in $periods; do - - $BIN/v-update-sys-rrd-la $period >/dev/null 2>&1 - $BIN/v-update-sys-rrd-net $period >/dev/null 2>&1 - $BIN/v-update-sys-rrd-mem $period >/dev/null 2>&1 - $BIN/v-update-sys-rrd-ssh $period >/dev/null 2>&1 - - # Updating web stats - if [ ! -z "$WEB_SYSTEM" ]; then - $BIN/v-update-sys-rrd-$WEB_SYSTEM $period >/dev/null 2>&1 - fi - - if [ ! -z "$PROXY_SYSTEM" ]; then - $BIN/v-update-sys-rrd-$PROXY_SYSTEM $period >/dev/null 2>&1 - fi - - # Updating mail stats - if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - $BIN/v-update-sys-rrd-mail $period >/dev/null 2>&1 - fi - - # Updating ftp stats - if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then - $BIN/v-update-sys-rrd-ftp $period >/dev/null 2>&1 - fi - - # Updating db stats - if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - for type in ${DB_SYSTEM//,/ }; do - # Switching on db type - case $type in - mysql) $BIN/v-update-sys-rrd-mysql $period >/dev/null 2>&1 ;; - pgsql) $BIN/v-update-sys-rrd-pgsql $period >/dev/null 2>&1 ;; - esac - done - fi -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging -#log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-update-sys-rrd-apache2 b/bin/v-update-sys-rrd-apache2 deleted file mode 100755 index d03a862de..000000000 --- a/bin/v-update-sys-rrd-apache2 +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash -# info: update apache2 rrd -# options: PERIOD -# -# The function is for updating apache rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -period=${1-daily} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - - -# Checking directory -if [ ! -d "$RRD/web" ]; then - mkdir $RRD/web -fi - -# Checking database -if [ ! -e "$RRD/web/apache2.rrd" ]; then - # Adding database - rrdtool create $RRD/web/apache2.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - server_status=$(wget -qO- http://localhost:8081/server-status |\ - grep 'currently being processed'| \ - cut -f 2 -d '>' |\ - sed 's/requests currently being processed, //' | \ - cut -f 1,2 -d ' ') - active=$(echo "$server_status"|cut -f 1 -d ' ') - idle=$(echo "$server_status"|cut -f 1 -d ' ') - a=$((active + idle)) - - # Updating rrd database - rrdtool update $RRD/web/apache2.rrd N:$a -fi - -# Updating rrd graph -rrdtool graph $RRD/web/$period-apache2.png \ - --imgformat PNG \ - --height="150" \ - --width="670" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Connections" \ - --x-grid "$grid" \ - -c "BACK#ffffff" \ - -c "SHADEA#ffffff" \ - -c "SHADEB#ffffff" \ - -c "FONT#555555" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/web/apache2.rrd:A:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Connections " \ - GPRINT:a:'LAST:Current\:''%8.0lf' \ - GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit diff --git a/bin/v-update-sys-rrd-ftp b/bin/v-update-sys-rrd-ftp deleted file mode 100755 index ff1a642f6..000000000 --- a/bin/v-update-sys-rrd-ftp +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# info: update ftp rrd -# options: PERIOD -# -# The function is for updating ftpd rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -period=${1-daily} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/ftp" ]; then - mkdir $RRD/ftp -fi - -# Checking database -if [ ! -e "$RRD/ftp/ftp.rrd" ]; then - # Adding database - rrdtool create $RRD/ftp/ftp.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - a=0 - a=$(ps aux |grep $FTP_SYSTEM |grep -v grep| grep -v nobody|\ - grep -v root|wc -l) - - # Updating rrd database - rrdtool update $RRD/ftp/ftp.rrd N:$a -fi - -# Updating rrd graph -rrdtool graph $RRD/ftp/$period-ftp.png \ - --imgformat PNG \ - --height="150" \ - --width="670" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Connections" \ - --x-grid "$grid" \ - -c "BACK#ffffff" \ - -c "SHADEA#ffffff" \ - -c "SHADEB#ffffff" \ - -c "FONT#555555" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/ftp/ftp.rrd:A:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Users " \ - GPRINT:a:'LAST:Current\:''%8.0lf' \ - GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit diff --git a/bin/v-update-sys-rrd-httpd b/bin/v-update-sys-rrd-httpd deleted file mode 100755 index 4e9af2817..000000000 --- a/bin/v-update-sys-rrd-httpd +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash -# info: update httpd rrd -# options: PERIOD -# -# The function is for updating apache rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -period=${1-daily} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - - -# Checking directory -if [ ! -d "$RRD/web" ]; then - mkdir $RRD/web -fi - -# Checking database -if [ ! -e "$RRD/web/httpd.rrd" ]; then - # Adding database - rrdtool create $RRD/web/httpd.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - server_status=$(wget -qO- http://localhost:8081/server-status |\ - grep 'currently being processed'| \ - cut -f 2 -d '>' |\ - sed 's/requests currently being processed, //' | \ - cut -f 1,2 -d ' ') - active=$(echo "$server_status"|cut -f 1 -d ' ') - idle=$(echo "$server_status"|cut -f 1 -d ' ') - a=$((active + idle)) - - # Updating rrd database - rrdtool update $RRD/web/httpd.rrd N:$a -fi - -# Updating rrd graph -rrdtool graph $RRD/web/$period-httpd.png \ - --imgformat PNG \ - --height="150" \ - --width="670" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Connections" \ - --x-grid "$grid" \ - -c "BACK#ffffff" \ - -c "SHADEA#ffffff" \ - -c "SHADEB#ffffff" \ - -c "FONT#555555" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/web/httpd.rrd:A:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Connections " \ - GPRINT:a:'LAST:Current\:''%8.0lf' \ - GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit diff --git a/bin/v-update-sys-rrd-la b/bin/v-update-sys-rrd-la deleted file mode 100755 index c6343e3d2..000000000 --- a/bin/v-update-sys-rrd-la +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash -# info: update load average rrd -# options: PERIOD -# -# The function is for updating load average rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -period=${1-daily} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/la" ]; then - mkdir $RRD/la -fi - -# Checking database -if [ ! -e "$RRD/la/la.rrd" ]; then - # Adding database - rrdtool create $RRD/la/la.rrd --step $RRD_STEP \ - DS:LA:GAUGE:600:U:U \ - DS:PR:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - loadavg=$(cat /proc/loadavg ) - la=$(echo "$loadavg"|cut -f 2 -d ' ') - pr=$(ps auxh |wc -l) - - # Updating rrd database - rrdtool update $RRD/la/la.rrd N:${la//./}:$pr -fi - -# Updating graph -rrdtool graph $RRD/la/$period-la.png \ - --imgformat PNG \ - --height="150" \ - --width="670" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Points" \ - --x-grid "$grid" \ - -c "BACK#ffffff" \ - -c "SHADEA#ffffff" \ - -c "SHADEB#ffffff" \ - -c "FONT#555555" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#777777" \ - -c "ARROW#555555" \ - DEF:la=$RRD/la/la.rrd:LA:AVERAGE \ - DEF:pr=$RRD/la/la.rrd:PR:AVERAGE \ - COMMENT:'\r' \ - AREA:la#C8EA2E:"LA * 100"\ - GPRINT:la:'LAST: Current\:''%8.0lf' \ - GPRINT:la:'MIN: Min\:''%8.0lf' \ - GPRINT:la:'MAX: Max\:''%8.0lf\j' \ - LINE1:pr#1c74cd:"Procs # " \ - GPRINT:pr:'LAST:Current\:''%8.0lf' \ - GPRINT:pr:'MIN:Min\:''%8.0lf' \ - GPRINT:pr:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit diff --git a/bin/v-update-sys-rrd-mail b/bin/v-update-sys-rrd-mail deleted file mode 100755 index 50cd05c34..000000000 --- a/bin/v-update-sys-rrd-mail +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash -# info: update mail rrd -# options: PERIOD -# -# The function is for updating mail rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -period=${1-daily} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/mail" ]; then - mkdir $RRD/mail -fi - -# Checking database -if [ ! -e "$RRD/mail/mail.rrd" ]; then - # Adding database - rrdtool create $RRD/mail/mail.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - a=0 - a=$(exim -bpc) - - # Updating rrd database - rrdtool update $RRD/mail/mail.rrd N:$a -fi - -# Updating daily graph -rrdtool graph $RRD/mail/$period-mail.png \ - --imgformat PNG \ - --height="150" \ - --width="670" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Queue Size" \ - --x-grid "$grid" \ - -c "BACK#ffffff" \ - -c "SHADEA#ffffff" \ - -c "SHADEB#ffffff" \ - -c "FONT#555555" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/mail/mail.rrd:A:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Emails " \ - GPRINT:a:'LAST:Current\:''%8.0lf' \ - GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit diff --git a/bin/v-update-sys-rrd-mem b/bin/v-update-sys-rrd-mem deleted file mode 100755 index 018acfb74..000000000 --- a/bin/v-update-sys-rrd-mem +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/bash -# info: update memory rrd -# options: PERIOD -# -# The function is for updating memory rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -period=${1-daily} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/mem" ]; then - mkdir $RRD/mem -fi - -# Checking database -if [ -e "$RRD/mem/mem.rrd" ]; then - rrd_check=$(rrdtool info $RRD/mem/mem.rrd |grep "FREE") - if [ -z "$rrd_check" ]; then - rm -f $RRD/mem/mem.rrd - fi -fi -if [ ! -e "$RRD/mem/mem.rrd" ]; then - # Adding database - rrdtool create $RRD/mem/mem.rrd --step $RRD_STEP \ - DS:RAM:GAUGE:600:U:U \ - DS:SWAP:GAUGE:600:U:U \ - DS:FREE:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - mem=$(free -m) - used=$(echo "$mem" |awk '(NR == 2)' |awk '{print $3}') - if [ -z "$(echo "$mem" | grep available)" ]; then - free=$(echo "$mem" |grep buff/cache |awk '{print $4}') - else - free=$(echo "$mem" |awk '(NR == 2)' |awk '{print $7}') - fi - swap=$(echo "$mem" |awk '(NR == 3)' |awk '{print $3}') - - # Updating rrd - rrdtool update $RRD/mem/mem.rrd N:$used:$swap:$free -fi - -# Updating rrd graph -rrdtool graph $RRD/mem/$period-mem.png \ - --imgformat PNG \ - --height="150" \ - --width="670" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Mbytes" \ - --x-grid "$grid" \ - -c "BACK#ffffff" \ - -c "SHADEA#ffffff" \ - -c "SHADEB#ffffff" \ - -c "FONT#555555" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:used=$RRD/mem/mem.rrd:RAM:AVERAGE \ - DEF:swap=$RRD/mem/mem.rrd:SWAP:AVERAGE \ - DEF:free=$RRD/mem/mem.rrd:FREE:AVERAGE \ - COMMENT:'\r' \ - AREA:used#867995:"USED"\ - GPRINT:used:'LAST: Current\:''%8.0lf' \ - GPRINT:used:'MIN: Min\:''%8.0lf' \ - GPRINT:used:'MAX: Max\:''%8.0lf\j' \ - LINE1:free#1c74cd:"FREE" \ - GPRINT:free:'LAST: Current\:''%8.0lf' \ - GPRINT:free:'MIN: Min\:''%8.0lf' \ - GPRINT:free:'MAX: Max\:''%8.0lf\j'\ - LINE2:swap#f57900:"SWAP" \ - GPRINT:swap:'LAST:Current\:''%8.0lf' \ - GPRINT:swap:'MIN:Min\:''%8.0lf' \ - GPRINT:swap:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit diff --git a/bin/v-update-sys-rrd-mysql b/bin/v-update-sys-rrd-mysql deleted file mode 100755 index 8c6bb75e2..000000000 --- a/bin/v-update-sys-rrd-mysql +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash -# info: update MySQL rrd -# options: PERIOD -# -# The function is for updating mysql rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -period=${1-daily} - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/db.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/db" ]; then - mkdir $RRD/db -fi - -# Parsing db hosts -conf="$VESTA/conf/mysql.conf" -hosts=$(grep HOST $conf |awk '{print $1}' |cut -f 2 -d \') -check_row=$(echo "$hosts" |wc -l) -if [ 0 -eq "$check_row" ]; then - exit -fi - -# Parsing excludes -for exclude in $(echo ${RRD_MYSQL_EXCLUDE//,/ }); do - hosts=$(echo "$hosts" |grep -vw "$exclude" ) -done - -for host in $hosts; do - # Checking database - if [ ! -e "$RRD/db/mysql_$host.rrd" ]; then - # Adding database - rrdtool create $RRD/db/mysql_$host.rrd --step $RRD_STEP \ - DS:A:COUNTER:600:U:U \ - DS:S:COUNTER:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 - fi - - if [ "$period" = 'daily' ]; then - mysql_connect $host - query='SHOW GLOBAL STATUS' - status=$(mysql_query "$query" 2>/dev/null) - if [ $? -ne 0 ]; then - active=0 - slow=0 - else - active=$(echo "$status"|grep 'Queries'|cut -f 2) - slow=$(echo "$status"|grep 'Slow_queries'|cut -f 2) - fi - - # Updating rrd - rrdtool update $RRD/db/mysql_$host.rrd N:$active:$slow - fi - - # Updating daily graph - rrdtool graph $RRD/db/$period-mysql_$host.png \ - --imgformat PNG \ - --height="150" \ - --width="670" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Queries" \ - --x-grid "$grid" \ - -c "BACK#ffffff" \ - -c "SHADEA#ffffff" \ - -c "SHADEB#ffffff" \ - -c "FONT#555555" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/db/mysql_$host.rrd:A:AVERAGE \ - DEF:s=$RRD/db/mysql_$host.rrd:S:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Queries"\ - GPRINT:a:'LAST: Current\:''%8.0lf' \ - GPRINT:a:'MIN: Min\:''%8.0lf' \ - GPRINT:a:'MAX: Max\:''%8.0lf\j' \ - AREA:s#f57900:"Slow " \ - GPRINT:s:'LAST:Current\:''%8.0lf' \ - GPRINT:s:'MIN:Min\:''%8.0lf' \ - GPRINT:s:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - if [ "$result" -ne 0 ]; then - exit $E_RRD - fi - -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-update-sys-rrd-net b/bin/v-update-sys-rrd-net deleted file mode 100755 index e9c642e4a..000000000 --- a/bin/v-update-sys-rrd-net +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/bash -# info: update network rrd -# options: PERIOD -# -# The function is for updating network usage rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -period=${1-daily} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/net" ]; then - mkdir $RRD/net -fi - -# Parsing network interfaces -ndev=$(cat /proc/net/dev) -ifaces=$(echo "$ndev" |grep : |cut -f 1 -d : | sed "s/ //g") - -# Parsing excludes -if [ -z "$RRD_IFACE_EXCLUDE" ]; then - RRD_IFACE_EXCLUDE='lo' -fi -for exclude in $(echo ${RRD_IFACE_EXCLUDE//,/ }); do - ifaces=$(echo "$ifaces" |grep -vw "$exclude" ) -done - -for iface in $ifaces; do - # Checking database - if [ ! -e "$RRD/net/$iface.rrd" ]; then - # Adding database - rrdtool create $RRD/net/$iface.rrd --step $RRD_STEP \ - DS:RX:COUNTER:600:U:U \ - DS:TX:COUNTER:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 - fi - - # Parsing device stats - if [ "$period" = 'daily' ]; then - x=$(echo "$ndev" |sed "s/^ *//" |grep "^$iface:" |sed "s/:/ /") - rx=$(echo "$x" |awk '{print $2}') - tx=$(echo "$x" |awk '{print $10}') - - # Updating rrd database - rrdtool update $RRD/net/$iface.rrd N:$rx:$tx - fi - - # Updating rrd graph - rrdtool graph $RRD/net/$period-$iface.png \ - --imgformat PNG \ - --height="150" \ - --width="670" \ - --start "$start" \ - --end "$end" \ - --vertical-label "KBytes" \ - --x-grid "$grid" \ - -c "BACK#ffffff" \ - -c "SHADEA#ffffff" \ - -c "SHADEB#ffffff" \ - -c "FONT#555555" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:inoctets=$RRD/net/$iface.rrd:RX:AVERAGE \ - DEF:outoctets=$RRD/net/$iface.rrd:TX:AVERAGE \ - "CDEF:in=inoctets,8,*" \ - "CDEF:out=outoctets,8,*" \ - COMMENT:'\r' \ - AREA:in#C8EA2E:"Input (rx) "\ - GPRINT:in:'LAST: Current\:''%8.0lf' \ - GPRINT:in:'MIN: Min\:''%8.0lf' \ - GPRINT:in:'MAX: Max\:''%8.0lf\j' \ - LINE1:out#1c74cd:"Output (tx)" \ - GPRINT:out:'LAST:Current\:''%8.0lf' \ - GPRINT:out:'MIN:Min\:''%8.0lf' \ - GPRINT:out:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - if [ "$result" -ne 0 ]; then - exit $E_RRD - fi - -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-update-sys-rrd-nginx b/bin/v-update-sys-rrd-nginx deleted file mode 100755 index 85bf30b8c..000000000 --- a/bin/v-update-sys-rrd-nginx +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/bash -# info: update nginx rrd -# options: PERIOD -# -# The function is for updating nginx rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -period=${1-daily} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/web" ]; then - mkdir $RRD/web -fi - -# Checking database -if [ ! -e "$RRD/web/nginx.rrd" ]; then - # Adding database - rrdtool create $RRD/web/nginx.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - a=$(wget -qO- http://localhost:8084/|head -n1|cut -f 3 -d ' ') - - # Updating rrd database - rrdtool update $RRD/web/nginx.rrd N:$a -fi - -# Updating rrd graph -rrdtool graph $RRD/web/$period-nginx.png \ - --imgformat PNG \ - --height="150" \ - --width="670" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Connections" \ - --x-grid "$grid" \ - -c "BACK#ffffff" \ - -c "SHADEA#ffffff" \ - -c "SHADEB#ffffff" \ - -c "FONT#555555" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/web/nginx.rrd:A:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Connections " \ - GPRINT:a:'LAST:Current\:''%8.0lf' \ - GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit diff --git a/bin/v-update-sys-rrd-pgsql b/bin/v-update-sys-rrd-pgsql deleted file mode 100755 index de2fec8f8..000000000 --- a/bin/v-update-sys-rrd-pgsql +++ /dev/null @@ -1,143 +0,0 @@ -#!/bin/bash -# info: update PostgreSQL rrd -# options: PERIOD -# -# The function is for updating postgresql rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -period=${1-daily} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/db" ]; then - mkdir $RRD/db -fi - -# Parsing db hosts -conf="$VESTA/conf/pgsql.conf" -hosts=$(grep HOST $conf |awk '{print $1}' |cut -f 2 -d \') -check_row=$(echo "$hosts" |wc -l) -if [ 0 -eq "$check_row" ]; then - exit -fi - -# Parsing excludes -for exclude in $(echo ${RRD_PGSQL_EXCLUDE//,/ }); do - hosts=$(echo "$hosts" |grep -vw "$exclude" ) -done - -for host in $hosts; do - # Checking database - if [ ! -e "$RRD/db/pgsql_$host.rrd" ]; then - # Adding database - rrdtool create $RRD/db/pgsql_$host.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - DS:T:COUNTER:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 - fi - - if [ "$period" = 'daily' ]; then - # Defining host credentials - host_str=$(grep "HOST='$host'" $conf) - for key in $host_str; do - eval ${key%%=*}=${key#*=} - done - - export PGPASSWORD="$PASSWORD" - sql="psql -h $HOST -U $USER -c" - - # Checking empty vars - if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ]; then - echo "Error: config is broken" - log_event "$E_PARSING" "$ARGUMENTS" - exit $E_PARSING - fi - - # Parsing data - q='SELECT SUM(xact_commit + xact_rollback), SUM(numbackends) - FROM pg_stat_database;' - status=$($sql psql -d postgres -c "$q" 2>/dev/null); code="$?" - if [ '0' -ne "$code" ]; then - active=0 - slow=0 - else - active=$(echo "$status"|head -n 3|tail -n 1|awk '{print $3}') - trans=$(echo "$status"|head -n 3 |tail -n 1|awk '{print $1}') - fi - - # Updating rrd - export PGPASSWORD='pgsql' - rrdtool update $RRD/db/pgsql_$host.rrd N:$active:$trans - fi - - # Updating rrd graph - rrdtool graph $RRD/db/$period-pgsql_$host.png \ - --imgformat PNG \ - --height="150" \ - --width="670" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Queries" \ - --x-grid "$grid" \ - -c "BACK#ffffff" \ - -c "SHADEA#ffffff" \ - -c "SHADEB#ffffff" \ - -c "FONT#555555" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/db/pgsql_$host.rrd:A:AVERAGE \ - DEF:t=$RRD/db/pgsql_$host.rrd:T:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Queries "\ - GPRINT:a:'LAST: Current\:''%8.0lf' \ - GPRINT:a:'MIN: Min\:''%8.0lf' \ - GPRINT:a:'MAX: Max\:''%8.0lf\j' \ - LINE2:t#f57900:"Transactions" \ - GPRINT:t:'LAST:Current\:''%8.0lf' \ - GPRINT:t:'MIN:Min\:''%8.0lf' \ - GPRINT:t:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - if [ "$result" -ne 0 ]; then - exit $E_RRD - fi - -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-update-sys-rrd-ssh b/bin/v-update-sys-rrd-ssh deleted file mode 100755 index a421b62dd..000000000 --- a/bin/v-update-sys-rrd-ssh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash -# info: update ssh rrd -# options: PERIOD -# -# The function is for updating ssh rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -period=${1-daily} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/ssh" ]; then - mkdir $RRD/ssh -fi - -# Checking database -if [ ! -e "$RRD/ssh/ssh.rrd" ]; then - # Adding database - rrdtool create $RRD/ssh/ssh.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - a=0 - a=$(ps auxf|grep sshd |grep -v grep |grep -v '/usr/sbin/'| wc -l) - - # Updating rrd database - rrdtool update $RRD/ssh/ssh.rrd N:$a -fi - -# Updating daily graph -rrdtool graph $RRD/ssh/$period-ssh.png \ - --imgformat PNG \ - --height="150" \ - --width="670" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Connections" \ - --x-grid "$grid" \ - -c "BACK#ffffff" \ - -c "SHADEA#ffffff" \ - -c "SHADEB#ffffff" \ - -c "FONT#555555" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/ssh/ssh.rrd:A:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Users " \ - GPRINT:a:'LAST:Current\:''%8.0lf' \ - GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit diff --git a/bin/v-update-sys-vesta b/bin/v-update-sys-vesta deleted file mode 100755 index da026ed13..000000000 --- a/bin/v-update-sys-vesta +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -# info: update vesta package/configs -# options: PACKAGE [VERSION] -# -# The function runs as rpm update trigger. It pulls shell script from vesta -# server and runs it. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -package=$1 - -# Importing system environment -source /etc/profile - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking arg number -check_args '1' "$#" 'PACKAGE' - -valid=0 -if [ "$package" = "vesta" ]; then - valid=1 -fi -if [ "$package" = "vesta-nginx" ]; then - valid=1 -fi -if [ "$package" = "vesta-php" ]; then - valid=1 -fi -if [ "$package" = "vesta-ioncube" ]; then - valid=1 -fi -if [ "$package" = "vesta-softaculous" ]; then - valid=1 -fi -if [ $valid -eq 0 ]; then - echo "Package $package is not valid" - exit 1 -fi - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ -n "$(command -v yum)" ]; then - # Clean yum chache - yum -q clean all - - # Define yum cmd - yum="yum -q -y --noplugins --disablerepo=* --enablerepo=vesta" - - # Update vesta package - $yum update $package > /dev/null 2>&1 - check_result $? "$package update failed" $E_UPDATE -else - # Update repo - apt-get update -o Dir::Etc::sourcelist="sources.list.d/vesta.list" \ - -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" -qq - - # Update vesta package - apt-get install $package -qq > /dev/null 2>&1 - check_result $? "$package update failed" $E_UPDATE -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-update-sys-vesta-all b/bin/v-update-sys-vesta-all deleted file mode 100755 index b43fc7930..000000000 --- a/bin/v-update-sys-vesta-all +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# info: update all vesta packages -# options: USER [RESTART] -# -# The function of updating all vesta packages - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system variables -source /etc/profile - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting update loop -for package in vesta vesta-nginx vesta-php vesta-ioncube vesta-softaculous; do - $BIN/v-update-sys-vesta "$package" -done - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit diff --git a/bin/v-update-user-backup-exclusions b/bin/v-update-user-backup-exclusions deleted file mode 100755 index eefad8c31..000000000 --- a/bin/v-update-user-backup-exclusions +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash -# info: update backup exclusion list -# options: USER FILE -# -# The function for updating backup exclusion list - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -vfile=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -is_file_available() { - if [ ! -e "$vfile" ]; then - check_result $E_NOTEXIST "file $vfile doesn't exist" - fi -} - -is_file_valid() { - exclude="[!|#|$|^|&|(|)|{|}|<|>|?|\|\"|;|%|\`]" - if [[ "$(cat $vfile)" =~ $exclude ]]; then - check_result $E_INVALID "invalid characters in the exlusion list" - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER FILE' -is_format_valid 'user' 'vfile' -is_object_valid 'user' 'USER' "$user" -is_file_available -is_file_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Flush variables -WEB='' -DNS='' -MAIL='' -DB='' -CRON='' -USER='' - -# Source exclusion list -source $vfile - -# Updating exlusion list -echo "WEB='$WEB'" > $USER_DATA/backup-excludes.conf -echo "DNS='$DNS'" >> $USER_DATA/backup-excludes.conf -echo "MAIL='$MAIL'" >> $USER_DATA/backup-excludes.conf -echo "DB='$DB'" >> $USER_DATA/backup-excludes.conf -echo "CRON='$CRON'" >> $USER_DATA/backup-excludes.conf -echo "USER='$USER'" >> $USER_DATA/backup-excludes.conf -chmod 660 $USER_DATA/backup-excludes.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "updated exlusion list" -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-update-user-counters b/bin/v-update-user-counters deleted file mode 100755 index b0f944302..000000000 --- a/bin/v-update-user-counters +++ /dev/null @@ -1,217 +0,0 @@ -#!/bin/bash -# info: update user usage counters -# options: USER -# -# Function updates usage counters like U_WEB_DOMAINS, U_MAIL_ACCOUNTS, etc. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '0' "$#" 'USER' -if [ ! -z "$user" ]; then - is_format_valid 'user' - is_object_valid 'user' 'USER' "$user" -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Creating user_list -if [ -z "$user" ]; then - user_list=$(ls $VESTA/data/users) -else - user_list="$user" -fi - -# Updating user stats -for user in $user_list; do - USER_DATA=$VESTA/data/users/$user - # Cleaning counters - SUSPENDED_USERS=0 - SUSPENDED_WEB=0 - SUSPENDED_DNS=0 - SUSPENDED_MAIL=0 - SUSPENDED_DB=0 - SUSPENDED_CRON=0 - IP_AVAIL=0 - IP_OWNED=0 - U_USERS=0 - U_DISK=0 - DISK=0 - U_DISK_DIRS=$(get_user_value '$U_DISK_DIRS') - if [ -z "$U_DISK_DIRS" ]; then - U_DISK_DIRS=0 - fi - DISK=$((DISK + U_DISK_DIRS)) - U_DISK_WEB=0 - U_DISK_MAIL=0 - U_DISK_DB=0 - BANDWIDTH=0 - U_BANDWIDTH=0 - U_WEB_DOMAINS=0 - U_WEB_SSL=0 - U_WEB_ALIASES=0 - U_DNS_DOMAINS=0 - U_DNS_RECORDS=0 - U_MAIL_DOMAINS=0 - U_MAIL_DKIM=0 - U_MAIL_ACCOUNTS=0 - U_DATABASES=0 - U_CRON_JOBS=0 - U_BACKUPS=0 - - # New IFS - IFS=$'\n' - - # Checking users - if [ "$user" = 'admin' ]; then - spnd=$(grep "SUSPENDED='yes'" $VESTA/data/users/*/user.conf | wc -l) - SUSPENDED_USERS=$spnd - U_USERS=$(ls $VESTA/data/users/|wc -l) - fi - - # Checking ip - for ip in $(ls $VESTA/data/ips) ;do - source $VESTA/data/ips/$ip - if [ "$OWNER" = "$user" ]; then - IP_OWNED=$((IP_OWNED + 1)) - IP_AVAIL=$((IP_AVAIL + 1)) - fi - if [ "$OWNER" = 'admin' ] && [ "$STATUS" = 'shared' ]; then - IP_AVAIL=$((IP_AVAIL + 1)) - fi - done - if [ "$user" = 'admin' ]; then - IP_AVAIL=$(ls $VESTA/data/ips | wc -l) - fi - - # Checking web system - U_WEB_DOMAINS=0 - for domain_str in $(cat $USER_DATA/web.conf) ;do - eval $domain_str - U_DISK_WEB=$((U_DISK_WEB + U_DISK)) - U_WEB_DOMAINS=$((U_WEB_DOMAINS + 1)) - - if [ "$SSL" = 'yes' ]; then - U_WEB_SSL=$((U_WEB_SSL + 1)) - fi - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_WEB=$((SUSPENDED_WEB + 1)) - fi - if [ ! -z "$ALIAS" ]; then - aliases=$(echo "$ALIAS"|tr ',' '\n'| wc -l) - U_WEB_ALIASES=$((U_WEB_ALIASES + aliases)) - fi - BANDWIDTH=$((BANDWIDTH + U_BANDWIDTH)) - done - DISK=$((DISK + U_DISK_WEB)) - - # Checking dns system - for domain_str in $(cat $USER_DATA/dns.conf); do - eval $domain_str - U_DNS_DOMAINS=$((U_DNS_DOMAINS + 1)) - records=$(wc -l $USER_DATA/dns/$DOMAIN.conf| cut -f 1 -d ' ') - U_DNS_RECORDS=$((U_DNS_RECORDS + records)) - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_DNS=$((SUSPENDED_DNS + 1)) - fi - update_object_value 'dns' 'DOMAIN' "$DOMAIN" '$RECORDS' "$records" - done - - # Checking mail system - for domain_str in $(cat $USER_DATA/mail.conf); do - eval $domain_str - U_DISK_MAIL=$((U_DISK_MAIL + U_DISK)) - U_MAIL_DOMAINS=$((U_MAIL_DOMAINS + 1)) - accounts=$(wc -l $USER_DATA/mail/$DOMAIN.conf| cut -f 1 -d ' ') - U_MAIL_ACCOUNTS=$((U_MAIL_ACCOUNTS + accounts)) - if [ "$DKIM" = 'yes' ]; then - U_MAIL_DKIM=$((U_MAIL_DKIM + 1)) - fi - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_MAIL=$((SUSPENDED_MAIL + 1)) - fi - update_object_value 'mail' 'DOMAIN' "$DOMAIN" '$ACCOUNTS' "$accounts" - done - DISK=$((DISK + U_DISK_MAIL)) - - # Checking db system - for db_str in $(cat $USER_DATA/db.conf); do - eval $db_str - U_DISK_DB=$((U_DISK_DB + U_DISK)) - U_DATABASES=$((U_DATABASES + 1)) - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_DB=$((SUSPENDED_DB + 1)) - fi - done - DISK=$((DISK + U_DISK_DB)) - - # Checking cron system - for cron_str in $(cat $USER_DATA/cron.conf);do - eval $cron_str - U_CRON_JOBS=$((U_CRON_JOBS + 1)) - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_CRON=$((SUSPENDED_CRON + 1)) - fi - done - - # Checking backup - for backup_str in $(cat $USER_DATA/backup.conf); do - U_BACKUPS=$((U_BACKUPS +1)) - done - - U_DISK=$DISK - U_BANDWIDTH=$BANDWIDTH - update_user_value "$user" '$SUSPENDED_USERS' "$SUSPENDED_USERS" - update_user_value "$user" '$SUSPENDED_WEB' "$SUSPENDED_WEB" - update_user_value "$user" '$SUSPENDED_DNS' "$SUSPENDED_DNS" - update_user_value "$user" '$SUSPENDED_MAIL' "$SUSPENDED_MAIL" - update_user_value "$user" '$SUSPENDED_DB' "$SUSPENDED_DB" - update_user_value "$user" '$SUSPENDED_CRON' "$SUSPENDED_CRON" - update_user_value "$user" '$IP_AVAIL' "$IP_AVAIL" - update_user_value "$user" '$IP_OWNED' "$IP_OWNED" - update_user_value "$user" '$U_USERS' "$U_USERS" - update_user_value "$user" '$U_DISK' "$U_DISK" - update_user_value "$user" '$U_DISK_DIRS' "$U_DISK_DIRS" - update_user_value "$user" '$U_DISK_WEB' "$U_DISK_WEB" - update_user_value "$user" '$U_DISK_MAIL' "$U_DISK_MAIL" - update_user_value "$user" '$U_DISK_DB' "$U_DISK_DB" - update_user_value "$user" '$U_BANDWIDTH' "$U_BANDWIDTH" - update_user_value "$user" '$U_WEB_DOMAINS' "$U_WEB_DOMAINS" - update_user_value "$user" '$U_WEB_SSL' "$U_WEB_SSL" - update_user_value "$user" '$U_WEB_ALIASES' "$U_WEB_ALIASES" - update_user_value "$user" '$U_DNS_DOMAINS' "$U_DNS_DOMAINS" - update_user_value "$user" '$U_DNS_RECORDS' "$U_DNS_RECORDS" - update_user_value "$user" '$U_MAIL_DOMAINS' "$U_MAIL_DOMAINS" - update_user_value "$user" '$U_MAIL_DKIM' "$U_MAIL_DKIM" - update_user_value "$user" '$U_MAIL_ACCOUNTS' "$U_MAIL_ACCOUNTS" - update_user_value "$user" '$U_DATABASES' "$U_DATABASES" - update_user_value "$user" '$U_CRON_JOBS' "$U_CRON_JOBS" - update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-update-user-disk b/bin/v-update-user-disk deleted file mode 100755 index a99eaf379..000000000 --- a/bin/v-update-user-disk +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# info: update user disk usage -# options: USER -# -# The functions recalculates disk usage and updates database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Saving old IFS -OLDIFS=$IFS -IFS=$(echo -en "\n\b") - -# Defining directory list -dir_list=$(ls $HOMEDIR/$user/ |grep -v '^web$' | grep -v '^mail$' |\ - grep -v '^conf$') - -# Starting update disk loop -disk_usage='0' -for dir in $dir_list; do - dir_disk=$(du -shm "$HOMEDIR/$user/$dir"|cut -f 1 ) - disk_usage=$((disk_usage + dir_disk)) -done - -# Restoring old IFS -IFS=$OLDIFS - -# Updating disk value in config -update_user_value "$user" '$U_DISK_DIRS' "$disk_usage" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Recalculating user disk space -recalc_user_disk_usage - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-update-user-package b/bin/v-update-user-package deleted file mode 100755 index fa9e5ce09..000000000 --- a/bin/v-update-user-package +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# info: update user package -# options: PACKAGE -# -# The function propagates package to connected users. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -package=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'PACKAGE' -is_format_valid 'package' -is_package_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -for user in $(ls $VESTA/data/users); do - check_package=$(grep "PACKAGE='$package'" $USER_DATA/$user/user.conf) - if [ ! -z "$check_package" ]; then - $BIN/v-change-user-package $user $package 'yes' - fi -done - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-update-user-quota b/bin/v-update-user-quota deleted file mode 100755 index 3483bca5b..000000000 --- a/bin/v-update-user-quota +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# info: update user disk quota -# options: USER -# -# The functions upates disk quota for specific user - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -is_format_valid 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Updating disk quota -# Had quota equals package value. Soft quota equals 90% of package value for warnings. -quota=$(get_user_value '$DISK_QUOTA') -soft=$(echo "$quota * 1024"|bc |cut -f 1 -d .) -hard=$(echo "$quota * 1024"|bc |cut -f 1 -d .) - -# Searching home mount point -mnt=$(df -P /home |awk '{print $6}' |tail -n1) - -# Checking unlinmited quota -if [ "$quota" = 'unlimited' ]; then - setquota $user 0 0 0 0 $mnt 2>/dev/null -else - setquota $user $soft $hard 0 0 $mnt 2>/dev/null -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-update-user-stats b/bin/v-update-user-stats deleted file mode 100755 index 23854328d..000000000 --- a/bin/v-update-user-stats +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash -# info: update user statistics -# options: USER -# -# Function logs user parameters into statistics database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 - -# Importing system environment as we run this script -# mostly by cron wich not read it by itself -source /etc/profile - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '0' "$#" 'USER' -if [ ! -z "$user" ]; then - is_format_valid 'user' - is_object_valid 'user' 'USER' "$user" -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Creating user_list -if [ -z "$user" ]; then - user_list=$(grep '@' /etc/passwd |cut -f1 -d:) -else - user_list="$user" -fi - -# Reset overal statistics -TOTAL_IP_OWNED=0 -TOTAL_U_DISK=0 -TOTAL_U_DISK_DIRS=0 -TOTAL_U_DISK_WEB=0 -TOTAL_U_DISK_MAIL=0 -TOTAL_U_DISK_DB=0 -TOTAL_U_BANDWIDTH=0 -TOTAL_U_WEB_DOMAINS=0 -TOTAL_U_WEB_SSL=0 -TOTAL_U_WEB_ALIASES=0 -TOTAL_U_DNS_DOMAINS=0 -TOTAL_U_DNS_RECORDS=0 -TOTAL_U_MAIL_DOMAINS=0 -TOTAL_U_MAIL_DKIM=0 -TOTAL_U_MAIL_ACCOUNTS=0 -TOTAL_U_DATABASES=0 -TOTAL_U_CRON_JOBS=0 -TOTAL_U_BACKUPS=0 -TOTAL_USERS=0 - -# Updating user stats -for user in $user_list; do - if [ ! -f "$VESTA/data/users/$user/user.conf" ]; then - continue; - fi - USER_DATA=$VESTA/data/users/$user - source $USER_DATA/user.conf - next_month=$(date +'%m/01/%y' -d '+ 1 month') - DATE=$(date -d "$next_month -1day" +%F) - - # Compiling report string - s="DATE='$DATE' TIME='$TIME' PACKAGE='$PACKAGE' IP_OWNED='$IP_OWNED'" - s="$s DISK_QUOTA='$DISK_QUOTA' U_DISK='$U_DISK'" - s="$s U_DISK_DIRS='$U_DISK_DIRS' U_DISK_WEB='$U_DISK_WEB'" - s="$s U_DISK_MAIL='$U_DISK_MAIL' U_DISK_DB='$U_DISK_DB'" - s="$s BANDWIDTH='$BANDWIDTH' U_BANDWIDTH='$U_BANDWIDTH'" - s="$s U_WEB_DOMAINS='$U_WEB_DOMAINS' U_WEB_SSL='$U_WEB_SSL'" - s="$s U_WEB_ALIASES='$U_WEB_ALIASES' U_DNS_DOMAINS='$U_DNS_DOMAINS'" - s="$s U_DNS_RECORDS='$U_DNS_RECORDS' U_MAIL_DOMAINS='$U_MAIL_DOMAINS'" - s="$s U_MAIL_DKIM='$U_MAIL_DKIM' U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS'" - s="$s U_DATABASES='$U_DATABASES' U_CRON_JOBS='$U_CRON_JOBS'" - s="$s U_BACKUPS='$U_BACKUPS'" - - # Updating user stats log - stats="$USER_DATA/stats.log" - if [ -e "$stats" ]; then - # Checking dublicates - check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :) - if [ -z "$check_month" ]; then - # Updating as there no dublicates - echo "$s" >> $stats - chmod 660 $stats - else - # Replacing string with new data - sed -i "$check_month s/.*/$s/" $stats - fi - else - # Creating stats log - echo "$s" >$stats - chmod 660 $stats - fi - - # Increase overall counters - TOTAL_IP_OWNED=$((TOTAL_IP_OWNED + IP_OWNED)) - TOTAL_U_DISK=$((TOTAL_U_DISK + U_DISK)) - TOTAL_U_DISK_DIRS=$((TOTAL_U_DISK_DIRS + U_DISK_DIRS)) - TOTAL_U_DISK_WEB=$((TOTAL_U_DISK_WEB + U_DISK_WEB)) - TOTAL_U_DISK_MAIL=$((TOTAL_U_DISK_MAIL + U_DISK_MAIL)) - TOTAL_U_DISK_DB=$((TOTAL_U_DISK_DB + U_DISK_DB)) - TOTAL_U_BANDWIDTH=$((TOTAL_U_BANDWIDTH + U_BANDWIDTH)) - TOTAL_U_WEB_DOMAINS=$((TOTAL_U_WEB_DOMAINS + U_WEB_DOMAINS)) - TOTAL_U_WEB_SSL=$((TOTAL_U_WEB_SSL + U_WEB_SSL)) - TOTAL_U_WEB_ALIASES=$((TOTAL_U_WEB_ALIASES + U_WEB_ALIASES)) - TOTAL_U_DNS_DOMAINS=$((TOTAL_U_DNS_DOMAINS + U_DNS_DOMAINS)) - TOTAL_U_DNS_RECORDS=$((TOTAL_U_DNS_RECORDS + U_DNS_RECORDS)) - TOTAL_U_MAIL_DOMAINS=$((TOTAL_U_MAIL_DOMAINS + U_MAIL_DOMAINS)) - TOTAL_U_MAIL_DKIM=$((TOTAL_U_MAIL_DKIM + U_MAIL_DKIM)) - TOTAL_U_MAIL_ACCOUNTS=$((TOTAL_U_MAIL_ACCOUNTS + U_MAIL_ACCOUNTS)) - TOTAL_U_DATABASES=$((TOTAL_U_DATABASES + U_DATABASES)) - TOTAL_U_CRON_JOBS=$((TOTAL_U_CRON_JOBS + U_CRON_JOBS)) - TOTAL_U_BACKUPS=$((TOTAL_U_BACKUPS + U_BACKUPS)) - TOTAL_USERS=$((TOTAL_USERS + 1)) - -done - -# Updating overall stats -stats="$VESTA/data/users/admin/overall_stats.log" - -s="DATE='$DATE' TIME='$TIME' PACKAGE='default' IP_OWNED='$TOTAL_IP_OWNED'" -s="$s DISK_QUOTA='0' U_DISK='$TOTAL_U_DISK' U_DISK_DIRS='$TOTAL_U_DISK_DIRS'" -s="$s U_DISK_WEB='$TOTAL_U_DISK_WEB' U_DISK_MAIL='$TOTAL_U_DISK_MAIL'" -s="$s U_DISK_DB='$TOTAL_U_DISK_DB' BANDWIDTH='0'" -s="$s U_BANDWIDTH='$TOTAL_U_BANDWIDTH' U_WEB_DOMAINS='$TOTAL_U_WEB_DOMAINS'" -s="$s U_WEB_SSL='$TOTAL_U_WEB_SSL' U_WEB_ALIASES='$TOTAL_U_WEB_ALIASES'" -s="$s U_DNS_DOMAINS='$TOTAL_U_DNS_DOMAINS'" -s="$s U_DNS_RECORDS='$TOTAL_U_DNS_RECORDS'" -s="$s U_MAIL_DOMAINS='$TOTAL_U_MAIL_DOMAINS'" -s="$s U_MAIL_DKIM='$TOTAL_U_MAIL_DKIM'" -s="$s U_MAIL_ACCOUNTS='$TOTAL_U_MAIL_ACCOUNTS'" -s="$s U_DATABASES='$TOTAL_U_DATABASES'" -s="$s U_CRON_JOBS='$TOTAL_U_CRON_JOBS' U_BACKUPS='$TOTAL_U_BACKUPS'" -s="$s U_USERS='$TOTAL_USERS'" - -if [ -e "$stats" ]; then - # Checking dublicates - check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :) - if [ -z "$check_month" ]; then - # Updating as there no dublicates - echo "$s" >> $stats - chmod 660 $stats - else - # Replacing string with new data - sed -i "$check_month s/.*/$s/" $stats - fi -else - # Creating stats log - echo "$s" >$stats - chmod 660 $stats -fi - - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-update-web-domain-disk b/bin/v-update-web-domain-disk deleted file mode 100755 index ac851b922..000000000 --- a/bin/v-update-web-domain-disk +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# info: update disk usage for domain -# options: USER DOMAIN -# -# The function recalculates disk usage for specific webdomain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining home directory -home_dir="$HOMEDIR/$user/web/$domain/" - -# Checking home directory exist -if [ -e "$home_dir" ]; then - disk_usage=$(nice -n 19 du -shm $home_dir | cut -f 1 ) -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating disk value in config -update_object_value 'web' 'DOMAIN' "$domain" '$U_DISK' "$disk_usage" -recalc_user_disk_usage - -# Logging -log_event "$OK" "$ARGUMENTS" - -exit diff --git a/bin/v-update-web-domain-ssl b/bin/v-update-web-domain-ssl deleted file mode 100755 index 877005c40..000000000 --- a/bin/v-update-web-domain-ssl +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -# info: updating ssl certificate for domain -# options: USER DOMAIN SSL_DIR [RESTART] -# -# The function updates the SSL certificate for a domain. Parameter ssl_dir is a path -# to directory where 2 or 3 ssl files can be found. Certificate file -# domain.tld.crt and its key domain.tld.key are mandatory. Certificate -# authority domain.tld.ca file is optional. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 -ssl_dir=$3 -restart=$4 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn -# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ? - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN SSL_DIR [RESTART]' -validate_format 'user' 'domain' 'ssl_dir' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_system_enabled "$WEB_SSL" 'SSL_SUPPORT' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' -is_web_domain_cert_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding certificate to user data directory -cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt -cp -f $ssl_dir/$domain.key $USER_DATA/ssl/$domain.key -cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem -if [ -e "$ssl_dir/$domain.ca" ]; then - cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca - echo >> $USER_DATA/ssl/$domain.pem - cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem -fi -chmod 660 $USER_DATA/ssl/$domain.* - - - -# Adding certificate to user dir -cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/web/ssl.$domain.crt -cp -f $USER_DATA/ssl/$domain.key $HOMEDIR/$user/conf/web/ssl.$domain.key -cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/web/ssl.$domain.pem -if [ -e "$USER_DATA/ssl/$domain.ca" ]; then - cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/web/ssl.$domain.ca -fi - - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restarting web server -$BIN/v-restart-web $restart -check_result $? "Web restart failed" >/dev/null - -$BIN/v-restart-proxy $restart -check_result $? "Proxy restart failed" >/dev/null - -# Logging -log_history "update ssl certificate for $domain" -log_event "$OK" "$EVENT" - -exit diff --git a/bin/v-update-web-domain-stat b/bin/v-update-web-domain-stat deleted file mode 100755 index c2c793e3c..000000000 --- a/bin/v-update-web-domain-stat +++ /dev/null @@ -1,153 +0,0 @@ -#!/bin/bash -# info: update domain statistics -# options: USER DOMAIN -# -# The function runs log analyzer for specific webdomain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument definition -user=$1 -domain=$2 -domain_idn=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/conf/vesta.conf - -# Additional argument formatting -format_domain -format_domain_idn - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -is_format_valid 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -get_domain_values 'web' - -# Checking config -config="$HOMEDIR/$user/conf/web/$STATS.$domain.conf" -if [ ! -e "$config" ]; then - check_result $E_NOTEXISTS "$config doesn't exist" -fi - -# Checking statistics directory -dir="$HOMEDIR/$user/web/$domain/stats" -if [ ! -e "$dir" ]; then - mkdir -p $dir -fi - -# Defining functions -build_webalizer() { - /usr/bin/webalizer -c $config -} - -build_awstats() { - if [ -d "/etc/sysconfig" ]; then - awstats="/usr/share/awstats/wwwroot/cgi-bin/awstats.pl" - wwwroot="/usr/share/awstats/wwwroot" - if [ ! -e "$awstats" ]; then - awstats="/var/www/awstats/awstats.pl" - wwwroot="/var/www/awstats" - fi - else - awstats="/usr/lib/cgi-bin/awstats.pl" - wwwroot="/usr/share/awstats" - fi - opts="-config=$domain_idn -staticlinks -update -output" - month=$(date "+%Y-%m") - output='alldomains allhosts lasthosts unknownip allrobots lastrobots - urldetail urlentry urlexit osdetail browserdetail unknownbrowser - unknownos refererse refererpages keyphrases keywords errors404' - - # Checking statistics directory - if [ ! -e "$dir/$month" ]; then - mkdir -p $dir/$month - fi - - # Logo check - if [ ! -e "$dir/logo.png" ]; then - cp -r $VESTA/web/images/logo.png $dir/ - fi - - # Icon directory check - if [ ! -e "$dir/icon" ]; then - cp -r $wwwroot/icon $dir/ - fi - - # Creating main awstats page - $awstats $opts | sed "s%awstats.$domain.%%g" > $dir/$month/index.html - - # Creating suplemental awstats pages - for format in $output; do - $awstats $opts=$format |\ - sed "s%awstats.$domain.%%g" > $dir/$month/$format.html - done - - # Creating index page - cat $WEBTPL/awstats/index.tpl | sed "s/%month%/$month/g" >\ - $dir/index.html - - # Creating navigation page - months=$(find $dir -type d | sed -e "s%$dir/%%g" -e "s%$dir%%g" |\ - grep -v icon | sort -r ) - for link in $months; do - year=$(echo $link |cut -f 1 -d \-) - month=$(echo $link |cut -f 2 -d \-| sed -e "s/^0//") - case "$month" in - 1) month='January';; - 2) month='February';; - 3) month='March';; - 4) month='April';; - 5) month='May';; - 6) month='June';; - 7) month='July';; - 8) month='August';; - 9) month='September';; - 10) month='October';; - 11) month='November';; - 12) month='December';; - esac - select_m="$select_m