Compare commits

..

5 commits

59 changed files with 1368 additions and 5425 deletions

3
.gitignore vendored
View file

@ -1,3 +0,0 @@
conf/config.local.php
.vagrant
.idea

View file

@ -1,66 +0,0 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
This project does not follow semantic versioning.
The **major** part of the version is the year
The **minor** part changes is the month
The **patch** part changes is incremented if multiple releases happen the same month
## [Unreleased]
### Added
### Changed
### Fixed
### Removed
### Security
## [24.04]
### Added
* Prevent op_del to fail and able to remove web account when part of it is already removed
### Changed
* Add sendmail_path and open_basedir in LXC PHP pool configs
### Fixed
* letsencrypt: Add required check when retrieving certificate. (Avoid TypeError.)
* web-add.sh: Fix ssh group membership (#94)
### Removed
### Security
## [23.02] 2023-02-20
### Added
* web : Display web-add.sh version
### Changed
* Readme.md : Translated to english. New contribution guidelines and misc information
### Fixed
* web-add.sh : Deleting mysql user with DROP USER to stay compatible with MariaDB 10.5+ - #78
* web-add.sh : Correcting deletion order to avoid dependency issues - #76
### Removed
### Security

3
INSTALL Normal file
View file

@ -0,0 +1,3 @@
* Ajouter l'utilisateur qui fait tourner l'application dans le groupe shadow
* Ajouter les autorisations sudo nécessaires
* Désactiver les magic quotes de PHP

888
LICENSE
View file

@ -1,620 +1,281 @@
GNU AFFERO GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 3, 19 November 2007 Version 2, June 1991
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
Preamble Preamble
The GNU Affero General Public License is a free, copyleft license for The licenses for most software are designed to take away your
software and other kinds of works, specifically designed to ensure freedom to share and change it. By contrast, the GNU General Public
cooperation with the community in the case of network server software. License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
The licenses for most software and other practical works are designed General Public License applies to most of the Free Software
to take away your freedom to share and change the works. By contrast, Foundation's software and to any other program whose authors commit to
our General Public Licenses are intended to guarantee your freedom to using it. (Some other Free Software Foundation software is covered by
share and change all versions of a program--to make sure it remains free the GNU Lesser General Public License instead.) You can apply it to
software for all its users. your programs, too.
When we speak of free software, we are referring to freedom, not When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for 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 this service if you wish), that you receive source code or can get it
want it, that you can change the software or use pieces of it in new if you want it, that you can change the software or use pieces of it
free programs, and that you know you can do these things. in new free programs; and that you know you can do these things.
Developers that use our General Public Licenses protect your rights To protect your rights, we need to make restrictions that forbid
with two steps: (1) assert copyright on the software, and (2) offer anyone to deny you these rights or to ask you to surrender the rights.
you this License which gives you legal permission to copy, distribute These restrictions translate to certain responsibilities for you if you
and/or modify the software. distribute copies of the software, or if you modify it.
A secondary benefit of defending all users' freedom is that For example, if you distribute copies of such a program, whether
improvements made in alternate versions of the program, if they gratis or for a fee, you must give the recipients all the rights that
receive widespread use, become available for other developers to you have. You must make sure that they, too, receive or can get the
incorporate. Many developers of free software are heartened and source code. And you must show them these terms so they know their
encouraged by the resulting cooperation. However, in the case of rights.
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to We protect your rights with two steps: (1) copyright the software, and
ensure that, in such cases, the modified source code becomes available (2) offer you this license which gives you legal permission to copy,
to the community. It requires the operator of a network server to distribute and/or modify the software.
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and Also, for each author's protection and ours, we want to make certain
published by Affero, was designed to accomplish similar goals. This is that everyone understands that there is no warranty for this free
a different license, not a version of the Affero GPL, but Affero has software. If the software is modified by someone else and passed on, we
released a new version of the Affero GPL which permits relicensing under want its recipients to know that what they have is not the original, so
this license. that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and The precise terms and conditions for copying, distribution and
modification follow. modification follow.
TERMS AND CONDITIONS GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. Definitions.
0. This License applies to any program or other work which contains
"This License" refers to version 3 of the GNU Affero General Public License. a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
"Copyright" also means copyright-like laws that apply to other kinds of refers to any such program or work, and a "work based on the Program"
works, such as semiconductor masks. means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
"The Program" refers to any copyrightable work licensed under this either verbatim or with modifications and/or translated into another
License. Each licensee is addressed as "you". "Licensees" and language. (Hereinafter, translation is included without limitation in
"recipients" may be individuals or organizations. the term "modification".) Each licensee is addressed as "you".
To "modify" a work means to copy from or adapt all or part of the work Activities other than copying, distribution and modification are not
in a fashion requiring copyright permission, other than the making of an covered by this License; they are outside its scope. The act of
exact copy. The resulting work is called a "modified version" of the running the Program is not restricted, and the output from the Program
earlier work or a work "based on" the earlier work. is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
A "covered work" means either the unmodified Program or a work based Whether that is true depends on what the Program does.
on the Program.
1. You may copy and distribute verbatim copies of the Program's
To "propagate" a work means to do anything with it that, without source code as you receive it, in any medium, provided that you
permission, would make you directly or secondarily liable for conspicuously and appropriately publish on each copy an appropriate
infringement under applicable copyright law, except executing it on a copyright notice and disclaimer of warranty; keep intact all the
computer or modifying a private copy. Propagation includes copying, notices that refer to this License and to the absence of any warranty;
distribution (with or without modification), making available to the and give any other recipients of the Program a copy of this License
public, and in some countries other activities as well. along with the Program.
To "convey" a work means any kind of propagation that enables other You may charge a fee for the physical act of transferring a copy, and
parties to make or receive copies. Mere interaction with a user through you may at your option offer warranty protection in exchange for a fee.
a computer network, with no transfer of a copy, is not conveying.
2. You may modify your copy or copies of the Program or any portion
An interactive user interface displays "Appropriate Legal Notices" of it, thus forming a work based on the Program, and copy and
to the extent that it includes a convenient and prominently visible distribute such modifications or work under the terms of Section 1
feature that (1) displays an appropriate copyright notice, and (2) above, provided that you also meet all of these conditions:
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the a) You must cause the modified files to carry prominent notices
work under this License, and how to view a copy of this License. If stating that you changed the files and the date of any change.
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion. b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
1. Source Code. part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source c) If the modified program normally reads commands interactively
form of a work. when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
A "Standard Interface" means an interface that either is an official announcement including an appropriate copyright notice and a
standard defined by a recognized standards body, or, in the case of notice that there is no warranty (or else, saying that you provide
interfaces specified for a particular programming language, one that a warranty) and that users may redistribute the program under
is widely used among developers working in that language. these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
The "System Libraries" of an executable work include anything, other does not normally print such an announcement, your work based on
than the work as a whole, that (a) is included in the normal form of the Program is not required to print an announcement.)
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 These requirements apply to the modified work as a whole. If
Major Component, or to implement a Standard Interface for which an identifiable sections of that work are not derived from the Program,
implementation is available to the public in source code form. A and can be reasonably considered independent and separate works in
"Major Component", in this context, means a major essential component themselves, then this License, and its terms, do not apply to those
(kernel, window system, and so on) of the specific operating system sections when you distribute them as separate works. But when you
(if any) on which the executable work runs, or a compiler used to distribute the same sections as part of a whole which is a work based
produce the work, or an object code interpreter used to run it. on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
The "Corresponding Source" for a work in object code form means all entire whole, and thus to each and every part regardless of who wrote it.
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to Thus, it is not the intent of this section to claim rights or contest
control those activities. However, it does not include the work's your rights to work written entirely by you; rather, the intent is to
System Libraries, or general-purpose tools or generally available free exercise the right to control the distribution of derivative or
programs which are used unmodified in performing those activities but collective works based on the Program.
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for In addition, mere aggregation of another work not based on the Program
the work, and the source code for shared libraries and dynamically with the Program (or with a work based on the Program) on a volume of
linked subprograms that the work is specifically designed to require, a storage or distribution medium does not bring the other work under
such as by intimate data communication or control flow between those the scope of this License.
subprograms and other parts of the work.
3. You may copy and distribute the Program (or a work based on it,
The Corresponding Source need not include anything that users under Section 2) in object code or executable form under the terms of
can regenerate automatically from other parts of the Corresponding Sections 1 and 2 above provided that you also do one of the following:
Source.
a) Accompany it with the complete corresponding machine-readable
The Corresponding Source for a work in source code form is that source code, which must be distributed under the terms of Sections
same work. 1 and 2 above on a medium customarily used for software interchange; or,
2. Basic Permissions. b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
All rights granted under this License are granted for the term of cost of physically performing source distribution, a complete
copyright on the Program, and are irrevocable provided the stated machine-readable copy of the corresponding source code, to be
conditions are met. This License explicitly affirms your unlimited distributed under the terms of Sections 1 and 2 above on a medium
permission to run the unmodified Program. The output from running a customarily used for software interchange; or,
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your c) Accompany it with the information you received as to the offer
rights of fair use or other equivalent, as provided by copyright law. to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
You may make, run and propagate covered works that you do not received the program in object code or executable form with such
convey, without conditions so long as your license otherwise remains an offer, in accord with Subsection b above.)
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you The source code for a work means the preferred form of the work for
with facilities for running those works, provided that you comply with making modifications to it. For an executable work, complete source
the terms of this License in conveying all material for which you do code means all the source code for all modules it contains, plus any
not control copyright. Those thus making or running the covered works associated interface definition files, plus the scripts used to
for you must do so exclusively on your behalf, under your direction control compilation and installation of the executable. However, as a
and control, on terms that prohibit them from making any copies of special exception, the source code distributed need not include
your copyrighted material outside their relationship with you. anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
Conveying under any other circumstances is permitted solely under operating system on which the executable runs, unless that component
the conditions stated below. Sublicensing is not allowed; section 10 itself accompanies the executable.
makes it unnecessary.
If distribution of executable or object code is made by offering
3. Protecting Users' Legal Rights From Anti-Circumvention Law. access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
No covered work shall be deemed part of an effective technological distribution of the source code, even though third parties are not
measure under any applicable law fulfilling obligations under article compelled to copy the source along with the object code.
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such 4. You may not copy, modify, sublicense, or distribute the Program
measures. except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
When you convey a covered work, you waive any legal power to forbid void, and will automatically terminate your rights under this License.
circumvention of technological measures to the extent such circumvention However, parties who have received copies, or rights, from you under
is effected by exercising rights under this License with respect to this License will not have their licenses terminated so long as such
the covered work, and you disclaim any intention to limit operation or parties remain in full compliance.
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of 5. You are not required to accept this License, since you have not
technological measures. signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
4. Conveying Verbatim Copies. prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
You may convey verbatim copies of the Program's source code as you Program), you indicate your acceptance of this License to do so, and
receive it, in any medium, provided that you conspicuously and all its terms and conditions for copying, distributing or modifying
appropriately publish on each copy an appropriate copyright notice; the Program or works based on it.
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code; 6. Each time you redistribute the Program (or any work based on the
keep intact all notices of the absence of any warranty; and give all Program), the recipient automatically receives a license from the
recipients a copy of this License along with the Program. original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
You may charge any price or no price for each copy that you convey, restrictions on the recipients' exercise of the rights granted herein.
and you may offer support or warranty protection for a fee. You are not responsible for enforcing compliance by third parties to
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. this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free 7. If, as a consequence of a court judgment or allegation of patent
patent license under the contributor's essential patent claims, to infringement or for any other reason (not limited to patent issues),
make, use, sell, offer for sale, import and otherwise run, modify and conditions are imposed on you (whether by court order, agreement or
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 otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a excuse you from the conditions of this License. If you cannot
covered work so as to satisfy simultaneously your obligations under this distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may License and any other pertinent obligations, then as a consequence you
not convey it at all. For example, if you agree to terms that obligate you may not distribute the Program at all. For example, if a patent
to collect a royalty for further conveying from those to whom you convey license would not permit royalty-free redistribution of the Program by
the Program, the only way you could satisfy both those terms and this all those who receive copies directly or indirectly through you, then
License would be to refrain entirely from conveying the Program. the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
13. Remote Network Interaction; Use with the GNU General Public License. If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
Notwithstanding any other provision of this License, if you modify the It is not the purpose of this section to induce you to infringe any
Program, your modified version must prominently offer all users patents or other property right claims or to contest validity of any
interacting with it remotely through a computer network (if your version such claims; this section has the sole purpose of protecting the
supports such interaction) an opportunity to receive the Corresponding integrity of the free software distribution system, which is
Source of your version by providing access to the Corresponding Source implemented by public license practices. Many people have made
from a network server at no charge, through some standard or customary generous contributions to the wide range of software distributed
means of facilitating copying of software. This Corresponding Source through that system in reliance on consistent application of that
shall include the Corresponding Source for any work covered by version 3 system; it is up to the author/donor to decide if he or she is willing
of the GNU General Public License that is incorporated pursuant to the to distribute software through any other system and a licensee cannot
following paragraph. impose that choice.
Notwithstanding any other provision of this License, you have This section is intended to make thoroughly clear what is believed to
permission to link or combine any covered work with a work licensed be a consequence of the rest of this License.
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License. 8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
The Free Software Foundation may publish revised and/or new versions of 9. The Free Software Foundation may publish revised and/or new versions
the GNU Affero General Public License from time to time. Such new versions of the General Public License from time to time. Such new versions will
will be similar in spirit to the present version, but may differ in detail to be similar in spirit to the present version, but may differ in detail to
address new problems or concerns. address new problems or concerns.
Each version is given a distinguishing version number. If the Each version is given a distinguishing version number. If the Program
Program specifies that a certain numbered version of the GNU Affero General specifies a version number of this License which applies to it and "any
Public License "or any later version" applies to it, you have the later version", you have the option of following the terms and conditions
option of following the terms and conditions either of that numbered either of that version or of any later version published by the Free
version or of any later version published by the Free Software Software Foundation. If the Program does not specify a version number of
Foundation. If the Program does not specify a version number of the this License, you may choose any version ever published by the Free Software
GNU Affero General Public License, you may choose any version ever published Foundation.
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future 10. If you wish to incorporate parts of the Program into other free
versions of the GNU Affero General Public License can be used, that proxy's programs whose distribution conditions are different, write to the author
public statement of acceptance of a version permanently authorizes you to ask for permission. For software which is copyrighted by the Free
to choose that version for the Program. Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
Later license versions may give you additional or different NO WARRANTY
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. 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
ALL NECESSARY SERVICING, REPAIR OR CORRECTION. PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
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 END OF TERMS AND CONDITIONS
@ -626,36 +287,53 @@ 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 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 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 convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found. the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author> Copyright (C) 2013 Benoît.S
This program is free software: you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License You should have received a copy of the GNU General Public License along
along with this program. If not, see <https://www.gnu.org/licenses/>. with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail. Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer If the program is interactive, make it output a short notice like this
network, you should also make sure that it provides a way for users to when it starts in an interactive mode:
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school, Gnomovision version 69, Copyright (C) year name of author
if any, to sign a "copyright disclaimer" for the program, if necessary. Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
For more information on this, and how to apply and follow the GNU AGPL, see This is free software, and you are welcome to redistribute it
<https://www.gnu.org/licenses/>. 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, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
This 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.

View file

@ -1,48 +1,3 @@
# Evoadmin-web evoadmin-web
============
Web interface and management scripts for web hosting Panel d'administration de serveur web.
Project leader : ?
## Versions & Branches
The `master` branch is ready for production.
It's compatible with the current Debian version (and few previous ones)
Code for older Debian releases (Wheezy, Jessie) is archived on separate branches.
The `unstable` branch contains not sufficiently tested changes that we don't consider ready for production yet.
### Versions
* Debian Stretch, Buster, Bullseye → use branch `master` (current stable version)
* Debian Jessie → use branch `jessie` (old, archive branch)
* Debian Wheezy → use branch `wheezy` (old, archive branch)
## Installation
Installation should be done with Ansible.
The role `packweb-apache` will handle all dependencies (Apache, PHP, MariaDB...) installation and configuration.
It will also use the role `webapps/evoadmin-web` to setup the web-interface and management sw
### Manually
TODO
## Contributing
Contributions are welcome, especially bug fixes. They will be merged in if they are consistent with our conventions and use cases. They might be rejected if they introduce complexity, cover features we don't need or don't fit "style".
Before starting anything of importance, we suggest opening an issue to discuss what you'd like to add or change.
All modifications should be documented in the CHANGELOG file, to help review releases. We encourage atomic commits and with the CHANGELOG in the same commit.
# Workflow
The ideal and most typical workflow is to create a branch, based on the `unstable` branch. The branch should have a descriptive name (a ticket/issue number is great). The branch can be treated as a pull-request or merge-request. It should be propery tested and reviewed before merging into `unstable`.
Changes that don't introduce significant changes — or that must go faster that the typical workflow — can be commited directly into `unstable`.
Hotfixes, can be prepared on a new branch, based on `master` or `unstable` (to be decided by the author). When ready, it can be merged back to `master` for immediate deployment and to `unstable` for proper backporting.
Other workflow are not forbidden, but should be discussed in advance.

View file

@ -1,180 +0,0 @@
### Activation du mode Multi PHP avec des conteneurs LXC
Installer les paquets nécessaires :
~~~
# apt install lxc debootstrap
~~~
Modifier la configuration de LXC :
~~~
# cat /etc/lxc/default.conf
# Set the default network virtualization method.
lxc.network.type = none
# Mount /home into containers.
lxc.mount.entry = /home home none bind 0 0
# Only one tty is enough.
# This require that you disabled others tty ([2-6]) in systemd.
lxc.tty = 1
# Run 64bits containers
lxc.arch = x86_64
# Start containers on boot by default
lxc.start.auto = 1
~~~
Dans cette configuration, les containers LXC n'ont pas leur interface réseau virtualisée. Et /home de l'hôte est partagé dans les containers.
#### PHP 5.6
On installe un conteneur Debian Jessie :
~~~
# lxc-create --name php56 --template debian --bdev dir --logfile /var/log/lxc/lxc-php56.log --logpriority INFO -- --arch amd64 --release jessie
~~~
Puis on installe les paquets PHP 5.6 dans ce conteneur :
~~~
# lxc-start -n php56
# lxc-attach -n php56 apt install php5-fpm php5-cli php5-gd php5-imap php5-ldap php5-mcrypt php5-mysql php5-pgsql php-gettext php5-intl php5-curl php5-ssh2 libphp-phpmailer
~~~
#### PHP 7.0
On installe un conteneur Debian Stretch :
~~~
# lxc-create --name php70 --template debian --bdev dir --logfile /var/log/lxc/lxc-php70.log --logpriority INFO -- --arch amd64 --release stretch
~~~
Puis on installe les paquets PHP 7.0 dans ce conteneur :
~~~
# lxc-start -n php70
# lxc-attach -n php70 apt install php-fpm php-cli php-gd php-intl php-imap php-ldap php-mcrypt php-mysql php-pgsql php-gettext php-curl php-ssh2 composer libphp-phpmailer
~~~
#### PHP 7.3
On installe un conteneur Debian Stretch :
~~~
# lxc-create --name php73 --template debian --bdev dir --logfile /var/log/lxc/lxc-php73.log --logpriority INFO -- --arch amd64 --release stretch
~~~
Puis on installe les paquets PHP 7.3 dans ce conteneur :
~~~
# lxc-start -n php73
# lxc-attach -n php73
# apt-get update && apt-get install -y --no-install-recommends wget apt-transport-https ca-certificates gnupg
# curl https://packages.sury.org/php/apt.gpg | apt-key add
# echo "deb https://packages.sury.org/php/ stretch main" > /etc/apt/sources.list.d/sury.list
# apt-get update && apt-get install -y --no-install-recommends php7.3 php7.3-fpm php7.3-cli php7.3-curl php7.3-mysql php7.3-pgsql php7.3-ldap php7.3-imap php7.3-gd php-ssh2 php-gettext composer libphp-phpmailer
~~~
#### Pour toutes les versions de PHP
Dans les containers, il faut ajouter le fichier **z-evolinux-defaults.ini** dans le dossier **conf.d** des réglages de PHP FPM et CLI
> Pour PHP5 **/etc/php5/fpm/conf.d/z-evolinux-defaults.ini** et **/etc/php5/cli/conf.d/z-evolinux-defaults.ini**
>
> Pour PHP7.0 **/etc/php/7.0/fpm/conf.d/z-evolinux-defaults.ini** et **/etc/php/7.0/cli/conf.d/z-evolinux-defaults.ini**
>
> Pour PHP7.3 **/etc/php/7.3/fpm/conf.d/z-evolinux-defaults.ini** et **/etc/php/7.3/cli/conf.d/z-evolinux-defaults.ini**
~~~
[PHP]
short_open_tag = Off
expose_php = Off
display_errors = Off
log_errors = On
html_errors = Off
allow_url_fopen = Off
disable_functions = exec,shell-exec,system,passthru,putenv,popen
~~~
Après cela, il faut redémarrer FPM
~~~
# lxc-attach -n php56 /etc/init.d/php5-fpm restart
# lxc-attach -n php70 /etc/init.d/php7.0-fpm restart
# lxc-attach -n php73 /etc/init.d/php7.3-fpm restart
~~~
Une fois les conteneurs installés, il faut configurer evoadmin-web pour lui indiquer les versions disponibles de PHP dans **/etc/evolinux/web-add.conf** (pour *web-add.sh*) et dans **/home/evoadmin/www/conf/config.local.php** pour l'interface web
~~~
# cat /etc/evolinux/web-add.conf
#(...)
PHP_VERSIONS=(56 70 73)
#(...)
~~~
~~~
# cat /home/evoadmin/www/conf/config.local.php
// (...)
$localconf['php_versions'] = array(70, 73);
// (...)
~~~
#### Apache
Il est nécessaire d'activer le mod proxy pour apache2 si ce n'a pas déjà été fait :
~~~
# a2enmod proxy_fcgi
# systemctl restart apache2.service
~~~
Si vous rencontrez l'erreur "File not found" avec les fichiers php, bien vérifier que le rootfs des conteneurs est en 755 :
~~~
# chmod 755 /var/lib/lxc/php56/rootfs
# chmod 755 /var/lib/lxc/php70/rootfs
# chmod 755 /var/lib/lxc/php73/rootfs
~~~
#### Email
Pour envoyer des mails, on peut installer **ssmtp** qui va forwarder les mails du conteneur vers l'hôte (à faire par conteneur via lxc-attach) :
Avant d'installer le paquet, il faut ajouter le hostname du conteneur dans **/etc/hosts**, sinon la configuration du paquet retourne une erreur :
~~~
127.0.0.1 php70
~~~
~~~
# apt install ssmtp
~~~
Editer **/etc/ssmtp/ssmtp.conf** (remplacer example.com par le hostname complet de votre machine) :
~~~
root=postmaster
mailhub=127.0.0.1
hostname=example.com
FromLineOverride=YES
~~~
#### PHP-CLI
~~~
$ cat /usr/local/bin/exec73
#!/bin/bash
php_cmd=$(printf "/usr/bin/php %q" "$@" )
lxc-attach -n php73 -- su - "$SUDO_USER" -c "$php_cmd"
~~~
Il faut ensuite s'assurer que ce script peut être exécuté via sudo.

7
TODO Normal file
View file

@ -0,0 +1,7 @@
* Verification des paramètres passés dans le script ftpadmin.sh
* Vérifier lors de la suppression que c'est bien la personne a qui appartient le compte qui lance la commande
* Tableau "sortable" (TableKit ?)
* Mettre en place EvoLog et logger la sortie des scripts
* Validation plus (très) stricte sur les entrées de formulaire
* Listage des comptes utilisateurs
* Total espace disque FTP

38
Vagrantfile vendored
View file

@ -1,38 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::DEFAULT_SERVER_URL.replace('https://vagrantcloud.com')
# Load ~/.VagrantFile if exist, permit local config provider
vagrantfile = File.join("#{Dir.home}", '.VagrantFile')
load File.expand_path(vagrantfile) if File.exists?(vagrantfile)
Vagrant.configure('2') do |config|
config.vm.synced_folder "./", "/vagrant", type: "rsync", rsync__exclude: [ '.vagrant', '.git']
config.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: true
config.vm.network "forwarded_port", guest: 443, host: 8443, auto_correct: true
# Prevent TTY Errors (copied from laravel/homestead: "homestead.rb" file)... By default this is "bash -l".
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
$deps = <<SCRIPT
sed -e '/RewriteRule/ s/^#*/#/' -i /etc/apache2/sites-available/evoadmin.conf
sed -e '/RewriteCond/ s/^#*/#/' -i /etc/apache2/sites-available/evoadmin.conf
systemctl restart apache2
rm -rf /home/evoadmin/www/
rm -rf /usr/share/scripts/evoadmin/
ln -s /vagrant/ /home/evoadmin/www
ln -s /vagrant/scripts /usr/share/scripts/evoadmin
SCRIPT
config.vm.define :packweb do |node|
node.vm.hostname = "evoadmin-web.example.com"
node.vm.box = "evolix/packweb"
node.vm.provision "deps", type: "shell", :inline => $deps
end
end

View file

@ -9,9 +9,9 @@ $file = '';
$server = ''; $server = '';
if (is_mcluster_mode()) { if (is_mcluster_mode()) {
if ($argc != 3) { if ($argc != 3) {
echo "Multi-cluster mode is enabled in your config file.\n"; echo "Multi-cluster mode is enabled in your config file.\n";
echo "Usage: $argv[0] <cluster> <server>\n"; echo "Usage: $argv[0] <cluster> <server>\n";
exit(1); exit(1);
} }
$file = str_replace('%cluster_name%', $argv[1], $conf['cache']); $file = str_replace('%cluster_name%', $argv[1], $conf['cache']);
$server = $argv[2]; $server = $argv[2];
@ -19,7 +19,7 @@ if (is_mcluster_mode()) {
else { else {
if ($argc != 2) { if ($argc != 2) {
echo "Usage: $argv[0] <server>\n"; echo "Usage: $argv[0] <server>\n";
exit(1); exit(1);
} }
$file = $conf['cache']; $file = $conf['cache'];
$server = $argv[1]; $server = $argv[1];
@ -27,8 +27,8 @@ else {
if (!file_exists($file)) { if (!file_exists($file)) {
echo "$file doesn't exist\n"; echo "$file doesn't exist\n";
exit(1); exit(1);
} }
$bdd->open($file); $bdd->open($file);

View file

@ -18,12 +18,12 @@ foreach ($files as $file) {
$bdd = new bdd(); $bdd = new bdd();
if (!file_exists($file)) { if (!file_exists($file)) {
$bdd->create($file); $bdd->create($file);
echo "$file created.\n"; echo "$file created.\n";
} }
else { else {
echo "$file is already created.\n"; echo "$file is already created.\n";
continue; continue;
} }
} }

View file

@ -7,23 +7,23 @@ $file = '';
$server = ''; $server = '';
if (is_mcluster_mode()) { if (is_mcluster_mode()) {
if ($argc != 2) { if ($argc != 2) {
echo "Multi-cluster mode is enabled in your config file.\n"; echo "Multi-cluster mode is enabled in your config file.\n";
echo "Usage: $argv[0] <cluster>\n"; echo "Usage: $argv[0] <cluster>\n";
exit(1); exit(1);
} }
$file = str_replace('%cluster_name%', $argv[1], $conf['cache']); $file = str_replace('%cluster_name%', $argv[1], $conf['cache']);
} }
else { else {
if ($argc != 1) { if ($argc != 1) {
echo "Usage: $argv[0]\n"; echo "Usage: $argv[0]\n";
exit(1); exit(1);
} }
$file = $conf['cache']; $file = $conf['cache'];
} }
if (!file_exists($file)) { if (!file_exists($file)) {
echo "$file is not created\n"; echo "$file is not created\n";
exit(1); exit(1);
} }
$bdd = new bdd(); $bdd = new bdd();

View file

@ -8,35 +8,26 @@
* $Id: config.php 273 2009-05-12 13:54:50Z tmartin $ * $Id: config.php 273 2009-05-12 13:54:50Z tmartin $
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2 * vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
* *
* @author Gregory Colpart <reg@evolix.fr> * @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr> * @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr> * @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0 * @version 1.0
*/ */
// Email pour les notifications
$oriconf['admin']['mail'] = 'admin@example.com'; $oriconf['admin']['mail'] = 'admin@example.com';
$oriconf['techmail'] = 'jdoe@example.com'; $oriconf['techmail'] = 'jdoe@example.com';
$oriconf['debug'] = false; $oriconf['debug'] = FALSE;
$oriconf['superadmin'] = array('superadmin'); $oriconf['superadmin'] = array('superadmin');
$oriconf['script_path'] = '/usr/share/scripts/evoadmin'; $oriconf['script_path'] = '/usr/share/scripts/evoadmin';
$oriconf['cluster'] = false; $oriconf['cluster'] = FALSE;
$oriconf['servers'] = array('servers'); $oriconf['servers'] = array('servers');
$oriconf['cache'] = '/home/evoadmin/www/cache.sqlite'; $oriconf['cache'] = '/home/evoadmin/www/cache.sqlite';
$oriconf['known_host'] = '/home/evoadmin/www/known_host'; $localconf['known_host'] = '/home/evoadmin/www/known_host';
$oriconf['ftpadmin'] = false; $oriconf['ftpadmin'] = TRUE;
$oriconf['bindadmin'] = false;
// Warning: Don't forget to add available PHP versions into : /etc/evolinux/web-add.conf
// $oriconf['php_versions'] = array();
$oriconf['quota'] = false;
$oriconf['dbadmin'] = false;
$oriconf['noreplication'] = array('srv00.example.com', 'srv01.example.com', 'srv02.example.com'); $oriconf['noreplication'] = array('srv00.example.com', 'srv01.example.com', 'srv02.example.com');
$oriconf['postponedreplication'] = array('srv00.example.com', 'srv01.example.com', 'srv02.example.com'); $oriconf['postponedreplication'] = array('srv00.example.com', 'srv01.example.com', 'srv02.example.com');
$oriconf['immediatereplication'] = array('srv00.example.com', 'srv01.example.com'); $oriconf['immediatereplication'] = array('srv00.example.com', 'srv01.example.com');
$oriconf['postponedreplication_mode'] = array('1 fois/jour', '3 fois/jour', '1 fois/jour'); $oriconf['postponedreplication_mode'] = array('1 fois/jour', '3 fois/jour', '1 fois/jour');
// Generate password hashes : mkpasswd --method=sha-512 (cli) or with PHP's password_hash()
$oriconf['logins'] = array();
//$oriconf['logins']['foo'] = '$6$X0jqa/ausLSBkj4m$dLMMcPGVxak.aDPo4V/GJLm2d8vU8/QA5LbGTuqXCdxSNYU0kRKBgDl16GAyp0GqXXZ5wwDEJKQ1npgFwiuV81';
//$oriconf['logins']['bar'] = '$6$Q6233S6mlWAF6p.j$LtzwG02YucozwqjAgSpeldh24Mnz7lBuVSbOQYbKKh9FiUx3tMVl6kJZkmrNdPqeadFXKAYXrqn.gy8KposF5.';

View file

@ -187,9 +187,8 @@ class FormPage {
} }
} }
public function addField($name, $obj, $default_value="") { public function addField($name, $obj) {
$obj->setName($name); $obj->setName($name);
if ($default_value != "") $obj->setValue($default_value);
array_push($this->fields, array($name, $obj)); array_push($this->fields, array($name, $obj));
} }
@ -404,161 +403,7 @@ class TextInputFormField extends FormField {
$out = ''; $out = '';
$out .= "<p>\n"; $out .= "<p>\n";
$out .= $this->getLabelHTML(); $out .= $this->getLabelHTML();
$out .= $this->getInputHTML(); $out .= $this->getInputHTML();
$out .= $this->getErrorHTML();
$out .= "</p>\n\n";
return $out;
}
}
class AlphaNumericalTextInputFormField extends FormField {
protected $mandatory = NULL;
protected $textsize = NULL;
public function __construct($label, $mandatory=TRUE, $textsize=array(20, 80)) {
parent::__construct($label);
$this->mandatory = $mandatory;
$this->textsize = $textsize;
}
public function verify($set_error) {
if($this->mandatory && (!strlen($this->value))) {
if($set_error) $this->error = 'Champ obligatoire';
return FALSE;
}
if (!preg_match("/^(?!-)(?!_)[[a-zA-Z0-9-_]*(?<!-)(?<!_)$/i", $this->value)) {
if($set_error) $this->error = 'Seul les caractères a-z A-Z 0-9 sont autorisés (- et _ le sont excepté en début et fin)';
return FALSE;
}
return TRUE;
}
public function getInputHTML() {
$input = '';
$input .= '<input type="text" id="'.$this->name.'"';
$input .= ' name="'.$this->name.'" value="'.htmlspecialchars($this->value,ENT_QUOTES).'"';
#$input .= sprintf(' name="%s" value="%s"', $this->name, htmlspecialchars($this->value, ENT_QUOTES));
$input .= ' maxlength="'.$this->textsize[1].'" size="'.$this->textsize[0].'" ';
if($this->read_only) { $input .= 'readonly="readonly="'; }
if($this->disabled) { $input .= 'disabled="disabled="'; }
$input .= '/>';
return $input;
}
public function __toString() {
$out = '';
$out .= "<p>\n";
$out .= $this->getLabelHTML();
$out .= $this->getInputHTML();
$out .= $this->getErrorHTML();
$out .= "</p>\n\n";
return $out;
}
}
class DomainInputFormField extends FormField {
protected $mandatory = NULL;
//protected $textsize = NULL;
public function __construct($label, $mandatory=TRUE, $hidden=FALSE) {
parent::__construct($label);
$this->mandatory = $mandatory;
$this->hidden = $hidden;
//$this->textsize = $textsize;
}
public function verify($set_error) {
if($this->mandatory && (!strlen($this->value))) {
if($set_error) $this->error = 'Champ obligatoire';
return FALSE;
}
if (!preg_match("/^[a-z0-9-.]+\.[a-z0-9-]{2,}$/i", $this->value)) {
if($set_error) $this->error = 'Ceci n\'est pas un nom de domaine';
return FALSE;
}
return TRUE;
}
public function getInputHTML() {
$input = '';
if ($this->hidden)
$input .= '<input type="hidden" id="'.$this->name.'"';
else
$input .= '<input type="text" id="'.$this->name.'"';
$input .= ' name="'.$this->name.'" value="'.htmlspecialchars($this->value,ENT_QUOTES).'"';
//$input .= ' maxlength="'.$this->textsize[1].'" size="'.$this->textsize[0].'" ';
if($this->read_only) { $input .= 'readonly="readonly="'; }
if($this->disabled) { $input .= 'disabled="disabled="'; }
$input .= '/>';
return $input;
}
public function __toString() {
$out = '';
$out .= "<p>\n";
if ($this->hidden) {
$out .= $this->getInputHTML();
} else {
$out .= $this->getLabelHTML();
$out .= $this->getInputHTML();
$out .= $this->getErrorHTML();
}
$out .= "</p>\n\n";
return $out;
}
}
class DomainListInputFormField extends FormField {
protected $mandatory = NULL;
//protected $textsize = NULL;
public function __construct($label, $mandatory=TRUE) {
parent::__construct($label);
$this->mandatory = $mandatory;
//$this->textsize = $textsize;
}
public function verify($set_error) {
if($this->mandatory && (!strlen($this->value))) {
if($set_error) $this->error = 'Champ obligatoire';
return FALSE;
}
if(strlen($this->value)){
$list = explode(',', $this->value);
foreach ($list as $value) {
if (!preg_match("/^[a-z0-9-.]+\.[a-z0-9-]{2,}$/i", $value)) {
if($set_error) $this->error = 'Ceci n\'est pas un nom de domaine';
return FALSE;
}
}
}
return TRUE;
}
public function getInputHTML() {
$input = '';
$input .= '<input type="text" id="'.$this->name.'"';
$input .= ' name="'.$this->name.'" value="'.htmlspecialchars($this->value,ENT_QUOTES).'"';
//$input .= ' maxlength="'.$this->textsize[1].'" size="'.$this->textsize[0].'" ';
if($this->read_only) { $input .= 'readonly="readonly="'; }
if($this->disabled) { $input .= 'disabled="disabled="'; }
$input .= '/>';
return $input;
}
public function __toString() {
$out = '';
$out .= "<p>\n";
$out .= $this->getLabelHTML();
$out .= $this->getInputHTML();
$out .= $this->getErrorHTML(); $out .= $this->getErrorHTML();
$out .= "</p>\n\n"; $out .= "</p>\n\n";
return $out; return $out;
@ -720,11 +565,6 @@ class PasswordInputFormField extends FormField {
return FALSE; return FALSE;
} }
if(!preg_match('#.*[/]+.*#',$this->value)==0){
if($set_error) $this->error = 'Votre mot de passe doit contenir le caractère \'/\'';
return FALSE;
}
return TRUE; return TRUE;
} }
@ -884,7 +724,7 @@ class SelectFormField extends FormField {
} }
public function verify($set_error) { public function verify($set_error) {
if($this->mandatory && strlen($this->value) === 0) { if($this->mandatory && empty($this->value)) {
if($set_error) $this->error = 'Champ obligatoire'; if($set_error) $this->error = 'Champ obligatoire';
return FALSE; return FALSE;
} }
@ -899,7 +739,7 @@ class SelectFormField extends FormField {
$input .= ' <option value="">-- Choisissez --</option>'."\n"; $input .= ' <option value="">-- Choisissez --</option>'."\n";
foreach ($this->list as $value => $label) { foreach ($this->list as $value => $label) {
$input .= ' <option value="'.htmlspecialchars($value,ENT_QUOTES).'"'; $input .= ' <option value="'.htmlspecialchars($value,ENT_QUOTES).'"';
if ($this->value == $value && strlen($this->value) !== 0) $input.=' selected="selected"'; if ($this->value == $value) $input.=' selected="selected"';
$input .= '>'.$label.'</option>'."\n"; $input .= '>'.$label.'</option>'."\n";
} }
$input .= "</select>\n"; $input .= "</select>\n";

View file

@ -1,4 +1,5 @@
<?php <?php
/** /**
* file included in every PHP file * file included in every PHP file
* *
@ -26,7 +27,7 @@ function test_exist($file) {
} }
function http_redirect($path) { function http_redirect($path) {
header('Location: '.$_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].$path); header('Location: http://'.$_SERVER['HTTP_HOST'].$path);
exit(0); exit(0);
} }
@ -86,35 +87,6 @@ function load_config_cluster($cluster) {
$conf = array_merge($conf, $clusterconf); $conf = array_merge($conf, $clusterconf);
} }
/**
* Return wether or not this evoadmin install is a multi PHP install
*
* @return boolean - True when it's a multi PHP system
*/
function is_multiphp() {
global $conf;
return array_key_exists('php_versions', $conf) && count($conf['php_versions']) > 1;
}
/**
* Webadd
*
* @return boolean - True when it's a multi PHP system
*/
function run_webadd_cmd($command) {
global $conf;
$cmd = 'web-add.sh '. $command;
$data_output = null;
$exec_return = null;
sudoexec($cmd, $data_output, $exec_return);
return $data_output;
}
/** /**
* Includes * Includes
*/ */
@ -135,5 +107,7 @@ if (!(ini_set('include_path', ini_get('include_path')))) {
require_once('../conf/config.php'); require_once('../conf/config.php');
test_exist('../conf/config.local.php'); test_exist('../conf/config.local.php');
require_once('../conf/config.local.php'); require_once('../conf/config.local.php');
# il faut un acces en lecture au fichier shadow pour pam_auth()
test_exist('/etc/shadow');
$conf = array_merge($oriconf, $localconf); $conf = array_merge($oriconf, $localconf);
} }

View file

@ -30,10 +30,6 @@ h1#top {
margin-bottom: 10px; margin-bottom: 10px;
} }
h3.form-error {
color: red;
}
div#disclaimer { div#disclaimer {
margin-top: 30px; margin-top: 30px;
} }
@ -139,11 +135,6 @@ span.form-error {
margin-left: 4px; margin-left: 4px;
} }
span.form-warning {
color: #E84D0C;
margin-left: 4px;
}
span.form-mandatory { span.form-mandatory {
color: red; color: red;
} }
@ -172,3 +163,4 @@ form#form-add legend {
form#form-add p { form#form-add p {
text-align: left; text-align: left;
} }

View file

@ -2,18 +2,18 @@
// vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2 // vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
function fill_directory_field(value) { function fill_directory_field(value) {
if(document.forms['addftp'].path.value == '') { if(document.forms['addftp'].path.value == '') {
document.forms['addftp'].path.value = value; document.forms['addftp'].path.value = value;
} }
} }
function check_form_ftp_add() { function check_form_ftp_add() {
field_passwd = document.getElementById('passwd').value; field_passwd = document.getElementById('passwd').value;
if(field_passwd.length < 6) { if(field_passwd.length < 6) {
alert('Le mot de passe doit contenir au moins 6 caractères '); alert('Le mot de passe doit contenir au moins 6 caractères ');
return false; return false;
} }
return true; return true;
} }
document.observe("dom:loaded", function() { document.observe("dom:loaded", function() {

View file

@ -21,12 +21,6 @@ function switch_disabled(name) {
} }
document.observe("dom:loaded", function() { document.observe("dom:loaded", function() {
if (document.getElementById('vhost-delete-db') != null) {
document.getElementById('vhost-delete-db').onclick = function() {
console.log("clicked box");
switch_disabled('vhost-dbname');
}
}
document.getElementById('password_random').onclick = function() { document.getElementById('password_random').onclick = function() {
switch_disabled('password'); switch_disabled('password');
} }

View file

@ -4,7 +4,7 @@
* common DirectoryIndex page * common DirectoryIndex page
* *
* Copyright (c) 2009 Evolix - Tous droits reserves * Copyright (c) 2009 Evolix - Tous droits reserves
* *
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2 * vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
* *
* @author Gregory Colpart <reg@evolix.fr> * @author Gregory Colpart <reg@evolix.fr>
@ -21,16 +21,16 @@ define('EVOADMIN_BASE','./');
/** /**
* PHP cookies session * PHP cookies session
*/ */
session_name('EVOADMINWEB_SESS'); session_name('EVOPMI_SESS');
session_start(); session_start();
error_reporting(E_ALL); error_reporting(E_ALL | E_NOTICE);
header('Content-Type: text/html; charset=utf-8'); header('Content-Type: text/html; charset=utf-8');
/** /**
* Requires * Requires
*/ */
require_once EVOADMIN_BASE . '../inc/common.php'; require_once EVOADMIN_BASE . 'common.php';
$uri = $_SERVER['REQUEST_URI']; $uri = $_SERVER['REQUEST_URI'];
@ -48,47 +48,14 @@ if (!array_key_exists('auth', $_SESSION) || $_SESSION['auth']!=1) {
include_once EVOADMIN_BASE . '../inc/webadmin.php'; include_once EVOADMIN_BASE . '../inc/webadmin.php';
} elseif (preg_match('#^/webadmin?#', $uri)) { } elseif (preg_match('#^/webadmin/edit/(.*)/?$#', $uri, $params)) {
// Redirect to /webadmin in order to set $_SESSION['non_stanard'] include_once EVOADMIN_BASE . '../inc/webadmin-edit.php';
if (!isset($_SESSION['non_standard']))
http_redirect('/webadmin');
// block the non-standard vhost modification } elseif (preg_match('#^/webadmin/suppr/(.*)/?$#', $uri, $params)) {
if (in_array(htmlspecialchars(basename($_SERVER['REDIRECT_URL'])), $_SESSION['non_standard']))
http_redirect('/webadmin');
if (preg_match('#^/webadmin/(.*)/domain/?(edit)?/?(.*)?/$#', $uri, $params)) { include_once EVOADMIN_BASE . '../inc/webadmin-suppr.php';
include_once EVOADMIN_BASE . '../inc/webadmin-servername.php';
} elseif (preg_match('#^/webadmin/(.*)/itk/?(enable|disable)?/?(.*)?/$#', $uri, $params)) {
include_once EVOADMIN_BASE . '../inc/webadmin-itk.php';
} elseif (preg_match('#^/webadmin/(.*)/php/$#', $uri, $params)) {
include_once EVOADMIN_BASE . '../inc/webadmin-php.php';
} elseif (preg_match('#^/webadmin/(.*)/alias/?(add|delete)?/?(.*)?/$#', $uri, $params)) {
include_once EVOADMIN_BASE . '../inc/webadmin-edit.php';
} elseif (preg_match('#^/webadmin/delete/(.*)/?$#', $uri, $params)) {
//TODO: fix according to route naming convention
include_once EVOADMIN_BASE . '../inc/webadmin-delete.php';
} elseif (preg_match('#^/webadmin/suppr/(.*)/?$#', $uri, $params)) {
include_once EVOADMIN_BASE . '../inc/webadmin-suppr.php';
} elseif (preg_match('#^/webadmin/(.*)/letsencrypt/?$#', $uri, $params)) {
include_once EVOADMIN_BASE . '../inc/webadmin-letsencrypt.php';
} else {
http_redirect('/webadmin');
}
} elseif (is_superadmin() && preg_match('#^/accounts/?#', $uri, $params)) { } elseif (is_superadmin() && preg_match('#^/accounts/?#', $uri, $params)) {
include_once EVOADMIN_BASE . '../inc/accounts.php'; include_once EVOADMIN_BASE . '../inc/accounts.php';
@ -101,10 +68,7 @@ if (!array_key_exists('auth', $_SESSION) || $_SESSION['auth']!=1) {
include_once EVOADMIN_BASE . '../inc/destroy.php'; include_once EVOADMIN_BASE . '../inc/destroy.php';
} elseif (preg_match('#^/dbadmin/?$#', $uri, $params)) {
include_once EVOADMIN_BASE . '../inc/dbadmin.php';
} else { } else {
die ("Cette page n'existe pas !!!"); die ("Cette page n'existe pas !!!");
} }

View file

@ -32,38 +32,29 @@ else {
} }
function web_add($form, $admin_mail) { function web_add($form, $admin_mail) {
global $conf;
$exec_cmd = 'web-add.sh add -y'; $exec_cmd = 'web-add.sh add -y';
if(!$form->getField('password_random')->getValue()) { if(!$form->getField('password_random')->getValue()) {
$exec_cmd .= sprintf(' -p %s', $exec_cmd .= sprintf(' -p %s',
escapeshellarg($form->getField('password')->getValue())); $form->getField('password')->getValue());
} }
/* Ajout des options spécifiques à MySQL si nécessaire */ /* Ajout des options spécifiques à MySQL si nécessaire */
if($form->getField('mysql_db')->getValue()) { if($form->getField('mysql_db')->getValue()) {
$exec_cmd .= sprintf(' -m %s', $exec_cmd .= sprintf(' -m %s',
escapeshellarg($form->getField('mysql_dbname')->getValue())); $form->getField('mysql_dbname')->getValue());
if(!$form->getField('mysql_password_random')->getValue()) { if(!$form->getField('mysql_password_random')->getValue()) {
$exec_cmd .= sprintf(' -P %s', $exec_cmd .= sprintf(' -P %s',
escapeshellarg($form->getField('mysql_password')->getValue())); $form->getField('mysql_password')->getValue());
} }
} }
if (array_key_exists('php_versions', $conf) && is_array($conf['php_versions'])) {
$exec_cmd .= sprintf(' -r %s', $conf['php_versions'][$form->getField('php_version')->getValue()]);
}
if ($conf['quota']) {
$exec_cmd .= sprintf(' -q %s:%s', escapeshellarg($form->getField('quota_soft')->getValue()), escapeshellarg($form->getField('quota_hard')->getValue()));
}
$exec_cmd .= sprintf(' -l %s %s %s 2>&1', $admin_mail, $exec_cmd .= sprintf(' -l %s %s %s 2>&1', $admin_mail,
escapeshellarg($form->getField('username')->getValue()), $form->getField('username')->getValue(),
escapeshellarg($form->getField('domain')->getValue())); $form->getField('domain')->getValue());
//domain_add($form, $_SERVER['SERVER_ADDR'], true); //domain_add($form, $_SERVER['SERVER_ADDR'], true);
sudoexec($exec_cmd, $exec_output, $exec_return); sudoexec($exec_cmd, $exec_output, $exec_return);
@ -72,10 +63,11 @@ function web_add($form, $admin_mail) {
if ( $form->getField('domain_alias')->getValue() ) { if ( $form->getField('domain_alias')->getValue() ) {
$domain_alias = preg_split('/,/', $form->getField('domain_alias')->getValue()); $domain_alias = preg_split('/,/', $form->getField('domain_alias')->getValue());
foreach ( $domain_alias as $domain ) { foreach ( $domain_alias as $domain ) {
$exec_cmd = 'web-add.sh add-alias '.escapeshellarg($form->getField('username')->getValue()).' '; $exec_cmd = 'web-add.sh add-alias '.$form->getField('domain')->getValue().' ';
$domain = trim($domain); $domain = trim($domain);
$exec_cmd .= $domain.' '. $server_list; $exec_cmd .= $domain.' '.$master.' '.$slave;
sudoexec($exec_cmd, $exec_output, $exec_return); sudoexec($exec_cmd, $exec_output, $exec_return);
//domain_add($form, gethostbyname($master), false);
} }
$exec_return |= $exec_return2; // $exec_return == 0 if $exec_return == 0 && $exec_return2 == 0 $exec_return |= $exec_return2; // $exec_return == 0 if $exec_return == 0 && $exec_return2 == 0
array_push($exec_output, $exec_output2); array_push($exec_output, $exec_output2);
@ -91,23 +83,23 @@ function web_add_cluster($form, $admin_mail) {
$exec_cmd = 'web-add-cluster.sh add'; $exec_cmd = 'web-add-cluster.sh add';
$realtime=0; $realtime=0;
/* array account with infos for sqlite cache */ /* array account with infos for sqlite cache */
$account = array(); $account = array();
if(!$form->getField('password_random')->getValue()) { if(!$form->getField('password_random')->getValue()) {
$exec_cmd .= sprintf(' -p %s', $exec_cmd .= sprintf(' -p %s',
escapeshellarg($form->getField('password')->getValue())); $form->getField('password')->getValue());
} }
/* Ajout des options spécifiques à MySQL si nécessaire */ /* Ajout des options spécifiques à MySQL si nécessaire */
if($form->getField('mysql_db')->getValue()) { if($form->getField('mysql_db')->getValue()) {
$exec_cmd .= sprintf(' -m %s', $exec_cmd .= sprintf(' -m %s',
escapeshellarg($form->getField('mysql_dbname')->getValue())); $form->getField('mysql_dbname')->getValue());
if(!$form->getField('mysql_password_random')->getValue()) { if(!$form->getField('mysql_password_random')->getValue()) {
$exec_cmd .= sprintf(' -P %s', $exec_cmd .= sprintf(' -P %s',
escapeshellarg($form->getField('mysql_password')->getValue())); $form->getField('mysql_password')->getValue());
} }
$account['bdd'] = $form->getField('mysql_dbname')->getValue(); $account['bdd'] = $form->getField('mysql_dbname')->getValue();
@ -173,15 +165,14 @@ function web_add_cluster($form, $admin_mail) {
break; break;
} }
$exec_cmd .= sprintf(' -l %s %s %s %s %s %s 2>&1', $exec_cmd .= sprintf(' -l %s %s %s %s %s %s 2>&1',
escapeshellarg($admin_mail), $admin_mail,
escapeshellarg($form->getField('username')->getValue()), $form->getField('username')->getValue(),
escapeshellarg($form->getField('domain')->getValue()), $form->getField('domain')->getValue(),
escapeshellarg($master), $master,
escapeshellarg($slave), $slave,
escapeshellarg( ($realtime ? 'realtime': 'deferred')) ); ($realtime ? 'realtime': 'deferred'));
//if ($conf['bindadmin'])
domain_add($form->getField('domain')->getValue(), gethostbyname($master), true, $form->getField('use_gmail_mxs')->getValue()); domain_add($form->getField('domain')->getValue(), gethostbyname($master), true, $form->getField('use_gmail_mxs')->getValue());
sudoexec($exec_cmd, $exec_output, $exec_return); sudoexec($exec_cmd, $exec_output, $exec_return);
@ -189,7 +180,7 @@ function web_add_cluster($form, $admin_mail) {
if ( $form->getField('domain_alias')->getValue() ) { if ( $form->getField('domain_alias')->getValue() ) {
$domain_alias = preg_split('/,/', $form->getField('domain_alias')->getValue()); $domain_alias = preg_split('/,/', $form->getField('domain_alias')->getValue());
foreach ( $domain_alias as $alias ) { foreach ( $domain_alias as $alias ) {
$exec_cmd = 'web-add-cluster.sh add-alias '.escapeshellarg($form->getField('username')->getValue()).' '; $exec_cmd = 'web-add-cluster.sh add-alias '.$form->getField('username')->getValue().' ';
$alias = trim($alias); $alias = trim($alias);
$exec_cmd .= $alias.' '.$master.' '.$slave; $exec_cmd .= $alias.' '.$master.' '.$slave;
sudoexec($exec_cmd, $exec_output2, $exec_return2); sudoexec($exec_cmd, $exec_output2, $exec_return2);
@ -203,22 +194,21 @@ function web_add_cluster($form, $admin_mail) {
/* insertion des infos dans le cache sqlite */ /* insertion des infos dans le cache sqlite */
if ($exec_return == 0) { if ($exec_return == 0) {
$bdd=new bdd(); $bdd=new bdd();
$bdd->open($cache); $bdd->open($cache);
$account['name'] = $form->getField('username')->getValue(); $account['name'] = $form->getField('username')->getValue();
$account['domain'] = $form->getField('domain')->getValue(); $account['domain'] = $form->getField('domain')->getValue();
//if ($conf['bindadmin'])
if ($form->getField('use_gmail_mxs')->getValue()) if ($form->getField('use_gmail_mxs')->getValue())
$account['mail'] = 'gmail'; $account['mail'] = 'gmail';
else else
$account['mail'] = 'evolix'; $account['mail'] = 'evolix';
$bdd->add_account($account); $bdd->add_account($account);
$bdd->add_role($account['name'], $master, 'master'); $bdd->add_role($account['name'], $master, 'master');
if ($slave != "null"); if ($slave != "null");
$bdd->add_role($account['name'], $slave, 'slave'); $bdd->add_role($account['name'], $slave, 'slave');
if (substr_compare($account['domain'], 'www.', 0, strlen('www.')) == 0) { if (substr_compare($account['domain'], 'www.', 0, strlen('www.')) == 0) {
$wwwalias = ltrim($account['domain'], 'www.'); $wwwalias = ltrim($account['domain'], 'www.');
@ -250,10 +240,10 @@ function web_add_cluster($form, $admin_mail) {
/* Construction du formulaire d'ajout */ /* Construction du formulaire d'ajout */
$form = new FormPage("Ajout d'un compte web", FALSE); $form = new FormPage("Ajout d'un compte web", FALSE);
$form->addField('username', new AlphaNumericalTextInputFormField("Nom d'utilisateur", TRUE, array(20,16))); $form->addField('username', new TextInputFormField("Nom d'utilisateur", TRUE, array(20,16)));
$form->addField('domain', new DomainInputFormField("Nom de domaine", TRUE)); $form->addField('domain', new TextInputFormField("Nom de domaine", TRUE));
$form->addField('domain_alias', new DomainListInputFormField("Alias (séparés par une virgule, sans espaces)", FALSE)); $form->addField('domain_alias', new TextInputFormField("Alias (séparés par une virgule)", FALSE));
$form->addField('password_random', $form->addField('password_random',
new CheckboxInputFormField("Mot de passe aléatoire ?", FALSE)); new CheckboxInputFormField("Mot de passe aléatoire ?", FALSE));
$form->getField('password_random')->setValue(TRUE); $form->getField('password_random')->setValue(TRUE);
$form->addField('password', new PasswordInputFormField('Mot de passe', FALSE)); $form->addField('password', new PasswordInputFormField('Mot de passe', FALSE));
@ -263,13 +253,13 @@ $form->addField('mysql_db',
FALSE)); FALSE));
$form->getField('mysql_db')->setValue(TRUE); $form->getField('mysql_db')->setValue(TRUE);
$form->addField('mysql_dbname', $form->addField('mysql_dbname',
new AlphaNumericalTextInputFormField("Nom de la base MySQL", FALSE, array(20,16))); new TextInputFormField("Nom de la base MySQL", FALSE, array(20,16)));
//$form->getField('mysql_dbname')->setDisabled();
$form->addField('mysql_password_random', $form->addField('mysql_password_random',
new CheckboxInputFormField("Mot de passe MySQL aléatoire ?", new CheckboxInputFormField("Mot de passe MySQL aléatoire ?",
FALSE)); FALSE));
$form->getField('mysql_password_random')->setValue(TRUE); $form->getField('mysql_password_random')->setValue(TRUE);
//$form->getField('mysql_password_random')->setDisabled();
$form->addField('mysql_password', $form->addField('mysql_password',
new PasswordInputFormField('Mot de passe MySQL', FALSE)); new PasswordInputFormField('Mot de passe MySQL', FALSE));
$form->getField('mysql_password')->setDisabled(); $form->getField('mysql_password')->setDisabled();
@ -342,68 +332,42 @@ if ($conf['cluster']) {
$form->addField('cluster_mode', new SelectFormField('Mode de réplication', FALSE, $choices)); $form->addField('cluster_mode', new SelectFormField('Mode de réplication', FALSE, $choices));
} }
if ($conf['bindadmin']) { /* Quai13 specific: allow to switch between Gmail MX/Quai13 MX */
/* Quai13 specific: allow to switch between Gmail MX/Quai13 MX */ $form->addField('use_gmail_mxs', new CheckboxInputFormField("Utilisation des serveurs Gmail en MX&nbsp;?", FALSE));
$form->addField('use_gmail_mxs', new CheckboxInputFormField("Utilisation des serveurs Gmail en MX&nbsp;?", FALSE));
}
if (array_key_exists('php_versions', $conf) && is_array($conf['php_versions'])) {
$form->addField('php_version', new SelectFormField("Version de PHP", TRUE, $conf['php_versions']));
}
if ($conf['quota']) {
$field_quota_soft = new TextInputFormField("Quota soft (GiB, entier)", TRUE);
$field_quota_soft->setValue('1');
$form->addField('quota_soft', $field_quota_soft);
$field_quota_hard = new TextInputFormField("Quota hard (GiB, entier)", TRUE);
$field_quota_hard->setValue('2');
$form->addField('quota_hard', $field_quota_hard);
}
/* Traitement du formulaire */ /* Traitement du formulaire */
if(!empty($_POST)) { if(!empty($_POST)) {
$form->isCurrentPage(TRUE); $form->isCurrentPage(TRUE);
$form->initFields(); $form->initFields();
/* Le champ password devient obligatoire si le champ password_random est /* Le champ password devient obligatoire si le champ password_random est
* décoché */ * décoché */
if(!$form->getField('password_random')->getValue()) { if(!$form->getField('password_random')->getValue()) {
$form->getField('password')->setMandatory(TRUE); $form->getField('password')->setMandatory(TRUE);
$form->getField('password')->setDisabled(FALSE); $form->getField('password')->setDisabled(FALSE);
} }
/* Erreur si mysql_db est coché */ /* Erreur si mysql_db est coché */
if($form->getField('mysql_db')->getValue()) { if($form->getField('mysql_db')->getValue()) {
$form->getField('mysql_dbname')->setMandatory(TRUE); $form->getField('mysql_dbname')->setMandatory(TRUE);
$form->getField('mysql_dbname')->setDisabled(FALSE); $form->getField('mysql_dbname')->setDisabled(FALSE);
$form->getField('mysql_password_random')->setDisabled(FALSE); $form->getField('mysql_password_random')->setDisabled(FALSE);
/* Le champ mysql_passwd devient obligatoire si le champ /* Le champ mysql_passwd devient obligatoire si le champ
* mysql_password_random est coché */ * mysql_password_random est coché */
if(!$form->getField('mysql_password_random')->getValue()) { if(!$form->getField('mysql_password_random')->getValue()) {
$form->getField('mysql_password')->setMandatory(TRUE); $form->getField('mysql_password')->setMandatory(TRUE);
$form->getField('mysql_password')->setDisabled(FALSE); $form->getField('mysql_password')->setDisabled(FALSE);
} }
} }
/* Test de validation du formulaire */ /* Test de validation du formulaire */
if($form->verify(TRUE)) { if($form->verify(TRUE)) {
$errors_check = array(); if ($conf['cluster'])
$exec_info = web_add_cluster($form, $conf['admin']['mail']);
if(check_occurence_name($form->getField('domain')->getValue())){ else
array_push($errors_check, "Domaine déjà présent dans d'autres vhosts."); $exec_info = web_add($form, $conf['admin']['mail']);
} }
if(check_occurence_name($form->getField('domain_alias')->getValue())){
array_push($errors_check, "Alias déjà présent(s) dans d'autres vhosts.");
}
if (count($errors_check) === 0) {
if ($conf['cluster'])
$exec_info = web_add_cluster($form, $conf['admin']['mail']);
else
$exec_info = web_add($form, $conf['admin']['mail']);
}
}
} }
include_once EVOADMIN_BASE . '../tpl/header.tpl.php'; include_once EVOADMIN_BASE . '../tpl/header.tpl.php';

View file

@ -1,53 +1,57 @@
<?php <?php
/** /**
* Authentification controler * Authentification page
* *
* Copyright (c) 2009-2022 Evolix - Tous droits reserves * Copyright (c) 2009 Evolix - Tous droits reserves
* *
* @author Evolix <info@evolix.fr> * vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
* @author Gregory Colpart <reg@evolix.fr> *
* @author Thomas Martin <tmartin@evolix.fr> * @author Gregory Colpart <reg@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr> * @author Thomas Martin <tmartin@evolix.fr>
* @author and others. * @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0 * @version 1.0
*/ */
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST)) {
$input_username = $_POST['login'];
$input_password = $_POST['passw'];
if (isset($conf['logins'][$input_username]) && strlen($conf['logins'][$input_username]) != 64 && password_verify($input_password, $conf['logins'][$input_username]) ) {
$_SESSION['auth'] = true;
$_SESSION['user'] = $input_username;
$_SESSION['user_id'] = posix_getpwnam($input_username) ? posix_getpwnam($input_username)['uid'] : 65534;
$_SESSION['cli_version'] = run_webadd_cmd('version')[0];
unset($_SESSION['error']);
} elseif (isset($conf['logins'][$input_username]) && strlen($conf['logins'][$input_username]) == 64 && hash("sha256",$input_password) === $conf['logins'][$input_username]) { if ((empty($_GET['form']) || $_GET['form']!=1) && !empty($_POST)) {
// Compatibility mode for previous installs (sha256) $login=0;
$_SESSION['auth'] = true; $username=$_POST['login'];
$_SESSION['user'] = $input_username; $password=$_POST['passw'];
$_SESSION['user_id'] = posix_getpwnam($input_username) ? posix_getpwnam($input_username)['uid'] : 65534;
$_SESSION['cli_version'] = run_webadd_cmd('version')[0];
unset($_SESSION['error']);
} else {
$_SESSION['auth'] = false;
$_SESSION['user'] = '';
$_SESSION['error'] = true;
}
http_redirect('/'); $login = pam_auth($username, $password);
if ($login==1) {
$_SESSION['auth']=1;
$_SESSION['user']=$username;
$_SESSION['error']='';
$user = posix_getpwnam($username);
// On nettoie le nom complet
$gecos = explode(',',$user['gecos']);
$user['gecos'] = $gecos[0];
$_SESSION['user_id'] = $user['uid'];
$_SESSION['user_gid'] = $user['gid'];
$_SESSION['user_name'] = $user['gecos'];
} else {
$_SESSION['auth']=0;
$_SESSION['user']='';
$_SESSION['error']=1;
}
http_redirect('/');
} else { } else {
if (!empty($_SESSION['error'])) { if(!empty($_SESSION['error'])) {
$error = $_SESSION['error']; $error=$_SESSION['error'];
unset($_SESSION['error']); }
}
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/header.tpl.php'; include_once EVOADMIN_BASE . '../tpl/auth.tpl.php';
include_once EVOADMIN_BASE . '../tpl/auth.tpl.php'; include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
} }
?>

View file

@ -1,45 +0,0 @@
<?php
/**
* Databases Management Page
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0
*/
global $conf;
if (!$conf['dbadmin'])
http_redirect('/');
$cmd = 'dbadmin.sh list';
if(!is_superadmin()) {
$cmd .= ' ' . $_SESSION['user'];
}
sudoexec($cmd, $data_output, $exec_return);
/*
* Put command output to db_list array.
*/
$db_list = array();
foreach ($data_output as $data_line) {
$data_split = explode(':', $data_line);
array_push($db_list, array(
'owner' => $data_split[0],
'database' => $data_split[1])
);
}
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
include_once EVOADMIN_BASE . '../tpl/dbadmin.tpl.php';
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
?>

View file

@ -155,7 +155,7 @@ if ($action=="add") {
} elseif ($action=="delete") { } elseif ($action=="delete") {
sudoexec("ftpadmin.sh -a d -n $account -f /dev/null -p azertyuiop", $standard_output, $function_output); sudoexec("ftpadmin.sh -a d -u $user_id -n $account -f /dev/null -p azertyuiop", $standard_output, $function_output);
$_SESSION['error'] = null; $_SESSION['error'] = null;
@ -200,13 +200,13 @@ if ($action=="add") {
$size_total += $infos[3]; $size_total += $infos[3];
$table[$num_line]['size'] = formatBytes($infos[3]); $table[$num_line]['size'] = formatBytes($infos[3]);
} else { } else {
$table[$num_line]['size'] = 0; $table[$num_line]['size'] = 0;
} }
if ($infos[4]>0) { if ($infos[4]>0) {
$table[$num_line]['date'] = date("d/m/Y h:i:s", $infos[4]); $table[$num_line]['date'] = date("d/m/Y h:i:s", $infos[4]);
} else { } else {
$table[$num_line]['date'] = "01/01/1970"; $table[$num_line]['date'] = "01/01/1970";
} }
$num_line++; $num_line++;
@ -256,7 +256,6 @@ function get_owner_list() {
foreach(array_keys($usernames) as $cur) { foreach(array_keys($usernames) as $cur) {
if(preg_match('/^www-/', $cur)) { continue; } if(preg_match('/^www-/', $cur)) { continue; }
if($cur == "evoadmin") { continue; }
if(empty($usernames["www-$cur"])) { continue; } if(empty($usernames["www-$cur"])) { continue; }
$owner_list[] = $cur; $owner_list[] = $cur;
} }

View file

@ -1,72 +0,0 @@
<?php
/**
* Apache VirtualHost Management Page
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0
*/
require_once EVOADMIN_BASE . '../lib/bdd.php';
require_once EVOADMIN_BASE . '../lib/domain.php';
global $conf;
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
if (isset($_POST['delete-vhost'])) {
$domain = $params[1];
while(true) {
// Errors handling
if (empty($_POST['vhost-name'])) {
print "<p>Veuillez entrer le nom du compte web à supprimer.</p>";
printf ('<p><a href="%s">Retour</a></p>', $_SERVER['REDIRECT_URL']);
break;
}
if ($_POST['vhost-name'] !== $domain) {
print "Le nom de compte ne correspond pas.";
printf ('<p><a href="%s">Retour</a></p>', $_SERVER['REDIRECT_URL']);
break;
}
if (isset($_POST['vhost-delete-db']) && empty($_POST['vhost-dbname'])) {
print "Veuillez spécifier un nom de base de données.";
printf ('<p><a href="%s">Retour</a></p>', $_SERVER['REDIRECT_URL']);
break;
}
// Shell arguments
if (!empty($_POST['vhost-dbname']))
$exec_cmd = "web-add.sh del -y " . $domain . " " . $_POST['vhost-dbname'];
else
$exec_cmd = "web-add.sh del -y " . $domain;
// Execute script
sudoexec($exec_cmd, $exec_output, $exec_return);
// Deal with response code
if ($exec_return == 0)
print "<p>Compte supprimé.</p>";
else
print "<p>La suppression a échouée. Veuillez contacter votre administrateur.</p>";
break;
}
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
} else {
include_once EVOADMIN_BASE . '../tpl/webadmin-delete.tpl.php';
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
}
?>

View file

@ -1,11 +1,11 @@
<?php <?php
/** /**
* Apache VirtualHost Management Page * Apache VirtualHost Management Page
* *
* Copyright (c) 2009 Evolix - Tous droits reserves * Copyright (c) 2009 Evolix - Tous droits reserves
* *
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2 * vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
* *
* @author Gregory Colpart <reg@evolix.fr> * @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr> * @author Thomas Martin <tmartin@evolix.fr>
@ -18,24 +18,21 @@ require_once EVOADMIN_BASE . '../lib/domain.php';
global $conf; global $conf;
$redirect_url = "/webadmin/" . $params[1] . "/alias/"; if (isset($_GET['del']) ) {
if (isset($params[2]) && $params[2] == "delete") {
if (isset($params[3]) && $params[3] == "") http_redirect($redirect_url);
include_once EVOADMIN_BASE . '../tpl/header.tpl.php'; include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php'; include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
$alias = $params[3]; $alias = htmlspecialchars($_GET['del']);
if (isset($_POST["confirm-delete-alias"])) { if (isset($_GET['modif']) && ($_GET['modif'] == 'yes')) {
print "<center>"; print "<center>";
print "<p>Suppression de $alias...</p>"; print "<p>Suppression de $alias...</p>";
$serveralias = array ( $serveralias = array (
'domain' => $params[1], 'domain' => htmlspecialchars(basename($_SERVER['REDIRECT_URL'])),
'alias' => $alias 'alias' => $alias
); );
@ -68,48 +65,37 @@ if (isset($params[2]) && $params[2] == "delete") {
sudoexec($exec_cmd, $exec_output, $exec_return); sudoexec($exec_cmd, $exec_output, $exec_return);
if ($exec_return == 0) { if ($exec_return == 0) {
if (! $bdd->del_serveralias($serveralias)) if (! $bdd->del_serveralias($serveralias))
print "<p>La suppression a échouée. Veuillez contacter votre administrateur.</p>"; print "<p>La suppression a échouée. Veuillez contacter votre administrateur.</p>";
printf ('<p>Alias %s est supprimé.</p>', $serveralias['alias']); printf ('<p>Alias %s est supprimé.</p>', $serveralias['alias']);
} else } else
print "<p>La suppression a échouée. Veuillez contacter votre administrateur.</p>"; print "<p>La suppression a échouée. Veuillez contacter votre administrateur.</p>";
} }
else { printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $_SERVER['REDIRECT_URL']);
$exec_cmd = 'web-add.sh del-alias ' . $serveralias['domain'] . ' ' . $serveralias['alias'];
sudoexec($exec_cmd, $exec_output, $exec_return);
if ($exec_return == 0) {
printf ('<p>Alias %s est supprimé.</p>', $serveralias['alias']);
} else
print "<p>La suppression a échouée. Veuillez contacter votre administrateur.</p>";
}
printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $redirect_url);
print "</center>"; print "</center>";
} else { } else if ( ! isset($_GET['modif']) ) {
print "<center>"; print "<center>";
print "<form name=\"form-confirm-delete-alias\" id=\"form-confirm-delete-alias\" action=\"\" method=\"POST\">";
print "<p>Confirmez vous la suppression de $alias ?</p>"; print "<p>Confirmez vous la suppression de $alias ?</p>";
print " <p><input type=\"hidden\" name=\"confirm-delete-alias\" value=\"confirm\">"; printf ('<p><a href="%s?del=%s&modif=yes">Confirmer la suppression</a></p>', $_SERVER['REDIRECT_URL'], $alias);
print " <p><input type=\"submit\" value=\"Confirmer la suppression\"/ style=\"margin-left:0px;\"></p>"; printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $_SERVER['REDIRECT_URL']);
print "</form>";
printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $redirect_url);
print "</center>"; print "</center>";
} }
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php'; include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
}
elseif (isset($params[2]) && $params[2] == "add") { } else if (isset($_GET['add']) ) {
require_once EVOADMIN_BASE . '../evolibs/Form.php'; require_once EVOADMIN_BASE . '../evolibs/Form.php';
include_once EVOADMIN_BASE . '../tpl/header.tpl.php'; include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php'; include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
$form = new FormPage("Ajout d'un alias", FALSE); $form = new FormPage("Ajout d'un alias", FALSE);
$form->addField('domain_alias', new DomainInputFormField("Alias", TRUE)); $form->addField('domain_alias', new TextInputFormField("Alias", FALSE));
if (!empty($_POST)) { if (!empty($_POST)) {
$form->isCurrentPage(TRUE); $form->isCurrentPage(TRUE);
@ -134,7 +120,7 @@ elseif (isset($params[2]) && $params[2] == "add") {
'domain' => htmlspecialchars(basename($_SERVER['REDIRECT_URL'])), 'domain' => htmlspecialchars(basename($_SERVER['REDIRECT_URL'])),
'alias' => $form->getField('domain_alias')->getValue(), 'alias' => $form->getField('domain_alias')->getValue(),
); );
$account_name=$serveralias['domain']; $account_name=$serveralias['domain'];
$account = $bdd->get_account($account_name); $account = $bdd->get_account($account_name);
@ -185,58 +171,12 @@ elseif (isset($params[2]) && $params[2] == "add") {
} }
} }
else {
$serveralias = array (
'domain' => $params[1],
'alias' => $form->getField('domain_alias')->getValue(),
);
$account_name=$serveralias['domain'];
$is_alias_present = check_occurence_name($serveralias['alias']);
if (!$is_alias_present) {
$exec_cmd = 'web-add.sh add-alias ' . $serveralias['domain'] . ' ' . $serveralias['alias'];
sudoexec($exec_cmd, $exec_output, $exec_return);
if ($exec_return == 0) {
//domain_add($serveralias['alias'], gethostbyname($master) , false); TODO avec l'IP du load balancer
print "<center>";
printf ('<p>L\'alias %s du domaine %s a bien été créé</p>', $serveralias['alias'], $serveralias['domain']);
printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $redirect_url);
print "</center>";
}
else {
print "<center>";
printf ('<p>Echec dans la creation de l\'alias %s du domaine %s</p>', $serveralias['alias'], $serveralias['domain']);
printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $redirect_url);
print "</center>";
}
}
else {
print "<center>";
printf ('<p>Echec dans la creation de l\'alias %s</p>', $serveralias['alias']);
print ('<p>L\'alias existe dans d\'autres vhosts.');
printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $redirect_url);
print "</center>";
}
}
}
else {
print "<h2>Ajout d'un alias</h2><hr>";
print "<form name=\"form-add\" id=\"form-add\" action=\"\" method=\"POST\">";
print " <fieldset>";
print " <legend>Ajout d'un alias</legend>";
print $form;
print " <p><input type=\"submit\" value=\"Créer\"/></p>";
print " </fieldset>";
print "</form>";
} }
} else { } else {
print "<h2>Ajout d'un alias</h2><hr>";
print "<form name=\"form-add\" id=\"form-add\" action=\"\" method=\"POST\">"; print "<form name=\"form-add\" id=\"form-add\" action=\"\" method=\"POST\">";
print " <fieldset>"; print " <fieldset>";
print " <legend>Ajout d'un alias</legend>"; print " <legend>Ajout d'un serveralias</legend>";
print $form; print $form;
print " <p><input type=\"submit\" value=\"Créer\"/></p>"; print " <p><input type=\"submit\" value=\"Créer\"/></p>";
print " </fieldset>"; print " </fieldset>";
@ -245,9 +185,9 @@ elseif (isset($params[2]) && $params[2] == "add") {
} }
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php'; include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
}
else {
} else {
$domain = $params[1]; $domain = $params[1];
$alias_list = array(); $alias_list = array();
@ -272,26 +212,6 @@ else {
$alias_list = $bdd->list_serveralias($domain); $alias_list = $bdd->list_serveralias($domain);
} }
else {
$cmd = 'web-add.sh list-vhost';
if(!is_superadmin()) {
$cmd = sprintf('%s %s', $cmd, $_SESSION['user']);
}
sudoexec($cmd, $data_output, $exec_return);
/* Récupération de cette liste dans le tableau $vhost_list */
$vhost_list = array();
foreach($data_output as $data_line) {
$data_split = explode(':', $data_line);
if ($data_split[0] == $domain && $data_split[3] != '') {
$alias_split = explode(',', $data_split[3]);
foreach($alias_split as $alias) {
$alias_array['alias'] = $alias;
array_push($alias_list, $alias_array);
}
}
}
}
include_once EVOADMIN_BASE . '../tpl/header.tpl.php'; include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php'; include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';

View file

@ -1,94 +0,0 @@
<?php
/**
* Apache VirtualHost Management Page
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0
*/
require_once EVOADMIN_BASE . '../lib/bdd.php';
require_once EVOADMIN_BASE . '../lib/domain.php';
global $conf;
if (isset($params[2]) && $params[2] != "") {
$redirect_url = "/webadmin/" . $params[1] . "/itk/";
require_once EVOADMIN_BASE . '../evolibs/Form.php';
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
$servername = array (
'domain' => $params[1],
);
if ($params[2] == "enable") {
$enable_cmd = 'web-add.sh enable-user-itk ' . $servername['domain'];
sudoexec($enable_cmd, $enable_cmd_output, $enable_cmd_return);
if ($enable_cmd_return == 0) {
print 'Sécurité ITK activée.';
printf ('<p><a href="%s">Retour à la gestion ITK</a></p>', $redirect_url);
}
}
elseif ($params[2] == "disable") {
$disable_cmd = 'web-add.sh disable-user-itk ' . $servername['domain'];
sudoexec($disable_cmd, $disable_cmd_output, $disable_cmd_return);
if ($disable_cmd_return == 0) {
print 'Sécurité ITK désactivée';
printf ('<p><a href="%s">Retour à la gestion ITK</a></p>', $redirect_url);
}
}
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
} else {
$domain = $params[1];
// TODO: adapt for cluster mode
if ($conf['cluster']) {
if (is_mcluster_mode()) {
// If the user has not yet selected a cluster, redirect-it to home page.
if (empty($_SESSION['cluster'])) {
http_redirect('/');
}
$cache = str_replace('%cluster_name%', $_SESSION['cluster'], $conf['cache']);
}
else {
$cache = $conf['cache'];
}
$alias_list = array();
/* parcours de la table Serveralias */
$bdd = new bdd();
$bdd->open($cache);
$alias_list = $bdd->list_serveralias($domain);
}
else {
$cmd_itk = 'web-add.sh list-user-itk ' . $domain;
sudoexec($cmd_itk, $data_output_itk, $exec_return_itk);
$user_itk = $data_output_itk[0];
}
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
include_once EVOADMIN_BASE . '../tpl/webadmin-itk.tpl.php';
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
}
?>

View file

@ -1,168 +0,0 @@
<?php
require_once EVOADMIN_BASE . '../lib/letsencrypt.php';
use lib\LetsEncrypt as letsencryt;
// store domain and aliases in session
if (!isset($_SESSION['lestencrypt-domains']) || empty($_SESSION['letsencrypt-domains'])) {
$domain = $params[1];
$cmd = 'web-add.sh list-vhost ' . $domain;
sudoexec($cmd, $data_output, $exec_return);
$data_split = explode(':', $data_output[0]);
$aliases = explode(',', $data_split[3]);
$domains = array();
// store domain and aliases
array_push($domains, $data_split[2]);
foreach ($aliases as $alias) {
array_push($domains, $alias);
}
$_SESSION['letsencrypt-domains'] = array_filter($domains);
}
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
$letsencrypt = new letsencryt();
$errorMessage = '';
$warningMessage = '';
if (isset($_POST['submit'])) {
while (true) {
// check HTTP
$isRemoteResourceAvailable = $letsencrypt->checkRemoteResourceAvailability($_SESSION['letsencrypt-domains'][0]);
if (!$isRemoteResourceAvailable) {
$errorMessage = "Erreur : Le challenge HTTP a échoué.<br>
Merci de vérifier que le dossier <code>/.well-known/evoacme-challenge/</code> est accessible.";
break;
}
// check DNS
$valid_domains = $letsencrypt->checkDNSValidity($_SESSION['letsencrypt-domains']);
$failed_domains = array_diff($_SESSION['letsencrypt-domains'], $valid_domains);
if (!empty($failed_domains)) {
$errorMessage = "Erreur : La vérification DNS a échoué.<br>
Merci de vérifier les enregistrements de type A et AAAA pour les domaine(s) suivant(s) :";
break;
}
// make csr
$isCsrGenerated = $letsencrypt->makeCsr($params[1], $_SESSION['letsencrypt-domains']);
if (!$isCsrGenerated) {
$errorMessage = "Erreur : La génération de demande de certificat a échoué.<br>
Merci de contacter un administrateur pour continuer.";
break;
}
// evoacme TEST
$testGenerateCert = $letsencrypt->generateSSLCertificate($params[1]);
if (!$testGenerateCert) {
$errorMessage = "Erreur : La génération de certificat en mode TEST a échoué.<br>
Merci de contacter un administrateur pour continuer.";
break;
}
// evoacme
$generateCert = $letsencrypt->generateSSLCertificate($params[1], false);
if (!$generateCert) {
$errorMessage = "Erreur : La génération de certificat a échoué.<br>
Merci de contacter un administrateur pour continuer.";
break;
}
break;
}
} else {
$validUntil = '';
while(true) {
// check domains list
if (empty($_SESSION['letsencrypt-domains'])) {
$errorMessage = "Erreur : la liste des domaines est vide.";
break;
}
// check if evoacme is installed
$binaries_installed = $letsencrypt->isEvoacmeInstalled();
if (!$binaries_installed) {
$errorMessage = "Erreur : les binaires Evoacme ne sont pas installés.
Veuillez contacter un administrateur.";
break;
}
// Check existing SSL certificate
$domainsIncluded = array();
foreach ($_SESSION['letsencrypt-domains'] as $domain) {
$existingSSLCertificate = $letsencrypt->getCertificate($domain);
// if no certificate is present (false returned) for this domain, go to the next domain
if (is_bool($existingSSLCertificate)) {
continue;
}
$parsedCertificate = $letsencrypt->parseCertificate($existingSSLCertificate);
// check if LE is the certificate issuer
$isIssuerValid = $letsencrypt->isCertIssuedByLetsEncrypt($parsedCertificate["issuer"]);
if (!$isIssuerValid) {
$errorMessage = "Erreur : le certificat existant n'est pas géré par Let's Encrypt.";
break 2; // break the foreach and the while
}
// check wether the certificate is valid or expired
$isCertValid = $letsencrypt->isCertValid($parsedCertificate["validUntil"]);
if (!$isCertValid && !isset($_POST['force_renew'])) {
$warningMessage = "Attention : le certificat existant n'est plus valide.
Souhaitez-vous le renouveller ?";
break 2;
} else {
$validUntil = date("d/m/Y", $parsedCertificate["validUntil"]);
}
// check if the domain is already in the certificate
$isDomainIncluded = $letsencrypt->isDomainIncludedInCert($domain, $parsedCertificate["includedDomains"]);
if ($isDomainIncluded) {
array_push($domainsIncluded, $domain);
continue; // break only the current foreach iteration
}
}
// contains all the domains included in the existing certificate
if (!empty($domainsIncluded) && !isset($_POST['force_renew'])) {
$domainsNotIncluded = array_diff($_SESSION['letsencrypt-domains'], $domainsIncluded);
if (empty($domainsNotIncluded)) {
$errorMessage = "Le certificat existant couvre déjà tous les domaines jusqu'au " . $validUntil . ".";
break;
}
$warningMessage = "Attention : le certificat existant couvre déjà le(s) domaine(s) jusqu'au " . $validUntil . " :<br>";
foreach ($domainsIncluded as $domainIncluded) {
$warningMessage .= $domainIncluded . "<br>";
}
$warningMessage .= "<br><strong>En confirmant le renouvellement, vous allez ajouter :</strong><br>";
foreach ($domainsNotIncluded as $domainNotIncluded) {
$warningMessage .= $domainNotIncluded . "<br>";
}
break;
}
break;
}
}
include_once EVOADMIN_BASE . '../tpl/webadmin-letsencrypt.tpl.php';
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';

View file

@ -1,94 +0,0 @@
<?php
/**
* Apache VirtualHost Management Page
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0
*/
require_once EVOADMIN_BASE . '../lib/bdd.php';
require_once EVOADMIN_BASE . '../lib/domain.php';
require_once EVOADMIN_BASE . '../evolibs/Form.php';
global $conf;
$form = new FormPage("Modification de la version de PHP", FALSE);
$form->addField('php_version', new SelectFormField("Nouvelle version de PHP", True, $conf['php_versions']));
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
$domain = $params[1];
// TODO: adapt for cluster mode
if ($conf['cluster']) {
print "<center>";
printf ('<h2>ERREUR</h2>');
printf ('<p>Cette action n\'est pas encore supportée en mode cluster</p>');
printf ('<p><a href="/webadmin">Retour à liste des comptes</a></p>');
print "</center>";
}
else {
$cmd = 'web-add.sh list-vhost ' . escapeshellarg($domain);
sudoexec($cmd, $data_output, $exec_return);
$data_split = explode(':', $data_output[0]);
$current_PHP_version = $data_split[7];
if (!empty($_POST)) {
$form->isCurrentPage(TRUE);
$form->initFields();
if ($form->verify(TRUE)) {
if (isset($conf['php_versions'][$form->getField('php_version')->getValue()]))
{
$selected_php_version = $conf['php_versions'][$form->getField('php_version')->getValue()];
$exec_cmd = 'web-add.sh setphpversion '.escapeshellarg($domain).' '.escapeshellarg($selected_php_version);
sudoexec($exec_cmd, $exec_output, $exec_return);
if ($exec_return == 0) {
print "<center>";
printf ('<p>La version de PHP a bien été modifiée</p>');
printf ('<p><a href="/webadmin">Retour à liste des comptes</a></p>');
print "</center>";
}
else {
print "<center>";
printf ('<h2>ERREUR</h2>');
printf ('<p>Une erreur inattendue s\'est produite </p>');
if ($conf['debug'] == TRUE) {
print '<pre>';
foreach($exec_output as $exec_line) {
printf("%s\n", $exec_line);
}
print '</pre>';
}
printf ('<p><a href="/webadmin">Retour à liste des comptes</a></p>');
print "</center>";
}
}
else {
include_once EVOADMIN_BASE . '../tpl/webadmin-php.tpl.php';
}
}
else {
include_once EVOADMIN_BASE . '../tpl/webadmin-php.tpl.php';
}
}
else {
include_once EVOADMIN_BASE . '../tpl/webadmin-php.tpl.php';
}
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
}

View file

@ -1,218 +0,0 @@
<?php
/**
* Apache VirtualHost Management Page
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0
*/
require_once EVOADMIN_BASE . '../lib/bdd.php';
require_once EVOADMIN_BASE . '../lib/domain.php';
global $conf;
if (isset($params[2]) && $params[2] == "edit") {
$redirect_url = "/webadmin/" . $params[1] . "/domain/";
if (isset($params[3]) && $params[3] == "") http_redirect($redirect_url);
require_once EVOADMIN_BASE . '../evolibs/Form.php';
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
$form = new FormPage("Modification du Servername", FALSE);
$form->addField('domain_servername', new DomainInputFormField("Servername", TRUE), $params[3]);
$form->addField('previous_servername', new DomainInputFormField("", TRUE, TRUE), $params[3]);
if (!empty($_POST)) {
$form->isCurrentPage(TRUE);
$form->initFields();
if ($form->verify(TRUE)) {
// TODO: Adapt the script for cluster mode
if ($conf['cluster']) {
if (is_mcluster_mode()) {
// If the user has not yet selected a cluster, redirect-it to home page.
if (empty($_SESSION['cluster'])) {
http_redirect('/');
}
$cache = str_replace('%cluster_name%', $_SESSION['cluster'], $conf['cache']);
}
else {
$cache = $conf['cache'];
}
$bdd = new bdd();
$bdd->open($cache);
$servername = array (
'domain' => htmlspecialchars(basename($_SERVER['REDIRECT_URL'])),
'servername' => $form->getField('domain_servername')->getValue(),
'previous_servername' => $form->getField('previous_servername')->getValue(),
);
$account_name=$servername['domain'];
$account = $bdd->get_account($account_name);
if (sizeof($account) == 0)
die("Anomalie... Contactez votre administrateur.");
$master = $bdd->get_server_from_roleid($account['id_master']);
$slave = $bdd->get_server_from_roleid($account['id_slave']);
if ( $bdd->is_serveralias( $account_name, $serveralias['alias'] ) == 0 ) {
/* web-add-cluster addalias */
$exec_cmd = 'web-add-cluster.sh add-alias '.$serveralias['domain'].' '.$serveralias['alias'].' '.$master.' '.$slave;
sudoexec($exec_cmd, $exec_output, $exec_return);
if ($exec_return == 0) {
/* Ajout BDD */
$bdd->add_serveralias($serveralias);
domain_add($serveralias['alias'], gethostbyname($master) , false);
# Si le compte en question est en replication temps
# reel, il faut faire un restart manuel de lsyncd
# pour prendre en compte le nouveau domaine.
if ($account['replication'] == "realtime") {
mail('tech@evolix.fr', "[TAF] Redemarrer lsyncd sur $master", wordwrap('killer tous les processus lsyncd lancé par vmail pour le compte '.$account['name'].' et les relancer (cf. la ligne correspondante à ce compte dans la crontab de vmail).\n', 70));
}
print "<center>";
printf ('<p>L\'alias %s du domaine %s a bien été créé</p>', $serveralias['alias'], $serveralias['domain']);
printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $redirect_url);
print "</center>";
} else {
print "<center>";
printf ('<p>Echec dans la creation de l\'alias %s du domaine %s</p>', $serveralias['alias'], $serveralias['domain']);
printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $redirect_url);
print "</center>";
}
} else {
print "<center>";
printf ('<p>Alias %s du domaine %s deja existant !</p>', $serveralias['alias'], $serveralias['domain']);
printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $redirect_url);
print "</center>";
}
}
else {
$servername = array (
'domain' => $params[1],
'servername' => $form->getField('domain_servername')->getValue(),
'previous_servername' => $form->getField('previous_servername')->getValue(),
);
$account_name=$servername['domain'];
$is_servername_present = check_occurence_name($servername['servername']);
if (!$is_servername_present) {
$exec_cmd = 'web-add.sh update-servername ' . $servername['domain'] . ' ' . $servername['servername'] . ' ' . $servername['previous_servername'];
sudoexec($exec_cmd, $exec_output, $exec_return);
if ($exec_return == 0) {
//domain_add($serveralias['alias'], gethostbyname($master) , false); TODO avec l'IP du load balancer
print "<center>";
printf ('<p>Le Servername %s a bien été modifié</p>', $servername['servername']);
printf ('<p><a href="%s">Retour à la liste des Servernames</a></p>', $redirect_url);
print "</center>";
}
else {
print "<center>";
printf ('<p>Echec dans la modification du Servername %s</p>', $servername['servername']);
printf ('<p><a href="%s">Retour à la liste des Servernames</a></p>', $redirect_url);
print "</center>";
}
}
else {
print "<center>";
printf ('<p>Echec dans la modification du Servername %s</p>', $servername['servername']);
print ('<p>Le domaine existe déjà dans d\'autres vhosts.');
printf ('<p><a href="%s">Retour à la liste des Servernames</a></p>', $redirect_url);
print "</center>";
}
}
} else {
print "<h2>Modification du Servername</h2><hr>";
print "<form name=\"form-add\" id=\"form-add\" action=\"\" method=\"POST\">";
print " <fieldset>";
print " <legend>Modification du Servername</legend>";
print $form;
print " <p><input type=\"submit\" value=\"Modifier\"/></p>";
print " </fieldset>";
print "</form>";
}
} else {
print "<h2>Modification du Servername</h2><hr>";
print "<form name=\"form-add\" id=\"form-add\" action=\"\" method=\"POST\">";
print " <fieldset>";
print " <legend>Modification du Servername</legend>";
print $form;
print " <p><input type=\"submit\" value=\"Modifier\"/></p>";
print " </fieldset>";
print "</form>";
}
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
} else {
$domain = $params[1];
$servername_list = array();
// TODO: adapt for cluster mode
if ($conf['cluster']) {
if (is_mcluster_mode()) {
// If the user has not yet selected a cluster, redirect-it to home page.
if (empty($_SESSION['cluster'])) {
http_redirect('/');
}
$cache = str_replace('%cluster_name%', $_SESSION['cluster'], $conf['cache']);
}
else {
$cache = $conf['cache'];
}
$alias_list = array();
/* parcours de la table Serveralias */
$bdd = new bdd();
$bdd->open($cache);
$alias_list = $bdd->list_serveralias($domain);
}
else {
$cmd = 'web-add.sh list-vhost ' . $domain;
if(!is_superadmin()) {
$cmd = sprintf('%s %s', $cmd, $_SESSION['user']);
}
sudoexec($cmd, $data_output, $exec_return);
$data_vhost = explode(':', $data_output[0]);
$servername = $data_vhost[2];
}
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
include_once EVOADMIN_BASE . '../tpl/webadmin-servername.tpl.php';
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
}
?>

View file

@ -1,11 +1,11 @@
<?php <?php
/** /**
* Apache VirtualHost Management Page * Apache VirtualHost Management Page
* *
* Copyright (c) 2009 Evolix - Tous droits reserves * Copyright (c) 2009 Evolix - Tous droits reserves
* *
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2 * vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
* *
* @author Gregory Colpart <reg@evolix.fr> * @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr> * @author Thomas Martin <tmartin@evolix.fr>
@ -21,81 +21,24 @@ global $conf;
if (!$conf['cluster']) { if (!$conf['cluster']) {
$cmd = 'web-add.sh list-vhost'; $cmd = 'web-add.sh list-vhost';
if(!is_superadmin()) {
$cmd = sprintf('%s %s', $cmd, $_SESSION['user']);
}
sudoexec($cmd, $data_output, $exec_return);
if(!is_superadmin()) { /* Récupération de cette liste dans le tableau $vhost_list */
$cmd = sprintf('%s %s', $cmd, $_SESSION['user']); $vhost_list = array();
} foreach($data_output as $data_line) {
sudoexec($cmd, $data_output, $exec_return); $data_split = explode(':', $data_line);
array_push($vhost_list, array(
'owner' => $data_split[0],
'configid' => $data_split[1],
'server_name' => $data_split[2],
'server_alias' => $data_split[3])
);
}
/* Récupération de cette liste dans le tableau $vhost_list */
$vhost_list = array();
if (!isset($_SESSION['non_standard'])) {
$_SESSION['non_standard'] = array();
}
foreach($data_output as $data_line) {
$data_split = explode(':', $data_line);
if(isset($conf['quota']) && $conf['quota'] === true) {
if (strstr($data_split[4],'K')) {
$taille_utilise = number_format(($data_split[4]/1024), 2, '.', '').'M';
$taille_utilise_mo = $taille_utilise;
if ($taille_utilise >= 1024) {
$taille_utilise = number_format(($taille_utilise/1024), 2, '.', '').'G';
}
} else if ($data_split[4] >= 1024) {
$taille_utilise_mo = $data_split[4];
$taille_utilise = number_format(($data_split[4]/1024), 2, '.', '').'G';
} else {
$taille_utilise_mo = $data_split[4];
$taille_utilise = $data_split[4];
}
$quota_bas_mo = $data_split[5];
$quota_bas = number_format(($data_split[5]/1024), 2, '.', '').'G';
$quota_haut = number_format(($data_split[6]/1024), 2, '.', '').'G';
$occupation = number_format((($taille_utilise_mo/$quota_bas_mo)*100), 2, '.', '');
if ($occupation >= 90) {
$occupation = '<span style="color:red;font-weight:bold;">'.$occupation.'%</span>';
} else if ($occupation >= 80) {
$occupation = '<span style="color:MediumVioletRed;font-weight:bold;">'.$occupation.'%</span>';
} else if ($occupation >= 70) {
$occupation = '<span style="color:Fuchsia;font-weight:bold;">'.$occupation.'%</span>';
} else {
$occupation = $occupation.'%';
}
}
else {
$taille_utilise ="";
$quota_bas = "";
$quota_haut = "";
$occupation = "";
}
// current vhost isn't standard and thus not manageable by evoadmin-web
if (!$data_split[9] && (!in_array($data_split[0], $_SESSION['non_standard']))) {
array_push($_SESSION['non_standard'], $data_split[0]);
}
array_push($vhost_list, array(
'owner' => $data_split[0],
'configid' => $data_split[1],
'server_name' => $data_split[2],
'server_alias' => $data_split[3],
'size' => $taille_utilise,
'quota_soft' => $quota_bas,
'quota_hard' => $quota_haut,
'occupation' => $occupation,
'php_version' => $data_split[7],
'is_enabled' => $data_split[8])
);
}
} }
else { else {
@ -110,35 +53,39 @@ else {
$cache = $conf['cache']; $cache = $conf['cache'];
} }
$vhost_list = array(); $vhost_list = array();
/* parcours de la table account */ /* parcours de la table account */
$bdd=new bdd(); $bdd=new bdd();
$bdd->open($cache); $bdd->open($cache);
$accounts = $bdd->list_accounts(); $accounts = $bdd->list_accounts();
if (!empty($accounts)) { if (!empty($accounts)) {
foreach($accounts as $account) { foreach($accounts as $account) {
$master = $bdd->get_server_from_roleid($account['id_master']);
$master = $bdd->get_server_from_roleid($account['id_master']);
$slave = '';
if (!empty($account['id_slave'])) $slave = '';
$slave = $bdd->get_server_from_roleid($account['id_slave']); if (!empty($account['id_slave']))
$slave = $bdd->get_server_from_roleid($account['id_slave']);
array_push($vhost_list, array(
'owner' => $account['name'], array_push($vhost_list, array(
'server_name'=> $account['domain'], 'owner' => $account['name'],
'bdd' => $account['bdd'], 'server_name'=> $account['domain'],
'bdd' => $account['bdd'],
'mail' => $account['mail'], 'mail' => $account['mail'],
'replication' => $account['replication'], 'replication' => $account['replication'],
'master' => $master, 'master' => $master,
'slave' => $slave) 'slave' => $slave)
); );
}
} }
}
} }
include_once EVOADMIN_BASE . '../tpl/header.tpl.php'; include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php'; include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
include_once EVOADMIN_BASE . '../tpl/webadmin.tpl.php'; include_once EVOADMIN_BASE . '../tpl/webadmin.tpl.php';

View file

@ -132,7 +132,7 @@ class bdd {
return $row['name']; return $row['name'];
} }
return 0; return 0;
} }
/** /**
@ -450,9 +450,9 @@ class bdd {
public function list_accounts() public function list_accounts()
{ {
$database = $this->db; $database = $this->db;
$query = "SELECT * FROM Accounts"; $query = "SELECT * FROM Accounts";
$result = $database->query($query); $result = $database->query($query);
if ($result != FALSE) if ($result != FALSE)
@ -474,12 +474,12 @@ class bdd {
public function list_serveralias($domain) public function list_serveralias($domain)
{ {
$database = $this->db; $database = $this->db;
if ($domain == NULL) if ($domain == NULL)
return NULL; return NULL;
$query = "SELECT * FROM Serveralias WHERE domain = '$domain'"; $query = "SELECT * FROM Serveralias WHERE domain = '$domain'";
$result = $database->query($query); $result = $database->query($query);
if ($result != FALSE) if ($result != FALSE)
@ -501,7 +501,7 @@ class bdd {
public function is_serveralias($domain, $alias) public function is_serveralias($domain, $alias)
{ {
$database = $this->db; $database = $this->db;
if ($domain == NULL) if ($domain == NULL)
return 0; return 0;

View file

@ -17,37 +17,13 @@ function domain_add($name, $IP, $with_mxs, $gmail=false) {
$exec_cmd .= ' -m mail,10'; $exec_cmd .= ' -m mail,10';
$exec_cmd .= ' -m backup.quai13.net.,20'; $exec_cmd .= ' -m backup.quai13.net.,20';
} }
# mail('tech@evolix.fr', '[TAF] Ajouter '.$name.' sur quai13-backup', wordwrap('Ajouter le domaine '.$name.' à la directive relay_domains dans le fichier /etc/postfix/main.cf sur quai13-backup, pour mettre en place le MX secondaire du domaine.', 70));
} }
$exec_cmd .= " -a $IP $name"; $exec_cmd .= " -a $IP $name";
//echo $exec_cmd."\n";
sudoexec($exec_cmd, $exec_output, $exec_return); sudoexec($exec_cmd, $exec_output, $exec_return);
return array($exec_cmd, $exec_return, $exec_output); return array($exec_cmd, $exec_return, $exec_output);
} }
/**
* Ensure that the domain (or list of domains) do no exists in any other
* apache config file. Either as a ServerName or ServerAlias
*
* @param string $name Domain (or list of domains separated by commas)
*
* @return boolean True if one occurence is found. Else otherwise
*/
function check_occurence_name($name) {
// If no domain are given, that should be okay
if(strlen($name) === 0){
return false;
}
$exploded_names = explode(',', $name);
foreach ($exploded_names as $current_name) {
$check_occurence_cmd = 'web-add.sh check-occurence ' . escapeshellarg($current_name);
sudoexec($check_occurence_cmd, $check_occurence_output, $check_occurence_return);
if ($check_occurence_return == 0) return true;
}
return false;
}

View file

@ -1,217 +0,0 @@
<?php
namespace lib;
/**
* LetsEncrypt
*/
class LetsEncrypt
{
const HTTP_OK = 200;
const HTTP_CHALLENGE_URL = '/.well-known/acme-challenge/testfile';
/**
* create the file used to test the HTTP challenge
*/
private function createFileHttpChallenge()
{
$cmd = 'web-add.sh manage-http-challenge-file create';
sudoexec($cmd, $data_output, $exec_return);
}
/**
* delete the file used to test the HTTP challenge
*/
private function deleteFileHttpChallenge()
{
$cmd = 'web-add.sh manage-http-challenge-file delete';
sudoexec($cmd, $data_output, $exec_return);
}
/**
* generate a CSR
* @param string $vhost
* @param Array $domains
* @return boolean
*/
public function makeCsr($vhost, $domains)
{
$domains = implode(' ', $domains);
$cmd = 'web-add.sh generate-csr ' . $vhost . ' ' . "$domains";
sudoexec($cmd, $data_output, $exec_return);
if ($exec_return == 0) {
return true;
}
return false;
}
/**
* Generate a SSL certificate
* @param string $vhost
* @param boolean $test generate in TEST mode or not
* @return boolean
*/
public function generateSSLCertificate($vhost, $test = true)
{
$cmd = 'web-add.sh generate-ssl-certificate ' . $vhost . ' ' . ($test ? "true" : "false");
sudoexec($cmd, $data_output, $exec_return);
if ($exec_return == 0) {
return true;
}
return false;
}
/**
* perform a cURL call on the remote resource
* the cURL call follows redirections
* @param Array $domains list of domains
* @return boolean
*/
public function checkRemoteResourceAvailability($domain)
{
$this->createFileHttpChallenge();
$curl_handler = curl_init();
// setting cURL options
curl_setopt($curl_handler, CURLOPT_URL, $domain . self::HTTP_CHALLENGE_URL);
curl_setopt($curl_handler, CURLOPT_TIMEOUT, 3);
curl_setopt($curl_handler, CURLOPT_HEADER, true);
curl_setopt($curl_handler, CURLOPT_NOBODY, true);
curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_handler, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl_handler, CURLOPT_MAXREDIRS, 3);
curl_setopt($curl_handler, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true);
curl_exec($curl_handler);
$returned_http_code = curl_getinfo($curl_handler, CURLINFO_HTTP_CODE);
$returned_http_url = curl_getinfo($curl_handler, CURLINFO_EFFECTIVE_URL);
$this->deleteFileHttpChallenge();
if ($returned_http_code === self::HTTP_OK && strpos($returned_http_url, self::HTTP_CHALLENGE_URL)) {
$returned_http_url = str_replace(self::HTTP_CHALLENGE_URL, '', $returned_http_url);
$returned_http_url = preg_replace('#^https?://#', '', $returned_http_url);
return true;
}
return false;
}
/**
* Query the corresponding IP for each domain
* @param Array $domains list of HTTP checked domains
* @return Array $valid_dns_domains list of valid domains
*/
public function checkDNSValidity($domains)
{
$valid_dns_domains = array();
$serverIP = exec("ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$/\\1/p'");
foreach ($domains as $domain) {
//FQDN syntax
$domain .= '.';
$dns_record_ipv4 = dns_get_record($domain, DNS_A);
$dns_record_ipv6 = dns_get_record($domain, DNS_AAAA);
if ($dns_record_ipv4[0]['ip'] === $serverIP || $dns_record_ipv6[0]['ip'] === $serverIP) {
// remove the last dot added for the FQDN syntax
$domain = rtrim($domain, '.');
array_push($valid_dns_domains, $domain);
}
}
return $valid_dns_domains;
}
/**
* check the presence of make-csr and evoacme binaries
* @return boolean
*/
public function isEvoacmeInstalled()
{
$output_make_csr = shell_exec("which make-csr");
$output_evoacme = shell_exec("which evoacme");
if (empty($output_make_csr) || empty($output_evoacme)) {
return false;
}
return true;
}
/**
* Retrieve the SSL certificate from the URL
* @param string $domain
* @return Array|false $cont list of parameters of the certificate, or false
*/
public function getCertificate($domain)
{
$stream = stream_context_create(array("ssl" => array("capture_peer_cert" => true)));
$read = stream_socket_client("ssl://" . $domain . ":443", $errno, $errstr, 10, STREAM_CLIENT_CONNECT, $stream);
if ($read === false) {
return false;
}
$cont = stream_context_get_params($read);
return $cont;
}
/**
* Parse the certificat arguments and extract data
* @param Array $certificateParameters certificat arguments
* @return Array $infosCert contains only the issuer, domains and expiration date
*/
public function parseCertificate($certificateParameters)
{
$infosCert = array();
$parsedParameters = openssl_x509_parse($certificateParameters["options"]["ssl"]["peer_certificate"]);
$issuer = $parsedParameters["issuer"]["O"];
$includedDomains = $parsedParameters["extensions"]["subjectAltName"];
$validUntil = $parsedParameters["validTo_time_t"];
$infosCert["issuer"] = $issuer;
$infosCert["includedDomains"] = $includedDomains;
$infosCert["validUntil"] = $validUntil;
return $infosCert;
}
/**
* Check wether the certificat is issued by Let's Encrypt or not
* @param string $issuer name of the certificat issuer
* @return boolean
*/
public function isCertIssuedByLetsEncrypt($issuer)
{
return ($issuer === "Let's Encrypt") ? true : false;
}
/**
* Check wether the certificat is valid or not
* @param string $timestampCertValidUntil certificat expiration date in timestamp
* @return boolean
*/
public function isCertValid($timestampCertValidUntil)
{
$currentDate = time();
return ($timestampCertValidUntil > $currentDate) ? true : false;
}
public function isDomainIncludedInCert($domainRequested, $san)
{
$san = preg_replace('/DNS:| DNS:/', '', $san);
$sanArray = explode(',', $san);
return (in_array($domainRequested, $sanArray)) ? true : false;
}
}

View file

@ -1,4 +1,4 @@
Include "/etc/awstats/awstats.conf" Include "/etc/awstats/awstats.conf.local"
LogFile="HOME_DIR/XXX/log/access.log" LogFile="HOME_DIR/XXX/log/access.log"
SiteDomain="SERVERNAME" SiteDomain="SERVERNAME"
DirData="HOME_DIR/XXX/awstats" DirData="HOME_DIR/XXX/awstats"

View file

@ -43,7 +43,7 @@ add_mx () {
return 0 return 0
fi fi
if ! grep -q -P "^$mx_subdomain[ \t]+IN[ \t]+MX[ \t]+[[:digit:]]+[ \t]+$mx$" $zonefile; then if ! grep -q -E "^$mx_subdomain[ \t]+IN[ \t]+MX[ \t]+[[:digit:]]+[ \t]+$mx$" $zonefile; then
echo "$mx_subdomain IN MX $mx_priority $mx" >>$zonefile echo "$mx_subdomain IN MX $mx_priority $mx" >>$zonefile
else else
log ERR "MX Record $mx already exists." log ERR "MX Record $mx already exists."
@ -58,7 +58,7 @@ add_subdomain () {
zonefile="$BINDROOT/db.$domain" zonefile="$BINDROOT/db.$domain"
if ! grep -q -P "^$subdomain[ \t]+IN[ \t]+(CNAME|A)[ \t]+" $zonefile; then if ! grep -q -E "^$subdomain[ \t]+IN[ \t]+(CNAME|A)[ \t]+" $zonefile; then
echo "$subdomain IN CNAME @" >>$zonefile echo "$subdomain IN CNAME @" >>$zonefile
else else
log ERR "CNAME or A record for $subdomain already exists." log ERR "CNAME or A record for $subdomain already exists."
@ -73,7 +73,7 @@ inc_and_reload () {
zonefile="$BINDROOT/db.$domain" zonefile="$BINDROOT/db.$domain"
# Set the date for serial (only if greater than actual serial) # Set the date for serial (only if greater than actual serial)
serial=$(grep -P '^[ \t]*[0-9]{10}[ \t]*; serial' $zonefile | sed "s/^[ \t]*\([0-9]\{10\}\)[ \t]*; serial/\1/") serial=$(grep -E '^[ \t]*[0-9]{10}[ \t]*; serial' $zonefile | sed "s/^[ \t]*\([0-9]\{10\}\)[ \t]*; serial/\1/")
if [ `date "+%Y%m%d%H"` -gt $serial ]; then serial=$(date "+%Y%m%d%H"); else serial=$(( $serial + 1 )); fi if [ `date "+%Y%m%d%H"` -gt $serial ]; then serial=$(date "+%Y%m%d%H"); else serial=$(( $serial + 1 )); fi
sed -i "s/^\([ \t]*\)[0-9]\{10\}\([ \t]*; serial\)/\1$serial\2/" \ sed -i "s/^\([ \t]*\)[0-9]\{10\}\([ \t]*; serial\)/\1$serial\2/" \
$zonefile $zonefile

View file

@ -9,7 +9,7 @@ LOGFILE=~/log/evocluster.log
MAIL="jdoe@example.com" MAIL="jdoe@example.com"
mail_error() { mail_error() {
echo "From: John Doe <jdoe@example.com> echo "From: John Doe <jdoe@example.com>
To: $MAIL To: $MAIL
Subject: [evocluster] check_cron_state.sh Subject: [evocluster] check_cron_state.sh
@ -52,45 +52,45 @@ fi
if [ "$STATE" = "slave" ]; then if [ "$STATE" = "slave" ]; then
info 'Account is in state slave, execution of cron is disabled' info 'Account is in state slave, execution of cron is disabled'
exit 1 exit 1
else else
# env var $FORCE_CRON is set to yes, execute the cron # env var $FORCE_CRON is set to yes, execute the cron
[ "$FORCE_CRON" = "yes" ] && exit 0; [ "$FORCE_CRON" = "yes" ] && exit 0;
###  rajouter une règle sudo pour pouvoir exécuter ping ? ###  rajouter une règle sudo pour pouvoir exécuter ping ?
# test if the remote server is alive # test if the remote server is alive
#if ! ping -c1 -w1 $REMOTE_IP; then #if ! ping -c1 -w1 $REMOTE_IP; then
# error "Remote server $IP doesn't seem to be up, I don't know what to do...Add 'FORCE_CRON=yes' in ~/state file to execute user cron" # error "Remote server $IP doesn't seem to be up, I don't know what to do...Add 'FORCE_CRON=yes' in ~/state file to execute user cron"
# exit 1 # exit 1
#fi #fi
### ###
# try to connect to the remote server and check if it isn't a master # try to connect to the remote server and check if it isn't a master
REMOTE_STATE=$(mktemp) REMOTE_STATE=$(mktemp)
if ssh $REMOTE_IP [ -e ~/state ]; then if ssh $REMOTE_IP [ -e ~/state ]; then
ssh $REMOTE_IP cat ~/state >$REMOTE_STATE ssh $REMOTE_IP cat ~/state >$REMOTE_STATE
elif [ $? -eq 255 ]; then elif [ $? -eq 255 ]; then
error "Failed to connect to slave ($REMOTE_IP)! I don't know what to do.." error "Failed to connect to slave ($REMOTE_IP)! I don't know what to do.."
exit 1 exit 1
else else
error "State file does not exist on slave !" error "State file does not exist on slave !"
exit 1 exit 1
fi fi
. $REMOTE_STATE . $REMOTE_STATE
rm -rf $REMOTE_STATE rm -rf $REMOTE_STATE
if [ -n "$STATE" ]; then if [ -n "$STATE" ]; then
REMOTE_STATE=$STATE REMOTE_STATE=$STATE
else else
error '$STATE not set in remote state file!' error '$STATE not set in remote state file!'
exit 1 exit 1
fi fi
if [ "$REMOTE_STATE" = "master" ]; then if [ "$REMOTE_STATE" = "master" ]; then
error "Remote server $IP is master too. (incoherent state)..." error "Remote server $IP is master too. (incoherent state)..."
exit 1 exit 1
fi fi
fi fi
# Remote server is slave # Remote server is slave

View file

@ -1,101 +0,0 @@
#!/bin/sh
#
# Manage MySQL accounts and databases.
#
# Note: in the following code:
# - account means user@host
# - user is the user part of account
#
MYSQL_OPTS="--raw --skip-column-names --skip-line-numbers"
usage() {
cat <<EOT >&2
Usage: $0 <command> [<command arg>]
Available commands are:
list [<user>]
List all accounts and their databases, separated by semi-colon. If user
is specified, list databases for this user only.
passwd <user> <new password>
Change password for specified user.
EOT
}
error() {
printf >&2 "Error: $@\n"
}
get_host() {
user="$1"
host=$(mysql $MYSQL_OPTS --execute "SELECT host FROM mysql.user WHERE user='$user'")
if [ $(echo "$host" |wc -l) -gt 1 ]; then
# TODO: Not perfect!
echo "$host" |grep '%'
else
echo $host
fi
}
get_dbs() {
account="$1"
echo "$(mysql $MYSQL_OPTS --execute "SHOW GRANTS FOR $account" |perl -ne 'print "$1 " if (/^GRANT (?!USAGE).* ON `(.*)`/)')"
}
get_accounts() {
echo "$(mysql $MYSQL_OPTS --execute "SELECT user,host FROM mysql.user;" |perl -ne 'print "$1\@$2\n" if (/^([^\s]+)\s+([^\s]+)$/)'|sed "s/^/'/; s/@/'@'/; s/$/'/;")"
}
list() {
if [ $# -gt 0 ]; then
user="$1"
host=$(get_host $user)
account="'$user'@'$host'"
echo $account:$(get_dbs "$account")
else
for account in $(get_accounts); do
echo $account:$(get_dbs "$account")
done
fi
}
passwd() {
if [ $# -ne 2 ]; then
usage
exit 1
fi
user="$1"
password="$2"
host=$(get_host $user)
mysql -e "SET PASSWORD FOR '$user'@'$host' = PASSWORD('$password');"
}
#
# Argument processing.
#
if [ $# -lt 1 ]; then
usage
exit 1
fi
command="$1"
shift
case "$command" in
list)
list $@
;;
passwd)
passwd $@
;;
*)
error "Unknown command: $command."
;;
esac

View file

@ -1,18 +0,0 @@
[SED_LOGIN]
user = SED_LOGIN
group = SED_LOGIN
listen = /var/run/php-fpm-SED_LOGIN.sock
listen.mode = 0660
listen.owner = SED_LOGIN
listen.group = SED_LOGIN
pm = ondemand
pm.max_children = 10
pm.process_idle_timeout = 10s
pm.status_path = SED_STATUS
php_admin_value[error_log] = /home/SED_LOGIN/phplog/php.log
php_admin_value[post_max_size] = 50M
php_admin_value[upload_max_filesize] = 50M
php_admin_value[max_execution_time] = 600

View file

@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/bin/bash
############################################################ ############################################################
# # # #
@ -13,11 +13,6 @@
# vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2 # vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
set -o errexit
set -o pipefail
set -o nounset
#set -x
VPASSWD_PATH="/etc/proftpd/vpasswd" VPASSWD_PATH="/etc/proftpd/vpasswd"
FTPLOG_PATH="/var/log/evolix-ftp.log" FTPLOG_PATH="/var/log/evolix-ftp.log"
@ -53,38 +48,48 @@ EOT
} }
log_msg() { log_msg() {
curdate="$(date +"%Y/%m/%d %H:%M:%S")" curdate=`date +"%Y/%m/%d %H:%M:%S"`
echo "$curdate $1" >> "$FTPLOG_PATH" echo "$curdate $1" >>$FTPLOG_PATH
} }
get_user_login_by_UID() { get_user_login_by_UID() {
uid=$1 uid=$1
grep "$uid" /etc/passwd | awk -F : "{if (\$3==$uid) print \$1}" grep $uid /etc/passwd | awk -F : "{if (\$3==$uid) print \$1}"
} }
list_accounts_by_UID() { list_accounts_by_UID() {
uid=$1 uid=$1
# Remove # and empty lines
ftp_users=$(grep -v -E '^[[:blank:]]*(#.*)*$' "$VPASSWD_PATH")
for line in $ftp_users; do account_list=''
line_uid="$(echo "$line" | cut -d":" -f3)" oldIFS=IFS
IFS=$'\n'
if [[ ! "$uid" ]] || [[ "$line_uid" == "$uid" ]]; then
username=$(get_user_login_by_UID "$line_uid") for line in `cat $VPASSWD_PATH`
account=$(echo "$line" | cut -d":" -f1) do
path=$(echo "$line" | cut -d":" -f6) line_uid=`echo $line | cut -d":" -f3`
size="inconnue"
# Check output of daily "du" cron job if [ ! "$uid" ] || [ "$line_uid" == "$uid" ]; then
# (set by ansible-roles/packweb-apache/tasks/main.yml) username=`get_user_login_by_UID $line_uid`
if [ -r "$path/.size" ]; then account=`echo $line | cut -d":" -f1`
size=$(cat "$path/.size") path=`echo $line | cut -d":" -f6`
fi if [ -r $path/.size ]; then
#modif="$(cat $path/.lastmodified)" size=`cat $path/.size`
echo "$username:$account:$path:$size${modif:+:$modif}" else
fi size=0
done fi
#modif=`cat $path/.lastmodified`
# Passage en minuscule ?
#account=`echo $account | tr '[A-Z]' '[a-z]'`
#path=`echo $path | tr '[A-Z]' '[a-z]'`
account_list="${account_list}$username:$account:$path:$size:$modif\n"
fi
done
echo "$account_list"
IFS=$oldIFS
} }
add_account() { add_account() {
@ -94,17 +99,18 @@ add_account() {
passwd=$4 passwd=$4
cmd="{if (\$3==$user_id) print \$4}" cmd="{if (\$3==$user_id) print \$4}"
user_gid="$(awk -F : "$cmd" /etc/passwd)" user_gid=`awk -F : "$cmd" /etc/passwd`
# Si le répertoire de travail du compte FTP n'existe pas, on le crée # Si le répoertoire de travail du compte FTP n'existe pas, on le crée
if [[ ! -d "$path" ]]; then if [ ! -d "$path" ]; then
mkdir -p "$path" mkdir -p $path
chown "$user_id":"$user_gid" "$path" chown $user_id:$user_gid $path
# fix by tmartin : s/655/755/ # fix by tmartin : s/655/755/
chmod 755 "$path" chmod 755 $path
setfacl -R -d -m 'o:rX' $path
fi fi
echo "$passwd" | ftpasswd --passwd --file=$VPASSWD_PATH --name="$account_name" --uid="$user_id" --gid="$user_gid" --home="$path" --shell=/bin/false --stdin echo `echo $passwd | ftpasswd --passwd --file=$VPASSWD_PATH --name=$account_name --uid=$user_id --gid=$user_gid --home=$path --shell=/bin/false --stdin`
log_msg "Creation du compte $account_name (uid=$user_id, gid=$user_gid, home=$path)" log_msg "Creation du compte $account_name (uid=$user_id, gid=$user_gid, home=$path)"
} }
@ -112,7 +118,7 @@ edit_password() {
account_name=$1 account_name=$1
passwd=$2 passwd=$2
echo "$passwd" | ftpasswd --passwd --file="$VPASSWD_PATH" --name="$account_name" --uid=9999 --gid=9999 --home=/dev/null --shell=/dev/null --change-password --stdin echo `echo $passwd | ftpasswd --passwd --file=$VPASSWD_PATH --name=$account_name --uid=9999 --gid=9999 --home=/dev/null --shell=/dev/null --change-password --stdin`
} }
@ -121,88 +127,48 @@ delete_account() {
account_name=$1 account_name=$1
ftpasswd --passwd --file=$VPASSWD_PATH --name="$account_name" --delete-user echo `ftpasswd --passwd --file=$VPASSWD_PATH --name=$account_name --uid=9999 --gid=9999 --home=/dev/null --shell=/dev/null --delete-user`
log_msg "Suppression du compte $account_name" log_msg "Suppression du compte $account_name"
} }
while getopts ha:u:n:f:p: opt; do
while getopts a:u:n:f:p: opt; do
case "$opt" in case "$opt" in
a) a)
in_action=$OPTARG in_action=$OPTARG
;; ;;
u) u)
in_userid=$OPTARG in_userid=$OPTARG
;; ;;
n) n)
in_accountname=$OPTARG in_accountname=$OPTARG
;; ;;
f) f)
in_workpath=$OPTARG in_workpath=$OPTARG
;; ;;
p) p)
in_password=$OPTARG in_password=$OPTARG
;; ;;
h)
usage
exit 1
;;
*)
usage
exit 1
;;
esac esac
done done
case "${in_action-}" in case "$in_action" in
l) l)
echo -e "$(list_accounts_by_UID "${in_userid-}")" account_list=`list_accounts_by_UID $in_userid`
exit 1 echo -e -n $account_list
;; exit 1
;;
a) a)
if [[ -z "${in_userid-}" ]]; then echo -e -n `add_account $in_userid $in_accountname $in_workpath $in_password`
echo "User ID not specified" exit 1
elif [[ $in_userid = *[!0-9]* ]]; then ;;
echo "User ID must be a non negative integer"
elif [[ -z "${in_accountname-}" ]]; then
echo "Account name not specified"
elif [[ -z "${in_workpath-}" ]]; then
echo "A directory was not specified"
elif [[ -z "${in_password-}" ]]; then
echo "A password was not specified"
else
echo -e -n \
"$(add_account \
"$in_userid" \
"$in_accountname" \
"$in_workpath" \
"$in_password")"
fi
exit 1
;;
m) m)
if [[ -z "${in_accountname-}" ]]; then echo -e -n `edit_password $in_accountname $in_password`
echo "Account name not specified" exit 1;
elif [[ -z "${in_password-}" ]]; then ;;
echo "A password was not specified"
else
echo -e -n \
"$(edit_password \
"$in_accountname" \
"$in_password")"
fi
exit 1;
;;
d) d)
if [[ -z "${in_accountname-}" ]]; then echo -e -n `delete_account $in_accountname`
echo "Account name not specified" exit 1;
else ;;
echo -e -n \
"$(delete_account "$in_accountname")"
fi
exit 1;
;;
*)
usage
exit 1
;;
esac esac

View file

@ -1,48 +0,0 @@
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 passwd <login>"
echo "Usage: $0 adddb <login>"
echo "Usage: $0 dropdb <login>"
exit 1
fi
if [ "$1" = "passwd" ]; then
login="$2"
read -s -p "New password for ${login}: " password1
echo
read -s -p "New password for $login (confirm): " password2
if [ -z "$password1" ] || [ "$password1" != "$password2" ]; then
echo "Incorrect password."
exit 1
fi
mysql -e "SET PASSWORD FOR '${login}'@'%' = PASSWORD('${password1}');"
fi
if [ "$1" = "adddb" ]; then
login="$2"
read -p "New database name for ${login}: " database
if [ -z "$database" ]; then
echo "Database name cannot be empty."
exit 1
fi
mysql -e "CREATE DATABASE ${database};"
mysql -e "GRANT ALL ON ${database}.* TO '${login}'@'%';"
fi
if [ "$1" = "dropdb" ]; then
login="$2"
read -p "Drop database name for ${login}: " database
if [ -z "$database" ]; then
echo "Database name cannot be empty."
exit 1
fi
mysql -e "DROP DATABASE ${database};"
mysql -e "REVOKE ALL PRIVILEGES ON ${database}.* FROM '${login}'@'%';"
fi

View file

@ -1,13 +1,23 @@
#!/bin/sh #!/bin/sh
set -o errexit for dir in `cat /etc/proftpd/vpasswd | cut -d : -f 6`; do
set -o nounset #for dir in /home/dalleFTP/reynaud_mila; do
#set -x if [ -d $dir ]; then
du -s $dir | cut -f 1 >$dir/.size
chmod 644 $dir/.size
cut -d : -f 6 /etc/proftpd/vpasswd | while read -r dir; do #mtime=0
if [ -d "$dir" ]; then #export IFS=$'\n'
du -s "$dir" | cut -f 1 > "$dir"/.size #for file in `find $dir -type f -not -name .size -not -name .last-modified`; do
chmod 644 "$dir"/.size # timestamp=`stat -c %Y $file`
fi # if [ $timestamp -gt $mtime ]; then
# mtime=$timestamp
# fi
#done
#unset IFS
#echo $mtime >$dir/.lastmodified
#chmod 644 $dir/.lastmodified
fi
done done

View file

@ -59,10 +59,10 @@ if [ $LOCAL_STATE = 'master' ]; then
# Try to connect to the remote server and check if it is a slave # Try to connect to the remote server and check if it is a slave
REMOTE_STATE=$(mktemp) REMOTE_STATE=$(mktemp)
if ssh $REMOTE_IP [ -e ~/state ]; then if ssh $REMOTE_IP [ -e ~/state ]; then
ssh $REMOTE_IP cat ~/state >$REMOTE_STATE ssh $REMOTE_IP cat ~/state >$REMOTE_STATE
elif [ $? -eq 255 ]; then elif [ $? -eq 255 ]; then
error "failed to connect to slave ($REMOTE_IP)!" error "failed to connect to slave ($REMOTE_IP)!"
exit 2 exit 2
else else
error "state file does not exist on slave!" error "state file does not exist on slave!"
exit 2 exit 2

View file

@ -1,4 +1,4 @@
<VirtualHost *:80 *:443> <VirtualHost *:80>
# FQDN principal # FQDN principal
ServerName SERVERNAME ServerName SERVERNAME
@ -7,11 +7,6 @@
# Repertoire principal # Repertoire principal
DocumentRoot HOME_DIR/XXX/www/ DocumentRoot HOME_DIR/XXX/www/
# SSL
# Apache < 2.4.30 (Jessie, Stretch) va générer une erreur si le fichier
# désigné sans regex n'existe pas. On contourne ça avec [f] à place de f
IncludeOptional /etc/apache2/ssl/XXX.con[f]
# Propriete du repertoire # Propriete du repertoire
<Directory HOME_DIR/XXX/www/> <Directory HOME_DIR/XXX/www/>
#Options +Indexes +SymLinksIfOwnerMatch #Options +Indexes +SymLinksIfOwnerMatch
@ -66,6 +61,8 @@
#php_admin_value max_execution_time 60 #php_admin_value max_execution_time 60
#php_admin_value upload_max_filesize 8M #php_admin_value upload_max_filesize 8M
#php_admin_flag allow_url_fopen Off #php_admin_flag allow_url_fopen Off
#php_value default_charset ISO-8859-15
php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f www-XXX" php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f www-XXX"
php_admin_value error_log "HOME_DIR/XXX/log/php.log"
php_admin_value open_basedir "/usr/share/php:HOME_DIR/XXX:/tmp" php_admin_value open_basedir "/usr/share/php:HOME_DIR/XXX:/tmp"
</VirtualHost>

View file

@ -1,41 +0,0 @@
server {
server_name www.DOMAIN DOMAIN;
listen 0.0.0.0:80;
listen [::]:80;
# listen 0.0.0.0:443 ssl http2;
# listen [::]:443 ssl http2;
#
# # Redirect HTTP to HTTPS
# if ( $scheme = http ) {
# return 301 https://$server_name$request_uri;
# }
#
# include /etc/nginx/ssl/LOGIN.conf;
# Redirect alias to main server_name
if ($http_host != "www.DOMAIN") {
return 301 $scheme://www.DOMAIN$request_uri;
}
access_log /home/LOGIN/log/access.log;
error_log /home/LOGIN/log/error.log;
root /home/LOGIN/www;
index index.html index.php;
# Set X-Forwarded-For, when you use reverse proxy such as Varnish.
#set_real_ip_from 127.0.0.1;
#real_ip_header X-Forwarded-For;
location / {
try_files $uri $uri/ /index.php?$args;
# Symphony
#try_files $uri /app.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php-fpm-LOGIN.sock;
}
}

View file

@ -40,7 +40,7 @@ config_file="/etc/evolinux/web-add.conf"
[ -r $config_file ] && . $config_file [ -r $config_file ] && . $config_file
usage() { usage() {
cat <<EOT >&2 cat <<EOT >&2
Usage: $0 COMMAND [ARG] Usage: $0 COMMAND [ARG]
@ -97,8 +97,8 @@ EOT
# Affiche un message d'erreur de validation # Affiche un message d'erreur de validation
# #
in_error() { in_error() {
msg=$1 msg=$1
cat >&2 <<EOT cat >&2 <<EOT
*** ***
Erreur : $msg Erreur : $msg
*** ***
@ -106,55 +106,55 @@ EOT
} }
gen_random_passwd() { gen_random_passwd() {
apg -c /dev/urandom -n1 -E oOlL10\&\\\/\"\' apg -c /dev/urandom -n1 -E oOlL10\&\\\/\"\'
} }
validate_login() { validate_login() {
login=$1 login=$1
length=${#login} length=${#login}
if [ $length -lt 3 ]; then if [ $length -lt 3 ]; then
in_error "Le login doit contenir plus de 2 caracteres" in_error "Le login doit contenir plus de 2 caracteres"
return 1 return 1
fi fi
if [ $length -gt $MAX_LOGIN_CHAR ]; then if [ $length -gt $MAX_LOGIN_CHAR ]; then
in_error "Le login ne doit pas contenir plus de $MAX_LOGIN_CHAR caracteres" in_error "Le login ne doit pas contenir plus de $MAX_LOGIN_CHAR caracteres"
return 1 return 1
fi fi
} }
validate_passwd() { validate_passwd() {
passwd=$1 passwd=$1
length=${#passwd} length=${#passwd}
if [ $length -lt 6 ] && [ $length -gt 0 ]; then if [ $length -lt 6 ] && [ $length -gt 0 ]; then
in_error "Le mot de passe doit avoir au moins 6 caracteres" in_error "Le mot de passe doit avoir au moins 6 caracteres"
return 1 return 1
fi fi
} }
validate_dbname() { validate_dbname() {
dbname=$1 dbname=$1
# aandre 18/06 # aandre 18/06
# if mysql -ss -e "show databases" | grep "^$dbname$" >/dev/null; then # if mysql -ss -e "show databases" | grep "^$dbname$" >/dev/null; then
# in_error "Base de données déjà existante" # in_error "Base de données déjà existante"
# return 1 # return 1
# fi # fi
} }
validate_wwwdomain() { validate_wwwdomain() {
wwwdomain=$1 wwwdomain=$1
if [ -z "$wwwdomain" ]; then if [ -z "$wwwdomain" ]; then
in_error "Le nom de domaine est obligatoire" in_error "Le nom de domaine est obligatoire"
return 1 return 1
fi fi
return 0 return 0
} }
validate_mail() { validate_mail() {
return 0 return 0
} }
validate_replmode() { validate_replmode() {
@ -191,23 +191,23 @@ validate_replinterval() {
} }
step_ok() { step_ok() {
msg=$1 msg=$1
echo "[OK] $msg" echo "[OK] $msg"
} }
create_www_accounts() { create_www_accounts() {
CMD_MASTER="$SSH -T $SSH_USER@$in_master" CMD_MASTER="$SSH -T $SSH_USER@$in_master"
CMD_SLAVE="$SSH -T $SSH_USER@$in_slave" CMD_SLAVE="$SSH -T $SSH_USER@$in_slave"
# On verifie que le compte n'existe pas sur master et slave # On verifie que le compte n'existe pas sur master et slave
if [ -n "$($CMD_MASTER cut -d: -f1 /etc/passwd| grep ^$in_login$)" ]; then if [ -n "$($CMD_MASTER cut -d: -f1 /etc/passwd| grep ^$in_login$)" ]; then
in_error "Le compte $in_login existe sur $in_master"; in_error "Le compte $in_login existe sur $in_master";
exit 1; exit 1;
fi fi
if [ $in_slave != "null" ]; then if [ $in_slave != "null" ]; then
if [ -n "$($CMD_SLAVE cut -d: -f1 /etc/passwd| grep ^$in_login$)" ]; then if [ -n "$($CMD_SLAVE cut -d: -f1 /etc/passwd| grep ^$in_login$)" ]; then
@ -217,13 +217,13 @@ create_www_accounts() {
fi fi
# Trouver un UID valide et commun pour le compte cree sur Master et Slave # Trouver un UID valide et commun pour le compte cree sur Master et Slave
last_uid_master=$($CMD_MASTER $LAST_UID) last_uid_master=$($CMD_MASTER $LAST_UID)
if [ -z "$last_uid_master" ]; then if [ -z "$last_uid_master" ]; then
echo "error while fetching uid in master"; echo "error while fetching uid in master";
return 1 return 1
fi fi
if [ $in_slave != "null" ]; then if [ $in_slave != "null" ]; then
last_uid_slave=$($CMD_SLAVE $LAST_UID) last_uid_slave=$($CMD_SLAVE $LAST_UID)
@ -247,19 +247,19 @@ create_www_accounts() {
uid=$(($last_uid_master + 1)) uid=$(($last_uid_master + 1))
fi fi
echo "UID libre: $uid" echo "UID libre: $uid"
# options mysql # options mysql
opts_mysql=''; opts_mysql='';
[ -n "$in_dbname" ] && opts_mysql="-m $in_dbname -P '$in_dbpasswd'" [ -n "$in_dbname" ] && opts_mysql="-m $in_dbname -P '$in_dbpasswd'"
# Creation web account on Master # Creation web account on Master
echo "MASTER: $CMD_MASTER $WEBADD add -p '$in_passwd' $opts_mysql -l $in_mail -y -u $uid -g $uid -U $(($uid + 1)) $in_login $in_wwwdomain" echo "MASTER: $CMD_MASTER $WEBADD add -p '$in_passwd' $opts_mysql -l $in_mail -y -u $uid -g $uid -U $(($uid + 1)) $in_login $in_wwwdomain"
$CMD_MASTER $WEBADD add -p \'$in_passwd\' $opts_mysql -l $in_mail -y -u $uid -g $uid -U $(($uid + 1)) $in_login $in_wwwdomain || (in_error "creation du compte master sur $in_master: $?" && exit 1) $CMD_MASTER $WEBADD add -p \'$in_passwd\' $opts_mysql -l $in_mail -y -u $uid -g $uid -U $(($uid + 1)) $in_login $in_wwwdomain || (in_error "creation du compte master sur $in_master: $?" && exit 1)
# Creation web account on Slave # Creation web account on Slave
if [ $in_slave != "null" ]; then if [ $in_slave != "null" ]; then
@ -334,10 +334,10 @@ ENDSSH
sudo -u $in_login lsyncd ~$in_login/www $in_slave:www sudo -u $in_login lsyncd ~$in_login/www $in_slave:www
ENDSSH ENDSSH
# Pour les mails # Pour les mails
# La réplication se fait au niveau du domaine (réplication de tout # La réplication se fait au niveau du domaine (réplication de tout
# /home/vmail/example.com/). # /home/vmail/example.com/).
domain=$(remove_subdomain $wwwdomain) domain=$(remove_subdomain $wwwdomain)
$CMD_MASTER <<ENDSSH $CMD_MASTER <<ENDSSH
if [ ! -d ~$VMAIL_USER/$domain ]; then if [ ! -d ~$VMAIL_USER/$domain ]; then
mkdir ~$VMAIL_USER/$domain mkdir ~$VMAIL_USER/$domain
chown $VMAIL_USER:$VMAIL_USER ~$VMAIL_USER/$domain chown $VMAIL_USER:$VMAIL_USER ~$VMAIL_USER/$domain
@ -400,18 +400,18 @@ ENDSSH
} }
op_del() { op_del() {
if [ $# -lt 3 ]; then if [ $# -lt 3 ]; then
usage usage
exit 1 exit 1
else else
login=$1 login=$1
master=$2 master=$2
slave=$3 slave=$3
if [ $# -eq 4 ]; then if [ $# -eq 4 ]; then
dbname=$4 dbname=$4
fi fi
fi fi
if [ $slave != "null" ]; then if [ $slave != "null" ]; then
echo "Deleting account $login on $master and $slave. Continue ?" echo "Deleting account $login on $master and $slave. Continue ?"
@ -420,14 +420,14 @@ op_del() {
fi fi
read read
CMD_MASTER="$SSH $SSH_USER@$master" CMD_MASTER="$SSH $SSH_USER@$master"
CMD_SLAVE="$SSH $SSH_USER@$slave" CMD_SLAVE="$SSH $SSH_USER@$slave"
# check account exist on master and slave # check account exist on master and slave
if [ -z "$($CMD_MASTER cut -d: -f1 /etc/passwd| grep ^$login$)" ]; then if [ -z "$($CMD_MASTER cut -d: -f1 /etc/passwd| grep ^$login$)" ]; then
echo "Account $login doesn't exist on $master"; echo "Account $login doesn't exist on $master";
exit 1; exit 1;
fi fi
if [ $slave != "null" ]; then if [ $slave != "null" ]; then
if [ -z "$($CMD_SLAVE cut -d: -f1 /etc/passwd| grep ^$login$)" ]; then if [ -z "$($CMD_SLAVE cut -d: -f1 /etc/passwd| grep ^$login$)" ]; then
@ -436,12 +436,12 @@ op_del() {
fi fi
fi fi
yes | $CMD_MASTER $WEBADD del $login $dbname yes | $CMD_MASTER $WEBADD del $login $dbname
if [ $slave != "null" ]; then if [ $slave != "null" ]; then
yes | $CMD_SLAVE $WEBADD del $login $dbname yes | $CMD_SLAVE $WEBADD del $login $dbname
fi fi
DATE=$(date +"%Y-%m-%d") DATE=$(date +"%Y-%m-%d")
if [ $slave != "null" ]; then if [ $slave != "null" ]; then
echo "$DATE [web-add-cluster.sh] $login deleted from $master and $slave" >> /var/log/evolix.log echo "$DATE [web-add-cluster.sh] $login deleted from $master and $slave" >> /var/log/evolix.log
else else
@ -460,8 +460,8 @@ op_aliasadd() {
master=$3 master=$3
slave=$4 slave=$4
CMD_MASTER="$SSH $SSH_USER@$master" CMD_MASTER="$SSH $SSH_USER@$master"
CMD_SLAVE="$SSH $SSH_USER@$slave" CMD_SLAVE="$SSH $SSH_USER@$slave"
$CMD_MASTER $WEBADD add-alias $vhost $alias $CMD_MASTER $WEBADD add-alias $vhost $alias
@ -469,7 +469,7 @@ op_aliasadd() {
$CMD_SLAVE $WEBADD add-alias $vhost $alias $CMD_SLAVE $WEBADD add-alias $vhost $alias
fi fi
DATE=$(date +"%Y-%m-%d") DATE=$(date +"%Y-%m-%d")
if [ $slave != "null" ]; then if [ $slave != "null" ]; then
echo "$DATE [web-add-cluster.sh] $alias added to $vhost on $master and $slave" >> /var/log/evolix.log echo "$DATE [web-add-cluster.sh] $alias added to $vhost on $master and $slave" >> /var/log/evolix.log
else else
@ -488,8 +488,8 @@ op_aliasdel() {
master=$3 master=$3
slave=$4 slave=$4
CMD_MASTER="$SSH $SSH_USER@$master" CMD_MASTER="$SSH $SSH_USER@$master"
CMD_SLAVE="$SSH $SSH_USER@$slave" CMD_SLAVE="$SSH $SSH_USER@$slave"
$CMD_MASTER $WEBADD del-alias $vhost $alias $CMD_MASTER $WEBADD del-alias $vhost $alias
@ -497,7 +497,7 @@ op_aliasdel() {
$CMD_SLAVE $WEBADD del-alias $vhost $alias $CMD_SLAVE $WEBADD del-alias $vhost $alias
fi fi
DATE=$(date +"%Y-%m-%d") DATE=$(date +"%Y-%m-%d")
if [ $slave != "null" ]; then if [ $slave != "null" ]; then
echo "$DATE [web-add-cluster.sh] $alias deleted from $vhost on $master and $slave" >> /var/log/evolix.log echo "$DATE [web-add-cluster.sh] $alias deleted from $vhost on $master and $slave" >> /var/log/evolix.log
else else
@ -509,148 +509,148 @@ op_aliasdel() {
arg_processing() { arg_processing() {
# Détermination de la commande # Détermination de la commande
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
usage usage
else else
commandname=$1 commandname=$1
shift shift
case "$commandname" in case "$commandname" in
add) add)
op_add $* op_add $*
;; ;;
del) del)
op_del $* op_del $*
;; ;;
list-vhost) list-vhost)
op_listvhost $* op_listvhost $*
;; ;;
add-alias) add-alias)
op_aliasadd $* op_aliasadd $*
;; ;;
del-alias) del-alias)
op_aliasdel $* op_aliasdel $*
;; ;;
*) *)
usage usage
;; ;;
esac esac
fi fi
} }
op_listvhost() { op_listvhost() {
if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
configlist="$VHOST_PATH/$1"; configlist="$VHOST_PATH/$1";
else else
configlist="$VHOST_PATH/*"; configlist="$VHOST_PATH/*";
fi fi
for configfile in $configlist; do for configfile in $configlist; do
if [ -r "$configfile" ]; then if [ -r "$configfile" ]; then
servername=`awk '/^[[:space:]]*ServerName (.*)/ { print $2 }' $configfile | head -n 1` servername=`awk '/^[[:space:]]*ServerName (.*)/ { print $2 }' $configfile | head -n 1`
serveraliases=`perl -ne 'print $1 if /^[[:space:]]*ServerAlias (.*)/' $configfile | head -n 1` serveraliases=`perl -ne 'print $1 if /^[[:space:]]*ServerAlias (.*)/' $configfile | head -n 1`
serveraliases=`echo $serveraliases | sed 's/ \+/, /g'` serveraliases=`echo $serveraliases | sed 's/ \+/, /g'`
userid=`awk '/^[[:space:]]*AssignUserID.*/ { print $3 }' $configfile | head -n 1` userid=`awk '/^[[:space:]]*AssignUserID.*/ { print $3 }' $configfile | head -n 1`
if [ "$servername" ] && [ "$userid" ]; then if [ "$servername" ] && [ "$userid" ]; then
configid=`basename $configfile` configid=`basename $configfile`
echo "$userid:$configid:$servername:$serveraliases" echo "$userid:$configid:$servername:$serveraliases"
fi fi
fi fi
done done
} }
op_add() { op_add() {
while getopts hyp:m:P:s:l:f:c: opt; do while getopts hyp:m:P:s:l:f:c: opt; do
case "$opt" in case "$opt" in
p) p)
in_passwd=$OPTARG in_passwd=$OPTARG
;; ;;
m) m)
in_dbname=$OPTARG in_dbname=$OPTARG
;; ;;
P) P)
in_dbpasswd=$OPTARG in_dbpasswd=$OPTARG
;; ;;
l) l)
in_mail=$OPTARG in_mail=$OPTARG
;; ;;
f) f)
in_replinterval=$OPTARG in_replinterval=$OPTARG
;; ;;
c) c)
in_replunit=$OPTARG in_replunit=$OPTARG
;; ;;
h) h)
usage usage
exit 1 exit 1
;; ;;
?) ?)
usage usage
exit 1 exit 1
;; ;;
esac esac
done done
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
if [ $# -ne 5 ]; then if [ $# -ne 5 ]; then
usage usage
exit 1 exit 1
fi fi
in_login=$1 in_login=$1
in_wwwdomain=$2 in_wwwdomain=$2
in_master=$3 in_master=$3
in_slave=$4 in_slave=$4
in_replmode=$5 in_replmode=$5
# in_master doit etre different d'in_slave # in_master doit etre different d'in_slave
[ "$in_master" = "$in_slave" ] && in_slave="null"; [ "$in_master" = "$in_slave" ] && in_slave="null";
validate_login $in_login || exit 1 validate_login $in_login || exit 1
[ -z "$in_passwd" ] && in_passwd=`gen_random_passwd` [ -z "$in_passwd" ] && in_passwd=`gen_random_passwd`
validate_passwd $in_passwd || exit 1 validate_passwd $in_passwd || exit 1
if [ -n "$in_dbname" ]; then if [ -n "$in_dbname" ]; then
validate_dbname $in_dbname || exit 1 validate_dbname $in_dbname || exit 1
if [ -z "$in_dbpasswd" ]; then if [ -z "$in_dbpasswd" ]; then
in_dbpasswd=`gen_random_passwd` in_dbpasswd=`gen_random_passwd`
validate_passwd $in_dbpasswd || exit 1 validate_passwd $in_dbpasswd || exit 1
echo "validate mysql passwd $in_dbpasswd"; echo "validate mysql passwd $in_dbpasswd";
fi fi
echo " ? validate mysql passwd $in_dbpasswd"; echo " ? validate mysql passwd $in_dbpasswd";
fi fi
validate_wwwdomain $in_wwwdomain || exit 1 validate_wwwdomain $in_wwwdomain || exit 1
[ -z "$in_mail" ] && in_mail=$CONTACT_MAIL [ -z "$in_mail" ] && in_mail=$CONTACT_MAIL
validate_mail $in_mail || exit 1 validate_mail $in_mail || exit 1
validate_replmode $in_replmode || exit 1 validate_replmode $in_replmode || exit 1
if [ $in_replmode = "deferred" ]; then if [ $in_replmode = "deferred" ]; then
validate_replinterval $in_replinterval $in_replunit || exit 1 validate_replinterval $in_replinterval $in_replunit || exit 1
fi fi
echo echo
echo "----------------------------------------------" echo "----------------------------------------------"
echo "Nom du compte : $in_login" echo "Nom du compte : $in_login"
echo "Mot de passe : $in_passwd" echo "Mot de passe : $in_passwd"
if [ -n "$in_dbname" ]; then if [ -n "$in_dbname" ]; then
echo "Base de données MySQL : $in_dbname" echo "Base de données MySQL : $in_dbname"
echo "Mot de passe MySQL : $in_dbpasswd" echo "Mot de passe MySQL : $in_dbpasswd"
fi fi
echo "Nom de domaine : $in_wwwdomain" echo "Nom de domaine : $in_wwwdomain"
echo "IP compte master : $in_master" echo "IP compte master : $in_master"
echo "IP compte slave : $in_slave" echo "IP compte slave : $in_slave"
echo "Mode de replication : $in_replmode" echo "Mode de replication : $in_replmode"
echo "Envoi du mail récapitulatif à : $in_mail" echo "Envoi du mail récapitulatif à : $in_mail"
echo "----------------------------------------------" echo "----------------------------------------------"
echo echo
create_www_accounts create_www_accounts
echo echo
echo " => Compte $in_login créé avec succès" echo " => Compte $in_login créé avec succès"
echo echo
} }
remove_subdomain() { remove_subdomain() {

View file

@ -1,649 +0,0 @@
#!/bin/bash
#
# Gestion des comptes web et des hôtes virtuels Nginx
#
# Copyright (c) 2013 Evolix - Tous droits reserves
#
# TODO
# - Gestion des quota
# - Possibilité de créer un compte FTP-only
# - Pouvoir spécifier le CONTACT_MAIL dans un fichier de conf
# - Traduire usage() en francais, ou l'inverse ??
set -e
HOME="/root"
CONTACT_MAIL="equipe@evolix.fr"
WWWBOUNCE_MAIL="equipe@evolix.fr"
LOCAL_SCRIPT="/usr/share/scripts/evoadmin/web-add.local.sh"
PRE_LOCAL_SCRIPT="/usr/share/scripts/evoadmin/web-add.pre-local.sh"
TPL_VHOST="/usr/share/scripts/evoadmin/vhost-nginx.tpl"
TPL_AWSTATS="/usr/share/scripts/evoadmin/awstats.XXX.conf"
TPL_MAIL="/usr/share/scripts/evoadmin/web-mail-nginx.tpl"
TPL_FPM="/usr/share/scripts/evoadmin/fpm.conf.tpl"
VHOST_PATH="/etc/nginx/sites-available"
FPM_PATH="/etc/php/7.0/fpm/pool.d"
FPM_SERVICE_NAME="php7.0-fpm"
MAX_LOGIN_CHAR=16
HOME_DIR="/home"
MYSQL_CREATE_DB_OPTS=""
# Utiliser ce fichier pour redefinir la valeur des variables ci-dessus
config_file="/etc/evolinux/web-add.conf"
[ -r $config_file ] && . $config_file
usage() {
cat <<EOT >&2
Usage: $0 COMMAND [ARG]
add [ [OPTIONS] LOGIN WWWDOMAIN ]
Create web account LOGIN.
No arguments starts interactive mode.
-p PASSWD
FTP and SFTP password (default : random)
-m DBNAME
Name of MySQL database (default : same as account)
-P DBPASSWD
MySQL password (default : random)
-l MAIL
Send summary email to MAIL
-k SSHKEY
Use this SSH key
-u UID
Force account UID (only in command line)
-g GID
Force account GID (only in command line)
-U UID
Force www-account UID (only in command line)
-y
Don't ask for confirmation
Example : web-add.sh add -m testdb testlogin testdomain.com
del LOGIN [DBNAME]
Delete account and all files related (Apache, Awstats, etc)
Archive home directory.
Remove MySQL database only if DBNAME is specified.
list-vhost LOGIN
List Apache vhost for user LOGIN
EOT
}
#
# Affiche un message d'erreur de validation
#
in_error() {
msg=$1
cat >&2 <<EOT
***
Erreur : $msg
***
EOT
}
gen_random_passwd() {
apg -c /dev/urandom -n1 -E oOlL10\&\\\/\"\'
}
validate_login() {
login=$1
length=${#login}
if [ $length -lt 3 ]; then
in_error "Le login doit contenir plus de 2 caracteres"
return 1
fi
if [ $length -gt $MAX_LOGIN_CHAR ]; then
in_error "Le login ne doit pas contenir plus de $MAX_LOGIN_CHAR caracteres"
return 1
fi
}
validate_passwd() {
passwd=$1
length=${#passwd}
if [ $length -lt 6 ] && [ $length -gt 0 ]; then
in_error "Le mot de passe doit avoir au moins 6 caracteres"
return 1
fi
}
validate_dbname() {
dbname=$1
if mysql -ss -e "show databases" | grep "^$dbname$" >/dev/null; then
in_error "Base de données déjà existante"
return 1
fi
}
validate_wwwdomain() {
wwwdomain=$1
if [ -z "$wwwdomain" ]; then
in_error "Le nom de domaine est obligatoire"
return 1
fi
return 0
}
validate_mail() {
return 0
}
step_ok() {
msg=$1
echo "[OK] $msg"
}
create_www_account() {
# Vérifications
for filetocheck in $TPL_VHOST $TPL_AWSTATS $TPL_MAIL; do
if [ ! -f $filetocheck ]; then
in_error "Fichier inexistant : $filetocheck"
exit 1
fi
done
############################################################################
if [ -f $PRE_LOCAL_SCRIPT ]; then
source $PRE_LOCAL_SCRIPT
fi
step_ok "Exécution du pre-script spécifique"
############################################################################
if [ -z "$HOME_DIR_USER" ]; then
HOME_DIR_USER="$HOME_DIR/$in_login"
fi
############################################################################
if [ -d "$HOME_DIR_USER" ]; then
in_error "Ce compte existe deja (ou il a mal été effacé)"
return 1
fi
############################################################################
# Force UID GID if specified
[ -n "$in_uid" ] && OPT_UID="--uid" && OPT_UID_ARG="$in_uid"
[ -n "$in_gid" ] && OPT_GID="--gid" && OPT_GID_ARG="$in_gid"
[ -n "$in_wwwuid" ] && OPT_WWWUID="--uid" && OPT_WWWUID_ARG="$in_wwwuid"
############################################################################
/usr/sbin/adduser --gecos "User $in_login" --disabled-password "$in_login" \
--shell /bin/bash $OPT_UID $OPT_UID_ARG --force-badname \
--home "$HOME_DIR_USER" >/dev/null
[ -z "$in_sshkey" ] && echo "$in_login:$in_passwd" | chpasswd
[ -z "$in_sshkey" ] || [ -n "$HOME_DIR_USER" ] \
&& mkdir "$HOME_DIR_USER/.ssh" \
&& echo "$in_sshkey" > "$HOME_DIR_USER/.ssh/authorized_keys" \
&& chmod -R u=rwX,g=,o= "$HOME_DIR_USER/.ssh/authorized_keys" \
&& chown -R "$in_login":"$in_login" "$HOME_DIR_USER/.ssh"
# Adding user www-data to group $in_login.
# And primary group www-data for $in_login.
adduser www-data $in_login
usermod -g www-data $in_login
# Authorize user to connect by SSH.
sed -i "s/^AllowUsers .*/& $in_login/" /etc/ssh/sshd_config
/etc/init.d/ssh reload
step_ok "Création des utilisateurs"
############################################################################
echo "$login: $WWWBOUNCE_MAIL" >> /etc/aliases
newaliases
step_ok "Alias mail"
############################################################################
chmod 750 $HOME_DIR_USER/
# Répertoires par défaut
mkdir -p $HOME_DIR_USER/{log,www,awstats}
chown $in_login:$in_login $HOME_DIR_USER/www
chgrp $in_login $HOME_DIR_USER/{log,awstats}
chmod 750 $HOME_DIR_USER/{log,www,awstats}
# Ajout des logs par defaut
touch $HOME_DIR_USER/log/access.log
touch $HOME_DIR_USER/log/error.log
touch $HOME_DIR_USER/log/php.log
chgrp $in_login $HOME_DIR_USER/log/access.log
chgrp $in_login $HOME_DIR_USER/log/error.log
chown $in_login:$in_login $HOME_DIR_USER/log/php.log
chmod 640 $HOME_DIR_USER/log/access.log
chmod 640 $HOME_DIR_USER/log/error.log
chmod 640 $HOME_DIR_USER/log/php.log
step_ok "Création du répertoire personnel"
############################################################################
random=$RANDOM
cat $TPL_VHOST | \
sed -e "
s/DOMAIN/${in_wwwdomain}/g;
s/LOGIN/${in_login}/g;" > ${VHOST_PATH}/$in_login
# On active aussi example.com si le domaine commence par "www." comme
# www.example
# if echo $in_wwwdomain | grep '^www.' > /dev/null; then
# subweb=$(echo $in_wwwdomain | sed -e "s/www.//")
# sed -i -e "s/^\(.*\)#\(ServerAlias\).*$/\1\2 $subweb/" $vhostfile
# fi
ln -s /etc/nginx/sites-available/$in_login \
/etc/nginx/sites-enabled/$in_login
/etc/init.d/nginx restart
step_ok "Configuration de Nginx + restart"
############################################################################
cat $TPL_FPM | \
sed -e "s/SED_LOGIN/${in_login}/g;" > ${FPM_PATH}/${in_login}.conf
step_ok "Creation du pool PHP-FPM"
############################################################################
cat $TPL_AWSTATS | \
sed -e "s/XXX/$in_login/ ; s/SERVERNAME/$in_wwwdomain/ ; s#HOME_DIR#$HOME_DIR#" \
> /etc/awstats/awstats.$in_login.conf
chmod 644 /etc/awstats/awstats.$in_login.conf
VAR=`grep -v "^#" /etc/cron.d/awstats |tail -1 | cut -d " " -f1`
if [ "$VAR" = "" ] || [ $VAR -ge 59 ]; then
VAR=1
else
VAR=$(($VAR +1))
fi
echo "$VAR * * * * root umask 033; [ -x /usr/lib/cgi-bin/awstats.pl -a -f /etc/awstats/awstats.$in_login.conf -a -r $HOME_DIR_USER/log/access.log ] && /usr/lib/cgi-bin/awstats.pl -config=$in_login -update >/dev/null" >> /etc/cron.d/awstats
step_ok "Activation d'Awstats"
############################################################################
if [ "$in_dbname" ]; then
echo "CREATE DATABASE \`$in_dbname\` $MYSQL_CREATE_DB_OPTS;" | mysql
#echo "CREATE DATABASE \`staging_${in_dbname}\` $MYSQL_CREATE_DB_OPTS;" | mysql
echo "GRANT ALL PRIVILEGES ON \`$in_dbname\`.* TO \`$in_login\`@localhost IDENTIFIED BY '$in_dbpasswd';" | mysql
#echo "GRANT ALL PRIVILEGES ON \`staging_${in_dbname}\`.* TO \`$in_login\`@localhost IDENTIFIED BY '$in_dbpasswd';" | mysql
echo "FLUSH PRIVILEGES;" | mysql
my_cnf_file="$HOME_DIR_USER/.my.cnf"
cat >$my_cnf_file <<-EOT
[client]
user = $in_login
password = "$in_dbpasswd"
[mysql]
database = $in_dbname
EOT
chown $in_login $my_cnf_file
chmod 600 $my_cnf_file
step_ok "Création base de données et compte MySQL"
fi
############################################################################
cat $TPL_MAIL | \
sed -e "s/LOGIN/$in_login/g ; s/SERVERNAME/$in_wwwdomain/ ; s/PASSE1/$in_passwd/ ; s/PASSE2/$in_dbpasswd/ ; s/RANDOM/$random/ ; s/QUOTA/$quota/ ; s/RCPTTO/$in_mail/ ; s/DBNAME/$in_dbname/ ; s#HOME_DIR#$HOME_DIR#"| \
/usr/lib/sendmail -oi -t -f "$CONTACT_MAIL"
step_ok "Envoi du mail récapitulatif"
############################################################################
fpm_status=$(echo -n $in_login | md5sum | cut -d' ' -f1)
cat <<EOT> /etc/munin/plugin-conf.d/phpfpm_${in_login}_
[phpfpm_${in_login}_*]
env.url http://munin:%d/fpm_status_$fpm_status
env.ports 80
env.phpbin php-fpm
env.phppool $in_login
EOT
for name in average connections memory processes status; do
ln -s /usr/local/share/munin/plugins/phpfpm_${name} \
/etc/munin/plugins/phpfpm_${in_login}_${name}
done
mkdir -p /etc/nginx/evolinux.d/
cat <<EOT>> /etc/nginx/evolinux.d/munin-plugins.conf
# $in_login FPM Status page. Secret part is md5 of pool name.
location ~ ^/fpm_status_${fpm_status}$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm-${in_login}.sock;
fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name;
allow 127.0.0.1;
deny all;
}
EOT
sed -i "s#SED_STATUS#/fpm_status_${fpm_status}#" \
${FPM_PATH}/${in_login}.conf
/etc/init.d/nginx reload
/etc/init.d/${FPM_SERVICE_NAME} reload
/etc/init.d/munin-node restart
step_ok "Configuration plugin php-fpm pour munin"
############################################################################
if [ -f $LOCAL_SCRIPT ]; then
source $LOCAL_SCRIPT
fi
step_ok "Exécution du script spécifique"
############################################################################
DATE=$(date +"%Y-%m-%d")
echo "$DATE [web-add.sh] Ajout $in_login" >> /var/log/evolix.log
}
op_del() {
if [ $# -lt 1 ]; then
usage
exit 1
else
login=$1
if [ $# -eq 2 ]; then
dbname=$2
fi
fi
echo "Deleting account $login. Continue ?"
read
set -x
deluser www-data $login
userdel -f $login
groupdel $login
sed -i.bak "/^$login:/d" /etc/aliases
sed -i "s/^\(AllowUsers .*\)$login/\1/" /etc/ssh/sshd_config
/etc/init.d/ssh reload
if [ -d "$HOME_DIR/$login" ]; then
mv -i $HOME_DIR/$login $HOME_DIR/$login.`date '+%Y%m%d-%H%M%S'`.bak
else
echo "warning : $HOME_DIR/$login does not exist"
fi
rm ${FPM_PATH}/${login}.conf
rm /etc/nginx/sites-{available,enabled}/$login
rm /etc/awstats/awstats.$login.conf
rm /etc/munin/plugins/phpfpm_${login}*
sed -i.bak "/-config=$login/d" /etc/cron.d/awstats
nginx -t
set +x
if [ -n "$dbname" ]; then
echo "Deleting mysql DATABASE $dbname and mysql user $login. Continue ?"
read
set -x
echo "DROP DATABASE \`${dbname}\`; delete from mysql.user where User=\'${login}\' ; FLUSH PRIVILEGES;" | mysql
set +x
fi
}
arg_processing() {
# Détermination de la commande
if [ $# -lt 1 ]; then
usage
else
commandname=$1
shift
case "$commandname" in
add)
op_add $*
;;
del)
op_del $*
;;
list-vhost)
op_listvhost $*
;;
*)
usage
;;
esac
fi
}
op_listvhost() {
if [ $# -eq 1 ]; then
configlist="$VHOST_PATH/$1";
else
configlist="$VHOST_PATH/*";
fi
for configfile in $configlist; do
if [ -r "$configfile" ]; then
servername=`awk '/^[[:space:]]*ServerName (.*)/ { print $2 }' $configfile | head -n 1`
serveraliases=`perl -ne 'print $1 if /^[[:space:]]*ServerAlias (.*)/' $configfile | head -n 1`
serveraliases=`echo $serveraliases | sed 's/ \+/, /g'`
userid=`awk '/^[[:space:]]*AssignUserID.*/ { print $3 }' $configfile | head -n 1`
if [ "$servername" ] && [ "$userid" ]; then
configid=`basename $configfile`
echo "$userid:$configid:$servername:$serveraliases"
fi
fi
done
}
op_add() {
#
# Mode interactif
#
if [ $# -eq 0 ]; then
echo
echo "Ajout d'un compte WEB"
echo
until [ "$in_login" ]; do
echo -n "Entrez le login du nouveau compte : "
read tmp
if validate_login "$tmp"; then
in_login="$tmp"
fi
done
until [ "$in_passwd" ]; do
echo -n "Entrez le mot de passe FTP/SFTP/SSH (ou vide pour aleatoire) : "
read -s tmp
echo
if [ -z "$tmp" ]; then
tmp=`gen_random_passwd`
fi
if validate_passwd "$tmp"; then
in_passwd="$tmp"
fi
done
echo -n "Voulez-vous aussi un compte/base MySQL ? [Y|n] "
read confirm
if [ "$confirm" != "n" ] && [ "$confirm" != "N" ]; then
until [ "$in_dbname" ]; do
echo -n "Entrez le nom de la base de donnees ($in_login par defaut) : "
read tmp
if [ -z "$tmp" ]; then
tmp=$in_login
fi
if validate_dbname "$tmp"; then
in_dbname="$tmp"
fi
done
until [ "$in_dbpasswd" ]; do
echo -n "Entrez le mot de passe MySQL (ou vide pour aleatoire) : "
read -s tmp
echo
if [ -z "$tmp" ]; then
tmp=`gen_random_passwd`
fi
if validate_passwd "$tmp"; then
in_dbpasswd="$tmp"
fi
done
fi
until [ "$in_wwwdomain" ]; do
echo -n "Entrez le nom de domaine web (ex: foo.example.com) : "
read tmp
if validate_wwwdomain "$tmp"; then
in_wwwdomain="$tmp"
fi
done
until [ "$in_mail" ]; do
echo -n "Entrez votre adresse mail pour recevoir le mail de creation ($CONTACT_MAIL par défaut) : "
read tmp
if [ -z "$tmp" ]; then
tmp="$CONTACT_MAIL"
fi
if validate_mail "$tmp"; then
in_mail="$tmp"
fi
done
#
# Mode non interactif
#
else
while getopts hyp:m:P:w:l:k:u:g:U: opt; do
case "$opt" in
p)
in_passwd=$OPTARG
;;
m)
in_dbname=$OPTARG
;;
P)
in_dbpasswd=$OPTARG
;;
l)
in_mail=$OPTARG
;;
k)
in_sshkey=$OPTARG
;;
y)
force_confirm=1
;;
u)
in_uid=$OPTARG
;;
g)
in_gid=$OPTARG
;;
U)
in_wwwuid=$OPTARG
;;
h)
usage
exit 1
;;
?)
usage
exit 1
;;
esac
done
shift $(($OPTIND - 1))
if [ $# -ne 2 ]; then
usage
exit 1
else
in_login=$1
in_wwwdomain=$2
validate_login $in_login || exit 1
[ -z "$in_passwd" ] && [ -z "$in_sshkey" ] && in_passwd=`gen_random_passwd`
[ -z "$in_sshkey" ] && ( validate_passwd $in_passwd || exit 1 )
[ -n "$in_dbname" ] && ( validate_dbname $in_dbname || exit 1 )
[ -z "$in_dbpasswd" ] && [ -n "$in_dbname" ] && in_dbpasswd=`gen_random_passwd`
[ -n "$in_dbname" ] && ( validate_passwd $in_dbpasswd || exit 1 )
validate_wwwdomain $in_wwwdomain || exit 1
[ -z "$in_mail" ] && in_mail=$CONTACT_MAIL
validate_mail $in_mail || exit 1
fi
fi
echo
echo "----------------------------------------------"
echo "Nom du compte : $in_login"
echo "Mot de passe : $in_passwd"
if [ "$in_dbname" ]; then
echo "Base de données MySQL : $in_dbname"
echo "Mot de passe MySQL : $in_dbpasswd"
fi
echo "Nom de domaine : $in_wwwdomain"
echo "Envoi du mail récapitulatif à : $in_mail"
echo "----------------------------------------------"
echo
if [ -z "$force_confirm" ]; then
echo -n "Confirmer la création ? [y/N] : "
read tmp
echo
if [ "$tmp" != "y" ] && [ "$tmp" != "Y" ]; then
echo "Annulation..."
echo
exit 1
fi
fi
create_www_account
echo
echo " => Compte $in_login créé avec succès"
echo
}
# Point d'entrée
arg_processing $*

View file

@ -1,9 +1,10 @@
#!/bin/bash #!/bin/bash
# #
# Gestion des comptes web et des hôtes virtuels pour Apache et Nginx # Gestion des comptes web et des hôtes virtuels Apache
# #
# Copyright (c) 2009-2017 Evolix - Tous droits reserves # Copyright (c) 2009 Evolix - Tous droits reserves
# $Id$
# #
# TODO # TODO
@ -14,53 +15,28 @@
set -e set -e
VERSION="24.04"
HOME="/root" HOME="/root"
CONTACT_MAIL="jdoe@example.org" CONTACT_MAIL="jdoe@example.org"
WWWBOUNCE_MAIL="jdoe@example.org" WWWBOUNCE_MAIL="jdoe@example.org"
SCRIPTS_PATH="/usr/share/scripts/evoadmin" SCRIPTS_PATH="/usr/share/scripts/evoadmin"
LOCAL_SCRIPT="$SCRIPTS_PATH/web-add.local.sh" LOCAL_SCRIPT="$SCRIPTS_PATH/web-add.local.sh"
PRE_LOCAL_SCRIPT="$SCRIPTS_PATH/web-add.pre-local.sh" PRE_LOCAL_SCRIPT="$SCRIPTS_PATH/web-add.pre-local.sh"
TPL_VHOST="$SCRIPTS_PATH/vhost"
TPL_AWSTATS="$SCRIPTS_PATH/awstats.XXX.conf" TPL_AWSTATS="$SCRIPTS_PATH/awstats.XXX.conf"
SSH_GROUP="evolinux-ssh" TPL_MAIL="$SCRIPTS_PATH/web-mail.tpl"
HOST="$(hostname -f)" VHOST_PATH="/etc/apache2/sites-enabled/"
# Set to nginx if you use nginx and not apache
WEB_SERVER="apache"
if [ "$WEB_SERVER" == "apache" ]; then
VHOST_PATH="/etc/apache2/sites-available"
TPL_VHOST="$SCRIPTS_PATH/vhost"
TPL_MAIL="$SCRIPTS_PATH/web-mail.tpl"
elif [ "$WEB_SERVER" == "nginx" ]; then
VHOST_PATH="/etc/nginx/sites-available"
TPL_VHOST="$SCRIPTS_PATH/vhost-nginx.tpl"
TPL_MAIL="$SCRIPTS_PATH/web-mail-nginx.tpl"
else
echo "$WEB_SERVER is not apache nor nginx, exiting..."
exit 1
fi
# FPM
FPM_PATH="/etc/php/7.0/fpm/pool.d"
FPM_SERVICE_NAME="php7.0-fpm"
TPL_FPM="$SCRIPTS_PATH/fpm.conf.tpl"
MAX_LOGIN_CHAR=16 MAX_LOGIN_CHAR=16
HOME_DIR="/home" HOME_DIR="/home"
MYSQL_CREATE_DB_OPTS="" MYSQL_CREATE_DB_OPTS=""
MYSQL_OPTS="" SSH_GROUP="evolinux-ssh"
PHP_VERSIONS=()
# Utiliser ce fichier pour redefinir la valeur des variables ci-dessus # Utiliser ce fichier pour redefinir la valeur des variables ci-dessus
config_file="/etc/evolinux/web-add.conf" config_file="/etc/evolinux/web-add.conf"
# shellcheck source=/etc/evolinux/web-add.conf
[ -r $config_file ] && . $config_file [ -r $config_file ] && . $config_file
usage() { usage() {
cat <<EOT >&2 cat <<EOT >&2
Evoadmin web tooling - Version $VERSION
Usage: $0 COMMAND [ARG] Usage: $0 COMMAND [ARG]
add [ [OPTIONS] LOGIN WWWDOMAIN ] add [ [OPTIONS] LOGIN WWWDOMAIN ]
@ -95,34 +71,18 @@ add [ [OPTIONS] LOGIN WWWDOMAIN ]
-y -y
Don't ask for confirmation Don't ask for confirmation
-r Example : web-add.sh add -m testdb testlogin testdomain.com
PHP version (without dot)
-q del LOGIN [DBNAME]
Filesystem quota in GiB, in the form <quota soft>:<quota hard>
Example : web-add.sh add -m testdb -r 56 testlogin testdomain.com
del [ [OPTIONS] LOGIN [DBNAME] ]
Delete account and all files related (Apache, Awstats, etc) Delete account and all files related (Apache, Awstats, etc)
Archive home directory. Archive home directory.
Remove MySQL database only if DBNAME is specified. Remove MySQL database only if DBNAME is specified.
-y
Don't ask for confirmation
Example : web-add.sh del -y testlogin testdatabase
list-vhost LOGIN list-vhost LOGIN
List Apache vhost for user LOGIN List Apache vhost for user LOGIN
check-vhosts -f
List suggested changes to vhosts, apply fixes with -f
add-alias VHOST ALIAS add-alias VHOST ALIAS
Add a ServerAlias to an Apache vhost Add a ServerAlias to an Apache vhost
@ -131,53 +91,6 @@ del-alias VHOST ALIAS
Del a ServerAlias from an Apache vhost Del a ServerAlias from an Apache vhost
update-servername VHOST SERVERNAME OLD_SERVERNAME
Replace the OLD_SERVERNAME with the SERVERNAME for an Apache vhost
Also apply to rewrite rules
check-occurence NAME
List all occurences of NAME in vhosts
list-user-itk LOGIN
List the assigned ITK user for the LOGIN specified
enable-user-itk LOGIN
Enable the assigned ITK user for the LOGIN specified
disable-user-itk LOGIN
Disable the assigned ITK user for the LOGIN specified
setphpversion LOGIN VERSION
Change PHP version for LOGIN
setquota LOGIN QUOTA_SOFT:QUOTA_HARD
Change quotas for LOGIN
manage-http-challenge-file [CREATE | DELETE]
Create or delete a dummy file for the Let's Encrypt HTTP challenge
The default directory is /var/lib/letsencrypt/.well-known/
generate-csr LOGIN DOMAINS
Generate the request for the Let's Encrypt certificate
generate-ssl-certificate LOGIN [false]
Generate the Let's Encrypt certificate
Run in TEST mode unless "false" is used
version
Obtain the script version
EOT EOT
} }
@ -185,8 +98,8 @@ EOT
# Affiche un message d'erreur de validation # Affiche un message d'erreur de validation
# #
in_error() { in_error() {
msg=$1 msg=$1
cat >&2 <<EOT cat >&2 <<EOT
*** ***
Erreur : $msg Erreur : $msg
*** ***
@ -194,354 +107,200 @@ EOT
} }
gen_random_passwd() { gen_random_passwd() {
apg -c /dev/urandom -MNCL -n1 -m18 -E oOlL10 apg -c /dev/urandom -n1 -E oOlL10\&\\\/\"\'
} }
validate_login() { validate_login() {
login=$1 login=$1
length=${#login} length=${#login}
if [ "$length" -lt 3 ]; then if [ $length -lt 3 ]; then
in_error "Le login doit contenir plus de 2 caracteres" in_error "Le login doit contenir plus de 2 caracteres"
return 1 return 1
fi fi
if [ "$length" -gt $MAX_LOGIN_CHAR ]; then if [ $length -gt $MAX_LOGIN_CHAR ]; then
in_error "Le login ne doit pas contenir plus de $MAX_LOGIN_CHAR caracteres" in_error "Le login ne doit pas contenir plus de $MAX_LOGIN_CHAR caracteres"
return 1 return 1
fi fi
} }
validate_passwd() { validate_passwd() {
passwd=$1 passwd=$1
length=${#passwd} length=${#passwd}
if [ "$length" -lt 6 ] && [ "$length" -gt 0 ]; then if [ $length -lt 6 ] && [ $length -gt 0 ]; then
in_error "Le mot de passe doit avoir au moins 6 caracteres" in_error "Le mot de passe doit avoir au moins 6 caracteres"
return 1 return 1
fi fi
} }
validate_dbname() { validate_dbname() {
dbname=$1 dbname=$1
if mysql $MYSQL_OPTS -ss -e "show databases" | grep "^$dbname$" >/dev/null; then if mysql -ss -e "show databases" | grep "^$dbname$" >/dev/null; then
in_error "Base de données déjà existante" in_error "Base de données déjà existante"
return 1 return 1
fi fi
} }
validate_wwwdomain() { validate_wwwdomain() {
wwwdomain=$1 wwwdomain=$1
if [ -z "$wwwdomain" ]; then if [ -z "$wwwdomain" ]; then
in_error "Le nom de domaine est obligatoire" in_error "Le nom de domaine est obligatoire"
return 1 return 1
fi fi
case "$wwwdomain" in return 0
*'/'*)
in_error "Le caractère / n'est pas autorisé. Avez-vous confondu nom de domaine (example.com) et URL (https://example.com) ?"
return 1;;
*':'*)
in_error "Le caractère : n'est pas autorisé. Avez-vous confondu nom de domaine (example.com) et URL (https://example.com) ?"
return 1;;
esac
return 0
} }
validate_mail() { validate_mail() {
return 0 return 0
}
validate_phpversion() {
php_version="$1"
if [[ ! " ${PHP_VERSIONS[*]} " =~ ${php_version} ]]; then
in_error "Version de PHP incorrecte."
return 1
fi
}
validate_quota() {
quota_soft=$(echo "$1" |cut -f 1 -d:)
quota_hard=$(echo "$1" |cut -f 2 -d:)
if [ -z "$quota_soft" ] || [ -z "$quota_hard" ]; then
in_error "Le quota soft et le quota hard doivent être spécifiés sous la forme <quota soft>:<quota hard>."
return 1
elif [ "$quota_soft" -gt "$quota_hard" ]; then
in_error "Le quota hard doit être plus grand que le quota soft."
return 1
fi
} }
step_ok() { step_ok() {
msg=$1 msg=$1
echo "[OK] $msg" echo "[OK] $msg"
} }
create_www_account() { create_www_account() {
# Vérifications # Vérifications
for filetocheck in $TPL_VHOST $TPL_AWSTATS $TPL_MAIL; do for filetocheck in $TPL_VHOST $TPL_AWSTATS $TPL_MAIL; do
if [ ! -f $filetocheck ]; then if [ ! -f $filetocheck ]; then
in_error "Fichier inexistant : $filetocheck" in_error "Fichier inexistant : $filetocheck"
exit 1 exit 1
fi
done
############################################################################
if [ -f $PRE_LOCAL_SCRIPT ]; then
# shellcheck source=/usr/share/scripts/evoadmin/web-add.pre-local.sh
source $PRE_LOCAL_SCRIPT
fi fi
done
step_ok "Exécution du pre-script spécifique" ############################################################################
############################################################################ if [ -f $PRE_LOCAL_SCRIPT ]; then
source $PRE_LOCAL_SCRIPT
fi
if [ -z "$HOME_DIR_USER" ]; then step_ok "Exécution du pre-script spécifique"
HOME_DIR_USER="$HOME_DIR/$in_login"
############################################################################
if [ -z "$HOME_DIR_USER" ]; then
HOME_DIR_USER="$HOME_DIR/$in_login"
fi
############################################################################
if [ -d "$HOME_DIR_USER" ]; then
in_error "Ce compte existe deja (ou il a mal été effacé)"
return 1
fi
############################################################################
# Force UID GID if specified
[ -n "$in_uid" ] && OPT_UID="--uid" && OPT_UID_ARG="$in_uid"
[ -n "$in_gid" ] && OPT_GID="--gid" && OPT_GID_ARG="$in_gid"
[ -n "$in_wwwuid" ] && OPT_WWWUID="--uid" && OPT_WWWUID_ARG="$in_wwwuid"
############################################################################
/usr/sbin/adduser --gecos "User $in_login" --disabled-password "$in_login" --shell /bin/bash $OPT_UID $OPT_UID_ARG --force-badname --home "$HOME_DIR_USER" >/dev/null
[ -z "$in_sshkey" ] && echo "$in_login:$in_passwd" | chpasswd --md5
[ -z "$in_sshkey" ] || [ -n "$HOME_DIR_USER" ] && mkdir "$HOME_DIR_USER/.ssh" && echo "$in_sshkey" > "$HOME_DIR_USER/.ssh/authorized_keys" \
&& chmod -R u=rwX,g=,o= "$HOME_DIR_USER/.ssh/authorized_keys" && chown -R "$in_login":"$in_login" "$HOME_DIR_USER/.ssh"
/usr/sbin/adduser --disabled-password --home $HOME_DIR_USER/www \
--no-create-home --shell /bin/false --gecos "WWW $in_login" www-$in_login $OPT_WWWUID $OPT_WWWUID_ARG --ingroup $in_login --force-badname >/dev/null
if grep -qE '^AllowGroups' /etc/ssh/sshd_config; then
if ! grep -qE "^AllowGroups(\s+\S+)*(\s+$SSH_GROUP)" /etc/ssh/sshd_config; then
sed -i "s/^AllowGroups .*/& $SSH_GROUP/" /etc/ssh/sshd_config
groupadd --force $SSH_GROUP
fi fi
usermod -a -G $SSH_GROUP "$in_login"
elif grep -qE '^AllowUsers' /etc/ssh/sshd_config; then
sed -i "s/^AllowUsers .*/& $in_login/" /etc/ssh/sshd_config
fi
/etc/init.d/ssh reload
############################################################################ step_ok "Création des utilisateurs"
if [ -d "$HOME_DIR_USER" ]; then ############################################################################
in_error "Ce compte existe deja (ou il a mal été effacé)"
return 1
fi
# Create user and force UID / GID if specified echo "www-$login: $login" >> /etc/aliases
/usr/sbin/adduser \ echo "$login: $WWWBOUNCE_MAIL" >> /etc/aliases
--gecos "User $in_login" \ newaliases
--disabled-password \
"$in_login" \
--shell /bin/bash \
${in_uid:+'--uid' "$in_uid"} \
${in_gid:+'--gid' "$in_gid"} \
--force-badname \
--home "$HOME_DIR_USER" >/dev/null
[ -z "$in_sshkey" ] \ step_ok "Alias mail"
&& echo "$in_login:$in_passwd" | chpasswd
[ -z "$in_sshkey" ] \ ############################################################################
|| [ -n "$HOME_DIR_USER" ] \
&& mkdir "$HOME_DIR_USER/.ssh" \
&& echo "$in_sshkey" > "$HOME_DIR_USER/.ssh/authorized_keys" \
&& chmod -R u=rwX,g=,o= "$HOME_DIR_USER/.ssh/authorized_keys" \
&& chown -R "$in_login":"$in_login" "$HOME_DIR_USER/.ssh"
if [ "$WEB_SERVER" == "apache" ]; then chmod 750 $HOME_DIR_USER/
# Create www user and force UID if specified
/usr/sbin/adduser \
--gecos "WWW $in_login" \
--disabled-password \
www-"$in_login" \
--shell /bin/false \
${in_wwwuid:+'--uid' "$in_wwwuid"} \
--ingroup "$in_login" \
--force-badname \
--home "$HOME_DIR_USER"/www \
--no-create-home > /dev/null
elif [ "$WEB_SERVER" == "nginx" ]; then
# Adding user www-data to group $in_login.
# And primary group www-data for $in_login.
adduser www-data "$in_login"
usermod -g www-data "$in_login"
fi
# Get uid/gid for newly created accounts # Répertoires par défaut
uid=$(id -u "$in_login") mkdir -p $HOME_DIR_USER/{log,www,awstats}
gid=$(id -g "$in_login") chown $in_login:$in_login $HOME_DIR_USER/www
www_uid=$(id -u www-"$in_login") chgrp $in_login $HOME_DIR_USER/{log,awstats}
chmod 750 $HOME_DIR_USER/{log,www,awstats}
# Create users inside all containers # Ajout des logs par defaut
for php_version in "${PHP_VERSIONS[@]}"; do touch $HOME_DIR_USER/log/access.log
lxc-attach -n php"${php_version}" -- /usr/sbin/addgroup "$in_login" --gid "$gid" --force-badname >/dev/null touch $HOME_DIR_USER/log/error.log
lxc-attach -n php"${php_version}" -- /usr/sbin/adduser --gecos "User $in_login" --disabled-password "$in_login" --shell /bin/bash --uid "$uid" --gid "$gid" --force-badname --home "$HOME_DIR_USER" >/dev/null touch $HOME_DIR_USER/log/php.log
lxc-attach -n php"${php_version}" -- [ -z "$in_sshkey" ] && echo "$in_login:$in_passwd" | chpasswd chgrp $in_login $HOME_DIR_USER/log/access.log
lxc-attach -n php"${php_version}" -- /usr/sbin/adduser --disabled-password --home "$HOME_DIR_USER"/www --no-create-home --shell /bin/false --gecos "WWW $in_login" www-"$in_login" --uid "$www_uid" --ingroup "$in_login" --force-badname >/dev/null chgrp $in_login $HOME_DIR_USER/log/error.log
done chown www-$in_login:$in_login $HOME_DIR_USER/log/php.log
chmod 640 $HOME_DIR_USER/log/access.log
chmod 640 $HOME_DIR_USER/log/error.log
chmod 640 $HOME_DIR_USER/log/php.log
if grep -qE '^AllowUsers' /etc/ssh/sshd_config; then step_ok "Création du répertoire personnel"
sed -i "s/^AllowUsers .*/& $in_login/" /etc/ssh/sshd_config
else
if getent group "$SSH_GROUP" 1>/dev/null 2>&1; then
usermod --append --groups "$SSH_GROUP" "$in_login"
fi
fi
/etc/init.d/ssh reload
step_ok "Création des utilisateurs" ############################################################################
############################################################################ random=$RANDOM
vhostfile="/etc/apache2/sites-available/${in_login}.conf"
if [ "$WEB_SERVER" == "apache" ]; then cat $TPL_VHOST | \
echo "www-$login: $login" >> /etc/aliases sed -e "s/XXX/$in_login/g ; s/SERVERNAME/$in_wwwdomain/ ; s/RANDOM/$random/ ; s#HOME_DIR#$HOME_DIR#" >$vhostfile
echo "$login: $WWWBOUNCE_MAIL" >> /etc/aliases
elif [ "$WEB_SERVER" == "nginx" ]; then
echo "$login: $WWWBOUNCE_MAIL" >> /etc/aliases
fi
newaliases
step_ok "Alias mail" # On active aussi example.com si domaine commence par "www." comme www.example
if echo $in_wwwdomain | grep '^www.' > /dev/null; then
subweb=`echo $in_wwwdomain | sed -e "s/www.//"`
sed -i -e "s/^\(.*\)#\(ServerAlias\).*$/\1\2 $subweb/" $vhostfile
fi
############################################################################ a2ensite $in_login >/dev/null
chmod 750 "$HOME_DIR_USER"/ step_ok "Configuration d'Apache"
# Répertoires par défaut ############################################################################
mkdir -p "$HOME_DIR_USER"/{log,www,awstats}
chown "$in_login":"$in_login" "$HOME_DIR_USER"/www
chgrp "$in_login" "$HOME_DIR_USER"/{log,awstats}
chmod 750 "$HOME_DIR_USER"/{log,www,awstats}
# Ajout des logs par defaut
touch "$HOME_DIR_USER"/log/access.log
touch "$HOME_DIR_USER"/log/error.log
touch "$HOME_DIR_USER"/log/php.log
chgrp "$in_login" "$HOME_DIR_USER"/log/access.log
chgrp "$in_login" "$HOME_DIR_USER"/log/error.log
if [ "$WEB_SERVER" == "apache" ]; then
chown www-"$in_login":"$in_login" "$HOME_DIR_USER"/log/php.log
fi
# There is no php.log for nginx ATM, it will go in error.log.
chmod 640 "$HOME_DIR_USER"/log/access.log
chmod 640 "$HOME_DIR_USER"/log/error.log
chmod 640 "$HOME_DIR_USER"/log/php.log
step_ok "Création du répertoire personnel"
############################################################################
if [ -n "$in_quota" ]; then
quota_soft=$(($(echo "$in_quota" |cut -f 1 -d:) * 1024 * 1024))
quota_hard=$(($(echo "$in_quota" |cut -f 2 -d:) * 1024 * 1024))
setquota --remote --user "$in_login" $quota_soft $quota_hard 0 0 /home
fi
############################################################################
# Create FPM pool on all containers.
for php_version in "${PHP_VERSIONS[@]}"; do
if [ "$php_version" = "70" ]; then
pool_path="/etc/php/7.0/fpm/pool.d/"
elif [ "$php_version" = "73" ]; then
pool_path="/etc/php/7.3/fpm/pool.d/"
elif [ "$php_version" = "74" ]; then
pool_path="/etc/php/7.4/fpm/pool.d/"
elif [ "$php_version" = "80" ]; then
pool_path="/etc/php/8.0/fpm/pool.d/"
elif [ "$php_version" = "81" ]; then
pool_path="/etc/php/8.1/fpm/pool.d/"
elif [ "$php_version" = "82" ]; then
pool_path="/etc/php/8.2/fpm/pool.d/"
else
pool_path="/etc/php5/fpm/pool.d/"
fi
phpfpm_socket_path="/home/${in_login}/php-fpm${php_version}.sock"
cat <<EOT >/var/lib/lxc/php"${php_version}"/rootfs/${pool_path}/"${in_login}".conf
[${in_login}]
user = www-${in_login}
group = ${in_login}
listen = ${phpfpm_socket_path}
listen.owner = ${in_login}
listen.group = ${in_login}
pm = ondemand
pm.status_path = /evolinux_fpm_status-$(apg -Mncl -n1 -m32)
pm.max_children = 10
pm.process_idle_timeout = 10s
php_admin_value[error_log] = /home/${in_login}/log/php.log
php_admin_value[sendmail_path] = "/usr/sbin/sendmail -t -i -f www-${in_login}@${HOST}"
php_admin_value[open_basedir] = "/usr/share/php:/home/${in_login}:/tmp"
EOT
step_ok "Création du pool FPM ${php_version}"
done
############################################################################
random=$RANDOM
if [ "$WEB_SERVER" == "apache" ]; then
# On s'assure que /etc/apache2/ssl pour le IncludeOptional de la conf
mkdir -p /etc/apache2/ssl
vhostfile="/etc/apache2/sites-available/${in_login}.conf"
sed -e "s/XXX/$in_login/g ; s/SERVERNAME/$in_wwwdomain/ ; s/RANDOM/$random/ ; s#HOME_DIR#$HOME_DIR#" < $TPL_VHOST > "$vhostfile"
if [ ${#PHP_VERSIONS[@]} -gt 0 ]; then
phpfpm_socket_path="/home/${in_login}/php-fpm${in_phpversion}.sock"
cat <<EOT >>"$vhostfile"
<Proxy "unix:${phpfpm_socket_path}|fcgi://localhost/" timeout=300>
</Proxy>
<FilesMatch "\\.php$">
SetHandler proxy:unix:${phpfpm_socket_path}|fcgi://localhost/
</FilesMatch>
</VirtualHost>
EOT
else
cat <<EOT >>"$vhostfile"
</VirtualHost>
EOT
fi
# On active aussi example.com si domaine commence par "www." comme www.example
if echo "$in_wwwdomain" | grep '^www.' > /dev/null; then
subweb="${in_wwwdomain#www.}"
sed -i -e "s/^\\(.*\\)#\\(ServerAlias\\).*$/\\1\\2 $subweb/" "$vhostfile"
fi
a2ensite "${in_login}.conf" >/dev/null
step_ok "Configuration d'Apache"
elif [ "$WEB_SERVER" == "nginx" ]; then
sed -e \
"s/DOMAIN/${in_wwwdomain}/g; s/LOGIN/${in_login}/g;" \
< "$TPL_VHOST" \
> ${VHOST_PATH}/"$in_login"
ln -s /etc/nginx/sites-available/"$in_login" \
/etc/nginx/sites-enabled/"$in_login"
/etc/init.d/nginx restart
step_ok "Configuration de Nginx + restart"
############################################################################
sed -e "s/SED_LOGIN/${in_login}/g;" \
< $TPL_FPM > ${FPM_PATH}/"${in_login}".conf
step_ok "Creation du pool PHP-FPM"
############################################################################
fi
cat $TPL_AWSTATS | \
sed -e "s/XXX/$in_login/ ; s/SERVERNAME/$in_wwwdomain/ ; s#HOME_DIR#$HOME_DIR#" \ sed -e "s/XXX/$in_login/ ; s/SERVERNAME/$in_wwwdomain/ ; s#HOME_DIR#$HOME_DIR#" \
< $TPL_AWSTATS > /etc/awstats/awstats."$in_login".conf > /etc/awstats/awstats.$in_login.conf
chmod 644 /etc/awstats/awstats."$in_login".conf chmod 644 /etc/awstats/awstats.$in_login.conf
VAR=$(grep -v "^#" /etc/cron.d/awstats |tail -1 | cut -d " " -f1) VAR=`grep -v "^#" /etc/cron.d/awstats |tail -1 | cut -d " " -f1`
if [ "$VAR" = "" ] || [ "$VAR" -ge 59 ]; then if [ "$VAR" = "" ] || [ $VAR -ge 59 ]; then
VAR=1 VAR=1
else else
VAR=$((VAR +1)) VAR=$(($VAR +1))
fi fi
echo "$VAR * * * * root umask 033; [ -x /usr/lib/cgi-bin/awstats.pl -a -f /etc/awstats/awstats.$in_login.conf -a -r $HOME_DIR_USER/log/access.log ] && /usr/lib/cgi-bin/awstats.pl -config=$in_login -update >/dev/null" >> /etc/cron.d/awstats echo "$VAR * * * * root umask 033; [ -x /usr/lib/cgi-bin/awstats.pl -a -f /etc/awstats/awstats.$in_login.conf -a -r $HOME_DIR_USER/log/access.log ] && /usr/lib/cgi-bin/awstats.pl -config=$in_login -update >/dev/null" >> /etc/cron.d/awstats
step_ok "Activation d'Awstats" step_ok "Activation d'Awstats"
############################################################################ ############################################################################
if [ "$in_dbname" ]; then if [ "$in_dbname" ]; then
echo "CREATE DATABASE \`$in_dbname\` $MYSQL_CREATE_DB_OPTS;" | mysql $MYSQL_OPTS echo "CREATE DATABASE \`$in_dbname\` $MYSQL_CREATE_DB_OPTS;" | mysql
echo "GRANT ALL PRIVILEGES ON \`$in_dbname\`.* TO \`$in_login\`@localhost IDENTIFIED BY '$in_dbpasswd';" | mysql $MYSQL_OPTS echo "GRANT ALL PRIVILEGES ON \`$in_dbname\`.* TO \`$in_login\`@localhost IDENTIFIED BY '$in_dbpasswd';" | mysql
echo "FLUSH PRIVILEGES;" | mysql $MYSQL_OPTS echo "FLUSH PRIVILEGES;" | mysql
my_cnf_file="$HOME_DIR_USER/.my.cnf" my_cnf_file="$HOME_DIR_USER/.my.cnf"
cat > "$my_cnf_file" <<-EOT cat >$my_cnf_file <<-EOT
[client] [client]
user = $in_login user = $in_login
password = "$in_dbpasswd" password = "$in_dbpasswd"
@ -549,536 +308,155 @@ password = "$in_dbpasswd"
[mysql] [mysql]
database = $in_dbname database = $in_dbname
EOT EOT
chown "$in_login" "$my_cnf_file" chown $in_login $my_cnf_file
chmod 600 "$my_cnf_file" chmod 600 $my_cnf_file
step_ok "Création base de données et compte MySQL" step_ok "Création base de données et compte MySQL"
fi fi
############################################################################ ############################################################################
if [ "$in_dbname" ]; then cat $TPL_MAIL | \
sed -e " sed -e "s/LOGIN/$in_login/g ; s/SERVERNAME/$in_wwwdomain/ ; s/PASSE1/$in_passwd/ ; s/PASSE2/$in_dbpasswd/ ; s/RANDOM/$random/ ; s/QUOTA/$quota/ ; s/RCPTTO/$in_mail/ ; s/DBNAME/$in_dbname/ ; s#HOME_DIR#$HOME_DIR#"| \
s/LOGIN/$in_login/g ; /usr/lib/sendmail -oi -t -f "$CONTACT_MAIL"
s/SERVERNAME/$in_wwwdomain/ ;
s/PASSE1/$in_passwd/ ;
s/PASSE2/$in_dbpasswd/ ;
s/RANDOM/$random/ ;
s/QUOTA/$quota/ ;
s/RCPTTO/$in_mail/ ;
s/DBNAME/$in_dbname/ ;
s#HOME_DIR#$HOME_DIR#" \
< $TPL_MAIL | /usr/lib/sendmail -oi -t -f "$CONTACT_MAIL"
else
sed -e "
s/LOGIN/$in_login/g ;
s/SERVERNAME/$in_wwwdomain/ ;
s/PASSE1/$in_passwd/ ;
s/RANDOM/$random/ ;
s/QUOTA/$quota/ ;
s/RCPTTO/$in_mail/ ;
s#HOME_DIR#$HOME_DIR# ;
39,58d" \
< $TPL_MAIL | /usr/lib/sendmail -oi -t -f "$CONTACT_MAIL"
fi
step_ok "Envoi du mail récapitulatif" step_ok "Envoi du mail récapitulatif"
############################################################################ ############################################################################
if [ -f $LOCAL_SCRIPT ]; then if [ -f $LOCAL_SCRIPT ]; then
# shellcheck source=/usr/share/scripts/evoadmin/web-add.local.sh source $LOCAL_SCRIPT
source $LOCAL_SCRIPT fi
fi
step_ok "Exécution du script spécifique" step_ok "Exécution du script spécifique"
############################################################################ ############################################################################
if [ "$WEB_SERVER" == "apache" ]; then apache2ctl configtest 2>/dev/null
apache2ctl configtest 2>/dev/null /etc/init.d/apache2 force-reload >/dev/null
/etc/init.d/apache2 force-reload >/dev/null
for php_version in "${PHP_VERSIONS[@]}"; do
if [ "$php_version" = "70" ]; then
initscript_path="/etc/init.d/php7.0-fpm"
binary="php-fpm7.0"
elif [ "$php_version" = "73" ]; then
initscript_path="/etc/init.d/php7.3-fpm"
binary="php-fpm7.3"
elif [ "$php_version" = "74" ]; then
initscript_path="/etc/init.d/php7.4-fpm"
binary="php-fpm7.4"
elif [ "$php_version" = "80" ]; then
initscript_path="/etc/init.d/php8.0-fpm"
binary="php-fpm8.0"
elif [ "$php_version" = "81" ]; then
initscript_path="/etc/init.d/php8.1-fpm"
binary="php-fpm8.1"
elif [ "$php_version" = "82" ]; then
initscript_path="/etc/init.d/php8.2-fpm"
binary="php-fpm8.2"
else
initscript_path="/etc/init.d/php5-fpm"
binary="php5-fpm"
fi
lxc-attach -n php"${php_version}" -- $binary --test >/dev/null
lxc-attach -n php"${php_version}" -- $initscript_path restart >/dev/null
step_ok "Rechargement de php-fpm dans php${php_version}"
done
step_ok "Rechargement d'Apache" step_ok "Rechargement d'Apache"
fi
############################################################################ ############################################################################
if [ "$WEB_SERVER" == "nginx" ]; then DATE=$(date +"%Y-%m-%d")
fpm_status=$(echo -n "$in_login" | md5sum | cut -d' ' -f1) echo "$DATE [web-add.sh] Ajout $in_login" >> /var/log/evolix.log
cat <<EOT> /etc/munin/plugin-conf.d/phpfpm_"${in_login}"_
[phpfpm_${in_login}_*]
env.url http://munin:%d/fpm_status_$fpm_status
env.ports 80
env.phpbin php-fpm
env.phppool $in_login
EOT
for name in average connections memory processes status; do
ln -s /usr/local/share/munin/plugins/phpfpm_${name} \
/etc/munin/plugins/phpfpm_"${in_login}"_${name}
done
cat <<EOT>> /etc/nginx/evolinux.d/munin-plugins.conf
# $in_login FPM Status page. Secret part is md5 of pool name.
location ~ ^/fpm_status_${fpm_status}$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm-${in_login}.sock;
fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name;
allow 127.0.0.1;
deny all;
}
EOT
sed -i "s#SED_STATUS#/fpm_status_${fpm_status}#" \
${FPM_PATH}/"${in_login}".conf
/etc/init.d/nginx reload
/etc/init.d/${FPM_SERVICE_NAME} reload
/etc/init.d/munin-node restart
step_ok "Configuration plugin php-fpm pour munin"
fi
############################################################################
DATE=$(date +"%Y-%m-%d")
echo "$DATE [web-add.sh] Ajout $in_login" >> /var/log/evolix.log
} }
op_del() { op_del() {
if [ $# -lt 1 ]; then
# usage
# Mode interactif exit 1
# else
login=$1
if [ $# -eq 0 ]; then if [ $# -eq 2 ]; then
echo dbname=$2
echo "Suppression d'un compte WEB"
echo
until [ "$login" ]; do
echo -n "Entrez le login du compte à supprimer : "
read -r tmp
login="$tmp"
done
echo -n "Voulez-vous aussi supprimer un compte/base MySQL ? [y|N]"
read -r confirm
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
echo -n "Entrez le nom de la base de donnees ($login par defaut) : "
read -r tmp
if [ -z "$tmp" ]; then
dbname=$login
else
dbname="$tmp"
fi
fi
#
# Mode non interactif
#
else
while getopts hy opt; do
case "$opt" in
y)
force_confirm=1
;;
h)
usage
exit 1
;;
?)
usage
exit 1
;;
esac
done
shift $((OPTIND - 1))
if [ $# -gt 0 ] && [ $# -le 2 ]; then
login=$1
if [ $# -eq 2 ]; then
dbname=$2
fi
else
usage
exit 1
fi
fi fi
fi
echo echo "Deleting account $login. Continue ?"
echo "----------------------------------------------" read
echo "Nom du compte : $login"
if [ "$dbname" ]; then
echo "Base de données MySQL : $dbname"
fi
echo "----------------------------------------------"
echo
if [ -z "$force_confirm" ]; then set -x
echo -n "Confirmer la suppression ? [y/N] : " userdel $login
read -r tmp userdel www-$login
echo groupdel $login
if [ "$tmp" != "y" ] && [ "$tmp" != "Y" ]; then sed -i.bak "/^$login:/d" /etc/aliases
echo "Annulation..." sed -i.bak "/^www-$login:/d" /etc/aliases
echo
exit 1
fi
fi
if grep -E '^AllowUsers' /etc/ssh/sshd_config; then
sed -i "s/^\(AllowUsers .*\)$login/\1/" /etc/ssh/sshd_config
/etc/init.d/ssh reload
fi
if [ -d "$HOME_DIR/$login" ]; then
mv -i $HOME_DIR/$login $HOME_DIR/$login.`date '+%Y%m%d-%H%M%S'`.bak
else
echo "warning : $HOME_DIR/$login does not exist"
fi
a2dissite $login
rm /etc/apache2/sites-available/$login.conf
rm /etc/awstats/awstats.$login.conf
sed -i.bak "/-config=$login /d" /etc/cron.d/awstats
apache2ctl configtest
set +x
if [ -n "$dbname" ]; then
echo "Deleting mysql DATABASE $dbname and mysql user $login. Continue ?"
read
set -x set -x
# Crontab dump needs to be done **before** user deletion echo "DROP DATABASE $dbname; delete from mysql.user where user='$login' ; FLUSH PRIVILEGES;" | mysql
if crontab -l -u "$login"; then
crontab -l -u "$login" &> /home/$login/crontab-$(date '+%Y%m%d-%H%M%S').bak
crontab -r -u "$login"
fi
# Deactivate web vhost (apache or nginx)
if [ "$WEB_SERVER" == "apache" ]; then
if a2query -s "${login}" >/dev/null 2&>1; then
a2dissite "${login}.conf"
fi
rm -f /etc/apache2/sites-available/"$login.conf"
apache2ctl configtest
for php_version in "${PHP_VERSIONS[@]}"; do
if [ "$php_version" = "70" ]; then
phpfpm_dir="/etc/php/7.0/fpm/pool.d/"
initscript_path="/etc/init.d/php7.0-fpm"
elif [ "$php_version" = "73" ]; then
phpfpm_dir="/etc/php/7.3/fpm/pool.d/"
initscript_path="/etc/init.d/php7.3-fpm"
elif [ "$php_version" = "74" ]; then
phpfpm_dir="/etc/php/7.4/fpm/pool.d/"
initscript_path="/etc/init.d/php7.4-fpm"
elif [ "$php_version" = "80" ]; then
phpfpm_dir="/etc/php/8.0/fpm/pool.d/"
initscript_path="/etc/init.d/php8.0-fpm"
elif [ "$php_version" = "81" ]; then
phpfpm_dir="/etc/php/8.1/fpm/pool.d/"
initscript_path="/etc/init.d/php8.1-fpm"
elif [ "$php_version" = "82" ]; then
phpfpm_dir="/etc/php/8.2/fpm/pool.d/"
initscript_path="/etc/init.d/php8.2-fpm"
else
phpfpm_dir="/etc/php5/fpm/pool.d/"
initscript_path="/etc/init.d/php5-fpm"
fi
rm -f /var/lib/lxc/php"${php_version}"/rootfs/${phpfpm_dir}/"${login}".conf
lxc-attach -n php"${php_version}" -- $initscript_path restart >/dev/null
done
elif [ "$WEB_SERVER" == "nginx" ]; then
rm -f /etc/nginx/sites-{available,enabled}/"$login"
rm -f /etc/munin/plugins/phpfpm_"${in_login}"*
nginx -t
fi
rm -f /etc/awstats/awstats."$login.conf"
sed -i.bak "/-config=$login /d" /etc/cron.d/awstats
if [ "$WEB_SERVER" == "apache" ]; then
if id www-"$login" &> /dev/null; then
userdel -f www-"$login"
fi
for php_version in "${PHP_VERSIONS[@]}"; do
if lxc-attach -n php"${php_version}" -- getent passwd www-"$login" &> /dev/null; then
lxc-attach -n php"${php_version}" -- userdel -f www-"$login"
fi
if lxc-attach -n php"${php_version}" -- getent passwd "$login" &> /dev/null; then
lxc-attach -n php"${php_version}" -- userdel -f "$login"
fi
done
fi
if getent passwd "$login" &> /dev/null; then
userdel -f "$login"
fi
sed -i.bak "/^$login:/d" /etc/aliases
if [ "$WEB_SERVER" == "apache" ]; then
sed -i.bak "/^www-$login:/d" /etc/aliases
fi
if grep -qE '^AllowUsers' /etc/ssh/sshd_config; then
sed -i "s/^AllowUsers .*/& $in_login/" /etc/ssh/sshd_config
/etc/init.d/ssh reload
fi
if [ -d "$HOME_DIR/$login" ]; then
mv -i $HOME_DIR/"$login" $HOME_DIR/"$login"."$(date '+%Y%m%d-%H%M%S')".bak
else
echo "warning : $HOME_DIR/$login does not exist"
fi
if [ -d /etc/letsencrypt/"$login" ]; then
rm -r /etc/letsencrypt/"$login"
fi
set +x set +x
fi
if [ -n "$dbname" ]; then
set -x
echo "DROP DATABASE \`$dbname\`; DROP USER \`$login\`@localhost; FLUSH PRIVILEGES;" | mysql $MYSQL_OPTS
set +x
fi
}
op_setphpversion() {
if [ $# -ne 2 ]; then
usage
exit 1
fi
login="$1"
phpversion="$2"
validate_phpversion "$phpversion"
sed -i "s#^\\(\s*SetHandler proxy:unix:/home/.*/php-fpm\\)..\\(\\.sock\\)#\\1${phpversion}\\2#" /etc/apache2/sites-available/"${login}".conf
sed -i "s#^\\(\s*<Proxy .*unix:/home/.*/php-fpm\\)..\\(\\.sock\\)#\\1${phpversion}\\2#" /etc/apache2/sites-available/"${login}".conf
/etc/init.d/apache2 force-reload >/dev/null
DATE=$(date +"%Y-%m-%d")
echo "$DATE [web-add.sh] PHP version set to $phpversion for $login" >> /var/log/evolix.log
}
op_setquota() {
if [ $# -ne 2 ]; then
usage
exit 1
fi
login="$1"
quota="$2"
validate_quota "$quota"
quota_soft=$(($(echo "$quota" |cut -f 1 -d:) * 1024 * 1024))
quota_hard=$(($(echo "$quota" |cut -f 2 -d:) * 1024 * 1024))
setquota --remote --user "$login" $quota_soft $quota_hard 0 0 /home
DATE=$(date +"%Y-%m-%d")
echo "$DATE [web-add.sh] quota set to $quota for $login" >> /var/log/evolix.log
} }
arg_processing() { arg_processing() {
# Détermination de la commande # Détermination de la commande
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
usage usage
else else
commandname=$1 commandname=$1
shift shift
case "$commandname" in case "$commandname" in
add) add)
op_add "$@" op_add $*
;; ;;
del) del)
op_del "$@" op_del $*
;; ;;
list-vhost) list-vhost)
op_listvhost "$@" op_listvhost $*
;; ;;
check-vhosts)
op_checkvhosts "$@"
;;
add-alias) add-alias)
op_aliasadd "$@" op_aliasadd $*
;; ;;
del-alias) del-alias)
op_aliasdel "$@" op_aliasdel $*
;; ;;
update-servername) *)
op_servernameupdate "$@" usage
;; ;;
check-occurence) esac
op_checkoccurencename "$@" fi
;;
list-user-itk)
op_listuseritk "$@"
;;
enable-user-itk)
op_enableuseritk "$@"
;;
disable-user-itk)
op_disableuseritk "$@"
;;
setphpversion)
op_setphpversion "$@"
;;
setquota)
op_setquota "$@"
;;
manage-http-challenge-file)
op_managehttpchallengefile "$@"
;;
generate-csr)
op_makecsr "$@"
;;
generate-ssl-certificate)
op_generatesslcertificate "$@"
;;
version)
op_version "$@"
;;
*)
usage
;;
esac
fi
}
op_makecsr() {
if [ $# -gt 1 ]; then
vhost="$1"
domains=""
# remove the first argument to keep only the domains
shift 1
for domain in "$@"; do
domains="${domains:+${domains} }${domain}"
done
# pipe the domains to make-csr because we don't have STDIN
echo "$domains" | make-csr "$vhost"
else usage
fi
}
op_generatesslcertificate() {
if [ $# -gt 1 ]; then
vhost="$1"
test_mode="$2"
if [ "$test_mode" = "false" ]; then
if [ -L /etc/letsencrypt/$vhost/live ]; then
rm /etc/letsencrypt/$vhost/live
fi
evoacme "$vhost"
else
DRY_RUN=1 evoacme "$vhost"
fi
else usage
fi
}
op_managehttpchallengefile() {
if [ $# -eq 1 ]; then
folder="/var/lib/letsencrypt/.well-known"
file="testfile"
action=${1};
if [ "$action" = "create" ]; then
if [ ! -d "$folder" ]; then
mkdir -p "$folder/acme-challenge"
fi
if [ ! -f "$folder/acme-challenge/$file" ]; then
touch "$folder/acme-challenge/$file"
fi
chmod -R 755 "$folder"
elif [ "$action" = "delete" ]; then
rm -r "$folder"
else usage
fi
else usage
fi
} }
op_listvhost() { op_listvhost() {
if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
configlist="$VHOST_PATH/${1}.conf"; configlist="$VHOST_PATH/$1";
else else
configlist="$VHOST_PATH/*"; configlist="$VHOST_PATH/*";
fi
for configfile in $configlist; do
if [ -r "$configfile" ]; then
servername=`awk '/^[[:space:]]*ServerName (.*)/ { print $2 }' $configfile | head -n 1`
serveraliases=`perl -ne 'print $1 if /^[[:space:]]*ServerAlias (.*)/' $configfile | head -n 1`
serveraliases=`echo $serveraliases | sed 's/ \+/, /g'`
userid=`awk '/^[[:space:]]*AssignUserID.*/ { print $3 }' $configfile | head -n 1`
if [ "$servername" ] && [ "$userid" ]; then
configid=`basename $configfile`
echo "$userid:$configid:$servername:$serveraliases"
fi
fi fi
done
for configfile in $configlist; do
if [ -r "$configfile" ] && echo "$configfile" |grep -qvE "/(000-default|default-ssl|evoadmin)\\.conf$"; then
servername="$(awk '/^[[:space:]]*ServerName (.*)/ { print $2 }' "$configfile" | head -n 1)"
serveraliases="$(perl -ne 'print "$1 " if /^[[:space:]]*ServerAlias (.*)/' "$configfile" | head -n 1)"
serveraliases="$(echo $serveraliases | sed 's/ \+/,/g')"
userid="$(awk '/^[[:space:]]*AssignUserID.*/ { print $3 }' "$configfile" | head -n 1)"
if [ -x /usr/bin/quota ]; then
size=$(quota --no-wrap --human-readable "$userid" |grep /home |awk '{print $2}')
quota_soft=$(quota --no-wrap --human-readable "$userid" |grep /home |awk '{print $3}')
quota_hard=$(quota --no-wrap --human-readable "$userid" |grep /home |awk '{print $4}')
fi
phpversion=$(perl -lne 'print $1 if (m!^\s+SetHandler proxy:unix:/home/.*/php-fpm(\d{2})\.sock!)' "$configfile" | head -n 1)
if [ -e /etc/apache2/sites-enabled/"${userid}".conf ]; then
is_enabled=1
else
is_enabled=0
fi
count_virtualhosts="$(grep "<VirtualHost" "$configfile" | wc -l)"
if [ "$count_virtualhosts" -eq 1 ]; then
is_standard=1
else
is_standard=0
fi
if [ "$servername" ] && [ "$userid" ]; then
configid=$(basename "$configfile")
echo "$userid:$configid:$servername:$serveraliases:$size:$quota_soft:$quota_hard:$phpversion:$is_enabled:$is_standard"
fi
fi
done
} }
op_aliasadd() { op_aliasadd() {
if [ $# -eq 2 ]; then if [ $# -eq 2 ]; then
vhost="${1}.conf" vhost="${1}.conf"
alias=$2 alias=$2
vhost_file="${VHOST_PATH}/${vhost}"
if [ -f "${vhost_file}" ]; then [ -f $VHOST_PATH/$vhost ] && sed -i -e "s/\(ServerName .*\)/\1\n\tServerAlias $alias/" $VHOST_PATH/$vhost --follow-symlinks
sed -i "/ServerName .*/a \\\tServerAlias $alias" "${vhost_file}" --follow-symlinks
else
echo "VHost file \`${vhost_file}' not found'" >&2
return 1
fi
configtest_out=$(apache2ctl configtest) apache2ctl configtest 2>/dev/null
configtest_rc=$? /etc/init.d/apache2 force-reload >/dev/null
if [ "$configtest_rc" = "0" ]; then
/etc/init.d/apache2 force-reload >/dev/null
else
echo $configtest_out >&2
fi
else usage else usage
fi fi
} }
@ -1087,364 +465,191 @@ op_aliasdel() {
if [ $# -eq 2 ]; then if [ $# -eq 2 ]; then
vhost="${1}.conf" vhost="${1}.conf"
alias=$2 alias=$2
vhost_file="${VHOST_PATH}/${vhost}"
if [ -f "${vhost_file}" ]; then [ -f $VHOST_PATH/$vhost ] && sed -i -e "/ServerAlias $alias/d" $VHOST_PATH/$vhost --follow-symlinks
sed -i -e "/ServerAlias $alias/d" "${vhost_file}" --follow-symlinks
else
echo "VHost file \`${vhost_file}' not found'" >&2
return 1
fi
configtest_out=$(apache2ctl configtest) apache2ctl configtest 2>/dev/null
configtest_rc=$? /etc/init.d/apache2 force-reload >/dev/null
if [ "$configtest_rc" = "0" ]; then else usage
/etc/init.d/apache2 force-reload >/dev/null
else
echo $configtest_out >&2
fi
else
usage
fi
}
op_servernameupdate() {
if [ $# -eq 3 ]; then
vhost="${1}.conf"
servername=$2
old_servername=$3
vhost_file="${VHOST_PATH}/${vhost}"
if [ -f "${vhost_file}" ]; then
sed -i "/^ *ServerName/ s/$old_servername/$servername/g" "${vhost_file}" --follow-symlinks
sed -i "/^ *RewriteCond/ s/$old_servername/$servername/g" "${vhost_file}" --follow-symlinks
fi
configtest_out=$(apache2ctl configtest)
configtest_rc=$?
if [ "$configtest_rc" = "0" ]; then
/etc/init.d/apache2 force-reload >/dev/null
else
echo $configtest_out >&2
fi
else
usage
fi
}
op_checkoccurencename() {
if [ $# -eq 1 ]; then
name=${1}
configlist="$VHOST_PATH/*";
servernames=''
aliases=''
for configfile in $configlist; do
if [ -r "$configfile" ]; then
alias=$(perl -ne 'print "$1 " if /^[[:space:]]*ServerAlias (.*)/' "$configfile" | head -n 1)
aliases="$aliases $alias"
servername=$(awk '/^[[:space:]]*ServerName (.*)/ { print $2 }' "$configfile" | uniq)
servernames="$servernames $servername"
fi
done
echo "$servernames" "$aliases" | grep -E "(^|\s)$name(\s|$)"
else
usage
fi
}
op_listuseritk() {
if [ $# -eq 1 ]; then
configfile="$VHOST_PATH/${1}.conf"
awk '/AssignUserID/ {print $2}' "$configfile" | uniq
else
usage
fi
}
op_enableuseritk() {
if [ $# -eq 1 ]; then
configfile="$VHOST_PATH/${1}.conf"
group=$(awk '/AssignUserID/ {print $3}' "$configfile" | uniq)
sed -i "s/^ *AssignUserID $group/ AssignUserID www-$group/" "$configfile" --follow-symlinks
configtest_out=$(apache2ctl configtest)
configtest_rc=$?
if [ "$configtest_rc" = "0" ]; then
/etc/init.d/apache2 force-reload >/dev/null
else
echo $configtest_out >&2
fi
else
usage
fi
}
op_disableuseritk() {
if [ $# -eq 1 ]; then
configfile="$VHOST_PATH"/"${1}".conf
group=$(awk '/AssignUserID/ {print $3}' "$configfile" | uniq)
sed -i "s/^ *AssignUserID www-$group/ AssignUserID ${group}/" "$configfile" --follow-symlinks
configtest_out=$(apache2ctl configtest)
configtest_rc=$?
if [ "$configtest_rc" = "0" ]; then
/etc/init.d/apache2 force-reload >/dev/null
else
echo $configtest_out >&2
fi
else
usage
fi fi
} }
op_add() { op_add() {
# #
# Mode interactif # Mode interactif
# #
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
echo echo
echo "Ajout d'un compte WEB" echo "Ajout d'un compte WEB"
echo echo
until [ "$in_login" ]; do until [ "$in_login" ]; do
echo -n "Entrez le login du nouveau compte : " echo -n "Entrez le login du nouveau compte : "
read -r tmp read tmp
if validate_login "$tmp"; then if validate_login "$tmp"; then
in_login="$tmp" in_login="$tmp"
fi fi
done done
until [ "$in_passwd" ]; do until [ "$in_passwd" ]; do
echo -n "Entrez le mot de passe FTP/SFTP/SSH (ou vide pour aleatoire) : " echo -n "Entrez le mot de passe FTP/SFTP/SSH (ou vide pour aleatoire) : "
read -rs tmp read -s tmp
echo echo
if [ -z "$tmp" ]; then if [ -z "$tmp" ]; then
tmp=$(gen_random_passwd) tmp=`gen_random_passwd`
fi fi
if validate_passwd "$tmp"; then if validate_passwd "$tmp"; then
in_passwd="$tmp" in_passwd="$tmp"
fi fi
done done
echo -n "Voulez-vous aussi un compte/base MySQL ? [Y|n] " echo -n "Voulez-vous aussi un compte/base MySQL ? [Y|n] "
read -r confirm read confirm
if [ "$confirm" != "n" ] && [ "$confirm" != "N" ]; then if [ "$confirm" != "n" ] && [ "$confirm" != "N" ]; then
until [ "$in_dbname" ]; do until [ "$in_dbname" ]; do
echo -n "Entrez le nom de la base de donnees ($in_login par defaut) : " echo -n "Entrez le nom de la base de donnees ($in_login par defaut) : "
read -r tmp read tmp
if [ -z "$tmp" ]; then if [ -z "$tmp" ]; then
tmp=$in_login tmp=$in_login
fi
if validate_dbname "$tmp"; then
in_dbname="$tmp"
fi
done
until [ "$in_dbpasswd" ]; do
echo -n "Entrez le mot de passe MySQL (ou vide pour aleatoire) : "
read -rs tmp
echo
if [ -z "$tmp" ]; then
tmp=$(gen_random_passwd)
fi
if validate_passwd "$tmp"; then
in_dbpasswd="$tmp"
fi
done
fi fi
until [ "$in_wwwdomain" ]; do if validate_dbname "$tmp"; then
echo -n "Entrez le nom de domaine web (ex: foo.example.com) : " in_dbname="$tmp"
read -r tmp fi
if validate_wwwdomain "$tmp"; then done
in_wwwdomain="$tmp"
fi
done
if [ ${#PHP_VERSIONS[@]} -gt 0 ]; then until [ "$in_dbpasswd" ]; do
until [ "$in_phpversion" ]; do echo -n "Entrez le mot de passe MySQL (ou vide pour aleatoire) : "
echo -n "Entrez la version de PHP désirée parmis ${PHP_VERSIONS[*]} : " read -s tmp
read -r tmp echo
if validate_phpversion "$tmp"; then
in_phpversion="$tmp" if [ -z "$tmp" ]; then
fi tmp=`gen_random_passwd`
done
fi fi
until [ "$in_mail" ]; do if validate_passwd "$tmp"; then
echo -n "Entrez votre adresse mail pour recevoir le mail de creation ($CONTACT_MAIL par défaut) : " in_dbpasswd="$tmp"
read -r tmp fi
if [ -z "$tmp" ]; then done
tmp="$CONTACT_MAIL" fi
fi
if validate_mail "$tmp"; then
in_mail="$tmp"
fi
done
# until [ "$in_wwwdomain" ]; do
# Mode non interactif echo -n "Entrez le nom de domaine web (ex: foo.example.com) : "
# read tmp
if validate_wwwdomain "$tmp"; then
in_wwwdomain="$tmp"
fi
done
until [ "$in_mail" ]; do
echo -n "Entrez votre adresse mail pour recevoir le mail de creation ($CONTACT_MAIL par défaut) : "
read tmp
if [ -z "$tmp" ]; then
tmp="$CONTACT_MAIL"
fi
if validate_mail "$tmp"; then
in_mail="$tmp"
fi
done
#
# Mode non interactif
#
else
while getopts hyp:m:P:w:l:k:u:g:U: opt; do
case "$opt" in
p)
in_passwd=$OPTARG
;;
m)
in_dbname=$OPTARG
;;
P)
in_dbpasswd=$OPTARG
;;
l)
in_mail=$OPTARG
;;
k)
in_sshkey=$OPTARG
;;
y)
force_confirm=1
;;
u)
in_uid=$OPTARG
;;
g)
in_gid=$OPTARG
;;
U)
in_wwwuid=$OPTARG
;;
h)
usage
exit 1
;;
?)
usage
exit 1
;;
esac
done
shift $(($OPTIND - 1))
if [ $# -ne 2 ]; then
usage
exit 1
else else
while getopts hyp:m:P:w:l:k:u:g:U:r:q: opt; do in_login=$1
case "$opt" in in_wwwdomain=$2
p) validate_login $in_login || exit 1
in_passwd=$OPTARG [ -z "$in_passwd" ] && [ -z "$in_sshkey" ] && in_passwd=`gen_random_passwd`
;; [ -z "$in_sshkey" ] && ( validate_passwd $in_passwd || exit 1 )
m) [ -n "$in_dbname" ] && ( validate_dbname $in_dbname || exit 1 )
in_dbname=$OPTARG [ -z "$in_dbpasswd" ] && [ -n "$in_dbname" ] && in_dbpasswd=`gen_random_passwd`
;; [ -n "$in_dbname" ] && ( validate_passwd $in_dbpasswd || exit 1 )
P) validate_wwwdomain $in_wwwdomain || exit 1
in_dbpasswd=$OPTARG [ -z "$in_mail" ] && in_mail=$CONTACT_MAIL
;; validate_mail $in_mail || exit 1
l)
in_mail=$OPTARG
;;
k)
in_sshkey=$OPTARG
;;
y)
force_confirm=1
;;
u)
in_uid=$OPTARG
;;
g)
in_gid=$OPTARG
;;
U)
in_wwwuid=$OPTARG
;;
r)
in_phpversion=$OPTARG
;;
q)
in_quota=$OPTARG
;;
h)
usage
exit 1
;;
?)
usage
exit 1
;;
esac
done
shift $((OPTIND - 1))
if [ $# -ne 2 ]; then
usage
exit 1
else
in_login=$1
in_wwwdomain=$2
validate_login "$in_login" || exit 1
[ -z "$in_passwd" ] && [ -z "$in_sshkey" ] && in_passwd=$(gen_random_passwd)
[ -z "$in_sshkey" ] && ( validate_passwd "$in_passwd" || exit 1 )
[ -n "$in_dbname" ] && ( validate_dbname "$in_dbname" || exit 1 )
[ -z "$in_dbpasswd" ] && [ -n "$in_dbname" ] && in_dbpasswd=$(gen_random_passwd)
[ -n "$in_dbname" ] && ( validate_passwd "$in_dbpasswd" || exit 1 )
validate_wwwdomain "$in_wwwdomain" || exit 1
[ -z "$in_mail" ] && in_mail=$CONTACT_MAIL
validate_mail $in_mail || exit 1
[ -n "$in_phpversion" ] && (validate_phpversion "$in_phpversion" || exit 1)
[ -n "$in_quota" ] && (validate_quota "$in_quota" || exit 1)
fi
fi fi
fi
echo
echo "----------------------------------------------"
echo "Nom du compte : $in_login"
echo "Mot de passe : $in_passwd"
if [ "$in_dbname" ]; then
echo "Base de données MySQL : $in_dbname"
echo "Mot de passe MySQL : $in_dbpasswd"
fi
echo "Nom de domaine : $in_wwwdomain"
echo "Envoi du mail récapitulatif à : $in_mail"
echo "----------------------------------------------"
echo
if [ -z "$force_confirm" ]; then
echo -n "Confirmer la création ? [y/N] : "
read tmp
echo echo
echo "----------------------------------------------" if [ "$tmp" != "y" ] && [ "$tmp" != "Y" ]; then
echo "Nom du compte : $in_login" echo "Annulation..."
echo "Mot de passe : $in_passwd" echo
if [ "$in_dbname" ]; then exit 1
echo "Base de données MySQL : $in_dbname"
echo "Mot de passe MySQL : $in_dbpasswd"
fi fi
echo "Nom de domaine : $in_wwwdomain" fi
if [ ${#PHP_VERSIONS[@]} -gt 0 ]; then
echo "version de PHP : $in_phpversion"
fi
echo "Quota : $in_quota"
echo "Envoi du mail récapitulatif à : $in_mail"
echo "----------------------------------------------"
echo
if [ -z "$force_confirm" ]; then create_www_account
echo -n "Confirmer la création ? [y/N] : " echo
read -r tmp echo " => Compte $in_login créé avec succès"
echo echo
if [ "$tmp" != "y" ] && [ "$tmp" != "Y" ]; then
echo "Annulation..."
echo
exit 1
fi
fi
create_www_account
echo
echo " => Compte $in_login créé avec succès"
echo
}
# Some people forget to use the --follow-symlinks flag with sed(1),
# thus not carrying changes over to /etc/sites-available.
op_checkvhosts() {
ln_vhosts_dir="$(sed 's/available/enabled/' <<< "$VHOST_PATH")"
non_ln_vhosts="$(find "$ln_vhosts_dir"/* ! -type l)"
while getopts f opt; do
case "$opt" in
f)
apply=1
;;
?)
usage
exit 1
;;
esac
done
for ln_path in $non_ln_vhosts
do
vhost_name=$(basename "$ln_path")
fix_conf="mv $ln_path $VHOST_PATH/$vhost_name"
fix_ln="a2ensite ${vhost_name}.conf"
if [[ -z "$apply" ]]; then
echo "Suggested fixes for $vhost_name:"
echo "diff $ln_path $VHOST_PATH/$vhost_name"
echo "$fix_conf"
echo "$fix_ln"
else
$fix_conf
$fix_ln
fi
done
}
# Return web-add.sh version
op_version(){
echo "$VERSION"
} }
# Point d'entrée # Point d'entrée
arg_processing "$@" arg_processing $*

View file

@ -1,72 +0,0 @@
From: Equipe Evolix <equipe@evolix.fr>
To: RCPTTO
Bcc: alert3@evolix.fr
Subject: Parametres hebergement web : LOGIN
Bonjour,
Votre compte d'hebergement web a ete cree.
**********************************
* CONNEXION SFTP/SSH
**********************************
NOM DU SERVEUR : %SERVER_NAME%
USER : LOGIN
PASSWORD : PASSE1
*****************************************
* Details sur l'environnement NginX/PHP
*****************************************
URL du site :
http://SERVERNAME
Repertoire de connexion : HOME_DIR/LOGIN/
Repertoire pour site web : HOME_DIR/LOGIN/www/
PHP tourne en www-data:www-data c'est-a-dire qu'il a acces
uniquement *en lecture* aux differents fichiers/repertoires (a condition
d'avoir 'g=rx' sur les repertoires et 'g=r' sur les fichiers ce qui est le
comportement par defaut).
Lorsqu'on a besoin d'autoriser *l'ecriture* pour certains fichiers/repertoires,
il suffit d'ajouter le droit 'g+w'.
***********************************
* MySQL
***********************************
SERVEUR : 127.0.0.1
PORT DU SERVEUR : 3306
USER : LOGIN
PASSWORD : PASSE2
NOM BASE : DBNAME
URL interface d'admin :
%PMA_URL%
***********************************
* Rappels divers
***********************************
Votre nom de domaine doit etre configure pour pointer sur l'adresse IP
(enregistrement DNS A) ou etre un alias de (enregistrement DNS CNAME).
Si vous avez besoin de faire des tests, vous devez ajouter la ligne suivante au
fichier "/etc/hosts" sous Linux/Unix ou au fichier "system32\drivers\etc\hosts"
sous Windows :
%SERVER_ADDR% SERVERNAME
Attention, par defaut, toutes les connexions vers l'exterieur sont bloquees. Si
vous avez besoin de recuperer des donnees a l'exterieur (flux RSS, BDD externe,
etc.), contactez nous afin de mettre en oeuvre les autorisations necessaires.
Si vous desirez mettre en place des parametres particuliers pour votre site
(PHP, etc.) ou pour tout autre demande (scripts en crontab, etc.), n'hesitez
pas a nous contacter a l'adresse %MAIL_STANDARD% (ou %MAIL_URGENT% si
votre demande est urgente).
Cordialement,
--
Equipe Evolix <equipe@evolix.fr>
Evolix http://www.evolix.fr/

View file

@ -13,7 +13,9 @@
* @version 1.0 * @version 1.0
*/ */
?>
<?php
if(!empty($exec_info)) { if(!empty($exec_info)) {
print '<pre>'; print '<pre>';
if ($conf['debug'] == TRUE) if ($conf['debug'] == TRUE)
@ -21,7 +23,7 @@
if ($exec_info[1]) { if ($exec_info[1]) {
print "La commande a <strong>échoué</strong>\n"; print "La commande a <strong>échoué</strong>\n";
print_r($exec_info); print_r($exec_info);
} }
else print "Le compte a été créé avec succès\n"; else print "Le compte a été créé avec succès\n";
@ -32,21 +34,12 @@
print '</pre>'; print '</pre>';
} else { } else {
// If there is validation errors, display them
if (isset($errors_check)) {
print '<p class="form-error"><strong>Erreur(s) : </strong><br>';
foreach ($errors_check as $error) {
printf('%s<br>', $error);
}
print '</p>';
}
?> ?>
<form name="form-add" id="form-add" action="" method="POST"> <form name="form-add" id="form-add" action="" method="POST">
<fieldset> <fieldset>
<legend>Ajout d'un compte</legend> <legend>Ajout d'un compte</legend>
<?= $form ?> <?php print $form; ?>
<p><input type="submit" value="Créer"/></p> <p><input type="submit" value="Créer"/></p>
</fieldset> </fieldset>
</form> </form>

View file

@ -1,46 +1,43 @@
<?php <?php
/** /**
* Authentification page * Authentification form
* *
* Copyright (c) 2009-2022 Evolix - Tous droits reserves * Copyright (c) 2009 Evolix - Tous droits reserves
* *
* @author Evolix <info@evolix.fr> * vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
* @author Gregory Colpart <reg@evolix.fr> *
* @author Thomas Martin <tmartin@evolix.fr> * @author Gregory Colpart <reg@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr> * @author Thomas Martin <tmartin@evolix.fr>
* @author and others. * @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0 * @version 1.0
*/ */
?> ?>
<h2>Evoadmin : Connexion</h2> <br/><br/>
<form method="POST"> <form method="POST">
<table align="center"> <table width="300" align="center">
<tr> <tr>
<td align="right">Utilisateur : &nbsp;</td> <td align="right">Utilisateur : &nbsp;</td>
<td align="left"><input type="text" name="login" /></td> <td align="left"><input type="text" name="login" /></td>
</tr> </tr>
<tr> <tr>
<td align="right">Mot de passe : &nbsp;</td> <td align="right">Mot de passe : &nbsp;</td>
<td align="left"><input type="password" name="passw" /></td> <td align="left"><input type="password" name="passw" /></td>
</tr> </tr>
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<td align="left"><br/><input type="submit" value="Connexion" /></td> <td align="left"><br/><input type="submit" value="Connexion" /></td>
</tr> </tr>
<?php <?php
if (!empty($error)) { if (!empty($error)) {
?> ?>
<tr> <tr>
<td colspan="2" class="auth-error"> <td colspan="2" class="auth-error">Identifiants invalides. Veuillez -essayer</td>
Identifiants invalides. </tr>
Veuillez -essayer <?php
</td> }
</tr> ?>
<?php
}
?>
</table> </table>
</form> </form>

View file

@ -1,42 +0,0 @@
<?php
/**
* Databases management page template
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0
*/
?>
<div class="container">
<h2>Bases de données</h2><hr>
<?php if(count($db_list) > 0) { ?>
<table id="tab-list" class="table table-striped table-condensed">
<thead>
<tr>
<th>Propriétaire</th>
<th>Bases de données</th>
</tr>
</thead>
<tbody>
<?php foreach($db_list as $db_info) {
print '<tr>';
printf('<td align="left">&nbsp;&nbsp;%s</td>', preg_replace("/'/", "", $db_info['owner']));
printf('<td align="left">&nbsp;&nbsp;%s</td>', $db_info['database']);
print '</tr>';
} ?>
</tbody>
</table>
<?php
} else {
print '<div class="alert alert-info" role="alert">Aucune base existante !</div>';
}
?>
</div>

View file

@ -21,7 +21,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Evoadmin-web - Powered by Evolix</title> <title>EvoAdmin - Powered by Evolix</title>
<link rel="stylesheet" href="/inc/css/main.css" type="text/css" media="screen, projection" /> <link rel="stylesheet" href="/inc/css/main.css" type="text/css" media="screen, projection" />
<script type="text/javascript" src="/inc/js/lib/prototype-1.6.0.3.js"></script> <script type="text/javascript" src="/inc/js/lib/prototype-1.6.0.3.js"></script>
<script type="text/javascript" src="/inc/js/ftpadmin.js"></script> <script type="text/javascript" src="/inc/js/ftpadmin.js"></script>
@ -31,10 +31,10 @@
<body> <body>
<div id="main"> <div id="main">
<h1 id="top">Evoadmin-web <h1 id="top">EvoAdmin
<?php <?php
if(!empty($_SESSION['user'])) { if(!empty($_SESSION['user'])) {
print ' v'.$_SESSION['cli_version'].' - '.$_SESSION['user']; print ' - '.$_SESSION['user'];
if(is_superadmin()) { if(is_superadmin()) {
print ' (Administrateur)'; print ' (Administrateur)';

View file

@ -25,9 +25,6 @@
<li><a href="/ftpadmin/add">Ajout FTP</a></li> <li><a href="/ftpadmin/add">Ajout FTP</a></li>
<li><a href="/ftpadmin">Comptes FTP</a></li> <li><a href="/ftpadmin">Comptes FTP</a></li>
<?php } ?> <?php } ?>
<?php if ($conf['dbadmin']) { ?>
<li><a href="/dbadmin">Bases de données</a></li>
<?php } ?>
<li><a href="/destroy">Déconnexion</a></li> <li><a href="/destroy">Déconnexion</a></li>
</ul> </ul>
<br/> <br/>

View file

@ -1,36 +0,0 @@
<?php
/**
* Suppression d'un compte web
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Thomas Martin <tmartin@evolix.fr>
* @version 1.0
*/
?>
<h2>Suppression du compte web</h2>
<form name="form-delete-vhost" id="form-add" action="" method="POST">
<fieldset>
<p>
<label for="vhost-name">Nom du compte :</label>
<input type="text" name="vhost-name">
</p>
<p>
<label for="vhost-delete-db">Supprimer la base de données ? :</label>
<input id="vhost-delete-db" name="vhost-delete-db" checked="checked" value="1" type="checkbox">
</p>
<p>
<label for="vhost-dbname">Nom de la base de données :</label>
<input type="text" name="vhost-dbname" id="vhost-dbname">
</p>
<p>
<input type="submit" name="delete-vhost" value="Supprimer">
</p>
</fieldset>
</form>

View file

@ -5,7 +5,7 @@
* *
* Copyright (c) 2009 Evolix - Tous droits reserves * Copyright (c) 2009 Evolix - Tous droits reserves
* *
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2 * vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
* *
* @author Thomas Martin <tmartin@evolix.fr> * @author Thomas Martin <tmartin@evolix.fr>
* @version 1.0 * @version 1.0
@ -15,13 +15,14 @@
<h2>Server Alias</h2> <h2>Server Alias</h2>
<?php <?php
if ($conf['cluster']) {
if(count($alias_list) > 0) {
if(count($alias_list) > 0) {
if (is_superadmin()) { if (is_superadmin()) {
print "<center>"; print "<center>";
printf('<p><a href="/webadmin/%s/alias/add/">Ajouter un alias</a></p>', $domain); printf('<p><a href="/webadmin/edit/%s?add">Ajouter un alias</a></p>', $domain);
print "</center>"; print "</center>";
}?> }?>
@ -35,27 +36,29 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
for ( $i=0; $i < count($alias_list); ++$i ) { for ( $i=0; $i < count($alias_list); ++$i ) {
print '<tr>'; print '<tr>';
printf('<td>%s</td>', printf('<td><a href="http://%s">http://%s</a></td>',
$alias_list[$i]['alias'], $alias_list[$i]['alias']); $alias_list[$i]['alias'], $alias_list[$i]['alias']);
if (is_superadmin()) if (is_superadmin())
printf('<td><a href="/webadmin/%s/alias/delete/%s/">Supprimer</a></td>', printf('<td><a href="/webadmin/edit/%s?del=%s">Supprimer</a></td>',
$domain, $alias_list[$i]['alias']); $domain, $alias_list[$i]['alias']);
print '</tr>'; print '</tr>';
} ?> } ?>
</tbody> </tbody>
</table> </table>
<?php <?php
} else { } else {
print "<p>Aucun alias existant pour le domaine $domain !</p>"; print "<p>Aucun alias existant pour le domaine $domain !</p>";
if (is_superadmin()) { if (is_superadmin()) {
print "<center>"; print "<center>";
printf('<p><a href="/webadmin/%s/alias/add/">Ajouter un alias</a></p>', $domain); printf('<p><a href="/webadmin/edit/%s?add">Ajouter un alias</a></p>', $domain);
print "</center>"; print "</center>";
} }
} }
}
?> ?>

View file

@ -1,58 +0,0 @@
<?php
/**
* Edition d'un domaine
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Thomas Martin <tmartin@evolix.fr>
* @version 1.0
*/
?>
<h2>Sécurité ITK</h2>
<?php
if(!empty($user_itk)) { ?>
<table id="tab-list">
<thead>
<tr>
<th>Utilisateur</th>
<?php if (is_superadmin()) {
print '<th>Action</th>';
} ?>
</tr>
</thead>
<tbody>
<?php
print '<tr>';
printf('<td>%s</td>',
$user_itk);
if (is_superadmin()) {
if (strpos($user_itk, 'www') !== false) {
$action = ['disable', 'Désactiver'];
} else {
$action = ['enable', 'Activer'];
}
printf('<td><a href="/webadmin/%s/itk/%s/">'.$action[1].'</a></td>',
$domain, $action[0]);
}
print '</tr>';
?>
</tbody>
</table>
<?php
} else {
print "<p>La sécurité ITK ne semble pas en place pour le domaine $domain</p>";
}
?>

View file

@ -1,53 +0,0 @@
<h2>Gestion Let's Encrypt</h2>
<?php
if (isset($_POST['submit'])) {
if (!empty($errorMessage)) {
echo '<span class="form-error">' . $errorMessage . '</span>';
if (count($failed_domains) > 0) {
echo '<p>';
foreach ($failed_domains as $failed_domain) {
echo $failed_domain . "<br>";
}
echo '</p>';
}
} else {
echo "Votre certificat SSL a bien été installé !";
}
} else {
if (!empty($errorMessage)) {
echo '<span class="form-error">' . $errorMessage . '</span>';
if (count($failed_domains) > 0) {
echo '<p>';
foreach ($failed_domains as $failed_domain) {
echo $failed_domain . "<br>";
}
echo '</p>';
}
} elseif (!empty($warningMessage)) {
echo '<span class="form-warning">' . $warningMessage . '</span>'; ?>
<form name="form-confirm-renew-cert" id="form-confirm-renew-cert" action="" method="POST">
<p>
<input type="hidden" name="force_renew">
<input type="submit" name="submit" value="Confirmer l'installation" style="margin-left:0px;">
</p>
</form>
<?php
} else {
echo "<p>Les domaines suivants seront intégrés au certificat : </p>";
if (count($_SESSION['letsencrypt-domains']) > 0) {
echo '<p>';
foreach ($_SESSION['letsencrypt-domains'] as $domain) {
echo $domain . '<br>';
}
echo '</p>';
?>
<form name="form-confirm-install-cert" id="form-confirm-install-cert" action="" method="POST">
<p><input type="submit" name="submit" value="Installer le certificat" style="margin-left:0px;"></p>
</form>
<?php
}
}
}

View file

@ -1,26 +0,0 @@
<?php
/**
* Edition d'un domaine
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Thomas Martin <tmartin@evolix.fr>
* @version 1.0
*/
?>
<h2>Version PHP</h2>
<p>Version actuelle de PHP : <?= preg_replace("/^(\d)(\d)$/", '\1.\2', $current_PHP_version) ?></p>
<form name="form-add" id="form-add" action="" method="POST">
<fieldset>
<legend>Changement de version de PHP</legend>
<?= $form ?>
<p><input type="submit" value="Changer"/></p>
</fieldset>
</form>

View file

@ -1,49 +0,0 @@
<?php
/**
* Edition d'un domaine
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Thomas Martin <tmartin@evolix.fr>
* @version 1.0
*/
?>
<h2>Servername</h2>
<?php
if(!empty($servername)) { ?>
<table id="tab-list">
<thead>
<tr>
<th>Servername</th>
<?php if (is_superadmin()) {
print '<th>Action</th>';
} ?>
</tr>
</thead>
<tbody>
<?php
print '<tr>';
printf('<td>%s</td>',
$servername);
if (is_superadmin())
printf('<td><a href="/webadmin/%s/domain/edit/%s/">Modifier</a></td>',
$domain, $servername);
print '</tr>';
?>
</tbody>
</table>
<?php
} else {
print "<p>Aucun Servername existant pour le domaine $domain !</p>";
}
?>

View file

@ -5,7 +5,7 @@
* *
* Copyright (c) 2009 Evolix - Tous droits reserves * Copyright (c) 2009 Evolix - Tous droits reserves
* *
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2 * vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
* *
* @author Gregory Colpart <reg@evolix.fr> * @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr> * @author Thomas Martin <tmartin@evolix.fr>
@ -15,36 +15,16 @@
?> ?>
<h2>Liste des comptes web</h2> <h2>Domaines</h2>
<?php if(count($vhost_list) > 0) { ?> <?php if(count($vhost_list) > 0) { ?>
<table id="tab-list"> <table id="tab-list">
<thead> <thead>
<tr> <tr>
<?php if(is_superadmin()) { <?php if(is_superadmin()) {
print '<th>Virtual Host</th>'; print '<th>Propriétaire</th>';
} ?> } ?>
<th>Servername</th> <th>Domaine</th>
<?php if(is_superadmin()) {
print '<th>Alias</th>';
}
if($conf['quota']) {
print '<th>&nbsp;Utilisé&nbsp;</th>';
print '<th>&nbsp;Soft&nbsp;</th>';
print '<th>&nbsp;Hard&nbsp;</th>';
print '<th>&nbsp;Occupation&nbsp;</th>';
}
if (array_key_exists('php_versions', $conf) && count($conf['php_versions']) > 1) {
print '<th>&nbsp;PHP&nbsp;</th>';
}
?>
<th>&nbsp;Actif ?&nbsp;</th>
<?php if(is_superadmin()) {
print '<th>Administration</th>';
}
?>
<!--<th>Opérations</th>--> <!--<th>Opérations</th>-->
<?php if($conf['cluster']) { ?> <?php if($conf['cluster']) { ?>
<th>Bdd</th> <th>Bdd</th>
@ -52,8 +32,10 @@
<th>Replication</th> <th>Replication</th>
<th>Master</th> <th>Master</th>
<th>Slave</th> <th>Slave</th>
<?php } ?> <?php if(is_superadmin()) {
</tr> print '<th>Alias</th>';
}} ?>
<tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach($vhost_list as $vhost_info) { <?php foreach($vhost_list as $vhost_info) {
@ -61,72 +43,45 @@
if(is_superadmin()) { if(is_superadmin()) {
printf('<td>%s</td>', $vhost_info['owner']); printf('<td>%s</td>', $vhost_info['owner']);
} }
printf('<td>%s</td>', printf('<td><a href="http://%s">http://%s</a></td>',
$vhost_info['server_name'], $vhost_info['server_name']); $vhost_info['server_name'], $vhost_info['server_name']);
if ($conf['cluster']) { if ($conf['cluster']) {
if (empty($vhost_info['bdd'])) if (empty($vhost_info['bdd']))
printf('<td bgcolor="#696969"/>'); printf('<td bgcolor="#696969"/>');
else else
printf('<td>%s</td>', $vhost_info['bdd']); printf('<td>%s</td>', $vhost_info['bdd']);
if (empty($vhost_info['mail'])) if (empty($vhost_info['mail']))
printf('<td bgcolor="#696969" />'); printf('<td bgcolor="#696969" />');
else if ($vhost_info['mail'] == 'gmail') else if ($vhost_info['mail'] == 'gmail')
printf('<td><img src="/img/gmail.gif" alt="Gmail" /></td>'); printf('<td><img src="/img/gmail.gif" alt="Gmail" /></td>');
else printf('<td><img src="/img/evolix.gif" alt="Evolix" /></td>'); else printf('<td><img src="/img/evolix.gif" alt="Evolix" /></td>');
if (empty($vhost_info['replication'])) if (empty($vhost_info['replication']))
printf('<td bgcolor="#696969"/>'); printf('<td bgcolor="#696969"/>');
else else
printf('<td>%s</td>', $vhost_info['replication']); printf('<td>%s</td>', $vhost_info['replication']);
printf('<td>%s</td>', $vhost_info['master']); printf('<td>%s</td>', $vhost_info['master']);
if (empty($vhost_info['slave'])) if (empty($vhost_info['slave']))
printf('<td bgcolor="#696969"/>'); printf('<td bgcolor="#696969"/>');
else else
printf('<td>%s</td>', $vhost_info['slave']); printf('<td>%s</td>', $vhost_info['slave']);
}
else {
printf('<td>%s</td>', $vhost_info['server_alias']);
} }
printf('<td>%s</td>', preg_replace('/,/','<br />',$vhost_info['server_alias']));
if ($conf['quota']) {
printf('<td>%s</td>', $vhost_info['size']);
printf('<td>%s</td>', $vhost_info['quota_soft']);
printf('<td>%s</td>', $vhost_info['quota_hard']);
printf('<td>%s</td>', $vhost_info['occupation']);
}
if (array_key_exists('php_versions', $conf) && count($conf['php_versions']) > 1) {
printf('<td>%s</td>', preg_replace("/^(\d)(\d)$/", '\1.\2', $vhost_info['php_version']));
}
printf('<td>%s</td>', ($vhost_info['is_enabled'] ? 'Activé' : 'Désactivé' ));
if (is_superadmin()) { if (is_superadmin()) {
printf('<td>'); printf('<td><a href="/webadmin/edit/%s">Lister/Modifier</a></td>',
if (!in_array($vhost_info['owner'], $_SESSION['non_standard'])) { $vhost_info['owner']);
printf('<a href="/webadmin/%s/alias/">Alias</a> - ', $vhost_info['owner']);
printf('<a href="/webadmin/%s/domain/">Servername</a> - ', $vhost_info['owner']);
if(is_multiphp()) {
printf('<a href="/webadmin/%s/php/">PHP</a> - ', $vhost_info['owner']);
} else {
printf('<a href="/webadmin/%s/itk/">ITK</a> - ', $vhost_info['owner']);
}
printf('<a href="/webadmin/%s/letsencrypt/">Let\'s Encrypt</a> - ', $vhost_info['owner']);
printf('<a href="/webadmin/delete/%s">Supprimer</a>', $vhost_info['owner']);
} else {
print '<span class="form-mandatory-ok">VirtualHost non standard</span>';
}
printf('</td>');
} }
print '</tr>'; print '</tr>';
} ?> } ?>
</tbody> </tbody>
</table> </table>
<br>
Nombre total de comptes : <?= count($vhost_list); ?>
<?php <?php
} else { } else {
print '<p>Aucun domaine existant !</p>'; print '<p>Aucun domaine existant !</p>';